All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-kernel@vger.kernel.org,
	"Björn Andersson" <bjorn.andersson@linaro.org>
Subject: Re: [PATCH v2] mfd: qcom_rpm: handle message RAM clock
Date: Fri, 19 Aug 2016 09:34:30 +0100	[thread overview]
Message-ID: <20160819083430.GJ4254@dell> (raw)
In-Reply-To: <1471545645-11437-1-git-send-email-linus.walleij@linaro.org>

On Thu, 18 Aug 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 <bjorn.andersson@linaro.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> 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(+)

Applied, thanks.

> 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 <linux/mfd/qcom_rpm.h>
>  #include <linux/mfd/syscon.h>
>  #include <linux/regmap.h>
> +#include <linux/clk.h>
>  
>  #include <dt-bindings/mfd/qcom-rpm.h>
>  
> @@ -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;
>  }
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

      parent reply	other threads:[~2016-08-19  8:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-18 18:40 [PATCH v2] mfd: qcom_rpm: handle message RAM clock Linus Walleij
2016-08-18 19:22 ` Bjorn Andersson
2016-08-19  8:34 ` Lee Jones [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160819083430.GJ4254@dell \
    --to=lee.jones@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.