* [PATCH] mfd: qcom_rpm: handle message RAM clock
@ 2016-08-18 13:00 Linus Walleij
2016-08-18 14:17 ` Bjorn Andersson
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2016-08-18 13:00 UTC (permalink / raw)
To: lee.jones, linux-kernel; +Cc: Linus Walleij, Björn Andersson
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>
---
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..58d0617d9a0a 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.)
+ */
+ } else {
+ clk_prepare_enable(rpm->ramclk);
+ }
+
irq_ack = platform_get_irq_byname(pdev, "ack");
if (irq_ack < 0) {
dev_err(&pdev->dev, "required ack interrupt missing\n");
@@ -620,6 +636,10 @@ 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);
+
+ if (!IS_ERR(rpm->ramclk))
+ clk_disable_unprepare(rpm->ramclk);
of_platform_depopulate(&pdev->dev);
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mfd: qcom_rpm: handle message RAM clock
2016-08-18 13:00 [PATCH] mfd: qcom_rpm: handle message RAM clock Linus Walleij
@ 2016-08-18 14:17 ` Bjorn Andersson
0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Andersson @ 2016-08-18 14:17 UTC (permalink / raw)
To: Linus Walleij; +Cc: lee.jones, linux-kernel
On Thu 18 Aug 06:00 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.
>
Even more convenient is that clk_prepare_enable() and
clk_disable_unprepare() accepts a NULL.
So set rpm->ramclk = NULL in the error path and move the
clk_enable/disable() out of their conditional.
> 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";
> ...
> };
>
Please write a few lines in the binding document as well:
Documentation/devicetree/bindings/mfd/qcom-rpm.txt
> 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>
> ---
> 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
[..]
> @@ -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;
> + } else {
> + clk_prepare_enable(rpm->ramclk);
> + }
> +
> irq_ack = platform_get_irq_byname(pdev, "ack");
> if (irq_ack < 0) {
> dev_err(&pdev->dev, "required ack interrupt missing\n");
> @@ -620,6 +636,10 @@ 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);
> +
> + if (!IS_ERR(rpm->ramclk))
> + clk_disable_unprepare(rpm->ramclk);
I suggest that you do this after of_platform_depopulate().
> of_platform_depopulate(&pdev->dev);
> return 0;
> }
Regards,
Bjorn
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-18 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-18 13:00 [PATCH] mfd: qcom_rpm: handle message RAM clock Linus Walleij
2016-08-18 14:17 ` Bjorn Andersson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).