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: 753598 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w8nhz37vzz9s78 for ; Sat, 22 Apr 2017 06:41:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Zw8opd1Y"; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id DA46EB80324; Fri, 21 Apr 2017 22:41:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Fri, 21 Apr 2017 22:41:13 +0200 (CEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 766C2B802C8 for ; Fri, 21 Apr 2017 22:41:12 +0200 (CEST) X-policyd-weight: using cached result; rate: -7 Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Fri, 21 Apr 2017 22:41:12 +0200 (CEST) Received: by mail-lf0-f49.google.com with SMTP id 88so50385301lfr.0 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=J5E0aZch8uK883Yj/Q/pHhrvIpNu4GN+WzVqrfhWOAP7Uw0/kgWWmDHJjvdQFypa4q n0kxen6XRGMulCKYlf8dYzlNxQhTNfh8gWtCbIZY9UgOhncYIiGL5Uj52Q+0/zEi6Q31 3Hm44/HfgJnWtsMw/B/oFp2/H5nmw1mVNAITG8OJ0Jc822rketY8Db5LPfmFzcu6OiIl RswpByOHmBZvlGEGF6Up0SWynaWjRkOXvcCHLOTKI5toXXc9YilFEqa9SmNhG1DujlnT amD2NYbQk2WjaUF4IIqQvUBxcC53lKpb9oVEXzzNKTsMVSC5YusC+pLMDB/NRomKSa2N HZ1Q== X-Gm-Message-State: AN3rC/7Ag1oi1o17Saf0y7GPrQa4Ypyba15Og0uwUgDxE07c3I1mqNSW 7z58BGMMMmUaSIZprdUiSw== 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 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> Subject: [OpenWrt-Devel] [PATCH 3/5 v3] usb: host: fotg2: add silicon clock handling X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List 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 MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" 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(-) 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; };