From patchwork Wed Apr 29 17:31:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11518027 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9EB192A for ; Wed, 29 Apr 2020 17:31:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFAC0208FE for ; Wed, 29 Apr 2020 17:31:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iGmDqbcC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727042AbgD2Rbh (ORCPT ); Wed, 29 Apr 2020 13:31:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726456AbgD2Rbg (ORCPT ); Wed, 29 Apr 2020 13:31:36 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02D39C03C1AE; Wed, 29 Apr 2020 10:31:36 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id g13so3527957wrb.8; Wed, 29 Apr 2020 10:31:35 -0700 (PDT) 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=hQqyiz3VgaSkn1orBkc5cYQMmcAyasI8rZi9b6SsAs4=; b=iGmDqbcCdUM4/oWQteb7EnZKNc4+48gf8xUxyYVGo3TnmH2aD0JS4wqeYNBziFwmwz GS5HInIahI7uiczakMz9KITiJdoGCRjSbUXSGqxWKOcFYhkHJAtytjDrMoS0OeF1YrKE A/WHmSmYNt6mPfO+tVxTO3GyCbYed9RJ+6quGhTNegERcyMzmfbmX3tbshkusTJY9mXB 1P7K2bIllGcy1fBzG5RRPKVf1pSlhtWSgSvXwnuzE/t1QOruMG2KDphEexc+EmnberTR FQF0JqY1iD069jekWxSp5jiXGCJjz85Pj5O0urydo/5ot8JWbAirQWvqYAgDJGaqzcea +fcA== 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=hQqyiz3VgaSkn1orBkc5cYQMmcAyasI8rZi9b6SsAs4=; b=Atyl8noxp6jWPhQbTJ5RX54VHEoTAMe2KTd7yW8W5KPjg3Uq3+e1SJlfE7aeBcbBta 5lZ1oXKuX/Sfz9SQyuY12k+/DBOKfcL45PwZ72b8Zgz6cNHqasOF1V98nW7RLH5eKD0x NYcTylyCqkoLMarDh1b2VXSVhJzGjnmjGa/+nr6I7+mDFbli9xCg9SPg5sOn2S8oV80K i81eczm/WurTEl5cnLDO/sTxy1GdJVlnvjWBjkCMN3IWmM1L4DV9xwL1vUSSwHH12nfe Ine7mfan63lieYgRL71ICX2X7f7270ORnWOuS93vNSszEaLzYCVSSqXBkfM+49X3pF0F tSiA== X-Gm-Message-State: AGi0PuaIZBWjJEeI1tL1bGGzyVqtmm5evNUHguMXeSFSmcKdtN1XyT6m mHiGwodh/SKccwYCtlyKYkG7XJoxrs8= X-Google-Smtp-Source: APiQypLAksD45L/G/YUyVOhmOPxjz9zEhRrYXc0wmfc6UxxJMMdmNiSfKO7B8XCmZAcz3kNCXV8dGQ== X-Received: by 2002:adf:f58e:: with SMTP id f14mr39298005wro.79.1588181494446; Wed, 29 Apr 2020 10:31:34 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id j11sm31177182wrr.62.2020.04.29.10.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 10:31:33 -0700 (PDT) From: Al Cooper To: linux-kernel@vger.kernel.org Cc: Al Cooper , Alan Stern , bcm-kernel-feedback-list@broadcom.com, devicetree@vger.kernel.org, Greg Kroah-Hartman , Krzysztof Kozlowski , linux-usb@vger.kernel.org, Mathias Nyman , Rob Herring , Yoshihiro Shimoda , Andy Shevchenko Subject: [PATCH v4 1/4] dt-bindings: Add Broadcom STB USB support Date: Wed, 29 Apr 2020 13:31:09 -0400 Message-Id: <20200429173112.38366-2-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200429173112.38366-1-alcooperx@gmail.com> References: <20200429173112.38366-1-alcooperx@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add DT bindings for Broadcom STB USB EHCI and XHCI drivers. NOTE: The OHCI driver is not included because it uses the generic platform driver. Signed-off-by: Al Cooper --- .../bindings/usb/brcm,bcm7445-ehci.yaml | 60 +++++++++++++++++++ .../devicetree/bindings/usb/usb-xhci.txt | 1 + 2 files changed, 61 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.yaml diff --git a/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.yaml b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.yaml new file mode 100644 index 000000000000..7c67f7dd7a67 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.yaml @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/brcm,bcm7445-ehci.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom STB USB EHCI Controller Device Tree Bindings + +allOf: + - $ref: "usb-hcd.yaml" + +maintainers: + - Al Cooper + +properties: + compatible: + contains: + const: brcm,bcm7445-ehci + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + description: Clock specifier for the EHCI clock + + clock-names: + const: sw_usb + + phys: + maxItems: 1 + + phy-names: + const: usbphy + +required: + - compatible + - reg + - interrupts + - phys + - clocks + +additionalProperties: false + +examples: + - | + usb@f0b00300 { + compatible = "brcm,bcm7445-ehci"; + reg = <0xf0b00300 0xa8>; + interrupts = <0x0 0x5a 0x0>; + phys = <&usbphy_0 0x0>; + phy-names = "usbphy"; + clocks = <&usb20>; + clock-names = "sw_usb"; + }; + +... diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt index dc025f126d71..23e89d798b1b 100644 --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt @@ -24,6 +24,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 with XHCI - "xhci-platform" (deprecated) When compatible with the generic version, nodes must list the From patchwork Wed Apr 29 17:31:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11518021 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DAD4292A for ; Wed, 29 Apr 2020 17:31:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0864214D8 for ; Wed, 29 Apr 2020 17:31:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fp7tzS1e" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbgD2Rbk (ORCPT ); Wed, 29 Apr 2020 13:31:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726456AbgD2Rbi (ORCPT ); Wed, 29 Apr 2020 13:31:38 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 580CCC03C1AE; Wed, 29 Apr 2020 10:31:38 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id x17so3545221wrt.5; Wed, 29 Apr 2020 10:31:38 -0700 (PDT) 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=vkQbZ0OEnEU7UUbpzBp0+WjmUbWo04Z45g1QFzRKmTk=; b=fp7tzS1ege8TEIXp3sxQeN/AA4eyLe6DeCJjyrJ8peIFf2ViCjzTDKtvTiLo9rckjB bWMJw3IZxOK6hInW0ote2hvJKyKjbAD93mTYtKrB5TEJiKfFamzc3FTsadbc5/ssSOuC 8rDfbJgnXxXecRfvQem8iGSfVU36ZULDzvFED8pNF/5BpbFln1JF/W3Rr/0ea3jXJMsC tqyPWUHKMZA85+kpcexixQpiI6ZhrP57FcMYAK23oFM/4/HExUxKGuQUW2FOaDt190tw /eqAj8acGVDT7GKO1vFGKxumnRs8dg2dxejo2/CViTqufBhxMn/qDjAHsdrKljXisA2j rvXg== 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=vkQbZ0OEnEU7UUbpzBp0+WjmUbWo04Z45g1QFzRKmTk=; b=S+0D6DRq0Wi+AuAx7IvPCc6iksUGVe32sLToqiV1IEbzXbTJNzuL4DhePWfEiIg4/6 AXbpqZZDLfVzg/kt8fwRkdbmmrPgIJNGK/61YZsW89ZVTOAreQ0SYe1gfUzLz1eWcYtm Oq+pG5Z3CQeUx60w0OYyOR38hxCXLge2It0gDuLteDFIbdIcGoMdDmWGGtfVvgKjdjte /dAL7KVAox4b75+i9vUeluLrimMVyabPUt/DjvZWy2K9flpOATCseUsObOnILkWXQntg 8oKD7b3ngV/XXomJinikiyMBmVZbewN+iF3u5YhowtEAxwYzwEU7KdiMip2AeczIWiSL Ynag== X-Gm-Message-State: AGi0PuZeVzeaTPDTlziYnxXxN3xw2MkWvKNdsUKd5gp4BP2rVrvhhzlf bBryWfffCCT2Kb5CyBajIifHgBAGww8= X-Google-Smtp-Source: APiQypLt2LUmDoOaSoNkbDvsiSQvUo7WW6tWdwgxgNXSoRRT47yrfneK9/wa4tVhCUp6nFnxmaUrBg== X-Received: by 2002:adf:ed0e:: with SMTP id a14mr40073744wro.400.1588181496636; Wed, 29 Apr 2020 10:31:36 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id j11sm31177182wrr.62.2020.04.29.10.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 10:31:36 -0700 (PDT) From: Al Cooper To: linux-kernel@vger.kernel.org Cc: Al Cooper , Alan Stern , bcm-kernel-feedback-list@broadcom.com, devicetree@vger.kernel.org, Greg Kroah-Hartman , Krzysztof Kozlowski , linux-usb@vger.kernel.org, Mathias Nyman , Rob Herring , Yoshihiro Shimoda , Andy Shevchenko Subject: [PATCH v4 2/4] usb: xhci: xhci-plat: Add support for Broadcom STB SoC's Date: Wed, 29 Apr 2020 13:31:10 -0400 Message-Id: <20200429173112.38366-3-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200429173112.38366-1-alcooperx@gmail.com> References: <20200429173112.38366-1-alcooperx@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add support for Broadcom STB SoC's to the xhci platform driver Signed-off-by: Al Cooper Acked-by: Mathias Nyman --- drivers/usb/host/xhci-plat.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 1d4f6f85f0fe..44406d0eb317 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -112,6 +112,10 @@ static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen3 = { SET_XHCI_PLAT_PRIV_FOR_RCAR(XHCI_RCAR_FIRMWARE_NAME_V3) }; +static const struct xhci_plat_priv xhci_plat_brcm = { + .quirks = XHCI_RESET_ON_RESUME, +}; + static const struct of_device_id usb_xhci_of_match[] = { { .compatible = "generic-xhci", @@ -147,6 +151,12 @@ static const struct of_device_id usb_xhci_of_match[] = { }, { .compatible = "renesas,rcar-gen3-xhci", .data = &xhci_plat_renesas_rcar_gen3, + }, { + .compatible = "brcm,xhci-brcm-v2", + .data = &xhci_plat_brcm, + }, { + .compatible = "brcm,bcm7445-xhci", + .data = &xhci_plat_brcm, }, {}, }; From patchwork Wed Apr 29 17:31:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11518025 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95AAE92A for ; Wed, 29 Apr 2020 17:31:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73045208FE for ; Wed, 29 Apr 2020 17:31:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N4tAEtnG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727119AbgD2Rbm (ORCPT ); Wed, 29 Apr 2020 13:31:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726456AbgD2Rbl (ORCPT ); Wed, 29 Apr 2020 13:31:41 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8CDCC03C1AE; Wed, 29 Apr 2020 10:31:40 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id d15so3564614wrx.3; Wed, 29 Apr 2020 10:31:40 -0700 (PDT) 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=1bAKWOlSkMDu/tfAy0DoRT7Hrn8w1RS+eAxVrpX7cog=; b=N4tAEtnGop80HcsUviJolsX3Jl5ojsTj8Apf1VUIjYF7IbBSIM7NVK2V72ZhJI2dtY mgCvNisAmhXsqvgeil06hibPoqFQjS5oSl8tqopDu60ENpGqOHUcvaxoGlgtsDifKf4i WFOgTsjslGlUbDcbWi3u2IzlkXJ4+mOjINvKtQL/pdKrMmfaVgEV2YQ3cAxtB0qCqRpS Q0HVblP3jPe6t/MQ19QwYZOD0+XwTItRqSrQnbeyynt3nuQVw9rbU0l0MONsrIIuy4gW UvKfTrHnnv6FRM40OxxaX6x8+oghEovnsWsZn0ZMI5HUdtsqXjXSpFcyXA4KPNohXYLy wlbg== 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=1bAKWOlSkMDu/tfAy0DoRT7Hrn8w1RS+eAxVrpX7cog=; b=WCGlhaOAR4YUDBV33OC4wDxWcnmA44nK3rTmwMwJqzzPhueusRQr1zNfxvXB7vdcH3 /Ac66ieTy4WcKRnBbqlgakOkqCAjjA+aHWv8Kvk0hHE+9JHJgg0Gv4ZqibcG6nUJW6aU CqvWRyEiXKV9K9tZz+NfaOfVx7HOfbx3zRX5NqwvVoOPHgsZRsBxYqjYajn3q4KSX2Nz q76FzPe/GgtIJ2bdlTMqnOX52VFn74IqK6B2D+qpybaQ92hBy/iGQvqIOnObNwUBWm9o OerPeqB0v9eaxntszeI50LQgAnm9ZLp4AeprLf5zCQudA2Aiq95G9O6slu2VCl/0a5aG 1LfA== X-Gm-Message-State: AGi0PuZYa33B3Vxm2AYGEMPCJzEYmnZP3/uONxoDhBUm0k9aaD3IaWPl fKVaD/adcHmnP4qQgGLy2Ev4/8uYnek= X-Google-Smtp-Source: APiQypIMjWCds3CmFIrPmVkaeUVBbo7WfxiKrlLt6NfVcBvmVOOKa6MWL64/E/lBw10TVujampS8tg== X-Received: by 2002:adf:e704:: with SMTP id c4mr39023484wrm.181.1588181498918; Wed, 29 Apr 2020 10:31:38 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id j11sm31177182wrr.62.2020.04.29.10.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 10:31:38 -0700 (PDT) From: Al Cooper To: linux-kernel@vger.kernel.org Cc: Al Cooper , Alan Stern , bcm-kernel-feedback-list@broadcom.com, devicetree@vger.kernel.org, Greg Kroah-Hartman , Krzysztof Kozlowski , linux-usb@vger.kernel.org, Mathias Nyman , Rob Herring , Yoshihiro Shimoda , Andy Shevchenko Subject: [PATCH v4 3/4] usb: ehci: Add new EHCI driver for Broadcom STB SoC's Date: Wed, 29 Apr 2020 13:31:11 -0400 Message-Id: <20200429173112.38366-4-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200429173112.38366-1-alcooperx@gmail.com> References: <20200429173112.38366-1-alcooperx@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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..04c18fe721a5 --- /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 "ehci.h" + +#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) +{ + u32 frame_idx = ehci_readl(ehci, &ehci->regs->frame_index); + u32 val; + int res; + + /* Wait for next microframe (every 125 usecs) */ + res = readl_relaxed_poll_timeout(&ehci->regs->frame_index, val, + val != frame_idx, 1, 130); + if (res) + dev_err(ehci_to_hcd(ehci)->self.controller, + "Error waiting for SOF\n"); + 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 device *dev = &pdev->dev; + struct resource *res_mem; + struct brcm_priv *priv; + struct usb_hcd *hcd; + int irq; + int err; + + if (usb_disabled()) + return -ENODEV; + + err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); + if (err) + return err; + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + + /* Hook the hub control routine to work around a bug */ + if (!org_hub_control) + 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, dev, dev_name(dev)); + if (!hcd) + return -ENOMEM; + + platform_set_drvdata(pdev, hcd); + priv = hcd_to_ehci_priv(hcd); + + priv->clk = devm_clk_get_optional(dev, NULL); + if (IS_ERR(priv->clk)) { + err = PTR_ERR(priv->clk); + goto err_hcd; + } + + 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(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 0; + +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; +} + +static int __maybe_unused 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); + if (ret) + return ret; + clk_disable_unprepare(priv->clk); + return 0; +} + +static int __maybe_unused 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; +} + +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,ehci-brcm-v2", }, + { .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 = { + .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; + + 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("EHCI Broadcom STB driver"); +MODULE_AUTHOR("Al Cooper"); +MODULE_LICENSE("GPL"); From patchwork Wed Apr 29 17:31:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 11518023 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E65BE92C for ; Wed, 29 Apr 2020 17:31:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA28B214AF for ; Wed, 29 Apr 2020 17:31:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g8iStKx7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727773AbgD2Rbn (ORCPT ); Wed, 29 Apr 2020 13:31:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727124AbgD2Rbn (ORCPT ); Wed, 29 Apr 2020 13:31:43 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3CB1C03C1AE; Wed, 29 Apr 2020 10:31:42 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id r26so2944923wmh.0; Wed, 29 Apr 2020 10:31:42 -0700 (PDT) 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=lpRZMrHTzTW8z6tlIKgNxL8ccVzt5z7E+tVpzahVStY=; b=g8iStKx7j3a48hQ9diCtkrfWscJCCjYi7R66T+6R1drJJReIC6vDifbT2xfmsQ2KV0 aVGYa6wkdwF4YvznqekDAvkGExxvQ31gzgiaQ2HLsBPuNTY0xzu2x502zVSTB/xgmtG7 YbqioJ510L4TNH/ZM8bK8O+gjwvDp/xCDSPt0PkbadtJKu3brwPlSD9ReyOx8AXzbitg TUkbFF7ps0QaiGzGmrGTxCz+f8SE/Lzo8DqCxDDPWMVYdU61aNZfFRlkODzjtAzqG2Je OJo2MdQz01EceTYw1uC5twm15UOqQWXuAkNohFwRwZLf5AIN6CioZFwr+OTAf+BNTiJa h25Q== 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=lpRZMrHTzTW8z6tlIKgNxL8ccVzt5z7E+tVpzahVStY=; b=YvsDZ+P73StGYsae1CJG8etUXdhG9vF0zCK2kJRUa/bkRT6T3lGgvsq+4o1W9EOxJZ ilxOUwW9AjQc88en7ssr0lcNwxjPPscJP4N6/QDnaIvg+IqrS2Gjc1pQ2V+Zi+lWpBRh FWZDA5FC7Jk2ldem9dE2fyJJZ9KajAETlXVLZkwi/Vb/oqcrpYYFRtLygu7KQShfPGUu lwJ9HfcHhk1U20IdOikCwLpG9omb5pGP+l7GC7HdmZnIHHiY8mfhHPu/DD+8+upKMXD4 ZL/ET+yinAnVkjAR2A+4buAk0rLnTNLmyxM1Mm0ylo6wwt1rlK2/k+MEnPykR9itJqfm TEdA== X-Gm-Message-State: AGi0Pua2gSvWfKkykqzoaKhChCtQdV3tFL8hI7JuIsWVPRFSk8ciTPKA iA76BDI+DaeficWvSaFjLhKw404K/uY= X-Google-Smtp-Source: APiQypLH8sXqeobIc6UxTjqBMumvmLNAP3xqvcVTHT/bEOZ1FL08GJZzVtJ+rSFwNZ/4eU4l+oaZxA== X-Received: by 2002:a1c:e903:: with SMTP id q3mr4300005wmc.76.1588181501178; Wed, 29 Apr 2020 10:31:41 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id j11sm31177182wrr.62.2020.04.29.10.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 10:31:40 -0700 (PDT) From: Al Cooper To: linux-kernel@vger.kernel.org Cc: Al Cooper , Alan Stern , bcm-kernel-feedback-list@broadcom.com, devicetree@vger.kernel.org, Greg Kroah-Hartman , Krzysztof Kozlowski , linux-usb@vger.kernel.org, Mathias Nyman , Rob Herring , Yoshihiro Shimoda , Andy Shevchenko Subject: [PATCH v4 4/4] usb: host: Add ability to build new Broadcom STB USB drivers Date: Wed, 29 Apr 2020 13:31:12 -0400 Message-Id: <20200429173112.38366-5-alcooperx@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200429173112.38366-1-alcooperx@gmail.com> References: <20200429173112.38366-1-alcooperx@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add the build system changes needed to get the Broadcom STB XHCI, EHCI and OHCI functionality working. The OHCI support does not require anything unique to Broadcom so the standard ohci-platform driver is being used. 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 | 8 ++++++++ drivers/usb/host/Kconfig | 16 ++++++++++++++++ drivers/usb/host/Makefile | 16 ++++++++++------ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 26f281d9f32a..6147ed78d212 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3481,6 +3481,14 @@ S: Supported F: Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml F: drivers/i2c/busses/i2c-brcmstb.c +BROADCOM BRCMSTB USB EHCI DRIVER +M: Al Cooper +L: linux-usb@vger.kernel.org +L: bcm-kernel-feedback-list@broadcom.com +S: Maintained +F: Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.yaml +F: drivers/usb/host/ehci-brcm.* + BROADCOM BRCMSTB USB2 and USB3 PHY DRIVER M: Al Cooper L: linux-kernel@vger.kernel.org diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 55bdfdf11e4c..7d58fd66e412 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -97,6 +97,22 @@ config USB_XHCI_TEGRA endif # USB_XHCI_HCD +config USB_EHCI_BRCMSTB + tristate + +config USB_BRCMSTB + tristate "Broadcom STB USB support" + depends on (ARCH_BRCMSTB && PHY_BRCM_USB) || COMPILE_TEST + select USB_OHCI_HCD_PLATFORM if USB_OHCI_HCD + select USB_EHCI_BRCMSTB if USB_EHCI_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 b191361257cc..85fa6ace552a 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -37,6 +37,15 @@ endif obj-$(CONFIG_USB_PCI) += pci-quirks.o +# NOTE: BRCMSTB systems require that xhci driver be linked before the +# ehci/ohci drivers. +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 @@ -49,6 +58,7 @@ obj-$(CONFIG_USB_EHCI_HCD_STI) += ehci-st.o 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_EHCI_BRCMSTB) += ehci-brcm.o obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o @@ -69,12 +79,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