[PATCH 06/11] power: supply: qcom_smbx: respect battery charge-term-current-microamp

Casey Connolly posted 11 patches 3 months, 3 weeks ago
[PATCH 06/11] power: supply: qcom_smbx: respect battery charge-term-current-microamp
Posted by Casey Connolly 3 months, 3 weeks ago
Respect the max current limit set on the battery node, one some devices
this is set conservatively to avoid overheating since they only have a
single charger IC (instead of two in parallel).

Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
---
 drivers/power/supply/qcom_smbx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/qcom_smbx.c b/drivers/power/supply/qcom_smbx.c
index fc2a8e20435639a9da4d966c43271beaeb57a03f..7fc232fa7260a7422ac12a48686cd7d396edd9a4 100644
--- a/drivers/power/supply/qcom_smbx.c
+++ b/drivers/power/supply/qcom_smbx.c
@@ -583,9 +583,9 @@ static void smb_status_change_work(struct work_struct *work)
 	case POWER_SUPPLY_USB_TYPE_CDP:
 		current_ua = CDP_CURRENT_UA;
 		break;
 	case POWER_SUPPLY_USB_TYPE_DCP:
-		current_ua = DCP_CURRENT_UA;
+		current_ua = chip->batt_info->constant_charge_current_max_ua;
 		break;
 	case POWER_SUPPLY_USB_TYPE_SDP:
 	default:
 		current_ua = SDP_CURRENT_UA;
@@ -989,8 +989,10 @@ static int smb_probe(struct platform_device *pdev)
 	rc = power_supply_get_battery_info(chip->chg_psy, &chip->batt_info);
 	if (rc)
 		return dev_err_probe(chip->dev, rc,
 				     "Failed to get battery info\n");
+	if (chip->batt_info->constant_charge_current_max_ua == -EINVAL)
+		chip->batt_info->constant_charge_current_max_ua = DCP_CURRENT_UA;
 
 	rc = devm_delayed_work_autocancel(chip->dev, &chip->status_change_work,
 					  smb_status_change_work);
 	if (rc)

-- 
2.49.0
Re: [PATCH 06/11] power: supply: qcom_smbx: respect battery charge-term-current-microamp
Posted by Sebastian Reichel 3 months, 2 weeks ago
Hi,

On Thu, Jun 19, 2025 at 04:55:14PM +0200, Casey Connolly wrote:
> Respect the max current limit set on the battery node, one some devices
> this is set conservatively to avoid overheating since they only have a
> single charger IC (instead of two in parallel).
> 
> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
> ---
>  drivers/power/supply/qcom_smbx.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/qcom_smbx.c b/drivers/power/supply/qcom_smbx.c
> index fc2a8e20435639a9da4d966c43271beaeb57a03f..7fc232fa7260a7422ac12a48686cd7d396edd9a4 100644
> --- a/drivers/power/supply/qcom_smbx.c
> +++ b/drivers/power/supply/qcom_smbx.c
> @@ -583,9 +583,9 @@ static void smb_status_change_work(struct work_struct *work)
>  	case POWER_SUPPLY_USB_TYPE_CDP:
>  		current_ua = CDP_CURRENT_UA;
>  		break;
>  	case POWER_SUPPLY_USB_TYPE_DCP:
> -		current_ua = DCP_CURRENT_UA;
> +		current_ua = chip->batt_info->constant_charge_current_max_ua;

"constant_charge_current_max_ua" is current information for the
battery. But current_ua is written to chip->base + USBIN_CURRENT_LIMIT_CFG,
which sounds like it would be current limit on the USB side?

Assuming the charger is using a buck converter to get from USB
voltage to battery voltage (very likely) the currents are
different.

Greetings,

-- Sebastian
Re: [PATCH 06/11] power: supply: qcom_smbx: respect battery charge-term-current-microamp
Posted by Konrad Dybcio 3 months, 2 weeks ago
On 6/19/25 4:55 PM, Casey Connolly wrote:
> Respect the max current limit set on the battery node, one some devices
> this is set conservatively to avoid overheating since they only have a
> single charger IC (instead of two in parallel).
> 
> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
> ---

The subject references a different, similar-sounding property

The change looks ok

Konrad