b2ddbc8a68ab5d680f01392abb9aacedb02af3be
[openwrt/staging/lynxis/omap.git] / target / linux / ipq806x / patches-4.4 / 141-clk-qcom-Add-KPSS-ACC-GCC-driver.patch
1 Content-Type: text/plain; charset="utf-8"
2 MIME-Version: 1.0
3 Content-Transfer-Encoding: 7bit
4 Subject: [v3,10/13] clk: qcom: Add KPSS ACC/GCC driver
5 From: Stephen Boyd <sboyd@codeaurora.org>
6 X-Patchwork-Id: 6063201
7 Message-Id: <1426920332-9340-11-git-send-email-sboyd@codeaurora.org>
8 To: Mike Turquette <mturquette@linaro.org>, Stephen Boyd <sboyd@codeaurora.org>
9 Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
10 linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
11 Viresh Kumar <viresh.kumar@linaro.org>, <devicetree@vger.kernel.org>
12 Date: Fri, 20 Mar 2015 23:45:29 -0700
13
14 The ACC and GCC regions present in KPSSv1 contain registers to
15 control clocks and power to each Krait CPU and L2. For CPUfreq
16 purposes probe these devices and expose a mux clock that chooses
17 between PXO and PLL8.
18
19 Cc: <devicetree@vger.kernel.org>
20 Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
21
22 ---
23 .../devicetree/bindings/arm/msm/qcom,kpss-acc.txt | 7 ++
24 .../devicetree/bindings/arm/msm/qcom,kpss-gcc.txt | 28 +++++++
25 drivers/clk/qcom/Kconfig | 8 ++
26 drivers/clk/qcom/Makefile | 1 +
27 drivers/clk/qcom/kpss-xcc.c | 95 ++++++++++++++++++++++
28 5 files changed, 139 insertions(+)
29 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt
30 create mode 100644 drivers/clk/qcom/kpss-xcc.c
31
32 --- a/Documentation/devicetree/bindings/arm/msm/qcom,kpss-acc.txt
33 +++ b/Documentation/devicetree/bindings/arm/msm/qcom,kpss-acc.txt
34 @@ -21,10 +21,17 @@
35 the register region. An optional second element specifies
36 the base address and size of the alias register region.
37
38 +- clock-output-names:
39 + Usage: optional
40 + Value type: <string>
41 + Definition: Name of the output clock. Typically acpuX_aux where X is a
42 + CPU number starting at 0.
43 +
44 Example:
45
46 clock-controller@2088000 {
47 compatible = "qcom,kpss-acc-v2";
48 reg = <0x02088000 0x1000>,
49 <0x02008000 0x1000>;
50 + clock-output-names = "acpu0_aux";
51 };
52 --- /dev/null
53 +++ b/Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt
54 @@ -0,0 +1,28 @@
55 +Krait Processor Sub-system (KPSS) Global Clock Controller (GCC)
56 +
57 +PROPERTIES
58 +
59 +- compatible:
60 + Usage: required
61 + Value type: <string>
62 + Definition: should be one of:
63 + "qcom,kpss-gcc"
64 +
65 +- reg:
66 + Usage: required
67 + Value type: <prop-encoded-array>
68 + Definition: base address and size of the register region
69 +
70 +- clock-output-names:
71 + Usage: required
72 + Value type: <string>
73 + Definition: Name of the output clock. Typically acpu_l2_aux indicating
74 + an L2 cache auxiliary clock.
75 +
76 +Example:
77 +
78 + l2cc: clock-controller@2011000 {
79 + compatible = "qcom,kpss-gcc";
80 + reg = <0x2011000 0x1000>;
81 + clock-output-names = "acpu_l2_aux";
82 + };
83 --- a/drivers/clk/qcom/Kconfig
84 +++ b/drivers/clk/qcom/Kconfig
85 @@ -115,6 +115,14 @@
86 Say Y if you want to support CPU frequency scaling on devices
87 such as MSM8974, APQ8084, etc.
88
89 +config KPSS_XCC
90 + tristate "KPSS Clock Controller"
91 + depends on COMMON_CLK_QCOM
92 + help
93 + Support for the Krait ACC and GCC clock controllers. Say Y
94 + if you want to support CPU frequency scaling on devices such
95 + as MSM8960, APQ8064, etc.
96 +
97 config KRAIT_CLOCKS
98 bool
99 select KRAIT_L2_ACCESSORS
100 --- a/drivers/clk/qcom/Makefile
101 +++ b/drivers/clk/qcom/Makefile
102 @@ -9,6 +9,7 @@
103 clk-qcom-y += clk-regmap-divider.o
104 clk-qcom-y += clk-regmap-mux.o
105 clk-qcom-$(CONFIG_KRAIT_CLOCKS) += clk-krait.o
106 +obj-$(CONFIG_KPSS_XCC) += kpss-xcc.o
107 clk-qcom-y += clk-hfpll.o
108 clk-qcom-y += reset.o
109 clk-qcom-$(CONFIG_QCOM_GDSC) += gdsc.o
110 --- /dev/null
111 +++ b/drivers/clk/qcom/kpss-xcc.c
112 @@ -0,0 +1,95 @@
113 +/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
114 + *
115 + * This program is free software; you can redistribute it and/or modify
116 + * it under the terms of the GNU General Public License version 2 and
117 + * only version 2 as published by the Free Software Foundation.
118 + *
119 + * This program is distributed in the hope that it will be useful,
120 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
121 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
122 + * GNU General Public License for more details.
123 + */
124 +
125 +#include <linux/kernel.h>
126 +#include <linux/init.h>
127 +#include <linux/module.h>
128 +#include <linux/platform_device.h>
129 +#include <linux/err.h>
130 +#include <linux/io.h>
131 +#include <linux/of.h>
132 +#include <linux/of_device.h>
133 +#include <linux/clk.h>
134 +#include <linux/clk-provider.h>
135 +
136 +static const char *aux_parents[] = {
137 + "pll8_vote",
138 + "pxo",
139 +};
140 +
141 +static unsigned int aux_parent_map[] = {
142 + 3,
143 + 0,
144 +};
145 +
146 +static const struct of_device_id kpss_xcc_match_table[] = {
147 + { .compatible = "qcom,kpss-acc-v1", .data = (void *)1UL },
148 + { .compatible = "qcom,kpss-gcc" },
149 + {}
150 +};
151 +MODULE_DEVICE_TABLE(of, kpss_xcc_match_table);
152 +
153 +static int kpss_xcc_driver_probe(struct platform_device *pdev)
154 +{
155 + const struct of_device_id *id;
156 + struct clk *clk;
157 + struct resource *res;
158 + void __iomem *base;
159 + const char *name;
160 +
161 + id = of_match_device(kpss_xcc_match_table, &pdev->dev);
162 + if (!id)
163 + return -ENODEV;
164 +
165 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
166 + base = devm_ioremap_resource(&pdev->dev, res);
167 + if (IS_ERR(base))
168 + return PTR_ERR(base);
169 +
170 + if (id->data) {
171 + if (of_property_read_string_index(pdev->dev.of_node,
172 + "clock-output-names", 0, &name))
173 + return -ENODEV;
174 + base += 0x14;
175 + } else {
176 + name = "acpu_l2_aux";
177 + base += 0x28;
178 + }
179 +
180 + clk = clk_register_mux_table(&pdev->dev, name, aux_parents,
181 + ARRAY_SIZE(aux_parents), 0, base, 0, 0x3,
182 + 0, aux_parent_map, NULL);
183 +
184 + platform_set_drvdata(pdev, clk);
185 +
186 + return PTR_ERR_OR_ZERO(clk);
187 +}
188 +
189 +static int kpss_xcc_driver_remove(struct platform_device *pdev)
190 +{
191 + clk_unregister_mux(platform_get_drvdata(pdev));
192 + return 0;
193 +}
194 +
195 +static struct platform_driver kpss_xcc_driver = {
196 + .probe = kpss_xcc_driver_probe,
197 + .remove = kpss_xcc_driver_remove,
198 + .driver = {
199 + .name = "kpss-xcc",
200 + .of_match_table = kpss_xcc_match_table,
201 + },
202 +};
203 +module_platform_driver(kpss_xcc_driver);
204 +
205 +MODULE_DESCRIPTION("Krait Processor Sub System (KPSS) Clock Driver");
206 +MODULE_LICENSE("GPL v2");
207 +MODULE_ALIAS("platform:kpss-xcc");