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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. @@ -79,6 +79,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. @@ -18,4 +18,5 @@ obj-$(CONFIG_MSM_GCC_8960) += gcc-msm896
  96. obj-$(CONFIG_MSM_GCC_8974) += gcc-msm8974.o
  97. obj-$(CONFIG_MSM_MMCC_8960) += mmcc-msm8960.o
  98. obj-$(CONFIG_MSM_MMCC_8974) += mmcc-msm8974.o
  99. +obj-$(CONFIG_KPSS_XCC) += kpss-xcc.o
  100. obj-$(CONFIG_QCOM_HFPLL) += hfpll.o
  101. --- /dev/null
  102. +++ b/drivers/clk/qcom/kpss-xcc.c
  103. @@ -0,0 +1,95 @@
  104. +/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
  105. + *
  106. + * This program is free software; you can redistribute it and/or modify
  107. + * it under the terms of the GNU General Public License version 2 and
  108. + * only version 2 as published by the Free Software Foundation.
  109. + *
  110. + * This program is distributed in the hope that it will be useful,
  111. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  112. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  113. + * GNU General Public License for more details.
  114. + */
  115. +
  116. +#include <linux/kernel.h>
  117. +#include <linux/init.h>
  118. +#include <linux/module.h>
  119. +#include <linux/platform_device.h>
  120. +#include <linux/err.h>
  121. +#include <linux/io.h>
  122. +#include <linux/of.h>
  123. +#include <linux/of_device.h>
  124. +#include <linux/clk.h>
  125. +#include <linux/clk-provider.h>
  126. +
  127. +static const char *aux_parents[] = {
  128. + "pll8_vote",
  129. + "pxo",
  130. +};
  131. +
  132. +static unsigned int aux_parent_map[] = {
  133. + 3,
  134. + 0,
  135. +};
  136. +
  137. +static const struct of_device_id kpss_xcc_match_table[] = {
  138. + { .compatible = "qcom,kpss-acc-v1", .data = (void *)1UL },
  139. + { .compatible = "qcom,kpss-gcc" },
  140. + {}
  141. +};
  142. +MODULE_DEVICE_TABLE(of, kpss_xcc_match_table);
  143. +
  144. +static int kpss_xcc_driver_probe(struct platform_device *pdev)
  145. +{
  146. + const struct of_device_id *id;
  147. + struct clk *clk;
  148. + struct resource *res;
  149. + void __iomem *base;
  150. + const char *name;
  151. +
  152. + id = of_match_device(kpss_xcc_match_table, &pdev->dev);
  153. + if (!id)
  154. + return -ENODEV;
  155. +
  156. + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  157. + base = devm_ioremap_resource(&pdev->dev, res);
  158. + if (IS_ERR(base))
  159. + return PTR_ERR(base);
  160. +
  161. + if (id->data) {
  162. + if (of_property_read_string_index(pdev->dev.of_node,
  163. + "clock-output-names", 0, &name))
  164. + return -ENODEV;
  165. + base += 0x14;
  166. + } else {
  167. + name = "acpu_l2_aux";
  168. + base += 0x28;
  169. + }
  170. +
  171. + clk = clk_register_mux_table(&pdev->dev, name, aux_parents,
  172. + ARRAY_SIZE(aux_parents), 0, base, 0, 0x3,
  173. + 0, aux_parent_map, NULL);
  174. +
  175. + platform_set_drvdata(pdev, clk);
  176. +
  177. + return PTR_ERR_OR_ZERO(clk);
  178. +}
  179. +
  180. +static int kpss_xcc_driver_remove(struct platform_device *pdev)
  181. +{
  182. + clk_unregister_mux(platform_get_drvdata(pdev));
  183. + return 0;
  184. +}
  185. +
  186. +static struct platform_driver kpss_xcc_driver = {
  187. + .probe = kpss_xcc_driver_probe,
  188. + .remove = kpss_xcc_driver_remove,
  189. + .driver = {
  190. + .name = "kpss-xcc",
  191. + .of_match_table = kpss_xcc_match_table,
  192. + },
  193. +};
  194. +module_platform_driver(kpss_xcc_driver);
  195. +
  196. +MODULE_DESCRIPTION("Krait Processor Sub System (KPSS) Clock Driver");
  197. +MODULE_LICENSE("GPL v2");
  198. +MODULE_ALIAS("platform:kpss-xcc");