[PATCH v2 2/2] usb: misc: usb251xb: configure battery charging from DT
From: Jhon Wilker Rodrigues Aquino
Date: Tue Nov 03 2026 - 15:02:33 EST
From: Jhon Wilker Rodrigues Aquino <jhon.aquino@xxxxxxxxxxxxxxx>
Parse the battery-charging-enable port list from the device tree and set the corresponding bits in the hub configuration register.
Keep charging disabled by default when the property is omitted.
Signed-off-by: Jhon Wilker Rodrigues Aquino <jhon.aquino@xxxxxxxxxxxxxxx>
---
drivers/usb/misc/usb251xb.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index fb0693742f018..7c0086a554cfe 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -577,6 +577,11 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
(wchar_t *)hub->serial,
USB251XB_STRING_BUFSIZE);
+ hub->bat_charge_en = USB251XB_DEF_BATTERY_CHARGING_ENABLE;
+ if (data->bat_support)
+ usb251xb_get_ports_field(hub, "battery-charging-enable",
+ data->port_cnt, true, &hub->bat_charge_en);
+
/*
* The datasheet documents the register as 'Port Swap' but in real the
* register controls the USB DP/DM signal swapping for each port.
@@ -588,7 +593,6 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
/* The following parameters are currently not exposed to devicetree, but
* may be as soon as needed.
*/
- hub->bat_charge_en = USB251XB_DEF_BATTERY_CHARGING_ENABLE;
hub->boost_57 = USB251XB_DEF_BOOST_57;
hub->boost_14 = USB251XB_DEF_BOOST_14;
hub->port_map12 = USB251XB_DEF_PORT_MAP_12;
--
2.43.0