From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754105AbcHSAuE (ORCPT ); Thu, 18 Aug 2016 20:50:04 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:34647 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754064AbcHSAt6 (ORCPT ); Thu, 18 Aug 2016 20:49:58 -0400 Date: Thu, 18 Aug 2016 12:22:41 -0700 From: Bjorn Andersson To: Linus Walleij Cc: lee.jones@linaro.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mfd: qcom_rpm: handle message RAM clock Message-ID: <20160818192241.GW26240@tuxbot> References: <1471545645-11437-1-git-send-email-linus.walleij@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1471545645-11437-1-git-send-email-linus.walleij@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 18 Aug 11:40 PDT 2016, Linus Walleij wrote: > The MSM8660, APQ8060, IPQ806x and MSM8960 have a GCC clock > to the message RAM used by the RPM. This needs to be enabled > for messages to pass through. This is a crude solution that > simply prepare/enable at probe() and disable/unprepare > at remove(). More elaborate PM is probably possible to > add later. > > The construction uses IS_ERR() to gracefully handle the > platforms that do not provide a message RAM clock. It will > bail out of probe only if the clock is hitting a probe > deferral situation. > > Of course this requires the proper device tree set-up: > > rpm: rpm@104000 { > compatible = "qcom,rpm-msm8660"; > clocks = <&gcc RPM_MSG_RAM_H_CLK>; > clock-names = "ram"; > ... > }; > > I have provided this in the MSM8660 device tree, and will > provide patches for the other targets. > > Cc: Björn Andersson > Signed-off-by: Linus Walleij Acked-by: Bjorn Andersson Regards, Bjorn > --- > ChangeLog v1->v2: > - Exploit that a clk can be NULL and handled transparently > by the clock framework, simplifying the code > - Move clock disablement after the OF depopulation call > --- > drivers/mfd/qcom_rpm.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/mfd/qcom_rpm.c b/drivers/mfd/qcom_rpm.c > index 2e44323455dd..315da71bde49 100644 > --- a/drivers/mfd/qcom_rpm.c > +++ b/drivers/mfd/qcom_rpm.c > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > > #include > > @@ -48,6 +49,7 @@ struct qcom_rpm { > struct regmap *ipc_regmap; > unsigned ipc_offset; > unsigned ipc_bit; > + struct clk *ramclk; > > struct completion ack; > struct mutex lock; > @@ -501,6 +503,20 @@ static int qcom_rpm_probe(struct platform_device *pdev) > mutex_init(&rpm->lock); > init_completion(&rpm->ack); > > + /* Enable message RAM clock */ > + rpm->ramclk = devm_clk_get(&pdev->dev, "ram"); > + if (IS_ERR(rpm->ramclk)) { > + ret = PTR_ERR(rpm->ramclk); > + if (ret == -EPROBE_DEFER) > + return ret; > + /* > + * Fall through in all other cases, as the clock is > + * optional. (Does not exist on all platforms.) > + */ > + rpm->ramclk = NULL; > + } > + clk_prepare_enable(rpm->ramclk); /* Accepts NULL */ > + > irq_ack = platform_get_irq_byname(pdev, "ack"); > if (irq_ack < 0) { > dev_err(&pdev->dev, "required ack interrupt missing\n"); > @@ -620,7 +636,11 @@ static int qcom_rpm_probe(struct platform_device *pdev) > > static int qcom_rpm_remove(struct platform_device *pdev) > { > + struct qcom_rpm *rpm = dev_get_drvdata(&pdev->dev); > + > of_platform_depopulate(&pdev->dev); > + clk_disable_unprepare(rpm->ramclk); > + > return 0; > } > > -- > 2.7.4 >