4f0e544ab66f81856f5094fd35681ab7a9a82596
[oweals/openwrt.git] /
1 From 0fb08a02baf5114fd3bdbc5aa92d6a6cd6d5ef3f Mon Sep 17 00:00:00 2001
2 From: Manoharan Vijaya Raghavan <mraghava@codeaurora.org>
3 Date: Tue, 24 Jan 2017 20:58:46 +0530
4 Subject: ipq: scm: TZ don't need clock to be enabled/disabled for ipq
5
6 When SCM was made as a platform driver, clock management was
7 addedfor firmware calls. This is not required for IPQ.
8
9 Change-Id: I3d29fafe0266e51f708f2718bab03907078b0f4d
10 Signed-off-by: Manoharan Vijaya Raghavan <mraghava@codeaurora.org>
11 ---
12  drivers/firmware/qcom_scm.c | 87 +++++++++++++++++++++++++++++----------------
13  1 file changed, 57 insertions(+), 30 deletions(-)
14
15 (limited to 'drivers/firmware/qcom_scm.c')
16
17 --- a/drivers/firmware/qcom_scm.c
18 +++ b/drivers/firmware/qcom_scm.c
19 @@ -28,12 +28,15 @@
20  
21  #include "qcom_scm.h"
22  
23 +#define SCM_NOCLK 1
24 +
25  struct qcom_scm {
26         struct device *dev;
27         struct clk *core_clk;
28         struct clk *iface_clk;
29         struct clk *bus_clk;
30         struct reset_controller_dev reset;
31 +       int is_clkdisabled;
32  };
33  
34  static struct qcom_scm *__scm;
35 @@ -42,6 +45,9 @@ static int qcom_scm_clk_enable(void)
36  {
37         int ret;
38  
39 +       if (__scm->is_clkdisabled)
40 +               return 0;
41 +
42         ret = clk_prepare_enable(__scm->core_clk);
43         if (ret)
44                 goto bail;
45 @@ -66,6 +72,9 @@ bail:
46  
47  static void qcom_scm_clk_disable(void)
48  {
49 +       if (__scm->is_clkdisabled)
50 +               return;
51 +
52         clk_disable_unprepare(__scm->core_clk);
53         clk_disable_unprepare(__scm->iface_clk);
54         clk_disable_unprepare(__scm->bus_clk);
55 @@ -320,37 +329,61 @@ bool qcom_scm_is_available(void)
56  }
57  EXPORT_SYMBOL(qcom_scm_is_available);
58  
59 +static const struct of_device_id qcom_scm_dt_match[] = {
60 +       { .compatible = "qcom,scm-apq8064",},
61 +       { .compatible = "qcom,scm-msm8660",},
62 +       { .compatible = "qcom,scm-msm8960",},
63 +       { .compatible = "qcom,scm-ipq807x", .data = (void *)SCM_NOCLK },
64 +       { .compatible = "qcom,scm-ipq806x", .data = (void *)SCM_NOCLK },
65 +       { .compatible = "qcom,scm-ipq40xx", .data = (void *)SCM_NOCLK },
66 +       { .compatible = "qcom,scm-msm8960",},
67 +       { .compatible = "qcom,scm-msm8960",},
68 +       { .compatible = "qcom,scm",},
69 +       {}
70 +};
71 +
72  static int qcom_scm_probe(struct platform_device *pdev)
73  {
74         struct qcom_scm *scm;
75 +       const struct of_device_id *id;
76         int ret;
77  
78         scm = devm_kzalloc(&pdev->dev, sizeof(*scm), GFP_KERNEL);
79         if (!scm)
80                 return -ENOMEM;
81  
82 -       scm->core_clk = devm_clk_get(&pdev->dev, "core");
83 -       if (IS_ERR(scm->core_clk)) {
84 -               if (PTR_ERR(scm->core_clk) == -EPROBE_DEFER)
85 -                       return PTR_ERR(scm->core_clk);
86 +       id = of_match_device(qcom_scm_dt_match, &pdev->dev);
87 +       if (id)
88 +               scm->is_clkdisabled = (unsigned int)id->data;
89 +       else
90 +               scm->is_clkdisabled = 0;
91 +
92 +       if (!(scm->is_clkdisabled)) {
93 +
94 +               scm->core_clk = devm_clk_get(&pdev->dev, "core");
95 +               if (IS_ERR(scm->core_clk)) {
96 +                       if (PTR_ERR(scm->core_clk) == -EPROBE_DEFER)
97 +                               return PTR_ERR(scm->core_clk);
98  
99 -               scm->core_clk = NULL;
100 -       }
101 -
102 -       if (of_device_is_compatible(pdev->dev.of_node, "qcom,scm")) {
103 -               scm->iface_clk = devm_clk_get(&pdev->dev, "iface");
104 -               if (IS_ERR(scm->iface_clk)) {
105 -                       if (PTR_ERR(scm->iface_clk) != -EPROBE_DEFER)
106 -                               dev_err(&pdev->dev, "failed to acquire iface clk\n");
107 -                       return PTR_ERR(scm->iface_clk);
108 +                       scm->core_clk = NULL;
109                 }
110  
111 -               scm->bus_clk = devm_clk_get(&pdev->dev, "bus");
112 -               if (IS_ERR(scm->bus_clk)) {
113 -                       if (PTR_ERR(scm->bus_clk) != -EPROBE_DEFER)
114 -                               dev_err(&pdev->dev, "failed to acquire bus clk\n");
115 -                       return PTR_ERR(scm->bus_clk);
116 +               if (of_device_is_compatible(pdev->dev.of_node, "qcom,scm")) {
117 +                       scm->iface_clk = devm_clk_get(&pdev->dev, "iface");
118 +                       if (IS_ERR(scm->iface_clk)) {
119 +                               if (PTR_ERR(scm->iface_clk) != -EPROBE_DEFER)
120 +                                       dev_err(&pdev->dev, "failed to acquire iface clk\n");
121 +                               return PTR_ERR(scm->iface_clk);
122 +                       }
123 +
124 +                       scm->bus_clk = devm_clk_get(&pdev->dev, "bus");
125 +                       if (IS_ERR(scm->bus_clk)) {
126 +                               if (PTR_ERR(scm->bus_clk) != -EPROBE_DEFER)
127 +                                       dev_err(&pdev->dev, "failed to acquire bus clk\n");
128 +                               return PTR_ERR(scm->bus_clk);
129 +                       }
130                 }
131 +
132         }
133  
134         scm->reset.ops = &qcom_scm_pas_reset_ops;
135 @@ -358,10 +391,12 @@ static int qcom_scm_probe(struct platfor
136         scm->reset.of_node = pdev->dev.of_node;
137         reset_controller_register(&scm->reset);
138  
139 -       /* vote for max clk rate for highest performance */
140 -       ret = clk_set_rate(scm->core_clk, INT_MAX);
141 -       if (ret)
142 -               return ret;
143 +       if (!(scm->is_clkdisabled)) {
144 +               /* vote for max clk rate for highest performance */
145 +               ret = clk_set_rate(scm->core_clk, INT_MAX);
146 +               if (ret)
147 +                       return ret;
148 +       }
149  
150         __scm = scm;
151         __scm->dev = &pdev->dev;
152 @@ -371,14 +406,6 @@ static int qcom_scm_probe(struct platfor
153         return 0;
154  }
155  
156 -static const struct of_device_id qcom_scm_dt_match[] = {
157 -       { .compatible = "qcom,scm-apq8064",},
158 -       { .compatible = "qcom,scm-msm8660",},
159 -       { .compatible = "qcom,scm-msm8960",},
160 -       { .compatible = "qcom,scm",},
161 -       {}
162 -};
163 -
164  static struct platform_driver qcom_scm_driver = {
165         .driver = {
166                 .name   = "qcom_scm",