usb: misc: usb251xb: add DT battery charging configuration
Subsystems (3)
cover usb: misc: usb251xb: add DT battery charging configuration
From: Jhon Wilker Rodrigues Aquino <[email protected]>
Add a Device Tree property to configure battery charging on selected downstream ports of Microchip USB251x hubs.
The first patch documents the battery-charging-enable property and adds an example enabling charging on ports 1 and 2. The second parses the port list and sets the corresponding hub configuration bits. Charging remains disabled on all ports when the property is omitted.
Jhon Wilker Rodrigues Aquino (2):
dt-bindings: usb: microchip,usb251xb: add battery-charging-enable
property
usb: misc: usb251xb: configure battery charging from DT
Documentation/devicetree/bindings/usb/usb251xb.yaml | 7 +++++++ drivers/usb/misc/usb251xb.c | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-)
--
2.43.0
PATCH 1/2 dt-bindings: usb: microchip,usb251xb: add battery-charging-enable property
From: Jhon Wilker Rodrigues Aquino <[email protected]>
Describe the battery-charging-enable property as a list of downstream ports in the USB251x device tree binding.
Add an example that enables charging on ports 1 and 2.
--- Documentation/devicetree/bindings/usb/usb251xb.yaml | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/usb/usb251xb.yaml +7 -0
@@ -230,6 +230,12 @@ properties: Specifies the time it takes from the time the host initiates the power-on sequence to a port until the port has adequate power. + battery-charging-enable: + $ref: /schemas/types.yaml#/definitions/uint32-array + description: | + Specifies the downstream ports which will have battery charging enabled. + Battery charging is disabled on all ports by default. + swap-dx-lanes: $ref: /schemas/types.yaml#/definitions/uint32-array description: |
@@ -264,6 +270,7 @@ examples: manufacturer = "Foo"; product = "Foo-Bar"; serial = "1234567890A"; + battery-charging-enable = <1 2>; /* correct misplaced usb connectors on port 1,2 */ swap-dx-lanes = <1 2>; };
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 1/2] dt-bindings: usb: microchip,usb251xb: add battery-charging-enable property
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines
From: Jhon Wilker Rodrigues Aquino <[email protected]>
Describe the battery-charging-enable property as a list of downstream ports in the USB251x device tree binding.
Add an example that enables charging on ports 1 and 2.
Signed-off-by Jhon Wilker Rodrigues Aquino <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH 2/2 usb: misc: usb251xb: configure battery charging from DT
In reply to Jhon Wilker Rodrigues AquinoFrom: Jhon Wilker Rodrigues Aquino <[email protected]>
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.
--- drivers/usb/misc/usb251xb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/misc/usb251xb.c +4 -1
@@ -577,6 +577,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, (wchar_t *)hub->serial, USB251XB_STRING_BUFSIZE); + hub->bat_charge_en =USB251XB_DEF_BATTERY_CHARGING_ENABLE ; +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 +592,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 ;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 2/2] usb: misc: usb251xb: configure battery charging from DT
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] usb: misc: usb251xb: missing bat_support check in usb251xb_get_ofdata() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] usb: misc: usb251xb: missing bat_support check in usb251xb_get_ofdata() --
commit 7116fd963729fc92bbd453fc4d055b0129eabda3
Author: Jhon Wilker Rodrigues Aquino <[email protected]>
usb: misc: usb251xb: configure battery charging from DT
This commit parses the battery-charging-enable port list from the device tree to configure the battery charging enable register on USB251xB hubs.
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 582
Quoted 11 lines
drivers/usb/misc/usb251xb.c +3
-0@@ -577,6 +577,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, (wchar_t *)hub->serial, USB251XB_STRING_BUFSIZE); + hub->bat_charge_en =USB251XB_DEF_BATTERY_CHARGING_ENABLE ; +usb251xb_get_ports_field (hub,"battery-charging-enable" , data->port_cnt, + true, &hub->bat_charge_en);
[Severity: Medium]
Should parsing "battery-charging-enable" in usb251xb_get_ofdata() be gated on data->bat_support?
Commit dd99d106de25 ("usb: misc: usb251xb: Add structure for holding chip specific values") introduced bat_support in struct usb251xb_data, setting it to false for usb2517_data and usb2517i_data because the USB2517/USB2517i variants do not support battery charging:
static const struct usb251xb_data usb2517_data = {
.product_id = 0x2517,
.port_cnt = 7,
.led_support = true,
.bat_support = false,
.product_str = "USB2517",
};Earlier in usb251xb_get_ofdata(), the variant-specific LED property checks data->led_support before applying the configuration:
if (data->led_support && of_get_property(np, "led-usb-mode", NULL)) hub->conf_data3 &= ~BIT(1);
Without a similar check on data->bat_support here, bat_support remains unused and probing a USB2517 or USB2517i node with "battery-charging-enable" present in the device tree will populate hub->bat_charge_en and write non-zero values to the reserved register 0xD0 (USB251XB_ADDR_BATTERY_CHARGING_ENABLE) during usb251xb_connect().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
v2 cover usb: misc: usb251xb: add DT battery charging configuration
In reply to Jhon Wilker Rodrigues AquinoFrom: Jhon Wilker Rodrigues Aquino <[email protected]>
Add a Device Tree property to configure battery charging on selected downstream ports of Microchip USB251x hubs.
The first patch documents the battery-charging-enable property and adds an example enabling charging on ports 1 and 2. The second parses the port list and sets the corresponding hub configuration bits. Charging remains disabled on all ports when the property is omitted.
Changes in v2:
- Only parse battery-charging-enable when the chip variant supports battery charging.
Jhon Wilker Rodrigues Aquino (2):
dt-bindings: usb: microchip,usb251xb: add battery-charging-enable
property
usb: misc: usb251xb: configure battery charging from DT
Documentation/devicetree/bindings/usb/usb251xb.yaml | 7 +++++++ drivers/usb/misc/usb251xb.c | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-)
--
2.43.0
PATCH v2 1/2 dt-bindings: usb: microchip,usb251xb: add battery-charging-enable property
From: Jhon Wilker Rodrigues Aquino <[email protected]>
Describe the battery-charging-enable property as a list of downstream ports in the USB251x device tree binding.
Add an example that enables charging on ports 1 and 2.
--- Documentation/devicetree/bindings/usb/usb251xb.yaml | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/usb/usb251xb.yaml +7 -0
@@ -230,6 +230,12 @@ properties: Specifies the time it takes from the time the host initiates the power-on sequence to a port until the port has adequate power. + battery-charging-enable: + $ref: /schemas/types.yaml#/definitions/uint32-array + description: | + Specifies the downstream ports which will have battery charging enabled. + Battery charging is disabled on all ports by default. + swap-dx-lanes: $ref: /schemas/types.yaml#/definitions/uint32-array description: |
@@ -264,6 +270,7 @@ examples: manufacturer = "Foo"; product = "Foo-Bar"; serial = "1234567890A"; + battery-charging-enable = <1 2>; /* correct misplaced usb connectors on port 1,2 */ swap-dx-lanes = <1 2>; };
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 1/2] dt-bindings: usb: microchip,usb251xb: add battery-charging-enable property
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines
From: Jhon Wilker Rodrigues Aquino <[email protected]>
Describe the battery-charging-enable property as a list of downstream ports in the USB251x device tree binding.
Add an example that enables charging on ports 1 and 2.
Signed-off-by Jhon Wilker Rodrigues Aquino <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v2 1/2] dt-bindings: usb: microchip,usb251xb: add battery-charging-enable property
In reply to Jhon Wilker Rodrigues AquinoQuoted 1 line · Jhon Wilker Rodrigues Aquino
From: Jhon Wilker Rodrigues Aquino <[email protected]>
Do not attach (thread) your patchsets to some other threads (unrelated or older versions). This buries them deep in the mailbox and might interfere with applying entire sets. See also:
https://elixir.bootlin.com/linux/v6.16-rc2/source/Documentation/process/submitting-patches.rst#L830
Quoted 2 lines
Describe the battery-charging-enable property as a list of downstream ports in the USB251x device tree binding.
Please wrap commit message according to Linux coding style / submission process (neither too early nor over the limit):
https://elixir.bootlin.com/linux/v6.4-rc1/source/Documentation/process/submitting-patches.rst#L597
Please run scripts/checkpatch.pl on the patches and fix reported warnings. After that, run also 'scripts/checkpatch.pl --strict' on the patches and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.
Quoted 13 lines
Add an example that enables charging on ports 1 and 2.
Signed-off-by Jhon Wilker Rodrigues Aquino <[email protected]>--- Documentation/devicetree/bindings/usb/usb251xb.yaml | 7 +++++++ 1 file changed, 7 insertions(+)Documentation/devicetree/bindings/usb/usb251xb.yaml +0
-0
Documentation/devicetree/bindings/usb/usb251xb.yaml properties: · line 233
Quoted 4 lines
Documentation/devicetree/bindings/usb/usb251xb.yaml +1
-0@@ -230,6 +230,12 @@ properties: Specifies the time it takes from the time the host initiates the power-on sequence to a port until the port has adequate power. + battery-charging-enable:
Custom properties needs prefix, see writing bindings.
Documentation/devicetree/bindings/usb/usb251xb.yaml properties: · line 235
Quoted 2 lines
Documentation/devicetree/bindings/usb/usb251xb.yaml +2
-0+ $ref: /schemas/types.yaml#/definitions/uint32-array + description: |
Do not need '|' unless you need to preserve formatting.
Documentation/devicetree/bindings/usb/usb251xb.yaml properties: · line 237
Quoted 2 lines
Documentation/devicetree/bindings/usb/usb251xb.yaml +2
-0+ Specifies the downstream ports which will have battery charging enabled. + Battery charging is disabled on all ports by default.
Why wouldn't you enable charging on all ports? You have entire description (and/or commit msg) to explain why you are doing this and why this is exactly hardware property.
Best regards,
Krzysztof
PATCH v2 2/2 usb: misc: usb251xb: configure battery charging from DT
In reply to Jhon Wilker Rodrigues AquinoFrom: Jhon Wilker Rodrigues Aquino <[email protected]>
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.
--- drivers/usb/misc/usb251xb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/misc/usb251xb.c +5 -1
@@ -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 ;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 2/2] usb: misc: usb251xb: configure battery charging from DT
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines
From: Jhon Wilker Rodrigues Aquino <[email protected]>
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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2