Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tcpm: allow external charger detection to set USB_TYPE
@ 2026-11-06 11:57 Daniel Baluta
  2026-11-06 12:10 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Baluta @ 2026-11-06 11:57 UTC (permalink / raw)
  To: badhri, heikki.krogerus
  Cc: gregkh, linux-usb, linux-kernel, stefan.ghetu, imx, Li Jun,
	Daniel Baluta

From: Li Jun <jun.li@nxp.com>

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@nxp.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
 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


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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06 11:57 [PATCH] usb: typec: tcpm: allow external charger detection to set USB_TYPE Daniel Baluta
2026-11-06 12:10 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox