qcom-rpmh-regulator.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright (c) 2018, The Linux Foundation. All rights reserved.
  3. #define pr_fmt(fmt) "%s: " fmt, __func__
  4. #include <linux/err.h>
  5. #include <linux/kernel.h>
  6. #include <linux/module.h>
  7. #include <linux/of.h>
  8. #include <linux/of_device.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/slab.h>
  11. #include <linux/string.h>
  12. #include <linux/regulator/driver.h>
  13. #include <linux/regulator/machine.h>
  14. #include <linux/regulator/of_regulator.h>
  15. #include <soc/qcom/cmd-db.h>
  16. #include <soc/qcom/rpmh.h>
  17. #include <dt-bindings/regulator/qcom,rpmh-regulator.h>
  18. /**
  19. * enum rpmh_regulator_type - supported RPMh accelerator types
  20. * %VRM: RPMh VRM accelerator which supports voting on enable, voltage,
  21. * and mode of LDO, SMPS, and BOB type PMIC regulators.
  22. * %XOB: RPMh XOB accelerator which supports voting on the enable state
  23. * of PMIC regulators.
  24. */
  25. enum rpmh_regulator_type {
  26. VRM,
  27. XOB,
  28. };
  29. #define RPMH_REGULATOR_REG_VRM_VOLTAGE 0x0
  30. #define RPMH_REGULATOR_REG_ENABLE 0x4
  31. #define RPMH_REGULATOR_REG_VRM_MODE 0x8
  32. #define PMIC4_LDO_MODE_RETENTION 4
  33. #define PMIC4_LDO_MODE_LPM 5
  34. #define PMIC4_LDO_MODE_HPM 7
  35. #define PMIC4_SMPS_MODE_RETENTION 4
  36. #define PMIC4_SMPS_MODE_PFM 5
  37. #define PMIC4_SMPS_MODE_AUTO 6
  38. #define PMIC4_SMPS_MODE_PWM 7
  39. #define PMIC4_BOB_MODE_PASS 0
  40. #define PMIC4_BOB_MODE_PFM 1
  41. #define PMIC4_BOB_MODE_AUTO 2
  42. #define PMIC4_BOB_MODE_PWM 3
  43. #define PMIC5_LDO_MODE_RETENTION 3
  44. #define PMIC5_LDO_MODE_LPM 4
  45. #define PMIC5_LDO_MODE_HPM 7
  46. #define PMIC5_SMPS_MODE_RETENTION 3
  47. #define PMIC5_SMPS_MODE_PFM 4
  48. #define PMIC5_SMPS_MODE_AUTO 6
  49. #define PMIC5_SMPS_MODE_PWM 7
  50. #define PMIC5_BOB_MODE_PASS 2
  51. #define PMIC5_BOB_MODE_PFM 4
  52. #define PMIC5_BOB_MODE_AUTO 6
  53. #define PMIC5_BOB_MODE_PWM 7
  54. /**
  55. * struct rpmh_vreg_hw_data - RPMh regulator hardware configurations
  56. * @regulator_type: RPMh accelerator type used to manage this
  57. * regulator
  58. * @ops: Pointer to regulator ops callback structure
  59. * @voltage_range: The single range of voltages supported by this
  60. * PMIC regulator type
  61. * @n_voltages: The number of unique voltage set points defined
  62. * by voltage_range
  63. * @hpm_min_load_uA: Minimum load current in microamps that requires
  64. * high power mode (HPM) operation. This is used
  65. * for LDO hardware type regulators only.
  66. * @pmic_mode_map: Array indexed by regulator framework mode
  67. * containing PMIC hardware modes. Must be large
  68. * enough to index all framework modes supported
  69. * by this regulator hardware type.
  70. * @of_map_mode: Maps an RPMH_REGULATOR_MODE_* mode value defined
  71. * in device tree to a regulator framework mode
  72. */
  73. struct rpmh_vreg_hw_data {
  74. enum rpmh_regulator_type regulator_type;
  75. const struct regulator_ops *ops;
  76. const struct regulator_linear_range voltage_range;
  77. int n_voltages;
  78. int hpm_min_load_uA;
  79. const int *pmic_mode_map;
  80. unsigned int (*of_map_mode)(unsigned int mode);
  81. };
  82. /**
  83. * struct rpmh_vreg - individual RPMh regulator data structure encapsulating a
  84. * single regulator device
  85. * @dev: Device pointer for the top-level PMIC RPMh
  86. * regulator parent device. This is used as a
  87. * handle in RPMh write requests.
  88. * @addr: Base address of the regulator resource within
  89. * an RPMh accelerator
  90. * @rdesc: Regulator descriptor
  91. * @hw_data: PMIC regulator configuration data for this RPMh
  92. * regulator
  93. * @always_wait_for_ack: Boolean flag indicating if a request must always
  94. * wait for an ACK from RPMh before continuing even
  95. * if it corresponds to a strictly lower power
  96. * state (e.g. enabled --> disabled).
  97. * @enabled: Flag indicating if the regulator is enabled or
  98. * not
  99. * @bypassed: Boolean indicating if the regulator is in
  100. * bypass (pass-through) mode or not. This is
  101. * only used by BOB rpmh-regulator resources.
  102. * @voltage_selector: Selector used for get_voltage_sel() and
  103. * set_voltage_sel() callbacks
  104. * @mode: RPMh VRM regulator current framework mode
  105. */
  106. struct rpmh_vreg {
  107. struct device *dev;
  108. u32 addr;
  109. struct regulator_desc rdesc;
  110. const struct rpmh_vreg_hw_data *hw_data;
  111. bool always_wait_for_ack;
  112. int enabled;
  113. bool bypassed;
  114. int voltage_selector;
  115. unsigned int mode;
  116. };
  117. /**
  118. * struct rpmh_vreg_init_data - initialization data for an RPMh regulator
  119. * @name: Name for the regulator which also corresponds
  120. * to the device tree subnode name of the regulator
  121. * @resource_name: RPMh regulator resource name format string.
  122. * This must include exactly one field: '%s' which
  123. * is filled at run-time with the PMIC ID provided
  124. * by device tree property qcom,pmic-id. Example:
  125. * "ldo%s1" for RPMh resource "ldoa1".
  126. * @supply_name: Parent supply regulator name
  127. * @hw_data: Configuration data for this PMIC regulator type
  128. */
  129. struct rpmh_vreg_init_data {
  130. const char *name;
  131. const char *resource_name;
  132. const char *supply_name;
  133. const struct rpmh_vreg_hw_data *hw_data;
  134. };
  135. /**
  136. * rpmh_regulator_send_request() - send the request to RPMh
  137. * @vreg: Pointer to the RPMh regulator
  138. * @cmd: Pointer to the RPMh command to send
  139. * @wait_for_ack: Boolean indicating if execution must wait until the
  140. * request has been acknowledged as complete
  141. *
  142. * Return: 0 on success, errno on failure
  143. */
  144. static int rpmh_regulator_send_request(struct rpmh_vreg *vreg,
  145. struct tcs_cmd *cmd, bool wait_for_ack)
  146. {
  147. int ret;
  148. if (wait_for_ack || vreg->always_wait_for_ack)
  149. ret = rpmh_write(vreg->dev, RPMH_ACTIVE_ONLY_STATE, cmd, 1);
  150. else
  151. ret = rpmh_write_async(vreg->dev, RPMH_ACTIVE_ONLY_STATE, cmd,
  152. 1);
  153. return ret;
  154. }
  155. static int _rpmh_regulator_vrm_set_voltage_sel(struct regulator_dev *rdev,
  156. unsigned int selector, bool wait_for_ack)
  157. {
  158. struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
  159. struct tcs_cmd cmd = {
  160. .addr = vreg->addr + RPMH_REGULATOR_REG_VRM_VOLTAGE,
  161. };
  162. int ret;
  163. /* VRM voltage control register is set with voltage in millivolts. */
  164. cmd.data = DIV_ROUND_UP(regulator_list_voltage_linear_range(rdev,
  165. selector), 1000);
  166. ret = rpmh_regulator_send_request(vreg, &cmd, wait_for_ack);
  167. if (!ret)
  168. vreg->voltage_selector = selector;
  169. return ret;
  170. }
  171. static int rpmh_regulator_vrm_set_voltage_sel(struct regulator_dev *rdev,
  172. unsigned int selector)
  173. {
  174. struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
  175. if (vreg->enabled == -EINVAL) {
  176. /*
  177. * Cache the voltage and send it later when the regulator is
  178. * enabled or disabled.
  179. */
  180. vreg->voltage_selector = selector;
  181. return 0;
  182. }
  183. return _rpmh_regulator_vrm_set_voltage_sel(rdev, selector,
  184. selector > vreg->voltage_selector);
  185. }
  186. static int rpmh_regulator_vrm_get_voltage_sel(struct regulator_dev *rdev)
  187. {
  188. struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
  189. return vreg->voltage_selector;
  190. }
  191. static int rpmh_regulator_is_enabled(struct regulator_dev *rdev)
  192. {
  193. struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
  194. return vreg->enabled;
  195. }
  196. static int rpmh_regulator_set_enable_state(struct regulator_dev *rdev,
  197. bool enable)
  198. {
  199. struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
  200. struct tcs_cmd cmd = {
  201. .addr = vreg->addr + RPMH_REGULATOR_REG_ENABLE,
  202. .data = enable,
  203. };
  204. int ret;
  205. if (vreg->enabled == -EINVAL &&
  206. vreg->voltage_selector != -ENOTRECOVERABLE) {
  207. ret = _rpmh_regulator_vrm_set_voltage_sel(rdev,
  208. vreg->voltage_selector, true);
  209. if (ret < 0)
  210. return ret;
  211. }
  212. ret = rpmh_regulator_send_request(vreg, &cmd, enable);
  213. if (!ret)
  214. vreg->enabled = enable;
  215. return ret;
  216. }
  217. static int rpmh_regulator_enable(struct regulator_dev *rdev)
  218. {
  219. return rpmh_regulator_set_enable_state(rdev, true);
  220. }
  221. static int rpmh_regulator_disable(struct regulator_dev *rdev)
  222. {
  223. return rpmh_regulator_set_enable_state(rdev, false);
  224. }
  225. static int rpmh_regulator_vrm_set_mode_bypass(struct rpmh_vreg *vreg,
  226. unsigned int mode, bool bypassed)
  227. {
  228. struct tcs_cmd cmd = {
  229. .addr = vreg->addr + RPMH_REGULATOR_REG_VRM_MODE,
  230. };
  231. int pmic_mode;
  232. if (mode > REGULATOR_MODE_STANDBY)
  233. return -EINVAL;
  234. pmic_mode = vreg->hw_data->pmic_mode_map[mode];
  235. if (pmic_mode < 0)
  236. return pmic_mode;
  237. if (bypassed)
  238. cmd.data = PMIC4_BOB_MODE_PASS;
  239. else
  240. cmd.data = pmic_mode;
  241. return rpmh_regulator_send_request(vreg, &cmd, true);
  242. }
  243. static int rpmh_regulator_vrm_set_mode(struct regulator_dev *rdev,
  244. unsigned int mode)
  245. {
  246. struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
  247. int ret;
  248. if (mode == vreg->mode)
  249. return 0;
  250. ret = rpmh_regulator_vrm_set_mode_bypass(vreg, mode, vreg->bypassed);
  251. if (!ret)
  252. vreg->mode = mode;
  253. return ret;
  254. }
  255. static unsigned int rpmh_regulator_vrm_get_mode(struct regulator_dev *rdev)
  256. {
  257. struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
  258. return vreg->mode;
  259. }
  260. /**
  261. * rpmh_regulator_vrm_set_load() - set the regulator mode based upon the load
  262. * current requested
  263. * @rdev: Regulator device pointer for the rpmh-regulator
  264. * @load_uA: Aggregated load current in microamps
  265. *
  266. * This function is used in the regulator_ops for VRM type RPMh regulator
  267. * devices.
  268. *
  269. * Return: 0 on success, errno on failure
  270. */
  271. static int rpmh_regulator_vrm_set_load(struct regulator_dev *rdev, int load_uA)
  272. {
  273. struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
  274. unsigned int mode;
  275. if (load_uA >= vreg->hw_data->hpm_min_load_uA)
  276. mode = REGULATOR_MODE_NORMAL;
  277. else
  278. mode = REGULATOR_MODE_IDLE;
  279. return rpmh_regulator_vrm_set_mode(rdev, mode);
  280. }
  281. static int rpmh_regulator_vrm_set_bypass(struct regulator_dev *rdev,
  282. bool enable)
  283. {
  284. struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
  285. int ret;
  286. if (vreg->bypassed == enable)
  287. return 0;
  288. ret = rpmh_regulator_vrm_set_mode_bypass(vreg, vreg->mode, enable);
  289. if (!ret)
  290. vreg->bypassed = enable;
  291. return ret;
  292. }
  293. static int rpmh_regulator_vrm_get_bypass(struct regulator_dev *rdev,
  294. bool *enable)
  295. {
  296. struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
  297. *enable = vreg->bypassed;
  298. return 0;
  299. }
  300. static const struct regulator_ops rpmh_regulator_vrm_ops = {
  301. .enable = rpmh_regulator_enable,
  302. .disable = rpmh_regulator_disable,
  303. .is_enabled = rpmh_regulator_is_enabled,
  304. .set_voltage_sel = rpmh_regulator_vrm_set_voltage_sel,
  305. .get_voltage_sel = rpmh_regulator_vrm_get_voltage_sel,
  306. .list_voltage = regulator_list_voltage_linear_range,
  307. .set_mode = rpmh_regulator_vrm_set_mode,
  308. .get_mode = rpmh_regulator_vrm_get_mode,
  309. };
  310. static const struct regulator_ops rpmh_regulator_vrm_drms_ops = {
  311. .enable = rpmh_regulator_enable,
  312. .disable = rpmh_regulator_disable,
  313. .is_enabled = rpmh_regulator_is_enabled,
  314. .set_voltage_sel = rpmh_regulator_vrm_set_voltage_sel,
  315. .get_voltage_sel = rpmh_regulator_vrm_get_voltage_sel,
  316. .list_voltage = regulator_list_voltage_linear_range,
  317. .set_mode = rpmh_regulator_vrm_set_mode,
  318. .get_mode = rpmh_regulator_vrm_get_mode,
  319. .set_load = rpmh_regulator_vrm_set_load,
  320. };
  321. static const struct regulator_ops rpmh_regulator_vrm_bypass_ops = {
  322. .enable = rpmh_regulator_enable,
  323. .disable = rpmh_regulator_disable,
  324. .is_enabled = rpmh_regulator_is_enabled,
  325. .set_voltage_sel = rpmh_regulator_vrm_set_voltage_sel,
  326. .get_voltage_sel = rpmh_regulator_vrm_get_voltage_sel,
  327. .list_voltage = regulator_list_voltage_linear_range,
  328. .set_mode = rpmh_regulator_vrm_set_mode,
  329. .get_mode = rpmh_regulator_vrm_get_mode,
  330. .set_bypass = rpmh_regulator_vrm_set_bypass,
  331. .get_bypass = rpmh_regulator_vrm_get_bypass,
  332. };
  333. static const struct regulator_ops rpmh_regulator_xob_ops = {
  334. .enable = rpmh_regulator_enable,
  335. .disable = rpmh_regulator_disable,
  336. .is_enabled = rpmh_regulator_is_enabled,
  337. };
  338. /**
  339. * rpmh_regulator_init_vreg() - initialize all attributes of an rpmh-regulator
  340. * vreg: Pointer to the individual rpmh-regulator resource
  341. * dev: Pointer to the top level rpmh-regulator PMIC device
  342. * node: Pointer to the individual rpmh-regulator resource
  343. * device node
  344. * pmic_id: String used to identify the top level rpmh-regulator
  345. * PMIC device on the board
  346. * pmic_rpmh_data: Pointer to a null-terminated array of rpmh-regulator
  347. * resources defined for the top level PMIC device
  348. *
  349. * Return: 0 on success, errno on failure
  350. */
  351. static int rpmh_regulator_init_vreg(struct rpmh_vreg *vreg, struct device *dev,
  352. struct device_node *node, const char *pmic_id,
  353. const struct rpmh_vreg_init_data *pmic_rpmh_data)
  354. {
  355. struct regulator_config reg_config = {};
  356. char rpmh_resource_name[20] = "";
  357. const struct rpmh_vreg_init_data *rpmh_data;
  358. struct regulator_init_data *init_data;
  359. struct regulator_dev *rdev;
  360. int ret;
  361. vreg->dev = dev;
  362. for (rpmh_data = pmic_rpmh_data; rpmh_data->name; rpmh_data++)
  363. if (of_node_name_eq(node, rpmh_data->name))
  364. break;
  365. if (!rpmh_data->name) {
  366. dev_err(dev, "Unknown regulator %pOFn\n", node);
  367. return -EINVAL;
  368. }
  369. scnprintf(rpmh_resource_name, sizeof(rpmh_resource_name),
  370. rpmh_data->resource_name, pmic_id);
  371. vreg->addr = cmd_db_read_addr(rpmh_resource_name);
  372. if (!vreg->addr) {
  373. dev_err(dev, "%pOFn: could not find RPMh address for resource %s\n",
  374. node, rpmh_resource_name);
  375. return -ENODEV;
  376. }
  377. vreg->rdesc.name = rpmh_data->name;
  378. vreg->rdesc.supply_name = rpmh_data->supply_name;
  379. vreg->hw_data = rpmh_data->hw_data;
  380. vreg->enabled = -EINVAL;
  381. vreg->voltage_selector = -ENOTRECOVERABLE;
  382. vreg->mode = REGULATOR_MODE_INVALID;
  383. if (rpmh_data->hw_data->n_voltages) {
  384. vreg->rdesc.linear_ranges = &rpmh_data->hw_data->voltage_range;
  385. vreg->rdesc.n_linear_ranges = 1;
  386. vreg->rdesc.n_voltages = rpmh_data->hw_data->n_voltages;
  387. }
  388. vreg->always_wait_for_ack = of_property_read_bool(node,
  389. "qcom,always-wait-for-ack");
  390. vreg->rdesc.owner = THIS_MODULE;
  391. vreg->rdesc.type = REGULATOR_VOLTAGE;
  392. vreg->rdesc.ops = vreg->hw_data->ops;
  393. vreg->rdesc.of_map_mode = vreg->hw_data->of_map_mode;
  394. init_data = of_get_regulator_init_data(dev, node, &vreg->rdesc);
  395. if (!init_data)
  396. return -ENOMEM;
  397. if (rpmh_data->hw_data->regulator_type == XOB &&
  398. init_data->constraints.min_uV &&
  399. init_data->constraints.min_uV == init_data->constraints.max_uV) {
  400. vreg->rdesc.fixed_uV = init_data->constraints.min_uV;
  401. vreg->rdesc.n_voltages = 1;
  402. }
  403. reg_config.dev = dev;
  404. reg_config.init_data = init_data;
  405. reg_config.of_node = node;
  406. reg_config.driver_data = vreg;
  407. rdev = devm_regulator_register(dev, &vreg->rdesc, &reg_config);
  408. if (IS_ERR(rdev)) {
  409. ret = PTR_ERR(rdev);
  410. dev_err(dev, "%pOFn: devm_regulator_register() failed, ret=%d\n",
  411. node, ret);
  412. return ret;
  413. }
  414. dev_dbg(dev, "%pOFn regulator registered for RPMh resource %s @ 0x%05X\n",
  415. node, rpmh_resource_name, vreg->addr);
  416. return 0;
  417. }
  418. static const int pmic_mode_map_pmic4_ldo[REGULATOR_MODE_STANDBY + 1] = {
  419. [REGULATOR_MODE_INVALID] = -EINVAL,
  420. [REGULATOR_MODE_STANDBY] = PMIC4_LDO_MODE_RETENTION,
  421. [REGULATOR_MODE_IDLE] = PMIC4_LDO_MODE_LPM,
  422. [REGULATOR_MODE_NORMAL] = PMIC4_LDO_MODE_HPM,
  423. [REGULATOR_MODE_FAST] = -EINVAL,
  424. };
  425. static const int pmic_mode_map_pmic5_ldo[REGULATOR_MODE_STANDBY + 1] = {
  426. [REGULATOR_MODE_INVALID] = -EINVAL,
  427. [REGULATOR_MODE_STANDBY] = PMIC5_LDO_MODE_RETENTION,
  428. [REGULATOR_MODE_IDLE] = PMIC5_LDO_MODE_LPM,
  429. [REGULATOR_MODE_NORMAL] = PMIC5_LDO_MODE_HPM,
  430. [REGULATOR_MODE_FAST] = -EINVAL,
  431. };
  432. static unsigned int rpmh_regulator_pmic4_ldo_of_map_mode(unsigned int rpmh_mode)
  433. {
  434. unsigned int mode;
  435. switch (rpmh_mode) {
  436. case RPMH_REGULATOR_MODE_HPM:
  437. mode = REGULATOR_MODE_NORMAL;
  438. break;
  439. case RPMH_REGULATOR_MODE_LPM:
  440. mode = REGULATOR_MODE_IDLE;
  441. break;
  442. case RPMH_REGULATOR_MODE_RET:
  443. mode = REGULATOR_MODE_STANDBY;
  444. break;
  445. default:
  446. mode = REGULATOR_MODE_INVALID;
  447. break;
  448. }
  449. return mode;
  450. }
  451. static const int pmic_mode_map_pmic4_smps[REGULATOR_MODE_STANDBY + 1] = {
  452. [REGULATOR_MODE_INVALID] = -EINVAL,
  453. [REGULATOR_MODE_STANDBY] = PMIC4_SMPS_MODE_RETENTION,
  454. [REGULATOR_MODE_IDLE] = PMIC4_SMPS_MODE_PFM,
  455. [REGULATOR_MODE_NORMAL] = PMIC4_SMPS_MODE_AUTO,
  456. [REGULATOR_MODE_FAST] = PMIC4_SMPS_MODE_PWM,
  457. };
  458. static const int pmic_mode_map_pmic5_smps[REGULATOR_MODE_STANDBY + 1] = {
  459. [REGULATOR_MODE_INVALID] = -EINVAL,
  460. [REGULATOR_MODE_STANDBY] = PMIC5_SMPS_MODE_RETENTION,
  461. [REGULATOR_MODE_IDLE] = PMIC5_SMPS_MODE_PFM,
  462. [REGULATOR_MODE_NORMAL] = PMIC5_SMPS_MODE_AUTO,
  463. [REGULATOR_MODE_FAST] = PMIC5_SMPS_MODE_PWM,
  464. };
  465. static unsigned int
  466. rpmh_regulator_pmic4_smps_of_map_mode(unsigned int rpmh_mode)
  467. {
  468. unsigned int mode;
  469. switch (rpmh_mode) {
  470. case RPMH_REGULATOR_MODE_HPM:
  471. mode = REGULATOR_MODE_FAST;
  472. break;
  473. case RPMH_REGULATOR_MODE_AUTO:
  474. mode = REGULATOR_MODE_NORMAL;
  475. break;
  476. case RPMH_REGULATOR_MODE_LPM:
  477. mode = REGULATOR_MODE_IDLE;
  478. break;
  479. case RPMH_REGULATOR_MODE_RET:
  480. mode = REGULATOR_MODE_STANDBY;
  481. break;
  482. default:
  483. mode = REGULATOR_MODE_INVALID;
  484. break;
  485. }
  486. return mode;
  487. }
  488. static const int pmic_mode_map_pmic4_bob[REGULATOR_MODE_STANDBY + 1] = {
  489. [REGULATOR_MODE_INVALID] = -EINVAL,
  490. [REGULATOR_MODE_STANDBY] = -EINVAL,
  491. [REGULATOR_MODE_IDLE] = PMIC4_BOB_MODE_PFM,
  492. [REGULATOR_MODE_NORMAL] = PMIC4_BOB_MODE_AUTO,
  493. [REGULATOR_MODE_FAST] = PMIC4_BOB_MODE_PWM,
  494. };
  495. static const int pmic_mode_map_pmic5_bob[REGULATOR_MODE_STANDBY + 1] = {
  496. [REGULATOR_MODE_INVALID] = -EINVAL,
  497. [REGULATOR_MODE_STANDBY] = -EINVAL,
  498. [REGULATOR_MODE_IDLE] = PMIC5_BOB_MODE_PFM,
  499. [REGULATOR_MODE_NORMAL] = PMIC5_BOB_MODE_AUTO,
  500. [REGULATOR_MODE_FAST] = PMIC5_BOB_MODE_PWM,
  501. };
  502. static unsigned int rpmh_regulator_pmic4_bob_of_map_mode(unsigned int rpmh_mode)
  503. {
  504. unsigned int mode;
  505. switch (rpmh_mode) {
  506. case RPMH_REGULATOR_MODE_HPM:
  507. mode = REGULATOR_MODE_FAST;
  508. break;
  509. case RPMH_REGULATOR_MODE_AUTO:
  510. mode = REGULATOR_MODE_NORMAL;
  511. break;
  512. case RPMH_REGULATOR_MODE_LPM:
  513. mode = REGULATOR_MODE_IDLE;
  514. break;
  515. default:
  516. mode = REGULATOR_MODE_INVALID;
  517. break;
  518. }
  519. return mode;
  520. }
  521. static const struct rpmh_vreg_hw_data pmic4_pldo = {
  522. .regulator_type = VRM,
  523. .ops = &rpmh_regulator_vrm_drms_ops,
  524. .voltage_range = REGULATOR_LINEAR_RANGE(1664000, 0, 255, 8000),
  525. .n_voltages = 256,
  526. .hpm_min_load_uA = 10000,
  527. .pmic_mode_map = pmic_mode_map_pmic4_ldo,
  528. .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode,
  529. };
  530. static const struct rpmh_vreg_hw_data pmic4_pldo_lv = {
  531. .regulator_type = VRM,
  532. .ops = &rpmh_regulator_vrm_drms_ops,
  533. .voltage_range = REGULATOR_LINEAR_RANGE(1256000, 0, 127, 8000),
  534. .n_voltages = 128,
  535. .hpm_min_load_uA = 10000,
  536. .pmic_mode_map = pmic_mode_map_pmic4_ldo,
  537. .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode,
  538. };
  539. static const struct rpmh_vreg_hw_data pmic4_nldo = {
  540. .regulator_type = VRM,
  541. .ops = &rpmh_regulator_vrm_drms_ops,
  542. .voltage_range = REGULATOR_LINEAR_RANGE(312000, 0, 127, 8000),
  543. .n_voltages = 128,
  544. .hpm_min_load_uA = 30000,
  545. .pmic_mode_map = pmic_mode_map_pmic4_ldo,
  546. .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode,
  547. };
  548. static const struct rpmh_vreg_hw_data pmic4_hfsmps3 = {
  549. .regulator_type = VRM,
  550. .ops = &rpmh_regulator_vrm_ops,
  551. .voltage_range = REGULATOR_LINEAR_RANGE(320000, 0, 215, 8000),
  552. .n_voltages = 216,
  553. .pmic_mode_map = pmic_mode_map_pmic4_smps,
  554. .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode,
  555. };
  556. static const struct rpmh_vreg_hw_data pmic4_ftsmps426 = {
  557. .regulator_type = VRM,
  558. .ops = &rpmh_regulator_vrm_ops,
  559. .voltage_range = REGULATOR_LINEAR_RANGE(320000, 0, 258, 4000),
  560. .n_voltages = 259,
  561. .pmic_mode_map = pmic_mode_map_pmic4_smps,
  562. .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode,
  563. };
  564. static const struct rpmh_vreg_hw_data pmic4_bob = {
  565. .regulator_type = VRM,
  566. .ops = &rpmh_regulator_vrm_bypass_ops,
  567. .voltage_range = REGULATOR_LINEAR_RANGE(1824000, 0, 83, 32000),
  568. .n_voltages = 84,
  569. .pmic_mode_map = pmic_mode_map_pmic4_bob,
  570. .of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode,
  571. };
  572. static const struct rpmh_vreg_hw_data pmic4_lvs = {
  573. .regulator_type = XOB,
  574. .ops = &rpmh_regulator_xob_ops,
  575. /* LVS hardware does not support voltage or mode configuration. */
  576. };
  577. static const struct rpmh_vreg_hw_data pmic5_pldo = {
  578. .regulator_type = VRM,
  579. .ops = &rpmh_regulator_vrm_drms_ops,
  580. .voltage_range = REGULATOR_LINEAR_RANGE(1504000, 0, 255, 8000),
  581. .n_voltages = 256,
  582. .hpm_min_load_uA = 10000,
  583. .pmic_mode_map = pmic_mode_map_pmic5_ldo,
  584. .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode,
  585. };
  586. static const struct rpmh_vreg_hw_data pmic5_pldo_lv = {
  587. .regulator_type = VRM,
  588. .ops = &rpmh_regulator_vrm_drms_ops,
  589. .voltage_range = REGULATOR_LINEAR_RANGE(1504000, 0, 62, 8000),
  590. .n_voltages = 63,
  591. .hpm_min_load_uA = 10000,
  592. .pmic_mode_map = pmic_mode_map_pmic5_ldo,
  593. .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode,
  594. };
  595. static const struct rpmh_vreg_hw_data pmic5_nldo = {
  596. .regulator_type = VRM,
  597. .ops = &rpmh_regulator_vrm_drms_ops,
  598. .voltage_range = REGULATOR_LINEAR_RANGE(320000, 0, 123, 8000),
  599. .n_voltages = 124,
  600. .hpm_min_load_uA = 30000,
  601. .pmic_mode_map = pmic_mode_map_pmic5_ldo,
  602. .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode,
  603. };
  604. static const struct rpmh_vreg_hw_data pmic5_hfsmps510 = {
  605. .regulator_type = VRM,
  606. .ops = &rpmh_regulator_vrm_ops,
  607. .voltage_range = REGULATOR_LINEAR_RANGE(320000, 0, 215, 8000),
  608. .n_voltages = 216,
  609. .pmic_mode_map = pmic_mode_map_pmic5_smps,
  610. .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode,
  611. };
  612. static const struct rpmh_vreg_hw_data pmic5_ftsmps510 = {
  613. .regulator_type = VRM,
  614. .ops = &rpmh_regulator_vrm_ops,
  615. .voltage_range = REGULATOR_LINEAR_RANGE(300000, 0, 263, 4000),
  616. .n_voltages = 264,
  617. .pmic_mode_map = pmic_mode_map_pmic5_smps,
  618. .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode,
  619. };
  620. static const struct rpmh_vreg_hw_data pmic5_hfsmps515 = {
  621. .regulator_type = VRM,
  622. .ops = &rpmh_regulator_vrm_ops,
  623. .voltage_range = REGULATOR_LINEAR_RANGE(320000, 0, 235, 16000),
  624. .n_voltages = 236,
  625. .pmic_mode_map = pmic_mode_map_pmic5_smps,
  626. .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode,
  627. };
  628. static const struct rpmh_vreg_hw_data pmic5_bob = {
  629. .regulator_type = VRM,
  630. .ops = &rpmh_regulator_vrm_bypass_ops,
  631. .voltage_range = REGULATOR_LINEAR_RANGE(3000000, 0, 31, 32000),
  632. .n_voltages = 32,
  633. .pmic_mode_map = pmic_mode_map_pmic5_bob,
  634. .of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode,
  635. };
  636. #define RPMH_VREG(_name, _resource_name, _hw_data, _supply_name) \
  637. { \
  638. .name = _name, \
  639. .resource_name = _resource_name, \
  640. .hw_data = _hw_data, \
  641. .supply_name = _supply_name, \
  642. }
  643. static const struct rpmh_vreg_init_data pm8998_vreg_data[] = {
  644. RPMH_VREG("smps1", "smp%s1", &pmic4_ftsmps426, "vdd-s1"),
  645. RPMH_VREG("smps2", "smp%s2", &pmic4_ftsmps426, "vdd-s2"),
  646. RPMH_VREG("smps3", "smp%s3", &pmic4_hfsmps3, "vdd-s3"),
  647. RPMH_VREG("smps4", "smp%s4", &pmic4_hfsmps3, "vdd-s4"),
  648. RPMH_VREG("smps5", "smp%s5", &pmic4_hfsmps3, "vdd-s5"),
  649. RPMH_VREG("smps6", "smp%s6", &pmic4_ftsmps426, "vdd-s6"),
  650. RPMH_VREG("smps7", "smp%s7", &pmic4_ftsmps426, "vdd-s7"),
  651. RPMH_VREG("smps8", "smp%s8", &pmic4_ftsmps426, "vdd-s8"),
  652. RPMH_VREG("smps9", "smp%s9", &pmic4_ftsmps426, "vdd-s9"),
  653. RPMH_VREG("smps10", "smp%s10", &pmic4_ftsmps426, "vdd-s10"),
  654. RPMH_VREG("smps11", "smp%s11", &pmic4_ftsmps426, "vdd-s11"),
  655. RPMH_VREG("smps12", "smp%s12", &pmic4_ftsmps426, "vdd-s12"),
  656. RPMH_VREG("smps13", "smp%s13", &pmic4_ftsmps426, "vdd-s13"),
  657. RPMH_VREG("ldo1", "ldo%s1", &pmic4_nldo, "vdd-l1-l27"),
  658. RPMH_VREG("ldo2", "ldo%s2", &pmic4_nldo, "vdd-l2-l8-l17"),
  659. RPMH_VREG("ldo3", "ldo%s3", &pmic4_nldo, "vdd-l3-l11"),
  660. RPMH_VREG("ldo4", "ldo%s4", &pmic4_nldo, "vdd-l4-l5"),
  661. RPMH_VREG("ldo5", "ldo%s5", &pmic4_nldo, "vdd-l4-l5"),
  662. RPMH_VREG("ldo6", "ldo%s6", &pmic4_pldo, "vdd-l6"),
  663. RPMH_VREG("ldo7", "ldo%s7", &pmic4_pldo_lv, "vdd-l7-l12-l14-l15"),
  664. RPMH_VREG("ldo8", "ldo%s8", &pmic4_nldo, "vdd-l2-l8-l17"),
  665. RPMH_VREG("ldo9", "ldo%s9", &pmic4_pldo, "vdd-l9"),
  666. RPMH_VREG("ldo10", "ldo%s10", &pmic4_pldo, "vdd-l10-l23-l25"),
  667. RPMH_VREG("ldo11", "ldo%s11", &pmic4_nldo, "vdd-l3-l11"),
  668. RPMH_VREG("ldo12", "ldo%s12", &pmic4_pldo_lv, "vdd-l7-l12-l14-l15"),
  669. RPMH_VREG("ldo13", "ldo%s13", &pmic4_pldo, "vdd-l13-l19-l21"),
  670. RPMH_VREG("ldo14", "ldo%s14", &pmic4_pldo_lv, "vdd-l7-l12-l14-l15"),
  671. RPMH_VREG("ldo15", "ldo%s15", &pmic4_pldo_lv, "vdd-l7-l12-l14-l15"),
  672. RPMH_VREG("ldo16", "ldo%s16", &pmic4_pldo, "vdd-l16-l28"),
  673. RPMH_VREG("ldo17", "ldo%s17", &pmic4_nldo, "vdd-l2-l8-l17"),
  674. RPMH_VREG("ldo18", "ldo%s18", &pmic4_pldo, "vdd-l18-l22"),
  675. RPMH_VREG("ldo19", "ldo%s19", &pmic4_pldo, "vdd-l13-l19-l21"),
  676. RPMH_VREG("ldo20", "ldo%s20", &pmic4_pldo, "vdd-l20-l24"),
  677. RPMH_VREG("ldo21", "ldo%s21", &pmic4_pldo, "vdd-l13-l19-l21"),
  678. RPMH_VREG("ldo22", "ldo%s22", &pmic4_pldo, "vdd-l18-l22"),
  679. RPMH_VREG("ldo23", "ldo%s23", &pmic4_pldo, "vdd-l10-l23-l25"),
  680. RPMH_VREG("ldo24", "ldo%s24", &pmic4_pldo, "vdd-l20-l24"),
  681. RPMH_VREG("ldo25", "ldo%s25", &pmic4_pldo, "vdd-l10-l23-l25"),
  682. RPMH_VREG("ldo26", "ldo%s26", &pmic4_nldo, "vdd-l26"),
  683. RPMH_VREG("ldo27", "ldo%s27", &pmic4_nldo, "vdd-l1-l27"),
  684. RPMH_VREG("ldo28", "ldo%s28", &pmic4_pldo, "vdd-l16-l28"),
  685. RPMH_VREG("lvs1", "vs%s1", &pmic4_lvs, "vin-lvs-1-2"),
  686. RPMH_VREG("lvs2", "vs%s2", &pmic4_lvs, "vin-lvs-1-2"),
  687. {},
  688. };
  689. static const struct rpmh_vreg_init_data pmi8998_vreg_data[] = {
  690. RPMH_VREG("bob", "bob%s1", &pmic4_bob, "vdd-bob"),
  691. {},
  692. };
  693. static const struct rpmh_vreg_init_data pm8005_vreg_data[] = {
  694. RPMH_VREG("smps1", "smp%s1", &pmic4_ftsmps426, "vdd-s1"),
  695. RPMH_VREG("smps2", "smp%s2", &pmic4_ftsmps426, "vdd-s2"),
  696. RPMH_VREG("smps3", "smp%s3", &pmic4_ftsmps426, "vdd-s3"),
  697. RPMH_VREG("smps4", "smp%s4", &pmic4_ftsmps426, "vdd-s4"),
  698. {},
  699. };
  700. static const struct rpmh_vreg_init_data pm8150_vreg_data[] = {
  701. RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"),
  702. RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"),
  703. RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"),
  704. RPMH_VREG("smps4", "smp%s4", &pmic5_hfsmps510, "vdd-s4"),
  705. RPMH_VREG("smps5", "smp%s5", &pmic5_hfsmps510, "vdd-s5"),
  706. RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"),
  707. RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"),
  708. RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps510, "vdd-s8"),
  709. RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps510, "vdd-s9"),
  710. RPMH_VREG("smps10", "smp%s10", &pmic5_ftsmps510, "vdd-s10"),
  711. RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l8-l11"),
  712. RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, "vdd-l2-l10"),
  713. RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3-l4-l5-l18"),
  714. RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l3-l4-l5-l18"),
  715. RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo, "vdd-l3-l4-l5-l18"),
  716. RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l6-l9"),
  717. RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l7-l12-l14-l15"),
  718. RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l1-l8-l11"),
  719. RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l6-l9"),
  720. RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l2-l10"),
  721. RPMH_VREG("ldo11", "ldo%s11", &pmic5_nldo, "vdd-l1-l8-l11"),
  722. RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"),
  723. RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l13-l16-l17"),
  724. RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"),
  725. RPMH_VREG("ldo15", "ldo%s15", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"),
  726. RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l13-l16-l17"),
  727. RPMH_VREG("ldo17", "ldo%s17", &pmic5_pldo, "vdd-l13-l16-l17"),
  728. RPMH_VREG("ldo18", "ldo%s18", &pmic5_nldo, "vdd-l3-l4-l5-l18"),
  729. {},
  730. };
  731. static const struct rpmh_vreg_init_data pm8150l_vreg_data[] = {
  732. RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"),
  733. RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"),
  734. RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"),
  735. RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps510, "vdd-s4"),
  736. RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps510, "vdd-s5"),
  737. RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"),
  738. RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"),
  739. RPMH_VREG("smps8", "smp%s8", &pmic5_hfsmps510, "vdd-s8"),
  740. RPMH_VREG("ldo1", "ldo%s1", &pmic5_pldo_lv, "vdd-l1-l8"),
  741. RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2-l3"),
  742. RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l2-l3"),
  743. RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo, "vdd-l4-l5-l6"),
  744. RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l4-l5-l6"),
  745. RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l4-l5-l6"),
  746. RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l7-l11"),
  747. RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo_lv, "vdd-l1-l8"),
  748. RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, "vdd-l9-l10"),
  749. RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l9-l10"),
  750. RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l7-l11"),
  751. RPMH_VREG("bob", "bob%s1", &pmic5_bob, "vdd-bob"),
  752. {},
  753. };
  754. static const struct rpmh_vreg_init_data pm8009_vreg_data[] = {
  755. RPMH_VREG("smps1", "smp%s1", &pmic5_hfsmps510, "vdd-s1"),
  756. RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps515, "vdd-s2"),
  757. RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1"),
  758. RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2"),
  759. RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"),
  760. RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4"),
  761. RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l6"),
  762. RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l5-l6"),
  763. RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo_lv, "vdd-l7"),
  764. {},
  765. };
  766. static int rpmh_regulator_probe(struct platform_device *pdev)
  767. {
  768. struct device *dev = &pdev->dev;
  769. const struct rpmh_vreg_init_data *vreg_data;
  770. struct device_node *node;
  771. struct rpmh_vreg *vreg;
  772. const char *pmic_id;
  773. int ret;
  774. vreg_data = of_device_get_match_data(dev);
  775. if (!vreg_data)
  776. return -ENODEV;
  777. ret = of_property_read_string(dev->of_node, "qcom,pmic-id", &pmic_id);
  778. if (ret < 0) {
  779. dev_err(dev, "qcom,pmic-id missing in DT node\n");
  780. return ret;
  781. }
  782. for_each_available_child_of_node(dev->of_node, node) {
  783. vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL);
  784. if (!vreg) {
  785. of_node_put(node);
  786. return -ENOMEM;
  787. }
  788. ret = rpmh_regulator_init_vreg(vreg, dev, node, pmic_id,
  789. vreg_data);
  790. if (ret < 0) {
  791. of_node_put(node);
  792. return ret;
  793. }
  794. }
  795. return 0;
  796. }
  797. static const struct of_device_id rpmh_regulator_match_table[] = {
  798. {
  799. .compatible = "qcom,pm8005-rpmh-regulators",
  800. .data = pm8005_vreg_data,
  801. },
  802. {
  803. .compatible = "qcom,pm8009-rpmh-regulators",
  804. .data = pm8009_vreg_data,
  805. },
  806. {
  807. .compatible = "qcom,pm8150-rpmh-regulators",
  808. .data = pm8150_vreg_data,
  809. },
  810. {
  811. .compatible = "qcom,pm8150l-rpmh-regulators",
  812. .data = pm8150l_vreg_data,
  813. },
  814. {
  815. .compatible = "qcom,pm8998-rpmh-regulators",
  816. .data = pm8998_vreg_data,
  817. },
  818. {
  819. .compatible = "qcom,pmi8998-rpmh-regulators",
  820. .data = pmi8998_vreg_data,
  821. },
  822. {}
  823. };
  824. MODULE_DEVICE_TABLE(of, rpmh_regulator_match_table);
  825. static struct platform_driver rpmh_regulator_driver = {
  826. .driver = {
  827. .name = "qcom-rpmh-regulator",
  828. .of_match_table = of_match_ptr(rpmh_regulator_match_table),
  829. },
  830. .probe = rpmh_regulator_probe,
  831. };
  832. module_platform_driver(rpmh_regulator_driver);
  833. MODULE_DESCRIPTION("Qualcomm RPMh regulator driver");
  834. MODULE_LICENSE("GPL v2");