Skip to content

Commit 8bc0636

Browse files
Matthias Kaehlckegregkh
authored andcommitted
usb: misc: Add onboard_usb_hub driver
The main issue this driver addresses is that a USB hub needs to be powered before it can be discovered. For discrete onboard hubs (an example for such a hub is the Realtek RTS5411) this is often solved by supplying the hub with an 'always-on' regulator, which is kind of a hack. Some onboard hubs may require further initialization steps, like changing the state of a GPIO or enabling a clock, which requires even more hacks. This driver creates a platform device representing the hub which performs the necessary initialization. Currently it only supports switching on a single regulator, support for multiple regulators or other actions can be added as needed. Different initialization sequences can be supported based on the compatible string. Besides performing the initialization the driver can be configured to power the hub off during system suspend. This can help to extend battery life on battery powered devices which have no requirements to keep the hub powered during suspend. The driver can also be configured to leave the hub powered when a wakeup capable USB device is connected when suspending, and power it off otherwise. Technically the driver consists of two drivers, the platform driver described above and a very thin USB driver that subclasses the generic driver. The purpose of this driver is to provide the platform driver with the USB devices corresponding to the hub(s) (a hub controller may provide multiple 'logical' hubs, e.g. one to support USB 2.0 and another for USB 3.x). Co-developed-by: Ravi Chandra Sadineni <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Signed-off-by: Ravi Chandra Sadineni <[email protected]> Signed-off-by: Matthias Kaehlcke <[email protected]> Link: https://lore.kernel.org/r/20220630123445.v24.3.I7c9a1f1d6ced41dd8310e8a03da666a32364e790@changeid Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent dee6719 commit 8bc0636

File tree

9 files changed

+641
-0
lines changed

9 files changed

+641
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
What: /sys/bus/platform/devices/<dev>/always_powered_in_suspend
2+
Date: June 2022
3+
KernelVersion: 5.20
4+
Contact: Matthias Kaehlcke <[email protected]>
5+
6+
Description:
7+
(RW) Controls whether the USB hub remains always powered
8+
during system suspend or not.

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14848,6 +14848,13 @@ S: Maintained
1484814848
T: git git://linuxtv.org/media_tree.git
1484914849
F: drivers/media/i2c/ov9734.c
1485014850

14851+
ONBOARD USB HUB DRIVER
14852+
M: Matthias Kaehlcke <[email protected]>
14853+
14854+
S: Maintained
14855+
F: Documentation/ABI/testing/sysfs-bus-platform-onboard-usb-hub
14856+
F: drivers/usb/misc/onboard_usb_hub.c
14857+
1485114858
ONENAND FLASH DRIVER
1485214859
M: Kyungmin Park <[email protected]>
1485314860

drivers/usb/core/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ usbcore-$(CONFIG_OF) += of.o
1212
usbcore-$(CONFIG_USB_PCI) += hcd-pci.o
1313
usbcore-$(CONFIG_ACPI) += usb-acpi.o
1414

15+
ifdef CONFIG_USB_ONBOARD_HUB
16+
usbcore-y += ../misc/onboard_usb_hub_pdevs.o
17+
endif
18+
1519
obj-$(CONFIG_USB) += usbcore.o
1620

1721
obj-$(CONFIG_USB_LEDS_TRIGGER_USBPORT) += ledtrig-usbport.o

drivers/usb/misc/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,19 @@ config BRCM_USB_PINMAP
295295
This option enables support for remapping some USB external
296296
signals, which are typically on dedicated pins on the chip,
297297
to any gpio.
298+
299+
config USB_ONBOARD_HUB
300+
tristate "Onboard USB hub support"
301+
depends on OF || COMPILE_TEST
302+
help
303+
Say Y here if you want to support discrete onboard USB hubs that
304+
don't require an additional control bus for initialization, but
305+
need some non-trivial form of initialization, such as enabling a
306+
power regulator. An example for such a hub is the Realtek
307+
RTS5411.
308+
309+
This driver can be used as a module but its state (module vs
310+
builtin) must match the state of the USB subsystem. Enabling
311+
this config will enable the driver and it will automatically
312+
match the state of the USB subsystem. If this driver is a
313+
module it will be called onboard_usb_hub.

drivers/usb/misc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ obj-$(CONFIG_USB_CHAOSKEY) += chaoskey.o
3333
obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/
3434
obj-$(CONFIG_USB_LINK_LAYER_TEST) += lvstest.o
3535
obj-$(CONFIG_BRCM_USB_PINMAP) += brcmstb-usb-pinmap.o
36+
obj-$(CONFIG_USB_ONBOARD_HUB) += onboard_usb_hub.o

0 commit comments

Comments
 (0)