ipq806x: refresh patches
[openwrt/openwrt.git] / target / linux / ipq806x / patches-4.4 / 006-mfd-qcom_rpm-Handle-message-RAM-clock.patch
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
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
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
14 add later.
15
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
19 deferral situation.
20
21 Of course this requires the proper device tree set-up:
22
23 rpm: rpm@104000 {
24 compatible = "qcom,rpm-msm8660";
25 clocks = <&gcc RPM_MSG_RAM_H_CLK>;
26 clock-names = "ram";
27 ...
28 };
29
30 I have provided this in the MSM8660 device tree, and will
31 provide patches for the other targets.
32
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>
36 ---
37 drivers/mfd/qcom_rpm.c | 20 ++++++++++++++++++++
38 1 file changed, 20 insertions(+)
39
40 --- a/drivers/mfd/qcom_rpm.c
41 +++ b/drivers/mfd/qcom_rpm.c
42 @@ -21,6 +21,7 @@
43 #include <linux/mfd/qcom_rpm.h>
44 #include <linux/mfd/syscon.h>
45 #include <linux/regmap.h>
46 +#include <linux/clk.h>
47
48 #include <dt-bindings/mfd/qcom-rpm.h>
49
50 @@ -48,6 +49,7 @@ struct qcom_rpm {
51 struct regmap *ipc_regmap;
52 unsigned ipc_offset;
53 unsigned ipc_bit;
54 + struct clk *ramclk;
55
56 struct completion ack;
57 struct mutex lock;
58 @@ -503,6 +505,20 @@ static int qcom_rpm_probe(struct platfor
59 mutex_init(&rpm->lock);
60 init_completion(&rpm->ack);
61
62 + /* Enable message RAM clock */
63 + rpm->ramclk = devm_clk_get(&pdev->dev, "ram");
64 + if (IS_ERR(rpm->ramclk)) {
65 + ret = PTR_ERR(rpm->ramclk);
66 + if (ret == -EPROBE_DEFER)
67 + return ret;
68 + /*
69 + * Fall through in all other cases, as the clock is
70 + * optional. (Does not exist on all platforms.)
71 + */
72 + rpm->ramclk = NULL;
73 + }
74 + clk_prepare_enable(rpm->ramclk); /* Accepts NULL */
75 +
76 irq_ack = platform_get_irq_byname(pdev, "ack");
77 if (irq_ack < 0) {
78 dev_err(&pdev->dev, "required ack interrupt missing\n");
79 @@ -621,7 +637,11 @@ static int qcom_rpm_probe(struct platfor
80
81 static int qcom_rpm_remove(struct platform_device *pdev)
82 {
83 + struct qcom_rpm *rpm = dev_get_drvdata(&pdev->dev);
84 +
85 of_platform_depopulate(&pdev->dev);
86 + clk_disable_unprepare(rpm->ramclk);
87 +
88 return 0;
89 }
90