usb: usb251xb: configurable reset delay
Subsystems (3)
cover usb: usb251xb: configurable reset delay
The Microchip USB251xB hub, according to its datasheet, is operational 500us after deasserting reset on startup and can then be attached or configured.
I ran into a batch of such hubs, of the 2512Bi variant, that didn't appear to work or only worked sporadically. Debugging the issue revealed that these specific hubs do not typically manage to reset within 500us. Instead they become operational 800us or so after deasserting the RESET_N signal.
This is probably a faulty batch of the chips but making the reset delay configurable through dt bindings allows these chips to be used.
Daniels Umanovskis (2):
dt-bindings: usb: usb251xb: add documentation for reset-delay-us
usb: usb251xb: make power-up reset delay configurable in device tree
Documentation/devicetree/bindings/usb/usb251xb.txt | 2 ++ drivers/usb/misc/usb251xb.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-)
Signature · 1 line
2.30.2
PATCH 1/2 dt-bindings: usb: usb251xb: add documentation for reset-delay-us
Next patch implements support for this property
--- Documentation/devicetree/bindings/usb/usb251xb.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/usb/usb251xb.txt +2 -0
@@ -12,6 +12,8 @@ Required properties : Optional properties : - reset-gpios : Should specify the gpio for hub reset + - reset-delay-us: Specifies delay in microseconds after reset deassert + on hub power-up. (32 bit, default is 500us) - vdd-supply : Should specify the phandle to the regulator supplying vdd - 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)
Signature · 1 line
2.30.2
Re: [PATCH 1/2] dt-bindings: usb: usb251xb: add documentation for reset-delay-us
Quoted 3 lines · Daniels Umanovskis
Next patch implements support for this property
Signed-off-by Daniels Umanovskis <[email protected]>
LGTM.
Quoted 20 lines
--- Documentation/devicetree/bindings/usb/usb251xb.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/usb/usb251xb.txt +2
-0@@ -12,6 +12,8 @@ Required properties : Optional properties : - reset-gpios : Should specify the gpio for hub reset + - reset-delay-us: Specifies delay in microseconds after reset deassert + on hub power-up. (32 bit, default is 500us) - vdd-supply : Should specify the phandle to the regulator supplying vdd - 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)Signature · 1 line
2.30.2
Rob Herring
maintainerRe: [PATCH 1/2] dt-bindings: usb: usb251xb: add documentation for reset-delay-us
In reply to Daniels UmanovskisQuoted 1 line · Daniels Umanovskis
Next patch implements support for this property
Not a great reason why you need this. This patch should stand on its own.
My first question is whether this is board specific? If the default or what the reference manual says is 500us, but you have a case needing 600us, why not just change the driver. I don't think this really needs tuning to each board unless the delay becomes noticeable.
Quoted 23 lines
Signed-off-by Daniels Umanovskis <[email protected]>--- Documentation/devicetree/bindings/usb/usb251xb.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/usb/usb251xb.txt +2
-0@@ -12,6 +12,8 @@ Required properties : Optional properties : - reset-gpios : Should specify the gpio for hub reset + - reset-delay-us: Specifies delay in microseconds after reset deassert + on hub power-up. (32 bit, default is 500us) - vdd-supply : Should specify the phandle to the regulator supplying vdd - 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)Signature · 1 line
2.30.2
Re: [PATCH 1/2] dt-bindings: usb: usb251xb: add documentation for reset-delay-us
Quoted 4 lines · Rob Herring
My first question is whether this is board specific? If the default or what the reference manual says is 500us, but you have a case needing 600us, why not just change the driver. I don't think this really needs tuning to each board unless the delay becomes noticeable.
This isn't a board specific issue. I detected the issue on a board we've been using for a long time, it's due to a specific batch of USB2512 hubs. We've had several batches of these hubs that were fine, but more recently received a batch produced in late 2021 and the hubs in this batch do not become responsive to I2C within the expected 500us.
I arrived at that by using an oscilloscope to observe how soon after deasserting the reset signal the USB hub is able to respond to I2C. Most of the 2512s we have do that within 500us, the latest batch doesn't.
Richard Leitner - SKIDATA
maintainerRe: [PATCH 1/2] dt-bindings: usb: usb251xb: add documentation for reset-delay-us
Quoted 11 lines · Daniels Umanovskis
Quoted 4 lines · Rob Herring
My first question is whether this is board specific? If the default or what the reference manual says is 500us, but you have a case needing 600us, why not just change the driver. I don't think this really needs tuning to each board unless the delay becomes noticeable.
This isn't a board specific issue. I detected the issue on a board we've been using for a long time, it's due to a specific batch of USB2512 hubs. We've had several batches of these hubs that were fine, but more recently received a batch produced in late 2021 and the hubs in this batch do not become responsive to I2C within the expected 500us.
What's the maximum timeout you've observed?
I guess it would be the simpler and "better" approach to just increase the timeout in the driver (if it's not too much above the 500µs).
Quoted 5 lines
I arrived at that by using an oscilloscope to observe how soon after deasserting the reset signal the USB hub is able to respond to I2C. Most of the 2512s we have do that within 500us, the latest batch doesn't.
regards;rl
Re: [PATCH 1/2] dt-bindings: usb: usb251xb: add documentation for reset-delay-us
Quoted 4 lines · Richard Leitner - SKIDATA
What's the maximum timeout you've observed?
I guess it would be the simpler and "better" approach to just increase the timeout in the driver (if it's not too much above the 500µs).
I saw 800-820 us at most, and my initial fix internally was just to increase the sleep duration in the driver. But it's an increase of over 50% and I don't feel it makes sense to change the driver's behavior for thousands of users with properly working chips, hence the configurable timeout for out-of-spec batches like the one we had here. I expect more users to run across such batches in the coming months.
In an ideal world, we'd just trash these hubs that should have surely failed factory QA, but with today's component shortage that's an unimaginable luxury...
/Daniels
Rob Herring
maintainerRe: [PATCH 1/2] dt-bindings: usb: usb251xb: add documentation for reset-delay-us
Quoted 13 lines · Daniels Umanovskis
Quoted 4 lines · Richard Leitner - SKIDATA
What's the maximum timeout you've observed?
I guess it would be the simpler and "better" approach to just increase the timeout in the driver (if it's not too much above the 500µs).
I saw 800-820 us at most, and my initial fix internally was just to increase the sleep duration in the driver. But it's an increase of over 50% and I don't feel it makes sense to change the driver's behavior for thousands of users with properly working chips, hence the configurable timeout for out-of-spec batches like the one we had here. I expect more users to run across such batches in the coming months.
Quoted 3 lines
In an ideal world, we'd just trash these hubs that should have surely failed factory QA, but with today's component shortage that's an unimaginable luxury...
The only solution that works here is increase the timeout in the driver. Are you going to tweak the dtb based on what batch the chip is from? No, that's not possible.
Having worked in a chip company, I can tell you how they would fix it. Better testing? No, they'd change the documentation.
Rob
PATCH 2/2 usb: usb251xb: make power-up reset delay configurable in device tree
In reply to Daniels UmanovskisAccording to the datasheet, the hub should be operational 500us after the reset has been deasserted. Some individual circuits have been observed not to reset within the specified 500us and require a longer wait for subsequent configuration to succeed.
--- drivers/usb/misc/usb251xb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/misc/usb251xb.c +5 -1
@@ -115,6 +115,7 @@ struct usb251xb {struct regulator *vdd;u8 skip_config;struct gpio_desc *gpio_reset; +u32 reset_delay_us;u16 vendor_id;u16 product_id;u16 device_id;
@@ -278,7 +279,7 @@ static void usb251xb_reset(struct usb251xb *hub)gpiod_set_value_cansleep (hub->gpio_reset,0 );/* wait for hub recovery/stabilization */ -usleep_range (500 ,750 );/* >=500us after RESET_N deasserted */ +fsleep (hub->reset_delay_us);i2c_unlock_bus (hub->i2c->adapter,I2C_LOCK_SEGMENT ); }
@@ -424,6 +425,9 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,return err; } +if (of_property_read_u32 (np,"reset-delay-us" , &hub->reset_delay_us)) + hub->reset_delay_us =500 ; +if (of_property_read_u16_array (np,"vendor-id" , &hub->vendor_id,1 )) hub->vendor_id =USB251XB_DEF_VENDOR_ID ;
Signature · 1 line
2.30.2
Greg KH
maintainerRe: [PATCH 2/2] usb: usb251xb: make power-up reset delay configurable in device tree
Quoted 32 lines · Daniels Umanovskis
According to the datasheet, the hub should be operational 500us after the reset has been deasserted. Some individual circuits have been observed not to reset within the specified 500us and require a longer wait for subsequent configuration to succeed.
Signed-off-by Daniels Umanovskis <[email protected]>--- drivers/usb/misc/usb251xb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/usb/misc/usb251xb.c +2
-1@@ -115,6 +115,7 @@ struct usb251xb {struct regulator *vdd;u8 skip_config;struct gpio_desc *gpio_reset; +u32 reset_delay_us;u16 vendor_id;u16 product_id;u16 device_id;@@ -278,7 +279,7 @@ static void usb251xb_reset(struct usb251xb *hub)gpiod_set_value_cansleep (hub->gpio_reset,0 );/* wait for hub recovery/stabilization */ -usleep_range (500 ,750 );/* >=500us after RESET_N deasserted */ +fsleep (hub->reset_delay_us);i2c_unlock_bus (hub->i2c->adapter,I2C_LOCK_SEGMENT ); }
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 429
Quoted 5 lines
drivers/usb/misc/usb251xb.c +2
-0@@ -424,6 +425,9 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,return err; } +if (of_property_read_u32 (np,"reset-delay-us" , &hub->reset_delay_us)) + hub->reset_delay_us =500 ;
So if this fails the delay is 0?
And what commit id does this fix?
And any reason why you didn't cc: the people you get when running scripts/get_maintainer.pl on the patch?
thanks,
greg k-h
Re: [PATCH 2/2] usb: usb251xb: make power-up reset delay configurable in device tree
Quoted 36 lines · Greg KH
Quoted 35 lines · Daniels Umanovskis
According to the datasheet, the hub should be operational 500us after the reset has been deasserted. Some individual circuits have been observed not to reset within the specified 500us and require a longer wait for subsequent configuration to succeed.
Signed-off-by Daniels Umanovskis <[email protected]>--- drivers/usb/misc/usb251xb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/usb/misc/usb251xb.c +2
-1@@ -115,6 +115,7 @@ struct usb251xb {struct regulator *vdd;u8 skip_config;struct gpio_desc *gpio_reset; +u32 reset_delay_us;u16 vendor_id;u16 product_id;u16 device_id;@@ -278,7 +279,7 @@ static void usb251xb_reset(struct usb251xb *hub)gpiod_set_value_cansleep (hub->gpio_reset,0 );/* wait for hub recovery/stabilization */ -usleep_range (500 ,750 );/* >=500us after RESET_N deasserted */ +fsleep (hub->reset_delay_us);i2c_unlock_bus (hub->i2c->adapter,I2C_LOCK_SEGMENT ); }@@ -424,6 +425,9 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,return err; }
Quoted 3 lines
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 429
Quoted 2 lines
drivers/usb/misc/usb251xb.c +2
-0+if (of_property_read_u32 (np,"reset-delay-us" , &hub->reset_delay_us)) + hub->reset_delay_us =500 ;So if this fails the delay is 0?
of_property_read_u32 can fail with -EINVAL or -ENODATA, then delay is 500, unless I'm missing something more obvious.
Quoted 1 line
And what commit id does this fix?
No Fixes: tag because this isn't a bug or regression, just a new workaround for a hardware issue nobody's (presumably) encountered/bothered with.
Quoted 2 lines
And any reason why you didn't cc: the people you get when running
scripts/get_maintainer.plon the patch?
get_maintainer showed Richard as the maintainer. You showed as a supporter, if supporters should also be CCed by default then it's my bad - perhaps that should be clarified in submitting-patches.rst.
Quoted 3 lines
thanks,
greg k-h
/Daniels
Greg KH
maintainerRe: [PATCH 2/2] usb: usb251xb: make power-up reset delay configurable in device tree
Quoted 37 lines · Daniels Umanovskis
Quoted 28 lines · Greg KH
Quoted 27 lines · Daniels Umanovskis
According to the datasheet, the hub should be operational 500us after the reset has been deasserted. Some individual circuits have been observed not to reset within the specified 500us and require a longer wait for subsequent configuration to succeed.
Signed-off-by Daniels Umanovskis <[email protected]>--- drivers/usb/misc/usb251xb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/usb/misc/usb251xb.c +2
-1@@ -115,6 +115,7 @@ struct usb251xb {struct regulator *vdd;u8 skip_config;struct gpio_desc *gpio_reset; +u32 reset_delay_us;u16 vendor_id;u16 product_id;u16 device_id;@@ -278,7 +279,7 @@ static void usb251xb_reset(struct usb251xb *hub)gpiod_set_value_cansleep (hub->gpio_reset,0 );/* wait for hub recovery/stabilization */ -usleep_range (500 ,750 );/* >=500us after RESET_N deasserted */ +fsleep (hub->reset_delay_us);Quoted 8 lines
drivers/usb/misc/usb251xb.c static int usb251xb_get_ofdata(struct usb251xb *hub, · line 428
Quoted 7 lines
drivers/usb/misc/usb251xb.c +2
-0i2c_unlock_bus (hub->i2c->adapter,I2C_LOCK_SEGMENT ); }@@ -424,6 +425,9 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,return err; } +if (of_property_read_u32 (np,"reset-delay-us" , &hub->reset_delay_us)) + hub->reset_delay_us =500 ;So if this fails the delay is 0?
Quoted 2 lines
of_property_read_u32can fail with-EINVALor-ENODATA, then delay is 500, unless I'm missing something more obvious.
Ah, no, you are right, sorry, I read this wrong.
greg k-h
Re: [PATCH 2/2] usb: usb251xb: make power-up reset delay configurable in device tree
In reply to Daniels UmanovskisQuoted 6 lines · Daniels Umanovskis
According to the datasheet, the hub should be operational 500us after the reset has been deasserted. Some individual circuits have been observed not to reset within the specified 500us and require a longer wait for subsequent configuration to succeed.
Signed-off-by Daniels Umanovskis <[email protected]>
LGTM.
Quoted 38 lines
--- drivers/usb/misc/usb251xb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/usb/misc/usb251xb.c +5
-1@@ -115,6 +115,7 @@ struct usb251xb {struct regulator *vdd;u8 skip_config;struct gpio_desc *gpio_reset; +u32 reset_delay_us;u16 vendor_id;u16 product_id;u16 device_id;@@ -278,7 +279,7 @@ static void usb251xb_reset(struct usb251xb *hub)gpiod_set_value_cansleep (hub->gpio_reset,0 );/* wait for hub recovery/stabilization */ -usleep_range (500 ,750 );/* >=500us after RESET_N deasserted */ +fsleep (hub->reset_delay_us);i2c_unlock_bus (hub->i2c->adapter,I2C_LOCK_SEGMENT ); }@@ -424,6 +425,9 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,return err; } +if (of_property_read_u32 (np,"reset-delay-us" , &hub->reset_delay_us)) + hub->reset_delay_us =500 ; +if (of_property_read_u16_array (np,"vendor-id" , &hub->vendor_id,1 )) hub->vendor_id =USB251XB_DEF_VENDOR_ID ;Signature · 1 line
2.30.2