141-clk-qcom-Add-KPSS-ACC-GCC-driver.patch 6.1 KB

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