138-clk-qcom-Add-HFPLL-driver.patch 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. Content-Type: text/plain; charset="utf-8"
  2. MIME-Version: 1.0
  3. Content-Transfer-Encoding: 7bit
  4. Subject: [v3,06/13] clk: qcom: Add HFPLL driver
  5. From: Stephen Boyd <sboyd@codeaurora.org>
  6. X-Patchwork-Id: 6063231
  7. Message-Id: <1426920332-9340-7-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:25 -0700
  13. On some devices (MSM8974 for example), the HFPLLs are
  14. instantiated within the Krait processor subsystem as separate
  15. register regions. Add a driver for these PLLs so that we can
  16. provide HFPLL clocks for use by the system.
  17. Cc: <devicetree@vger.kernel.org>
  18. Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
  19. ---
  20. .../devicetree/bindings/clock/qcom,hfpll.txt | 40 ++++++++
  21. drivers/clk/qcom/Kconfig | 8 ++
  22. drivers/clk/qcom/Makefile | 1 +
  23. drivers/clk/qcom/hfpll.c | 109 +++++++++++++++++++++
  24. 4 files changed, 158 insertions(+)
  25. create mode 100644 Documentation/devicetree/bindings/clock/qcom,hfpll.txt
  26. create mode 100644 drivers/clk/qcom/hfpll.c
  27. --- /dev/null
  28. +++ b/Documentation/devicetree/bindings/clock/qcom,hfpll.txt
  29. @@ -0,0 +1,40 @@
  30. +High-Frequency PLL (HFPLL)
  31. +
  32. +PROPERTIES
  33. +
  34. +- compatible:
  35. + Usage: required
  36. + Value type: <string>
  37. + Definition: must be "qcom,hfpll"
  38. +
  39. +- reg:
  40. + Usage: required
  41. + Value type: <prop-encoded-array>
  42. + Definition: address and size of HPLL registers. An optional second
  43. + element specifies the address and size of the alias
  44. + register region.
  45. +
  46. +- clock-output-names:
  47. + Usage: required
  48. + Value type: <string>
  49. + Definition: Name of the PLL. Typically hfpllX where X is a CPU number
  50. + starting at 0. Otherwise hfpll_Y where Y is more specific
  51. + such as "l2".
  52. +
  53. +Example:
  54. +
  55. +1) An HFPLL for the L2 cache.
  56. +
  57. + clock-controller@f9016000 {
  58. + compatible = "qcom,hfpll";
  59. + reg = <0xf9016000 0x30>;
  60. + clock-output-names = "hfpll_l2";
  61. + };
  62. +
  63. +2) An HFPLL for CPU0. This HFPLL has the alias register region.
  64. +
  65. + clock-controller@f908a000 {
  66. + compatible = "qcom,hfpll";
  67. + reg = <0xf908a000 0x30>, <0xf900a000 0x30>;
  68. + clock-output-names = "hfpll0";
  69. + };
  70. --- a/drivers/clk/qcom/Kconfig
  71. +++ b/drivers/clk/qcom/Kconfig
  72. @@ -135,3 +135,11 @@ config MSM_MMCC_8974
  73. Support for the multimedia clock controller on msm8974 devices.
  74. Say Y if you want to support multimedia devices such as display,
  75. graphics, video encode/decode, camera, etc.
  76. +
  77. +config QCOM_HFPLL
  78. + tristate "High-Frequency PLL (HFPLL) Clock Controller"
  79. + depends on COMMON_CLK_QCOM
  80. + help
  81. + Support for the high-frequency PLLs present on Qualcomm devices.
  82. + Say Y if you want to support CPU frequency scaling on devices
  83. + such as MSM8974, APQ8084, etc.
  84. --- a/drivers/clk/qcom/Makefile
  85. +++ b/drivers/clk/qcom/Makefile
  86. @@ -25,3 +25,4 @@ obj-$(CONFIG_MSM_MMCC_8960) += mmcc-msm8
  87. obj-$(CONFIG_MSM_MMCC_8974) += mmcc-msm8974.o
  88. obj-$(CONFIG_QCOM_CLK_SMD_RPM) += clk-smd-rpm.o
  89. obj-$(CONFIG_QCOM_CLK_RPM) += clk-rpm.o
  90. +obj-$(CONFIG_QCOM_HFPLL) += hfpll.o
  91. --- /dev/null
  92. +++ b/drivers/clk/qcom/hfpll.c
  93. @@ -0,0 +1,109 @@
  94. +/*
  95. + * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
  96. + *
  97. + * This program is free software; you can redistribute it and/or modify
  98. + * it under the terms of the GNU General Public License version 2 and
  99. + * only version 2 as published by the Free Software Foundation.
  100. + *
  101. + * This program is distributed in the hope that it will be useful,
  102. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  103. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  104. + * GNU General Public License for more details.
  105. + */
  106. +
  107. +#include <linux/kernel.h>
  108. +#include <linux/init.h>
  109. +#include <linux/module.h>
  110. +#include <linux/platform_device.h>
  111. +#include <linux/of.h>
  112. +#include <linux/clk.h>
  113. +#include <linux/clk-provider.h>
  114. +#include <linux/regmap.h>
  115. +
  116. +#include "clk-regmap.h"
  117. +#include "clk-hfpll.h"
  118. +
  119. +static const struct hfpll_data hdata = {
  120. + .mode_reg = 0x00,
  121. + .l_reg = 0x04,
  122. + .m_reg = 0x08,
  123. + .n_reg = 0x0c,
  124. + .user_reg = 0x10,
  125. + .config_reg = 0x14,
  126. + .config_val = 0x430405d,
  127. + .status_reg = 0x1c,
  128. + .lock_bit = 16,
  129. +
  130. + .user_val = 0x8,
  131. + .user_vco_mask = 0x100000,
  132. + .low_vco_max_rate = 1248000000,
  133. + .min_rate = 537600000UL,
  134. + .max_rate = 2900000000UL,
  135. +};
  136. +
  137. +static const struct of_device_id qcom_hfpll_match_table[] = {
  138. + { .compatible = "qcom,hfpll" },
  139. + { }
  140. +};
  141. +MODULE_DEVICE_TABLE(of, qcom_hfpll_match_table);
  142. +
  143. +static const struct regmap_config hfpll_regmap_config = {
  144. + .reg_bits = 32,
  145. + .reg_stride = 4,
  146. + .val_bits = 32,
  147. + .max_register = 0x30,
  148. + .fast_io = true,
  149. +};
  150. +
  151. +static int qcom_hfpll_probe(struct platform_device *pdev)
  152. +{
  153. + struct clk *clk;
  154. + struct resource *res;
  155. + struct device *dev = &pdev->dev;
  156. + void __iomem *base;
  157. + struct regmap *regmap;
  158. + struct clk_hfpll *h;
  159. + struct clk_init_data init = {
  160. + .parent_names = (const char *[]){ "xo" },
  161. + .num_parents = 1,
  162. + .ops = &clk_ops_hfpll,
  163. + };
  164. +
  165. + h = devm_kzalloc(dev, sizeof(*h), GFP_KERNEL);
  166. + if (!h)
  167. + return -ENOMEM;
  168. +
  169. + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  170. + base = devm_ioremap_resource(dev, res);
  171. + if (IS_ERR(base))
  172. + return PTR_ERR(base);
  173. +
  174. + regmap = devm_regmap_init_mmio(&pdev->dev, base, &hfpll_regmap_config);
  175. + if (IS_ERR(regmap))
  176. + return PTR_ERR(regmap);
  177. +
  178. + if (of_property_read_string_index(dev->of_node, "clock-output-names",
  179. + 0, &init.name))
  180. + return -ENODEV;
  181. +
  182. + h->d = &hdata;
  183. + h->clkr.hw.init = &init;
  184. + spin_lock_init(&h->lock);
  185. +
  186. + clk = devm_clk_register_regmap(&pdev->dev, &h->clkr);
  187. +
  188. + return PTR_ERR_OR_ZERO(clk);
  189. +}
  190. +
  191. +static struct platform_driver qcom_hfpll_driver = {
  192. + .probe = qcom_hfpll_probe,
  193. + .driver = {
  194. + .name = "qcom-hfpll",
  195. + .of_match_table = qcom_hfpll_match_table,
  196. + },
  197. +};
  198. +module_platform_driver(qcom_hfpll_driver);
  199. +
  200. +MODULE_DESCRIPTION("QCOM HFPLL Clock Driver");
  201. +MODULE_LICENSE("GPL v2");
  202. +MODULE_ALIAS("platform:qcom-hfpll");