Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3002952ybt; Mon, 29 Jun 2020 12:37:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFZOtkLFKthT8ehj/1mtasEcs1I3VPa5cbkJWE2+VsvBgy96TBG0plGn9Mw4yuY3c15zcl X-Received: by 2002:a17:906:780f:: with SMTP id u15mr3862918ejm.295.1593459436566; Mon, 29 Jun 2020 12:37:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593459436; cv=none; d=google.com; s=arc-20160816; b=f0nXif3jdGJOkgkAWedx3lXAdfCksFgABKgQHK3MGXM+71BXJUeH8OjKPlO4hg+qL6 SLWvCUDoGnichm6YwrOAdruk0I0ITImX1mVk/8N9SUKIb0Ow/NL/lDbiuiY55Dkqo5R8 VYOmH9uOkBKOJKq3yjiyNOqzC9X9qZXpDpWxI22dy4OEFbLWkEnvczqdo7mKIgB9hD/g pWJK+C7x8JorOOLyclrJAFUAkQ8rusyf39l3jmcj1Ql2c4wAwZ1hwPA54BytY5EuZ7dv 4VaKojVjdbB6302ZzXxaMKm+WKG5vZOumwMJ+ty3rLE6Y52ghDAtS8W4PISQdMmOEFjv pi1g== 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=FwFeLJTxkWvFa8cejZn7EQSKF4ZLJB1nHLVb56sVqtM=; b=h9NhyScbIwYldRK4mFLMKGeb+Mgt+7bRNaqHB1IiC1nVZznQZ7UhHCkzBaUsKbVg37 vePuP446z2mLFh8o9lbWz6Y6WeYeRVdpedxQAqOMXWICKxsVi0qpntxmR57adhjlYfCQ kxPdk0YZpIXY/+n0GxTksLqa8X+hxB1zMe86qonIRuxAKS5wBXl8vfFS+4uWqJr2mGL8 I+WTnPtHkdD5Gvf1331Xi7x74eAssV/y1+QBRzdbNMLqrnrmKa9FyauyLWVEsRDjMRlI g95belrI0dR0h8X5MnWkEJCNjAxfLLCWa8P8B7W+gQUsO6xn1AkQF90/rBLPO6ifUqLW 4p8Q== 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 k8si347384ejc.257.2020.06.29.12.36.52; Mon, 29 Jun 2020 12:37:16 -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 S1733220AbgF2Tet (ORCPT + 99 others); Mon, 29 Jun 2020 15:34:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:36620 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732399AbgF2TbZ (ORCPT ); Mon, 29 Jun 2020 15:31:25 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A69BCAE71; Mon, 29 Jun 2020 16:18:58 +0000 (UTC) From: Nicolas Saenz Julienne To: f.fainelli@gmail.com, gregkh@linuxfoundation.org, robh@kernel.org, wahrenst@gmx.net, p.zabel@pengutronix.de, andy.shevchenko@gmail.com Cc: linux-usb@vger.kernel.org, linux-kernel@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, mathias.nyman@linux.intel.com, lorenzo.pieralisi@arm.com, Nicolas Saenz Julienne Subject: [PATCH v5 5/9] usb: xhci-pci: Add support for reset controllers Date: Mon, 29 Jun 2020 18:18:41 +0200 Message-Id: <20200629161845.6021-6-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629161845.6021-1-nsaenzjulienne@suse.de> References: <20200629161845.6021-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 Acked-by: Mathias Nyman Reviewed-by: Philipp Zabel --- Changes since v3: - Now that DT is fixed we can use the actual xHCI device to get reset controller (not altering the reviewed-bys as it wasn't an xHCI/reset controller issue). 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..f8b171825dfc 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->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 c295e8a7f5ae..b22840049ff7 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.27.0