ab3100.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. /*
  2. * drivers/regulator/ab3100.c
  3. *
  4. * Copyright (C) 2008-2009 ST-Ericsson AB
  5. * License terms: GNU General Public License (GPL) version 2
  6. * Low-level control of the AB3100 IC Low Dropout (LDO)
  7. * regulators, external regulator and buck converter
  8. * Author: Mattias Wallin <mattias.wallin@stericsson.com>
  9. * Author: Linus Walleij <linus.walleij@stericsson.com>
  10. */
  11. #include <linux/module.h>
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/err.h>
  15. #include <linux/delay.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/regulator/driver.h>
  18. #include <linux/mfd/ab3100.h>
  19. /* LDO registers and some handy masking definitions for AB3100 */
  20. #define AB3100_LDO_A 0x40
  21. #define AB3100_LDO_C 0x41
  22. #define AB3100_LDO_D 0x42
  23. #define AB3100_LDO_E 0x43
  24. #define AB3100_LDO_E_SLEEP 0x44
  25. #define AB3100_LDO_F 0x45
  26. #define AB3100_LDO_G 0x46
  27. #define AB3100_LDO_H 0x47
  28. #define AB3100_LDO_H_SLEEP_MODE 0
  29. #define AB3100_LDO_H_SLEEP_EN 2
  30. #define AB3100_LDO_ON 4
  31. #define AB3100_LDO_H_VSEL_AC 5
  32. #define AB3100_LDO_K 0x48
  33. #define AB3100_LDO_EXT 0x49
  34. #define AB3100_BUCK 0x4A
  35. #define AB3100_BUCK_SLEEP 0x4B
  36. #define AB3100_REG_ON_MASK 0x10
  37. /**
  38. * struct ab3100_regulator
  39. * A struct passed around the individual regulator functions
  40. * @platform_device: platform device holding this regulator
  41. * @ab3100: handle to the AB3100 parent chip
  42. * @plfdata: AB3100 platform data passed in at probe time
  43. * @regreg: regulator register number in the AB3100
  44. * @fixed_voltage: a fixed voltage for this regulator, if this
  45. * 0 the voltages array is used instead.
  46. * @typ_voltages: an array of available typical voltages for
  47. * this regulator
  48. * @voltages_len: length of the array of available voltages
  49. */
  50. struct ab3100_regulator {
  51. struct regulator_dev *rdev;
  52. struct ab3100 *ab3100;
  53. struct ab3100_platform_data *plfdata;
  54. u8 regreg;
  55. int fixed_voltage;
  56. int const *typ_voltages;
  57. u8 voltages_len;
  58. };
  59. /* The order in which registers are initialized */
  60. static const u8 ab3100_reg_init_order[AB3100_NUM_REGULATORS+2] = {
  61. AB3100_LDO_A,
  62. AB3100_LDO_C,
  63. AB3100_LDO_E,
  64. AB3100_LDO_E_SLEEP,
  65. AB3100_LDO_F,
  66. AB3100_LDO_G,
  67. AB3100_LDO_H,
  68. AB3100_LDO_K,
  69. AB3100_LDO_EXT,
  70. AB3100_BUCK,
  71. AB3100_BUCK_SLEEP,
  72. AB3100_LDO_D,
  73. };
  74. /* Preset (hardware defined) voltages for these regulators */
  75. #define LDO_A_VOLTAGE 2750000
  76. #define LDO_C_VOLTAGE 2650000
  77. #define LDO_D_VOLTAGE 2650000
  78. static const int const ldo_e_buck_typ_voltages[] = {
  79. 1800000,
  80. 1400000,
  81. 1300000,
  82. 1200000,
  83. 1100000,
  84. 1050000,
  85. 900000,
  86. };
  87. static const int const ldo_f_typ_voltages[] = {
  88. 1800000,
  89. 1400000,
  90. 1300000,
  91. 1200000,
  92. 1100000,
  93. 1050000,
  94. 2500000,
  95. 2650000,
  96. };
  97. static const int const ldo_g_typ_voltages[] = {
  98. 2850000,
  99. 2750000,
  100. 1800000,
  101. 1500000,
  102. };
  103. static const int const ldo_h_typ_voltages[] = {
  104. 2750000,
  105. 1800000,
  106. 1500000,
  107. 1200000,
  108. };
  109. static const int const ldo_k_typ_voltages[] = {
  110. 2750000,
  111. 1800000,
  112. };
  113. /* The regulator devices */
  114. static struct ab3100_regulator
  115. ab3100_regulators[AB3100_NUM_REGULATORS] = {
  116. {
  117. .regreg = AB3100_LDO_A,
  118. .fixed_voltage = LDO_A_VOLTAGE,
  119. },
  120. {
  121. .regreg = AB3100_LDO_C,
  122. .fixed_voltage = LDO_C_VOLTAGE,
  123. },
  124. {
  125. .regreg = AB3100_LDO_D,
  126. .fixed_voltage = LDO_D_VOLTAGE,
  127. },
  128. {
  129. .regreg = AB3100_LDO_E,
  130. .typ_voltages = ldo_e_buck_typ_voltages,
  131. .voltages_len = ARRAY_SIZE(ldo_e_buck_typ_voltages),
  132. },
  133. {
  134. .regreg = AB3100_LDO_F,
  135. .typ_voltages = ldo_f_typ_voltages,
  136. .voltages_len = ARRAY_SIZE(ldo_f_typ_voltages),
  137. },
  138. {
  139. .regreg = AB3100_LDO_G,
  140. .typ_voltages = ldo_g_typ_voltages,
  141. .voltages_len = ARRAY_SIZE(ldo_g_typ_voltages),
  142. },
  143. {
  144. .regreg = AB3100_LDO_H,
  145. .typ_voltages = ldo_h_typ_voltages,
  146. .voltages_len = ARRAY_SIZE(ldo_h_typ_voltages),
  147. },
  148. {
  149. .regreg = AB3100_LDO_K,
  150. .typ_voltages = ldo_k_typ_voltages,
  151. .voltages_len = ARRAY_SIZE(ldo_k_typ_voltages),
  152. },
  153. {
  154. .regreg = AB3100_LDO_EXT,
  155. /* No voltages for the external regulator */
  156. },
  157. {
  158. .regreg = AB3100_BUCK,
  159. .typ_voltages = ldo_e_buck_typ_voltages,
  160. .voltages_len = ARRAY_SIZE(ldo_e_buck_typ_voltages),
  161. },
  162. };
  163. /*
  164. * General functions for enable, disable and is_enabled used for
  165. * LDO: A,C,E,F,G,H,K,EXT and BUCK
  166. */
  167. static int ab3100_enable_regulator(struct regulator_dev *reg)
  168. {
  169. struct ab3100_regulator *abreg = reg->reg_data;
  170. int err;
  171. u8 regval;
  172. err = ab3100_get_register_interruptible(abreg->ab3100, abreg->regreg,
  173. &regval);
  174. if (err) {
  175. dev_warn(&reg->dev, "failed to get regid %d value\n",
  176. abreg->regreg);
  177. return err;
  178. }
  179. /* The regulator is already on, no reason to go further */
  180. if (regval & AB3100_REG_ON_MASK)
  181. return 0;
  182. regval |= AB3100_REG_ON_MASK;
  183. err = ab3100_set_register_interruptible(abreg->ab3100, abreg->regreg,
  184. regval);
  185. if (err) {
  186. dev_warn(&reg->dev, "failed to set regid %d value\n",
  187. abreg->regreg);
  188. return err;
  189. }
  190. /* Per-regulator power on delay from spec */
  191. switch (abreg->regreg) {
  192. case AB3100_LDO_A: /* Fallthrough */
  193. case AB3100_LDO_C: /* Fallthrough */
  194. case AB3100_LDO_D: /* Fallthrough */
  195. case AB3100_LDO_E: /* Fallthrough */
  196. case AB3100_LDO_H: /* Fallthrough */
  197. case AB3100_LDO_K:
  198. udelay(200);
  199. break;
  200. case AB3100_LDO_F:
  201. udelay(600);
  202. break;
  203. case AB3100_LDO_G:
  204. udelay(400);
  205. break;
  206. case AB3100_BUCK:
  207. mdelay(1);
  208. break;
  209. default:
  210. break;
  211. }
  212. return 0;
  213. }
  214. static int ab3100_disable_regulator(struct regulator_dev *reg)
  215. {
  216. struct ab3100_regulator *abreg = reg->reg_data;
  217. int err;
  218. u8 regval;
  219. /*
  220. * LDO D is a special regulator. When it is disabled, the entire
  221. * system is shut down. So this is handled specially.
  222. */
  223. if (abreg->regreg == AB3100_LDO_D) {
  224. int i;
  225. dev_info(&reg->dev, "disabling LDO D - shut down system\n");
  226. /*
  227. * Set regulators to default values, ignore any errors,
  228. * we're going DOWN
  229. */
  230. for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) {
  231. (void) ab3100_set_register_interruptible(abreg->ab3100,
  232. ab3100_reg_init_order[i],
  233. abreg->plfdata->reg_initvals[i]);
  234. }
  235. /* Setting LDO D to 0x00 cuts the power to the SoC */
  236. return ab3100_set_register_interruptible(abreg->ab3100,
  237. AB3100_LDO_D, 0x00U);
  238. }
  239. /*
  240. * All other regulators are handled here
  241. */
  242. err = ab3100_get_register_interruptible(abreg->ab3100, abreg->regreg,
  243. &regval);
  244. if (err) {
  245. dev_err(&reg->dev, "unable to get register 0x%x\n",
  246. abreg->regreg);
  247. return err;
  248. }
  249. regval &= ~AB3100_REG_ON_MASK;
  250. return ab3100_set_register_interruptible(abreg->ab3100, abreg->regreg,
  251. regval);
  252. }
  253. static int ab3100_is_enabled_regulator(struct regulator_dev *reg)
  254. {
  255. struct ab3100_regulator *abreg = reg->reg_data;
  256. u8 regval;
  257. int err;
  258. err = ab3100_get_register_interruptible(abreg->ab3100, abreg->regreg,
  259. &regval);
  260. if (err) {
  261. dev_err(&reg->dev, "unable to get register 0x%x\n",
  262. abreg->regreg);
  263. return err;
  264. }
  265. return regval & AB3100_REG_ON_MASK;
  266. }
  267. static int ab3100_list_voltage_regulator(struct regulator_dev *reg,
  268. unsigned selector)
  269. {
  270. struct ab3100_regulator *abreg = reg->reg_data;
  271. if (selector > abreg->voltages_len)
  272. return -EINVAL;
  273. return abreg->typ_voltages[selector];
  274. }
  275. static int ab3100_get_voltage_regulator(struct regulator_dev *reg)
  276. {
  277. struct ab3100_regulator *abreg = reg->reg_data;
  278. u8 regval;
  279. int err;
  280. /* Return the voltage for fixed regulators immediately */
  281. if (abreg->fixed_voltage)
  282. return abreg->fixed_voltage;
  283. /*
  284. * For variable types, read out setting and index into
  285. * supplied voltage list.
  286. */
  287. err = ab3100_get_register_interruptible(abreg->ab3100,
  288. abreg->regreg, &regval);
  289. if (err) {
  290. dev_warn(&reg->dev,
  291. "failed to get regulator value in register %02x\n",
  292. abreg->regreg);
  293. return err;
  294. }
  295. /* The 3 highest bits index voltages */
  296. regval &= 0xE0;
  297. regval >>= 5;
  298. if (regval > abreg->voltages_len) {
  299. dev_err(&reg->dev,
  300. "regulator register %02x contains an illegal voltage setting\n",
  301. abreg->regreg);
  302. return -EINVAL;
  303. }
  304. return abreg->typ_voltages[regval];
  305. }
  306. static int ab3100_get_best_voltage_index(struct regulator_dev *reg,
  307. int min_uV, int max_uV)
  308. {
  309. struct ab3100_regulator *abreg = reg->reg_data;
  310. int i;
  311. int bestmatch;
  312. int bestindex;
  313. /*
  314. * Locate the minimum voltage fitting the criteria on
  315. * this regulator. The switchable voltages are not
  316. * in strict falling order so we need to check them
  317. * all for the best match.
  318. */
  319. bestmatch = INT_MAX;
  320. bestindex = -1;
  321. for (i = 0; i < abreg->voltages_len; i++) {
  322. if (abreg->typ_voltages[i] <= max_uV &&
  323. abreg->typ_voltages[i] >= min_uV &&
  324. abreg->typ_voltages[i] < bestmatch) {
  325. bestmatch = abreg->typ_voltages[i];
  326. bestindex = i;
  327. }
  328. }
  329. if (bestindex < 0) {
  330. dev_warn(&reg->dev, "requested %d<=x<=%d uV, out of range!\n",
  331. min_uV, max_uV);
  332. return -EINVAL;
  333. }
  334. return bestindex;
  335. }
  336. static int ab3100_set_voltage_regulator(struct regulator_dev *reg,
  337. int min_uV, int max_uV)
  338. {
  339. struct ab3100_regulator *abreg = reg->reg_data;
  340. u8 regval;
  341. int err;
  342. int bestindex;
  343. bestindex = ab3100_get_best_voltage_index(reg, min_uV, max_uV);
  344. if (bestindex < 0)
  345. return bestindex;
  346. err = ab3100_get_register_interruptible(abreg->ab3100,
  347. abreg->regreg, &regval);
  348. if (err) {
  349. dev_warn(&reg->dev,
  350. "failed to get regulator register %02x\n",
  351. abreg->regreg);
  352. return err;
  353. }
  354. /* The highest three bits control the variable regulators */
  355. regval &= ~0xE0;
  356. regval |= (bestindex << 5);
  357. err = ab3100_set_register_interruptible(abreg->ab3100,
  358. abreg->regreg, regval);
  359. if (err)
  360. dev_warn(&reg->dev, "failed to set regulator register %02x\n",
  361. abreg->regreg);
  362. return err;
  363. }
  364. static int ab3100_set_suspend_voltage_regulator(struct regulator_dev *reg,
  365. int uV)
  366. {
  367. struct ab3100_regulator *abreg = reg->reg_data;
  368. u8 regval;
  369. int err;
  370. int bestindex;
  371. u8 targetreg;
  372. if (abreg->regreg == AB3100_LDO_E)
  373. targetreg = AB3100_LDO_E_SLEEP;
  374. else if (abreg->regreg == AB3100_BUCK)
  375. targetreg = AB3100_BUCK_SLEEP;
  376. else
  377. return -EINVAL;
  378. /* LDO E and BUCK have special suspend voltages you can set */
  379. bestindex = ab3100_get_best_voltage_index(reg, uV, uV);
  380. err = ab3100_get_register_interruptible(abreg->ab3100,
  381. targetreg, &regval);
  382. if (err) {
  383. dev_warn(&reg->dev,
  384. "failed to get regulator register %02x\n",
  385. targetreg);
  386. return err;
  387. }
  388. /* The highest three bits control the variable regulators */
  389. regval &= ~0xE0;
  390. regval |= (bestindex << 5);
  391. err = ab3100_set_register_interruptible(abreg->ab3100,
  392. targetreg, regval);
  393. if (err)
  394. dev_warn(&reg->dev, "failed to set regulator register %02x\n",
  395. abreg->regreg);
  396. return err;
  397. }
  398. /*
  399. * The external regulator can just define a fixed voltage.
  400. */
  401. static int ab3100_get_voltage_regulator_external(struct regulator_dev *reg)
  402. {
  403. struct ab3100_regulator *abreg = reg->reg_data;
  404. return abreg->plfdata->external_voltage;
  405. }
  406. static struct regulator_ops regulator_ops_fixed = {
  407. .enable = ab3100_enable_regulator,
  408. .disable = ab3100_disable_regulator,
  409. .is_enabled = ab3100_is_enabled_regulator,
  410. .get_voltage = ab3100_get_voltage_regulator,
  411. };
  412. static struct regulator_ops regulator_ops_variable = {
  413. .enable = ab3100_enable_regulator,
  414. .disable = ab3100_disable_regulator,
  415. .is_enabled = ab3100_is_enabled_regulator,
  416. .get_voltage = ab3100_get_voltage_regulator,
  417. .set_voltage = ab3100_set_voltage_regulator,
  418. .list_voltage = ab3100_list_voltage_regulator,
  419. };
  420. static struct regulator_ops regulator_ops_variable_sleepable = {
  421. .enable = ab3100_enable_regulator,
  422. .disable = ab3100_disable_regulator,
  423. .is_enabled = ab3100_is_enabled_regulator,
  424. .get_voltage = ab3100_get_voltage_regulator,
  425. .set_voltage = ab3100_set_voltage_regulator,
  426. .set_suspend_voltage = ab3100_set_suspend_voltage_regulator,
  427. .list_voltage = ab3100_list_voltage_regulator,
  428. };
  429. /*
  430. * LDO EXT is an external regulator so it is really
  431. * not possible to set any voltage locally here, AB3100
  432. * is an on/off switch plain an simple. The external
  433. * voltage is defined in the board set-up if any.
  434. */
  435. static struct regulator_ops regulator_ops_external = {
  436. .enable = ab3100_enable_regulator,
  437. .disable = ab3100_disable_regulator,
  438. .is_enabled = ab3100_is_enabled_regulator,
  439. .get_voltage = ab3100_get_voltage_regulator_external,
  440. };
  441. static struct regulator_desc
  442. ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
  443. {
  444. .name = "LDO_A",
  445. .id = AB3100_LDO_A,
  446. .ops = &regulator_ops_fixed,
  447. .type = REGULATOR_VOLTAGE,
  448. },
  449. {
  450. .name = "LDO_C",
  451. .id = AB3100_LDO_C,
  452. .ops = &regulator_ops_fixed,
  453. .type = REGULATOR_VOLTAGE,
  454. },
  455. {
  456. .name = "LDO_D",
  457. .id = AB3100_LDO_D,
  458. .ops = &regulator_ops_fixed,
  459. .type = REGULATOR_VOLTAGE,
  460. },
  461. {
  462. .name = "LDO_E",
  463. .id = AB3100_LDO_E,
  464. .ops = &regulator_ops_variable_sleepable,
  465. .n_voltages = ARRAY_SIZE(ldo_e_buck_typ_voltages),
  466. .type = REGULATOR_VOLTAGE,
  467. },
  468. {
  469. .name = "LDO_F",
  470. .id = AB3100_LDO_F,
  471. .ops = &regulator_ops_variable,
  472. .n_voltages = ARRAY_SIZE(ldo_f_typ_voltages),
  473. .type = REGULATOR_VOLTAGE,
  474. },
  475. {
  476. .name = "LDO_G",
  477. .id = AB3100_LDO_G,
  478. .ops = &regulator_ops_variable,
  479. .n_voltages = ARRAY_SIZE(ldo_g_typ_voltages),
  480. .type = REGULATOR_VOLTAGE,
  481. },
  482. {
  483. .name = "LDO_H",
  484. .id = AB3100_LDO_H,
  485. .ops = &regulator_ops_variable,
  486. .n_voltages = ARRAY_SIZE(ldo_h_typ_voltages),
  487. .type = REGULATOR_VOLTAGE,
  488. },
  489. {
  490. .name = "LDO_K",
  491. .id = AB3100_LDO_K,
  492. .ops = &regulator_ops_variable,
  493. .n_voltages = ARRAY_SIZE(ldo_k_typ_voltages),
  494. .type = REGULATOR_VOLTAGE,
  495. },
  496. {
  497. .name = "LDO_EXT",
  498. .id = AB3100_LDO_EXT,
  499. .ops = &regulator_ops_external,
  500. .type = REGULATOR_VOLTAGE,
  501. },
  502. {
  503. .name = "BUCK",
  504. .id = AB3100_BUCK,
  505. .ops = &regulator_ops_variable_sleepable,
  506. .n_voltages = ARRAY_SIZE(ldo_e_buck_typ_voltages),
  507. .type = REGULATOR_VOLTAGE,
  508. },
  509. };
  510. /*
  511. * NOTE: the following functions are regulators pluralis - it is the
  512. * binding to the AB3100 core driver and the parent platform device
  513. * for all the different regulators.
  514. */
  515. static int __init ab3100_regulators_probe(struct platform_device *pdev)
  516. {
  517. struct ab3100_platform_data *plfdata = pdev->dev.platform_data;
  518. struct ab3100 *ab3100 = platform_get_drvdata(pdev);
  519. int err = 0;
  520. u8 data;
  521. int i;
  522. /* Check chip state */
  523. err = ab3100_get_register_interruptible(ab3100,
  524. AB3100_LDO_D, &data);
  525. if (err) {
  526. dev_err(&pdev->dev, "could not read initial status of LDO_D\n");
  527. return err;
  528. }
  529. if (data & 0x10)
  530. dev_notice(&pdev->dev,
  531. "chip is already in active mode (Warm start)\n");
  532. else
  533. dev_notice(&pdev->dev,
  534. "chip is in inactive mode (Cold start)\n");
  535. /* Set up regulators */
  536. for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) {
  537. err = ab3100_set_register_interruptible(ab3100,
  538. ab3100_reg_init_order[i],
  539. plfdata->reg_initvals[i]);
  540. if (err) {
  541. dev_err(&pdev->dev, "regulator initialization failed with error %d\n",
  542. err);
  543. return err;
  544. }
  545. }
  546. if (err) {
  547. dev_err(&pdev->dev,
  548. "LDO D regulator initialization failed with error %d\n",
  549. err);
  550. return err;
  551. }
  552. /* Register the regulators */
  553. for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
  554. struct ab3100_regulator *reg = &ab3100_regulators[i];
  555. struct regulator_dev *rdev;
  556. /*
  557. * Initialize per-regulator struct.
  558. * Inherit platform data, this comes down from the
  559. * i2c boarddata, from the machine. So if you want to
  560. * see what it looks like for a certain machine, go
  561. * into the machine I2C setup.
  562. */
  563. reg->ab3100 = ab3100;
  564. reg->plfdata = plfdata;
  565. /*
  566. * Register the regulator, pass around
  567. * the ab3100_regulator struct
  568. */
  569. rdev = regulator_register(&ab3100_regulator_desc[i],
  570. &pdev->dev,
  571. &plfdata->reg_constraints[i],
  572. reg);
  573. if (IS_ERR(rdev)) {
  574. err = PTR_ERR(rdev);
  575. dev_err(&pdev->dev,
  576. "%s: failed to register regulator %s err %d\n",
  577. __func__, ab3100_regulator_desc[i].name,
  578. err);
  579. i--;
  580. /* remove the already registered regulators */
  581. while (i > 0) {
  582. regulator_unregister(ab3100_regulators[i].rdev);
  583. i--;
  584. }
  585. return err;
  586. }
  587. /* Then set a pointer back to the registered regulator */
  588. reg->rdev = rdev;
  589. }
  590. return 0;
  591. }
  592. static int __exit ab3100_regulators_remove(struct platform_device *pdev)
  593. {
  594. int i;
  595. for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
  596. struct ab3100_regulator *reg = &ab3100_regulators[i];
  597. regulator_unregister(reg->rdev);
  598. }
  599. return 0;
  600. }
  601. static struct platform_driver ab3100_regulators_driver = {
  602. .driver = {
  603. .name = "ab3100-regulators",
  604. .owner = THIS_MODULE,
  605. },
  606. .probe = ab3100_regulators_probe,
  607. .remove = __exit_p(ab3100_regulators_remove),
  608. };
  609. static __init int ab3100_regulators_init(void)
  610. {
  611. return platform_driver_register(&ab3100_regulators_driver);
  612. }
  613. static __exit void ab3100_regulators_exit(void)
  614. {
  615. platform_driver_register(&ab3100_regulators_driver);
  616. }
  617. subsys_initcall(ab3100_regulators_init);
  618. module_exit(ab3100_regulators_exit);
  619. MODULE_AUTHOR("Mattias Wallin <mattias.wallin@stericsson.com>");
  620. MODULE_DESCRIPTION("AB3100 Regulator driver");
  621. MODULE_LICENSE("GPL");
  622. MODULE_ALIAS("platform:ab3100-regulators");