From patchwork Fri Nov 9 14:01:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 10676031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B678613AD for ; Fri, 9 Nov 2018 14:12:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A49A32E4BA for ; Fri, 9 Nov 2018 14:12:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 987F52E581; Fri, 9 Nov 2018 14:12:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 306E12E4BA for ; Fri, 9 Nov 2018 14:12:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728054AbeKIXwR (ORCPT ); Fri, 9 Nov 2018 18:52:17 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:38444 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727802AbeKIXwQ (ORCPT ); Fri, 9 Nov 2018 18:52:16 -0500 Received: by mail-yw1-f65.google.com with SMTP id i65-v6so1670446ywc.5; Fri, 09 Nov 2018 06:11:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AoHUTHGA1zpUa8UUDtSFA1T498oTPkU+IGtUNuwWsLg=; b=SGQ8hlAQ+i/j89KGKLpjQoSfrL64jJyXmL/0NAS++2WDmMG5fPyu8RWIS6QGtBI2Np +oOcGiaD1HLQgRHnzUt1DiM87+49B70e8INoHbc0qUIYXXT0l3Q1ENgpQMkshJ4bSRVy qxjEUaTeoOfMb9A6GtSvPv7juFEqP+0CKr0V8xrPo0080ywVvXRAaHHUWQv+DMqXC/3V ZROzHgczg41K2+XReSIw/NbI+k6Tj3Wqylw8k007wYDBw4MzsQADBxLh0WWAYdnQMYs8 /1P53IO7qnVa8V1ac3b6NJhrWw/JZyYtxFwvL0eloyFTIeTr0fjO/pOpS1DyHIIfTeSM 3hew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AoHUTHGA1zpUa8UUDtSFA1T498oTPkU+IGtUNuwWsLg=; b=SOi4pPlF+2428n0yCp/4mw+sOeApusWWWuNvuF1nIgeI7Hgb9bKqR/L/oi1wFyomg0 Xd5kBC8UnqQC8UkqaqH1e7dfJDXkXUj6vMzMUIiB6tQEJC1vqXgvtyOgk0sq9CamAAOK /BkhX5BdIl0fwwyIJoZelxEnjuk2TnY3iPNQ1zvKNfc6zgQLdZ9K2B/Vxx7BjcJhA4ce RWUTazHLBgZt8VS+ZKfqTqJOHAres8F73mdt07KZARmzeoCcBdWTu2JZOiVTgb21kBjz 55dRtGbgNECQFnCQNp026Mg3aofI81AIFG/nGqD+Q5DLJao8y547SwukKVzaKTvFm2Et K8Gg== X-Gm-Message-State: AGRZ1gKIYqOSSYHYnvnx2Uq5vjVSd6Lwjwyp55UvyxyxYMMAu94iB+s5 4pUlGokmTggMcG6YuD2bhZQPsDGG6E8= X-Google-Smtp-Source: AJdET5diYASp+julG1aE6VQS9GIIna9dVSjcBqXdSxSKsaaWT9u7TG35P+XbPOhmzEvSQH1yeBfXew== X-Received: by 2002:a81:498a:: with SMTP id w132-v6mr8637528ywa.232.1541772689513; Fri, 09 Nov 2018 06:11:29 -0800 (PST) Received: from stbsrv-and-3.and.broadcom.com ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id c6-v6sm7301965ywh.34.2018.11.09.06.11.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 06:11:29 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Cc: Al Cooper , Alan Stern , Alban Bedel , Alex Elder , Andrew Morton , Arnd Bergmann , Avi Fishman , bcm-kernel-feedback-list@broadcom.com, Bjorn Andersson , Chunfeng Yun , "David S. Miller" , devicetree@vger.kernel.org, Dmitry Osipenko , Greg Kroah-Hartman , "Gustavo A. R. Silva" , Hans de Goede , James Hogan , Johan Hovold , Kees Cook , linux-usb@vger.kernel.org, Lu Baolu , Mark Rutland , Martin Blumenstingl , Mathias Nyman , Mathias Nyman , Mauro Carvalho Chehab , Rishabh Bhatnagar , Rob Herring , Roger Quadros Subject: [PATCH V4 1/5] dt-bindings: Add Broadcom STB USB support Date: Fri, 9 Nov 2018 09:01:56 -0500 Message-Id: <1541772120-40394-2-git-send-email-alcooperx@gmail.com> X-Mailer: git-send-email 1.9.0.138.g2de3478 In-Reply-To: <1541772120-40394-1-git-send-email-alcooperx@gmail.com> References: <1541772120-40394-1-git-send-email-alcooperx@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add DT bindings for Broadcom STB USB EHCI and XHCI drivers. Add "phy-supplies-usb-clock" property description to usb-hcd.txt NOTE: The OHCI driver is not included because it uses the generic platform driver. Signed-off-by: Al Cooper Reviewed-by: Rob Herring --- .../devicetree/bindings/usb/brcm,bcm7445-ehci.txt | 24 ++++++++++++++++++++++ Documentation/devicetree/bindings/usb/usb-hcd.txt | 3 +++ Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 + 3 files changed, 28 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt diff --git a/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt new file mode 100644 index 000000000000..4dea956f2705 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt @@ -0,0 +1,24 @@ +Broadcom STB USB EHCI controller + +Required properties: +- compatible: should be "brcm,bcm7445-ehci" +- reg: should contain one register range i.e. start and length +- interrupts: description of the interrupt line +- phys: phandle + phy specifier pair + The specifier should be 0 for the OHCI/EHCI PHY +- phy-supplies-usb-clock: See usb-hcd.txt for details. + +Optional properties: +- clocks: A phandle for the EHCI clock + +Example: + +ehci@f0b00300 { + compatible = "brcm,bcm7445-ehci"; + reg = <0xf0b00300 0xa8>; + interrupts = <0x0 0x5a 0x0>; + interrupt-names = "usb0_ehci_0"; + phys = <&usbphy_0 0x0>; + clocks = <&usb20>; + phy-supplies-usb-clock; +}; diff --git a/Documentation/devicetree/bindings/usb/usb-hcd.txt b/Documentation/devicetree/bindings/usb/usb-hcd.txt index 50529b838c9c..6b4755924b15 100644 --- a/Documentation/devicetree/bindings/usb/usb-hcd.txt +++ b/Documentation/devicetree/bindings/usb/usb-hcd.txt @@ -2,6 +2,9 @@ Generic USB HCD (Host Controller Device) Properties Optional properties: - phys: a list of all USB PHYs on this HCD +- phy-supplies-usb-clock: boolean, used for SoCs where the PHY supplies + the usb controller clock. This will prevent the PHY exit from being + called on suspend. Example: &usb1 { diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt index fea8b1545751..f58e617ee54c 100644 --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt @@ -21,6 +21,7 @@ Required properties: device - "renesas,rcar-gen3-xhci" for a generic R-Car Gen3 or RZ/G2 compatible device + - "brcm,bcm7445-xhci" for Broadcom STB SoCs - "xhci-platform" (deprecated) When compatible with the generic version, nodes must list the From patchwork Fri Nov 9 14:01:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 10676027 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A6061709 for ; Fri, 9 Nov 2018 14:11:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 095F92E3D2 for ; Fri, 9 Nov 2018 14:11:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0A5B2E4BB; Fri, 9 Nov 2018 14:11:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43A502E3D2 for ; Fri, 9 Nov 2018 14:11:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728364AbeKIXwU (ORCPT ); Fri, 9 Nov 2018 18:52:20 -0500 Received: from mail-yb1-f194.google.com ([209.85.219.194]:40502 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728046AbeKIXwT (ORCPT ); Fri, 9 Nov 2018 18:52:19 -0500 Received: by mail-yb1-f194.google.com with SMTP id g9-v6so1078036ybh.7; Fri, 09 Nov 2018 06:11:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SJTlmwHK0QaJa76tDiqzpr+Ll6iBfOd6+RCAreENEmk=; b=V3gAjg3re2HeM6zvgwn/JWPBmgabme7oBKOk7OU2yRhvmBpWeRQ+VepLqPpxMndvft nmUt6z1LQXByt9Vpb/uqB50/sL6he0s7F+RjvKtH3VKx8DvVoAM6p7bc57xpZE67g4nf Yz1nj90A/eMhxQhrLwbIUGzGqIzTNsQQAC0LDZlz7RP83PipMtbrzjTEse+8+6vX1QtJ BfJr96t2wARJcfw8P9wD8ugSQLeYDJAew7mqONN6T/ruE2k3A4epYZ/+Ufxifs9ZH7ds diroWUYDnghCUl+M3PCsN1j3DEcA1aotKQKN6XwjTEoSdvqLMs7Ss4PYflx3U5d5hXeg t53g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SJTlmwHK0QaJa76tDiqzpr+Ll6iBfOd6+RCAreENEmk=; b=Vfja4KIniSIY220EdpnZSEpZScC2nv1mlkudctin+liHV49dDNfXNHhxmzyVkwFAfM 0PR96hro274ji13aHqRCkoYaRoODYTCR7HTkqh94SVigjR0xqeDnBiEhILqT6C3Qh3MS eqEvyRmXnD8KDMgoPv7OWPRWwHccQaCiDXUJUFH9ZH0HWPu8yoR9XjsCcz6MRjVEXmt9 NEHky+cS0y1EVtwdLrkWjo7S3tGl0mFh91oG6Dl61vIeWA8M2Ktv4f+v02vnCyug50J5 5oUTplfvSd0HCAkoIT72rL7VlerWNud+IlpoqVB+LYvMMErnChXHux1oZ2VmT7yjurTe KO5w== X-Gm-Message-State: AGRZ1gIxL2AKM42N8YFTb6FXHDSvQVx09c8yCRYK8TWZJTfFpLkpYJVZ bnSRV2AWI9Xrlp3Glk9mjVSxUW3xy8I= X-Google-Smtp-Source: AJdET5f9e0eXkypU9Krr0PSlQZ6nenFmdMEAdbEQEr3SykAN0aGwNaEaHlRSTIY+uvDy8nuDbWu5rw== X-Received: by 2002:a25:46c5:: with SMTP id t188-v6mr8943772yba.108.1541772691287; Fri, 09 Nov 2018 06:11:31 -0800 (PST) Received: from stbsrv-and-3.and.broadcom.com ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id c6-v6sm7301965ywh.34.2018.11.09.06.11.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 06:11:30 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Cc: Al Cooper , Alan Stern , Alban Bedel , Alex Elder , Andrew Morton , Arnd Bergmann , Avi Fishman , bcm-kernel-feedback-list@broadcom.com, Bjorn Andersson , Chunfeng Yun , "David S. Miller" , devicetree@vger.kernel.org, Dmitry Osipenko , Greg Kroah-Hartman , "Gustavo A. R. Silva" , Hans de Goede , James Hogan , Johan Hovold , Kees Cook , linux-usb@vger.kernel.org, Lu Baolu , Mark Rutland , Martin Blumenstingl , Mathias Nyman , Mathias Nyman , Mauro Carvalho Chehab , Rishabh Bhatnagar , Rob Herring , Roger Quadros Subject: [PATCH V4 2/5] usb: core: Add ability to skip phy exit on suspend and init on resume Date: Fri, 9 Nov 2018 09:01:57 -0500 Message-Id: <1541772120-40394-3-git-send-email-alcooperx@gmail.com> X-Mailer: git-send-email 1.9.0.138.g2de3478 In-Reply-To: <1541772120-40394-1-git-send-email-alcooperx@gmail.com> References: <1541772120-40394-1-git-send-email-alcooperx@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add the ability to skip calling the PHY's exit routine on suspend and the PHY's init routine on resume. This is to handle a USB PHY that should have it's power_off function called on suspend but cannot have it's exit function called because on exit it will disable the PHY to the point where all USB clocks are stopped and register accesses to the Host Controllers using the PHY will be disabled and the host drivers will crash. This is enabled with the HCD flag "phy_supplies_usb_clock" which can be set from any HCD driver or with the device tree property "phy-supplies-usb-clock". Signed-off-by: Al Cooper --- drivers/usb/core/hcd.c | 8 ++++---- drivers/usb/core/phy.c | 28 ++++++++++++++++++++-------- drivers/usb/core/phy.h | 9 ++++++--- include/linux/usb/hcd.h | 6 ++++++ 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 487025d31d44..5ebc82a69403 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2249,7 +2249,7 @@ int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg) hcd->state = HC_STATE_SUSPENDED; if (!PMSG_IS_AUTO(msg)) - usb_phy_roothub_suspend(hcd->self.sysdev, + usb_phy_roothub_suspend(hcd, hcd->phy_roothub); /* Did we race with a root-hub wakeup event? */ @@ -2290,7 +2290,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg) } if (!PMSG_IS_AUTO(msg)) { - status = usb_phy_roothub_resume(hcd->self.sysdev, + status = usb_phy_roothub_resume(hcd, hcd->phy_roothub); if (status) return status; @@ -2333,7 +2333,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg) } } else { hcd->state = old_state; - usb_phy_roothub_suspend(hcd->self.sysdev, hcd->phy_roothub); + usb_phy_roothub_suspend(hcd, hcd->phy_roothub); dev_dbg(&rhdev->dev, "bus %s fail, err %d\n", "resume", status); if (status != -ESHUTDOWN) @@ -2730,7 +2730,7 @@ int usb_add_hcd(struct usb_hcd *hcd, struct usb_device *rhdev; if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) { - hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev); + hcd->phy_roothub = usb_phy_roothub_alloc(hcd); if (IS_ERR(hcd->phy_roothub)) return PTR_ERR(hcd->phy_roothub); diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c index 38b2c776c4b4..8bfbacb52a7b 100644 --- a/drivers/usb/core/phy.c +++ b/drivers/usb/core/phy.c @@ -46,10 +46,11 @@ static int usb_phy_roothub_add_phy(struct device *dev, int index, return 0; } -struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev) +struct usb_phy_roothub *usb_phy_roothub_alloc(struct usb_hcd *hcd) { struct usb_phy_roothub *phy_roothub; int i, num_phys, err; + struct device *dev = hcd->self.sysdev; if (!IS_ENABLED(CONFIG_GENERIC_PHY)) return NULL; @@ -59,6 +60,9 @@ struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev) if (num_phys <= 0) return NULL; + if (device_property_read_bool(dev, "phy-supplies-usb-clock")) + hcd->phy_supplies_usb_clock = 1; + phy_roothub = devm_kzalloc(dev, sizeof(*phy_roothub), GFP_KERNEL); if (!phy_roothub) return ERR_PTR(-ENOMEM); @@ -162,26 +166,33 @@ void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub) } EXPORT_SYMBOL_GPL(usb_phy_roothub_power_off); -int usb_phy_roothub_suspend(struct device *controller_dev, +int usb_phy_roothub_suspend(struct usb_hcd *hcd, struct usb_phy_roothub *phy_roothub) { + struct device *controller_dev = hcd->self.sysdev; + usb_phy_roothub_power_off(phy_roothub); - /* keep the PHYs initialized so the device can wake up the system */ - if (device_may_wakeup(controller_dev)) + /* + * keep the PHYs initialized so the device can wake up the system + * or if needed to keep the USB clocks enabled. + */ + if (device_may_wakeup(controller_dev) || hcd->phy_supplies_usb_clock) return 0; return usb_phy_roothub_exit(phy_roothub); } EXPORT_SYMBOL_GPL(usb_phy_roothub_suspend); -int usb_phy_roothub_resume(struct device *controller_dev, +int usb_phy_roothub_resume(struct usb_hcd *hcd, struct usb_phy_roothub *phy_roothub) { + struct device *controller_dev = hcd->self.sysdev; int err; - /* if the device can't wake up the system _exit was called */ - if (!device_may_wakeup(controller_dev)) { + /* if _exit was called on suspend */ + if (!device_may_wakeup(controller_dev) && + !hcd->phy_supplies_usb_clock) { err = usb_phy_roothub_init(phy_roothub); if (err) return err; @@ -190,7 +201,8 @@ int usb_phy_roothub_resume(struct device *controller_dev, err = usb_phy_roothub_power_on(phy_roothub); /* undo _init if _power_on failed */ - if (err && !device_may_wakeup(controller_dev)) + if (err && !device_may_wakeup(controller_dev) + && !hcd->phy_supplies_usb_clock) usb_phy_roothub_exit(phy_roothub); return err; diff --git a/drivers/usb/core/phy.h b/drivers/usb/core/phy.h index 88a3c037e9df..34293e11a917 100644 --- a/drivers/usb/core/phy.h +++ b/drivers/usb/core/phy.h @@ -5,13 +5,16 @@ * Copyright (C) 2018 Martin Blumenstingl */ +#include +#include + #ifndef __USB_CORE_PHY_H_ #define __USB_CORE_PHY_H_ struct device; struct usb_phy_roothub; -struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev); +struct usb_phy_roothub *usb_phy_roothub_alloc(struct usb_hcd *hcd); int usb_phy_roothub_init(struct usb_phy_roothub *phy_roothub); int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub); @@ -19,9 +22,9 @@ int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub); void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub); -int usb_phy_roothub_suspend(struct device *controller_dev, +int usb_phy_roothub_suspend(struct usb_hcd *hcd, struct usb_phy_roothub *phy_roothub); -int usb_phy_roothub_resume(struct device *controller_dev, +int usb_phy_roothub_resume(struct usb_hcd *hcd, struct usb_phy_roothub *phy_roothub); #endif /* __USB_CORE_PHY_H_ */ diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 97e2ddec18b1..7c42cf0f6835 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -157,6 +157,12 @@ struct usb_hcd { */ unsigned skip_phy_initialization:1; + /* + * Some phys supply the USB controller clocks and should not + * have exit called on suspend. + */ + unsigned phy_supplies_usb_clock:1; + /* The next flag is a stopgap, to be removed when all the HCDs * support the new root-hub polling mechanism. */ unsigned uses_new_polling:1; From patchwork Fri Nov 9 14:01:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 10676029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1ECA313AD for ; Fri, 9 Nov 2018 14:11:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DAAF2E3D2 for ; Fri, 9 Nov 2018 14:11:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0186B2E4B0; Fri, 9 Nov 2018 14:11:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BB012E3D2 for ; Fri, 9 Nov 2018 14:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728272AbeKIXwU (ORCPT ); Fri, 9 Nov 2018 18:52:20 -0500 Received: from mail-yb1-f194.google.com ([209.85.219.194]:45326 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727802AbeKIXwT (ORCPT ); Fri, 9 Nov 2018 18:52:19 -0500 Received: by mail-yb1-f194.google.com with SMTP id 131-v6so1059851ybe.12; Fri, 09 Nov 2018 06:11:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SQ1qrcLiIRYqOVmsCK0PkJAXJvvPlMp6EdxfoWbisj0=; b=RdxUyQbkpkC6SAQUQSvaz17J9cY1KfdUEWq03ulBktroBdHbQCT3Xl0zl6sD6FD/Vs 9ZQ2IED5qBB3EwGQa4kanWL17vCm1idiTEWQTt273lnTxwT6S7HGXFI0l1TJOA7CZJjb tRvjgLD8da+8wAGmvzsL1n10A2JqKJjoPpMUqUHjnPqN3jiLCyNIeG/vhEbJPjtWQlm8 edJa3ttPeND/8V7iyuW2m5Kf8RJJmpsj16pmauC/GZ4GgV836++azscamvxn8a8h1yga vaB8h6pbXL/Jf67+lVzEJCIA2yirmsKff+wpKNgePNJ+zAIvrVSa5zf4inrlpB9RzxR5 b1vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SQ1qrcLiIRYqOVmsCK0PkJAXJvvPlMp6EdxfoWbisj0=; b=VLPCTZ25r7aRjQ+tcOyxojr327ABW2yjptb2iPM1pX1tWCUMLHfnnAotQbcdXSq3Ub +s+pUkI6H0OdYXPRqyUHdsESuAZi2EdBRdS+xMLNxwz9deZO+NdWjH14v3IwkFROWkPS 46yL9F6BrGvO/CrFx4SqauUcOw3eP/2FYmBY8wsFDuPO1iyV7YSi2Gxh6CLj5jmLxNwT HMFX8//9xQKkbm62n41gMZfqjjqu1ZpDt63QZUnwmivb/Z1hISvPHQjIKAIwdiQUFY3d my9nM7gyah+CgGtcqukzp9Ef5A6bLqtn1FH6ElFnmWjZAZ/VqUoa69pel92osudytfEI Uwrg== X-Gm-Message-State: AGRZ1gLmIXbMPykmzNntlGIIpo2/G99Qo42UD23KYwY0dnjX336uoxKD 4/96zEQ5ofedAFIi0UgT9yyQ1s03+bA= X-Google-Smtp-Source: AJdET5f5qCC9oQa2WkHIrYuP38sbT2YTTrYLFjU4qmfPyEXSslJMdN8FUzcKETUQigVvtYWhz0adRQ== X-Received: by 2002:a25:48c7:: with SMTP id v190-v6mr8705826yba.7.1541772692936; Fri, 09 Nov 2018 06:11:32 -0800 (PST) Received: from stbsrv-and-3.and.broadcom.com ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id c6-v6sm7301965ywh.34.2018.11.09.06.11.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 06:11:32 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Cc: Al Cooper , Alan Stern , Alban Bedel , Alex Elder , Andrew Morton , Arnd Bergmann , Avi Fishman , bcm-kernel-feedback-list@broadcom.com, Bjorn Andersson , Chunfeng Yun , "David S. Miller" , devicetree@vger.kernel.org, Dmitry Osipenko , Greg Kroah-Hartman , "Gustavo A. R. Silva" , Hans de Goede , James Hogan , Johan Hovold , Kees Cook , linux-usb@vger.kernel.org, Lu Baolu , Mark Rutland , Martin Blumenstingl , Mathias Nyman , Mathias Nyman , Mauro Carvalho Chehab , Rishabh Bhatnagar , Rob Herring , Roger Quadros Subject: [PATCH V4 3/5] usb: xhci: xhci-plat: Add support for Broadcom STB SoC's Date: Fri, 9 Nov 2018 09:01:58 -0500 Message-Id: <1541772120-40394-4-git-send-email-alcooperx@gmail.com> X-Mailer: git-send-email 1.9.0.138.g2de3478 In-Reply-To: <1541772120-40394-1-git-send-email-alcooperx@gmail.com> References: <1541772120-40394-1-git-send-email-alcooperx@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for Broadcom STB SoC's to the xhci platform driver Signed-off-by: Al Cooper --- drivers/usb/host/xhci-brcm.c | 16 ++++++++++++++++ drivers/usb/host/xhci-brcm.h | 16 ++++++++++++++++ drivers/usb/host/xhci-plat.c | 8 ++++++++ 3 files changed, 40 insertions(+) create mode 100644 drivers/usb/host/xhci-brcm.c create mode 100644 drivers/usb/host/xhci-brcm.h diff --git a/drivers/usb/host/xhci-brcm.c b/drivers/usb/host/xhci-brcm.c new file mode 100644 index 000000000000..bf8c0bfd1780 --- /dev/null +++ b/drivers/usb/host/xhci-brcm.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2018, Broadcom */ + +#include +#include + +#include "xhci.h" + +int xhci_plat_brcm_init_quirk(struct usb_hcd *hcd) +{ + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + + xhci->quirks |= XHCI_RESET_ON_RESUME; + return 0; +} + diff --git a/drivers/usb/host/xhci-brcm.h b/drivers/usb/host/xhci-brcm.h new file mode 100644 index 000000000000..e64800fae4d5 --- /dev/null +++ b/drivers/usb/host/xhci-brcm.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2018, Broadcom */ + +#ifndef _XHCI_BRCM_H +#define _XHCI_BRCM_H + +#if IS_ENABLED(CONFIG_USB_XHCI_BRCM) +int xhci_plat_brcm_init_quirk(struct usb_hcd *hcd); +#else +static inline int xhci_plat_brcm_init_quirk(struct usb_hcd *hcd) +{ + return 0; +} +#endif +#endif /* _XHCI_BRCM_H */ + diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 32b5574ad5c5..5372d4040be6 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -24,6 +24,7 @@ #include "xhci-plat.h" #include "xhci-mvebu.h" #include "xhci-rcar.h" +#include "xhci-brcm.h" static struct hc_driver __read_mostly xhci_plat_hc_driver; @@ -112,6 +113,10 @@ static int xhci_plat_start(struct usb_hcd *hcd) .resume_quirk = xhci_rcar_resume_quirk, }; +static const struct xhci_plat_priv xhci_plat_brcm = { + .init_quirk = xhci_plat_brcm_init_quirk +}; + static const struct of_device_id usb_xhci_of_match[] = { { .compatible = "generic-xhci", @@ -144,6 +149,9 @@ static int xhci_plat_start(struct usb_hcd *hcd) }, { .compatible = "renesas,rcar-gen3-xhci", .data = &xhci_plat_renesas_rcar_gen3, + }, { + .compatible = "brcm,bcm7445-xhci", + .data = &xhci_plat_brcm, }, {}, }; From patchwork Fri Nov 9 14:01:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 10676025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 157421709 for ; Fri, 9 Nov 2018 14:11:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02B572E3D2 for ; Fri, 9 Nov 2018 14:11:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA8C12E4BA; Fri, 9 Nov 2018 14:11:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F7C72E3D2 for ; Fri, 9 Nov 2018 14:11:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728178AbeKIXwW (ORCPT ); Fri, 9 Nov 2018 18:52:22 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:37501 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728604AbeKIXwV (ORCPT ); Fri, 9 Nov 2018 18:52:21 -0500 Received: by mail-yw1-f67.google.com with SMTP id v77-v6so1678124ywc.4; Fri, 09 Nov 2018 06:11:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EVb7VCq6Tf3SsekKc2jGmlWIMkhRfo5YqgMjxLjryJ0=; b=vKfyOps6b0oePBBZXQIgLp73Oisq7GqaMlxB9UxGxe1IL22RnlLGMGSOZKcMCuWpA8 fliCbt3TC1Sa6+b+fdsW2D7AI18JXEP0kgRMJlmxSEk9zbj8Le8xI+noSCTZYgX1AArr 46WR1E9xxWHPPIpy3u3xXrxROIriS93vffbmKteqKcVoroEG4u119puv0WKaYVlSs9Te PtYZ/aGVTeohpjqI57p41HEOIJbQ240JDCwxew3foBM85Sctq3pDwMgKggSZKA2HcOMN 9UoJ4GjGcxxI7/zc46Q05Ky/1Gfqpkx1W91iCIZ3UIuMbm9uTEScRxdxV5VkjLzGpXgd wTpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EVb7VCq6Tf3SsekKc2jGmlWIMkhRfo5YqgMjxLjryJ0=; b=lxIvW+qxxk74G+SQfjfIbx8zlN8DA6SYsdunSbuNSRzIQhqJ+GkxE49Hg41kDWCctV tOIiBHSCCbwub6aKSbJRF/XyTFkVbLKqFrBOR1LxLRU1aAZpIU1uy+22OUXuWBBHe5K0 /l3JcRqGp9Vut17+6NERyh5XfOyt5wzsBSELUIGoJ/XVzRr/dFPRoH0Yun+e3IZdlusr uu7uC5hlotR/4zwzYfGcMd1cGjdIXuJqY1BuhVu6ae9dE0S1Z6HzCY43KkFflDZlA31+ rJOilTYhGZ3hAYD6jcaTDtke2Kfvi5HLO/NsiKp0E6Z4iwXQinNttJAm59Udjvz4xVHZ K+GQ== X-Gm-Message-State: AGRZ1gKq3I5eB+xzgfJ9o4fyfj1lozKzd39El86MC+pO3WuSFpTp9+Wf DM9r4qb5G6R4Q8605YOXrIJ/IvbqQd0= X-Google-Smtp-Source: AJdET5dEVJm4QYG9hKajNrQ2pyDtb5+1K3FY1L6n3kwtxDOzdb7BM4sZQW6ha2hJhW+ztuE7/VKT5w== X-Received: by 2002:a81:6f57:: with SMTP id k84-v6mr8883177ywc.348.1541772694862; Fri, 09 Nov 2018 06:11:34 -0800 (PST) Received: from stbsrv-and-3.and.broadcom.com ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id c6-v6sm7301965ywh.34.2018.11.09.06.11.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 06:11:34 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Cc: Al Cooper , Alan Stern , Alban Bedel , Alex Elder , Andrew Morton , Arnd Bergmann , Avi Fishman , bcm-kernel-feedback-list@broadcom.com, Bjorn Andersson , Chunfeng Yun , "David S. Miller" , devicetree@vger.kernel.org, Dmitry Osipenko , Greg Kroah-Hartman , "Gustavo A. R. Silva" , Hans de Goede , James Hogan , Johan Hovold , Kees Cook , linux-usb@vger.kernel.org, Lu Baolu , Mark Rutland , Martin Blumenstingl , Mathias Nyman , Mathias Nyman , Mauro Carvalho Chehab , Rishabh Bhatnagar , Rob Herring , Roger Quadros Subject: [PATCH V4 4/5] usb: ehci: Add new EHCI driver for Broadcom STB SoC's Date: Fri, 9 Nov 2018 09:01:59 -0500 Message-Id: <1541772120-40394-5-git-send-email-alcooperx@gmail.com> X-Mailer: git-send-email 1.9.0.138.g2de3478 In-Reply-To: <1541772120-40394-1-git-send-email-alcooperx@gmail.com> References: <1541772120-40394-1-git-send-email-alcooperx@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a new EHCI driver for Broadcom STB SoC's. A new EHCI driver was created instead of adding support to the existing ehci platform driver because of the code required to workaround bugs in the EHCI controller. Signed-off-by: Al Cooper --- drivers/usb/host/ehci-brcm.c | 286 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 drivers/usb/host/ehci-brcm.c diff --git a/drivers/usb/host/ehci-brcm.c b/drivers/usb/host/ehci-brcm.c new file mode 100644 index 000000000000..eb0ea030a4c8 --- /dev/null +++ b/drivers/usb/host/ehci-brcm.c @@ -0,0 +1,286 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2018, Broadcom */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ehci.h" + +#define BRCM_DRIVER_DESC "EHCI Broadcom STB driver" + +#define hcd_to_ehci_priv(h) ((struct brcm_priv *)hcd_to_ehci(h)->priv) + +struct brcm_priv { + struct clk *clk; +}; + +static const char brcm_hcd_name[] = "ehci-brcm"; + +static int (*org_hub_control)(struct usb_hcd *hcd, + u16 typeReq, u16 wValue, u16 wIndex, + char *buf, u16 wLength); + +/* ehci_brcm_wait_for_sof + * Wait for start of next microframe, then wait extra delay microseconds + */ +static inline void ehci_brcm_wait_for_sof(struct ehci_hcd *ehci, u32 delay) +{ + int frame_idx = ehci_readl(ehci, &ehci->regs->frame_index); + + while (frame_idx == ehci_readl(ehci, &ehci->regs->frame_index)) + ; + udelay(delay); +} + +/* + * ehci_brcm_hub_control + * Intercept echi-hcd request to complete RESUME and align it to the start + * of the next microframe. + * If RESUME is complete too late in the microframe, host controller + * detects babble on suspended port and resets the port afterwards. + * This s/w workaround allows to avoid this problem. + * See SWLINUX-1909 for more details + */ +static int ehci_brcm_hub_control( + struct usb_hcd *hcd, + u16 typeReq, + u16 wValue, + u16 wIndex, + char *buf, + u16 wLength) +{ + struct ehci_hcd *ehci = hcd_to_ehci(hcd); + int ports = HCS_N_PORTS(ehci->hcs_params); + u32 __iomem *status_reg = &ehci->regs->port_status[ + (wIndex & 0xff) - 1]; + unsigned long flags; + int retval, irq_disabled = 0; + + /* + * RESUME is cleared when GetPortStatus() is called 20ms after start + * of RESUME + */ + if ((typeReq == GetPortStatus) && + (wIndex && wIndex <= ports) && + ehci->reset_done[wIndex-1] && + time_after_eq(jiffies, ehci->reset_done[wIndex-1]) && + (ehci_readl(ehci, status_reg) & PORT_RESUME)) { + + /* + * to make sure we are not interrupted until RESUME bit + * is cleared, disable interrupts on current CPU + */ + ehci_dbg(ehci, "SOF alignment workaround\n"); + irq_disabled = 1; + local_irq_save(flags); + ehci_brcm_wait_for_sof(ehci, 5); + } + retval = (*org_hub_control)(hcd, typeReq, wValue, wIndex, buf, wLength); + if (irq_disabled) + local_irq_restore(flags); + return retval; +} + +static int ehci_brcm_reset(struct usb_hcd *hcd) +{ + struct ehci_hcd *ehci = hcd_to_ehci(hcd); + + ehci->big_endian_mmio = 1; + + ehci->caps = (struct ehci_caps *) hcd->regs; + ehci->regs = (struct ehci_regs *) (hcd->regs + + HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase))); + + /* This fixes the lockup during reboot due to prior interrupts */ + ehci_writel(ehci, CMD_RESET, &ehci->regs->command); + mdelay(10); + + /* + * SWLINUX-1705: Avoid OUT packet underflows during high memory + * bus usage + * port_status[0x0f] = Broadcom-proprietary USB_EHCI_INSNREG00 @ 0x90 + */ + ehci_writel(ehci, 0x00800040, &ehci->regs->port_status[0x10]); + ehci_writel(ehci, 0x00000001, &ehci->regs->port_status[0x12]); + + return ehci_setup(hcd); +} + +static struct hc_driver __read_mostly ehci_brcm_hc_driver; + +static const struct ehci_driver_overrides brcm_overrides __initconst = { + + .reset = ehci_brcm_reset, + .extra_priv_size = sizeof(struct brcm_priv), +}; + +static int ehci_brcm_probe(struct platform_device *pdev) +{ + struct usb_hcd *hcd; + struct resource *res_mem; + struct brcm_priv *priv; + int irq; + int err; + + if (usb_disabled()) + return -ENODEV; + + err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); + if (err) + return err; + + irq = platform_get_irq(pdev, 0); + if (irq < 0) { + dev_err(&pdev->dev, "no irq provided"); + return irq; + } + + /* Hook the hub control routine to work around a bug */ + if (org_hub_control == NULL) + org_hub_control = ehci_brcm_hc_driver.hub_control; + ehci_brcm_hc_driver.hub_control = ehci_brcm_hub_control; + + /* initialize hcd */ + hcd = usb_create_hcd(&ehci_brcm_hc_driver, + &pdev->dev, dev_name(&pdev->dev)); + if (!hcd) + return -ENOMEM; + + platform_set_drvdata(pdev, hcd); + priv = hcd_to_ehci_priv(hcd); + + priv->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(priv->clk)) { + dev_err(&pdev->dev, "Clock not found in Device Tree\n"); + priv->clk = NULL; + } + err = clk_prepare_enable(priv->clk); + if (err) + goto err_hcd; + + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + hcd->regs = devm_ioremap_resource(&pdev->dev, res_mem); + if (IS_ERR(hcd->regs)) { + err = PTR_ERR(hcd->regs); + goto err_clk; + } + hcd->rsrc_start = res_mem->start; + hcd->rsrc_len = resource_size(res_mem); + err = usb_add_hcd(hcd, irq, IRQF_SHARED); + if (err) + goto err_clk; + + device_wakeup_enable(hcd->self.controller); + device_enable_async_suspend(hcd->self.controller); + platform_set_drvdata(pdev, hcd); + + return err; + +err_clk: + clk_disable_unprepare(priv->clk); +err_hcd: + usb_put_hcd(hcd); + + return err; +} + +static int ehci_brcm_remove(struct platform_device *dev) +{ + struct usb_hcd *hcd = platform_get_drvdata(dev); + struct brcm_priv *priv = hcd_to_ehci_priv(hcd); + + usb_remove_hcd(hcd); + clk_disable_unprepare(priv->clk); + usb_put_hcd(hcd); + return 0; +} + +#ifdef CONFIG_PM_SLEEP + +static int ehci_brcm_suspend(struct device *dev) +{ + int ret; + struct usb_hcd *hcd = dev_get_drvdata(dev); + struct brcm_priv *priv = hcd_to_ehci_priv(hcd); + bool do_wakeup = device_may_wakeup(dev); + + ret = ehci_suspend(hcd, do_wakeup); + clk_disable_unprepare(priv->clk); + return ret; +} + +static int ehci_brcm_resume(struct device *dev) +{ + struct usb_hcd *hcd = dev_get_drvdata(dev); + struct ehci_hcd *ehci = hcd_to_ehci(hcd); + struct brcm_priv *priv = hcd_to_ehci_priv(hcd); + int err; + + err = clk_prepare_enable(priv->clk); + if (err) + return err; + /* + * SWLINUX-1705: Avoid OUT packet underflows during high memory + * bus usage + * port_status[0x0f] = Broadcom-proprietary USB_EHCI_INSNREG00 + * @ 0x90 + */ + ehci_writel(ehci, 0x00800040, &ehci->regs->port_status[0x10]); + ehci_writel(ehci, 0x00000001, &ehci->regs->port_status[0x12]); + + ehci_resume(hcd, false); + return 0; +} +#endif /* CONFIG_PM_SLEEP */ + +static SIMPLE_DEV_PM_OPS(ehci_brcm_pm_ops, ehci_brcm_suspend, + ehci_brcm_resume); + +static const struct of_device_id brcm_ehci_of_match[] = { + { .compatible = "brcm,bcm7445-ehci", }, + {} +}; + +static struct platform_driver ehci_brcm_driver = { + .probe = ehci_brcm_probe, + .remove = ehci_brcm_remove, + .shutdown = usb_hcd_platform_shutdown, + .driver = { + .owner = THIS_MODULE, + .name = "ehci-brcm", + .pm = &ehci_brcm_pm_ops, + .of_match_table = brcm_ehci_of_match, + } +}; + +static int __init ehci_brcm_init(void) +{ + if (usb_disabled()) + return -ENODEV; + + pr_info("%s: " BRCM_DRIVER_DESC "\n", brcm_hcd_name); + + ehci_init_driver(&ehci_brcm_hc_driver, &brcm_overrides); + return platform_driver_register(&ehci_brcm_driver); +} +module_init(ehci_brcm_init); + +static void __exit ehci_brcm_exit(void) +{ + platform_driver_unregister(&ehci_brcm_driver); +} +module_exit(ehci_brcm_exit); + +MODULE_ALIAS("platform:ehci-brcm"); +MODULE_DESCRIPTION(BRCM_DRIVER_DESC); +MODULE_AUTHOR("Al Cooper"); +MODULE_LICENSE("GPL"); From patchwork Fri Nov 9 14:02:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 10676023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07EA313AD for ; Fri, 9 Nov 2018 14:11:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA6702E3D2 for ; Fri, 9 Nov 2018 14:11:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD6E32E4B0; Fri, 9 Nov 2018 14:11:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D3D82E3D2 for ; Fri, 9 Nov 2018 14:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728785AbeKIXwX (ORCPT ); Fri, 9 Nov 2018 18:52:23 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:41130 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728755AbeKIXwX (ORCPT ); Fri, 9 Nov 2018 18:52:23 -0500 Received: by mail-yw1-f65.google.com with SMTP id c126-v6so1651547ywd.8; Fri, 09 Nov 2018 06:11:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=efu/UKASP4+7G9ySkzD91Wo0xkjeVSO+tKS011qcDmE=; b=D+1O1HQHVbCk5kBHeFAK1F5IltYwl95BWJiTAZEwaj9+EjBZfnev5tQpnlJjZcEsjf UVb2lODWVSlFYvFuj7zssWIoQehXlHnEU7iqjaw75wWjYMDHiCSt63xqGhW3MF8WoF2Q erb+1uKYbjJwp3sXhy1OQQKNSTIdJAre9sZRz0Z2VsM3/MCNUSVD+EQus7fCc+n+oLXw KjjmsURsuXUup/btcHkPLHBM+V9PZtKa1Tu085tum9jZUBTYwIzcf3pkTvQNCf2X/lHE rQN5tORl4+iKD0hA3ExU5NtW3+9DDmmd+8OF9QQYMCHoe1cPbl69Uvx1U1VmlAL6n0db yDyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=efu/UKASP4+7G9ySkzD91Wo0xkjeVSO+tKS011qcDmE=; b=X+mkTDGuW3w187OBPNkVV6HcYy6G93CsjSERU4H440LW9GclYwUEU+UvUa5sYAfzBL VV6pGLaBGE4OypF0Y6yjLv3rT81w/uZk9wkAgZWyaWKjl7/e323hZWGU/nW+w2zlpGrR JL5q1rAdVcP5Ciz5MFYkggQiMgvDGWwDgG4Ee/cjh1EXdQcuvUE/5kwAbhCNzuoD90fL 5k3AGSbDyMLRmJ6kd6zP8uCNRgqvowWitPC4N69iCyvIkRBuKBy6tI3H8lPdQbVKoLEE 4JIWM6o+uxbC/8TDQqE1M9TqGCMLFa4KbzDMCbv0qh5o3Jft4jgLFxyUWa31i6NXORrk I9Jw== X-Gm-Message-State: AGRZ1gKyrhHOweOmE+vEmwjQGEtpCP27bMt8FR7wdxGyd0vUysJlQHQ/ pOayf9E2gP5OPsWJwJ+MKTWqlsV2cuA= X-Google-Smtp-Source: AJdET5diqsRhOAgj/KwFl7hVBnfXZZi7NKfjh0NViKBnaVSTl7eU08BWNbTO2AxvO8uorCJaZ6x2Hg== X-Received: by 2002:a81:9401:: with SMTP id l1-v6mr8482866ywg.2.1541772696505; Fri, 09 Nov 2018 06:11:36 -0800 (PST) Received: from stbsrv-and-3.and.broadcom.com ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id c6-v6sm7301965ywh.34.2018.11.09.06.11.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 06:11:36 -0800 (PST) From: Al Cooper To: linux-kernel@vger.kernel.org Cc: Al Cooper , Alan Stern , Alban Bedel , Alex Elder , Andrew Morton , Arnd Bergmann , Avi Fishman , bcm-kernel-feedback-list@broadcom.com, Bjorn Andersson , Chunfeng Yun , "David S. Miller" , devicetree@vger.kernel.org, Dmitry Osipenko , Greg Kroah-Hartman , "Gustavo A. R. Silva" , Hans de Goede , James Hogan , Johan Hovold , Kees Cook , linux-usb@vger.kernel.org, Lu Baolu , Mark Rutland , Martin Blumenstingl , Mathias Nyman , Mathias Nyman , Mauro Carvalho Chehab , Rishabh Bhatnagar , Rob Herring , Roger Quadros Subject: [PATCH V4 5/5] usb: host: Add ability to build new Broadcom STB USB drivers Date: Fri, 9 Nov 2018 09:02:00 -0500 Message-Id: <1541772120-40394-6-git-send-email-alcooperx@gmail.com> X-Mailer: git-send-email 1.9.0.138.g2de3478 In-Reply-To: <1541772120-40394-1-git-send-email-alcooperx@gmail.com> References: <1541772120-40394-1-git-send-email-alcooperx@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add the build system changes needed to get the Broadcom STB XHCI, EHCI and OHCI functionality working. The link order for XHCI was changed in the Makefile because of the way STB XHCI, EHCI and OHCI controllers share a port which requires that the XHCI driver be initialized first. Also update MAINTAINERS. Signed-off-by: Al Cooper --- MAINTAINERS | 9 +++++++++ arch/arm/configs/multi_v7_defconfig | 1 + arch/arm64/configs/defconfig | 1 + drivers/usb/host/Kconfig | 26 ++++++++++++++++++++++++++ drivers/usb/host/Makefile | 18 ++++++++++++------ 5 files changed, 49 insertions(+), 6 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 2f3eba4484aa..932fcc6f8ff5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2998,6 +2998,15 @@ S: Supported F: drivers/i2c/busses/i2c-brcmstb.c F: Documentation/devicetree/bindings/i2c/i2c-brcmstb.txt +BROADCOM BRCMSTB USB XHCI, EHCI and OHCI DRIVERS +M: Al Cooper +L: linux-usb@vger.kernel.org +L: bcm-kernel-feedback-list@broadcom.com +S: Maintained +F: drivers/usb/host/ehci-brcm.* +F: drivers/usb/host/xhci-brcm.* +F: Documentation/devicetree/bindings/usb/brcm,bcm7445-*.txt + BROADCOM BRCMSTB USB2 and USB3 PHY DRIVER M: Al Cooper L: linux-kernel@vger.kernel.org diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig index 63af6234c1b6..64ca0edb43ed 100644 --- a/arch/arm/configs/multi_v7_defconfig +++ b/arch/arm/configs/multi_v7_defconfig @@ -726,6 +726,7 @@ CONFIG_USB_CHIPIDEA_UDC=y CONFIG_USB_CHIPIDEA_HOST=y CONFIG_USB_ISP1760=y CONFIG_USB_HSIC_USB3503=y +CONFIG_USB_BRCM=y CONFIG_AB8500_USB=y CONFIG_KEYSTONE_USB_PHY=m CONFIG_NOP_USB_XCEIV=m diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index c9a57d11330b..89637256e7bf 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -520,6 +520,7 @@ CONFIG_USB_GADGET=y CONFIG_USB_RENESAS_USBHS_UDC=m CONFIG_USB_RENESAS_USB3=m CONFIG_USB_ULPI_BUS=y +CONFIG_USB_BRCM=y CONFIG_MMC=y CONFIG_MMC_BLOCK_MINORS=32 CONFIG_MMC_ARMMMCI=y diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 16758b12a5e9..2d0b3060ad05 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -96,6 +96,32 @@ config USB_XHCI_TEGRA endif # USB_XHCI_HCD +config USB_OHCI_BRCM + tristate + +config USB_EHCI_BRCM + tristate + +config USB_XHCI_BRCM + tristate + +config BRCM_USB_PHY + tristate + +config USB_BRCM + tristate "Broadcom STB USB support" + depends on ARCH_BRCMSTB || COMPILE_TEST + select USB_OHCI_HCD_PLATFORM if USB_OHCI_HCD + select USB_EHCI_BRCM if USB_EHCI_HCD + select USB_XHCI_BRCM if USB_XHCI_HCD + select USB_XHCI_PLATFORM if USB_XHCI_HCD + help + Say Y to enable support for XHCI, EHCI and OHCI host controllers + found in Broadcom STB SoC's. + + Disabling this will keep the controllers and corresponding + PHYs powered down. + config USB_EHCI_HCD tristate "EHCI HCD (USB 2.0) support" depends on HAS_DMA && HAS_IOMEM diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 84514f71ae44..9bdd64b710ee 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -31,6 +31,10 @@ ifneq ($(CONFIG_USB_XHCI_RCAR), ) xhci-plat-hcd-y += xhci-rcar.o endif +ifneq ($(CONFIG_USB_XHCI_BRCM), ) + xhci-plat-hcd-y += xhci-brcm.o +endif + ifneq ($(CONFIG_DEBUG_FS),) xhci-hcd-y += xhci-debugfs.o endif @@ -39,6 +43,13 @@ obj-$(CONFIG_USB_WHCI_HCD) += whci/ obj-$(CONFIG_USB_PCI) += pci-quirks.o +obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o +obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o +obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o +obj-$(CONFIG_USB_XHCI_HISTB) += xhci-histb.o +obj-$(CONFIG_USB_XHCI_MTK) += xhci-mtk.o +obj-$(CONFIG_USB_XHCI_TEGRA) += xhci-tegra.o + obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o obj-$(CONFIG_USB_EHCI_HCD_PLATFORM) += ehci-platform.o @@ -52,6 +63,7 @@ obj-$(CONFIG_USB_EHCI_EXYNOS) += ehci-exynos.o obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o obj-$(CONFIG_USB_EHCI_TEGRA) += ehci-tegra.o obj-$(CONFIG_USB_W90X900_EHCI) += ehci-w90x900.o +obj-$(CONFIG_USB_EHCI_BRCM) += ehci-brcm.o obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o @@ -72,12 +84,6 @@ obj-$(CONFIG_USB_OHCI_HCD_DAVINCI) += ohci-da8xx.o obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o obj-$(CONFIG_USB_FHCI_HCD) += fhci.o -obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o -obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o -obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o -obj-$(CONFIG_USB_XHCI_HISTB) += xhci-histb.o -obj-$(CONFIG_USB_XHCI_MTK) += xhci-mtk.o -obj-$(CONFIG_USB_XHCI_TEGRA) += xhci-tegra.o obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o