012-2-clk-qcom-Add-support-for-RPM-Clocks.patch 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. From 872f91b5ea720c72f81fb46d353c43ecb3263ffa Mon Sep 17 00:00:00 2001
  2. From: Georgi Djakov <georgi.djakov@linaro.org>
  3. Date: Wed, 2 Nov 2016 17:56:57 +0200
  4. Subject: clk: qcom: Add support for RPM Clocks
  5. This adds initial support for clocks controlled by the Resource
  6. Power Manager (RPM) processor on some Qualcomm SoCs, which use
  7. the qcom_rpm driver to communicate with RPM.
  8. Such platforms are apq8064 and msm8960.
  9. Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
  10. Acked-by: Rob Herring <robh@kernel.org>
  11. Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
  12. ---
  13. .../devicetree/bindings/clock/qcom,rpmcc.txt | 1 +
  14. drivers/clk/qcom/Kconfig | 13 +
  15. drivers/clk/qcom/Makefile | 1 +
  16. drivers/clk/qcom/clk-rpm.c | 489 +++++++++++++++++++++
  17. include/dt-bindings/clock/qcom,rpmcc.h | 24 +
  18. 5 files changed, 528 insertions(+)
  19. create mode 100644 drivers/clk/qcom/clk-rpm.c
  20. --- a/Documentation/devicetree/bindings/clock/qcom,rpmcc.txt
  21. +++ b/Documentation/devicetree/bindings/clock/qcom,rpmcc.txt
  22. @@ -11,6 +11,7 @@ Required properties :
  23. compatible "qcom,rpmcc" should be also included.
  24. "qcom,rpmcc-msm8916", "qcom,rpmcc"
  25. + "qcom,rpmcc-apq8064", "qcom,rpmcc"
  26. - #clock-cells : shall contain 1
  27. --- a/drivers/clk/qcom/Kconfig
  28. +++ b/drivers/clk/qcom/Kconfig
  29. @@ -12,6 +12,19 @@ config COMMON_CLK_QCOM
  30. select REGMAP_MMIO
  31. select RESET_CONTROLLER
  32. +config QCOM_CLK_RPM
  33. + tristate "RPM based Clock Controller"
  34. + depends on COMMON_CLK_QCOM && MFD_QCOM_RPM
  35. + select QCOM_RPMCC
  36. + help
  37. + The RPM (Resource Power Manager) is a dedicated hardware engine for
  38. + managing the shared SoC resources in order to keep the lowest power
  39. + profile. It communicates with other hardware subsystems via shared
  40. + memory and accepts clock requests, aggregates the requests and turns
  41. + the clocks on/off or scales them on demand.
  42. + Say Y if you want to support the clocks exposed by the RPM on
  43. + platforms such as ipq806x, msm8660, msm8960 etc.
  44. +
  45. config QCOM_CLK_SMD_RPM
  46. tristate "RPM over SMD based Clock Controller"
  47. depends on COMMON_CLK_QCOM && QCOM_SMD_RPM
  48. --- a/drivers/clk/qcom/Makefile
  49. +++ b/drivers/clk/qcom/Makefile
  50. @@ -23,3 +23,4 @@ obj-$(CONFIG_MSM_GCC_8974) += gcc-msm897
  51. obj-$(CONFIG_MSM_MMCC_8960) += mmcc-msm8960.o
  52. obj-$(CONFIG_MSM_MMCC_8974) += mmcc-msm8974.o
  53. obj-$(CONFIG_QCOM_CLK_SMD_RPM) += clk-smd-rpm.o
  54. +obj-$(CONFIG_QCOM_CLK_RPM) += clk-rpm.o
  55. --- /dev/null
  56. +++ b/drivers/clk/qcom/clk-rpm.c
  57. @@ -0,0 +1,489 @@
  58. +/*
  59. + * Copyright (c) 2016, Linaro Limited
  60. + * Copyright (c) 2014, The Linux Foundation. All rights reserved.
  61. + *
  62. + * This software is licensed under the terms of the GNU General Public
  63. + * License version 2, as published by the Free Software Foundation, and
  64. + * may be copied, distributed, and modified under those terms.
  65. + *
  66. + * This program is distributed in the hope that it will be useful,
  67. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  68. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  69. + * GNU General Public License for more details.
  70. + */
  71. +
  72. +#include <linux/clk-provider.h>
  73. +#include <linux/err.h>
  74. +#include <linux/export.h>
  75. +#include <linux/init.h>
  76. +#include <linux/kernel.h>
  77. +#include <linux/module.h>
  78. +#include <linux/mutex.h>
  79. +#include <linux/mfd/qcom_rpm.h>
  80. +#include <linux/of.h>
  81. +#include <linux/of_device.h>
  82. +#include <linux/platform_device.h>
  83. +
  84. +#include <dt-bindings/mfd/qcom-rpm.h>
  85. +#include <dt-bindings/clock/qcom,rpmcc.h>
  86. +
  87. +#define QCOM_RPM_MISC_CLK_TYPE 0x306b6c63
  88. +#define QCOM_RPM_SCALING_ENABLE_ID 0x2
  89. +
  90. +#define DEFINE_CLK_RPM(_platform, _name, _active, r_id) \
  91. + static struct clk_rpm _platform##_##_active; \
  92. + static struct clk_rpm _platform##_##_name = { \
  93. + .rpm_clk_id = (r_id), \
  94. + .peer = &_platform##_##_active, \
  95. + .rate = INT_MAX, \
  96. + .hw.init = &(struct clk_init_data){ \
  97. + .ops = &clk_rpm_ops, \
  98. + .name = #_name, \
  99. + .parent_names = (const char *[]){ "pxo_board" }, \
  100. + .num_parents = 1, \
  101. + }, \
  102. + }; \
  103. + static struct clk_rpm _platform##_##_active = { \
  104. + .rpm_clk_id = (r_id), \
  105. + .peer = &_platform##_##_name, \
  106. + .active_only = true, \
  107. + .rate = INT_MAX, \
  108. + .hw.init = &(struct clk_init_data){ \
  109. + .ops = &clk_rpm_ops, \
  110. + .name = #_active, \
  111. + .parent_names = (const char *[]){ "pxo_board" }, \
  112. + .num_parents = 1, \
  113. + }, \
  114. + }
  115. +
  116. +#define DEFINE_CLK_RPM_PXO_BRANCH(_platform, _name, _active, r_id, r) \
  117. + static struct clk_rpm _platform##_##_active; \
  118. + static struct clk_rpm _platform##_##_name = { \
  119. + .rpm_clk_id = (r_id), \
  120. + .active_only = true, \
  121. + .peer = &_platform##_##_active, \
  122. + .rate = (r), \
  123. + .branch = true, \
  124. + .hw.init = &(struct clk_init_data){ \
  125. + .ops = &clk_rpm_branch_ops, \
  126. + .name = #_name, \
  127. + .parent_names = (const char *[]){ "pxo_board" }, \
  128. + .num_parents = 1, \
  129. + }, \
  130. + }; \
  131. + static struct clk_rpm _platform##_##_active = { \
  132. + .rpm_clk_id = (r_id), \
  133. + .peer = &_platform##_##_name, \
  134. + .rate = (r), \
  135. + .branch = true, \
  136. + .hw.init = &(struct clk_init_data){ \
  137. + .ops = &clk_rpm_branch_ops, \
  138. + .name = #_active, \
  139. + .parent_names = (const char *[]){ "pxo_board" }, \
  140. + .num_parents = 1, \
  141. + }, \
  142. + }
  143. +
  144. +#define DEFINE_CLK_RPM_CXO_BRANCH(_platform, _name, _active, r_id, r) \
  145. + static struct clk_rpm _platform##_##_active; \
  146. + static struct clk_rpm _platform##_##_name = { \
  147. + .rpm_clk_id = (r_id), \
  148. + .peer = &_platform##_##_active, \
  149. + .rate = (r), \
  150. + .branch = true, \
  151. + .hw.init = &(struct clk_init_data){ \
  152. + .ops = &clk_rpm_branch_ops, \
  153. + .name = #_name, \
  154. + .parent_names = (const char *[]){ "cxo_board" }, \
  155. + .num_parents = 1, \
  156. + }, \
  157. + }; \
  158. + static struct clk_rpm _platform##_##_active = { \
  159. + .rpm_clk_id = (r_id), \
  160. + .active_only = true, \
  161. + .peer = &_platform##_##_name, \
  162. + .rate = (r), \
  163. + .branch = true, \
  164. + .hw.init = &(struct clk_init_data){ \
  165. + .ops = &clk_rpm_branch_ops, \
  166. + .name = #_active, \
  167. + .parent_names = (const char *[]){ "cxo_board" }, \
  168. + .num_parents = 1, \
  169. + }, \
  170. + }
  171. +
  172. +#define to_clk_rpm(_hw) container_of(_hw, struct clk_rpm, hw)
  173. +
  174. +struct clk_rpm {
  175. + const int rpm_clk_id;
  176. + const bool active_only;
  177. + unsigned long rate;
  178. + bool enabled;
  179. + bool branch;
  180. + struct clk_rpm *peer;
  181. + struct clk_hw hw;
  182. + struct qcom_rpm *rpm;
  183. +};
  184. +
  185. +struct rpm_cc {
  186. + struct qcom_rpm *rpm;
  187. + struct clk_hw_onecell_data data;
  188. + struct clk_hw *hws[];
  189. +};
  190. +
  191. +struct rpm_clk_desc {
  192. + struct clk_rpm **clks;
  193. + size_t num_clks;
  194. +};
  195. +
  196. +static DEFINE_MUTEX(rpm_clk_lock);
  197. +
  198. +static int clk_rpm_handoff(struct clk_rpm *r)
  199. +{
  200. + int ret;
  201. + u32 value = INT_MAX;
  202. +
  203. + ret = qcom_rpm_write(r->rpm, QCOM_RPM_ACTIVE_STATE,
  204. + r->rpm_clk_id, &value, 1);
  205. + if (ret)
  206. + return ret;
  207. + ret = qcom_rpm_write(r->rpm, QCOM_RPM_SLEEP_STATE,
  208. + r->rpm_clk_id, &value, 1);
  209. + if (ret)
  210. + return ret;
  211. +
  212. + return 0;
  213. +}
  214. +
  215. +static int clk_rpm_set_rate_active(struct clk_rpm *r, unsigned long rate)
  216. +{
  217. + u32 value = DIV_ROUND_UP(rate, 1000); /* to kHz */
  218. +
  219. + return qcom_rpm_write(r->rpm, QCOM_RPM_ACTIVE_STATE,
  220. + r->rpm_clk_id, &value, 1);
  221. +}
  222. +
  223. +static int clk_rpm_set_rate_sleep(struct clk_rpm *r, unsigned long rate)
  224. +{
  225. + u32 value = DIV_ROUND_UP(rate, 1000); /* to kHz */
  226. +
  227. + return qcom_rpm_write(r->rpm, QCOM_RPM_SLEEP_STATE,
  228. + r->rpm_clk_id, &value, 1);
  229. +}
  230. +
  231. +static void to_active_sleep(struct clk_rpm *r, unsigned long rate,
  232. + unsigned long *active, unsigned long *sleep)
  233. +{
  234. + *active = rate;
  235. +
  236. + /*
  237. + * Active-only clocks don't care what the rate is during sleep. So,
  238. + * they vote for zero.
  239. + */
  240. + if (r->active_only)
  241. + *sleep = 0;
  242. + else
  243. + *sleep = *active;
  244. +}
  245. +
  246. +static int clk_rpm_prepare(struct clk_hw *hw)
  247. +{
  248. + struct clk_rpm *r = to_clk_rpm(hw);
  249. + struct clk_rpm *peer = r->peer;
  250. + unsigned long this_rate = 0, this_sleep_rate = 0;
  251. + unsigned long peer_rate = 0, peer_sleep_rate = 0;
  252. + unsigned long active_rate, sleep_rate;
  253. + int ret = 0;
  254. +
  255. + mutex_lock(&rpm_clk_lock);
  256. +
  257. + /* Don't send requests to the RPM if the rate has not been set. */
  258. + if (!r->rate)
  259. + goto out;
  260. +
  261. + to_active_sleep(r, r->rate, &this_rate, &this_sleep_rate);
  262. +
  263. + /* Take peer clock's rate into account only if it's enabled. */
  264. + if (peer->enabled)
  265. + to_active_sleep(peer, peer->rate,
  266. + &peer_rate, &peer_sleep_rate);
  267. +
  268. + active_rate = max(this_rate, peer_rate);
  269. +
  270. + if (r->branch)
  271. + active_rate = !!active_rate;
  272. +
  273. + ret = clk_rpm_set_rate_active(r, active_rate);
  274. + if (ret)
  275. + goto out;
  276. +
  277. + sleep_rate = max(this_sleep_rate, peer_sleep_rate);
  278. + if (r->branch)
  279. + sleep_rate = !!sleep_rate;
  280. +
  281. + ret = clk_rpm_set_rate_sleep(r, sleep_rate);
  282. + if (ret)
  283. + /* Undo the active set vote and restore it */
  284. + ret = clk_rpm_set_rate_active(r, peer_rate);
  285. +
  286. +out:
  287. + if (!ret)
  288. + r->enabled = true;
  289. +
  290. + mutex_unlock(&rpm_clk_lock);
  291. +
  292. + return ret;
  293. +}
  294. +
  295. +static void clk_rpm_unprepare(struct clk_hw *hw)
  296. +{
  297. + struct clk_rpm *r = to_clk_rpm(hw);
  298. + struct clk_rpm *peer = r->peer;
  299. + unsigned long peer_rate = 0, peer_sleep_rate = 0;
  300. + unsigned long active_rate, sleep_rate;
  301. + int ret;
  302. +
  303. + mutex_lock(&rpm_clk_lock);
  304. +
  305. + if (!r->rate)
  306. + goto out;
  307. +
  308. + /* Take peer clock's rate into account only if it's enabled. */
  309. + if (peer->enabled)
  310. + to_active_sleep(peer, peer->rate, &peer_rate,
  311. + &peer_sleep_rate);
  312. +
  313. + active_rate = r->branch ? !!peer_rate : peer_rate;
  314. + ret = clk_rpm_set_rate_active(r, active_rate);
  315. + if (ret)
  316. + goto out;
  317. +
  318. + sleep_rate = r->branch ? !!peer_sleep_rate : peer_sleep_rate;
  319. + ret = clk_rpm_set_rate_sleep(r, sleep_rate);
  320. + if (ret)
  321. + goto out;
  322. +
  323. + r->enabled = false;
  324. +
  325. +out:
  326. + mutex_unlock(&rpm_clk_lock);
  327. +}
  328. +
  329. +static int clk_rpm_set_rate(struct clk_hw *hw,
  330. + unsigned long rate, unsigned long parent_rate)
  331. +{
  332. + struct clk_rpm *r = to_clk_rpm(hw);
  333. + struct clk_rpm *peer = r->peer;
  334. + unsigned long active_rate, sleep_rate;
  335. + unsigned long this_rate = 0, this_sleep_rate = 0;
  336. + unsigned long peer_rate = 0, peer_sleep_rate = 0;
  337. + int ret = 0;
  338. +
  339. + mutex_lock(&rpm_clk_lock);
  340. +
  341. + if (!r->enabled)
  342. + goto out;
  343. +
  344. + to_active_sleep(r, rate, &this_rate, &this_sleep_rate);
  345. +
  346. + /* Take peer clock's rate into account only if it's enabled. */
  347. + if (peer->enabled)
  348. + to_active_sleep(peer, peer->rate,
  349. + &peer_rate, &peer_sleep_rate);
  350. +
  351. + active_rate = max(this_rate, peer_rate);
  352. + ret = clk_rpm_set_rate_active(r, active_rate);
  353. + if (ret)
  354. + goto out;
  355. +
  356. + sleep_rate = max(this_sleep_rate, peer_sleep_rate);
  357. + ret = clk_rpm_set_rate_sleep(r, sleep_rate);
  358. + if (ret)
  359. + goto out;
  360. +
  361. + r->rate = rate;
  362. +
  363. +out:
  364. + mutex_unlock(&rpm_clk_lock);
  365. +
  366. + return ret;
  367. +}
  368. +
  369. +static long clk_rpm_round_rate(struct clk_hw *hw, unsigned long rate,
  370. + unsigned long *parent_rate)
  371. +{
  372. + /*
  373. + * RPM handles rate rounding and we don't have a way to
  374. + * know what the rate will be, so just return whatever
  375. + * rate is requested.
  376. + */
  377. + return rate;
  378. +}
  379. +
  380. +static unsigned long clk_rpm_recalc_rate(struct clk_hw *hw,
  381. + unsigned long parent_rate)
  382. +{
  383. + struct clk_rpm *r = to_clk_rpm(hw);
  384. +
  385. + /*
  386. + * RPM handles rate rounding and we don't have a way to
  387. + * know what the rate will be, so just return whatever
  388. + * rate was set.
  389. + */
  390. + return r->rate;
  391. +}
  392. +
  393. +static const struct clk_ops clk_rpm_ops = {
  394. + .prepare = clk_rpm_prepare,
  395. + .unprepare = clk_rpm_unprepare,
  396. + .set_rate = clk_rpm_set_rate,
  397. + .round_rate = clk_rpm_round_rate,
  398. + .recalc_rate = clk_rpm_recalc_rate,
  399. +};
  400. +
  401. +static const struct clk_ops clk_rpm_branch_ops = {
  402. + .prepare = clk_rpm_prepare,
  403. + .unprepare = clk_rpm_unprepare,
  404. + .round_rate = clk_rpm_round_rate,
  405. + .recalc_rate = clk_rpm_recalc_rate,
  406. +};
  407. +
  408. +/* apq8064 */
  409. +DEFINE_CLK_RPM(apq8064, afab_clk, afab_a_clk, QCOM_RPM_APPS_FABRIC_CLK);
  410. +DEFINE_CLK_RPM(apq8064, cfpb_clk, cfpb_a_clk, QCOM_RPM_CFPB_CLK);
  411. +DEFINE_CLK_RPM(apq8064, daytona_clk, daytona_a_clk, QCOM_RPM_DAYTONA_FABRIC_CLK);
  412. +DEFINE_CLK_RPM(apq8064, ebi1_clk, ebi1_a_clk, QCOM_RPM_EBI1_CLK);
  413. +DEFINE_CLK_RPM(apq8064, mmfab_clk, mmfab_a_clk, QCOM_RPM_MM_FABRIC_CLK);
  414. +DEFINE_CLK_RPM(apq8064, mmfpb_clk, mmfpb_a_clk, QCOM_RPM_MMFPB_CLK);
  415. +DEFINE_CLK_RPM(apq8064, sfab_clk, sfab_a_clk, QCOM_RPM_SYS_FABRIC_CLK);
  416. +DEFINE_CLK_RPM(apq8064, sfpb_clk, sfpb_a_clk, QCOM_RPM_SFPB_CLK);
  417. +DEFINE_CLK_RPM(apq8064, qdss_clk, qdss_a_clk, QCOM_RPM_QDSS_CLK);
  418. +
  419. +static struct clk_rpm *apq8064_clks[] = {
  420. + [RPM_APPS_FABRIC_CLK] = &apq8064_afab_clk,
  421. + [RPM_APPS_FABRIC_A_CLK] = &apq8064_afab_a_clk,
  422. + [RPM_CFPB_CLK] = &apq8064_cfpb_clk,
  423. + [RPM_CFPB_A_CLK] = &apq8064_cfpb_a_clk,
  424. + [RPM_DAYTONA_FABRIC_CLK] = &apq8064_daytona_clk,
  425. + [RPM_DAYTONA_FABRIC_A_CLK] = &apq8064_daytona_a_clk,
  426. + [RPM_EBI1_CLK] = &apq8064_ebi1_clk,
  427. + [RPM_EBI1_A_CLK] = &apq8064_ebi1_a_clk,
  428. + [RPM_MM_FABRIC_CLK] = &apq8064_mmfab_clk,
  429. + [RPM_MM_FABRIC_A_CLK] = &apq8064_mmfab_a_clk,
  430. + [RPM_MMFPB_CLK] = &apq8064_mmfpb_clk,
  431. + [RPM_MMFPB_A_CLK] = &apq8064_mmfpb_a_clk,
  432. + [RPM_SYS_FABRIC_CLK] = &apq8064_sfab_clk,
  433. + [RPM_SYS_FABRIC_A_CLK] = &apq8064_sfab_a_clk,
  434. + [RPM_SFPB_CLK] = &apq8064_sfpb_clk,
  435. + [RPM_SFPB_A_CLK] = &apq8064_sfpb_a_clk,
  436. + [RPM_QDSS_CLK] = &apq8064_qdss_clk,
  437. + [RPM_QDSS_A_CLK] = &apq8064_qdss_a_clk,
  438. +};
  439. +
  440. +static const struct rpm_clk_desc rpm_clk_apq8064 = {
  441. + .clks = apq8064_clks,
  442. + .num_clks = ARRAY_SIZE(apq8064_clks),
  443. +};
  444. +
  445. +static const struct of_device_id rpm_clk_match_table[] = {
  446. + { .compatible = "qcom,rpmcc-apq8064", .data = &rpm_clk_apq8064 },
  447. + { }
  448. +};
  449. +MODULE_DEVICE_TABLE(of, rpm_clk_match_table);
  450. +
  451. +static int rpm_clk_probe(struct platform_device *pdev)
  452. +{
  453. + struct clk_hw **hws;
  454. + struct rpm_cc *rcc;
  455. + struct clk_hw_onecell_data *data;
  456. + int ret;
  457. + size_t num_clks, i;
  458. + struct qcom_rpm *rpm;
  459. + struct clk_rpm **rpm_clks;
  460. + const struct rpm_clk_desc *desc;
  461. +
  462. + rpm = dev_get_drvdata(pdev->dev.parent);
  463. + if (!rpm) {
  464. + dev_err(&pdev->dev, "Unable to retrieve handle to RPM\n");
  465. + return -ENODEV;
  466. + }
  467. +
  468. + desc = of_device_get_match_data(&pdev->dev);
  469. + if (!desc)
  470. + return -EINVAL;
  471. +
  472. + rpm_clks = desc->clks;
  473. + num_clks = desc->num_clks;
  474. +
  475. + rcc = devm_kzalloc(&pdev->dev, sizeof(*rcc) + sizeof(*hws) * num_clks,
  476. + GFP_KERNEL);
  477. + if (!rcc)
  478. + return -ENOMEM;
  479. +
  480. + hws = rcc->hws;
  481. + data = &rcc->data;
  482. + data->num = num_clks;
  483. +
  484. + for (i = 0; i < num_clks; i++) {
  485. + if (!rpm_clks[i])
  486. + continue;
  487. +
  488. + rpm_clks[i]->rpm = rpm;
  489. +
  490. + ret = clk_rpm_handoff(rpm_clks[i]);
  491. + if (ret)
  492. + goto err;
  493. + }
  494. +
  495. + for (i = 0; i < num_clks; i++) {
  496. + if (!rpm_clks[i]) {
  497. + data->hws[i] = ERR_PTR(-ENOENT);
  498. + continue;
  499. + }
  500. +
  501. + ret = devm_clk_hw_register(&pdev->dev, &rpm_clks[i]->hw);
  502. + if (ret)
  503. + goto err;
  504. + }
  505. +
  506. + ret = of_clk_add_hw_provider(pdev->dev.of_node, of_clk_hw_onecell_get,
  507. + data);
  508. + if (ret)
  509. + goto err;
  510. +
  511. + return 0;
  512. +err:
  513. + dev_err(&pdev->dev, "Error registering RPM Clock driver (%d)\n", ret);
  514. + return ret;
  515. +}
  516. +
  517. +static int rpm_clk_remove(struct platform_device *pdev)
  518. +{
  519. + of_clk_del_provider(pdev->dev.of_node);
  520. + return 0;
  521. +}
  522. +
  523. +static struct platform_driver rpm_clk_driver = {
  524. + .driver = {
  525. + .name = "qcom-clk-rpm",
  526. + .of_match_table = rpm_clk_match_table,
  527. + },
  528. + .probe = rpm_clk_probe,
  529. + .remove = rpm_clk_remove,
  530. +};
  531. +
  532. +static int __init rpm_clk_init(void)
  533. +{
  534. + return platform_driver_register(&rpm_clk_driver);
  535. +}
  536. +core_initcall(rpm_clk_init);
  537. +
  538. +static void __exit rpm_clk_exit(void)
  539. +{
  540. + platform_driver_unregister(&rpm_clk_driver);
  541. +}
  542. +module_exit(rpm_clk_exit);
  543. +
  544. +MODULE_DESCRIPTION("Qualcomm RPM Clock Controller Driver");
  545. +MODULE_LICENSE("GPL v2");
  546. +MODULE_ALIAS("platform:qcom-clk-rpm");
  547. --- a/include/dt-bindings/clock/qcom,rpmcc.h
  548. +++ b/include/dt-bindings/clock/qcom,rpmcc.h
  549. @@ -14,6 +14,30 @@
  550. #ifndef _DT_BINDINGS_CLK_MSM_RPMCC_H
  551. #define _DT_BINDINGS_CLK_MSM_RPMCC_H
  552. +/* apq8064 */
  553. +#define RPM_PXO_CLK 0
  554. +#define RPM_PXO_A_CLK 1
  555. +#define RPM_CXO_CLK 2
  556. +#define RPM_CXO_A_CLK 3
  557. +#define RPM_APPS_FABRIC_CLK 4
  558. +#define RPM_APPS_FABRIC_A_CLK 5
  559. +#define RPM_CFPB_CLK 6
  560. +#define RPM_CFPB_A_CLK 7
  561. +#define RPM_QDSS_CLK 8
  562. +#define RPM_QDSS_A_CLK 9
  563. +#define RPM_DAYTONA_FABRIC_CLK 10
  564. +#define RPM_DAYTONA_FABRIC_A_CLK 11
  565. +#define RPM_EBI1_CLK 12
  566. +#define RPM_EBI1_A_CLK 13
  567. +#define RPM_MM_FABRIC_CLK 14
  568. +#define RPM_MM_FABRIC_A_CLK 15
  569. +#define RPM_MMFPB_CLK 16
  570. +#define RPM_MMFPB_A_CLK 17
  571. +#define RPM_SYS_FABRIC_CLK 18
  572. +#define RPM_SYS_FABRIC_A_CLK 19
  573. +#define RPM_SFPB_CLK 20
  574. +#define RPM_SFPB_A_CLK 21
  575. +
  576. /* msm8916 */
  577. #define RPM_SMD_XO_CLK_SRC 0
  578. #define RPM_SMD_XO_A_CLK_SRC 1