qcom-cpufreq-nvmem.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2018, The Linux Foundation. All rights reserved.
  4. */
  5. /*
  6. * In Certain QCOM SoCs like apq8096 and msm8996 that have KRYO processors,
  7. * the CPU frequency subset and voltage value of each OPP varies
  8. * based on the silicon variant in use. Qualcomm Process Voltage Scaling Tables
  9. * defines the voltage and frequency value based on the msm-id in SMEM
  10. * and speedbin blown in the efuse combination.
  11. * The qcom-cpufreq-nvmem driver reads the msm-id and efuse value from the SoC
  12. * to provide the OPP framework with required information.
  13. * This is used to determine the voltage and frequency value for each OPP of
  14. * operating-points-v2 table when it is parsed by the OPP framework.
  15. */
  16. #include <linux/cpu.h>
  17. #include <linux/err.h>
  18. #include <linux/init.h>
  19. #include <linux/kernel.h>
  20. #include <linux/module.h>
  21. #include <linux/nvmem-consumer.h>
  22. #include <linux/of.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/pm.h>
  25. #include <linux/pm_domain.h>
  26. #include <linux/pm_opp.h>
  27. #include <linux/pm_runtime.h>
  28. #include <linux/slab.h>
  29. #include <linux/soc/qcom/smem.h>
  30. #include <dt-bindings/arm/qcom,ids.h>
  31. enum ipq806x_versions {
  32. IPQ8062_VERSION = 0,
  33. IPQ8064_VERSION,
  34. IPQ8065_VERSION,
  35. };
  36. #define IPQ6000_VERSION BIT(2)
  37. enum ipq8074_versions {
  38. IPQ8074_HAWKEYE_VERSION = 0,
  39. IPQ8074_ACORN_VERSION,
  40. };
  41. struct qcom_cpufreq_drv;
  42. struct qcom_cpufreq_match_data {
  43. int (*get_version)(struct device *cpu_dev,
  44. struct nvmem_cell *speedbin_nvmem,
  45. char **pvs_name,
  46. struct qcom_cpufreq_drv *drv);
  47. const char **genpd_names;
  48. };
  49. struct qcom_cpufreq_drv_cpu {
  50. int opp_token;
  51. struct device **virt_devs;
  52. };
  53. struct qcom_cpufreq_drv {
  54. u32 versions;
  55. const struct qcom_cpufreq_match_data *data;
  56. struct qcom_cpufreq_drv_cpu cpus[];
  57. };
  58. static struct platform_device *cpufreq_dt_pdev, *cpufreq_pdev;
  59. static int qcom_cpufreq_simple_get_version(struct device *cpu_dev,
  60. struct nvmem_cell *speedbin_nvmem,
  61. char **pvs_name,
  62. struct qcom_cpufreq_drv *drv)
  63. {
  64. u8 *speedbin;
  65. *pvs_name = NULL;
  66. speedbin = nvmem_cell_read(speedbin_nvmem, NULL);
  67. if (IS_ERR(speedbin))
  68. return PTR_ERR(speedbin);
  69. dev_dbg(cpu_dev, "speedbin: %d\n", *speedbin);
  70. drv->versions = 1 << *speedbin;
  71. kfree(speedbin);
  72. return 0;
  73. }
  74. static void get_krait_bin_format_a(struct device *cpu_dev,
  75. int *speed, int *pvs,
  76. u8 *buf)
  77. {
  78. u32 pte_efuse;
  79. pte_efuse = *((u32 *)buf);
  80. *speed = pte_efuse & 0xf;
  81. if (*speed == 0xf)
  82. *speed = (pte_efuse >> 4) & 0xf;
  83. if (*speed == 0xf) {
  84. *speed = 0;
  85. dev_warn(cpu_dev, "Speed bin: Defaulting to %d\n", *speed);
  86. } else {
  87. dev_dbg(cpu_dev, "Speed bin: %d\n", *speed);
  88. }
  89. *pvs = (pte_efuse >> 10) & 0x7;
  90. if (*pvs == 0x7)
  91. *pvs = (pte_efuse >> 13) & 0x7;
  92. if (*pvs == 0x7) {
  93. *pvs = 0;
  94. dev_warn(cpu_dev, "PVS bin: Defaulting to %d\n", *pvs);
  95. } else {
  96. dev_dbg(cpu_dev, "PVS bin: %d\n", *pvs);
  97. }
  98. }
  99. static void get_krait_bin_format_b(struct device *cpu_dev,
  100. int *speed, int *pvs, int *pvs_ver,
  101. u8 *buf)
  102. {
  103. u32 pte_efuse, redundant_sel;
  104. pte_efuse = *((u32 *)buf);
  105. redundant_sel = (pte_efuse >> 24) & 0x7;
  106. *pvs_ver = (pte_efuse >> 4) & 0x3;
  107. switch (redundant_sel) {
  108. case 1:
  109. *pvs = ((pte_efuse >> 28) & 0x8) | ((pte_efuse >> 6) & 0x7);
  110. *speed = (pte_efuse >> 27) & 0xf;
  111. break;
  112. case 2:
  113. *pvs = (pte_efuse >> 27) & 0xf;
  114. *speed = pte_efuse & 0x7;
  115. break;
  116. default:
  117. /* 4 bits of PVS are in efuse register bits 31, 8-6. */
  118. *pvs = ((pte_efuse >> 28) & 0x8) | ((pte_efuse >> 6) & 0x7);
  119. *speed = pte_efuse & 0x7;
  120. }
  121. /* Check SPEED_BIN_BLOW_STATUS */
  122. if (pte_efuse & BIT(3)) {
  123. dev_dbg(cpu_dev, "Speed bin: %d\n", *speed);
  124. } else {
  125. dev_warn(cpu_dev, "Speed bin not set. Defaulting to 0!\n");
  126. *speed = 0;
  127. }
  128. /* Check PVS_BLOW_STATUS */
  129. pte_efuse = *(((u32 *)buf) + 1);
  130. pte_efuse &= BIT(21);
  131. if (pte_efuse) {
  132. dev_dbg(cpu_dev, "PVS bin: %d\n", *pvs);
  133. } else {
  134. dev_warn(cpu_dev, "PVS bin not set. Defaulting to 0!\n");
  135. *pvs = 0;
  136. }
  137. dev_dbg(cpu_dev, "PVS version: %d\n", *pvs_ver);
  138. }
  139. static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
  140. struct nvmem_cell *speedbin_nvmem,
  141. char **pvs_name,
  142. struct qcom_cpufreq_drv *drv)
  143. {
  144. size_t len;
  145. u32 msm_id;
  146. u8 *speedbin;
  147. int ret;
  148. *pvs_name = NULL;
  149. ret = qcom_smem_get_soc_id(&msm_id);
  150. if (ret)
  151. return ret;
  152. speedbin = nvmem_cell_read(speedbin_nvmem, &len);
  153. if (IS_ERR(speedbin))
  154. return PTR_ERR(speedbin);
  155. switch (msm_id) {
  156. case QCOM_ID_MSM8996:
  157. case QCOM_ID_APQ8096:
  158. case QCOM_ID_IPQ5332:
  159. case QCOM_ID_IPQ5322:
  160. case QCOM_ID_IPQ5312:
  161. case QCOM_ID_IPQ5302:
  162. case QCOM_ID_IPQ5300:
  163. case QCOM_ID_IPQ5321:
  164. case QCOM_ID_IPQ9514:
  165. case QCOM_ID_IPQ9550:
  166. case QCOM_ID_IPQ9554:
  167. case QCOM_ID_IPQ9570:
  168. case QCOM_ID_IPQ9574:
  169. drv->versions = 1 << (unsigned int)(*speedbin);
  170. break;
  171. case QCOM_ID_MSM8996SG:
  172. case QCOM_ID_APQ8096SG:
  173. drv->versions = 1 << ((unsigned int)(*speedbin) + 4);
  174. break;
  175. default:
  176. BUG();
  177. break;
  178. }
  179. kfree(speedbin);
  180. return 0;
  181. }
  182. static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,
  183. struct nvmem_cell *speedbin_nvmem,
  184. char **pvs_name,
  185. struct qcom_cpufreq_drv *drv)
  186. {
  187. int speed = 0, pvs = 0, pvs_ver = 0;
  188. u8 *speedbin;
  189. size_t len;
  190. int ret = 0;
  191. speedbin = nvmem_cell_read(speedbin_nvmem, &len);
  192. if (IS_ERR(speedbin))
  193. return PTR_ERR(speedbin);
  194. switch (len) {
  195. case 4:
  196. get_krait_bin_format_a(cpu_dev, &speed, &pvs, speedbin);
  197. break;
  198. case 8:
  199. get_krait_bin_format_b(cpu_dev, &speed, &pvs, &pvs_ver,
  200. speedbin);
  201. break;
  202. default:
  203. dev_err(cpu_dev, "Unable to read nvmem data. Defaulting to 0!\n");
  204. ret = -ENODEV;
  205. goto len_error;
  206. }
  207. snprintf(*pvs_name, sizeof("speedXX-pvsXX-vXX"), "speed%d-pvs%d-v%d",
  208. speed, pvs, pvs_ver);
  209. drv->versions = (1 << speed);
  210. len_error:
  211. kfree(speedbin);
  212. return ret;
  213. }
  214. static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev,
  215. struct nvmem_cell *speedbin_nvmem,
  216. char **pvs_name,
  217. struct qcom_cpufreq_drv *drv)
  218. {
  219. int speed = 0, pvs = 0;
  220. int msm_id, ret = 0;
  221. u8 *speedbin;
  222. size_t len;
  223. speedbin = nvmem_cell_read(speedbin_nvmem, &len);
  224. if (IS_ERR(speedbin))
  225. return PTR_ERR(speedbin);
  226. if (len != 4) {
  227. dev_err(cpu_dev, "Unable to read nvmem data. Defaulting to 0!\n");
  228. ret = -ENODEV;
  229. goto exit;
  230. }
  231. get_krait_bin_format_a(cpu_dev, &speed, &pvs, speedbin);
  232. ret = qcom_smem_get_soc_id(&msm_id);
  233. if (ret)
  234. goto exit;
  235. switch (msm_id) {
  236. case QCOM_ID_IPQ8062:
  237. drv->versions = BIT(IPQ8062_VERSION);
  238. break;
  239. case QCOM_ID_IPQ8064:
  240. case QCOM_ID_IPQ8066:
  241. case QCOM_ID_IPQ8068:
  242. drv->versions = BIT(IPQ8064_VERSION);
  243. break;
  244. case QCOM_ID_IPQ8065:
  245. case QCOM_ID_IPQ8069:
  246. drv->versions = BIT(IPQ8065_VERSION);
  247. break;
  248. default:
  249. dev_err(cpu_dev,
  250. "SoC ID %u is not part of IPQ8064 family, limiting to 1.0GHz!\n",
  251. msm_id);
  252. drv->versions = BIT(IPQ8062_VERSION);
  253. break;
  254. }
  255. /* IPQ8064 speed is never fused. Only pvs values are fused. */
  256. snprintf(*pvs_name, sizeof("speed0-pvsXX"), "speed0-pvs%d", pvs);
  257. exit:
  258. kfree(speedbin);
  259. return ret;
  260. }
  261. static int qcom_cpufreq_ipq6018_name_version(struct device *cpu_dev,
  262. struct nvmem_cell *speedbin_nvmem,
  263. char **pvs_name,
  264. struct qcom_cpufreq_drv *drv)
  265. {
  266. u32 msm_id;
  267. int ret;
  268. u8 *speedbin;
  269. *pvs_name = NULL;
  270. ret = qcom_smem_get_soc_id(&msm_id);
  271. if (ret)
  272. return ret;
  273. speedbin = nvmem_cell_read(speedbin_nvmem, NULL);
  274. if (IS_ERR(speedbin))
  275. return PTR_ERR(speedbin);
  276. switch (msm_id) {
  277. case QCOM_ID_IPQ6005:
  278. case QCOM_ID_IPQ6010:
  279. case QCOM_ID_IPQ6018:
  280. case QCOM_ID_IPQ6028:
  281. /* Fuse Value Freq BIT to set
  282. * ---------------------------------
  283. * 2’b0 No Limit BIT(0)
  284. * 2’b1 1.5 GHz BIT(1)
  285. */
  286. drv->versions = 1 << (unsigned int)(*speedbin);
  287. break;
  288. case QCOM_ID_IPQ6000:
  289. /*
  290. * IPQ6018 family only has one bit to advertise the CPU
  291. * speed-bin, but that is not enough for IPQ6000 which
  292. * is only rated up to 1.2GHz.
  293. * So for IPQ6000 manually set BIT(2) based on SMEM ID.
  294. */
  295. drv->versions = IPQ6000_VERSION;
  296. break;
  297. default:
  298. dev_err(cpu_dev,
  299. "SoC ID %u is not part of IPQ6018 family, limiting to 1.2GHz!\n",
  300. msm_id);
  301. drv->versions = IPQ6000_VERSION;
  302. break;
  303. }
  304. kfree(speedbin);
  305. return 0;
  306. }
  307. static int qcom_cpufreq_ipq8074_name_version(struct device *cpu_dev,
  308. struct nvmem_cell *speedbin_nvmem,
  309. char **pvs_name,
  310. struct qcom_cpufreq_drv *drv)
  311. {
  312. u32 msm_id;
  313. int ret;
  314. *pvs_name = NULL;
  315. ret = qcom_smem_get_soc_id(&msm_id);
  316. if (ret)
  317. return ret;
  318. switch (msm_id) {
  319. case QCOM_ID_IPQ8070A:
  320. case QCOM_ID_IPQ8071A:
  321. case QCOM_ID_IPQ8172:
  322. case QCOM_ID_IPQ8173:
  323. case QCOM_ID_IPQ8174:
  324. drv->versions = BIT(IPQ8074_ACORN_VERSION);
  325. break;
  326. case QCOM_ID_IPQ8072A:
  327. case QCOM_ID_IPQ8074A:
  328. case QCOM_ID_IPQ8076A:
  329. case QCOM_ID_IPQ8078A:
  330. drv->versions = BIT(IPQ8074_HAWKEYE_VERSION);
  331. break;
  332. default:
  333. dev_err(cpu_dev,
  334. "SoC ID %u is not part of IPQ8074 family, limiting to 1.4GHz!\n",
  335. msm_id);
  336. drv->versions = BIT(IPQ8074_ACORN_VERSION);
  337. break;
  338. }
  339. return 0;
  340. }
  341. static const char *generic_genpd_names[] = { "perf", NULL };
  342. static const struct qcom_cpufreq_match_data match_data_kryo = {
  343. .get_version = qcom_cpufreq_kryo_name_version,
  344. };
  345. static const struct qcom_cpufreq_match_data match_data_krait = {
  346. .get_version = qcom_cpufreq_krait_name_version,
  347. };
  348. static const struct qcom_cpufreq_match_data match_data_msm8909 = {
  349. .get_version = qcom_cpufreq_simple_get_version,
  350. .genpd_names = generic_genpd_names,
  351. };
  352. static const char *qcs404_genpd_names[] = { "cpr", NULL };
  353. static const struct qcom_cpufreq_match_data match_data_qcs404 = {
  354. .genpd_names = qcs404_genpd_names,
  355. };
  356. static const struct qcom_cpufreq_match_data match_data_ipq6018 = {
  357. .get_version = qcom_cpufreq_ipq6018_name_version,
  358. };
  359. static const struct qcom_cpufreq_match_data match_data_ipq8064 = {
  360. .get_version = qcom_cpufreq_ipq8064_name_version,
  361. };
  362. static const struct qcom_cpufreq_match_data match_data_ipq8074 = {
  363. .get_version = qcom_cpufreq_ipq8074_name_version,
  364. };
  365. static void qcom_cpufreq_suspend_virt_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu)
  366. {
  367. const char * const *name = drv->data->genpd_names;
  368. int i;
  369. if (!drv->cpus[cpu].virt_devs)
  370. return;
  371. for (i = 0; *name; i++, name++)
  372. device_set_awake_path(drv->cpus[cpu].virt_devs[i]);
  373. }
  374. static void qcom_cpufreq_put_virt_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu)
  375. {
  376. const char * const *name = drv->data->genpd_names;
  377. int i;
  378. if (!drv->cpus[cpu].virt_devs)
  379. return;
  380. for (i = 0; *name; i++, name++)
  381. pm_runtime_put(drv->cpus[cpu].virt_devs[i]);
  382. }
  383. static int qcom_cpufreq_probe(struct platform_device *pdev)
  384. {
  385. struct qcom_cpufreq_drv *drv;
  386. struct nvmem_cell *speedbin_nvmem;
  387. struct device *cpu_dev;
  388. char pvs_name_buffer[] = "speedXX-pvsXX-vXX";
  389. char *pvs_name = pvs_name_buffer;
  390. unsigned cpu;
  391. const struct of_device_id *match;
  392. int ret;
  393. cpu_dev = get_cpu_device(0);
  394. if (!cpu_dev)
  395. return -ENODEV;
  396. struct device_node *np __free(device_node) =
  397. dev_pm_opp_of_get_opp_desc_node(cpu_dev);
  398. if (!np)
  399. return -ENOENT;
  400. ret = of_device_is_compatible(np, "operating-points-v2-kryo-cpu") ||
  401. of_device_is_compatible(np, "operating-points-v2-krait-cpu");
  402. if (!ret)
  403. return -ENOENT;
  404. drv = devm_kzalloc(&pdev->dev, struct_size(drv, cpus, num_possible_cpus()),
  405. GFP_KERNEL);
  406. if (!drv)
  407. return -ENOMEM;
  408. match = pdev->dev.platform_data;
  409. drv->data = match->data;
  410. if (!drv->data)
  411. return -ENODEV;
  412. if (drv->data->get_version) {
  413. speedbin_nvmem = of_nvmem_cell_get(np, NULL);
  414. if (IS_ERR(speedbin_nvmem))
  415. return dev_err_probe(cpu_dev, PTR_ERR(speedbin_nvmem),
  416. "Could not get nvmem cell\n");
  417. ret = drv->data->get_version(cpu_dev,
  418. speedbin_nvmem, &pvs_name, drv);
  419. if (ret) {
  420. nvmem_cell_put(speedbin_nvmem);
  421. return ret;
  422. }
  423. nvmem_cell_put(speedbin_nvmem);
  424. }
  425. for_each_possible_cpu(cpu) {
  426. struct device **virt_devs = NULL;
  427. struct dev_pm_opp_config config = {
  428. .supported_hw = NULL,
  429. };
  430. cpu_dev = get_cpu_device(cpu);
  431. if (NULL == cpu_dev) {
  432. ret = -ENODEV;
  433. goto free_opp;
  434. }
  435. if (drv->data->get_version) {
  436. config.supported_hw = &drv->versions;
  437. config.supported_hw_count = 1;
  438. if (pvs_name)
  439. config.prop_name = pvs_name;
  440. }
  441. if (drv->data->genpd_names) {
  442. config.genpd_names = drv->data->genpd_names;
  443. config.virt_devs = &virt_devs;
  444. }
  445. if (config.supported_hw || config.genpd_names) {
  446. drv->cpus[cpu].opp_token = dev_pm_opp_set_config(cpu_dev, &config);
  447. if (drv->cpus[cpu].opp_token < 0) {
  448. ret = drv->cpus[cpu].opp_token;
  449. dev_err(cpu_dev, "Failed to set OPP config\n");
  450. goto free_opp;
  451. }
  452. }
  453. if (virt_devs) {
  454. const char * const *name = config.genpd_names;
  455. int i, j;
  456. for (i = 0; *name; i++, name++) {
  457. ret = pm_runtime_resume_and_get(virt_devs[i]);
  458. if (ret) {
  459. dev_err(cpu_dev, "failed to resume %s: %d\n",
  460. *name, ret);
  461. /* Rollback previous PM runtime calls */
  462. name = config.genpd_names;
  463. for (j = 0; *name && j < i; j++, name++)
  464. pm_runtime_put(virt_devs[j]);
  465. goto free_opp;
  466. }
  467. }
  468. drv->cpus[cpu].virt_devs = virt_devs;
  469. }
  470. }
  471. cpufreq_dt_pdev = platform_device_register_simple("cpufreq-dt", -1,
  472. NULL, 0);
  473. if (!IS_ERR(cpufreq_dt_pdev)) {
  474. platform_set_drvdata(pdev, drv);
  475. return 0;
  476. }
  477. ret = PTR_ERR(cpufreq_dt_pdev);
  478. dev_err(cpu_dev, "Failed to register platform device\n");
  479. free_opp:
  480. for_each_possible_cpu(cpu) {
  481. qcom_cpufreq_put_virt_devs(drv, cpu);
  482. dev_pm_opp_clear_config(drv->cpus[cpu].opp_token);
  483. }
  484. return ret;
  485. }
  486. static void qcom_cpufreq_remove(struct platform_device *pdev)
  487. {
  488. struct qcom_cpufreq_drv *drv = platform_get_drvdata(pdev);
  489. unsigned int cpu;
  490. platform_device_unregister(cpufreq_dt_pdev);
  491. for_each_possible_cpu(cpu) {
  492. qcom_cpufreq_put_virt_devs(drv, cpu);
  493. dev_pm_opp_clear_config(drv->cpus[cpu].opp_token);
  494. }
  495. }
  496. static int qcom_cpufreq_suspend(struct device *dev)
  497. {
  498. struct qcom_cpufreq_drv *drv = dev_get_drvdata(dev);
  499. unsigned int cpu;
  500. for_each_possible_cpu(cpu)
  501. qcom_cpufreq_suspend_virt_devs(drv, cpu);
  502. return 0;
  503. }
  504. static DEFINE_SIMPLE_DEV_PM_OPS(qcom_cpufreq_pm_ops, qcom_cpufreq_suspend, NULL);
  505. static struct platform_driver qcom_cpufreq_driver = {
  506. .probe = qcom_cpufreq_probe,
  507. .remove_new = qcom_cpufreq_remove,
  508. .driver = {
  509. .name = "qcom-cpufreq-nvmem",
  510. .pm = pm_sleep_ptr(&qcom_cpufreq_pm_ops),
  511. },
  512. };
  513. static const struct of_device_id qcom_cpufreq_match_list[] __initconst __maybe_unused = {
  514. { .compatible = "qcom,apq8096", .data = &match_data_kryo },
  515. { .compatible = "qcom,msm8909", .data = &match_data_msm8909 },
  516. { .compatible = "qcom,msm8996", .data = &match_data_kryo },
  517. { .compatible = "qcom,qcs404", .data = &match_data_qcs404 },
  518. { .compatible = "qcom,ipq5332", .data = &match_data_kryo },
  519. { .compatible = "qcom,ipq6018", .data = &match_data_ipq6018 },
  520. { .compatible = "qcom,ipq8064", .data = &match_data_ipq8064 },
  521. { .compatible = "qcom,ipq8074", .data = &match_data_ipq8074 },
  522. { .compatible = "qcom,apq8064", .data = &match_data_krait },
  523. { .compatible = "qcom,ipq9574", .data = &match_data_kryo },
  524. { .compatible = "qcom,msm8974", .data = &match_data_krait },
  525. { .compatible = "qcom,msm8960", .data = &match_data_krait },
  526. {},
  527. };
  528. MODULE_DEVICE_TABLE(of, qcom_cpufreq_match_list);
  529. /*
  530. * Since the driver depends on smem and nvmem drivers, which may
  531. * return EPROBE_DEFER, all the real activity is done in the probe,
  532. * which may be defered as well. The init here is only registering
  533. * the driver and the platform device.
  534. */
  535. static int __init qcom_cpufreq_init(void)
  536. {
  537. struct device_node *np __free(device_node) = of_find_node_by_path("/");
  538. const struct of_device_id *match;
  539. int ret;
  540. if (!np)
  541. return -ENODEV;
  542. match = of_match_node(qcom_cpufreq_match_list, np);
  543. if (!match)
  544. return -ENODEV;
  545. ret = platform_driver_register(&qcom_cpufreq_driver);
  546. if (unlikely(ret < 0))
  547. return ret;
  548. cpufreq_pdev = platform_device_register_data(NULL, "qcom-cpufreq-nvmem",
  549. -1, match, sizeof(*match));
  550. ret = PTR_ERR_OR_ZERO(cpufreq_pdev);
  551. if (0 == ret)
  552. return 0;
  553. platform_driver_unregister(&qcom_cpufreq_driver);
  554. return ret;
  555. }
  556. module_init(qcom_cpufreq_init);
  557. static void __exit qcom_cpufreq_exit(void)
  558. {
  559. platform_device_unregister(cpufreq_pdev);
  560. platform_driver_unregister(&qcom_cpufreq_driver);
  561. }
  562. module_exit(qcom_cpufreq_exit);
  563. MODULE_DESCRIPTION("Qualcomm Technologies, Inc. CPUfreq driver");
  564. MODULE_LICENSE("GPL v2");