Skip to content

Commit

Permalink
usb: host: xhci-plat: Create platform device for onboard hubs in probe()
Browse files Browse the repository at this point in the history
Check during probe() if a hub supported by the onboard_usb_hub
driver is connected to the controller. If such a hub is found
create the corresponding platform device. This requires the
device tree to have a node for the hub with its vendor and
product id (which is not common for USB devices). Further the
platform device is only created when CONFIG_USB_ONBOARD_HUB=y/m.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
  • Loading branch information
Matthias Kaehlcke authored and intel-lab-lkp committed May 3, 2021
1 parent 20a4dc8 commit ce77fd5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/usb/host/Kconfig
Expand Up @@ -54,6 +54,7 @@ config USB_XHCI_PCI_RENESAS
config USB_XHCI_PLATFORM
tristate "Generic xHCI driver for a platform device"
select USB_XHCI_RCAR if ARCH_RENESAS
depends on USB_ONBOARD_HUB || !USB_ONBOARD_HUB
help
Adds an xHCI host driver for a generic platform device, which
provides a memory space and an irq.
Expand Down
16 changes: 16 additions & 0 deletions drivers/usb/host/xhci-plat.c
Expand Up @@ -15,6 +15,7 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/usb/onboard_hub.h>
#include <linux/usb/phy.h>
#include <linux/slab.h>
#include <linux/acpi.h>
Expand Down Expand Up @@ -195,6 +196,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
int ret;
int irq;
struct xhci_plat_priv *priv = NULL;
struct device_node *np;


if (usb_disabled())
Expand Down Expand Up @@ -374,6 +376,17 @@ static int xhci_plat_probe(struct platform_device *pdev)
*/
pm_runtime_forbid(&pdev->dev);

np = usb_of_get_device_node(hcd->self.root_hub, hcd->self.busnum);
if (np && of_is_onboard_usb_hub(np)) {
struct platform_device *pdev;

pdev = of_platform_device_create(np, NULL, NULL);
if (pdev)
hcd->onboard_hub_dev = &pdev->dev;
else
xhci_warn(xhci, "failed to create onboard hub platform device\n");
}

return 0;


Expand Down Expand Up @@ -420,6 +433,9 @@ static int xhci_plat_remove(struct platform_device *dev)
usb_remove_hcd(hcd);
usb_put_hcd(shared_hcd);

if (hcd->onboard_hub_dev)
of_platform_device_destroy(hcd->onboard_hub_dev, NULL);

clk_disable_unprepare(clk);
clk_disable_unprepare(reg_clk);
usb_put_hcd(hcd);
Expand Down
2 changes: 2 additions & 0 deletions include/linux/usb/hcd.h
Expand Up @@ -225,6 +225,8 @@ struct usb_hcd {
* (ohci 32, uhci 1024, ehci 256/512/1024).
*/

struct device *onboard_hub_dev;

/* The HC driver's private data is stored at the end of
* this structure.
*/
Expand Down

0 comments on commit ce77fd5

Please sign in to comment.