From patchwork Fri Apr 21 20:40:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 97926 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp496684qgf; Fri, 21 Apr 2017 13:41:06 -0700 (PDT) X-Received: by 10.84.178.101 with SMTP id y92mr18089483plb.171.1492807266780; Fri, 21 Apr 2017 13:41:06 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s17si11190563pgn.118.2017.04.21.13.41.06; Fri, 21 Apr 2017 13:41:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1040625AbdDUUlF (ORCPT + 4 others); Fri, 21 Apr 2017 16:41:05 -0400 Received: from mail-lf0-f46.google.com ([209.85.215.46]:33538 "EHLO mail-lf0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1036998AbdDUUlD (ORCPT ); Fri, 21 Apr 2017 16:41:03 -0400 Received: by mail-lf0-f46.google.com with SMTP id 88so50383898lfr.0 for ; Fri, 21 Apr 2017 13:41:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=DdPNjnfPn7I7lJkW1yZhi7h0PnW7VRAkM9raRB+3HG0=; b=X8n1p8auZD2TxYJJ3FLmyNCUDR0AWCoeBomqWiaz21/fAFPMKePUx4X7VZ81H52N9d Dc+Ensp6uhRDc2DV5YA2is7NzHyE96NdOdHPxZb1CqJVBdnqVS/kq5DB/NGRJOPbmMZA zsDioDW4F+OqRLKgZgGhcXRWZ2IdXStAXz74c= 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; bh=DdPNjnfPn7I7lJkW1yZhi7h0PnW7VRAkM9raRB+3HG0=; b=hf+mSyPiBq1uHNautUvuN9sFSBxLDnuTT1WuM3o9EfKVHOpZO0k9g3BBmixNHSbdN3 oy6AwbKeQy8oShXlN/+vMPkMxLSFncZglLcIpaEI7LVwXnzYsdgzEAuiJc/mZq1J4YGN 1xa3Iq4odDUf5UpoiGUCqsBuzWoOXydHVmvAb8doXfSpEazzcKWheXemW0VQROGEjpA+ SYDq21wo9x2u3k/2xl52B5v6+1dzNoT1IcD+EAheATX4KMpy6IuLCQncQi+hBIIVoTK1 00t2z3BK1fIUDGv7NxaH4s+/QeD1RKiMZGaoyExQFN/EnhUi0ioG53Rfq+xK3wUaSb8K pt1w== X-Gm-Message-State: AN3rC/7BV9SLcg6QQWDOSj3MsatBKUj1lC18svbzcJuQeB+LfpWOTE4a Azif9b3vwqAAx1iV X-Received: by 10.46.9.82 with SMTP id 79mr5763238ljj.89.1492807262146; Fri, 21 Apr 2017 13:41:02 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-8a7f71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.127.138]) by smtp.gmail.com with ESMTPSA id m191sm1770244lfe.43.2017.04.21.13.41.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2017 13:41:01 -0700 (PDT) From: Linus Walleij To: Hans Ulli Kroll , Florian Fainelli , linux-usb@vger.kernel.org, Greg Kroah-Hartman Cc: Janos Laube , Paulius Zaleckas , openwrt-devel@openwrt.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Linus Walleij Subject: [PATCH 1/5 v3] usb: host: add DT bindings for faraday fotg2 Date: Fri, 21 Apr 2017 22:40:54 +0200 Message-Id: <20170421204058.6206-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Hans Ulli Kroll This adds device tree bindings for the Faraday FOTG2 dual-mode host controller. Cc: devicetree@vger.kernel.org Signed-off-by: Hans Ulli Kroll Signed-off-by: Linus Walleij --- ChangeLog v1->v3: - Change compatible to "faraday,fotg210" as the name of the hardware block. - Add an elaborate SoC-specific compatible string for the Cortina Systems Gemini so that SoC-specific features can be enabled. - Add cortina,gemini-mini-b to indicate a Gemini PHY with a Mini-B adapter connected. - Indicated that the Gemini version can handle "wakeup-source". - Add optional IP block clock. --- .../devicetree/bindings/usb/faraday,fotg210.txt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/faraday,fotg210.txt -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/usb/faraday,fotg210.txt b/Documentation/devicetree/bindings/usb/faraday,fotg210.txt new file mode 100644 index 000000000000..cf06808303e2 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/faraday,fotg210.txt @@ -0,0 +1,35 @@ +Faraday FOTG Host controller + +This OTG-capable USB host controller is found in Cortina Systems +Gemini and other SoC products. + +Required properties: +- compatible: should be one of: + "faraday,fotg210" + "cortina,gemini-usb", "faraday,fotg210" +- reg: should contain one register range i.e. start and length +- interrupts: description of the interrupt line + +Optional properties: +- clocks: should contain the IP block clock +- clock-names: should be "PCLK" for the IP block clock + +Required properties for "cortina,gemini-usb" compatible: +- syscon: a phandle to the system controller to access PHY registers + +Optional properties for "cortina,gemini-usb" compatible: +- cortina,gemini-mini-b: boolean property that indicates that a Mini-B + OTH connector is in use +- wakeup-source: see power/wakeup-source.txt + +Example for Gemini: + +usb@68000000 { + compatible = "cortina,gemini-usb", "faraday,fotg210"; + reg = <0x68000000 0x1000>; + interrupts = <10 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cc 12>; + clock-names = "PCLK"; + syscon = <&syscon>; + wakeup-source; +}; From patchwork Fri Apr 21 20:40:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 97927 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp496717qgf; Fri, 21 Apr 2017 13:41:12 -0700 (PDT) X-Received: by 10.84.143.195 with SMTP id 61mr18216581plz.158.1492807271955; Fri, 21 Apr 2017 13:41:11 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s17si11190563pgn.118.2017.04.21.13.41.11; Fri, 21 Apr 2017 13:41:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161132AbdDUUlK (ORCPT + 4 others); Fri, 21 Apr 2017 16:41:10 -0400 Received: from mail-lf0-f50.google.com ([209.85.215.50]:34774 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1036998AbdDUUlJ (ORCPT ); Fri, 21 Apr 2017 16:41:09 -0400 Received: by mail-lf0-f50.google.com with SMTP id t144so50416713lff.1 for ; Fri, 21 Apr 2017 13:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7ETV9bHdJJuNfXQGQ8l40aQzMZnlGCGJcXLR6WKcvig=; b=DTAvqZqulTQXuE3Ih4oBdz1G/XDhGuxVNpuroOKM+/cVTzLsK17ApyxMh/Yq4ETlD+ PdGizAe7kMSWmVlUTWT0c2VdxDzk71erADHETy+OTxGyPaOgCJWFs0KcSm9UfHNUgDMj zMjAGXzLlH4TzyPz3lx46t77VYkkEOvLm9Km4= 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=7ETV9bHdJJuNfXQGQ8l40aQzMZnlGCGJcXLR6WKcvig=; b=LE9RDTEtlYXCbHisSqcs5rXQmNN0zQfxrKPx+hmISITnhyEDKFZARaMksUt51DVgq/ /kDq8xlogoJER3Tgh7phdXtOeJxi/larBn50QsWcYcY5NMsEWZ0J97nqeUFpCEsZJ2N9 3I5gZaJsohSAV4MC4/vn9PXKCaYarpKnkPgSB/UtUjfA48TdAv6TQKCQlTB760E/mu36 RAnWY7uF3eAiJy4eoGAWT1evSfzRpHOmYffGrsLLaeH3lJBJrrN4WOmhBo0h2mtyzdan J/miSxht4/Wq+I2LPdyDbUUiO1fF6LXHrjYWi3c23rhb1x/zuBW/iSn+LEZRdQFSqSan owJQ== X-Gm-Message-State: AN3rC/5cbH/uDH7cVfXpY2rttS7Y29z8mJTi5eZbSxBM7xGHdQEDcxb0 V+dUxtcv92x/NBzw X-Received: by 10.46.82.137 with SMTP id n9mr5593562lje.0.1492807267885; Fri, 21 Apr 2017 13:41:07 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-8a7f71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.127.138]) by smtp.gmail.com with ESMTPSA id m191sm1770244lfe.43.2017.04.21.13.41.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2017 13:41:06 -0700 (PDT) From: Linus Walleij To: Hans Ulli Kroll , Florian Fainelli , linux-usb@vger.kernel.org, Greg Kroah-Hartman Cc: Janos Laube , Paulius Zaleckas , openwrt-devel@openwrt.org, linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 2/5 v3] usb: host: fotg2: add device tree probing Date: Fri, 21 Apr 2017 22:40:55 +0200 Message-Id: <20170421204058.6206-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170421204058.6206-1-linus.walleij@linaro.org> References: <20170421204058.6206-1-linus.walleij@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Hans Ulli Kroll Add device tree probing to the fotg2 driver. Signed-off-by: Hans Ulli Kroll Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Change compatible to "faraday,fotg210" simply. --- drivers/usb/host/fotg210-hcd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c index 1c5b34b74860..c226041101d1 100644 --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c @@ -23,6 +23,7 @@ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include +#include #include #include #include @@ -5600,6 +5601,15 @@ static int fotg210_hcd_probe(struct platform_device *pdev) if (usb_disabled()) return -ENODEV; + /* Right now device-tree probed devices don't get dma_mask set. + * Since shared usb code relies on it, set it here for now. + * Once we have dma capability bindings this can go away. + */ + + retval = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); + if (retval) + goto fail_create_hcd; + pdev->dev.power.power_state = PMSG_ON; res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); @@ -5676,9 +5686,18 @@ static int fotg210_hcd_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_OF +static const struct of_device_id fotg210_of_match[] = { + { .compatible = "faraday,fotg210" }, + {}, +}; +MODULE_DEVICE_TABLE(of, fotg210_of_match); +#endif + static struct platform_driver fotg210_hcd_driver = { .driver = { .name = "fotg210-hcd", + .of_match_table = of_match_ptr(fotg210_of_match), }, .probe = fotg210_hcd_probe, .remove = fotg210_hcd_remove, From patchwork Fri Apr 21 20:40:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 97928 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp496747qgf; Fri, 21 Apr 2017 13:41:16 -0700 (PDT) X-Received: by 10.98.138.150 with SMTP id o22mr14002144pfk.69.1492807276019; Fri, 21 Apr 2017 13:41:16 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s17si11190563pgn.118.2017.04.21.13.41.15; Fri, 21 Apr 2017 13:41:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162481AbdDUUlO (ORCPT + 4 others); Fri, 21 Apr 2017 16:41:14 -0400 Received: from mail-lf0-f48.google.com ([209.85.215.48]:35820 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161246AbdDUUlN (ORCPT ); Fri, 21 Apr 2017 16:41:13 -0400 Received: by mail-lf0-f48.google.com with SMTP id 75so50366922lfs.2 for ; Fri, 21 Apr 2017 13:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2lA1cwgf1fWJiY/gH8H3iwy8o2KPNs8ZeUAEYUDEohU=; b=Zw8opd1Y6RG5gQjoGli1VPERvbgF09PoMNRVRVcU1s83S11VB7/L+Sdc/RK9M6kn2M 6I6duwhFd6SAuCu4OEDruy27QJ7A7EZWBmrNRnO96uFbVTE69Uyut+djYfMfmQo9tPXc +nBgKYkaXI8jdEuSIQDOyqfxgA66kRQew6Shs= 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=2lA1cwgf1fWJiY/gH8H3iwy8o2KPNs8ZeUAEYUDEohU=; b=PQf6GPzRbPba94nQZXkeXM3VYqQiZdVEbvzXBplaj0m2BHcYhLNsL4LO8QNyX0qCzm yebXUK4Y1F7gK253SrDpuCpwDqKDC+ZiTVlvx66ueSTw3xggC8CORbsTN8gduEbJkKyY q1Uw4VB68SRxG7YZJsUyuB3e6NEc+VpKfw5oYSA69cR4Wc2mL34knyuInv83uEYS4wEV WDn8DtCpZG1kalz9UDyZxreLdv4I/FrCMvJ9NaEqWBLEUuFURQfJCS2+ijlaoc99cdib odCxlKaJNQ87PVY+nbaB5L83nRvSaTbms0tKbgzjy3tjkH3BT2GRLR6SktBlV8JJ2neb Fykw== X-Gm-Message-State: AN3rC/7E1H1hfuOzO+m0nkt9CnEV07Xi6SXZ22Vohak8fyuyESCHxiFR ZLH1z4kRjaf9aQVF X-Received: by 10.46.69.213 with SMTP id s204mr5494883lja.71.1492807271764; Fri, 21 Apr 2017 13:41:11 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-8a7f71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.127.138]) by smtp.gmail.com with ESMTPSA id m191sm1770244lfe.43.2017.04.21.13.41.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2017 13:41:10 -0700 (PDT) From: Linus Walleij To: Hans Ulli Kroll , Florian Fainelli , linux-usb@vger.kernel.org, Greg Kroah-Hartman Cc: Janos Laube , Paulius Zaleckas , openwrt-devel@openwrt.org, linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 3/5 v3] usb: host: fotg2: add silicon clock handling Date: Fri, 21 Apr 2017 22:40:56 +0200 Message-Id: <20170421204058.6206-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170421204058.6206-1-linus.walleij@linaro.org> References: <20170421204058.6206-1-linus.walleij@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When used in a system with software-controller silicon clocks, the FOTG210 needs to grab, prepare and enable the clock. This is needed on for example the Cortina Gemini, where the platform will by default gate off the clock unless the peripheral (in this case the USB driver) grabs and enables the clock. Signed-off-by: Linus Walleij --- drivers/usb/host/fotg210-hcd.c | 26 ++++++++++++++++++++++---- drivers/usb/host/fotg210.h | 3 +++ 2 files changed, 25 insertions(+), 4 deletions(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c index c226041101d1..906e42458791 100644 --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -5635,7 +5636,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev) hcd->regs = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(hcd->regs)) { retval = PTR_ERR(hcd->regs); - goto failed; + goto failed_put_hcd; } hcd->rsrc_start = res->start; @@ -5645,22 +5646,35 @@ static int fotg210_hcd_probe(struct platform_device *pdev) fotg210->caps = hcd->regs; + /* It's OK not to supply this clock */ + fotg210->pclk = clk_get(dev, "PCLK"); + if (!IS_ERR(fotg210->pclk)) { + retval = clk_prepare_enable(fotg210->pclk); + if (retval) { + dev_err(dev, "failed to enable PCLK\n"); + goto failed_dis_clk; + } + } + retval = fotg210_setup(hcd); if (retval) - goto failed; + goto failed_dis_clk; fotg210_init(fotg210); retval = usb_add_hcd(hcd, irq, IRQF_SHARED); if (retval) { dev_err(dev, "failed to add hcd with err %d\n", retval); - goto failed; + goto failed_dis_clk; } device_wakeup_enable(hcd->self.controller); return retval; -failed: +failed_dis_clk: + if (!IS_ERR(fotg210->pclk)) + clk_disable_unprepare(fotg210->pclk); +failed_put_hcd: usb_put_hcd(hcd); fail_create_hcd: dev_err(dev, "init %s fail, %d\n", dev_name(dev), retval); @@ -5676,6 +5690,10 @@ static int fotg210_hcd_remove(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct usb_hcd *hcd = dev_get_drvdata(dev); + struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); + + if (!IS_ERR(fotg210->pclk)) + clk_disable_unprepare(fotg210->pclk); if (!hcd) return 0; diff --git a/drivers/usb/host/fotg210.h b/drivers/usb/host/fotg210.h index b5cfa7aeb277..c429efeb2b7e 100644 --- a/drivers/usb/host/fotg210.h +++ b/drivers/usb/host/fotg210.h @@ -181,6 +181,9 @@ struct fotg210_hcd { /* one per controller */ # define COUNT(x) #endif + /* silicon clock */ + struct clk *pclk; + /* debug files */ struct dentry *debug_dir; }; From patchwork Fri Apr 21 20:40:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 97929 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp496769qgf; Fri, 21 Apr 2017 13:41:20 -0700 (PDT) X-Received: by 10.98.3.193 with SMTP id 184mr10643516pfd.145.1492807279943; Fri, 21 Apr 2017 13:41:19 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s17si11190563pgn.118.2017.04.21.13.41.19; Fri, 21 Apr 2017 13:41:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162483AbdDUUlS (ORCPT + 4 others); Fri, 21 Apr 2017 16:41:18 -0400 Received: from mail-lf0-f48.google.com ([209.85.215.48]:33582 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161246AbdDUUlQ (ORCPT ); Fri, 21 Apr 2017 16:41:16 -0400 Received: by mail-lf0-f48.google.com with SMTP id 88so50385756lfr.0 for ; Fri, 21 Apr 2017 13:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I732rPEc1YBEOkZOCnjmOWq9D/bNopL9IZnvEvHWJ8Y=; b=HrzyNvobMDVnCniZexFNV5m9UhSV1kk0TUUt+dEgQe81YJnYzWEhoH6GPukCt21VEm 3gpyfuQJn/F9hz/adN0pg8eP9QGqw2DBpqPB2oHBkVqz5lgU8/sSDY4z3R8ezqkeTDRh NUsHPPCnPxWc84zAgDEFflnrRiOo8Gy/zqib0= 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=I732rPEc1YBEOkZOCnjmOWq9D/bNopL9IZnvEvHWJ8Y=; b=O12KCtPUsSN9o4t/fRtulk3gbSo8wknYuD8ejZADqBcCXjmQY7+8ySGJqhgBDL4LAU rnBiJTPnjH4VN+D6RITAOIeSMOef/42RbbOQSY/Zi58nYUpSfHNLNdtOep5D0BlqPYEn AE8XI8rRGa2v8F2YzN8iXE8jSi6qPRWPgdNrT5DiAJSKGCkzPK6m1wtmquT1SBElBpdX UACuaRW8EL5KksvjnPLIMrfv9mGd7vHpWWlkHov3CzLQXAAtn8dIYhaeD+y20RM/F1qL eXhxeVPNysKTfCUDkKulWdkubezb9wPcIgGoKtnP76WHrqDpIOWH/bx97pcwuuvzfOwH RGsg== X-Gm-Message-State: AN3rC/44szXTNhg/ybDysO5k4IX7DbvmNLVNOSPM7v2OnwpDyEU3u2RF 1/YX3LaSDA4vbn+a X-Received: by 10.25.16.168 with SMTP id 40mr4918835lfq.75.1492807274772; Fri, 21 Apr 2017 13:41:14 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-8a7f71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.127.138]) by smtp.gmail.com with ESMTPSA id m191sm1770244lfe.43.2017.04.21.13.41.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2017 13:41:13 -0700 (PDT) From: Linus Walleij To: Hans Ulli Kroll , Florian Fainelli , linux-usb@vger.kernel.org, Greg Kroah-Hartman Cc: Janos Laube , Paulius Zaleckas , openwrt-devel@openwrt.org, linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 4/5 v3] usb: host: fotg2: add Gemini-specific handling Date: Fri, 21 Apr 2017 22:40:57 +0200 Message-Id: <20170421204058.6206-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170421204058.6206-1-linus.walleij@linaro.org> References: <20170421204058.6206-1-linus.walleij@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The Cortina Systems Gemini has bolted on a PHY inside the silicon that can be handled by six bits in a MISC register in the system controller. If we are running on Gemini, look up a syscon regmap through a phandle and enable VBUS and optionally the Mini-B connector. If the device is flagged as "wakeup-source" using the standard DT bindings, we also enable this in the global controller for respective port. Signed-off-by: Linus Walleij --- drivers/usb/host/Kconfig | 1 + drivers/usb/host/fotg210-hcd.c | 76 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 407d947b34ea..9750783e5481 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -375,6 +375,7 @@ config USB_ISP1362_HCD config USB_FOTG210_HCD tristate "FOTG210 HCD support" depends on USB && HAS_DMA && HAS_IOMEM + select MFD_SYSCON ---help--- Faraday FOTG210 is an OTG controller which can be configured as an USB2.0 host. It is designed to meet USB2.0 EHCI specification diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c index 906e42458791..146f1eb96b60 100644 --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c @@ -46,6 +46,10 @@ #include #include #include +#include +/* For Cortina Gemini */ +#include +#include #include #include @@ -5583,6 +5587,72 @@ static void fotg210_init(struct fotg210_hcd *fotg210) iowrite32(value, &fotg210->regs->otgcsr); } +/* + * Gemini-specific initialization function, only executed on the + * Gemini SoC using the global misc control register. + */ +#define GEMINI_GLOBAL_MISC_CTRL 0x30 +#define GEMINI_MISC_USB0_WAKEUP BIT(14) +#define GEMINI_MISC_USB1_WAKEUP BIT(15) +#define GEMINI_MISC_USB0_VBUS_ON BIT(22) +#define GEMINI_MISC_USB1_VBUS_ON BIT(23) +#define GEMINI_MISC_USB0_MINI_B BIT(29) +#define GEMINI_MISC_USB1_MINI_B BIT(30) + +static int fotg210_gemini_init(struct device *dev, struct usb_hcd *hcd) +{ + struct device_node *np = dev->of_node; + struct regmap *map; + bool mini_b; + bool wakeup; + u32 mask, val; + int ret; + + map = syscon_regmap_lookup_by_phandle(np, "syscon"); + if (IS_ERR(map)) { + dev_err(dev, "no syscon\n"); + return PTR_ERR(map); + } + mini_b = of_property_read_bool(np, "cortina,gemini-mini-b"); + wakeup = of_property_read_bool(np, "wakeup-source"); + + /* + * Figure out if this is USB0 or USB1 by simply checking the + * physical base address. + */ + mask = 0; + if (hcd->rsrc_start == 0x69000000) { + val = GEMINI_MISC_USB1_VBUS_ON; + if (mini_b) + val |= GEMINI_MISC_USB1_MINI_B; + else + mask |= GEMINI_MISC_USB1_MINI_B; + if (wakeup) + val |= GEMINI_MISC_USB1_WAKEUP; + else + mask |= GEMINI_MISC_USB1_WAKEUP; + } else { + val = GEMINI_MISC_USB0_VBUS_ON; + if (mini_b) + val |= GEMINI_MISC_USB0_MINI_B; + else + mask |= GEMINI_MISC_USB0_MINI_B; + if (wakeup) + val |= GEMINI_MISC_USB0_WAKEUP; + else + mask |= GEMINI_MISC_USB0_WAKEUP; + } + + ret = regmap_update_bits(map, GEMINI_GLOBAL_MISC_CTRL, mask, val); + if (ret) { + dev_err(dev, "failed to initialize Gemini PHY\n"); + return ret; + } + + dev_info(dev, "initialized Gemini PHY\n"); + return 0; +} + /** * fotg210_hcd_probe - initialize faraday FOTG210 HCDs * @@ -5662,6 +5732,12 @@ static int fotg210_hcd_probe(struct platform_device *pdev) fotg210_init(fotg210); + if (of_device_is_compatible(dev->of_node, "cortina,gemini-usb")) { + retval = fotg210_gemini_init(dev, hcd); + if (retval) + goto failed_dis_clk; + } + retval = usb_add_hcd(hcd, irq, IRQF_SHARED); if (retval) { dev_err(dev, "failed to add hcd with err %d\n", retval); From patchwork Fri Apr 21 20:40:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 97930 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp496793qgf; Fri, 21 Apr 2017 13:41:22 -0700 (PDT) X-Received: by 10.98.166.21 with SMTP id t21mr14046076pfe.120.1492807282269; Fri, 21 Apr 2017 13:41:22 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s17si11190563pgn.118.2017.04.21.13.41.22; Fri, 21 Apr 2017 13:41:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162485AbdDUUlU (ORCPT + 4 others); Fri, 21 Apr 2017 16:41:20 -0400 Received: from mail-lf0-f51.google.com ([209.85.215.51]:36540 "EHLO mail-lf0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161246AbdDUUlT (ORCPT ); Fri, 21 Apr 2017 16:41:19 -0400 Received: by mail-lf0-f51.google.com with SMTP id c80so50303804lfh.3 for ; Fri, 21 Apr 2017 13:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=S3VEefJ6Lc8f/eJBDnXhsaTzY+GVe0qIFuZTSzhdtCE=; b=JV50+5JAuhHMDx4f1t90s453BZ9gHHqY3PDcYtQIcKq/j6kJcFnRzYAC+Liap24iRU tZI3R8CFL4FWueT+aB9CtgmC889jfKkg+D3SgTCPwYfVSMWULBlLALESwOIYF+/gaqf3 6kdDGVXrKR6PXozJb9P+PvvbG1iwJMUeFGIEE= 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=S3VEefJ6Lc8f/eJBDnXhsaTzY+GVe0qIFuZTSzhdtCE=; b=q2A7KfM72p1lNDySg8fyJAvYP7Ra4c0UKhIzsgEgjnYUYLlOzwY9PRK0TGgWWIuZ+W r764xP5dmSDHA46KDPfi6q8DSgFYhYLIaV7YX2m6zSMDWSenArsmSl3+zde7gJdv0COA uyuvCsSk6Nm4sEY6QYzw9InkIMgzJJswaN6/29i3AgdnDtqMlkAYSl856ffk+YZRS1uc GbeQ0ZHPduOJ/YmWZyTafjXGzc1J56GwxokehB8DWET+fZbTcDVcobgot7W48RPiRTS1 xj6bc1R+6unh9SH6wbbF7qZQPptmbCSQn5/MOLovUvv3d6l3T9a21OHAw/BgJRZCMXMx dsqQ== X-Gm-Message-State: AN3rC/6I/r7COAd0xl+PR2chxEhocsNHpG85qKBsJ0bXZhiyzAxNrpB8 RhnW1PxCF6qxZwqo X-Received: by 10.25.22.99 with SMTP id m96mr5345724lfi.176.1492807277585; Fri, 21 Apr 2017 13:41:17 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-8a7f71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.127.138]) by smtp.gmail.com with ESMTPSA id m191sm1770244lfe.43.2017.04.21.13.41.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2017 13:41:16 -0700 (PDT) From: Linus Walleij To: Hans Ulli Kroll , Florian Fainelli , linux-usb@vger.kernel.org, Greg Kroah-Hartman Cc: Janos Laube , Paulius Zaleckas , openwrt-devel@openwrt.org, linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 5/5 v3] ARM: dts: Add the FOTG210 USB host to Gemini Date: Fri, 21 Apr 2017 22:40:58 +0200 Message-Id: <20170421204058.6206-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170421204058.6206-1-linus.walleij@linaro.org> References: <20170421204058.6206-1-linus.walleij@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This adds the FOTG210 USB host controller to the Gemini device trees. In the main SoC DTSI it is flagged as disabled and then it is selectively enabled on the devices that utilize it (these per-platform enablements are done on the out-of-tree OpenWrt patch set). It is not enabled on the Itian SquareOne NAS/router since this instead has a VIA host controller soldered on the PCI port, and can gate off these USB host controllers. Signed-off-by: Linus Walleij --- USB maintainers: I will merge this through the ARM SoC tree, the patch is only included in the series for context. --- arch/arm/boot/dts/gemini-nas4220b.dts | 8 ++++++++ arch/arm/boot/dts/gemini-rut1xx.dts | 8 ++++++++ arch/arm/boot/dts/gemini-wbd111.dts | 8 ++++++++ arch/arm/boot/dts/gemini-wbd222.dts | 8 ++++++++ arch/arm/boot/dts/gemini.dtsi | 22 ++++++++++++++++++++++ 5 files changed, 54 insertions(+) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/boot/dts/gemini-nas4220b.dts b/arch/arm/boot/dts/gemini-nas4220b.dts index 7668ba52158e..55059a72aef2 100644 --- a/arch/arm/boot/dts/gemini-nas4220b.dts +++ b/arch/arm/boot/dts/gemini-nas4220b.dts @@ -98,5 +98,13 @@ read-only; }; }; + + usb@68000000 { + status = "okay"; + }; + + usb@69000000 { + status = "okay"; + }; }; }; diff --git a/arch/arm/boot/dts/gemini-rut1xx.dts b/arch/arm/boot/dts/gemini-rut1xx.dts index 7b920bfbda32..1c253da9f28c 100644 --- a/arch/arm/boot/dts/gemini-rut1xx.dts +++ b/arch/arm/boot/dts/gemini-rut1xx.dts @@ -61,5 +61,13 @@ reg = <0x30000000 0x00800000>; /* TODO: add flash partitions here */ }; + + usb@68000000 { + status = "okay"; + }; + + usb@69000000 { + status = "okay"; + }; }; }; diff --git a/arch/arm/boot/dts/gemini-wbd111.dts b/arch/arm/boot/dts/gemini-wbd111.dts index 63b756e3bf5a..c6a5abca0935 100644 --- a/arch/arm/boot/dts/gemini-wbd111.dts +++ b/arch/arm/boot/dts/gemini-wbd111.dts @@ -98,5 +98,13 @@ read-only; }; }; + + usb@68000000 { + status = "okay"; + }; + + usb@69000000 { + status = "okay"; + }; }; }; diff --git a/arch/arm/boot/dts/gemini-wbd222.dts b/arch/arm/boot/dts/gemini-wbd222.dts index 9747f5a47807..415380262140 100644 --- a/arch/arm/boot/dts/gemini-wbd222.dts +++ b/arch/arm/boot/dts/gemini-wbd222.dts @@ -98,5 +98,13 @@ read-only; }; }; + + usb@68000000 { + status = "okay"; + }; + + usb@69000000 { + status = "okay"; + }; }; }; diff --git a/arch/arm/boot/dts/gemini.dtsi b/arch/arm/boot/dts/gemini.dtsi index 6fe678a68e31..2f8d0381d5eb 100644 --- a/arch/arm/boot/dts/gemini.dtsi +++ b/arch/arm/boot/dts/gemini.dtsi @@ -183,5 +183,27 @@ #interrupt-cells = <1>; }; }; + + usb@68000000 { + compatible = "cortina,gemini-usb", "faraday,fotg210"; + reg = <0x68000000 0x1000>; + interrupts = <10 IRQ_TYPE_LEVEL_HIGH>; + resets = <&rcon 8>; + clocks = <&gcc GEMINI_CLK_GATE_USB0>; + clock-names = "PCLK"; + syscon = <&syscon>; + status = "disabled"; + }; + + usb@69000000 { + compatible = "cortina,gemini-usb", "faraday,fotg210"; + reg = <0x69000000 0x1000>; + interrupts = <11 IRQ_TYPE_LEVEL_HIGH>; + resets = <&rcon 9>; + clocks = <&gcc GEMINI_CLK_GATE_USB1>; + clock-names = "PCLK"; + syscon = <&syscon>; + status = "disabled"; + }; }; };