From patchwork Sat Sep 1 16:03:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 145712 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp700728ljw; Sat, 1 Sep 2018 09:03:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbyLQQqmF0rWxqt3qC7dETcUtVmvZa/R0uLJcH8uRDjQCeS9S0MFnE/Yhc1EPC60sMGj8kZ X-Received: by 2002:a63:e841:: with SMTP id a1-v6mr4576366pgk.126.1535817804285; Sat, 01 Sep 2018 09:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535817804; cv=none; d=google.com; s=arc-20160816; b=R0/jSRfsaHmJFX+lEZ02E9d0W888/IntgyJwgQRToGW8J/vdYgks4wnmfELM+Qnuxv cwbv1YfWfl7xiAxqf1tNjyeifxWY+ilgvbarfUkFJ6R0VJCO+gusiPaNJi1oU4NA7hFo CsTmL6dokhyCg/do/NY9nNv+IA5CKPUNOEhpGSmFd/JppHSMc0IW64rvFm3FpVpQtuYu UjtwkGkjkjLSt+WyjfKPiRC7zqpEFxTBE49pOjb+KvMaX2jcMLnWQXWLF4ECWW7aD3wH +h7sPCoR/p533NkXhZgevq94v6xf3tL6zyaXhckZ9pNifgP5GVogovfIQY7E8vc3mcQ4 vA9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=G64wHmn7sK80cMdJ/SLVbpXOhuydH1SXbpEZlS6QpmU=; b=V6shrQbLtR+6ND9bTse828GmthWd8DnIjngVRfl62GhA0nYxOaRvrNS3UqAc9Cf/EJ VatVdJyRP8+bzvEYwnsjpnUZ5rVuqZ82i4KZbv+DbLK1n5utgfnEYIXt/7nFLrIKFB8q uvsUo4BzmK6G08AZqRX/iSDQ8y5NQix5vPQy6kEnqcaqj1DypRTI2IwOlByRhpxXTS5p V8HmMfZ0J4ZPqLCnKvKj6ZnfqHZkRhRP0gBtFOErvx810L5MKjVmxBHoJAJlaT0PRKW+ IjGNEUmgHUY0VuibiDnOnL1g+QFmU3gEFMlTmEhluGoQGS1BGod5HjCYy5G3v3/rAFtR IFjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZXvHrtFn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w26-v6si13630559pgk.372.2018.09.01.09.03.23; Sat, 01 Sep 2018 09:03:24 -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=pass header.i=@linaro.org header.s=google header.b=ZXvHrtFn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726976AbeIAUPs (ORCPT + 5 others); Sat, 1 Sep 2018 16:15:48 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:35644 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726934AbeIAUPs (ORCPT ); Sat, 1 Sep 2018 16:15:48 -0400 Received: by mail-lj1-f193.google.com with SMTP id p10-v6so12332436ljg.2 for ; Sat, 01 Sep 2018 09:03: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; bh=G64wHmn7sK80cMdJ/SLVbpXOhuydH1SXbpEZlS6QpmU=; b=ZXvHrtFnwgsuL73/MKD/axZRurwPEtn0xk8z1QZtYpJJ+6VHiFdrE+HVEQF2XbUPtF BdT2p7KNahQWSeBDJvCtS5x8q92VSGBX5yjAkQ0WPWrJGbrUFIgVuWYq9tSA8Olcqb7k q+NGqSdPaSw2nOa0/RcMlG4oaVGR09Mec528Y= 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=G64wHmn7sK80cMdJ/SLVbpXOhuydH1SXbpEZlS6QpmU=; b=W/MK3mmfj5/zwn/Ik/rWasroroMCHxxyR30ZNJVO2mCwbAEPe9dpSj7Q9gLigtuks3 RbtNuAiDeVStx57s8bHX2A70SK23PQjqVCOfGMwAi3G5Sz3t+5erCeMcyjS2F6ywp5gJ KIMXtEIrlioOQ72FRoSlTku5YVxR9yk3q+iquy/sHndI4Icb5s9KkOemGVNZrutcpQQ3 xCuPVLQ9JSOnWSdZXTXIfDQKyPupTDxf9C3mMxde9BriPEq0h8XqH0ra690GS5mkBr0e q65qC1hWdARzxzHMgnrLmHup50ZPso7W48rtI29YTuoZRlCKOrM+hJrqo8+WPkkEGNV5 +x4g== X-Gm-Message-State: APzg51DXxQg8uA+gC1VUYJcicIT14FwveVFkPPAILKiXAW47DiOfu2bE V9ldlBBtOuzUK+dt+fcdwBcIZw== X-Received: by 2002:a2e:720e:: with SMTP id n14-v6mr13798151ljc.93.1535817798156; Sat, 01 Sep 2018 09:03:18 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id h16-v6sm2439488ljh.26.2018.09.01.09.03.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Sep 2018 09:03:16 -0700 (PDT) From: Linus Walleij To: Hans Ulli Kroll , Florian Fainelli , linux-usb@vger.kernel.org, Greg Kroah-Hartman Cc: Linus Walleij Subject: [PATCH v2] usb: host: fotg2: add silicon clock handling Date: Sat, 1 Sep 2018 18:03:12 +0200 Message-Id: <20180901160312.24163-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 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-controlled 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. If there is no clock available on the platform, we live without it. Make sure to percolate probe deferrals. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Handle probe deferrals on the clock controller, no matter how unlikely they are. - Send the patch to get Gemini USB rolling and try to get some stuff upstream, this patch should be fine on its own. --- drivers/usb/host/fotg210-hcd.c | 33 +++++++++++++++++++++++++++++---- drivers/usb/host/fotg210.h | 3 +++ 2 files changed, 32 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c index e64eb47770c8..058ff82ea789 100644 --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -5596,7 +5597,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; @@ -5606,22 +5607,42 @@ 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_put_hcd; + } + } else if (PTR_ERR(fotg210->pclk) == -EPROBE_DEFER) { + /* + * Percolate deferrals, for anything else, + * just live without the clocking. + */ + retval = PTR_ERR(fotg210->pclk); + 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); @@ -5637,6 +5658,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 7fcd785c7bc8..28f6467c0cbf 100644 --- a/drivers/usb/host/fotg210.h +++ b/drivers/usb/host/fotg210.h @@ -182,6 +182,9 @@ struct fotg210_hcd { /* one per controller */ # define COUNT(x) #endif + /* silicon clock */ + struct clk *pclk; + /* debug files */ struct dentry *debug_dir; };