All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] power: supply: qcom_battmgr: report the USB type from USB_ADAP_TYPE
@ 2026-10-07 12:39 Joonhoe Kim
  2026-10-12 10:43 ` Kamal Wadhwa
  0 siblings, 1 reply; 2+ messages in thread
From: Joonhoe Kim @ 2026-10-07 12:39 UTC (permalink / raw)
  To: sre; +Cc: konrad.dybcio, kamal.wadhwa, linux-arm-msm, linux-pm,
	linux-kernel

On SM8350 and SM8550 class firmware the USB power supply reads its
usb_type from the USB_TYPE property. On a Kaanapali (SM8850) tablet that
property is 1 (SDP) whatever is plugged in, while USB_ADAP_TYPE reports
the adapter, using the same numbering as POWER_SUPPLY_USB_TYPE_*:

  PC port                  USB_TYPE 1   USB_ADAP_TYPE 1 (SDP)
  USB-C dock, 5 V PD       USB_TYPE 1   USB_ADAP_TYPE 6 (PD)
  65 W PPS charger         USB_TYPE 1   USB_ADAP_TYPE 8 (PD_PPS)

Qualcomm's downstream qti_battery_charger driver also maps
USB_ADAP_TYPE to POWER_SUPPLY_PROP_USB_TYPE.

Request USB_ADAP_TYPE for POWER_SUPPLY_PROP_USB_TYPE instead.

Tested on a Lenovo Legion Tab Y700 gen 5 (qcom,kaanapali-pmic-glink,
which uses the SM8550 path). Only tested on this device; the SM8350
variant shares the property map and was not tested.

Assisted-by: LLM
Signed-off-by: Joonhoe Kim <26rote@gmail.com>
---
The downstream qti_battery_charger in SM8350, SM8450, SM8550, SM8650 and
SM7635 vendor kernels uses the same property ids, maps USB_ADAP_TYPE to
POWER_SUPPLY_PROP_USB_TYPE and reads it on every USB change, so the
firmware of this family should implement it. Like downstream, values
outside the enum (QC chargers, 0x80 and up there) are passed through.

Not tested with a plain DCP or a QC charger. Once, when the USB gadget
did not connect to the PC after plugging, USB_ADAP_TYPE read 4 (ACA)
until the cable was plugged again; when the gadget connects, the PC
port reads 1 (SDP).

Kamal Wadhwa's multi-port series makes the same switch for X1E80100
(a new x1e80100_usb_prop_map) [1]; this patch is for the shared SM8350/
SM8550 map, which that series leaves on USB_TYPE.

[1] https://lore.kernel.org/all/20260806-b4-battmgr-multiport-usb-v2-1-1a6dd1e06cc2@oss.qualcomm.com/

 drivers/power/supply/qcom_battmgr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index 7716eb9e1aff..b24860d2ded2 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -975,7 +975,7 @@ static const u8 sm8350_usb_prop_map[] = {
 	[POWER_SUPPLY_PROP_CURRENT_NOW] = USB_CURR_NOW,
 	[POWER_SUPPLY_PROP_CURRENT_MAX] = USB_CURR_MAX,
 	[POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT] = USB_INPUT_CURR_LIMIT,
-	[POWER_SUPPLY_PROP_USB_TYPE] = USB_TYPE,
+	[POWER_SUPPLY_PROP_USB_TYPE] = USB_ADAP_TYPE,
 };
 
 static int qcom_battmgr_usb_sm8350_update(struct qcom_battmgr *battmgr,
@@ -1513,7 +1513,7 @@ static void qcom_battmgr_sm8350_callback(struct qcom_battmgr *battmgr,
 		case USB_INPUT_CURR_LIMIT:
 			battmgr->usb.current_limit = le32_to_cpu(resp->intval.value);
 			break;
-		case USB_TYPE:
+		case USB_ADAP_TYPE:
 			battmgr->usb.usb_type = le32_to_cpu(resp->intval.value);
 			break;
 		default:
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] power: supply: qcom_battmgr: report the USB type from USB_ADAP_TYPE
  2026-10-07 12:39 [PATCH] power: supply: qcom_battmgr: report the USB type from USB_ADAP_TYPE Joonhoe Kim
@ 2026-10-12 10:43 ` Kamal Wadhwa
  0 siblings, 0 replies; 2+ messages in thread
From: Kamal Wadhwa @ 2026-10-12 10:43 UTC (permalink / raw)
  To: Joonhoe Kim; +Cc: sre, konrad.dybcio, linux-arm-msm, linux-pm, linux-kernel

On Wed, Oct 07, 2026 at 09:39:32PM +0900, Joonhoe Kim wrote:
> On SM8350 and SM8550 class firmware the USB power supply reads its
> usb_type from the USB_TYPE property. On a Kaanapali (SM8850) tablet that
> property is 1 (SDP) whatever is plugged in, while USB_ADAP_TYPE reports
> the adapter, using the same numbering as POWER_SUPPLY_USB_TYPE_*:
> 
>   PC port                  USB_TYPE 1   USB_ADAP_TYPE 1 (SDP) USB-C dock, 5 V
>   PD       USB_TYPE 1   USB_ADAP_TYPE 6 (PD) 65 W PPS charger
>   USB_TYPE 1   USB_ADAP_TYPE 8 (PD_PPS)
> 
> Qualcomm's downstream qti_battery_charger driver also maps
> USB_ADAP_TYPE to POWER_SUPPLY_PROP_USB_TYPE.
> 
> Request USB_ADAP_TYPE for POWER_SUPPLY_PROP_USB_TYPE instead.
> 
> Tested on a Lenovo Legion Tab Y700 gen 5 (qcom,kaanapali-pmic-glink,
> which uses the SM8550 path). Only tested on this device; the SM8350
> variant shares the property map and was not tested.
> 
> Assisted-by: LLM
> Signed-off-by: Joonhoe Kim <26rote@gmail.com>

Add fixes tag, with that i think it should be good to go.

Reviewed-by: Kamal Wadhwa <kamal.wadhwa@oss.qualcomm.com>

> --- The downstream qti_battery_charger in SM8350, SM8450, SM8550, SM8650 and
> SM7635 vendor kernels uses the same property ids, maps USB_ADAP_TYPE to
> POWER_SUPPLY_PROP_USB_TYPE and reads it on every USB change, so the firmware
> of this family should implement it. Like downstream, values outside the enum
> (QC chargers, 0x80 and up there) are passed through.
> 
> Not tested with a plain DCP or a QC charger. Once, when the USB gadget
> did not connect to the PC after plugging, USB_ADAP_TYPE read 4 (ACA)
> until the cable was plugged again; when the gadget connects, the PC
> port reads 1 (SDP).
> 
> Kamal Wadhwa's multi-port series makes the same switch for X1E80100
> (a new x1e80100_usb_prop_map) [1]; this patch is for the shared SM8350/
> SM8550 map, which that series leaves on USB_TYPE.
> 
> [1] https://lore.kernel.org/all/20260806-b4-battmgr-multiport-usb-v2-1-1a6dd1e06cc2@oss.qualcomm.com/
> 
>  drivers/power/supply/qcom_battmgr.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
> index 7716eb9e1aff..b24860d2ded2 100644
> --- a/drivers/power/supply/qcom_battmgr.c
> +++ b/drivers/power/supply/qcom_battmgr.c
> @@ -975,7 +975,7 @@ static const u8 sm8350_usb_prop_map[] = {
>  	[POWER_SUPPLY_PROP_CURRENT_NOW] = USB_CURR_NOW,
>  	[POWER_SUPPLY_PROP_CURRENT_MAX] = USB_CURR_MAX,
>  	[POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT] = USB_INPUT_CURR_LIMIT,
> -	[POWER_SUPPLY_PROP_USB_TYPE] = USB_TYPE,
> +	[POWER_SUPPLY_PROP_USB_TYPE] = USB_ADAP_TYPE,
>  };
>  
>  static int qcom_battmgr_usb_sm8350_update(struct qcom_battmgr *battmgr,
> @@ -1513,7 +1513,7 @@ static void qcom_battmgr_sm8350_callback(struct qcom_battmgr *battmgr,
>  		case USB_INPUT_CURR_LIMIT:
>  			battmgr->usb.current_limit = le32_to_cpu(resp->intval.value);
>  			break;
> -		case USB_TYPE:
> +		case USB_ADAP_TYPE:
>  			battmgr->usb.usb_type = le32_to_cpu(resp->intval.value);
>  			break;
>  		default:
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-12 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-07 12:39 [PATCH] power: supply: qcom_battmgr: report the USB type from USB_ADAP_TYPE Joonhoe Kim
2026-10-12 10:43 ` Kamal Wadhwa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.