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
6 When SCM was made as a platform driver, clock management was
7 addedfor firmware calls. This is not required for IPQ.
9 Change-Id: I3d29fafe0266e51f708f2718bab03907078b0f4d
10 Signed-off-by: Manoharan Vijaya Raghavan <mraghava@codeaurora.org>
12 drivers/firmware/qcom_scm.c | 87 +++++++++++++++++++++++++++++----------------
13 1 file changed, 57 insertions(+), 30 deletions(-)
15 (limited to 'drivers/firmware/qcom_scm.c')
17 --- a/drivers/firmware/qcom_scm.c
18 +++ b/drivers/firmware/qcom_scm.c
28 struct clk *iface_clk;
30 struct reset_controller_dev reset;
34 static struct qcom_scm *__scm;
35 @@ -42,6 +45,9 @@ static int qcom_scm_clk_enable(void)
39 + if (__scm->is_clkdisabled)
42 ret = clk_prepare_enable(__scm->core_clk);
45 @@ -66,6 +72,9 @@ bail:
47 static void qcom_scm_clk_disable(void)
49 + if (__scm->is_clkdisabled)
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)
57 EXPORT_SYMBOL(qcom_scm_is_available);
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",},
72 static int qcom_scm_probe(struct platform_device *pdev)
75 + const struct of_device_id *id;
78 scm = devm_kzalloc(&pdev->dev, sizeof(*scm), GFP_KERNEL);
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);
88 + scm->is_clkdisabled = (unsigned int)id->data;
90 + scm->is_clkdisabled = 0;
92 + if (!(scm->is_clkdisabled)) {
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);
99 - scm->core_clk = NULL;
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;
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);
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);
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);
139 - /* vote for max clk rate for highest performance */
140 - ret = clk_set_rate(scm->core_clk, INT_MAX);
143 + if (!(scm->is_clkdisabled)) {
144 + /* vote for max clk rate for highest performance */
145 + ret = clk_set_rate(scm->core_clk, INT_MAX);
151 __scm->dev = &pdev->dev;
152 @@ -371,14 +406,6 @@ static int qcom_scm_probe(struct platfor
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",},
164 static struct platform_driver qcom_scm_driver = {