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; };