usb: usb251xb: Add USB2517i hub support and fix some bugs
Subsystems (3)
cover usb: usb251xb: Add USB2517i hub support and fix some bugs
Primarily it was intended to just add USB2517 hub support to the driver. But after tests a bug and inconistency were discovered. So it was decided to perform following changes:
Changelog v1:
- Add USB2517/i hub specifics support to the driver
- Fix property_u32 NULL-pointer dereference
- Add new {bus,self}-max-{power,curret} dts properties
- Replace legacy GPIO API usage with descriptor-based one
Serge Semin (5):
usb: usb251xb: Add USB2517/i hub support
usb: usb251xb: Fix property_u32 NULL pointer dereference
usb: usb251xb: Add max power/current dts nodes
usb: usb251xb: Use GPIO descriptor consumer interface
usb: usb251xb: Add copyrights
Documentation/devicetree/bindings/usb/usb251xb.txt | 12 +- drivers/usb/misc/usb251xb.c | 154 +++++++++++++++------ 2 files changed, 123 insertions(+), 43 deletions(-)
Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/5 usb: usb251xb: Add USB2517/i hub support
USB2517i hubs are very like USB251xb devices series. They have almost the same configuration registers space except number of ports, led configurations and lack of battery settings. All these peculiarities are reflected in this patch.
--- Documentation/devicetree/bindings/usb/usb251xb.txt | 4 +- drivers/usb/misc/usb251xb.c | 84 +++++++++++++++++++--- 2 files changed, 78 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/usb/usb251xb.txt +3 -1
@@ -6,7 +6,8 @@ Hi-Speed Controller. Required properties : - compatible : Should be "microchip,usb251xb" or one of the specific types: "microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b", - "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi" + "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi", + "microchip,usb2517", "microchip,usb2517i" - reset-gpios : Should specify the gpio for hub reset - reg : I2C address on the selected bus (default is <0x2C>)
@@ -36,6 +37,7 @@ Optional properties : an invalid value is given, the default is used instead. - compound-device : indicate the hub is part of a compound device - port-mapping-mode : enable port mapping mode + - speed-led-mode : led speed indiation mode selection (usb2517 only) - string-support : enable string descriptor support (required for manufacturer, product and serial string configuration) - non-removable-ports : Should specify the ports which have a non-removable
drivers/usb/misc/usb251xb.c +75 -9
204 lines not on this page · raw message
Signature · 1 line
2.12.0
PATCH 2/5 usb: usb251xb: Fix property_u32 NULL pointer dereference
In reply to Serge SeminThe methods like of_property_read_u32 utilizing the specified pointer permit only the pointer to a preallocated u32 storage as the third argument. As a result the driver crashes on NULL pointer dereference in case if "oc-delay-us" or "power-on-time-ms" declared in dts file.
--- drivers/usb/misc/usb251xb.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/usb/misc/usb251xb.c +7 -7
@@ -348,7 +348,7 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,struct device *dev = hub->dev;struct device_node *np = dev->of_node;int len, err, i; -u32 *property_u32 =NULL ; +u32 property_u32 =0 ;const u32 *cproperty_u32;const char *cproperty_char;char str[USB251XB_STRING_BUFSIZE /2 ];
@@ -425,16 +425,16 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,if (of_get_property (np,"dynamic-power-switching" ,NULL )) hub->conf_data2 |=BIT (7 ); -if (!of_property_read_u32 (np,"oc-delay-us" , property_u32)) { -if (*property_u32 ==100 ) { +if (!of_property_read_u32 (np,"oc-delay-us" , &property_u32)) { +if (property_u32 ==100 ) {/* 100 us*/ hub->conf_data2 &= ~BIT (5 ); hub->conf_data2 &= ~BIT (4 ); - }else if (*property_u32 ==4000 ) { + }else if (property_u32 ==4000 ) {/* 4 ms */ hub->conf_data2 &= ~BIT (5 ); hub->conf_data2 |=BIT (4 ); - }else if (*property_u32 ==16000 ) { + }else if (property_u32 ==16000 ) {/* 16 ms */ hub->conf_data2 |=BIT (5 ); hub->conf_data2 |=BIT (4 );
@@ -494,8 +494,8 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, } hub->power_on_time =USB251XB_DEF_POWER_ON_TIME ; -if (!of_property_read_u32 (np,"power-on-time-ms" , property_u32)) - hub->power_on_time =min_t (u8, *property_u32 /2 ,255 ); +if (!of_property_read_u32 (np,"power-on-time-ms" , &property_u32)) + hub->power_on_time =min_t (u8, property_u32 /2 ,255 );if (of_property_read_u16_array (np,"language-id" , &hub->lang_id,1 )) hub->lang_id =USB251XB_DEF_LANGUAGE_ID ;
Signature · 1 line
2.12.0
PATCH 3/5 usb: usb251xb: Add max power/current dts nodes
In reply to Serge SeminThis parameters may be varied in accordance with hardware specifics. So lets add the corresponding settings to the usb251x driver dts specification.
--- Documentation/devicetree/bindings/usb/usb251xb.txt | 6 ++++++ drivers/usb/misc/usb251xb.c | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/usb/usb251xb.txt +6 -0
@@ -44,6 +44,12 @@ Optional properties : device connected. - sp-disabled-ports : Specifies the ports which will be self-power disabled - bp-disabled-ports : Specifies the ports which will be bus-power disabled + - sp-max-{power,current} : Indicates the power/current consumed by hub from + an upstream port (VBUS) when operation as a self-powered hub. The value + is given in mA in a 0 - 100 range (default is 1mA). + - bp-max-{power,current} : Indicates the power/current consumed by hub from + an upstream port (VBUS) when operation as a bus-powered hub. The value + is given in mA in a 0 - 510 range (default is 100mA). - power-on-time-ms : Specifies the time it takes from the time the host initiates the power-on sequence to a port until the port has adequate power. The value is given in ms in a 0 - 510 range (default is 100ms).
drivers/usb/misc/usb251xb.c +16 -4
@@ -493,6 +493,22 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, } } + hub->max_power_sp =USB251XB_DEF_MAX_POWER_SELF ; +if (!of_property_read_u32 (np,"sp-max-power" , &property_u32)) + hub->max_power_sp =min_t (u8, property_u32 /2 ,50 ); + + hub->max_power_bp =USB251XB_DEF_MAX_POWER_BUS ; +if (!of_property_read_u32 (np,"bp-max-power" , &property_u32)) + hub->max_power_bp =min_t (u8, property_u32 /2 ,255 ); + + hub->max_current_sp =USB251XB_DEF_MAX_CURRENT_SELF ; +if (!of_property_read_u32 (np,"sp-max-current" , &property_u32)) + hub->max_current_sp =min_t (u8, property_u32 /2 ,50 ); + + hub->max_current_bp =USB251XB_DEF_MAX_CURRENT_BUS ; +if (!of_property_read_u32 (np,"bp-max-current" , &property_u32)) + hub->max_current_bp =min_t (u8, property_u32 /2 ,255 ); + hub->power_on_time =USB251XB_DEF_POWER_ON_TIME ;if (!of_property_read_u32 (np,"power-on-time-ms" , &property_u32)) hub->power_on_time =min_t (u8, property_u32 /2 ,255 );
@@ -532,10 +548,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->max_power_sp =USB251XB_DEF_MAX_POWER_SELF ; - hub->max_power_bp =USB251XB_DEF_MAX_POWER_BUS ; - hub->max_current_sp =USB251XB_DEF_MAX_CURRENT_SELF ; - hub->max_current_bp =USB251XB_DEF_MAX_CURRENT_BUS ; hub->bat_charge_en =USB251XB_DEF_BATTERY_CHARGING_ENABLE ; hub->boost_up =USB251XB_DEF_BOOST_UP ; hub->boost_57 =USB251XB_DEF_BOOST_57 ;
Signature · 1 line
2.12.0
PATCH 4/5 usb: usb251xb: Use GPIO descriptor consumer interface
In reply to Serge SeminThe driver used to be developed with legacy GPIO API support. It's better to use descriptor-based interface for several reasons. First of all the legacy API doesn't support the ACTIVE_LOW/HIGH flag of dts nodes, which is essential since different hardware may have different GPIOs connectivity including the logical value inversion. Secondly, by requesting the reset GPIO descriptor the driver prevent the other applications from changing its value. And last but not least the legacy GPIO interface should be avoided in the new code due to it obsolescence.
--- Documentation/devicetree/bindings/usb/usb251xb.txt | 2 +- drivers/usb/misc/usb251xb.c | 33 +++++++++------------- 2 files changed, 14 insertions(+), 21 deletions(-)
Documentation/devicetree/bindings/usb/usb251xb.txt +1 -1
@@ -8,10 +8,10 @@ Required properties : "microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b", "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi", "microchip,usb2517", "microchip,usb2517i" - - reset-gpios : Should specify the gpio for hub reset - reg : I2C address on the selected bus (default is <0x2C>) Optional properties : + - reset-gpios : Should specify the gpio for hub reset - skip-config : Skip Hub configuration, but only send the USB-Attach command - vendor-id : Set USB Vendor ID of the hub (16 bit, default is 0x0424) - product-id : Set USB Product ID of the hub (16 bit, default depends on type)
drivers/usb/misc/usb251xb.c +13 -20
@@ -20,12 +20,11 @@*/ #include <linux/delay.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/module.h> #include <linux/nls.h> #include <linux/of_device.h> -#include <linux/of_gpio.h> #include <linux/slab.h> /* Internal Register Set Addresses & Default Values acc. to DS00001692C */
@@ -127,7 +126,7 @@ struct usb251xb {struct device *dev;struct i2c_client *i2c;u8 skip_config; -int gpio_reset; +struct gpio_desc *gpio_reset;u16 vendor_id;u16 product_id;u16 device_id;
@@ -235,13 +234,13 @@ static const struct usb251xb_data usb2517i_data = {static void usb251xb_reset (struct usb251xb *hub,int state) { -if (!gpio_is_valid (hub->gpio_reset)) +if (!hub->gpio_reset)return ; -gpio_set_value_cansleep (hub->gpio_reset, state); +gpiod_set_value_cansleep (hub->gpio_reset, state);/* wait for hub recovery/stabilization */ -if (state) +if (!state)usleep_range (500 ,750 );/* >=500us at power on */ else usleep_range (1 ,10 );/* >=1us at power down */
@@ -260,7 +259,7 @@ static int usb251xb_connect(struct usb251xb *hub) i2c_wb[0 ] =0x01 ; i2c_wb[1 ] =USB251XB_STATUS_COMMAND_ATTACH ; -usb251xb_reset (hub,1 ); +usb251xb_reset (hub,0 ); err =i2c_smbus_write_i2c_block_data (hub->i2c,USB251XB_ADDR_STATUS_COMMAND ,2 , i2c_wb);
@@ -310,7 +309,7 @@ static int usb251xb_connect(struct usb251xb *hub) i2c_wb[USB251XB_ADDR_PORT_MAP_7 ] = hub->port_map7; i2c_wb[USB251XB_ADDR_STATUS_COMMAND ] =USB251XB_STATUS_COMMAND_ATTACH ; -usb251xb_reset (hub,1 ); +usb251xb_reset (hub,0 );/* write registers */ for (i =0 ; i < (USB251XB_I2C_REG_SZ /USB251XB_I2C_WRITE_SZ ); i++) {
@@ -363,19 +362,13 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,else hub->skip_config =0 ; - hub->gpio_reset =of_get_named_gpio (np,"reset-gpios" ,0 ); -if (hub->gpio_reset == -EPROBE_DEFER ) + hub->gpio_reset =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH ); +if (PTR_ERR (hub->gpio_reset) == -EPROBE_DEFER ) {return -EPROBE_DEFER ; -if (gpio_is_valid (hub->gpio_reset)) { - err =devm_gpio_request_one (dev, hub->gpio_reset, -GPIOF_OUT_INIT_LOW , -"usb251xb reset" ); -if (err) { -dev_err (dev, -"unable to request GPIO %d as reset pin (%d)\n" , - hub->gpio_reset, err); -return err; - } + }else if (IS_ERR (hub->gpio_reset)) { + err =PTR_ERR (hub->gpio_reset); +dev_err (dev,"unable to request GPIO reset pin (%d)\n" , err); +return err; }if (of_property_read_u16_array (np,"vendor-id" , &hub->vendor_id,1 ))
Signature · 1 line
2.12.0
PATCH 5/5 usb: usb251xb: Add copyrights
In reply to Serge Semin--- drivers/usb/misc/usb251xb.c | 1 + 1 file changed, 1 insertions(+), 0 deletion(-)
drivers/usb/misc/usb251xb.c +1 -0
@@ -3,6 +3,7 @@* Configuration via SMBus. * * Copyright (c) 2017 SKIDATA AG +* Copyright (c) 2017 T-platforms * * This work is based on the USB3503 driver by Dongjin Kim and * a not-accepted patch by Fabien Lahoudere, see:
Signature · 1 line
2.12.0
Greg KH
maintainerRe: [PATCH 5/5] usb: usb251xb: Add copyrights
Quoted 4 lines · Serge Semin
Signed-off-by Serge Semin <[email protected]>--- drivers/usb/misc/usb251xb.c | 1 + 1 file changed, 1 insertions(+), 0 deletion(-)
I can't take patches without any changelog text, sorry.
drivers/usb/misc/usb251xb.c line 6
Quoted 10 lines
drivers/usb/misc/usb251xb.c +1
-0@@ -3,6 +3,7 @@* Configuration via SMBus. * * Copyright (c) 2017 SKIDATA AG +* Copyright (c) 2017 T-platforms
I don't see the connection between a random company, and a random gmail.com email address. Please explain :)
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Greg KH
maintainerRe: [PATCH 5/5] usb: usb251xb: Add copyrights
Quoted 9 lines · Greg KH
Quoted 4 lines · Serge Semin
Signed-off-by Serge Semin <[email protected]>--- drivers/usb/misc/usb251xb.c | 1 + 1 file changed, 1 insertions(+), 0 deletion(-)I can't take patches without any changelog text, sorry.
Quoted 1 line
Quoted 12 lines
drivers/usb/misc/usb251xb.c line 6
Quoted 9 lines
drivers/usb/misc/usb251xb.c +1
-0@@ -3,6 +3,7 @@* Configuration via SMBus. * * Copyright (c) 2017 SKIDATA AG +* Copyright (c) 2017 T-platforms I don't see the connection between a random company, and a random gmail.com email address. Please explain :)
Also, based on the changes in this series, I fail to see how you could even claim copyright on the entire file. Please explain that as well when you resend this patch.
Note, I'm not a lawyer, and this isn't legal advice, please contact your company's lawyers, they know this type of thing, and now the normal rules for claiming copyright of a whole file. They also know that copyright notices in files don't mean anything, but lawyers love to cargo-cult things more than any other profession :)
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Greg KH
maintainerRe: [PATCH 1/5] usb: usb251xb: Add USB2517/i hub support
In reply to Serge SeminQuoted 4 lines · Serge Semin
USB2517i hubs are very like USB251xb devices series. They have almost the same configuration registers space except number of ports, led configurations and lack of battery settings. All these peculiarities are reflected in this patch.
Please add one type of feature at a time per patch. That makes it easier to review and ensure you got it right.
thanks,
greg k-h
Re: [PATCH 5/5] usb: usb251xb: Add copyrights
In reply to Greg KHQuoted 8 lines · Greg KH
Quoted 4 lines · Serge Semin
Signed-off-by Serge Semin <[email protected]>--- drivers/usb/misc/usb251xb.c | 1 + 1 file changed, 1 insertions(+), 0 deletion(-)I can't take patches without any changelog text, sorry.
I'll merge it into the previous patch then. There is nothing to changeloging here.
Quoted 13 lines
drivers/usb/misc/usb251xb.c line 6
Quoted 10 lines
drivers/usb/misc/usb251xb.c +1
-0@@ -3,6 +3,7 @@* Configuration via SMBus. * * Copyright (c) 2017 SKIDATA AG +* Copyright (c) 2017 T-platforms I don't see the connection between a random company, and a random gmail.com email address. Please explain :)
Why do you see gmail.com only? I cc-ed this patchset to my work email:
[email protected]
Do I really need to send it from my work e-mail? I have met such rule before.
Quoted 4 lines
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH 5/5] usb: usb251xb: Add copyrights
Quoted 26 lines · Serge Semin
Quoted 8 lines · Greg KH
Quoted 4 lines · Serge Semin
Signed-off-by Serge Semin <[email protected]>--- drivers/usb/misc/usb251xb.c | 1 + 1 file changed, 1 insertions(+), 0 deletion(-)I can't take patches without any changelog text, sorry.
I'll merge it into the previous patch then. There is nothing to changeloging here.
Quoted 13 lines
drivers/usb/misc/usb251xb.c line 6
Quoted 10 lines
drivers/usb/misc/usb251xb.c +1
-0@@ -3,6 +3,7 @@* Configuration via SMBus. * * Copyright (c) 2017 SKIDATA AG +* Copyright (c) 2017 T-platforms I don't see the connection between a random company, and a random gmail.com email address. Please explain :)
Quoted 3 lines
Why do you see gmail.com only? I cc-ed this patchset to my work email:
[email protected]
Do I really need to send it from my work e-mail? I have met such rule before.
The authorship of these patches are coming from a gmail.com address, how do I know what that relates to some random email you cc: on the patch :)
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/5] usb: usb251xb: Add USB2517/i hub support
In reply to Greg KHQuoted 6 lines · Greg KH
Quoted 4 lines · Serge Semin
USB2517i hubs are very like USB251xb devices series. They have almost the same configuration registers space except number of ports, led configurations and lack of battery settings. All these peculiarities are reflected in this patch.
Quoted 6 lines
Please add one type of feature at a time per patch. That makes it easier to review and ensure you got it right.
thanks,
greg k-h
Ok. The patch isn't that big though.
Regards,
-Sergey
Re: [PATCH 5/5] usb: usb251xb: Add copyrights
In reply to Greg KHQuoted 31 lines · Greg KH
Quoted 26 lines · Serge Semin
Quoted 8 lines · Greg KH
Quoted 4 lines · Serge Semin
Signed-off-by Serge Semin <[email protected]>--- drivers/usb/misc/usb251xb.c | 1 + 1 file changed, 1 insertions(+), 0 deletion(-)I can't take patches without any changelog text, sorry.
I'll merge it into the previous patch then. There is nothing to changeloging here.
Quoted 13 lines
drivers/usb/misc/usb251xb.c line 6
Quoted 10 lines
drivers/usb/misc/usb251xb.c +1
-0@@ -3,6 +3,7 @@* Configuration via SMBus. * * Copyright (c) 2017 SKIDATA AG +* Copyright (c) 2017 T-platforms I don't see the connection between a random company, and a random gmail.com email address. Please explain :)
Quoted 3 lines
Why do you see gmail.com only? I cc-ed this patchset to my work email:
[email protected]
Do I really need to send it from my work e-mail? I have met such rule before.
Quoted 6 lines
The authorship of these patches are coming from a gmail.com address, how do I know what that relates to some random email you cc: on the patch :)
thanks,
greg k-h
Does it really matter? I could create any domain and add some random company as copyright. How would you know the copyrighted company is real then? The only way would be just google it. That's it. But still the site can be faked if it is really necessary.
I thought these things are a matter of trust. I submitted a patchset from my personal e-mail, but created it while working for the company. It's highly possible, that my personal email is going to be mine for much longer time, then I'll be working in the company. In this case, the better way to declare it as primary email, instead of the company one, so to have a longer support. Isn't it? Why would I need to fake a copyrighted company anyway?
-Sergey
v2 cover usb: usb251xb: Add USB2517i hub support and fix some bugs
In reply to Serge SeminPrimarily it was intended to just add USB2517 hub support to the driver. But after tests a bug and inconistency were discovered. So it was decided to make the following changes:
Changelog v1:
- Add USB2517/i hub specifics support to the driver
- Fix property_u32 NULL-pointer dereference
- Add new {bus,self}-max-{power,curret} dts properties
- Replace legacy GPIO API usage with descriptor-based one
Changelog v2:
- Split first patch into smaller ones
- Fix invalid BOOST_14 register definition
- Combine copyrights adding patch into the last one
Serge Semin (9):
usb: usb251xb: Add USB2517i specific struct and IDs
usb: usb251xb: Add USB251x specific port count setting
usb: usb251xb: Add 5,6,7 ports mapping def setting
usb: usb251xb: Add 5,6,7 ports boost settings
usb: usb251xb: Add battery enable setting flag
usb: usb251xb: Add USB2517 LED settings
usb: usb251xb: Fix property_u32 NULL pointer dereference
usb: usb251xb: Add max power/current dts property support
usb: usb251xb: Use GPIO descriptor consumer interface
Documentation/devicetree/bindings/usb/usb251xb.txt | 12 +- drivers/usb/misc/usb251xb.c | 160 +++++++++++++++------ 2 files changed, 128 insertions(+), 44 deletions(-)
Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/9 usb: usb251xb: Add USB2517i specific struct and IDs
There are USB2517 and USB2517i hubs, which have almost the same registers space as already supported USB251xbi series. The difference it in DIDs and in few functions. This patch adds the USB2517/i data structures to the driver, so it would have different setting depending on the device discovered on i2c-bus.
--- Documentation/devicetree/bindings/usb/usb251xb.txt | 3 ++- drivers/usb/misc/usb251xb.c | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/usb/usb251xb.txt +2 -1
@@ -6,7 +6,8 @@ Hi-Speed Controller. Required properties : - compatible : Should be "microchip,usb251xb" or one of the specific types: "microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b", - "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi" + "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi", + "microchip,usb2517", "microchip,usb2517i" - reset-gpios : Should specify the gpio for hub reset - reg : I2C address on the selected bus (default is <0x2C>)
drivers/usb/misc/usb251xb.c +20 -1
@@ -38,6 +38,7 @@#define USB251XB_DEF_PRODUCT_ID_12 0x2512/* USB2512B/12Bi */ #define USB251XB_DEF_PRODUCT_ID_13 0x2513/* USB2513B/13Bi */ #define USB251XB_DEF_PRODUCT_ID_14 0x2514/* USB2514B/14Bi */ +#define USB251XB_DEF_PRODUCT_ID_17 0x2517/* USB2517i */ #define USB251XB_ADDR_DEVICE_ID_LSB 0x04#define USB251XB_ADDR_DEVICE_ID_MSB 0x05
@@ -82,7 +83,7 @@#define USB251XB_ADDR_PRODUCT_STRING_LEN 0x14#define USB251XB_ADDR_PRODUCT_STRING 0x54 -#define USB251XB_DEF_PRODUCT_STRING "USB251xB/xBi" +#define USB251XB_DEF_PRODUCT_STRING "USB251xB/xBi/7i"#define USB251XB_ADDR_SERIAL_STRING_LEN 0x15#define USB251XB_ADDR_SERIAL_STRING 0x92
@@ -186,6 +187,16 @@ static const struct usb251xb_data usb2514bi_data = { .product_str = "USB2514Bi", }; +static const struct usb251xb_data usb2517_data = { + .product_id =0x2517 , + .product_str ="USB2517" , +}; + +static const struct usb251xb_data usb2517i_data = { + .product_id =0x2517 , + .product_str ="USB2517i" , +}; +static void usb251xb_reset (struct usb251xb *hub,int state) {if (!gpio_is_valid (hub->gpio_reset))
@@ -511,6 +522,12 @@ static const struct of_device_id usb251xb_of_match[] = { .compatible = "microchip,usb2514bi", .data = &usb2514bi_data, }, { + .compatible = "microchip,usb2517", + .data = &usb2517_data, + }, { + .compatible = "microchip,usb2517i", + .data = &usb2517i_data, + }, {/* sentinel */ } };
@@ -574,6 +591,8 @@ static const struct i2c_device_id usb251xb_id[] = { { "usb2513bi", 0 }, { "usb2514b", 0 }, { "usb2514bi", 0 }, + { "usb2517", 0 }, + { "usb2517i", 0 }, { /* sentinel */ } };MODULE_DEVICE_TABLE (i2c, usb251xb_id);
Signature · 1 line
2.12.0
PATCH v2 2/9 usb: usb251xb: Add USB251x specific port count setting
In reply to Serge SeminUSB251xb as well as USB2517 datasheet states, that all these hubs differ by number of ports declared as the last digit in the model name. So USB2512 got two ports, USB2513 - three, and so on. Such setting must be reflected in the device specific data structure and corresponding dts property should be checked whether it doesn't get out of available ports.
--- drivers/usb/misc/usb251xb.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/usb/misc/usb251xb.c +18 -3
@@ -154,46 +154,55 @@ struct usb251xb {struct usb251xb_data {u16 product_id; +u8 port_cnt;char product_str[USB251XB_STRING_BUFSIZE /2 ];/* ASCII string */ };static const struct usb251xb_data usb2512b_data = { .product_id =0x2512 , + .port_cnt =2 , .product_str ="USB2512B" , };static const struct usb251xb_data usb2512bi_data = { .product_id =0x2512 , + .port_cnt =2 , .product_str ="USB2512Bi" , };static const struct usb251xb_data usb2513b_data = { .product_id =0x2513 , + .port_cnt =3 , .product_str ="USB2513B" , };static const struct usb251xb_data usb2513bi_data = { .product_id =0x2513 , + .port_cnt =3 , .product_str ="USB2513Bi" , };static const struct usb251xb_data usb2514b_data = { .product_id =0x2514 , + .port_cnt =4 , .product_str ="USB2514B" , };static const struct usb251xb_data usb2514bi_data = { .product_id =0x2514 , + .port_cnt =4 , .product_str ="USB2514Bi" , };static const struct usb251xb_data usb2517_data = { .product_id =0x2517 , + .port_cnt =7 , .product_str ="USB2517" , };static const struct usb251xb_data usb2517i_data = { .product_id =0x2517 , + .port_cnt =7 , .product_str ="USB2517i" , };
@@ -422,8 +431,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,for (i =0 ; i < len /sizeof (u32); i++) {u32 port =be32_to_cpu (cproperty_u32[i]); -if ((port >=1 ) && (port <=4 )) +if ((port >=1 ) && (port <= data->port_cnt)) hub->non_rem_dev |=BIT (port); +else +dev_warn (dev,"port %u doesn't exist\n" , port); } }
@@ -433,8 +444,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,for (i =0 ; i < len /sizeof (u32); i++) {u32 port =be32_to_cpu (cproperty_u32[i]); -if ((port >=1 ) && (port <=4 )) +if ((port >=1 ) && (port <= data->port_cnt)) hub->port_disable_sp |=BIT (port); +else +dev_warn (dev,"port %u doesn't exist\n" , port); } }
@@ -444,8 +457,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,for (i =0 ; i < len /sizeof (u32); i++) {u32 port =be32_to_cpu (cproperty_u32[i]); -if ((port >=1 ) && (port <=4 )) +if ((port >=1 ) && (port <= data->port_cnt)) hub->port_disable_bp |=BIT (port); +else +dev_warn (dev,"port %u doesn't exist\n" , port); } }
Signature · 1 line
2.12.0
PATCH v2 3/9 usb: usb251xb: Add 5,6,7 ports mapping def setting
In reply to Serge SeminUSB2517 got three additionl downstream ports, which can as well be mapped to another logical ports. USB2551xb driver currently doesn't fully support such setting configuration from dts file. This patch doesn't change this, but adds usb2517 spcific ports default liner mapping.
--- drivers/usb/misc/usb251xb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/usb/misc/usb251xb.c +11 -1
@@ -103,7 +103,11 @@#define USB251XB_ADDR_PORT_MAP_12 0xFB#define USB251XB_DEF_PORT_MAP_12 0x00#define USB251XB_ADDR_PORT_MAP_34 0xFC -#define USB251XB_DEF_PORT_MAP_34 0x00/* USB2513B/i & USB2514B/i only */ +#define USB251XB_DEF_PORT_MAP_34 0x00/* USB251{3B/i,4B/i,7/i} only */ +#define USB251XB_ADDR_PORT_MAP_56 0xFD +#define USB251XB_DEF_PORT_MAP_56 0x00/* USB2517/i only */ +#define USB251XB_ADDR_PORT_MAP_7 0xFE +#define USB251XB_DEF_PORT_MAP_7 0x00/* USB2517/i only */ #define USB251XB_ADDR_STATUS_COMMAND 0xFF#define USB251XB_STATUS_COMMAND_SMBUS_DOWN 0x04
@@ -149,6 +153,8 @@ struct usb251xb {u8 port_swap;u8 port_map12;u8 port_map34; +u8 port_map56; +u8 port_map7;u8 status; };
@@ -278,6 +284,8 @@ static int usb251xb_connect(struct usb251xb *hub) i2c_wb[USB251XB_ADDR_PORT_SWAP ] = hub->port_swap; i2c_wb[USB251XB_ADDR_PORT_MAP_12 ] = hub->port_map12; i2c_wb[USB251XB_ADDR_PORT_MAP_34 ] = hub->port_map34; + i2c_wb[USB251XB_ADDR_PORT_MAP_56 ] = hub->port_map56; + i2c_wb[USB251XB_ADDR_PORT_MAP_7 ] = hub->port_map7; i2c_wb[USB251XB_ADDR_STATUS_COMMAND ] =USB251XB_STATUS_COMMAND_ATTACH ;usb251xb_reset (hub,1 );
@@ -513,6 +521,8 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, hub->port_swap =USB251XB_DEF_PORT_SWAP ; hub->port_map12 =USB251XB_DEF_PORT_MAP_12 ; hub->port_map34 =USB251XB_DEF_PORT_MAP_34 ; + hub->port_map56 =USB251XB_DEF_PORT_MAP_56 ; + hub->port_map7 =USB251XB_DEF_PORT_MAP_7 ;return 0 ; }
Signature · 1 line
2.12.0
PATCH v2 4/9 usb: usb251xb: Add 5,6,7 ports boost settings
In reply to Serge SeminUSB electrical signaling drive strength boost bit is also supported by USB2517 hub. Since it got three addition ports, the designers needed to add one more register for initialization. It turned out to be formerly reserved 0xF7. As before we just initialize it with default zeros.
--- drivers/usb/misc/usb251xb.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/usb/misc/usb251xb.c +10 -5
@@ -94,8 +94,10 @@#define USB251XB_ADDR_BOOST_UP 0xF6#define USB251XB_DEF_BOOST_UP 0x00 -#define USB251XB_ADDR_BOOST_X 0xF8 -#define USB251XB_DEF_BOOST_X 0x00 +#define USB251XB_ADDR_BOOST_57 0xF7 +#define USB251XB_DEF_BOOST_57 0x00 +#define USB251XB_ADDR_BOOST_14 0xF8 +#define USB251XB_DEF_BOOST_14 0x00#define USB251XB_ADDR_PORT_SWAP 0xFA#define USB251XB_DEF_PORT_SWAP 0x00
@@ -149,7 +151,8 @@ struct usb251xb {char serial[USB251XB_STRING_BUFSIZE ];u8 bat_charge_en;u8 boost_up; -u8 boost_x; +u8 boost_57; +u8 boost_14;u8 port_swap;u8 port_map12;u8 port_map34;
@@ -280,7 +283,8 @@ static int usb251xb_connect(struct usb251xb *hub) USB251XB_STRING_BUFSIZE); i2c_wb[USB251XB_ADDR_BATTERY_CHARGING_ENABLE ] = hub->bat_charge_en; i2c_wb[USB251XB_ADDR_BOOST_UP ] = hub->boost_up; - i2c_wb[USB251XB_ADDR_BOOST_X ] = hub->boost_x; + i2c_wb[USB251XB_ADDR_BOOST_57 ] = hub->boost_57; + i2c_wb[USB251XB_ADDR_BOOST_14 ] = hub->boost_14; i2c_wb[USB251XB_ADDR_PORT_SWAP ] = hub->port_swap; i2c_wb[USB251XB_ADDR_PORT_MAP_12 ] = hub->port_map12; i2c_wb[USB251XB_ADDR_PORT_MAP_34 ] = hub->port_map34;
@@ -517,7 +521,8 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, hub->max_current_bp =USB251XB_DEF_MAX_CURRENT_BUS ; hub->bat_charge_en =USB251XB_DEF_BATTERY_CHARGING_ENABLE ; hub->boost_up =USB251XB_DEF_BOOST_UP ; - hub->boost_x =USB251XB_DEF_BOOST_X ; + hub->boost_57 =USB251XB_DEF_BOOST_57 ; + hub->boost_14 =USB251XB_DEF_BOOST_14 ; hub->port_swap =USB251XB_DEF_PORT_SWAP ; hub->port_map12 =USB251XB_DEF_PORT_MAP_12 ; hub->port_map34 =USB251XB_DEF_PORT_MAP_34 ;
Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 5/9 usb: usb251xb: Add battery enable setting flag
In reply to Serge SeminBattery charging settings are supported by USB251xb hubs only. USB2517i isn't one of them. So we need to reflect it within the device-specific data structure. The driver doesn't support dts property to change this setting, but instead defaults it with zero. So the flag isn't used anywhere in the driver, but still can be helpful in future, when necessity of corresponding dts setting arises.
--- drivers/usb/misc/usb251xb.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/misc/usb251xb.c +9 -0
@@ -164,54 +164,63 @@ struct usb251xb {struct usb251xb_data {u16 product_id;u8 port_cnt; +bool bat_support;char product_str[USB251XB_STRING_BUFSIZE /2 ];/* ASCII string */ };static const struct usb251xb_data usb2512b_data = { .product_id =0x2512 , .port_cnt =2 , + .bat_support = true, .product_str ="USB2512B" , };static const struct usb251xb_data usb2512bi_data = { .product_id =0x2512 , .port_cnt =2 , + .bat_support = true, .product_str ="USB2512Bi" , };static const struct usb251xb_data usb2513b_data = { .product_id =0x2513 , .port_cnt =3 , + .bat_support = true, .product_str ="USB2513B" , };static const struct usb251xb_data usb2513bi_data = { .product_id =0x2513 , .port_cnt =3 , + .bat_support = true, .product_str ="USB2513Bi" , };static const struct usb251xb_data usb2514b_data = { .product_id =0x2514 , .port_cnt =4 , + .bat_support = true, .product_str ="USB2514B" , };static const struct usb251xb_data usb2514bi_data = { .product_id =0x2514 , .port_cnt =4 , + .bat_support = true, .product_str ="USB2514Bi" , };static const struct usb251xb_data usb2517_data = { .product_id =0x2517 , .port_cnt =7 , + .bat_support = false, .product_str ="USB2517" , };static const struct usb251xb_data usb2517i_data = { .product_id =0x2517 , .port_cnt =7 , + .bat_support = false, .product_str ="USB2517i" , };
Signature · 1 line
2.12.0
PATCH v2 6/9 usb: usb251xb: Add USB2517 LED settings
In reply to Serge SeminUSB2517 supports two LED modes: USB mode (default) and speed indication mode. The last one can be switched on by corresponding dts property. Since USB251xb hubs doesn't support LEDs settings, we need to ignore this setting.
--- Documentation/devicetree/bindings/usb/usb251xb.txt | 1 + drivers/usb/misc/usb251xb.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/usb/usb251xb.txt +1 -0
@@ -37,6 +37,7 @@ Optional properties : an invalid value is given, the default is used instead. - compound-device : indicate the hub is part of a compound device - port-mapping-mode : enable port mapping mode + - speed-led-mode : led speed indiation mode selection (usb2517 only) - string-support : enable string descriptor support (required for manufacturer, product and serial string configuration) - non-removable-ports : Should specify the ports which have a non-removable
drivers/usb/misc/usb251xb.c +13 -1
@@ -49,7 +49,7 @@#define USB251XB_ADDR_CONFIG_DATA_2 0x07#define USB251XB_DEF_CONFIG_DATA_2 0x20#define USB251XB_ADDR_CONFIG_DATA_3 0x08 -#define USB251XB_DEF_CONFIG_DATA_3 0x02 +#define USB251XB_DEF_CONFIG_DATA_3 0x00#define USB251XB_ADDR_NON_REMOVABLE_DEVICES 0x09#define USB251XB_DEF_NON_REMOVABLE_DEVICES 0x00
@@ -164,6 +164,7 @@ struct usb251xb {struct usb251xb_data {u16 product_id;u8 port_cnt; +bool led_support;bool bat_support;char product_str[USB251XB_STRING_BUFSIZE /2 ];/* ASCII string */ };
@@ -171,6 +172,7 @@ struct usb251xb_data {static const struct usb251xb_data usb2512b_data = { .product_id =0x2512 , .port_cnt =2 , + .led_support = false, .bat_support = true, .product_str ="USB2512B" , };
@@ -178,6 +180,7 @@ static const struct usb251xb_data usb2512b_data = {static const struct usb251xb_data usb2512bi_data = { .product_id =0x2512 , .port_cnt =2 , + .led_support = false, .bat_support = true, .product_str ="USB2512Bi" , };
@@ -185,6 +188,7 @@ static const struct usb251xb_data usb2512bi_data = {static const struct usb251xb_data usb2513b_data = { .product_id =0x2513 , .port_cnt =3 , + .led_support = false, .bat_support = true, .product_str ="USB2513B" , };
@@ -192,6 +196,7 @@ static const struct usb251xb_data usb2513b_data = {static const struct usb251xb_data usb2513bi_data = { .product_id =0x2513 , .port_cnt =3 , + .led_support = false, .bat_support = true, .product_str ="USB2513Bi" , };
@@ -199,6 +204,7 @@ static const struct usb251xb_data usb2513bi_data = {static const struct usb251xb_data usb2514b_data = { .product_id =0x2514 , .port_cnt =4 , + .led_support = false, .bat_support = true, .product_str ="USB2514B" , };
@@ -206,6 +212,7 @@ static const struct usb251xb_data usb2514b_data = {static const struct usb251xb_data usb2514bi_data = { .product_id =0x2514 , .port_cnt =4 , + .led_support = false, .bat_support = true, .product_str ="USB2514Bi" , };
@@ -213,6 +220,7 @@ static const struct usb251xb_data usb2514bi_data = {static const struct usb251xb_data usb2517_data = { .product_id =0x2517 , .port_cnt =7 , + .led_support = true, .bat_support = false, .product_str ="USB2517" , };
@@ -220,6 +228,7 @@ static const struct usb251xb_data usb2517_data = {static const struct usb251xb_data usb2517i_data = { .product_id =0x2517 , .port_cnt =7 , + .led_support = true, .bat_support = false, .product_str ="USB2517i" , };
@@ -443,6 +452,9 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,if (of_get_property (np,"port-mapping-mode" ,NULL )) hub->conf_data3 |=BIT (3 ); +if (data->led_support &&of_get_property (np,"speed-led-mode" ,NULL )) + hub->conf_data3 |=BIT (1 ); +if (of_get_property (np,"string-support" ,NULL )) hub->conf_data3 |=BIT (0 );
Signature · 1 line
2.12.0
PATCH v2 7/9 usb: usb251xb: Fix property_u32 NULL pointer dereference
In reply to Serge SeminThe methods like of_property_read_u32 utilizing the specified pointer permit only the pointer to a preallocated u32 storage as the third argument. As a result the driver crashes on NULL pointer dereference in case if "oc-delay-us" or "power-on-time-ms" declared in dts file.
--- drivers/usb/misc/usb251xb.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/usb/misc/usb251xb.c +7 -7
@@ -348,7 +348,7 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,struct device *dev = hub->dev;struct device_node *np = dev->of_node;int len, err, i; -u32 *property_u32 =NULL ; +u32 property_u32 =0 ;const u32 *cproperty_u32;const char *cproperty_char;char str[USB251XB_STRING_BUFSIZE /2 ];
@@ -425,16 +425,16 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,if (of_get_property (np,"dynamic-power-switching" ,NULL )) hub->conf_data2 |=BIT (7 ); -if (!of_property_read_u32 (np,"oc-delay-us" , property_u32)) { -if (*property_u32 ==100 ) { +if (!of_property_read_u32 (np,"oc-delay-us" , &property_u32)) { +if (property_u32 ==100 ) {/* 100 us*/ hub->conf_data2 &= ~BIT (5 ); hub->conf_data2 &= ~BIT (4 ); - }else if (*property_u32 ==4000 ) { + }else if (property_u32 ==4000 ) {/* 4 ms */ hub->conf_data2 &= ~BIT (5 ); hub->conf_data2 |=BIT (4 ); - }else if (*property_u32 ==16000 ) { + }else if (property_u32 ==16000 ) {/* 16 ms */ hub->conf_data2 |=BIT (5 ); hub->conf_data2 |=BIT (4 );
@@ -498,8 +498,8 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, } hub->power_on_time =USB251XB_DEF_POWER_ON_TIME ; -if (!of_property_read_u32 (np,"power-on-time-ms" , property_u32)) - hub->power_on_time =min_t (u8, *property_u32 /2 ,255 ); +if (!of_property_read_u32 (np,"power-on-time-ms" , &property_u32)) + hub->power_on_time =min_t (u8, property_u32 /2 ,255 );if (of_property_read_u16_array (np,"language-id" , &hub->lang_id,1 )) hub->lang_id =USB251XB_DEF_LANGUAGE_ID ;
Signature · 1 line
2.12.0
PATCH v2 8/9 usb: usb251xb: Add max power/current dts property support
In reply to Serge SeminThis parameters may be varied in accordance with hardware specifics. So lets add the corresponding settings to the usb251x driver dts specification.
--- Documentation/devicetree/bindings/usb/usb251xb.txt | 6 ++++++ drivers/usb/misc/usb251xb.c | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/usb/usb251xb.txt +6 -0
@@ -44,6 +44,12 @@ Optional properties : device connected. - sp-disabled-ports : Specifies the ports which will be self-power disabled - bp-disabled-ports : Specifies the ports which will be bus-power disabled + - sp-max-{power,current} : Indicates the power/current consumed by hub from + an upstream port (VBUS) when operation as a self-powered hub. The value + is given in mA in a 0 - 100 range (default is 1mA). + - bp-max-{power,current} : Indicates the power/current consumed by hub from + an upstream port (VBUS) when operation as a bus-powered hub. The value + is given in mA in a 0 - 510 range (default is 100mA). - power-on-time-ms : Specifies the time it takes from the time the host initiates the power-on sequence to a port until the port has adequate power. The value is given in ms in a 0 - 510 range (default is 100ms).
drivers/usb/misc/usb251xb.c +16 -4
@@ -497,6 +497,22 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, } } + hub->max_power_sp =USB251XB_DEF_MAX_POWER_SELF ; +if (!of_property_read_u32 (np,"sp-max-power" , &property_u32)) + hub->max_power_sp =min_t (u8, property_u32 /2 ,50 ); + + hub->max_power_bp =USB251XB_DEF_MAX_POWER_BUS ; +if (!of_property_read_u32 (np,"bp-max-power" , &property_u32)) + hub->max_power_bp =min_t (u8, property_u32 /2 ,255 ); + + hub->max_current_sp =USB251XB_DEF_MAX_CURRENT_SELF ; +if (!of_property_read_u32 (np,"sp-max-current" , &property_u32)) + hub->max_current_sp =min_t (u8, property_u32 /2 ,50 ); + + hub->max_current_bp =USB251XB_DEF_MAX_CURRENT_BUS ; +if (!of_property_read_u32 (np,"bp-max-current" , &property_u32)) + hub->max_current_bp =min_t (u8, property_u32 /2 ,255 ); + hub->power_on_time =USB251XB_DEF_POWER_ON_TIME ;if (!of_property_read_u32 (np,"power-on-time-ms" , &property_u32)) hub->power_on_time =min_t (u8, property_u32 /2 ,255 );
@@ -536,10 +552,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->max_power_sp =USB251XB_DEF_MAX_POWER_SELF ; - hub->max_power_bp =USB251XB_DEF_MAX_POWER_BUS ; - hub->max_current_sp =USB251XB_DEF_MAX_CURRENT_SELF ; - hub->max_current_bp =USB251XB_DEF_MAX_CURRENT_BUS ; hub->bat_charge_en =USB251XB_DEF_BATTERY_CHARGING_ENABLE ; hub->boost_up =USB251XB_DEF_BOOST_UP ; hub->boost_57 =USB251XB_DEF_BOOST_57 ;
Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 9/9 usb: usb251xb: Use GPIO descriptor consumer interface
In reply to Serge SeminThe driver used to be developed with legacy GPIO API support. It's better to use descriptor-based interface for several reasons. First of all the legacy API doesn't support the ACTIVE_LOW/HIGH flag of dts nodes, which is essential since different hardware may have different GPIOs connectivity including the logical value inversion. Secondly, by requesting the reset GPIO descriptor the driver prevent the other applications from changing its value. And last but not least the legacy GPIO interface should be avoided in the new code due to it obsolescence.
--- Documentation/devicetree/bindings/usb/usb251xb.txt | 2 +- drivers/usb/misc/usb251xb.c | 34 +++++++++------------- 2 files changed, 15 insertions(+), 21 deletions(-)
Documentation/devicetree/bindings/usb/usb251xb.txt +1 -1
@@ -8,10 +8,10 @@ Required properties : "microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b", "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi", "microchip,usb2517", "microchip,usb2517i" - - reset-gpios : Should specify the gpio for hub reset - reg : I2C address on the selected bus (default is <0x2C>) Optional properties : + - reset-gpios : Should specify the gpio for hub reset - skip-config : Skip Hub configuration, but only send the USB-Attach command - vendor-id : Set USB Vendor ID of the hub (16 bit, default is 0x0424) - product-id : Set USB Product ID of the hub (16 bit, default depends on type)
drivers/usb/misc/usb251xb.c +14 -20
@@ -3,6 +3,7 @@* Configuration via SMBus. * * Copyright (c) 2017 SKIDATA AG +* Copyright (c) 2017 T-platforms * * This work is based on the USB3503 driver by Dongjin Kim and * a not-accepted patch by Fabien Lahoudere, see:
@@ -20,12 +21,11 @@*/ #include <linux/delay.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/module.h> #include <linux/nls.h> #include <linux/of_device.h> -#include <linux/of_gpio.h> #include <linux/slab.h> /* Internal Register Set Addresses & Default Values acc. to DS00001692C */
@@ -127,7 +127,7 @@ struct usb251xb {struct device *dev;struct i2c_client *i2c;u8 skip_config; -int gpio_reset; +struct gpio_desc *gpio_reset;u16 vendor_id;u16 product_id;u16 device_id;
@@ -235,13 +235,13 @@ static const struct usb251xb_data usb2517i_data = {static void usb251xb_reset (struct usb251xb *hub,int state) { -if (!gpio_is_valid (hub->gpio_reset)) +if (!hub->gpio_reset)return ; -gpio_set_value_cansleep (hub->gpio_reset, state); +gpiod_set_value_cansleep (hub->gpio_reset, state);/* wait for hub recovery/stabilization */ -if (state) +if (!state)usleep_range (500 ,750 );/* >=500us at power on */ else usleep_range (1 ,10 );/* >=1us at power down */
@@ -260,7 +260,7 @@ static int usb251xb_connect(struct usb251xb *hub) i2c_wb[0 ] =0x01 ; i2c_wb[1 ] =USB251XB_STATUS_COMMAND_ATTACH ; -usb251xb_reset (hub,1 ); +usb251xb_reset (hub,0 ); err =i2c_smbus_write_i2c_block_data (hub->i2c,USB251XB_ADDR_STATUS_COMMAND ,2 , i2c_wb);
@@ -310,7 +310,7 @@ static int usb251xb_connect(struct usb251xb *hub) i2c_wb[USB251XB_ADDR_PORT_MAP_7 ] = hub->port_map7; i2c_wb[USB251XB_ADDR_STATUS_COMMAND ] =USB251XB_STATUS_COMMAND_ATTACH ; -usb251xb_reset (hub,1 ); +usb251xb_reset (hub,0 );/* write registers */ for (i =0 ; i < (USB251XB_I2C_REG_SZ /USB251XB_I2C_WRITE_SZ ); i++) {
@@ -363,19 +363,13 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,else hub->skip_config =0 ; - hub->gpio_reset =of_get_named_gpio (np,"reset-gpios" ,0 ); -if (hub->gpio_reset == -EPROBE_DEFER ) + hub->gpio_reset =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH ); +if (PTR_ERR (hub->gpio_reset) == -EPROBE_DEFER ) {return -EPROBE_DEFER ; -if (gpio_is_valid (hub->gpio_reset)) { - err =devm_gpio_request_one (dev, hub->gpio_reset, -GPIOF_OUT_INIT_LOW , -"usb251xb reset" ); -if (err) { -dev_err (dev, -"unable to request GPIO %d as reset pin (%d)\n" , - hub->gpio_reset, err); -return err; - } + }else if (IS_ERR (hub->gpio_reset)) { + err =PTR_ERR (hub->gpio_reset); +dev_err (dev,"unable to request GPIO reset pin (%d)\n" , err); +return err; }if (of_property_read_u16_array (np,"vendor-id" , &hub->vendor_id,1 ))
Signature · 1 line
2.12.0
Rob Herring
maintainerRe: [PATCH 1/5] usb: usb251xb: Add USB2517/i hub support
In reply to Serge SeminQuoted 8 lines · Serge Semin
USB2517i hubs are very like USB251xb devices series. They have almost the same configuration registers space except number of ports, led configurations and lack of battery settings. All these peculiarities are reflected in this patch.
Signed-off-by Serge Semin <[email protected]>--- Documentation/devicetree/bindings/usb/usb251xb.txt | 4 +-
Though Greg wants the code split, I want the binding as one change. H/w doesn't gain features one by one.
It's preferred to split bindings to a separate patch.
Quoted 18 lines
drivers/usb/misc/usb251xb.c | 84 +++++++++++++++++++--- 2 files changed, 78 insertions(+), 10 deletions(-)Documentation/devicetree/bindings/usb/usb251xb.txt +2
-1@@ -6,7 +6,8 @@ Hi-Speed Controller. Required properties : - compatible : Should be "microchip,usb251xb" or one of the specific types: "microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b", - "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi" + "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi", + "microchip,usb2517", "microchip,usb2517i" - reset-gpios : Should specify the gpio for hub reset - reg : I2C address on the selected bus (default is <0x2C>)
Documentation/devicetree/bindings/usb/usb251xb.txt Optional properties : · line 40
Quoted 4 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +1
-0@@ -36,6 +37,7 @@ Optional properties : an invalid value is given, the default is used instead. - compound-device : indicate the hub is part of a compound device - port-mapping-mode : enable port mapping mode + - speed-led-mode : led speed indiation mode selection (usb2517 only)
This is a boolean or has values? What are valid values?
This needs a vendor prefix. Somehow the other properties got in without.
Quoted 3 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +0
-0- string-support : enable string descriptor support (required for manufacturer, product and serial string configuration) - non-removable-ports : Should specify the ports which have a non-removable
Rob Herring
maintainerRe: [PATCH 8/9 v2] usb: usb251xb: Add max power/current dts property support
In reply to Serge SeminQuoted 15 lines · Serge Semin
This parameters may be varied in accordance with hardware specifics. So lets add the corresponding settings to the usb251x driver dts specification.
Signed-off-by Serge Semin <[email protected]>--- Documentation/devicetree/bindings/usb/usb251xb.txt | 6 ++++++ drivers/usb/misc/usb251xb.c | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-)Documentation/devicetree/bindings/usb/usb251xb.txt +0
-0
Documentation/devicetree/bindings/usb/usb251xb.txt Optional properties : · line 52
Quoted 9 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +6
-0@@ -44,6 +44,12 @@ Optional properties : device connected. - sp-disabled-ports : Specifies the ports which will be self-power disabled - bp-disabled-ports : Specifies the ports which will be bus-power disabled + - sp-max-{power,current} : Indicates the power/current consumed by hub from + an upstream port (VBUS) when operation as a self-powered hub. The value + is given in mA in a 0 - 100 range (default is 1mA). + - bp-max-{power,current} : Indicates the power/current consumed by hub from + an upstream port (VBUS) when operation as a bus-powered hub. The value + is given in mA in a 0 - 510 range (default is 100mA).
These need units as defined in property-units.txt.
Why do you need power and current? Can't you calculate power?
Quoted 3 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +0
-0- power-on-time-ms : Specifies the time it takes from the time the host initiates the power-on sequence to a port until the port has adequate power. The value is given in ms in a 0 - 510 range (default is 100ms).
Rob Herring
maintainerRe: [PATCH 9/9 v2] usb: usb251xb: Use GPIO descriptor consumer interface
In reply to Serge SeminQuoted 9 lines · Serge Semin
The driver used to be developed with legacy GPIO API support. It's better to use descriptor-based interface for several reasons. First of all the legacy API doesn't support the ACTIVE_LOW/HIGH flag of dts nodes, which is essential since different hardware may have different GPIOs connectivity including the logical value inversion. Secondly, by requesting the reset GPIO descriptor the driver prevent the other applications from changing its value. And last but not least the legacy GPIO interface should be avoided in the new code due to it obsolescence.
All this has nothing to do with the binding. Please make the binding change separate and state why it should be optional.
Quoted 6 lines
Signed-off-by Serge Semin <[email protected]>--- Documentation/devicetree/bindings/usb/usb251xb.txt | 2 +- drivers/usb/misc/usb251xb.c | 34 +++++++++------------- 2 files changed, 15 insertions(+), 21 deletions(-)
Re: [PATCH 1/5] usb: usb251xb: Add USB2517/i hub support
In reply to Rob HerringQuoted 6 lines · Rob Herring
Quoted 5 lines · Serge Semin
USB2517i hubs are very like USB251xb devices series. They have almost the same configuration registers space except number of ports, led configurations and lack of battery settings. All these peculiarities are reflected in this patch.
Quoted 9 lines
Quoted 3 lines
Signed-off-by Serge Semin <[email protected]>--- Documentation/devicetree/bindings/usb/usb251xb.txt | 4 +-Though Greg wants the code split, I want the binding as one change. H/w doesn't gain features one by one.
It's preferred to split bindings to a separate patch.
Folks, you are really driving people crazy. When I was reviewing a kernel-patchset from a Logan-guy, I asked him to combine some of his patches, since in fact their combination represented one solid driver. I was told to go very far, and Greg supported him with it. I'm not going to be that rude and will do as you asked me to. But really, isn't it possible to have some strict rule created so a developer would always follow it thereby not being asked to combine/split patches almost everytime?
The only way I see for now is to know each maintainer personal preferences.
Quoted 17 lines
Quoted 17 lines
drivers/usb/misc/usb251xb.c | 84 +++++++++++++++++++--- 2 files changed, 78 insertions(+), 10 deletions(-)Documentation/devicetree/bindings/usb/usb251xb.txt +2
-1@@ -6,7 +6,8 @@ Hi-Speed Controller. Required properties : - compatible : Should be "microchip,usb251xb" or one of the specific types: "microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b", - "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi" + "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi", + "microchip,usb2517", "microchip,usb2517i" - reset-gpios : Should specify the gpio for hub reset - reg : I2C address on the selected bus (default is <0x2C>)
Quoted 8 lines
Documentation/devicetree/bindings/usb/usb251xb.txt Optional properties : · line 40
Quoted 5 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +1
-0@@ -36,6 +37,7 @@ Optional properties : an invalid value is given, the default is used instead. - compound-device : indicate the hub is part of a compound device - port-mapping-mode : enable port mapping mode + - speed-led-mode : led speed indiation mode selection (usb2517 only)This is a boolean or has values? What are valid values?
It's boolean. Shall I rename it as:
"- speed-led-mode : enable led speed indication mode (usb2517 only)"?
Quoted 2 lines
This needs a vendor prefix. Somehow the other properties got in without.
Hmm, it's not vendor specific, but device-specific. USB2517 is produced by the same vendor - microchip. The new device got almost the same functionality as the others, except number or ports, LED feature and battery enable feature. The last one isn't configurable by dts. The rest of the properties are the same for all the compatible devices. So what properties you are talking about then?
Quoted 3 lines
Quoted 3 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +0
-0- string-support : enable string descriptor support (required for manufacturer, product and serial string configuration) - non-removable-ports : Should specify the ports which have a non-removable
Re: [PATCH 8/9 v2] usb: usb251xb: Add max power/current dts property support
In reply to Rob HerringQuoted 11 lines · Rob Herring
Quoted 10 lines · Serge Semin
This parameters may be varied in accordance with hardware specifics. So lets add the corresponding settings to the usb251x driver dts specification.
Signed-off-by Serge Semin <[email protected]>--- Documentation/devicetree/bindings/usb/usb251xb.txt | 6 ++++++ drivers/usb/misc/usb251xb.c | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-)
Quoted 17 lines
Quoted 5 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +0
-0Documentation/devicetree/bindings/usb/usb251xb.txt Optional properties : · line 52
Quoted 9 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +6
-0@@ -44,6 +44,12 @@ Optional properties : device connected. - sp-disabled-ports : Specifies the ports which will be self-power disabled - bp-disabled-ports : Specifies the ports which will be bus-power disabled + - sp-max-{power,current} : Indicates the power/current consumed by hub from + an upstream port (VBUS) when operation as a self-powered hub. The value + is given in mA in a 0 - 100 range (default is 1mA). + - bp-max-{power,current} : Indicates the power/current consumed by hub from + an upstream port (VBUS) when operation as a bus-powered hub. The value + is given in mA in a 0 - 510 range (default is 100mA).These need units as defined in property-units.txt.
Ok.
Quoted 2 lines
Why do you need power and current? Can't you calculate power?
These are different parameters of the device. They got different configuration registers and descriptions:
max_power* - ... This value also includes the power consumption of a permanently attached peripheral if the hub is configured as a compound device, and the embedded peripheral reports 0mA in its descriptors. max_current* - ... This value does NOT include the power consumption of a permanently attached peripheral if the hub is configured as a compound device.
Additionally as you can see, they both are measured in "mA", so it isn't a real physical power.
Quoted 3 lines
Quoted 3 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +0
-0- power-on-time-ms : Specifies the time it takes from the time the host initiates the power-on sequence to a port until the port has adequate power. The value is given in ms in a 0 - 510 range (default is 100ms).
Re: [PATCH 9/9 v2] usb: usb251xb: Use GPIO descriptor consumer interface
In reply to Rob HerringQuoted 11 lines · Rob Herring
Quoted 9 lines · Serge Semin
The driver used to be developed with legacy GPIO API support. It's better to use descriptor-based interface for several reasons. First of all the legacy API doesn't support the ACTIVE_LOW/HIGH flag of dts nodes, which is essential since different hardware may have different GPIOs connectivity including the logical value inversion. Secondly, by requesting the reset GPIO descriptor the driver prevent the other applications from changing its value. And last but not least the legacy GPIO interface should be avoided in the new code due to it obsolescence.
Quoted 3 lines
All this has nothing to do with the binding. Please make the binding change separate and state why it should be optional.
Ok.
Quoted 6 lines
Quoted 6 lines
Signed-off-by Serge Semin <[email protected]>--- Documentation/devicetree/bindings/usb/usb251xb.txt | 2 +- drivers/usb/misc/usb251xb.c | 34 +++++++++------------- 2 files changed, 15 insertions(+), 21 deletions(-)
Greg KH
maintainerRe: [PATCH 9/9 v2] usb: usb251xb: Use GPIO descriptor consumer interface
In reply to Serge Semindrivers/usb/misc/usb251xb.c line 6
Quoted 9 lines · Serge Semin
drivers/usb/misc/usb251xb.c +1
-0@@ -3,6 +3,7 @@* Configuration via SMBus. * * Copyright (c) 2017 SKIDATA AG +* Copyright (c) 2017 T-platforms
Again, no, please consult with your corporate lawyers why this isn't ok.
greg k-h
Re: [PATCH 9/9 v2] usb: usb251xb: Use GPIO descriptor consumer interface
Quoted 13 lines · Greg KH
drivers/usb/misc/usb251xb.c line 6
Quoted 9 lines · Serge Semin
drivers/usb/misc/usb251xb.c +1
-0@@ -3,6 +3,7 @@* Configuration via SMBus. * * Copyright (c) 2017 SKIDATA AG +* Copyright (c) 2017 T-platforms Again, no, please consult with your corporate lawyers why this isn't ok.
Quoted 1 line
greg k-h
I still can't see why this isn't right. We submitted the patchset. It is not that big and still it isn't just two lines. As I've seen all over the kernel, It is a common practice to have multiple copyrights in kernel files. We are not claiming the copyright to the whole file, but to the contribution only. I got a consent to contribute when I was employed by the company. What's wrong with that? Shall I send the patchset from my corporate e-mail then?
-Sergey
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Greg KH
maintainerRe: [PATCH 9/9 v2] usb: usb251xb: Use GPIO descriptor consumer interface
Quoted 14 lines · Serge Semin
Quoted 13 lines · Greg KH
drivers/usb/misc/usb251xb.c line 6
Quoted 9 lines · Serge Semin
drivers/usb/misc/usb251xb.c +1
-0@@ -3,6 +3,7 @@* Configuration via SMBus. * * Copyright (c) 2017 SKIDATA AG +* Copyright (c) 2017 T-platforms Again, no, please consult with your corporate lawyers why this isn't ok.
Quoted 8 lines
Quoted 1 line
greg k-h
I still can't see why this isn't right. We submitted the patchset. It is not that big and still it isn't just two lines. As I've seen all over the kernel, It is a common practice to have multiple copyrights in kernel files. We are not claiming the copyright to the whole file, but to the contribution only. I got a consent to contribute when I was employed by the company. What's wrong with that? Shall I send the patchset from my corporate e-mail then?
Well, yes, I need some way to properly identify that this corporation did do the changes. I said that before, I don't know why you ignored that.
And yes, multiple copyrights are just fine, but again, please talk to your corporate lawyer about why these changes don't seem to warrant that "mark". If they do think that they do warrant that, great, I will be glad to discuss that with them, off-list if needed.
For even more fun, try discussing with your lawyers about why copyright marks like this don't even mean anything anymore, and haven't for 20+ years now (can't remember the actual date...) But that's a different topic, and one not really relevant here.
thanks,
greg k-h
Rob Herring
maintainerRe: [PATCH 8/9 v2] usb: usb251xb: Add max power/current dts property support
In reply to Serge SeminQuoted 35 lines · Serge Semin
Quoted 11 lines · Rob Herring
Quoted 10 lines · Serge Semin
This parameters may be varied in accordance with hardware specifics. So lets add the corresponding settings to the usb251x driver dts specification.
Signed-off-by Serge Semin <[email protected]>--- Documentation/devicetree/bindings/usb/usb251xb.txt | 6 ++++++ drivers/usb/misc/usb251xb.c | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-)Quoted 17 lines
Quoted 5 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +0
-0Documentation/devicetree/bindings/usb/usb251xb.txt Optional properties : · line 52
Quoted 9 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +6
-0@@ -44,6 +44,12 @@ Optional properties : device connected. - sp-disabled-ports : Specifies the ports which will be self-power disabled - bp-disabled-ports : Specifies the ports which will be bus-power disabled + - sp-max-{power,current} : Indicates the power/current consumed by hub from + an upstream port (VBUS) when operation as a self-powered hub. The value + is given in mA in a 0 - 100 range (default is 1mA). + - bp-max-{power,current} : Indicates the power/current consumed by hub from + an upstream port (VBUS) when operation as a bus-powered hub. The value + is given in mA in a 0 - 510 range (default is 100mA).These need units as defined in property-units.txt.
Ok.
Quoted 2 lines
Why do you need power and current? Can't you calculate power?
Quoted 8 lines
These are different parameters of the device. They got different configuration registers and descriptions:
max_power* - ... This value also includes the power consumption of a permanently attached peripheral if the hub is configured as a compound device, and the embedded peripheral reports 0mA in its descriptors. max_current* - ... This value does NOT include the power consumption of a permanently attached peripheral if the hub is configured as a compound device.
Then the names here should somehow reflect the above. Perhaps "composite-current" and "hub-current" or something like that.
Quoted 3 lines
Additionally as you can see, they both are measured in "mA", so it isn't a real physical power.
Well, I can't because there's no units.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Rob Herring
maintainerRe: [PATCH 1/5] usb: usb251xb: Add USB2517/i hub support
In reply to Serge SeminQuoted 17 lines · Serge Semin
Quoted 6 lines · Rob Herring
Quoted 5 lines · Serge Semin
USB2517i hubs are very like USB251xb devices series. They have almost the same configuration registers space except number of ports, led configurations and lack of battery settings. All these peculiarities are reflected in this patch.
Quoted 9 lines
Quoted 3 lines
Signed-off-by Serge Semin <[email protected]>--- Documentation/devicetree/bindings/usb/usb251xb.txt | 4 +-Though Greg wants the code split, I want the binding as one change. H/w doesn't gain features one by one.
It's preferred to split bindings to a separate patch.
Quoted 8 lines
Folks, you are really driving people crazy. When I was reviewing a kernel-patchset from a Logan-guy, I asked him to combine some of his patches, since in fact their combination represented one solid driver. I was told to go very far, and Greg supported him with it. I'm not going to be that rude and will do as you asked me to. But really, isn't it possible to have some strict rule created so a developer would always follow it thereby not being asked to combine/split patches almost everytime?
The only way I see for now is to know each maintainer personal preferences.
That rule is in Documentation/devicetree/bindings/submitting-patches.txt.
I generally only ask to respin and split bindings if there's other changes.
Quoted 26 lines
Quoted 17 lines
Quoted 17 lines
drivers/usb/misc/usb251xb.c | 84 +++++++++++++++++++--- 2 files changed, 78 insertions(+), 10 deletions(-)Documentation/devicetree/bindings/usb/usb251xb.txt +2
-1@@ -6,7 +6,8 @@ Hi-Speed Controller. Required properties : - compatible : Should be "microchip,usb251xb" or one of the specific types: "microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b", - "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi" + "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi", + "microchip,usb2517", "microchip,usb2517i" - reset-gpios : Should specify the gpio for hub reset - reg : I2C address on the selected bus (default is <0x2C>)Quoted 8 lines
Documentation/devicetree/bindings/usb/usb251xb.txt Optional properties : · line 40
Quoted 5 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +1
-0@@ -36,6 +37,7 @@ Optional properties : an invalid value is given, the default is used instead. - compound-device : indicate the hub is part of a compound device - port-mapping-mode : enable port mapping mode + - speed-led-mode : led speed indiation mode selection (usb2517 only)This is a boolean or has values? What are valid values?
Quoted 2 lines
It's boolean. Shall I rename it as:
"- speed-led-mode : enable led speed indication mode (usb2517 only)"?
Having the the word "boolean" in there would help.
Quoted 8 lines
Quoted 2 lines
This needs a vendor prefix. Somehow the other properties got in without.
Hmm, it's not vendor specific, but device-specific. USB2517 is produced by the same vendor - microchip. The new device got almost the same functionality as the others, except number or ports, LED feature and battery enable feature. The last one isn't configurable by dts. The rest of the properties are the same for all the compatible devices. So what properties you are talking about then?
Well, we don't name things after devices. Properties are either common (either from DT Spec or a class of device (clocks, regulators, USB device, USB hubs, etc.)) or vendor specific. I haven't looked at which other ones specifically could be common for hubs or USB devices and which ones should be MicroChip specific.
Rob
Re: [PATCH 8/9 v2] usb: usb251xb: Add max power/current dts property support
In reply to Rob HerringQuoted 45 lines · Rob Herring
Quoted 35 lines · Serge Semin
Quoted 11 lines · Rob Herring
Quoted 10 lines · Serge Semin
This parameters may be varied in accordance with hardware specifics. So lets add the corresponding settings to the usb251x driver dts specification.
Signed-off-by Serge Semin <[email protected]>--- Documentation/devicetree/bindings/usb/usb251xb.txt | 6 ++++++ drivers/usb/misc/usb251xb.c | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-)Quoted 17 lines
Quoted 5 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +0
-0Documentation/devicetree/bindings/usb/usb251xb.txt Optional properties : · line 52
Quoted 9 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +6
-0@@ -44,6 +44,12 @@ Optional properties : device connected. - sp-disabled-ports : Specifies the ports which will be self-power disabled - bp-disabled-ports : Specifies the ports which will be bus-power disabled + - sp-max-{power,current} : Indicates the power/current consumed by hub from + an upstream port (VBUS) when operation as a self-powered hub. The value + is given in mA in a 0 - 100 range (default is 1mA). + - bp-max-{power,current} : Indicates the power/current consumed by hub from + an upstream port (VBUS) when operation as a bus-powered hub. The value + is given in mA in a 0 - 510 range (default is 100mA).These need units as defined in property-units.txt.
Ok.
Quoted 2 lines
Why do you need power and current? Can't you calculate power?
Quoted 8 lines
These are different parameters of the device. They got different configuration registers and descriptions:
max_power* - ... This value also includes the power consumption of a permanently attached peripheral if the hub is configured as a compound device, and the embedded peripheral reports 0mA in its descriptors. max_current* - ... This value does NOT include the power consumption of a permanently attached peripheral if the hub is configured as a compound device.
Quoted 3 lines
Then the names here should somehow reflect the above. Perhaps "composite-current" and "hub-current" or something like that.
I left the naming in accordance with the device datasheet. I thought it would be better since the driver user would still need to consult with the device documentation to properly set them. I don't really get how the difference is reflected with the naming declared there though. So what naming would you prefer then? Might be something like:
{sp,bp}-max-total-current - for so named {sp,bp}-max-power, since it includes all the permanently attached peripherals.
{sp,bp}-max-removable-current - for so named {sp,bp}-max-current, since it doesn't include the permanently attached peripherals.
Or is it better to leave it in compliance with the documentation naming?
Quoted 6 lines
Quoted 3 lines
Additionally as you can see, they both are measured in "mA", so it isn't a real physical power.
Well, I can't because there's no units.
What this line means then?
- sp-max-{power,current} : ... The value is given in mA in a 0 - 100 range (default is 1mA).
- bp-max-{power,current} : ... The value is given in mA in a 0 - 510 range (default is 100mA).
Maybe I don't know something and the description line should state the units somehow clearer?
Quoted 1 line
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/5] usb: usb251xb: Add USB2517/i hub support
In reply to Rob HerringQuoted 27 lines · Rob Herring
Quoted 17 lines · Serge Semin
Quoted 6 lines · Rob Herring
Quoted 5 lines · Serge Semin
USB2517i hubs are very like USB251xb devices series. They have almost the same configuration registers space except number of ports, led configurations and lack of battery settings. All these peculiarities are reflected in this patch.
Quoted 9 lines
Quoted 3 lines
Signed-off-by Serge Semin <[email protected]>--- Documentation/devicetree/bindings/usb/usb251xb.txt | 4 +-Though Greg wants the code split, I want the binding as one change. H/w doesn't gain features one by one.
It's preferred to split bindings to a separate patch.
Quoted 8 lines
Folks, you are really driving people crazy. When I was reviewing a kernel-patchset from a Logan-guy, I asked him to combine some of his patches, since in fact their combination represented one solid driver. I was told to go very far, and Greg supported him with it. I'm not going to be that rude and will do as you asked me to. But really, isn't it possible to have some strict rule created so a developer would always follow it thereby not being asked to combine/split patches almost everytime?
The only way I see for now is to know each maintainer personal preferences.
Quoted 4 lines
That rule is in
Documentation/devicetree/bindings/submitting-patches.txt.I generally only ask to respin and split bindings if there's other changes.
Great! I didn't know there is a document like that. Ok. From now I'll do as it's prescribed there.
Quoted 40 lines
Quoted 26 lines
Quoted 17 lines
Quoted 17 lines
drivers/usb/misc/usb251xb.c | 84 +++++++++++++++++++--- 2 files changed, 78 insertions(+), 10 deletions(-)Documentation/devicetree/bindings/usb/usb251xb.txt +2
-1@@ -6,7 +6,8 @@ Hi-Speed Controller. Required properties : - compatible : Should be "microchip,usb251xb" or one of the specific types: "microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b", - "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi" + "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi", + "microchip,usb2517", "microchip,usb2517i" - reset-gpios : Should specify the gpio for hub reset - reg : I2C address on the selected bus (default is <0x2C>)Quoted 8 lines
Documentation/devicetree/bindings/usb/usb251xb.txt Optional properties : · line 40
Quoted 5 lines
Documentation/devicetree/bindings/usb/usb251xb.txt +1
-0@@ -36,6 +37,7 @@ Optional properties : an invalid value is given, the default is used instead. - compound-device : indicate the hub is part of a compound device - port-mapping-mode : enable port mapping mode + - speed-led-mode : led speed indiation mode selection (usb2517 only)This is a boolean or has values? What are valid values?
Quoted 2 lines
It's boolean. Shall I rename it as:
"- speed-led-mode : enable led speed indication mode (usb2517 only)"?Having the the word "boolean" in there would help.
Quoted 8 lines
Quoted 2 lines
This needs a vendor prefix. Somehow the other properties got in without.
Hmm, it's not vendor specific, but device-specific. USB2517 is produced by the same vendor - microchip. The new device got almost the same functionality as the others, except number or ports, LED feature and battery enable feature. The last one isn't configurable by dts. The rest of the properties are the same for all the compatible devices. So what properties you are talking about then?
Quoted 6 lines
Well, we don't name things after devices. Properties are either common (either from DT Spec or a class of device (clocks, regulators, USB device, USB hubs, etc.)) or vendor specific. I haven't looked at which other ones specifically could be common for hubs or USB devices and which ones should be MicroChip specific.
Alright. I found the recommended vendor-specific prefix, it's "microchip". What's next? The thing is, that this driver isn't usual USB root port controller driver. It's the driver to perform the usb251x hubs configuration on boot time in accordance with the hardware specifics. So to speak, this driver is something like EEPROM firmware embedded in the kernel and configured by device tree node properties. I can't be sure, whether all of these settings might be vendor specific, or some of them still can be exposed by the hubs of other vendors. Most of the circuit designers just add real EEPROMs to be connected to hubs, so their configurations would be loaded from them. What shall we do with this bindings then? Shall we add the vendor-specific vendor to the bindings file?
Quoted 1 line
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 9/9 v2] usb: usb251xb: Use GPIO descriptor consumer interface
In reply to Greg KHQuoted 33 lines · Greg KH
Quoted 14 lines · Serge Semin
Quoted 13 lines · Greg KH
drivers/usb/misc/usb251xb.c line 6
Quoted 9 lines · Serge Semin
drivers/usb/misc/usb251xb.c +1
-0@@ -3,6 +3,7 @@* Configuration via SMBus. * * Copyright (c) 2017 SKIDATA AG +* Copyright (c) 2017 T-platforms Again, no, please consult with your corporate lawyers why this isn't ok.
Quoted 8 lines
Quoted 1 line
greg k-h
I still can't see why this isn't right. We submitted the patchset. It is not that big and still it isn't just two lines. As I've seen all over the kernel, It is a common practice to have multiple copyrights in kernel files. We are not claiming the copyright to the whole file, but to the contribution only. I got a consent to contribute when I was employed by the company. What's wrong with that? Shall I send the patchset from my corporate e-mail then?
Well, yes, I need some way to properly identify that this corporation did do the changes. I said that before, I don't know why you ignored that.
And yes, multiple copyrights are just fine, but again, please talk to your corporate lawyer about why these changes don't seem to warrant that "mark". If they do think that they do warrant that, great, I will be glad to discuss that with them, off-list if needed.
Quoted 8 lines
For even more fun, try discussing with your lawyers about why copyright marks like this don't even mean anything anymore, and haven't for 20+ years now (can't remember the actual date...) But that's a different topic, and one not really relevant here.
thanks,
greg k-h
Alright then. We'll remove the Copyright mark and I'll resend the patchset from my corporate e-mail. Hope it will solve this issue.
Could you review the rest of the patchset?
Regards,
-Sergey
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Greg KH
maintainerRe: [PATCH 9/9 v2] usb: usb251xb: Use GPIO descriptor consumer interface
Quoted 39 lines · Serge Semin
Quoted 38 lines · Greg KH
Quoted 14 lines · Serge Semin
Quoted 13 lines · Greg KH
drivers/usb/misc/usb251xb.c line 6
Quoted 9 lines · Serge Semin
drivers/usb/misc/usb251xb.c +1
-0@@ -3,6 +3,7 @@* Configuration via SMBus. * * Copyright (c) 2017 SKIDATA AG +* Copyright (c) 2017 T-platforms Again, no, please consult with your corporate lawyers why this isn't ok.
Quoted 8 lines
Quoted 1 line
greg k-h
I still can't see why this isn't right. We submitted the patchset. It is not that big and still it isn't just two lines. As I've seen all over the kernel, It is a common practice to have multiple copyrights in kernel files. We are not claiming the copyright to the whole file, but to the contribution only. I got a consent to contribute when I was employed by the company. What's wrong with that? Shall I send the patchset from my corporate e-mail then?
Well, yes, I need some way to properly identify that this corporation did do the changes. I said that before, I don't know why you ignored that.
And yes, multiple copyrights are just fine, but again, please talk to your corporate lawyer about why these changes don't seem to warrant that "mark". If they do think that they do warrant that, great, I will be glad to discuss that with them, off-list if needed.
For even more fun, try discussing with your lawyers about why copyright marks like this don't even mean anything anymore, and haven't for 20+ years now (can't remember the actual date...) But that's a different topic, and one not really relevant here.
Quoted 7 lines
Quoted 3 lines
thanks,
greg k-h
Alright then. We'll remove the Copyright mark and I'll resend the patchset from my corporate e-mail. Hope it will solve this issue.
Could you review the rest of the patchset?
I'll wait for the resend, as Rob already pointed out issues, so it is long-gone from my patchqueue.
thanks,
greg k-h
Richard Leitner
maintainerRe: [PATCH 2/9 v2] usb: usb251xb: Add USB251x specific port count setting
In reply to Serge SeminQuoted 16 lines · Serge Semin
USB251xb as well as USB2517 datasheet states, that all these hubs differ by number of ports declared as the last digit in the model name. So USB2512 got two ports, USB2513 - three, and so on. Such setting must be reflected in the device specific data structure and corresponding dts property should be checked whether it doesn't get out of available ports.
Signed-off-by Serge Semin <[email protected]>--- drivers/usb/misc/usb251xb.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)drivers/usb/misc/usb251xb.c +0
-0
...
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 437
Quoted 10 lines
drivers/usb/misc/usb251xb.c +3
-1@@ -422,8 +431,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,for (i =0 ; i < len /sizeof (u32); i++) {u32 port =be32_to_cpu (cproperty_u32[i]); -if ((port >=1 ) && (port <=4 )) +if ((port >=1 ) && (port <= data->port_cnt)) hub->non_rem_dev |=BIT (port); +else +dev_warn (dev,"port %u doesn't exist\n" , port);
I'd prefer to add the (invalid) property trying to be set in this warning messages. So someone is able to find the invalid dt setting faster. Something like;
dev_warn(dev, "requested NRD port %u doesn't exist\n", port);
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 450
Quoted 12 lines
drivers/usb/misc/usb251xb.c +3
-1} }@@ -433,8 +444,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,for (i =0 ; i < len /sizeof (u32); i++) {u32 port =be32_to_cpu (cproperty_u32[i]); -if ((port >=1 ) && (port <=4 )) +if ((port >=1 ) && (port <= data->port_cnt)) hub->port_disable_sp |=BIT (port); +else +dev_warn (dev,"port %u doesn't exist\n" , port);
... same as above. For example:
dev_warn(dev, "requested PDS port %u doesn't exist\n", port);
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 463
Quoted 12 lines
drivers/usb/misc/usb251xb.c +3
-1} }@@ -444,8 +457,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,for (i =0 ; i < len /sizeof (u32); i++) {u32 port =be32_to_cpu (cproperty_u32[i]); -if ((port >=1 ) && (port <=4 )) +if ((port >=1 ) && (port <= data->port_cnt)) hub->port_disable_bp |=BIT (port); +else +dev_warn (dev,"port %u doesn't exist\n" , port);
... same as above. For example:
dev_warn(dev, "requested PDB port %u doesn't exist\n", port);
Apart from that this patch looks fine for me. Thanks for the spot of the hardcoded max ports check.
regards,
Richard.L
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Richard Leitner
maintainerRe: [PATCH 1/9 v2] usb: usb251xb: Add USB2517i specific struct and IDs
In reply to Serge SeminHi Serge,
Quoted 11 lines · Serge Semin
There are USB2517 and USB2517i hubs, which have almost the same registers space as already supported USB251xbi series. The difference it in DIDs and in few functions. This patch adds the USB2517/i data structures to the driver, so it would have different setting depending on the device discovered on i2c-bus.
Signed-off-by Serge Semin <[email protected]>--- Documentation/devicetree/bindings/usb/usb251xb.txt | 3 ++- drivers/usb/misc/usb251xb.c | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-)
...
Please also mention support for the USB2517(i) hubs in the Kconfig helptext of the driver @ drivers/usb/misc/Kconfig. Thanks.
Apart from that the patch looks good to me.
regards,
Richard.L
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/9 v2] usb: usb251xb: Add 5,6,7 ports mapping def setting
In reply to Serge SeminQuoted 2 lines · Serge Semin
USB2517 got three additionl downstream ports, which can as well be mapped to another logical ports. USB2551xb driver
typo in "USB251xb"
Quoted 9 lines
currently doesn't fully support such setting configuration from dts file. This patch doesn't change this, but adds usb2517 spcific ports default liner mapping.
Signed-off-by Serge Semin <[email protected]>--- drivers/usb/misc/usb251xb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Code itself looks good to me, therefore feel free to add:
regards,
Richard.L
Re: [PATCH 4/9 v2] usb: usb251xb: Add 5,6,7 ports boost settings
In reply to Serge SeminQuoted 11 lines · Serge Semin
USB electrical signaling drive strength boost bit is also supported by USB2517 hub. Since it got three addition ports, the designers needed to add one more register for initialization. It turned out to be formerly reserved
0xF7. As before we just initialize it with default zeros.Signed-off-by Serge Semin <[email protected]>--- drivers/usb/misc/usb251xb.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
Looks good to me. Feel free to add:
regards,
Richard.L
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Richard Leitner
maintainerRe: [PATCH 8/9 v2] usb: usb251xb: Add max power/current dts property support
In reply to Serge SeminQuoted 2 lines · Serge Semin
Quoted 1 line · Rob Herring
On Wed, Sep 20, 2017 at 4:27 PM, Serge Semin <[email protected]> wrote:
...
Quoted 23 lines
Quoted 9 lines
Quoted 8 lines
These are different parameters of the device. They got different configuration registers and descriptions:
max_power* - ... This value also includes the power consumption of a permanently attached peripheral if the hub is configured as a compound device, and the embedded peripheral reports 0mA in its descriptors. max_current* - ... This value does NOT include the power consumption of a permanently attached peripheral if the hub is configured as a compound device.Quoted 3 lines
Then the names here should somehow reflect the above. Perhaps "composite-current" and "hub-current" or something like that.
I left the naming in accordance with the device datasheet. I thought it would be better since the driver user would still need to consult with the device documentation to properly set them. I don't really get how the difference is reflected with the naming declared there though. So what naming would you prefer then? Might be something like:
{sp,bp}-max-total-current - for so named {sp,bp}-max-power, since it includes all the permanently attached peripherals.
{sp,bp}-max-removable-current - for so named {sp,bp}-max-current, since it doesn't include the permanently attached peripherals.
Quoted 1 line
Or is it better to leave it in compliance with the documentation naming?
I'd prefer the naming to be in accordance with the device datasheet too. Changing it will IMHO generate avoidable misunderstandings...
But if we should go with Robs proposal please make sure the name from the device datasheet is mentioned somewhere in the description of the binding.
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Additionally as you can see, they both are measured in "mA", so it isn't a real physical power.
Well, I can't because there's no units.
Quoted 6 lines
What this line means then?
- sp-max-{power,current} : ... The value is given in mA in a 0 - 100 range (default is 1mA).
- bp-max-{power,current} : ... The value is given in mA in a 0 - 510 range (default is 100mA).Maybe I don't know something and the description line should state the units somehow clearer?
Append the unit to the binding name, just like in "power-on-time-ms". As there's no "Standard Unit Suffix" for mA stated in the documentation (Documentation/devicetree/bindings/property-units.txt) I think it should be "-milliamp"?
regards,
Richard.L
Rob Herring
maintainerRe: [PATCH 8/9 v2] usb: usb251xb: Add max power/current dts property support
Quoted 30 lines · Richard Leitner
Quoted 2 lines · Serge Semin
Quoted 1 line · Rob Herring
On Wed, Sep 20, 2017 at 4:27 PM, Serge Semin <[email protected]> wrote:
...
Quoted 23 lines
Quoted 9 lines
Quoted 8 lines
These are different parameters of the device. They got different configuration registers and descriptions:
max_power* - ... This value also includes the power consumption of a permanently attached peripheral if the hub is configured as a compound device, and the embedded peripheral reports 0mA in its descriptors. max_current* - ... This value does NOT include the power consumption of a permanently attached peripheral if the hub is configured as a compound device.Quoted 3 lines
Then the names here should somehow reflect the above. Perhaps "composite-current" and "hub-current" or something like that.
I left the naming in accordance with the device datasheet. I thought it would be better since the driver user would still need to consult with the device documentation to properly set them. I don't really get how the difference is reflected with the naming declared there though. So what naming would you prefer then? Might be something like:
{sp,bp}-max-total-current - for so named {sp,bp}-max-power, since it includes all the permanently attached peripherals.
{sp,bp}-max-removable-current - for so named {sp,bp}-max-current, since it doesn't include the permanently attached peripherals.
Quoted 4 lines
Quoted 1 line
Or is it better to leave it in compliance with the documentation naming?
I'd prefer the naming to be in accordance with the device datasheet too. Changing it will IMHO generate avoidable misunderstandings...
Okay, then add a vendor prefix.
Quoted 18 lines
But if we should go with Robs proposal please make sure the name from the device datasheet is mentioned somewhere in the description of the binding.
Quoted 14 lines
Quoted 7 lines
Quoted 4 lines
Additionally as you can see, they both are measured in "mA", so it isn't a real physical power.
Well, I can't because there's no units.
What this line means then?
- sp-max-{power,current} : ... The value is given in mA in a 0 - 100 range (default is 1mA).
- bp-max-{power,current} : ... The value is given in mA in a 0 - 510 range (default is 100mA).Maybe I don't know something and the description line should state the units somehow clearer?
The reason we have units in the name is so we don't have to go lookup the documentation to find the units and so people don't use the same property name with different units.
Quoted 4 lines
Append the unit to the binding name, just like in "power-on-time-ms". As there's no "Standard Unit Suffix" for mA stated in the documentation (
Documentation/devicetree/bindings/property-units.txt) I think it should be "-milliamp"?
The reason being is we align around microamps and try to avoid everyone picking their own units (celliamps anyone?). So unless microamps is not enough range for you, I would stick with that.
If you have both units and vendor prefix, then I care less about the poorly written datasheet naming used.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
v3 cover usb: usb251xb: Add USB2517i hub support and fix some bugs
In reply to Serge SeminPrimarily it was intended to just add USB2517 hub support to the driver. But after tests a bug and inconistency were discovered. So it was decided to make the following changes:
Changelog v1:
- Add USB2517/i hub specifics support to the driver
- Fix property_u32 NULL-pointer dereference
- Add new {bus,self}-max-{power,curret} dts properties
- Replace legacy GPIO API usage with descriptor-based one
Changelog v2:
- Split first patch into smaller ones
- Fix invalid BOOST_14 register definition
- Combine copyrights adding patch into the last one
Changelog v3:
- Move bindings documentation updates to a separate patch
- Add "boolean" info to the corresponding properties
- Rename {sp,bp}-max-{power,current} with a better readable {sp,bp}-max-{total,removable}-current-microamp
- Discard Copyright line
- Add better reason text for dev_warn()'s
- Set led-speed-mode being default
- Fix some types
Serge Semin (10):
usb: usb251xb: Update usb251xb bindings
usb: usb251xb: Add USB2517i specific struct and IDs
usb: usb251xb: Add USB251x specific port count setting
usb: usb251xb: Add 5,6,7 ports mapping def setting
usb: usb251xb: Add 5,6,7 ports boost settings
usb: usb251xb: Add battery enable setting flag
usb: usb251xb: Add USB2517 LED settings
usb: usb251xb: Fix property_u32 NULL pointer dereference
usb: usb251xb: Add max power/current dts property support
usb: usb251xb: Use GPIO descriptor consumer interface
.../devicetree/bindings/usb/usb251xb.txt | 46 ++++-- kernel/drivers/usb/misc/Kconfig | 4 +- kernel/drivers/usb/misc/usb251xb.c | 166 +++++++++++++++------ 3 files changed, 158 insertions(+), 58 deletions(-)
Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 1/10 usb: usb251xb: Update usb251xb bindings
Since hub usb2517 is going to be supported by the usb251xb driver, the bindings need to be properly updated. Particularly:
- add "microchip,usb2517" and "microchip,usb2517i" compatible strings.
- add "boolean" description to all the properties, which really accept a boolean value including a new one "led-{usb,speed}-mode".
- move reset-gpios property to the optional section. It isn't defined as required in the code and shouldn't be required at all, since hardware may handle reset pins by itself.
- add new led-{usb,speed}-mode mode property. USB2517 device supports two LED modes: USB mode and speed (default) indication mode. The last one can be switched on by this property.
- add {bp,sp}-max-{total,removable}-current-microamp property measured in microamp. It hasn't been defined as property before. Since the limitation specified by these parameters is hardware specific it needs to be defined in dts.
--- .../devicetree/bindings/usb/usb251xb.txt | 46 +++++++++++++++------- 1 file changed, 32 insertions(+), 14 deletions(-)
Documentation/devicetree/bindings/usb/usb251xb.txt +32 -14
@@ -1,16 +1,17 @@ Microchip USB 2.0 Hi-Speed Hub Controller -The device node for the configuration of a Microchip USB251xB/xBi USB 2.0 +The device node for the configuration of a Microchip USB251x/xBi USB 2.0 Hi-Speed Controller. Required properties : - compatible : Should be "microchip,usb251xb" or one of the specific types: "microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b", - "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi" - - reset-gpios : Should specify the gpio for hub reset + "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi", + "microchip,usb2517", "microchip,usb2517i" - reg : I2C address on the selected bus (default is <0x2C>) Optional properties : + - reset-gpios : Should specify the gpio for hub reset - skip-config : Skip Hub configuration, but only send the USB-Attach command - vendor-id : Set USB Vendor ID of the hub (16 bit, default is 0x0424) - product-id : Set USB Product ID of the hub (16 bit, default depends on type)
@@ -19,29 +20,47 @@ Optional properties : - manufacturer : Set USB Manufacturer string (max 31 characters long) - product : Set USB Product string (max 31 characters long) - serial : Set USB Serial string (max 31 characters long) - - {bus,self}-powered : selects between self- and bus-powered operation (default - is self-powered) - - disable-hi-speed : disable USB Hi-Speed support + - {bus,self}-powered : selects between self- and bus-powered operation + (boolean, default is self-powered) + - disable-hi-speed : disable USB Hi-Speed support (boolean) - {multi,single}-tt : selects between multi- and single-transaction-translator - (default is multi-tt) - - disable-eop : disable End of Packet generation in full-speed mode + (boolean, default is multi-tt) + - disable-eop : disable End of Packet generation in full-speed mode (boolean) - {ganged,individual}-sensing : select over-current sense type in self-powered - mode (default is individual) + mode (boolean, default is individual) - {ganged,individual}-port-switching : select port power switching mode - (default is individual) + (boolean, default is individual) - dynamic-power-switching : enable auto-switching from self- to bus-powered - operation if the local power source is removed or unavailable + operation if the local power source is removed or unavailable (boolean) - oc-delay-us : Delay time (in microseconds) for filtering the over-current sense inputs. Valid values are 100, 4000, 8000 (default) and 16000. If an invalid value is given, the default is used instead. - - compound-device : indicate the hub is part of a compound device - - port-mapping-mode : enable port mapping mode + - compound-device : indicate the hub is part of a compound device (boolean) + - port-mapping-mode : enable port mapping mode (boolean) + - led-{usb,speed}-mode : led usb/speed indication mode selection + (boolean, default is speed mode) - string-support : enable string descriptor support (required for manufacturer, product and serial string configuration) - non-removable-ports : Should specify the ports which have a non-removable device connected. - sp-disabled-ports : Specifies the ports which will be self-power disabled - bp-disabled-ports : Specifies the ports which will be bus-power disabled + - sp-max-total-current-microamp: Specifies max current consumed by the hub + from VBUS when operating in self-powered hub. It includes the hub + silicon along with all associated circuitry including a permanently + attached peripheral (range: 0 - 100000 uA, default 1000 uA) + - bp-max-total-current-microamp: Specifies max current consumed by the hub + from VBUS when operating in self-powered hub. It includes the hub + silicon along with all associated circuitry including a permanently + attached peripheral (range: 0 - 510000 uA, default 100000 uA) + - sp-max-removable-current-microamp: Specifies max current consumed by the hub + from VBUS when operating in self-powered hub. It includes the hub + silicon along with all associated circuitry excluding a permanently + attached peripheral (range: 0 - 100000 uA, default 1000 uA) + - bp-max-removable-current-microamp: Specifies max current consumed by the hub + from VBUS when operating in self-powered hub. It includes the hub + silicon along with all associated circuitry excluding a permanently + attached peripheral (range: 0 - 510000 uA, default 100000 uA) - power-on-time-ms : Specifies the time it takes from the time the host initiates the power-on sequence to a port until the port has adequate power. The value is given in ms in a 0 - 510 range (default is 100ms).
@@ -56,7 +75,6 @@ Examples: usb2514b@2c { compatible = "microchip,usb2514b"; reg = <0x2c>; - reset-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>; vendor-id = /bits/ 16 <0x0000>; product-id = /bits/ 16 <0x0000>; string-support;
Signature · 1 line
2.12.0
PATCH v3 2/10 usb: usb251xb: Add USB2517i specific struct and IDs
In reply to Serge SeminThere are USB2517 and USB2517i hubs, which have almost the same registers space as already supported USB251xBi series. The difference it in DIDs and in a few functions. This patch adds the USB2517/i data structures to the driver, so it would have different setting depending on the device discovered on i2c-bus.
--- drivers/usb/misc/Kconfig | 4 ++-- drivers/usb/misc/usb251xb.c | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-)
drivers/usb/misc/Kconfig +2 -2
@@ -247,8 +247,8 @@ config USB_HUB_USB251XB depends on I2C help This option enables support for configuration via SMBus of the - Microchip USB251xB/xBi USB 2.0 Hub Controller series. - Configuration parameters may be set in devicetree or platform data. + Microchip USB251x/xBi USB 2.0 Hub Controller series. Configuration + parameters may be set in devicetree or platform data. Say Y or M here if you need to configure such a device via SMBus. config USB_HSIC_USB3503
drivers/usb/misc/usb251xb.c +21 -2
@@ -38,6 +38,7 @@#define USB251XB_DEF_PRODUCT_ID_12 0x2512/* USB2512B/12Bi */ #define USB251XB_DEF_PRODUCT_ID_13 0x2513/* USB2513B/13Bi */ #define USB251XB_DEF_PRODUCT_ID_14 0x2514/* USB2514B/14Bi */ +#define USB251XB_DEF_PRODUCT_ID_17 0x2517/* USB2517/17i */ #define USB251XB_ADDR_DEVICE_ID_LSB 0x04#define USB251XB_ADDR_DEVICE_ID_MSB 0x05
@@ -82,7 +83,7 @@#define USB251XB_ADDR_PRODUCT_STRING_LEN 0x14#define USB251XB_ADDR_PRODUCT_STRING 0x54 -#define USB251XB_DEF_PRODUCT_STRING "USB251xB/xBi" +#define USB251XB_DEF_PRODUCT_STRING "USB251xB/xBi/7i"#define USB251XB_ADDR_SERIAL_STRING_LEN 0x15#define USB251XB_ADDR_SERIAL_STRING 0x92
@@ -186,6 +187,16 @@ static const struct usb251xb_data usb2514bi_data = { .product_str = "USB2514Bi", }; +static const struct usb251xb_data usb2517_data = { + .product_id =0x2517 , + .product_str ="USB2517" , +}; + +static const struct usb251xb_data usb2517i_data = { + .product_id =0x2517 , + .product_str ="USB2517i" , +}; +static void usb251xb_reset (struct usb251xb *hub,int state) {if (!gpio_is_valid (hub->gpio_reset))
@@ -511,6 +522,12 @@ static const struct of_device_id usb251xb_of_match[] = { .compatible = "microchip,usb2514bi", .data = &usb2514bi_data, }, { + .compatible = "microchip,usb2517", + .data = &usb2517_data, + }, { + .compatible = "microchip,usb2517i", + .data = &usb2517i_data, + }, {/* sentinel */ } };
@@ -574,6 +591,8 @@ static const struct i2c_device_id usb251xb_id[] = { { "usb2513bi", 0 }, { "usb2514b", 0 }, { "usb2514bi", 0 }, + { "usb2517", 0 }, + { "usb2517i", 0 }, { /* sentinel */ } };MODULE_DEVICE_TABLE (i2c, usb251xb_id);
@@ -590,5 +609,5 @@ static struct i2c_driver usb251xb_i2c_driver = {module_i2c_driver (usb251xb_i2c_driver);MODULE_AUTHOR ("Richard Leitner <[email protected]>" ); -MODULE_DESCRIPTION ("USB251xB/xBi USB 2.0 Hub Controller Driver" ); +MODULE_DESCRIPTION ("USB251x/xBi USB 2.0 Hub Controller Driver" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.12.0
PATCH v3 3/10 usb: usb251xb: Add USB251x specific port count setting
In reply to Serge SeminUSB251xb as well as USB2517 datasheet states, that all these hubs differ by number of ports declared as the last digit in the model name. So USB2512 got two ports, USB2513 - three, and so on. Such setting must be reflected in the device specific data structure and corresponding dts property should be checked whether it doesn't get out of available ports.
--- drivers/usb/misc/usb251xb.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/usb/misc/usb251xb.c +21 -3
@@ -154,46 +154,55 @@ struct usb251xb {struct usb251xb_data {u16 product_id; +u8 port_cnt;char product_str[USB251XB_STRING_BUFSIZE /2 ];/* ASCII string */ };static const struct usb251xb_data usb2512b_data = { .product_id =0x2512 , + .port_cnt =2 , .product_str ="USB2512B" , };static const struct usb251xb_data usb2512bi_data = { .product_id =0x2512 , + .port_cnt =2 , .product_str ="USB2512Bi" , };static const struct usb251xb_data usb2513b_data = { .product_id =0x2513 , + .port_cnt =3 , .product_str ="USB2513B" , };static const struct usb251xb_data usb2513bi_data = { .product_id =0x2513 , + .port_cnt =3 , .product_str ="USB2513Bi" , };static const struct usb251xb_data usb2514b_data = { .product_id =0x2514 , + .port_cnt =4 , .product_str ="USB2514B" , };static const struct usb251xb_data usb2514bi_data = { .product_id =0x2514 , + .port_cnt =4 , .product_str ="USB2514Bi" , };static const struct usb251xb_data usb2517_data = { .product_id =0x2517 , + .port_cnt =7 , .product_str ="USB2517" , };static const struct usb251xb_data usb2517i_data = { .product_id =0x2517 , + .port_cnt =7 , .product_str ="USB2517i" , };
@@ -422,8 +431,11 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,for (i =0 ; i < len /sizeof (u32); i++) {u32 port =be32_to_cpu (cproperty_u32[i]); -if ((port >=1 ) && (port <=4 )) +if ((port >=1 ) && (port <= data->port_cnt)) hub->non_rem_dev |=BIT (port); +else +dev_warn (dev,"NRD port %u doesn't exist\n" , + port); } }
@@ -433,8 +445,11 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,for (i =0 ; i < len /sizeof (u32); i++) {u32 port =be32_to_cpu (cproperty_u32[i]); -if ((port >=1 ) && (port <=4 )) +if ((port >=1 ) && (port <= data->port_cnt)) hub->port_disable_sp |=BIT (port); +else +dev_warn (dev,"PDS port %u doesn't exist\n" , + port); } }
@@ -444,8 +459,11 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,for (i =0 ; i < len /sizeof (u32); i++) {u32 port =be32_to_cpu (cproperty_u32[i]); -if ((port >=1 ) && (port <=4 )) +if ((port >=1 ) && (port <= data->port_cnt)) hub->port_disable_bp |=BIT (port); +else +dev_warn (dev,"PDB port %u doesn't exist\n" , + port); } }
Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 4/10 usb: usb251xb: Add 5,6,7 ports mapping def setting
In reply to Serge SeminUSB2517 got three additionl downstream ports, which can as well be mapped to another logical ports. USB251xb driver currently doesn't fully support such setting configuration from dts file. This patch doesn't change this, but adds usb2517 spcific ports default liner mapping.
--- drivers/usb/misc/usb251xb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/usb/misc/usb251xb.c +11 -1
@@ -103,7 +103,11 @@#define USB251XB_ADDR_PORT_MAP_12 0xFB#define USB251XB_DEF_PORT_MAP_12 0x00#define USB251XB_ADDR_PORT_MAP_34 0xFC -#define USB251XB_DEF_PORT_MAP_34 0x00/* USB2513B/i & USB2514B/i only */ +#define USB251XB_DEF_PORT_MAP_34 0x00/* USB251{3B/i,4B/i,7/i} only */ +#define USB251XB_ADDR_PORT_MAP_56 0xFD +#define USB251XB_DEF_PORT_MAP_56 0x00/* USB2517/i only */ +#define USB251XB_ADDR_PORT_MAP_7 0xFE +#define USB251XB_DEF_PORT_MAP_7 0x00/* USB2517/i only */ #define USB251XB_ADDR_STATUS_COMMAND 0xFF#define USB251XB_STATUS_COMMAND_SMBUS_DOWN 0x04
@@ -149,6 +153,8 @@ struct usb251xb {u8 port_swap;u8 port_map12;u8 port_map34; +u8 port_map56; +u8 port_map7;u8 status; };
@@ -278,6 +284,8 @@ static int usb251xb_connect(struct usb251xb *hub) i2c_wb[USB251XB_ADDR_PORT_SWAP ] = hub->port_swap; i2c_wb[USB251XB_ADDR_PORT_MAP_12 ] = hub->port_map12; i2c_wb[USB251XB_ADDR_PORT_MAP_34 ] = hub->port_map34; + i2c_wb[USB251XB_ADDR_PORT_MAP_56 ] = hub->port_map56; + i2c_wb[USB251XB_ADDR_PORT_MAP_7 ] = hub->port_map7; i2c_wb[USB251XB_ADDR_STATUS_COMMAND ] =USB251XB_STATUS_COMMAND_ATTACH ;usb251xb_reset (hub,1 );
@@ -516,6 +524,8 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, hub->port_swap =USB251XB_DEF_PORT_SWAP ; hub->port_map12 =USB251XB_DEF_PORT_MAP_12 ; hub->port_map34 =USB251XB_DEF_PORT_MAP_34 ; + hub->port_map56 =USB251XB_DEF_PORT_MAP_56 ; + hub->port_map7 =USB251XB_DEF_PORT_MAP_7 ;return 0 ; }
Signature · 1 line
2.12.0
PATCH v3 5/10 usb: usb251xb: Add 5,6,7 ports boost settings
In reply to Serge SeminUSB electrical signaling drive strength boost bit is also supported by USB2517 hub. Since it got three addition ports, the designers needed to add one more register for initialization. It turned out to be formerly reserved 0xF7. As before we just initialize it with default zeros.
--- drivers/usb/misc/usb251xb.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/usb/misc/usb251xb.c +10 -5
@@ -94,8 +94,10 @@#define USB251XB_ADDR_BOOST_UP 0xF6#define USB251XB_DEF_BOOST_UP 0x00 -#define USB251XB_ADDR_BOOST_X 0xF8 -#define USB251XB_DEF_BOOST_X 0x00 +#define USB251XB_ADDR_BOOST_57 0xF7 +#define USB251XB_DEF_BOOST_57 0x00 +#define USB251XB_ADDR_BOOST_14 0xF8 +#define USB251XB_DEF_BOOST_14 0x00#define USB251XB_ADDR_PORT_SWAP 0xFA#define USB251XB_DEF_PORT_SWAP 0x00
@@ -149,7 +151,8 @@ struct usb251xb {char serial[USB251XB_STRING_BUFSIZE ];u8 bat_charge_en;u8 boost_up; -u8 boost_x; +u8 boost_57; +u8 boost_14;u8 port_swap;u8 port_map12;u8 port_map34;
@@ -280,7 +283,8 @@ static int usb251xb_connect(struct usb251xb *hub) USB251XB_STRING_BUFSIZE); i2c_wb[USB251XB_ADDR_BATTERY_CHARGING_ENABLE ] = hub->bat_charge_en; i2c_wb[USB251XB_ADDR_BOOST_UP ] = hub->boost_up; - i2c_wb[USB251XB_ADDR_BOOST_X ] = hub->boost_x; + i2c_wb[USB251XB_ADDR_BOOST_57 ] = hub->boost_57; + i2c_wb[USB251XB_ADDR_BOOST_14 ] = hub->boost_14; i2c_wb[USB251XB_ADDR_PORT_SWAP ] = hub->port_swap; i2c_wb[USB251XB_ADDR_PORT_MAP_12 ] = hub->port_map12; i2c_wb[USB251XB_ADDR_PORT_MAP_34 ] = hub->port_map34;
@@ -520,7 +524,8 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, hub->max_current_bp =USB251XB_DEF_MAX_CURRENT_BUS ; hub->bat_charge_en =USB251XB_DEF_BATTERY_CHARGING_ENABLE ; hub->boost_up =USB251XB_DEF_BOOST_UP ; - hub->boost_x =USB251XB_DEF_BOOST_X ; + hub->boost_57 =USB251XB_DEF_BOOST_57 ; + hub->boost_14 =USB251XB_DEF_BOOST_14 ; hub->port_swap =USB251XB_DEF_PORT_SWAP ; hub->port_map12 =USB251XB_DEF_PORT_MAP_12 ; hub->port_map34 =USB251XB_DEF_PORT_MAP_34 ;
Signature · 1 line
2.12.0
PATCH v3 6/10 usb: usb251xb: Add battery enable setting flag
In reply to Serge SeminBattery charging settings are supported by USB251xb hubs only. USB2517i isn't one of them. So we need to reflect it within the device-specific data structure. The driver doesn't support dts property changing this setting, but instead defaults it with zero. So the flag isn't used anywhere in the driver, but still can be helpful in future, when necessity of the corresponding dts setting arises.
--- drivers/usb/misc/usb251xb.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/misc/usb251xb.c +9 -0
@@ -164,54 +164,63 @@ struct usb251xb {struct usb251xb_data {u16 product_id;u8 port_cnt; +bool bat_support;char product_str[USB251XB_STRING_BUFSIZE /2 ];/* ASCII string */ };static const struct usb251xb_data usb2512b_data = { .product_id =0x2512 , .port_cnt =2 , + .bat_support = true, .product_str ="USB2512B" , };static const struct usb251xb_data usb2512bi_data = { .product_id =0x2512 , .port_cnt =2 , + .bat_support = true, .product_str ="USB2512Bi" , };static const struct usb251xb_data usb2513b_data = { .product_id =0x2513 , .port_cnt =3 , + .bat_support = true, .product_str ="USB2513B" , };static const struct usb251xb_data usb2513bi_data = { .product_id =0x2513 , .port_cnt =3 , + .bat_support = true, .product_str ="USB2513Bi" , };static const struct usb251xb_data usb2514b_data = { .product_id =0x2514 , .port_cnt =4 , + .bat_support = true, .product_str ="USB2514B" , };static const struct usb251xb_data usb2514bi_data = { .product_id =0x2514 , .port_cnt =4 , + .bat_support = true, .product_str ="USB2514Bi" , };static const struct usb251xb_data usb2517_data = { .product_id =0x2517 , .port_cnt =7 , + .bat_support = false, .product_str ="USB2517" , };static const struct usb251xb_data usb2517i_data = { .product_id =0x2517 , .port_cnt =7 , + .bat_support = false, .product_str ="USB2517i" , };
Signature · 1 line
2.12.0
PATCH v3 7/10 usb: usb251xb: Add USB2517 LED settings
In reply to Serge SeminUSB2517 supports two LED modes: USB mode and speed (default) indication mode. The last one can be switched on by corresponding dts property. Since USB251xb hubs doesn't support LEDs settings, we need to ignore this setting.
--- drivers/usb/misc/usb251xb.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/usb/misc/usb251xb.c +12 -0
@@ -164,6 +164,7 @@ struct usb251xb {struct usb251xb_data {u16 product_id;u8 port_cnt; +bool led_support;bool bat_support;char product_str[USB251XB_STRING_BUFSIZE /2 ];/* ASCII string */ };
@@ -171,6 +172,7 @@ struct usb251xb_data {static const struct usb251xb_data usb2512b_data = { .product_id =0x2512 , .port_cnt =2 , + .led_support = false, .bat_support = true, .product_str ="USB2512B" , };
@@ -178,6 +180,7 @@ static const struct usb251xb_data usb2512b_data = {static const struct usb251xb_data usb2512bi_data = { .product_id =0x2512 , .port_cnt =2 , + .led_support = false, .bat_support = true, .product_str ="USB2512Bi" , };
@@ -185,6 +188,7 @@ static const struct usb251xb_data usb2512bi_data = {static const struct usb251xb_data usb2513b_data = { .product_id =0x2513 , .port_cnt =3 , + .led_support = false, .bat_support = true, .product_str ="USB2513B" , };
@@ -192,6 +196,7 @@ static const struct usb251xb_data usb2513b_data = {static const struct usb251xb_data usb2513bi_data = { .product_id =0x2513 , .port_cnt =3 , + .led_support = false, .bat_support = true, .product_str ="USB2513Bi" , };
@@ -199,6 +204,7 @@ static const struct usb251xb_data usb2513bi_data = {static const struct usb251xb_data usb2514b_data = { .product_id =0x2514 , .port_cnt =4 , + .led_support = false, .bat_support = true, .product_str ="USB2514B" , };
@@ -206,6 +212,7 @@ static const struct usb251xb_data usb2514b_data = {static const struct usb251xb_data usb2514bi_data = { .product_id =0x2514 , .port_cnt =4 , + .led_support = false, .bat_support = true, .product_str ="USB2514Bi" , };
@@ -213,6 +220,7 @@ static const struct usb251xb_data usb2514bi_data = {static const struct usb251xb_data usb2517_data = { .product_id =0x2517 , .port_cnt =7 , + .led_support = true, .bat_support = false, .product_str ="USB2517" , };
@@ -220,6 +228,7 @@ static const struct usb251xb_data usb2517_data = {static const struct usb251xb_data usb2517i_data = { .product_id =0x2517 , .port_cnt =7 , + .led_support = true, .bat_support = false, .product_str ="USB2517i" , };
@@ -443,6 +452,9 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,if (of_get_property (np,"port-mapping-mode" ,NULL )) hub->conf_data3 |=BIT (3 ); +if (data->led_support &&of_get_property (np,"led-usb-mode" ,NULL )) + hub->conf_data3 &= ~BIT (1 ); +if (of_get_property (np,"string-support" ,NULL )) hub->conf_data3 |=BIT (0 );
Signature · 1 line
2.12.0
PATCH v3 8/10 usb: usb251xb: Fix property_u32 NULL pointer dereference
In reply to Serge SeminThe methods like of_property_read_u32 utilizing the specified pointer permit only the pointer to a preallocated u32 storage as the third argument. As a result the driver crashes on NULL pointer dereference in case if "oc-delay-us" or "power-on-time-ms" declared in dts file.
--- drivers/usb/misc/usb251xb.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/usb/misc/usb251xb.c +7 -7
@@ -348,7 +348,7 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,struct device *dev = hub->dev;struct device_node *np = dev->of_node;int len, err, i; -u32 *property_u32 =NULL ; +u32 property_u32 =0 ;const u32 *cproperty_u32;const char *cproperty_char;char str[USB251XB_STRING_BUFSIZE /2 ];
@@ -425,16 +425,16 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,if (of_get_property (np,"dynamic-power-switching" ,NULL )) hub->conf_data2 |=BIT (7 ); -if (!of_property_read_u32 (np,"oc-delay-us" , property_u32)) { -if (*property_u32 ==100 ) { +if (!of_property_read_u32 (np,"oc-delay-us" , &property_u32)) { +if (property_u32 ==100 ) {/* 100 us*/ hub->conf_data2 &= ~BIT (5 ); hub->conf_data2 &= ~BIT (4 ); - }else if (*property_u32 ==4000 ) { + }else if (property_u32 ==4000 ) {/* 4 ms */ hub->conf_data2 &= ~BIT (5 ); hub->conf_data2 |=BIT (4 ); - }else if (*property_u32 ==16000 ) { + }else if (property_u32 ==16000 ) {/* 16 ms */ hub->conf_data2 |=BIT (5 ); hub->conf_data2 |=BIT (4 );
@@ -501,8 +501,8 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, } hub->power_on_time =USB251XB_DEF_POWER_ON_TIME ; -if (!of_property_read_u32 (np,"power-on-time-ms" , property_u32)) - hub->power_on_time =min_t (u8, *property_u32 /2 ,255 ); +if (!of_property_read_u32 (np,"power-on-time-ms" , &property_u32)) + hub->power_on_time =min_t (u8, property_u32 /2 ,255 );if (of_property_read_u16_array (np,"language-id" , &hub->lang_id,1 )) hub->lang_id =USB251XB_DEF_LANGUAGE_ID ;
Signature · 1 line
2.12.0
PATCH v3 9/10 usb: usb251xb: Add max power/current dts property support
In reply to Serge SeminThis parameters may be varied in accordance with hardware specifics. So lets add the corresponding settings to the usb251xb driver dts specification.
--- drivers/usb/misc/usb251xb.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
drivers/usb/misc/usb251xb.c +20 -4
@@ -500,6 +500,26 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, } } + hub->max_power_sp =USB251XB_DEF_MAX_POWER_SELF ; +if (!of_property_read_u32 (np,"sp-max-total-current-microamp" , + &property_u32)) + hub->max_power_sp =min_t (u8, property_u32 /2000 ,50 ); + + hub->max_power_bp =USB251XB_DEF_MAX_POWER_BUS ; +if (!of_property_read_u32 (np,"bp-max-total-current-microamp" , + &property_u32)) + hub->max_power_bp =min_t (u8, property_u32 /2000 ,255 ); + + hub->max_current_sp =USB251XB_DEF_MAX_CURRENT_SELF ; +if (!of_property_read_u32 (np,"sp-max-removable-current-microamp" , + &property_u32)) + hub->max_current_sp =min_t (u8, property_u32 /2000 ,50 ); + + hub->max_current_bp =USB251XB_DEF_MAX_CURRENT_BUS ; +if (!of_property_read_u32 (np,"bp-max-removable-current-microamp" , + &property_u32)) + hub->max_current_bp =min_t (u8, property_u32 /2000 ,255 ); + hub->power_on_time =USB251XB_DEF_POWER_ON_TIME ;if (!of_property_read_u32 (np,"power-on-time-ms" , &property_u32)) hub->power_on_time =min_t (u8, property_u32 /2 ,255 );
@@ -539,10 +559,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->max_power_sp =USB251XB_DEF_MAX_POWER_SELF ; - hub->max_power_bp =USB251XB_DEF_MAX_POWER_BUS ; - hub->max_current_sp =USB251XB_DEF_MAX_CURRENT_SELF ; - hub->max_current_bp =USB251XB_DEF_MAX_CURRENT_BUS ; hub->bat_charge_en =USB251XB_DEF_BATTERY_CHARGING_ENABLE ; hub->boost_up =USB251XB_DEF_BOOST_UP ; hub->boost_57 =USB251XB_DEF_BOOST_57 ;
Signature · 1 line
2.12.0
PATCH v3 10/10 usb: usb251xb: Use GPIO descriptor consumer interface
In reply to Serge SeminThe driver used to be developed with legacy GPIO API support. It's better to use descriptor-based interface for several reasons. First of all the legacy API doesn't support the ACTIVE_LOW/HIGH flag of dts nodes, which is essential since different hardware may have different GPIOs connectivity including the logical value inversion. Secondly, by requesting the reset GPIO descriptor the driver prevent the other applications from changing its value. And last but not least the legacy GPIO interface should be avoided in the new code due to it obsolescence.
--- drivers/usb/misc/usb251xb.c | 33 +++++++++++---------------- 1 file changed, 13 insertions(+), 20 deletions(-)
drivers/usb/misc/usb251xb.c +13 -20
@@ -20,12 +20,11 @@*/ #include <linux/delay.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/module.h> #include <linux/nls.h> #include <linux/of_device.h> -#include <linux/of_gpio.h> #include <linux/slab.h> /* Internal Register Set Addresses & Default Values acc. to DS00001692C */
@@ -127,7 +126,7 @@ struct usb251xb {struct device *dev;struct i2c_client *i2c;u8 skip_config; -int gpio_reset; +struct gpio_desc *gpio_reset;u16 vendor_id;u16 product_id;u16 device_id;
@@ -235,13 +234,13 @@ static const struct usb251xb_data usb2517i_data = {static void usb251xb_reset (struct usb251xb *hub,int state) { -if (!gpio_is_valid (hub->gpio_reset)) +if (!hub->gpio_reset)return ; -gpio_set_value_cansleep (hub->gpio_reset, state); +gpiod_set_value_cansleep (hub->gpio_reset, state);/* wait for hub recovery/stabilization */ -if (state) +if (!state)usleep_range (500 ,750 );/* >=500us at power on */ else usleep_range (1 ,10 );/* >=1us at power down */
@@ -260,7 +259,7 @@ static int usb251xb_connect(struct usb251xb *hub) i2c_wb[0 ] =0x01 ; i2c_wb[1 ] =USB251XB_STATUS_COMMAND_ATTACH ; -usb251xb_reset (hub,1 ); +usb251xb_reset (hub,0 ); err =i2c_smbus_write_i2c_block_data (hub->i2c,USB251XB_ADDR_STATUS_COMMAND ,2 , i2c_wb);
@@ -310,7 +309,7 @@ static int usb251xb_connect(struct usb251xb *hub) i2c_wb[USB251XB_ADDR_PORT_MAP_7 ] = hub->port_map7; i2c_wb[USB251XB_ADDR_STATUS_COMMAND ] =USB251XB_STATUS_COMMAND_ATTACH ; -usb251xb_reset (hub,1 ); +usb251xb_reset (hub,0 );/* write registers */ for (i =0 ; i < (USB251XB_I2C_REG_SZ /USB251XB_I2C_WRITE_SZ ); i++) {
@@ -363,19 +362,13 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,else hub->skip_config =0 ; - hub->gpio_reset =of_get_named_gpio (np,"reset-gpios" ,0 ); -if (hub->gpio_reset == -EPROBE_DEFER ) + hub->gpio_reset =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH ); +if (PTR_ERR (hub->gpio_reset) == -EPROBE_DEFER ) {return -EPROBE_DEFER ; -if (gpio_is_valid (hub->gpio_reset)) { - err =devm_gpio_request_one (dev, hub->gpio_reset, -GPIOF_OUT_INIT_LOW , -"usb251xb reset" ); -if (err) { -dev_err (dev, -"unable to request GPIO %d as reset pin (%d)\n" , - hub->gpio_reset, err); -return err; - } + }else if (IS_ERR (hub->gpio_reset)) { + err =PTR_ERR (hub->gpio_reset); +dev_err (dev,"unable to request GPIO reset pin (%d)\n" , err); +return err; }if (of_property_read_u16_array (np,"vendor-id" , &hub->vendor_id,1 ))
Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 03/10 v3] usb: usb251xb: Add USB251x specific port count setting
In reply to Serge SeminQuoted 11 lines · Serge Semin
USB251xb as well as USB2517 datasheet states, that all these hubs differ by number of ports declared as the last digit in the model name. So USB2512 got two ports, USB2513 - three, and so on. Such setting must be reflected in the device specific data structure and corresponding dts property should be checked whether it doesn't get out of available ports.
Signed-off-by Serge Semin <[email protected]>--- drivers/usb/misc/usb251xb.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
...
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 438
Quoted 10 lines
drivers/usb/misc/usb251xb.c +4
-1@@ -422,8 +431,11 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,for (i =0 ; i < len /sizeof (u32); i++) {u32 port =be32_to_cpu (cproperty_u32[i]); -if ((port >=1 ) && (port <=4 )) +if ((port >=1 ) && (port <= data->port_cnt)) hub->non_rem_dev |=BIT (port); +else +dev_warn (dev,"NRD port %u doesn't exist\n" , + port);
Please match the alignment of the second line with the open parenthesis.
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 452
Quoted 13 lines
drivers/usb/misc/usb251xb.c +4
-1} }@@ -433,8 +445,11 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,for (i =0 ; i < len /sizeof (u32); i++) {u32 port =be32_to_cpu (cproperty_u32[i]); -if ((port >=1 ) && (port <=4 )) +if ((port >=1 ) && (port <= data->port_cnt)) hub->port_disable_sp |=BIT (port); +else +dev_warn (dev,"PDS port %u doesn't exist\n" , + port);
... same here ...
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 466
Quoted 13 lines
drivers/usb/misc/usb251xb.c +4
-1} }@@ -444,8 +459,11 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,for (i =0 ; i < len /sizeof (u32); i++) {u32 port =be32_to_cpu (cproperty_u32[i]); -if ((port >=1 ) && (port <=4 )) +if ((port >=1 ) && (port <= data->port_cnt)) hub->port_disable_bp |=BIT (port); +else +dev_warn (dev,"PDB port %u doesn't exist\n" , + port);
... and here.
Review static int usb251xb_get_ofdata(struct usb251xb *hub, · line 468
Quoted 2 lines
(quoted diff) +0
-0} }
Otherwise feel free to add:
regards,
Richard.L
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Richard Leitner
maintainerRe: [PATCH 02/10 v3] usb: usb251xb: Add USB2517i specific struct and IDs
In reply to Serge SeminHi,
please see comments below for some nit-picks.
Quoted 17 lines · Serge Semin
There are USB2517 and USB2517i hubs, which have almost the same registers space as already supported USB251xBi series. The difference it in DIDs and in a few functions. This patch adds the USB2517/i data structures to the driver, so it would have different setting depending on the device discovered on i2c-bus.
Signed-off-by Serge Semin <[email protected]>--- drivers/usb/misc/Kconfig | 4 ++-- drivers/usb/misc/usb251xb.c | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-)drivers/usb/misc/Kconfig +0
-0
drivers/usb/misc/Kconfig config USB_HUB_USB251XB · line 251
Quoted 7 lines
drivers/usb/misc/Kconfig +2
-2@@ -247,8 +247,8 @@ config USB_HUB_USB251XB depends on I2C help This option enables support for configuration via SMBus of the - Microchip USB251xB/xBi USB 2.0 Hub Controller series. - Configuration parameters may be set in devicetree or platform data. + Microchip USB251x/xBi USB 2.0 Hub Controller series. Configuration + parameters may be set in devicetree or platform data.
Here you have "USB251x/xBi"...
Quoted 7 lines
drivers/usb/misc/Kconfig +0
-0Say Y or M here if you need to configure such a device via SMBus. config USB_HSIC_USB3503drivers/usb/misc/usb251xb.c +0
-0
...
drivers/usb/misc/usb251xb.c line 86
Quoted 6 lines
drivers/usb/misc/usb251xb.c +1
-1@@ -82,7 +83,7 @@#define USB251XB_ADDR_PRODUCT_STRING_LEN 0x14#define USB251XB_ADDR_PRODUCT_STRING 0x54 -#define USB251XB_DEF_PRODUCT_STRING "USB251xB/xBi" +#define USB251XB_DEF_PRODUCT_STRING "USB251xB/xBi/7i"
but here you have "USB251xB/xBi/7i"...
Quoted 3 lines
drivers/usb/misc/usb251xb.c +0
-0#define USB251XB_ADDR_SERIAL_STRING_LEN 0x15#define USB251XB_ADDR_SERIAL_STRING 0x92
...
drivers/usb/misc/usb251xb.c static struct i2c_driver usb251xb_i2c_driver = { · line 612
Quoted 6 lines
drivers/usb/misc/usb251xb.c +1
-1@@ -590,5 +609,5 @@ static struct i2c_driver usb251xb_i2c_driver = {module_i2c_driver (usb251xb_i2c_driver);MODULE_AUTHOR ("Richard Leitner <[email protected]>" ); -MODULE_DESCRIPTION ("USB251xB/xBi USB 2.0 Hub Controller Driver" ); +MODULE_DESCRIPTION ("USB251x/xBi USB 2.0 Hub Controller Driver" );
... and here again "USB251x/xBi"...
drivers/usb/misc/usb251xb.c static struct i2c_driver usb251xb_i2c_driver = { · line 613
Quoted 2 lines
drivers/usb/misc/usb251xb.c +0
-0MODULE_LICENSE ("GPL" );
I'd prefer to use just one "name" for the driver. If you be precise that would be "USB251xB/xBi/xi". But that seems a bit overloaded to me. AFAIK the "B" and "i" prepended to the type have no affect on the I2C interface/register map, so maybe "USB251x" would be sufficient?
kind regards,
Richard.L
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Richard Leitner
maintainerRe: [PATCH 09/10 v3] usb: usb251xb: Add max power/current dts property support
In reply to Serge SeminHi,
again some nit-picks below...
Quoted 14 lines · Serge Semin
This parameters may be varied in accordance with hardware specifics. So lets add the corresponding settings to the usb251xb driver dts specification.
Signed-off-by Serge Semin <[email protected]>--- drivers/usb/misc/usb251xb.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)drivers/usb/misc/usb251xb.c +0
-0
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 505
Quoted 6 lines
drivers/usb/misc/usb251xb.c +3
-0@@ -500,6 +500,26 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, } } + hub->max_power_sp =USB251XB_DEF_MAX_POWER_SELF ; +if (!of_property_read_u32 (np,"sp-max-total-current-microamp" , + &property_u32))
Please match the "correct" (of_property_read_u32) opening parenthesis here...
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 510
Quoted 5 lines
drivers/usb/misc/usb251xb.c +5
-0+ hub->max_power_sp =min_t (u8, property_u32 /2000 ,50 ); + + hub->max_power_bp =USB251XB_DEF_MAX_POWER_BUS ; +if (!of_property_read_u32 (np,"bp-max-total-current-microamp" , + &property_u32))
... and here ...
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 515
Quoted 5 lines
drivers/usb/misc/usb251xb.c +5
-0+ hub->max_power_bp =min_t (u8, property_u32 /2000 ,255 ); + + hub->max_current_sp =USB251XB_DEF_MAX_CURRENT_SELF ; +if (!of_property_read_u32 (np,"sp-max-removable-current-microamp" , + &property_u32))
... and here ...
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 520
Quoted 5 lines
drivers/usb/misc/usb251xb.c +5
-0+ hub->max_current_sp =min_t (u8, property_u32 /2000 ,50 ); + + hub->max_current_bp =USB251XB_DEF_MAX_CURRENT_BUS ; +if (!of_property_read_u32 (np,"bp-max-removable-current-microamp" , + &property_u32))
... and here ...
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 525
Quoted 5 lines
drivers/usb/misc/usb251xb.c +2
-0+ hub->max_current_bp =min_t (u8, property_u32 /2000 ,255 ); + hub->power_on_time =USB251XB_DEF_POWER_ON_TIME ;if (!of_property_read_u32 (np,"power-on-time-ms" , &property_u32)) hub->power_on_time =min_t (u8, property_u32 /2 ,255 );
Thanks!
kind regards,
Richard.L
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 01/10 v3] usb: usb251xb: Update usb251xb bindings
In reply to Serge SeminQuoted 16 lines · Serge Semin
Since hub usb2517 is going to be supported by the usb251xb driver, the bindings need to be properly updated. Particularly:
- add "microchip,usb2517" and "microchip,usb2517i" compatible strings.
- add "boolean" description to all the properties, which really accept a boolean value including a new one "led-{usb,speed}-mode".
- move reset-gpios property to the optional section. It isn't defined as required in the code and shouldn't be required at all, since hardware may handle reset pins by itself.
- add new led-{usb,speed}-mode mode property. USB2517 device supports two LED modes: USB mode and speed (default) indication mode. The last one can be switched on by this property.
- add {bp,sp}-max-{total,removable}-current-microamp property measured in microamp. It hasn't been defined as property before. Since the limitation specified by these parameters is hardware specific it needs to be defined in dts.
Quoted 4 lines
Signed-off-by Serge Semin <[email protected]>--- .../devicetree/bindings/usb/usb251xb.txt | 46 +++++++++++++++------- 1 file changed, 32 insertions(+), 14 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html