[PATCH] usb: typec: tcpm: allow external charger detection to set USB_TYPE

From: Daniel Baluta

Date: Fri Nov 06 2026 - 07:09:31 EST


From: Li Jun <jun.li@xxxxxxx>

Teach tcpm_psy_set_prop() to accept writes of
POWER_SUPPLY_PROP_USB_TYPE and store the value in port->usb_type, and
advertise the BC1.2 USB types (SDP/DCP/CDP/ACA) in
psy_desc.usb_types so power_supply_set_property() callers are not
rejected by power_supply_has_property().

This is a prerequisite for a follow-up PHY charger-detection driver
that calls power_supply_set_property() on the tcpm-backed power
supply once it determines the attached BC1.2 charger type.

Signed-off-by: Li Jun <jun.li@xxxxxxx>
Signed-off-by: Daniel Baluta <daniel.baluta@xxxxxxx>
---
drivers/usb/typec/tcpm/tcpm.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index d721baef52104..24f4e8854f37f 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -8766,6 +8766,10 @@ static int tcpm_psy_set_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_CURRENT_NOW:
ret = tcpm_aug_set_op_curr(port, val->intval / 1000);
break;
+ case POWER_SUPPLY_PROP_USB_TYPE:
+ port->usb_type = val->intval;
+ ret = 0;
+ break;
default:
ret = -EINVAL;
break;
@@ -8807,7 +8811,11 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
port_dev_name);
port->psy_desc.name = psy_name;
port->psy_desc.type = POWER_SUPPLY_TYPE_USB;
- port->psy_desc.usb_types = BIT(POWER_SUPPLY_USB_TYPE_C) |
+ port->psy_desc.usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
+ BIT(POWER_SUPPLY_USB_TYPE_DCP) |
+ BIT(POWER_SUPPLY_USB_TYPE_CDP) |
+ BIT(POWER_SUPPLY_USB_TYPE_ACA) |
+ BIT(POWER_SUPPLY_USB_TYPE_C) |
BIT(POWER_SUPPLY_USB_TYPE_PD) |
BIT(POWER_SUPPLY_USB_TYPE_PD_PPS) |
BIT(POWER_SUPPLY_USB_TYPE_PD_PPS_SPR_AVS) |
--
2.45.2