Re: [PATCH v3 4/4] power: tps65217_charger: add support for NTC type, voltage and current charge

From: Sebastian Reichel
Date: Thu Jun 08 2017 - 12:11:47 EST


Hi Enric,

On Fri, May 26, 2017 at 01:04:13PM +0200, Enric Balletbo i Serra wrote:
> Allow the possibility to configure the charge and the current voltage of
> the charger and also the NTC type for battery temperature measurement.
>
> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@xxxxxxxxxxxxx>
> ---
> Changes since v2:
> - Requested by Sebastian Reichel
> - Use the simple-battery framework
> - Use device_property_read_u32 instead of of_property_read_u32
> Changes since v1:
> - None
>
> drivers/power/supply/tps65217_charger.c | 194 ++++++++++++++++++++++++++++++--
> include/linux/mfd/tps65217.h | 2 +
> 2 files changed, 188 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/power/supply/tps65217_charger.c b/drivers/power/supply/tps65217_charger.c
> index 1f52340..5939e77 100644
> --- a/drivers/power/supply/tps65217_charger.c
> +++ b/drivers/power/supply/tps65217_charger.c
>
> [...]
>
> +#ifdef CONFIG_OF

You can drop the #ifdef CONFIG_OF. device_properties can also be
added via ACPI or boardcode and power_supply_get_battery_info is
always available (but will return -EINVAL values for !OF at the
moment).

> +static struct tps65217_charger_platform_data *tps65217_charger_pdata_init(
> + struct tps65217_charger *charger)
> +{
> + struct tps65217_charger_platform_data *pdata;
> + struct power_supply_battery_info info = {};
> + int ret;
> +
> + pdata = devm_kzalloc(charger->dev, sizeof(*pdata), GFP_KERNEL);
> + if (!pdata)
> + return ERR_PTR(-ENOMEM);
> +
> + /*
> + * If battery info is not supplied just ignore and program default
> + * values.
> + */
> + power_supply_get_battery_info(charger->psy, &info);
> +
> + if (info.charge_voltage_uv > 0)
> + pdata->charge_voltage_uv = info.charge_voltage_uv;
> + else
> + pdata->charge_voltage_uv = 4100000;
> +
> + if (info.charge_current_ua > 0)
> + pdata->charge_current_ua = info.charge_current_ua;
> + else
> + pdata->charge_current_ua = 500000;
> +
> + ret = device_property_read_u32(charger->dev, "ti,ntc-type",
> + &pdata->ntc_type);
> + if (ret)
> + pdata->ntc_type = 1; /* 10k (curve 2, B = 3480) */
> +
> + return pdata;
> +}
> +#else /* CONFIG_OF */
> +static struct tps65217_charger_platform_data *tps65217_charger_pdata_init(
> + struct tps65217_charger *charger)
> +{
> + return NULL;
> +}
> +#endif /* CONFIG_OF */
> +
> [...]
>

Otherwise looks fine to me.

-- Sebastian

Attachment: signature.asc
Description: PGP signature