tps6586x-regulator.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Regulator driver for TI TPS6586x
  4. *
  5. * Copyright (C) 2010 Compulab Ltd.
  6. * Author: Mike Rapoport <mike@compulab.co.il>
  7. *
  8. * Based on da903x
  9. * Copyright (C) 2006-2008 Marvell International Ltd.
  10. * Copyright (C) 2008 Compulab Ltd.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/module.h>
  14. #include <linux/init.h>
  15. #include <linux/err.h>
  16. #include <linux/of.h>
  17. #include <linux/slab.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/regulator/driver.h>
  20. #include <linux/regulator/machine.h>
  21. #include <linux/regulator/of_regulator.h>
  22. #include <linux/mfd/tps6586x.h>
  23. /* supply control and voltage setting */
  24. #define TPS6586X_SUPPLYENA 0x10
  25. #define TPS6586X_SUPPLYENB 0x11
  26. #define TPS6586X_SUPPLYENC 0x12
  27. #define TPS6586X_SUPPLYEND 0x13
  28. #define TPS6586X_SUPPLYENE 0x14
  29. #define TPS6586X_VCC1 0x20
  30. #define TPS6586X_VCC2 0x21
  31. #define TPS6586X_SM1V1 0x23
  32. #define TPS6586X_SM1V2 0x24
  33. #define TPS6586X_SM1SL 0x25
  34. #define TPS6586X_SM0V1 0x26
  35. #define TPS6586X_SM0V2 0x27
  36. #define TPS6586X_SM0SL 0x28
  37. #define TPS6586X_LDO2AV1 0x29
  38. #define TPS6586X_LDO2AV2 0x2A
  39. #define TPS6586X_LDO2BV1 0x2F
  40. #define TPS6586X_LDO2BV2 0x30
  41. #define TPS6586X_LDO4V1 0x32
  42. #define TPS6586X_LDO4V2 0x33
  43. /* converter settings */
  44. #define TPS6586X_SUPPLYV1 0x41
  45. #define TPS6586X_SUPPLYV2 0x42
  46. #define TPS6586X_SUPPLYV3 0x43
  47. #define TPS6586X_SUPPLYV4 0x44
  48. #define TPS6586X_SUPPLYV5 0x45
  49. #define TPS6586X_SUPPLYV6 0x46
  50. #define TPS6586X_SMODE1 0x47
  51. #define TPS6586X_SMODE2 0x48
  52. struct tps6586x_regulator {
  53. struct regulator_desc desc;
  54. int enable_bit[2];
  55. int enable_reg[2];
  56. };
  57. static struct regulator_ops tps6586x_rw_regulator_ops = {
  58. .list_voltage = regulator_list_voltage_table,
  59. .map_voltage = regulator_map_voltage_ascend,
  60. .get_voltage_sel = regulator_get_voltage_sel_regmap,
  61. .set_voltage_sel = regulator_set_voltage_sel_regmap,
  62. .is_enabled = regulator_is_enabled_regmap,
  63. .enable = regulator_enable_regmap,
  64. .disable = regulator_disable_regmap,
  65. };
  66. static struct regulator_ops tps6586x_rw_linear_regulator_ops = {
  67. .list_voltage = regulator_list_voltage_linear,
  68. .get_voltage_sel = regulator_get_voltage_sel_regmap,
  69. .set_voltage_sel = regulator_set_voltage_sel_regmap,
  70. .is_enabled = regulator_is_enabled_regmap,
  71. .enable = regulator_enable_regmap,
  72. .disable = regulator_disable_regmap,
  73. };
  74. static struct regulator_ops tps6586x_ro_regulator_ops = {
  75. .list_voltage = regulator_list_voltage_table,
  76. .map_voltage = regulator_map_voltage_ascend,
  77. .get_voltage_sel = regulator_get_voltage_sel_regmap,
  78. .is_enabled = regulator_is_enabled_regmap,
  79. .enable = regulator_enable_regmap,
  80. .disable = regulator_disable_regmap,
  81. };
  82. static struct regulator_ops tps6586x_sys_regulator_ops = {
  83. };
  84. static const unsigned int tps6586x_ldo0_voltages[] = {
  85. 1200000, 1500000, 1800000, 2500000, 2700000, 2850000, 3100000, 3300000,
  86. };
  87. static const unsigned int tps6586x_ldo_voltages[] = {
  88. 1250000, 1500000, 1800000, 2500000, 2700000, 2850000, 3100000, 3300000,
  89. };
  90. static const unsigned int tps658640_rtc_voltages[] = {
  91. 2500000, 2850000, 3100000, 3300000,
  92. };
  93. #define TPS6586X_REGULATOR(_id, _ops, _pin_name, vdata, vreg, shift, nbits, \
  94. ereg0, ebit0, ereg1, ebit1, goreg, gobit) \
  95. .desc = { \
  96. .supply_name = _pin_name, \
  97. .name = "REG-" #_id, \
  98. .ops = &tps6586x_## _ops ## _regulator_ops, \
  99. .type = REGULATOR_VOLTAGE, \
  100. .id = TPS6586X_ID_##_id, \
  101. .n_voltages = ARRAY_SIZE(vdata##_voltages), \
  102. .volt_table = vdata##_voltages, \
  103. .owner = THIS_MODULE, \
  104. .enable_reg = TPS6586X_SUPPLY##ereg0, \
  105. .enable_mask = 1 << (ebit0), \
  106. .vsel_reg = TPS6586X_##vreg, \
  107. .vsel_mask = ((1 << (nbits)) - 1) << (shift), \
  108. .apply_reg = (goreg), \
  109. .apply_bit = (gobit), \
  110. }, \
  111. .enable_reg[0] = TPS6586X_SUPPLY##ereg0, \
  112. .enable_bit[0] = (ebit0), \
  113. .enable_reg[1] = TPS6586X_SUPPLY##ereg1, \
  114. .enable_bit[1] = (ebit1),
  115. #define TPS6586X_REGULATOR_LINEAR(_id, _ops, _pin_name, n_volt, min_uv, \
  116. uv_step, vreg, shift, nbits, ereg0, \
  117. ebit0, ereg1, ebit1, goreg, gobit) \
  118. .desc = { \
  119. .supply_name = _pin_name, \
  120. .name = "REG-" #_id, \
  121. .ops = &tps6586x_## _ops ## _regulator_ops, \
  122. .type = REGULATOR_VOLTAGE, \
  123. .id = TPS6586X_ID_##_id, \
  124. .n_voltages = n_volt, \
  125. .min_uV = min_uv, \
  126. .uV_step = uv_step, \
  127. .owner = THIS_MODULE, \
  128. .enable_reg = TPS6586X_SUPPLY##ereg0, \
  129. .enable_mask = 1 << (ebit0), \
  130. .vsel_reg = TPS6586X_##vreg, \
  131. .vsel_mask = ((1 << (nbits)) - 1) << (shift), \
  132. .apply_reg = (goreg), \
  133. .apply_bit = (gobit), \
  134. }, \
  135. .enable_reg[0] = TPS6586X_SUPPLY##ereg0, \
  136. .enable_bit[0] = (ebit0), \
  137. .enable_reg[1] = TPS6586X_SUPPLY##ereg1, \
  138. .enable_bit[1] = (ebit1),
  139. #define TPS6586X_LDO(_id, _pname, vdata, vreg, shift, nbits, \
  140. ereg0, ebit0, ereg1, ebit1) \
  141. { \
  142. TPS6586X_REGULATOR(_id, rw, _pname, vdata, vreg, shift, nbits, \
  143. ereg0, ebit0, ereg1, ebit1, 0, 0) \
  144. }
  145. #define TPS6586X_LDO_LINEAR(_id, _pname, n_volt, min_uv, uv_step, vreg, \
  146. shift, nbits, ereg0, ebit0, ereg1, ebit1) \
  147. { \
  148. TPS6586X_REGULATOR_LINEAR(_id, rw_linear, _pname, n_volt, \
  149. min_uv, uv_step, vreg, shift, nbits, \
  150. ereg0, ebit0, ereg1, ebit1, 0, 0) \
  151. }
  152. #define TPS6586X_FIXED_LDO(_id, _pname, vdata, vreg, shift, nbits, \
  153. ereg0, ebit0, ereg1, ebit1) \
  154. { \
  155. TPS6586X_REGULATOR(_id, ro, _pname, vdata, vreg, shift, nbits, \
  156. ereg0, ebit0, ereg1, ebit1, 0, 0) \
  157. }
  158. #define TPS6586X_DVM(_id, _pname, n_volt, min_uv, uv_step, vreg, shift, \
  159. nbits, ereg0, ebit0, ereg1, ebit1, goreg, gobit) \
  160. { \
  161. TPS6586X_REGULATOR_LINEAR(_id, rw_linear, _pname, n_volt, \
  162. min_uv, uv_step, vreg, shift, nbits, \
  163. ereg0, ebit0, ereg1, ebit1, goreg, \
  164. gobit) \
  165. }
  166. #define TPS6586X_SYS_REGULATOR() \
  167. { \
  168. .desc = { \
  169. .supply_name = "sys", \
  170. .name = "REG-SYS", \
  171. .ops = &tps6586x_sys_regulator_ops, \
  172. .type = REGULATOR_VOLTAGE, \
  173. .id = TPS6586X_ID_SYS, \
  174. .owner = THIS_MODULE, \
  175. }, \
  176. }
  177. static struct tps6586x_regulator tps6586x_regulator[] = {
  178. TPS6586X_SYS_REGULATOR(),
  179. TPS6586X_LDO(LDO_0, "vinldo01", tps6586x_ldo0, SUPPLYV1, 5, 3, ENC, 0,
  180. END, 0),
  181. TPS6586X_LDO(LDO_3, "vinldo23", tps6586x_ldo, SUPPLYV4, 0, 3, ENC, 2,
  182. END, 2),
  183. TPS6586X_LDO(LDO_5, "REG-SYS", tps6586x_ldo, SUPPLYV6, 0, 3, ENE, 6,
  184. ENE, 6),
  185. TPS6586X_LDO(LDO_6, "vinldo678", tps6586x_ldo, SUPPLYV3, 0, 3, ENC, 4,
  186. END, 4),
  187. TPS6586X_LDO(LDO_7, "vinldo678", tps6586x_ldo, SUPPLYV3, 3, 3, ENC, 5,
  188. END, 5),
  189. TPS6586X_LDO(LDO_8, "vinldo678", tps6586x_ldo, SUPPLYV2, 5, 3, ENC, 6,
  190. END, 6),
  191. TPS6586X_LDO(LDO_9, "vinldo9", tps6586x_ldo, SUPPLYV6, 3, 3, ENE, 7,
  192. ENE, 7),
  193. TPS6586X_LDO(LDO_RTC, "REG-SYS", tps6586x_ldo, SUPPLYV4, 3, 3, V4, 7,
  194. V4, 7),
  195. TPS6586X_LDO_LINEAR(LDO_1, "vinldo01", 32, 725000, 25000, SUPPLYV1,
  196. 0, 5, ENC, 1, END, 1),
  197. TPS6586X_LDO_LINEAR(SM_2, "vin-sm2", 32, 3000000, 50000, SUPPLYV2,
  198. 0, 5, ENC, 7, END, 7),
  199. TPS6586X_DVM(LDO_2, "vinldo23", 32, 725000, 25000, LDO2BV1, 0, 5,
  200. ENA, 3, ENB, 3, TPS6586X_VCC2, BIT(6)),
  201. TPS6586X_DVM(LDO_4, "vinldo4", 32, 1700000, 25000, LDO4V1, 0, 5,
  202. ENC, 3, END, 3, TPS6586X_VCC1, BIT(6)),
  203. TPS6586X_DVM(SM_0, "vin-sm0", 32, 725000, 25000, SM0V1, 0, 5,
  204. ENA, 1, ENB, 1, TPS6586X_VCC1, BIT(2)),
  205. TPS6586X_DVM(SM_1, "vin-sm1", 32, 725000, 25000, SM1V1, 0, 5,
  206. ENA, 0, ENB, 0, TPS6586X_VCC1, BIT(0)),
  207. };
  208. static struct tps6586x_regulator tps658623_regulator[] = {
  209. TPS6586X_LDO_LINEAR(SM_2, "vin-sm2", 32, 1700000, 25000, SUPPLYV2,
  210. 0, 5, ENC, 7, END, 7),
  211. };
  212. static struct tps6586x_regulator tps658640_regulator[] = {
  213. TPS6586X_LDO(LDO_3, "vinldo23", tps6586x_ldo0, SUPPLYV4, 0, 3,
  214. ENC, 2, END, 2),
  215. TPS6586X_LDO(LDO_5, "REG-SYS", tps6586x_ldo0, SUPPLYV6, 0, 3,
  216. ENE, 6, ENE, 6),
  217. TPS6586X_LDO(LDO_6, "vinldo678", tps6586x_ldo0, SUPPLYV3, 0, 3,
  218. ENC, 4, END, 4),
  219. TPS6586X_LDO(LDO_7, "vinldo678", tps6586x_ldo0, SUPPLYV3, 3, 3,
  220. ENC, 5, END, 5),
  221. TPS6586X_LDO(LDO_8, "vinldo678", tps6586x_ldo0, SUPPLYV2, 5, 3,
  222. ENC, 6, END, 6),
  223. TPS6586X_LDO(LDO_9, "vinldo9", tps6586x_ldo0, SUPPLYV6, 3, 3,
  224. ENE, 7, ENE, 7),
  225. TPS6586X_LDO_LINEAR(SM_2, "vin-sm2", 32, 2150000, 50000, SUPPLYV2,
  226. 0, 5, ENC, 7, END, 7),
  227. TPS6586X_FIXED_LDO(LDO_RTC, "REG-SYS", tps658640_rtc, SUPPLYV4, 3, 2,
  228. V4, 7, V4, 7),
  229. };
  230. static struct tps6586x_regulator tps658643_regulator[] = {
  231. TPS6586X_LDO_LINEAR(SM_2, "vin-sm2", 32, 1025000, 25000, SUPPLYV2,
  232. 0, 5, ENC, 7, END, 7),
  233. };
  234. /*
  235. * TPS6586X has 2 enable bits that are OR'ed to determine the actual
  236. * regulator state. Clearing one of this bits allows switching
  237. * regulator on and of with single register write.
  238. */
  239. static inline int tps6586x_regulator_preinit(struct device *parent,
  240. struct tps6586x_regulator *ri)
  241. {
  242. uint8_t val1, val2;
  243. int ret;
  244. if (ri->enable_reg[0] == ri->enable_reg[1] &&
  245. ri->enable_bit[0] == ri->enable_bit[1])
  246. return 0;
  247. ret = tps6586x_read(parent, ri->enable_reg[0], &val1);
  248. if (ret)
  249. return ret;
  250. ret = tps6586x_read(parent, ri->enable_reg[1], &val2);
  251. if (ret)
  252. return ret;
  253. if (!(val2 & (1 << ri->enable_bit[1])))
  254. return 0;
  255. /*
  256. * The regulator is on, but it's enabled with the bit we don't
  257. * want to use, so we switch the enable bits
  258. */
  259. if (!(val1 & (1 << ri->enable_bit[0]))) {
  260. ret = tps6586x_set_bits(parent, ri->enable_reg[0],
  261. 1 << ri->enable_bit[0]);
  262. if (ret)
  263. return ret;
  264. }
  265. return tps6586x_clr_bits(parent, ri->enable_reg[1],
  266. 1 << ri->enable_bit[1]);
  267. }
  268. static int tps6586x_regulator_set_slew_rate(struct platform_device *pdev,
  269. int id, struct regulator_init_data *p)
  270. {
  271. struct device *parent = pdev->dev.parent;
  272. struct tps6586x_settings *setting = p->driver_data;
  273. uint8_t reg;
  274. if (setting == NULL)
  275. return 0;
  276. if (!(setting->slew_rate & TPS6586X_SLEW_RATE_SET))
  277. return 0;
  278. /* only SM0 and SM1 can have the slew rate settings */
  279. switch (id) {
  280. case TPS6586X_ID_SM_0:
  281. reg = TPS6586X_SM0SL;
  282. break;
  283. case TPS6586X_ID_SM_1:
  284. reg = TPS6586X_SM1SL;
  285. break;
  286. default:
  287. dev_err(&pdev->dev, "Only SM0/SM1 can set slew rate\n");
  288. return -EINVAL;
  289. }
  290. return tps6586x_write(parent, reg,
  291. setting->slew_rate & TPS6586X_SLEW_RATE_MASK);
  292. }
  293. static struct tps6586x_regulator *find_regulator_info(int id, int version)
  294. {
  295. struct tps6586x_regulator *ri;
  296. struct tps6586x_regulator *table = NULL;
  297. int num;
  298. int i;
  299. switch (version) {
  300. case TPS658623:
  301. case TPS658624:
  302. table = tps658623_regulator;
  303. num = ARRAY_SIZE(tps658623_regulator);
  304. break;
  305. case TPS658640:
  306. case TPS658640v2:
  307. table = tps658640_regulator;
  308. num = ARRAY_SIZE(tps658640_regulator);
  309. break;
  310. case TPS658643:
  311. table = tps658643_regulator;
  312. num = ARRAY_SIZE(tps658643_regulator);
  313. break;
  314. }
  315. /* Search version specific table first */
  316. if (table) {
  317. for (i = 0; i < num; i++) {
  318. ri = &table[i];
  319. if (ri->desc.id == id)
  320. return ri;
  321. }
  322. }
  323. for (i = 0; i < ARRAY_SIZE(tps6586x_regulator); i++) {
  324. ri = &tps6586x_regulator[i];
  325. if (ri->desc.id == id)
  326. return ri;
  327. }
  328. return NULL;
  329. }
  330. #ifdef CONFIG_OF
  331. static struct of_regulator_match tps6586x_matches[] = {
  332. { .name = "sys", .driver_data = (void *)TPS6586X_ID_SYS },
  333. { .name = "sm0", .driver_data = (void *)TPS6586X_ID_SM_0 },
  334. { .name = "sm1", .driver_data = (void *)TPS6586X_ID_SM_1 },
  335. { .name = "sm2", .driver_data = (void *)TPS6586X_ID_SM_2 },
  336. { .name = "ldo0", .driver_data = (void *)TPS6586X_ID_LDO_0 },
  337. { .name = "ldo1", .driver_data = (void *)TPS6586X_ID_LDO_1 },
  338. { .name = "ldo2", .driver_data = (void *)TPS6586X_ID_LDO_2 },
  339. { .name = "ldo3", .driver_data = (void *)TPS6586X_ID_LDO_3 },
  340. { .name = "ldo4", .driver_data = (void *)TPS6586X_ID_LDO_4 },
  341. { .name = "ldo5", .driver_data = (void *)TPS6586X_ID_LDO_5 },
  342. { .name = "ldo6", .driver_data = (void *)TPS6586X_ID_LDO_6 },
  343. { .name = "ldo7", .driver_data = (void *)TPS6586X_ID_LDO_7 },
  344. { .name = "ldo8", .driver_data = (void *)TPS6586X_ID_LDO_8 },
  345. { .name = "ldo9", .driver_data = (void *)TPS6586X_ID_LDO_9 },
  346. { .name = "ldo_rtc", .driver_data = (void *)TPS6586X_ID_LDO_RTC },
  347. };
  348. static struct tps6586x_platform_data *tps6586x_parse_regulator_dt(
  349. struct platform_device *pdev,
  350. struct of_regulator_match **tps6586x_reg_matches)
  351. {
  352. const unsigned int num = ARRAY_SIZE(tps6586x_matches);
  353. struct device_node *np = pdev->dev.parent->of_node;
  354. struct device_node *regs;
  355. const char *sys_rail = NULL;
  356. unsigned int i;
  357. struct tps6586x_platform_data *pdata;
  358. int err;
  359. regs = of_get_child_by_name(np, "regulators");
  360. if (!regs) {
  361. dev_err(&pdev->dev, "regulator node not found\n");
  362. return NULL;
  363. }
  364. err = of_regulator_match(&pdev->dev, regs, tps6586x_matches, num);
  365. of_node_put(regs);
  366. if (err < 0) {
  367. dev_err(&pdev->dev, "Regulator match failed, e %d\n", err);
  368. return NULL;
  369. }
  370. pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
  371. if (!pdata)
  372. return NULL;
  373. for (i = 0; i < num; i++) {
  374. uintptr_t id;
  375. if (!tps6586x_matches[i].init_data)
  376. continue;
  377. pdata->reg_init_data[i] = tps6586x_matches[i].init_data;
  378. id = (uintptr_t)tps6586x_matches[i].driver_data;
  379. if (id == TPS6586X_ID_SYS)
  380. sys_rail = pdata->reg_init_data[i]->constraints.name;
  381. if ((id == TPS6586X_ID_LDO_5) || (id == TPS6586X_ID_LDO_RTC))
  382. pdata->reg_init_data[i]->supply_regulator = sys_rail;
  383. }
  384. *tps6586x_reg_matches = tps6586x_matches;
  385. return pdata;
  386. }
  387. #else
  388. static struct tps6586x_platform_data *tps6586x_parse_regulator_dt(
  389. struct platform_device *pdev,
  390. struct of_regulator_match **tps6586x_reg_matches)
  391. {
  392. *tps6586x_reg_matches = NULL;
  393. return NULL;
  394. }
  395. #endif
  396. static int tps6586x_regulator_probe(struct platform_device *pdev)
  397. {
  398. struct tps6586x_regulator *ri = NULL;
  399. struct regulator_config config = { };
  400. struct regulator_dev *rdev;
  401. struct regulator_init_data *reg_data;
  402. struct tps6586x_platform_data *pdata;
  403. struct of_regulator_match *tps6586x_reg_matches = NULL;
  404. int version;
  405. int id;
  406. int err;
  407. dev_dbg(&pdev->dev, "Probing regulator\n");
  408. pdata = dev_get_platdata(pdev->dev.parent);
  409. if ((!pdata) && (pdev->dev.parent->of_node))
  410. pdata = tps6586x_parse_regulator_dt(pdev,
  411. &tps6586x_reg_matches);
  412. if (!pdata) {
  413. dev_err(&pdev->dev, "Platform data not available, exiting\n");
  414. return -ENODEV;
  415. }
  416. version = tps6586x_get_version(pdev->dev.parent);
  417. for (id = 0; id < TPS6586X_ID_MAX_REGULATOR; ++id) {
  418. reg_data = pdata->reg_init_data[id];
  419. ri = find_regulator_info(id, version);
  420. if (!ri) {
  421. dev_err(&pdev->dev, "invalid regulator ID specified\n");
  422. return -EINVAL;
  423. }
  424. err = tps6586x_regulator_preinit(pdev->dev.parent, ri);
  425. if (err) {
  426. dev_err(&pdev->dev,
  427. "regulator %d preinit failed, e %d\n", id, err);
  428. return err;
  429. }
  430. config.dev = pdev->dev.parent;
  431. config.init_data = reg_data;
  432. config.driver_data = ri;
  433. if (tps6586x_reg_matches)
  434. config.of_node = tps6586x_reg_matches[id].of_node;
  435. rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config);
  436. if (IS_ERR(rdev)) {
  437. dev_err(&pdev->dev, "failed to register regulator %s\n",
  438. ri->desc.name);
  439. return PTR_ERR(rdev);
  440. }
  441. if (reg_data) {
  442. err = tps6586x_regulator_set_slew_rate(pdev, id,
  443. reg_data);
  444. if (err < 0) {
  445. dev_err(&pdev->dev,
  446. "Slew rate config failed, e %d\n", err);
  447. return err;
  448. }
  449. }
  450. }
  451. platform_set_drvdata(pdev, rdev);
  452. return 0;
  453. }
  454. static struct platform_driver tps6586x_regulator_driver = {
  455. .driver = {
  456. .name = "tps6586x-regulator",
  457. },
  458. .probe = tps6586x_regulator_probe,
  459. };
  460. static int __init tps6586x_regulator_init(void)
  461. {
  462. return platform_driver_register(&tps6586x_regulator_driver);
  463. }
  464. subsys_initcall(tps6586x_regulator_init);
  465. static void __exit tps6586x_regulator_exit(void)
  466. {
  467. platform_driver_unregister(&tps6586x_regulator_driver);
  468. }
  469. module_exit(tps6586x_regulator_exit);
  470. MODULE_LICENSE("GPL");
  471. MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
  472. MODULE_DESCRIPTION("Regulator Driver for TI TPS6586X PMIC");
  473. MODULE_ALIAS("platform:tps6586x-regulator");