From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
To: f.fainelli@gmail.com, gregkh@linuxfoundation.org,
wahrenst@gmx.net, p.zabel@pengutronix.de,
linux-kernel@vger.kernel.org,
Mathias Nyman <mathias.nyman@intel.com>
Cc: linux-usb@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
bcm-kernel-feedback-list@broadcom.com, tim.gover@raspberrypi.org,
linux-pci@vger.kernel.org, helgaas@kernel.org,
andy.shevchenko@gmail.com, mathias.nyman@linux.intel.com,
lorenzo.pieralisi@arm.com,
Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Subject: [PATCH v3 5/9] usb: xhci-pci: Add support for reset controllers
Date: Fri, 12 Jun 2020 19:13:29 +0200 [thread overview]
Message-ID: <20200612171334.26385-6-nsaenzjulienne@suse.de> (raw)
In-Reply-To: <20200612171334.26385-1-nsaenzjulienne@suse.de>
Some atypical users of xhci-pci might need to manually reset their xHCI
controller before starting the HCD setup. Check if a reset controller
device is available to the PCI bus and trigger a reset.
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
Changes since v2:
- Also reset on resume
Changes since v1:
- Use proper reset API
- Make code simpler
drivers/usb/host/xhci-pci.c | 10 ++++++++++
drivers/usb/host/xhci.h | 2 ++
2 files changed, 12 insertions(+)
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index ef513c2fb843..e76b9283faa3 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -12,6 +12,7 @@
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/acpi.h>
+#include <linux/reset.h>
#include "xhci.h"
#include "xhci-trace.h"
@@ -339,6 +340,7 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
struct xhci_hcd *xhci;
struct usb_hcd *hcd;
struct xhci_driver_data *driver_data;
+ struct reset_control *reset;
driver_data = (struct xhci_driver_data *)id->driver_data;
if (driver_data && driver_data->quirks & XHCI_RENESAS_FW_QUIRK) {
@@ -347,6 +349,11 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
return retval;
}
+ reset = devm_reset_control_get_optional_exclusive(&dev->bus->dev, NULL);
+ if (IS_ERR(reset))
+ return PTR_ERR(reset);
+ reset_control_reset(reset);
+
/* Prevent runtime suspending between USB-2 and USB-3 initialization */
pm_runtime_get_noresume(&dev->dev);
@@ -364,6 +371,7 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
/* USB 2.0 roothub is stored in the PCI device now. */
hcd = dev_get_drvdata(&dev->dev);
xhci = hcd_to_xhci(hcd);
+ xhci->reset = reset;
xhci->shared_hcd = usb_create_shared_hcd(&xhci_pci_hc_driver, &dev->dev,
pci_name(dev), hcd);
if (!xhci->shared_hcd) {
@@ -515,6 +523,8 @@ static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
int retval = 0;
+ reset_control_reset(xhci->reset);
+
/* The BIOS on systems with the Intel Panther Point chipset may or may
* not support xHCI natively. That means that during system resume, it
* may switch the ports back to EHCI so that users can use their
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 2c6c4f8d1ee1..379ffa24877d 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1770,6 +1770,8 @@ struct xhci_hcd {
/* optional clocks */
struct clk *clk;
struct clk *reg_clk;
+ /* optional reset controller */
+ struct reset_control *reset;
/* data structures */
struct xhci_device_context_array *dcbaa;
struct xhci_ring *cmd_ring;
--
2.26.2
next prev parent reply other threads:[~2020-06-12 17:14 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-12 17:13 [PATCH v3 0/9] Raspberry Pi 4 USB firmware initialization rework Nicolas Saenz Julienne
2020-06-12 17:13 ` [PATCH v3 1/9] dt-bindings: reset: Add a binding for the RPi Firmware reset controller Nicolas Saenz Julienne
2020-06-17 9:55 ` Philipp Zabel
2020-06-17 10:22 ` Nicolas Saenz Julienne
2020-07-13 18:23 ` Rob Herring
2020-07-14 11:59 ` Nicolas Saenz Julienne
2020-07-14 21:07 ` Rob Herring
2020-07-14 21:17 ` Florian Fainelli
2020-07-14 23:18 ` Rob Herring
2020-06-12 17:13 ` [PATCH v3 2/9] reset: Add Raspberry Pi 4 firmware " Nicolas Saenz Julienne
2020-06-17 10:02 ` Philipp Zabel
2020-06-17 10:44 ` Nicolas Saenz Julienne
2020-06-26 10:43 ` Philipp Zabel
2020-06-29 15:19 ` Nicolas Saenz Julienne
2020-06-12 17:13 ` [PATCH v3 3/9] ARM: dts: bcm2711: Add firmware usb reset node Nicolas Saenz Julienne
2020-06-12 17:13 ` [PATCH v3 4/9] ARM: dts: bcm2711: Add reset controller to xHCI node Nicolas Saenz Julienne
2020-06-17 19:21 ` Nicolas Saenz Julienne
2020-06-12 17:13 ` Nicolas Saenz Julienne [this message]
2020-06-12 17:24 ` [PATCH v3 5/9] usb: xhci-pci: Add support for reset controllers Florian Fainelli
2020-06-15 7:29 ` Mathias Nyman
2020-06-17 10:02 ` Philipp Zabel
2020-06-12 17:13 ` [PATCH v3 6/9] Revert "USB: pci-quirks: Add Raspberry Pi 4 quirk" Nicolas Saenz Julienne
2020-06-12 17:13 ` [PATCH v3 7/9] usb: host: pci-quirks: Bypass xHCI quirks for Raspberry Pi 4 Nicolas Saenz Julienne
2020-06-12 17:13 ` [PATCH v3 8/9] Revert "firmware: raspberrypi: Introduce vl805 init routine" Nicolas Saenz Julienne
2020-06-12 17:13 ` [PATCH v3 9/9] Revert "PCI: brcmstb: Wait for Raspberry Pi's firmware when present" Nicolas Saenz Julienne
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=20200612171334.26385-6-nsaenzjulienne@suse.de \
--to=nsaenzjulienne@suse.de \
--cc=andy.shevchenko@gmail.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=f.fainelli@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=helgaas@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mathias.nyman@intel.com \
--cc=mathias.nyman@linux.intel.com \
--cc=p.zabel@pengutronix.de \
--cc=tim.gover@raspberrypi.org \
--cc=wahrenst@gmx.net \
/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).