tps6586x-regulator.c 16 KB

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