[PATCH V2 3/5] power: supply: bq257xx: Add support for BQ257XX charger manager

Sebastian Reichel sebastian.reichel at collabora.com
Sun Jun 22 15:37:53 PDT 2025


On Sat, Jun 21, 2025 at 01:01:17PM -0500, Chris Morgan wrote:
> From: Chris Morgan <macromorgan at hotmail.com>
> 
> Add support for the charger function of the BQ257XX. The device is
> capable of charging batteries with a layout of 1 to 4 cells in
> series.
> 
> Signed-off-by: Chris Morgan <macromorgan at hotmail.com>
> ---

[...]

> +static void bq257xx_external_power_changed(struct power_supply *psy)
> +{
> +	struct bq257xx_chg *pdata = power_supply_get_drvdata(psy);
> +	union power_supply_propval val;
> +	int ret;
> +	int imax = pdata->iindpm_max;
> +
> +	pdata->chip->bq257xx_get_state(pdata);
> +
> +	pdata->supplied = power_supply_am_i_supplied(pdata->charger);
> +	if (pdata->supplied < 0)
> +		return;
> +
> +	if (pdata->supplied == 0)
> +		goto out;
> +
> +	ret = power_supply_get_property_from_supplier(psy,
> +						      POWER_SUPPLY_PROP_USB_TYPE,
> +						      &val);
> +	if (ret)
> +		return;
> +
> +	pdata->usb_type = val.intval;
> +
> +	if ((pdata->usb_type == POWER_SUPPLY_USB_TYPE_PD) ||
> +	    (pdata->usb_type == POWER_SUPPLY_USB_TYPE_PD_DRP) ||
> +	    (pdata->usb_type == POWER_SUPPLY_USB_TYPE_PD)) {

Duplicated check for POWER_SUPPLY_USB_TYPE_PD.

> +		ret = power_supply_get_property_from_supplier(psy,
> +							      POWER_SUPPLY_PROP_CURRENT_MAX,
> +							      &val);
> +		if (ret)
> +			return;
> +
> +		if (val.intval)
> +			imax = val.intval;
> +	}
> +
> +	if (pdata->supplied) {
> +		pdata->chip->bq257xx_set_ichg(pdata, imax);
> +		pdata->chip->bq257xx_set_iindpm(pdata, imax);

Are you sure about this? ichg and iindpm are two completley separate
things. One runs at USB bus voltage and one runs at battery charge
voltage. Setting both to the same current limit is a hint that
somebody did not understand what they are doing.

Otherwise the driver LGTM (apart from the documentation issue
reported by the bit of course).

Greetings,

-- Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-rockchip/attachments/20250623/63e71120/attachment.sig>


More information about the Linux-rockchip mailing list