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: 9693727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2B0D260328 for ; Fri, 21 Apr 2017 20:43:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B51C28655 for ; Fri, 21 Apr 2017 20:43:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E88628673; Fri, 21 Apr 2017 20:43:27 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6BC9728655 for ; Fri, 21 Apr 2017 20:43:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=r0DOHtEH4xcW0DXdr9jrmZpxWwu2Pr1YHTlos6d9iJc=; b=SfTrFladGGOUtKmfbCqNr/M51V rNet9oCELEFm1+tikvgUt6DMSJI7g9ERUYzcLmBKNvVM4x0WQgaQrtfgNoxg16ZDd7vh+CPdtspnG 76r8UO8Rq4rqHtpqOkO3eaumI63IVJYdp3sxs4mfexHqQ6PMrbnystLD8vqlpYYOI4u7tY7NhazYz cvVKPsTenxaSdvsaSYX3OMOp0Ty5D6D67lIs4jKcK4NHlbiDqDnU79moZSo+R5u22/5CMsts0PgaH 6VX2aON68FwJGrhMczmegjQABubnGM6oIKmDU/3TicWms2wu24HCwUCd/N8FgUGEer1G3iYI7NNhx 3ZYcjUSg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d1fOn-0003SQ-Oe; Fri, 21 Apr 2017 20:43:25 +0000 Received: from mail-lf0-x230.google.com ([2a00:1450:4010:c07::230]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d1fN2-0002Hg-Sa for linux-arm-kernel@lists.infradead.org; Fri, 21 Apr 2017 20:41:39 +0000 Received: by mail-lf0-x230.google.com with SMTP id t144so50417722lff.1 for ; Fri, 21 Apr 2017 13:41:16 -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=a31Uxebem9QEa5txDaxyMNEkyOPNwTPCs/laXxjbi+5UjbB5Nv7hY6sHWzGURw4Hf7 hpo1xThy4+pXJIpX4VdP5KgiOfCA4MKlp0k2MSNhiiwl8Yjx1S9wF1UR9h5vMiGa0c3J H3kKo3rTL3pfVXrNbX2Sv4jy9S6ywe5w/TfLCEPJ5Z9gRfWKgP2eHOCHmZs4g9isIxI3 xNDYnQfANoLLss0zlt7nncnZXEUjLlIBSe/GaK9MsUlAGurmYgAY+4tNuHut3swbov00 r6MfSc5Qs/ldkSVUx4gHiFiV5i1a5x9Tm92xQNfjj/zkXr2l1GKhCI19OFhwjRYPn4z8 IAVg== X-Gm-Message-State: AN3rC/5uc3iqE1BqBCPvvYfjLw+Qa3U9qTT+rpEhREqYdYBeZgYEXQjE Ylqs2KlYn3yyURgE 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170421_134137_139006_B6FBDA08 X-CRM114-Status: GOOD ( 16.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openwrt-devel@openwrt.org, Janos Laube , linux-arm-kernel@lists.infradead.org, Paulius Zaleckas , Linus Walleij MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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);