misc: Port USB251xB/xBi Hi-Speed Hub Controller Driver from Linux
PATCH 1/1 misc: Port USB251xB/xBi Hi-Speed Hub Controller Driver from Linux
This patch adds a driver for configuration of the Microchip USB251xB/xBi USB 2.0 hub controller series with USB 2.0 upstream connectivity, SMBus configuration interface and two to four USB 2.0 downstream ports.
This is ported from Linux as of Linux kernel commit 5c2b9c61ae5d8 ("usb: usb251xb: add boost-up property support")
--- drivers/misc/Kconfig | 9 + drivers/misc/Makefile | 1 + drivers/misc/usb251xb.c | 605 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 615 insertions(+) create mode 100644 drivers/misc/usb251xb.c
drivers/misc/Kconfig +9 -0
@@ -360,6 +360,15 @@ config TEST_DRV model. This should only be enabled for testing as it is not useful for anything else. +config USB_HUB_USB251XB + tristate "USB251XB Hub Controller Configuration Driver" + depends on I2C + help + This option enables support for configuration via SMBus of the + 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 TWL4030_LED bool "Enable TWL4030 LED controller" help
drivers/misc/Makefile +1 -0
@@ -20,6 +20,7 @@ endif ifdef CONFIG_$(SPL_)DM_I2C ifndef CONFIG_SPL_BUILD obj-$(CONFIG_SANDBOX) += i2c_eeprom_emul.o +obj-$(CONFIG_USB_HUB_USB251XB) += usb251xb.o endif endif ifdef CONFIG_SPL_OF_PLATDATA
drivers/misc/usb251xb.c new file +605 -0
605 lines not on this page · raw message
Signature · 1 line
2.35.1
Quoted 6 lines · Marek Vasut
This patch adds a driver for configuration of the Microchip USB251xB/xBi USB 2.0 hub controller series with USB 2.0 upstream connectivity, SMBus configuration interface and two to four USB 2.0 downstream ports.
This is ported from Linux as of Linux kernel commit
5c2b9c61ae5d8("usb: usb251xb: add boost-up property support")
The patch is aligned with kernel as you said but I expect this hub will be described on i2c bus which is based on
https://lore.kernel.org/all/CAL_JsqJedhX6typpUKbnzV7CLK6UZVjq3CyG9iY_j5DLPqvVdw@mail.gmail.com/
not where Rob would like to see ends.
It is not a problem with the patch from my point of view I just wanted to let you know that based on him it should be handled differently.
Thanks,
Michal
Quoted 10 lines · Michal Simek
Quoted 6 lines · Marek Vasut
This patch adds a driver for configuration of the Microchip USB251xB/xBi USB 2.0 hub controller series with USB 2.0 upstream connectivity, SMBus configuration interface and two to four USB 2.0 downstream ports.
This is ported from Linux as of Linux kernel commit
5c2b9c61ae5d8("usb: usb251xb: add boost-up property support")
Quoted 7 lines
The patch is aligned with kernel as you said but I expect this hub will be described on i2c bus which is based on
https://lore.kernel.org/all/CAL_JsqJedhX6typpUKbnzV7CLK6UZVjq3CyG9iY_j5DLPqvVdw@mail.gmail.com/not where Rob would like to see ends.
It is not a problem with the patch from my point of view I just wanted to let you know that based on him it should be handled differently.
Can you include me in that discussion ?
However, it seems the discussion is not about USB251x , but some other hub which is connected over HSIC, not USB, that's likey why Rob wants it described differently than this hub.
Quoted 11 lines · Marek Vasut
This patch adds a driver for configuration of the Microchip USB251xB/xBi USB 2.0 hub controller series with USB 2.0 upstream connectivity, SMBus configuration interface and two to four USB 2.0 downstream ports.
This is ported from Linux as of Linux kernel commit
5c2b9c61ae5d8("usb: usb251xb: add boost-up property support")Signed-off-by Marek Vasut <[email protected]>Cc Bin Meng <[email protected]>Cc Michal Simek <[email protected]>Cc Simon Glass <[email protected]>
If there are no comments, I will apply this soon.
Hi Marek,
sorry for the late comments but I think the driver doesn't work as expected.
Am 10.04.2022 um 06:27 schrieb Marek Vasut:
Quoted 24 lines
This patch adds a driver for configuration of the Microchip USB251xB/xBi USB 2.0 hub controller series with USB 2.0 upstream connectivity, SMBus configuration interface and two to four USB 2.0 downstream ports.
This is ported from Linux as of Linux kernel commit
5c2b9c61ae5d8("usb: usb251xb: add boost-up property support")Signed-off-by Marek Vasut <[email protected]>Cc Bin Meng <[email protected]>Cc Michal Simek <[email protected]>Cc Simon Glass <[email protected]>--- drivers/misc/Kconfig | 9 + drivers/misc/Makefile | 1 + drivers/misc/usb251xb.c | 605 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 615 insertions(+)create mode 100644
drivers/misc/usb251xb.cdrivers/misc/usb251xb.c new file +0
-0@@ -0,0 +1,605 @@
[snip]
Quoted 20 lines
drivers/misc/usb251xb.c new file +20
-0+static int usb251xb_of_to_plat (struct udevice *dev) +{ +struct usb251xb_data *data = + (struct usb251xb_data *)dev_get_driver_data (dev); +struct usb251xb *hub =dev_get_priv (dev); +char str[USB251XB_STRING_BUFSIZE /2 ]; +const char *cproperty_char; +u32 property_u32 =0 ; +int len, err; + +if (dev_read_bool (dev,"skip-config" )) + hub->skip_config =1 ; +else + hub->skip_config =0 ; + + err =gpio_request_by_name (dev,"reset-gpios" ,0 , &hub->gpio_reset, +GPIOD_IS_OUT |GPIOD_IS_OUT_ACTIVE ); +if (err && err != -ENOENT ) { +dev_err (dev,"unable to request GPIO reset pin (%d)\n" , err); +return err;
drivers/misc/usb251xb.c line 401
Quoted 10 lines
drivers/misc/usb251xb.c new file +10
-0+ } + +if (IS_ENABLED (CONFIG_DM_REGULATOR )) { + err =device_get_supply_regulator (dev,"vdd-supply" , + &hub->vdd); +if (err && err != -ENOENT ) { +dev_err (dev,"Warning: cannot get power supply\n" ); +return err; + } + }
Shouldn't the gpio and regulator request be part of the probe?
Quoted 10 lines
drivers/misc/usb251xb.c new file +10
-0+ +if (dev_read_u32 (dev,"vendor-id" , &hub->vendor_id)) + hub->vendor_id =USB251XB_DEF_VENDOR_ID ; + +if (dev_read_u32 (dev,"product-id" , &hub->product_id)) + hub->product_id = data->product_id; + +if (dev_read_u32 (dev,"device-id" , &hub->device_id)) + hub->device_id =USB251XB_DEF_DEVICE_ID ; +
[snip]
drivers/misc/usb251xb.c line 518
Quoted 3 lines
drivers/misc/usb251xb.c new file +3
-0+if (dev_read_u32 (dev,"language-id" , &hub->lang_id)) + hub->lang_id =USB251XB_DEF_LANGUAGE_ID ; +
This doesn't work because the ids are 16 bit [1,2] and the dev_read_u32 function checks the size.
drivers/misc/usb251xb.c line 520
Quoted 2 lines
drivers/misc/usb251xb.c new file +2
-0+if (!dev_read_u32 (dev,"boost-up" , &hub->boost_up)) + hub->boost_up =USB251XB_DEF_BOOST_UP ;
This looks like a 8 bit value [1].
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/misc/usb251xb.c
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/usb/usb251xb.txt
Regards,
Stefan
Quoted 1 line · Stefan Herbrechtsmeier
Hi Marek,
Hi,
Quoted 1 line
sorry for the late comments but I think the driver doesn't work as expected.
How come ? It works on my board.
[...]
Quoted 11 lines
Quoted 9 lines
+
+ if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+ err =device_get_supply_regulator(dev, "vdd-supply", + &hub->vdd);
+ if (err && err !=-ENOENT) {
+dev_err(dev, "Warning: cannot get power supply\n"); + return err;
+ }
+ }Shouldn't the gpio and regulator request be part of the probe?
What makes you think that ?
Quoted 16 lines
Quoted 9 lines
+ if (
dev_read_u32(dev, "vendor-id", &hub->vendor_id)) +hub->vendor_id=USB251XB_DEF_VENDOR_ID;drivers/misc/usb251xb.c new file +7
-0+ + if (dev_read_u32(dev, "product-id", &hub->product_id)) + hub->product_id = data->product_id; + + if (dev_read_u32(dev, "device-id", &hub->device_id)) + hub->device_id = USB251XB_DEF_DEVICE_ID; +[snip]
Quoted 3 lines
+ if (
dev_read_u32(dev, "language-id", &hub->lang_id)) +hub->lang_id=USB251XB_DEF_LANGUAGE_ID; +
Quoted 6 lines
This doesn't work because the ids are 16 bit [1,2] and the
dev_read_u32function checks the size.Quoted 2 lines
+ if (!dev_read_u32(dev, "boost-up",
&hub->boost_up)) +hub->boost_up=USB251XB_DEF_BOOST_UP;This looks like a 8 bit value [1].
The dev_read_u32() is also capable of reading 0xNNNN 16bit value from DT.
What kind of problem are you running into exactly ?
Hi Marek,
Am 13.06.2022 um 18:00 schrieb Marek Vasut:
Quoted 8 lines · Stefan Herbrechtsmeier
Quoted 1 line
Hi Marek,
Hi,
Quoted 1 line
sorry for the late comments but I think the driver doesn't work as expected.
How come ? It works on my board.
Have you test with 16 bit property data?
Quoted 13 lines
[...]
Quoted 10 lines
Quoted 9 lines
+
+ if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+ err =device_get_supply_regulator(dev, "vdd-supply", + &hub->vdd);
+ if (err && err !=-ENOENT) {
+dev_err(dev, "Warning: cannot get power supply\n"); + return err;
+ }
+ }
Quoted 3 lines
Quoted 1 line
Shouldn't the gpio and regulator request be part of the probe?
What makes you think that ?
It's more a question regarding the device model design:
of_to_plat - convert device tree data to plat
Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
+ if (
dev_read_u32(dev, "vendor-id", &hub->vendor_id)) +hub->vendor_id=USB251XB_DEF_VENDOR_ID;drivers/misc/usb251xb.c new file +7
-0+ + if (dev_read_u32(dev, "product-id", &hub->product_id)) + hub->product_id = data->product_id; + + if (dev_read_u32(dev, "device-id", &hub->device_id)) + hub->device_id = USB251XB_DEF_DEVICE_ID; +[snip]
Quoted 3 lines
+ if (
dev_read_u32(dev, "language-id", &hub->lang_id)) +hub->lang_id=USB251XB_DEF_LANGUAGE_ID; +This doesn't work because the ids are 16 bit [1,2] and the
dev_read_u32function checks the size.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
+ if (!dev_read_u32(dev, "boost-up",
&hub->boost_up)) +hub->boost_up=USB251XB_DEF_BOOST_UP;This looks like a 8 bit value [1].
The
dev_read_u32()is also capable of reading 0xNNNN 16bit value from DT.What kind of problem are you running into exactly ?
Have you test the values from device tree binding documentation:
vendor-id = /bits/ 16 <0xNNNN>;
product-id = /bits/ 16 <0xNNNN>;
I get an EOVERFLOW error.
Quoted 1 line · Stefan Herbrechtsmeier
Hi Marek,
Hi,
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
+
+ if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+ err =device_get_supply_regulator(dev, "vdd-supply", + &hub->vdd);
+ if (err && err !=-ENOENT) {
+dev_err(dev, "Warning: cannot get power supply\n"); + return err;
+ }
+ }
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Shouldn't the gpio and regulator request be part of the probe?
What makes you think that ?
It's more a question regarding the device model design:
of_to_plat- convert device tree data to plat
As far as I can tell, you should be able to obtain reference to a regulator here, but not probe the regulator.
Quoted 25 lines
Quoted 25 lines
Quoted 16 lines
Quoted 9 lines
+ if (
dev_read_u32(dev, "vendor-id", &hub->vendor_id)) +hub->vendor_id=USB251XB_DEF_VENDOR_ID;drivers/misc/usb251xb.c new file +7
-0+ + if (dev_read_u32(dev, "product-id", &hub->product_id)) + hub->product_id = data->product_id; + + if (dev_read_u32(dev, "device-id", &hub->device_id)) + hub->device_id = USB251XB_DEF_DEVICE_ID; +[snip]
Quoted 3 lines
+ if (
dev_read_u32(dev, "language-id", &hub->lang_id)) +hub->lang_id=USB251XB_DEF_LANGUAGE_ID; +Quoted 6 lines
This doesn't work because the ids are 16 bit [1,2] and the
dev_read_u32function checks the size.Quoted 2 lines
+ if (!dev_read_u32(dev, "boost-up",
&hub->boost_up)) +hub->boost_up=USB251XB_DEF_BOOST_UP;This looks like a 8 bit value [1].
The
dev_read_u32()is also capable of reading 0xNNNN 16bit value from DT.
Quoted 8 lines
Quoted 1 line
What kind of problem are you running into exactly ?
Have you test the values from device tree binding documentation:
vendor-id = /bits/ 16 <0xNNNN>;
product-id = /bits/ 16 <0xNNNN>;I get an EOVERFLOW error.
No, I only tested foo = <0xNNNN>; .
Can you send a fix ?
Am 13.06.2022 um 22:26 schrieb Marek Vasut:
Quoted 1 line · Stefan Herbrechtsmeier
[snip]
Quoted 29 lines
Quoted 29 lines
Quoted 18 lines
Quoted 18 lines
Quoted 9 lines
+ if (
dev_read_u32(dev, "vendor-id", &hub->vendor_id)) +hub->vendor_id=USB251XB_DEF_VENDOR_ID;drivers/misc/usb251xb.c new file +7
-0+ + if (dev_read_u32(dev, "product-id", &hub->product_id)) + hub->product_id = data->product_id; + + if (dev_read_u32(dev, "device-id", &hub->device_id)) + hub->device_id = USB251XB_DEF_DEVICE_ID; +[snip]
Quoted 3 lines
+ if (
dev_read_u32(dev, "language-id", &hub->lang_id)) +hub->lang_id=USB251XB_DEF_LANGUAGE_ID; +This doesn't work because the ids are 16 bit [1,2] and the
dev_read_u32function checks the size.Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
+ if (!dev_read_u32(dev, "boost-up",
&hub->boost_up)) +hub->boost_up=USB251XB_DEF_BOOST_UP;This looks like a 8 bit value [1].
The
dev_read_u32()is also capable of reading 0xNNNN 16bit value from DT.What kind of problem are you running into exactly ?
Have you test the values from device tree binding documentation:
Quoted 8 lines
Quoted 4 lines
vendor-id = /bits/ 16 <0xNNNN>;
product-id = /bits/ 16 <0xNNNN>;I get an EOVERFLOW error.
No, I only tested foo = <0xNNNN>; .
Can you send a fix ?
Should I add a function to the driver or a dev_read_u8/16, ofnode_read_u8/16 and friends function?
Quoted 37 lines · Stefan Herbrechtsmeier
Am 13.06.2022 um 22:26 schrieb Marek Vasut:
Quoted 1 line · Stefan Herbrechtsmeier
[snip]
Quoted 32 lines
Quoted 32 lines
Quoted 18 lines
Quoted 18 lines
Quoted 9 lines
+ if (
dev_read_u32(dev, "vendor-id", &hub->vendor_id)) +hub->vendor_id=USB251XB_DEF_VENDOR_ID;drivers/misc/usb251xb.c new file +7
-0+ + if (dev_read_u32(dev, "product-id", &hub->product_id)) + hub->product_id = data->product_id; + + if (dev_read_u32(dev, "device-id", &hub->device_id)) + hub->device_id = USB251XB_DEF_DEVICE_ID; +[snip]
Quoted 3 lines
+ if (
dev_read_u32(dev, "language-id", &hub->lang_id)) +hub->lang_id=USB251XB_DEF_LANGUAGE_ID; +This doesn't work because the ids are 16 bit [1,2] and the
dev_read_u32function checks the size.Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
+ if (!dev_read_u32(dev, "boost-up",
&hub->boost_up)) +hub->boost_up=USB251XB_DEF_BOOST_UP;This looks like a 8 bit value [1].
The
dev_read_u32()is also capable of reading 0xNNNN 16bit value from DT.What kind of problem are you running into exactly ?
Have you test the values from device tree binding documentation:
vendor-id = /bits/ 16 <0xNNNN>;
product-id = /bits/ 16 <0xNNNN>;
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
I get an EOVERFLOW error.
No, I only tested foo = <0xNNNN>; .
Can you send a fix ?
Should I add a function to the driver or a dev_read_u8/16, ofnode_read_u8/16 and friends function?
It seems more like you would have to add the _u8 and _u16 variants into common code, alongside the _u32 variant (should be easy) and then use them in this driver (should also be easy), so two patches.
Hi Marek,
Am 14.06.2022 um 09:38 schrieb Marek Vasut:
Quoted 40 lines · Stefan Herbrechtsmeier
Quoted 39 lines
Am 13.06.2022 um 22:26 schrieb Marek Vasut:
Quoted 1 line · Stefan Herbrechtsmeier
[snip]
Quoted 34 lines
Quoted 33 lines
Quoted 18 lines
Quoted 18 lines
Quoted 9 lines
+ if (
dev_read_u32(dev, "vendor-id", &hub->vendor_id)) +hub->vendor_id=USB251XB_DEF_VENDOR_ID;(quoted diff) +7
-0+ + if (dev_read_u32(dev, "product-id", &hub->product_id)) + hub->product_id = data->product_id; + + if (dev_read_u32(dev, "device-id", &hub->device_id)) + hub->device_id = USB251XB_DEF_DEVICE_ID; +[snip]
Quoted 3 lines
+ if (
dev_read_u32(dev, "language-id", &hub->lang_id)) +hub->lang_id=USB251XB_DEF_LANGUAGE_ID; +This doesn't work because the ids are 16 bit [1,2] and the
dev_read_u32function checks the size.Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
+ if (!dev_read_u32(dev, "boost-up",
&hub->boost_up)) +hub->boost_up=USB251XB_DEF_BOOST_UP;This looks like a 8 bit value [1].
The
dev_read_u32()is also capable of reading 0xNNNN 16bit value from DT.What kind of problem are you running into exactly ?
Have you test the values from device tree binding documentation:
vendor-id = /bits/ 16 <0xNNNN>;
product-id = /bits/ 16 <0xNNNN>;I get an EOVERFLOW error.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
No, I only tested foo = <0xNNNN>; .
Can you send a fix ?
Should I add a function to the driver or a dev_read_u8/16, ofnode_read_u8/16 and friends function?
It seems more like you would have to add the
_u8and_u16variants into common code, alongside the_u32variant (should be easy) and then use them in this driver (should also be easy), so two patches.
https://lists.denx.de/pipermail/u-boot/2022-June/486423.html
https://lists.denx.de/pipermail/u-boot/2022-June/486424.html
Do you have any comments?
Regards
Stefan