From: Matthias Kaehlcke <mka@chromium.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alan Stern <stern@rowland.harvard.edu>,
Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>
Cc: Ravi Chandra Sadineni <ravisadineni@chromium.org>,
Peter Chen <peter.chen@nxp.com>,
Michal Simek <michal.simek@xilinx.com>,
Stephen Boyd <swboyd@chromium.org>,
linux-kernel@vger.kernel.org, Bastien Nocera <hadess@hadess.net>,
linux-usb@vger.kernel.org,
Douglas Anderson <dianders@chromium.org>,
devicetree@vger.kernel.org, Krzysztof Kozlowski <krzk@kernel.org>,
Matthias Kaehlcke <mka@chromium.org>,
Mathias Nyman <mathias.nyman@intel.com>
Subject: [PATCH v6 4/5] usb: host: xhci-plat: Create platform device for onboard hubs in probe()
Date: Fri, 5 Mar 2021 11:38:52 -0800 [thread overview]
Message-ID: <20210305113832.v6.4.I7a3a7d9d2126c34079b1cab87aa0b2ec3030f9b7@changeid> (raw)
In-Reply-To: <20210305193853.2040456-1-mka@chromium.org>
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>
---
Changes in v6:
- none
Changes in v5:
- patch added to the series
drivers/usb/host/xhci-plat.c | 16 ++++++++++++++++
include/linux/usb/hcd.h | 2 ++
2 files changed, 18 insertions(+)
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index c1edcc9b13ce..9c0fb7e8df1f 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -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>
@@ -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())
@@ -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;
@@ -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);
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 96281cd50ff6..d02a508e19b0 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -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.
*/
--
2.30.1.766.gb4fecdf3b7-goog
next prev parent reply other threads:[~2021-03-05 19:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-05 19:38 [PATCH v6 0/5] USB: misc: Add onboard_usb_hub driver Matthias Kaehlcke
2021-03-05 19:38 ` [PATCH v6 1/5] dt-bindings: usb: Add binding for Realtek RTS5411 hub controller Matthias Kaehlcke
2021-03-06 19:28 ` Rob Herring
2021-03-06 19:43 ` Rob Herring
2021-03-05 19:38 ` [PATCH v6 2/5] USB: misc: Add onboard_usb_hub driver Matthias Kaehlcke
2021-03-05 19:38 ` [PATCH v6 3/5] of/platform: Add stubs for of_platform_device_create/destroy() Matthias Kaehlcke
2021-03-08 22:32 ` Rob Herring
2021-03-09 17:20 ` Matthias Kaehlcke
2021-03-05 19:38 ` Matthias Kaehlcke [this message]
2021-03-05 19:38 ` [PATCH v6 5/5] arm64: dts: qcom: sc7180-trogdor: Add nodes for onboard USB hub Matthias Kaehlcke
2021-04-05 20:18 [PATCH v6 0/5] USB: misc: Add onboard_usb_hub driver Matthias Kaehlcke
2021-04-05 20:18 ` [PATCH v6 4/5] usb: host: xhci-plat: Create platform device for onboard hubs in probe() Matthias Kaehlcke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210305113832.v6.4.I7a3a7d9d2126c34079b1cab87aa0b2ec3030f9b7@changeid \
--to=mka@chromium.org \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=frowand.list@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hadess@hadess.net \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=michal.simek@xilinx.com \
--cc=peter.chen@nxp.com \
--cc=ravisadineni@chromium.org \
--cc=robh+dt@kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=swboyd@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).