1 From 3526403353c2a1b94c3181f900582626d23c339b Mon Sep 17 00:00:00 2001
2 From: Linus Walleij <linus.walleij@linaro.org>
3 Date: Thu, 18 Aug 2016 20:40:45 +0200
4 Subject: mfd: qcom_rpm: Handle message RAM clock
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 The MSM8660, APQ8060, IPQ806x and MSM8960 have a GCC clock
10 to the message RAM used by the RPM. This needs to be enabled
11 for messages to pass through. This is a crude solution that
12 simply prepare/enable at probe() and disable/unprepare
13 at remove(). More elaborate PM is probably possible to
16 The construction uses IS_ERR() to gracefully handle the
17 platforms that do not provide a message RAM clock. It will
18 bail out of probe only if the clock is hitting a probe
21 Of course this requires the proper device tree set-up:
24 compatible = "qcom,rpm-msm8660";
25 clocks = <&gcc RPM_MSG_RAM_H_CLK>;
30 I have provided this in the MSM8660 device tree, and will
31 provide patches for the other targets.
33 Cc: Björn Andersson <bjorn.andersson@linaro.org>
34 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
35 Signed-off-by: Lee Jones <lee.jones@linaro.org>
37 drivers/mfd/qcom_rpm.c | 20 ++++++++++++++++++++
38 1 file changed, 20 insertions(+)
40 diff --git a/drivers/mfd/qcom_rpm.c b/drivers/mfd/qcom_rpm.c
41 index d330071..52fafea 100644
42 --- a/drivers/mfd/qcom_rpm.c
43 +++ b/drivers/mfd/qcom_rpm.c
45 #include <linux/mfd/qcom_rpm.h>
46 #include <linux/mfd/syscon.h>
47 #include <linux/regmap.h>
48 +#include <linux/clk.h>
50 #include <dt-bindings/mfd/qcom-rpm.h>
52 @@ -48,6 +49,7 @@ struct qcom_rpm {
53 struct regmap *ipc_regmap;
58 struct completion ack;
60 @@ -552,6 +554,20 @@ static int qcom_rpm_probe(struct platform_device *pdev)
61 mutex_init(&rpm->lock);
62 init_completion(&rpm->ack);
64 + /* Enable message RAM clock */
65 + rpm->ramclk = devm_clk_get(&pdev->dev, "ram");
66 + if (IS_ERR(rpm->ramclk)) {
67 + ret = PTR_ERR(rpm->ramclk);
68 + if (ret == -EPROBE_DEFER)
71 + * Fall through in all other cases, as the clock is
72 + * optional. (Does not exist on all platforms.)
76 + clk_prepare_enable(rpm->ramclk); /* Accepts NULL */
78 irq_ack = platform_get_irq_byname(pdev, "ack");
80 dev_err(&pdev->dev, "required ack interrupt missing\n");
81 @@ -672,7 +688,11 @@ static int qcom_rpm_probe(struct platform_device *pdev)
83 static int qcom_rpm_remove(struct platform_device *pdev)
85 + struct qcom_rpm *rpm = dev_get_drvdata(&pdev->dev);
87 of_platform_depopulate(&pdev->dev);
88 + clk_disable_unprepare(rpm->ramclk);