Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp628969ybg; Fri, 12 Jun 2020 10:17:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNtec2456mkpae1OMTAOLkHpDzBDHHWyDG4rd5w5FPklQ+W/QweN3/z2txQF73omXhtxml X-Received: by 2002:a17:906:6897:: with SMTP id n23mr14532544ejr.437.1591982224615; Fri, 12 Jun 2020 10:17:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591982224; cv=none; d=google.com; s=arc-20160816; b=DsU4vbTbPnB3qpkWoKgA0yyP/Mzny+zoRRYqH96wacgwEf7zHiDDkivm8EEImSBlCl 2rIDYQYrYmpYMDq/q+dfzrs1nyvylPhF9gGYVARJ06wuXA+bf9eVT3Zcx0gr7dtf3s3M ahP4tpt9Gm5kDds8rJ8Sd+PS+zYjnL9IVGq+KzoqGJdTqJNvOXiNe8jZ7efC0SikjVq4 cMLLiiDTi51FuzxlMpVxn1+CUrNvJPnzQ+GA6m5g7LwRCQY2BYgV9V+Q6U/6tQE/svWa BAYtc2XDncb5aWoqRK3H2OJytKk52WR/CVQPCn+Gkk0riwM8sVxidj8quooyqVxI7vO+ gBpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=n2+mNcD2n48BUz3BM4VXyqmhyStJUXFpr4N9H1VLAWs=; b=yCYkBEUM24QSrnV5bIRF7HyTOj1O7ReVVRba5NwczaJiQuyxg4IhaJdMu5X0DIAfje 2nEiKbPKlb2NDq3/grOBriX3m2g+rUU5OXRdfFZPK+kTijCRBSy7A6lfh80dEPOVM1VD OQZOK6xpFjMR/5b5y+x4J/FNi0QRbjWnKIJhwBWuiJDKlZ0Sh8BzMD0sPSE/jBCHe+Qh tU8BXiwiTMX4GoqAcicCn2RTNVvHgFP9lCXiFNOxwLK4g28gaVDyoecd5P2rbnT7qdNN zWCrbXdy1UadqdjjSPBN9q17A7SqFBRv+wCt6qt3to2P8DKeuc2BZcZ5b83lpfz7FpfD nHbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s9si4218400edx.608.2020.06.12.10.16.42; Fri, 12 Jun 2020 10:17:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726553AbgFLRO2 (ORCPT + 99 others); Fri, 12 Jun 2020 13:14:28 -0400 Received: from mx2.suse.de ([195.135.220.15]:50668 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726371AbgFLRNu (ORCPT ); Fri, 12 Jun 2020 13:13:50 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B58D5AEF8; Fri, 12 Jun 2020 17:13:52 +0000 (UTC) From: Nicolas Saenz Julienne To: f.fainelli@gmail.com, gregkh@linuxfoundation.org, wahrenst@gmx.net, p.zabel@pengutronix.de, linux-kernel@vger.kernel.org, Mathias Nyman 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 Subject: [PATCH v3 5/9] usb: xhci-pci: Add support for reset controllers Date: Fri, 12 Jun 2020 19:13:29 +0200 Message-Id: <20200612171334.26385-6-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200612171334.26385-1-nsaenzjulienne@suse.de> References: <20200612171334.26385-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 #include #include +#include #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