pv88080-regulator.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. // SPDX-License-Identifier: GPL-2.0+
  2. //
  3. // pv88080-regulator.c - Regulator device driver for PV88080
  4. // Copyright (C) 2016 Powerventure Semiconductor Ltd.
  5. #include <linux/err.h>
  6. #include <linux/i2c.h>
  7. #include <linux/module.h>
  8. #include <linux/of.h>
  9. #include <linux/init.h>
  10. #include <linux/slab.h>
  11. #include <linux/regulator/driver.h>
  12. #include <linux/regulator/machine.h>
  13. #include <linux/regmap.h>
  14. #include <linux/irq.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/regulator/of_regulator.h>
  17. #include "pv88080-regulator.h"
  18. #define PV88080_MAX_REGULATORS 4
  19. /* PV88080 REGULATOR IDs */
  20. enum {
  21. /* BUCKs */
  22. PV88080_ID_BUCK1,
  23. PV88080_ID_BUCK2,
  24. PV88080_ID_BUCK3,
  25. PV88080_ID_HVBUCK,
  26. };
  27. enum pv88080_types {
  28. TYPE_PV88080_AA,
  29. TYPE_PV88080_BA,
  30. };
  31. struct pv88080_regulator {
  32. struct regulator_desc desc;
  33. unsigned int mode_reg;
  34. unsigned int conf2;
  35. unsigned int conf5;
  36. };
  37. struct pv88080 {
  38. struct device *dev;
  39. struct regmap *regmap;
  40. struct regulator_dev *rdev[PV88080_MAX_REGULATORS];
  41. unsigned long type;
  42. const struct pv88080_compatible_regmap *regmap_config;
  43. };
  44. struct pv88080_buck_voltage {
  45. int min_uV;
  46. int max_uV;
  47. int uV_step;
  48. };
  49. struct pv88080_buck_regmap {
  50. /* REGS */
  51. int buck_enable_reg;
  52. int buck_vsel_reg;
  53. int buck_mode_reg;
  54. int buck_limit_reg;
  55. int buck_vdac_range_reg;
  56. int buck_vrange_gain_reg;
  57. /* MASKS */
  58. int buck_enable_mask;
  59. int buck_vsel_mask;
  60. int buck_limit_mask;
  61. };
  62. struct pv88080_compatible_regmap {
  63. /* BUCK1, 2, 3 */
  64. struct pv88080_buck_regmap buck_regmap[PV88080_MAX_REGULATORS-1];
  65. /* HVBUCK */
  66. int hvbuck_enable_reg;
  67. int hvbuck_vsel_reg;
  68. int hvbuck_enable_mask;
  69. int hvbuck_vsel_mask;
  70. };
  71. static const struct regmap_config pv88080_regmap_config = {
  72. .reg_bits = 8,
  73. .val_bits = 8,
  74. };
  75. /* Current limits array (in uA) for BUCK1, BUCK2, BUCK3.
  76. * Entry indexes corresponds to register values.
  77. */
  78. static const unsigned int pv88080_buck1_limits[] = {
  79. 3230000, 5130000, 6960000, 8790000
  80. };
  81. static const unsigned int pv88080_buck23_limits[] = {
  82. 1496000, 2393000, 3291000, 4189000
  83. };
  84. static const struct pv88080_buck_voltage pv88080_buck_vol[2] = {
  85. {
  86. .min_uV = 600000,
  87. .max_uV = 1393750,
  88. .uV_step = 6250,
  89. },
  90. {
  91. .min_uV = 1400000,
  92. .max_uV = 2193750,
  93. .uV_step = 6250,
  94. },
  95. };
  96. static const struct pv88080_compatible_regmap pv88080_aa_regs = {
  97. /* BUCK1 */
  98. .buck_regmap[0] = {
  99. .buck_enable_reg = PV88080AA_REG_BUCK1_CONF0,
  100. .buck_vsel_reg = PV88080AA_REG_BUCK1_CONF0,
  101. .buck_mode_reg = PV88080AA_REG_BUCK1_CONF1,
  102. .buck_limit_reg = PV88080AA_REG_BUCK1_CONF1,
  103. .buck_vdac_range_reg = PV88080AA_REG_BUCK1_CONF2,
  104. .buck_vrange_gain_reg = PV88080AA_REG_BUCK1_CONF5,
  105. .buck_enable_mask = PV88080_BUCK1_EN,
  106. .buck_vsel_mask = PV88080_VBUCK1_MASK,
  107. .buck_limit_mask = PV88080_BUCK1_ILIM_MASK,
  108. },
  109. /* BUCK2 */
  110. .buck_regmap[1] = {
  111. .buck_enable_reg = PV88080AA_REG_BUCK2_CONF0,
  112. .buck_vsel_reg = PV88080AA_REG_BUCK2_CONF0,
  113. .buck_mode_reg = PV88080AA_REG_BUCK2_CONF1,
  114. .buck_limit_reg = PV88080AA_REG_BUCK2_CONF1,
  115. .buck_vdac_range_reg = PV88080AA_REG_BUCK2_CONF2,
  116. .buck_vrange_gain_reg = PV88080AA_REG_BUCK2_CONF5,
  117. .buck_enable_mask = PV88080_BUCK2_EN,
  118. .buck_vsel_mask = PV88080_VBUCK2_MASK,
  119. .buck_limit_mask = PV88080_BUCK2_ILIM_MASK,
  120. },
  121. /* BUCK3 */
  122. .buck_regmap[2] = {
  123. .buck_enable_reg = PV88080AA_REG_BUCK3_CONF0,
  124. .buck_vsel_reg = PV88080AA_REG_BUCK3_CONF0,
  125. .buck_mode_reg = PV88080AA_REG_BUCK3_CONF1,
  126. .buck_limit_reg = PV88080AA_REG_BUCK3_CONF1,
  127. .buck_vdac_range_reg = PV88080AA_REG_BUCK3_CONF2,
  128. .buck_vrange_gain_reg = PV88080AA_REG_BUCK3_CONF5,
  129. .buck_enable_mask = PV88080_BUCK3_EN,
  130. .buck_vsel_mask = PV88080_VBUCK3_MASK,
  131. .buck_limit_mask = PV88080_BUCK3_ILIM_MASK,
  132. },
  133. /* HVBUCK */
  134. .hvbuck_enable_reg = PV88080AA_REG_HVBUCK_CONF2,
  135. .hvbuck_vsel_reg = PV88080AA_REG_HVBUCK_CONF1,
  136. .hvbuck_enable_mask = PV88080_HVBUCK_EN,
  137. .hvbuck_vsel_mask = PV88080_VHVBUCK_MASK,
  138. };
  139. static const struct pv88080_compatible_regmap pv88080_ba_regs = {
  140. /* BUCK1 */
  141. .buck_regmap[0] = {
  142. .buck_enable_reg = PV88080BA_REG_BUCK1_CONF0,
  143. .buck_vsel_reg = PV88080BA_REG_BUCK1_CONF0,
  144. .buck_mode_reg = PV88080BA_REG_BUCK1_CONF1,
  145. .buck_limit_reg = PV88080BA_REG_BUCK1_CONF1,
  146. .buck_vdac_range_reg = PV88080BA_REG_BUCK1_CONF2,
  147. .buck_vrange_gain_reg = PV88080BA_REG_BUCK1_CONF5,
  148. .buck_enable_mask = PV88080_BUCK1_EN,
  149. .buck_vsel_mask = PV88080_VBUCK1_MASK,
  150. .buck_limit_mask = PV88080_BUCK1_ILIM_MASK,
  151. },
  152. /* BUCK2 */
  153. .buck_regmap[1] = {
  154. .buck_enable_reg = PV88080BA_REG_BUCK2_CONF0,
  155. .buck_vsel_reg = PV88080BA_REG_BUCK2_CONF0,
  156. .buck_mode_reg = PV88080BA_REG_BUCK2_CONF1,
  157. .buck_limit_reg = PV88080BA_REG_BUCK2_CONF1,
  158. .buck_vdac_range_reg = PV88080BA_REG_BUCK2_CONF2,
  159. .buck_vrange_gain_reg = PV88080BA_REG_BUCK2_CONF5,
  160. .buck_enable_mask = PV88080_BUCK2_EN,
  161. .buck_vsel_mask = PV88080_VBUCK2_MASK,
  162. .buck_limit_mask = PV88080_BUCK2_ILIM_MASK,
  163. },
  164. /* BUCK3 */
  165. .buck_regmap[2] = {
  166. .buck_enable_reg = PV88080BA_REG_BUCK3_CONF0,
  167. .buck_vsel_reg = PV88080BA_REG_BUCK3_CONF0,
  168. .buck_mode_reg = PV88080BA_REG_BUCK3_CONF1,
  169. .buck_limit_reg = PV88080BA_REG_BUCK3_CONF1,
  170. .buck_vdac_range_reg = PV88080BA_REG_BUCK3_CONF2,
  171. .buck_vrange_gain_reg = PV88080BA_REG_BUCK3_CONF5,
  172. .buck_enable_mask = PV88080_BUCK3_EN,
  173. .buck_vsel_mask = PV88080_VBUCK3_MASK,
  174. .buck_limit_mask = PV88080_BUCK3_ILIM_MASK,
  175. },
  176. /* HVBUCK */
  177. .hvbuck_enable_reg = PV88080BA_REG_HVBUCK_CONF2,
  178. .hvbuck_vsel_reg = PV88080BA_REG_HVBUCK_CONF1,
  179. .hvbuck_enable_mask = PV88080_HVBUCK_EN,
  180. .hvbuck_vsel_mask = PV88080_VHVBUCK_MASK,
  181. };
  182. #ifdef CONFIG_OF
  183. static const struct of_device_id pv88080_dt_ids[] = {
  184. { .compatible = "pvs,pv88080", .data = (void *)TYPE_PV88080_AA },
  185. { .compatible = "pvs,pv88080-aa", .data = (void *)TYPE_PV88080_AA },
  186. { .compatible = "pvs,pv88080-ba", .data = (void *)TYPE_PV88080_BA },
  187. {},
  188. };
  189. MODULE_DEVICE_TABLE(of, pv88080_dt_ids);
  190. #endif
  191. static unsigned int pv88080_buck_get_mode(struct regulator_dev *rdev)
  192. {
  193. struct pv88080_regulator *info = rdev_get_drvdata(rdev);
  194. unsigned int data;
  195. int ret, mode = 0;
  196. ret = regmap_read(rdev->regmap, info->mode_reg, &data);
  197. if (ret < 0)
  198. return ret;
  199. switch (data & PV88080_BUCK1_MODE_MASK) {
  200. case PV88080_BUCK_MODE_SYNC:
  201. mode = REGULATOR_MODE_FAST;
  202. break;
  203. case PV88080_BUCK_MODE_AUTO:
  204. mode = REGULATOR_MODE_NORMAL;
  205. break;
  206. case PV88080_BUCK_MODE_SLEEP:
  207. mode = REGULATOR_MODE_STANDBY;
  208. break;
  209. default:
  210. return -EINVAL;
  211. }
  212. return mode;
  213. }
  214. static int pv88080_buck_set_mode(struct regulator_dev *rdev,
  215. unsigned int mode)
  216. {
  217. struct pv88080_regulator *info = rdev_get_drvdata(rdev);
  218. int val = 0;
  219. switch (mode) {
  220. case REGULATOR_MODE_FAST:
  221. val = PV88080_BUCK_MODE_SYNC;
  222. break;
  223. case REGULATOR_MODE_NORMAL:
  224. val = PV88080_BUCK_MODE_AUTO;
  225. break;
  226. case REGULATOR_MODE_STANDBY:
  227. val = PV88080_BUCK_MODE_SLEEP;
  228. break;
  229. default:
  230. return -EINVAL;
  231. }
  232. return regmap_update_bits(rdev->regmap, info->mode_reg,
  233. PV88080_BUCK1_MODE_MASK, val);
  234. }
  235. static const struct regulator_ops pv88080_buck_ops = {
  236. .get_mode = pv88080_buck_get_mode,
  237. .set_mode = pv88080_buck_set_mode,
  238. .enable = regulator_enable_regmap,
  239. .disable = regulator_disable_regmap,
  240. .is_enabled = regulator_is_enabled_regmap,
  241. .set_voltage_sel = regulator_set_voltage_sel_regmap,
  242. .get_voltage_sel = regulator_get_voltage_sel_regmap,
  243. .list_voltage = regulator_list_voltage_linear,
  244. .set_current_limit = regulator_set_current_limit_regmap,
  245. .get_current_limit = regulator_get_current_limit_regmap,
  246. };
  247. static const struct regulator_ops pv88080_hvbuck_ops = {
  248. .enable = regulator_enable_regmap,
  249. .disable = regulator_disable_regmap,
  250. .is_enabled = regulator_is_enabled_regmap,
  251. .set_voltage_sel = regulator_set_voltage_sel_regmap,
  252. .get_voltage_sel = regulator_get_voltage_sel_regmap,
  253. .list_voltage = regulator_list_voltage_linear,
  254. };
  255. #define PV88080_BUCK(chip, regl_name, min, step, max, limits_array) \
  256. {\
  257. .desc = {\
  258. .id = chip##_ID_##regl_name,\
  259. .name = __stringify(chip##_##regl_name),\
  260. .of_match = of_match_ptr(#regl_name),\
  261. .regulators_node = of_match_ptr("regulators"),\
  262. .type = REGULATOR_VOLTAGE,\
  263. .owner = THIS_MODULE,\
  264. .ops = &pv88080_buck_ops,\
  265. .min_uV = min, \
  266. .uV_step = step, \
  267. .n_voltages = ((max) - (min))/(step) + 1, \
  268. .curr_table = limits_array, \
  269. .n_current_limits = ARRAY_SIZE(limits_array), \
  270. },\
  271. }
  272. #define PV88080_HVBUCK(chip, regl_name, min, step, max) \
  273. {\
  274. .desc = {\
  275. .id = chip##_ID_##regl_name,\
  276. .name = __stringify(chip##_##regl_name),\
  277. .of_match = of_match_ptr(#regl_name),\
  278. .regulators_node = of_match_ptr("regulators"),\
  279. .type = REGULATOR_VOLTAGE,\
  280. .owner = THIS_MODULE,\
  281. .ops = &pv88080_hvbuck_ops,\
  282. .min_uV = min, \
  283. .uV_step = step, \
  284. .n_voltages = ((max) - (min))/(step) + 1, \
  285. },\
  286. }
  287. static struct pv88080_regulator pv88080_regulator_info[] = {
  288. PV88080_BUCK(PV88080, BUCK1, 600000, 6250, 1393750,
  289. pv88080_buck1_limits),
  290. PV88080_BUCK(PV88080, BUCK2, 600000, 6250, 1393750,
  291. pv88080_buck23_limits),
  292. PV88080_BUCK(PV88080, BUCK3, 600000, 6250, 1393750,
  293. pv88080_buck23_limits),
  294. PV88080_HVBUCK(PV88080, HVBUCK, 0, 5000, 1275000),
  295. };
  296. static irqreturn_t pv88080_irq_handler(int irq, void *data)
  297. {
  298. struct pv88080 *chip = data;
  299. int i, reg_val, err, ret = IRQ_NONE;
  300. err = regmap_read(chip->regmap, PV88080_REG_EVENT_A, &reg_val);
  301. if (err < 0)
  302. goto error_i2c;
  303. if (reg_val & PV88080_E_VDD_FLT) {
  304. for (i = 0; i < PV88080_MAX_REGULATORS; i++) {
  305. if (chip->rdev[i] != NULL)
  306. regulator_notifier_call_chain(chip->rdev[i],
  307. REGULATOR_EVENT_UNDER_VOLTAGE,
  308. NULL);
  309. }
  310. err = regmap_write(chip->regmap, PV88080_REG_EVENT_A,
  311. PV88080_E_VDD_FLT);
  312. if (err < 0)
  313. goto error_i2c;
  314. ret = IRQ_HANDLED;
  315. }
  316. if (reg_val & PV88080_E_OVER_TEMP) {
  317. for (i = 0; i < PV88080_MAX_REGULATORS; i++) {
  318. if (chip->rdev[i] != NULL)
  319. regulator_notifier_call_chain(chip->rdev[i],
  320. REGULATOR_EVENT_OVER_TEMP,
  321. NULL);
  322. }
  323. err = regmap_write(chip->regmap, PV88080_REG_EVENT_A,
  324. PV88080_E_OVER_TEMP);
  325. if (err < 0)
  326. goto error_i2c;
  327. ret = IRQ_HANDLED;
  328. }
  329. return ret;
  330. error_i2c:
  331. dev_err(chip->dev, "I2C error : %d\n", err);
  332. return IRQ_NONE;
  333. }
  334. /*
  335. * I2C driver interface functions
  336. */
  337. static int pv88080_i2c_probe(struct i2c_client *i2c,
  338. const struct i2c_device_id *id)
  339. {
  340. struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev);
  341. struct pv88080 *chip;
  342. const struct pv88080_compatible_regmap *regmap_config;
  343. const struct of_device_id *match;
  344. struct regulator_config config = { };
  345. int i, error, ret;
  346. unsigned int conf2, conf5;
  347. chip = devm_kzalloc(&i2c->dev, sizeof(struct pv88080), GFP_KERNEL);
  348. if (!chip)
  349. return -ENOMEM;
  350. chip->dev = &i2c->dev;
  351. chip->regmap = devm_regmap_init_i2c(i2c, &pv88080_regmap_config);
  352. if (IS_ERR(chip->regmap)) {
  353. error = PTR_ERR(chip->regmap);
  354. dev_err(chip->dev, "Failed to allocate register map: %d\n",
  355. error);
  356. return error;
  357. }
  358. if (i2c->dev.of_node) {
  359. match = of_match_node(pv88080_dt_ids, i2c->dev.of_node);
  360. if (!match) {
  361. dev_err(chip->dev, "Failed to get of_match_node\n");
  362. return -EINVAL;
  363. }
  364. chip->type = (unsigned long)match->data;
  365. } else {
  366. chip->type = id->driver_data;
  367. }
  368. i2c_set_clientdata(i2c, chip);
  369. if (i2c->irq != 0) {
  370. ret = regmap_write(chip->regmap, PV88080_REG_MASK_A, 0xFF);
  371. if (ret < 0) {
  372. dev_err(chip->dev,
  373. "Failed to mask A reg: %d\n", ret);
  374. return ret;
  375. }
  376. ret = regmap_write(chip->regmap, PV88080_REG_MASK_B, 0xFF);
  377. if (ret < 0) {
  378. dev_err(chip->dev,
  379. "Failed to mask B reg: %d\n", ret);
  380. return ret;
  381. }
  382. ret = regmap_write(chip->regmap, PV88080_REG_MASK_C, 0xFF);
  383. if (ret < 0) {
  384. dev_err(chip->dev,
  385. "Failed to mask C reg: %d\n", ret);
  386. return ret;
  387. }
  388. ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL,
  389. pv88080_irq_handler,
  390. IRQF_TRIGGER_LOW|IRQF_ONESHOT,
  391. "pv88080", chip);
  392. if (ret != 0) {
  393. dev_err(chip->dev, "Failed to request IRQ: %d\n",
  394. i2c->irq);
  395. return ret;
  396. }
  397. ret = regmap_update_bits(chip->regmap, PV88080_REG_MASK_A,
  398. PV88080_M_VDD_FLT | PV88080_M_OVER_TEMP, 0);
  399. if (ret < 0) {
  400. dev_err(chip->dev,
  401. "Failed to update mask reg: %d\n", ret);
  402. return ret;
  403. }
  404. } else {
  405. dev_warn(chip->dev, "No IRQ configured\n");
  406. }
  407. switch (chip->type) {
  408. case TYPE_PV88080_AA:
  409. chip->regmap_config = &pv88080_aa_regs;
  410. break;
  411. case TYPE_PV88080_BA:
  412. chip->regmap_config = &pv88080_ba_regs;
  413. break;
  414. }
  415. regmap_config = chip->regmap_config;
  416. config.dev = chip->dev;
  417. config.regmap = chip->regmap;
  418. /* Registeration for BUCK1, 2, 3 */
  419. for (i = 0; i < PV88080_MAX_REGULATORS-1; i++) {
  420. if (init_data)
  421. config.init_data = &init_data[i];
  422. pv88080_regulator_info[i].desc.csel_reg
  423. = regmap_config->buck_regmap[i].buck_limit_reg;
  424. pv88080_regulator_info[i].desc.csel_mask
  425. = regmap_config->buck_regmap[i].buck_limit_mask;
  426. pv88080_regulator_info[i].mode_reg
  427. = regmap_config->buck_regmap[i].buck_mode_reg;
  428. pv88080_regulator_info[i].conf2
  429. = regmap_config->buck_regmap[i].buck_vdac_range_reg;
  430. pv88080_regulator_info[i].conf5
  431. = regmap_config->buck_regmap[i].buck_vrange_gain_reg;
  432. pv88080_regulator_info[i].desc.enable_reg
  433. = regmap_config->buck_regmap[i].buck_enable_reg;
  434. pv88080_regulator_info[i].desc.enable_mask
  435. = regmap_config->buck_regmap[i].buck_enable_mask;
  436. pv88080_regulator_info[i].desc.vsel_reg
  437. = regmap_config->buck_regmap[i].buck_vsel_reg;
  438. pv88080_regulator_info[i].desc.vsel_mask
  439. = regmap_config->buck_regmap[i].buck_vsel_mask;
  440. ret = regmap_read(chip->regmap,
  441. pv88080_regulator_info[i].conf2, &conf2);
  442. if (ret < 0)
  443. return ret;
  444. conf2 = ((conf2 >> PV88080_BUCK_VDAC_RANGE_SHIFT) &
  445. PV88080_BUCK_VDAC_RANGE_MASK);
  446. ret = regmap_read(chip->regmap,
  447. pv88080_regulator_info[i].conf5, &conf5);
  448. if (ret < 0)
  449. return ret;
  450. conf5 = ((conf5 >> PV88080_BUCK_VRANGE_GAIN_SHIFT) &
  451. PV88080_BUCK_VRANGE_GAIN_MASK);
  452. pv88080_regulator_info[i].desc.min_uV =
  453. pv88080_buck_vol[conf2].min_uV * (conf5+1);
  454. pv88080_regulator_info[i].desc.uV_step =
  455. pv88080_buck_vol[conf2].uV_step * (conf5+1);
  456. pv88080_regulator_info[i].desc.n_voltages =
  457. ((pv88080_buck_vol[conf2].max_uV * (conf5+1))
  458. - (pv88080_regulator_info[i].desc.min_uV))
  459. /(pv88080_regulator_info[i].desc.uV_step) + 1;
  460. config.driver_data = (void *)&pv88080_regulator_info[i];
  461. chip->rdev[i] = devm_regulator_register(chip->dev,
  462. &pv88080_regulator_info[i].desc, &config);
  463. if (IS_ERR(chip->rdev[i])) {
  464. dev_err(chip->dev,
  465. "Failed to register PV88080 regulator\n");
  466. return PTR_ERR(chip->rdev[i]);
  467. }
  468. }
  469. pv88080_regulator_info[PV88080_ID_HVBUCK].desc.enable_reg
  470. = regmap_config->hvbuck_enable_reg;
  471. pv88080_regulator_info[PV88080_ID_HVBUCK].desc.enable_mask
  472. = regmap_config->hvbuck_enable_mask;
  473. pv88080_regulator_info[PV88080_ID_HVBUCK].desc.vsel_reg
  474. = regmap_config->hvbuck_vsel_reg;
  475. pv88080_regulator_info[PV88080_ID_HVBUCK].desc.vsel_mask
  476. = regmap_config->hvbuck_vsel_mask;
  477. /* Registeration for HVBUCK */
  478. if (init_data)
  479. config.init_data = &init_data[PV88080_ID_HVBUCK];
  480. config.driver_data = (void *)&pv88080_regulator_info[PV88080_ID_HVBUCK];
  481. chip->rdev[PV88080_ID_HVBUCK] = devm_regulator_register(chip->dev,
  482. &pv88080_regulator_info[PV88080_ID_HVBUCK].desc, &config);
  483. if (IS_ERR(chip->rdev[PV88080_ID_HVBUCK])) {
  484. dev_err(chip->dev, "Failed to register PV88080 regulator\n");
  485. return PTR_ERR(chip->rdev[PV88080_ID_HVBUCK]);
  486. }
  487. return 0;
  488. }
  489. static const struct i2c_device_id pv88080_i2c_id[] = {
  490. { "pv88080", TYPE_PV88080_AA },
  491. { "pv88080-aa", TYPE_PV88080_AA },
  492. { "pv88080-ba", TYPE_PV88080_BA },
  493. {},
  494. };
  495. MODULE_DEVICE_TABLE(i2c, pv88080_i2c_id);
  496. static struct i2c_driver pv88080_regulator_driver = {
  497. .driver = {
  498. .name = "pv88080",
  499. .of_match_table = of_match_ptr(pv88080_dt_ids),
  500. },
  501. .probe = pv88080_i2c_probe,
  502. .id_table = pv88080_i2c_id,
  503. };
  504. module_i2c_driver(pv88080_regulator_driver);
  505. MODULE_AUTHOR("James Ban <James.Ban.opensource@diasemi.com>");
  506. MODULE_DESCRIPTION("Regulator device driver for Powerventure PV88080");
  507. MODULE_LICENSE("GPL");