ab3100.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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/abx500.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. * @dev: handle to the device
  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 device *dev;
  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 ldo_e_buck_typ_voltages[] = {
  79. 1800000,
  80. 1400000,
  81. 1300000,
  82. 1200000,
  83. 1100000,
  84. 1050000,
  85. 900000,
  86. };
  87. static const int 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 ldo_g_typ_voltages[] = {
  98. 2850000,
  99. 2750000,
  100. 1800000,
  101. 1500000,
  102. };
  103. static const int ldo_h_typ_voltages[] = {
  104. 2750000,
  105. 1800000,
  106. 1500000,
  107. 1200000,
  108. };
  109. static const int 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 = abx500_get_register_interruptible(abreg->dev, 0, 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 = abx500_set_register_interruptible(abreg->dev, 0, 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. return 0;
  191. }
  192. static int ab3100_disable_regulator(struct regulator_dev *reg)
  193. {
  194. struct ab3100_regulator *abreg = reg->reg_data;
  195. int err;
  196. u8 regval;
  197. /*
  198. * LDO D is a special regulator. When it is disabled, the entire
  199. * system is shut down. So this is handled specially.
  200. */
  201. pr_info("Called ab3100_disable_regulator\n");
  202. if (abreg->regreg == AB3100_LDO_D) {
  203. dev_info(&reg->dev, "disabling LDO D - shut down system\n");
  204. /* Setting LDO D to 0x00 cuts the power to the SoC */
  205. return abx500_set_register_interruptible(abreg->dev, 0,
  206. AB3100_LDO_D, 0x00U);
  207. }
  208. /*
  209. * All other regulators are handled here
  210. */
  211. err = abx500_get_register_interruptible(abreg->dev, 0, abreg->regreg,
  212. &regval);
  213. if (err) {
  214. dev_err(&reg->dev, "unable to get register 0x%x\n",
  215. abreg->regreg);
  216. return err;
  217. }
  218. regval &= ~AB3100_REG_ON_MASK;
  219. return abx500_set_register_interruptible(abreg->dev, 0, abreg->regreg,
  220. regval);
  221. }
  222. static int ab3100_is_enabled_regulator(struct regulator_dev *reg)
  223. {
  224. struct ab3100_regulator *abreg = reg->reg_data;
  225. u8 regval;
  226. int err;
  227. err = abx500_get_register_interruptible(abreg->dev, 0, abreg->regreg,
  228. &regval);
  229. if (err) {
  230. dev_err(&reg->dev, "unable to get register 0x%x\n",
  231. abreg->regreg);
  232. return err;
  233. }
  234. return regval & AB3100_REG_ON_MASK;
  235. }
  236. static int ab3100_list_voltage_regulator(struct regulator_dev *reg,
  237. unsigned selector)
  238. {
  239. struct ab3100_regulator *abreg = reg->reg_data;
  240. if (selector >= abreg->voltages_len)
  241. return -EINVAL;
  242. return abreg->typ_voltages[selector];
  243. }
  244. static int ab3100_get_voltage_regulator(struct regulator_dev *reg)
  245. {
  246. struct ab3100_regulator *abreg = reg->reg_data;
  247. u8 regval;
  248. int err;
  249. /* Return the voltage for fixed regulators immediately */
  250. if (abreg->fixed_voltage)
  251. return abreg->fixed_voltage;
  252. /*
  253. * For variable types, read out setting and index into
  254. * supplied voltage list.
  255. */
  256. err = abx500_get_register_interruptible(abreg->dev, 0,
  257. abreg->regreg, &regval);
  258. if (err) {
  259. dev_warn(&reg->dev,
  260. "failed to get regulator value in register %02x\n",
  261. abreg->regreg);
  262. return err;
  263. }
  264. /* The 3 highest bits index voltages */
  265. regval &= 0xE0;
  266. regval >>= 5;
  267. if (regval >= abreg->voltages_len) {
  268. dev_err(&reg->dev,
  269. "regulator register %02x contains an illegal voltage setting\n",
  270. abreg->regreg);
  271. return -EINVAL;
  272. }
  273. return abreg->typ_voltages[regval];
  274. }
  275. static int ab3100_get_best_voltage_index(struct regulator_dev *reg,
  276. int min_uV, int max_uV)
  277. {
  278. struct ab3100_regulator *abreg = reg->reg_data;
  279. int i;
  280. int bestmatch;
  281. int bestindex;
  282. /*
  283. * Locate the minimum voltage fitting the criteria on
  284. * this regulator. The switchable voltages are not
  285. * in strict falling order so we need to check them
  286. * all for the best match.
  287. */
  288. bestmatch = INT_MAX;
  289. bestindex = -1;
  290. for (i = 0; i < abreg->voltages_len; i++) {
  291. if (abreg->typ_voltages[i] <= max_uV &&
  292. abreg->typ_voltages[i] >= min_uV &&
  293. abreg->typ_voltages[i] < bestmatch) {
  294. bestmatch = abreg->typ_voltages[i];
  295. bestindex = i;
  296. }
  297. }
  298. if (bestindex < 0) {
  299. dev_warn(&reg->dev, "requested %d<=x<=%d uV, out of range!\n",
  300. min_uV, max_uV);
  301. return -EINVAL;
  302. }
  303. return bestindex;
  304. }
  305. static int ab3100_set_voltage_regulator(struct regulator_dev *reg,
  306. int min_uV, int max_uV,
  307. unsigned *selector)
  308. {
  309. struct ab3100_regulator *abreg = reg->reg_data;
  310. u8 regval;
  311. int err;
  312. int bestindex;
  313. bestindex = ab3100_get_best_voltage_index(reg, min_uV, max_uV);
  314. if (bestindex < 0)
  315. return bestindex;
  316. *selector = bestindex;
  317. err = abx500_get_register_interruptible(abreg->dev, 0,
  318. abreg->regreg, &regval);
  319. if (err) {
  320. dev_warn(&reg->dev,
  321. "failed to get regulator register %02x\n",
  322. abreg->regreg);
  323. return err;
  324. }
  325. /* The highest three bits control the variable regulators */
  326. regval &= ~0xE0;
  327. regval |= (bestindex << 5);
  328. err = abx500_set_register_interruptible(abreg->dev, 0,
  329. abreg->regreg, regval);
  330. if (err)
  331. dev_warn(&reg->dev, "failed to set regulator register %02x\n",
  332. abreg->regreg);
  333. return err;
  334. }
  335. static int ab3100_set_suspend_voltage_regulator(struct regulator_dev *reg,
  336. int uV)
  337. {
  338. struct ab3100_regulator *abreg = reg->reg_data;
  339. u8 regval;
  340. int err;
  341. int bestindex;
  342. u8 targetreg;
  343. if (abreg->regreg == AB3100_LDO_E)
  344. targetreg = AB3100_LDO_E_SLEEP;
  345. else if (abreg->regreg == AB3100_BUCK)
  346. targetreg = AB3100_BUCK_SLEEP;
  347. else
  348. return -EINVAL;
  349. /* LDO E and BUCK have special suspend voltages you can set */
  350. bestindex = ab3100_get_best_voltage_index(reg, uV, uV);
  351. err = abx500_get_register_interruptible(abreg->dev, 0,
  352. targetreg, &regval);
  353. if (err) {
  354. dev_warn(&reg->dev,
  355. "failed to get regulator register %02x\n",
  356. targetreg);
  357. return err;
  358. }
  359. /* The highest three bits control the variable regulators */
  360. regval &= ~0xE0;
  361. regval |= (bestindex << 5);
  362. err = abx500_set_register_interruptible(abreg->dev, 0,
  363. targetreg, regval);
  364. if (err)
  365. dev_warn(&reg->dev, "failed to set regulator register %02x\n",
  366. abreg->regreg);
  367. return err;
  368. }
  369. /*
  370. * The external regulator can just define a fixed voltage.
  371. */
  372. static int ab3100_get_voltage_regulator_external(struct regulator_dev *reg)
  373. {
  374. struct ab3100_regulator *abreg = reg->reg_data;
  375. return abreg->plfdata->external_voltage;
  376. }
  377. static int ab3100_enable_time_regulator(struct regulator_dev *reg)
  378. {
  379. struct ab3100_regulator *abreg = reg->reg_data;
  380. /* Per-regulator power on delay from spec */
  381. switch (abreg->regreg) {
  382. case AB3100_LDO_A: /* Fallthrough */
  383. case AB3100_LDO_C: /* Fallthrough */
  384. case AB3100_LDO_D: /* Fallthrough */
  385. case AB3100_LDO_E: /* Fallthrough */
  386. case AB3100_LDO_H: /* Fallthrough */
  387. case AB3100_LDO_K:
  388. return 200;
  389. case AB3100_LDO_F:
  390. return 600;
  391. case AB3100_LDO_G:
  392. return 400;
  393. case AB3100_BUCK:
  394. return 1000;
  395. default:
  396. break;
  397. }
  398. return 0;
  399. }
  400. static struct regulator_ops regulator_ops_fixed = {
  401. .enable = ab3100_enable_regulator,
  402. .disable = ab3100_disable_regulator,
  403. .is_enabled = ab3100_is_enabled_regulator,
  404. .get_voltage = ab3100_get_voltage_regulator,
  405. .enable_time = ab3100_enable_time_regulator,
  406. };
  407. static struct regulator_ops regulator_ops_variable = {
  408. .enable = ab3100_enable_regulator,
  409. .disable = ab3100_disable_regulator,
  410. .is_enabled = ab3100_is_enabled_regulator,
  411. .get_voltage = ab3100_get_voltage_regulator,
  412. .set_voltage = ab3100_set_voltage_regulator,
  413. .list_voltage = ab3100_list_voltage_regulator,
  414. .enable_time = ab3100_enable_time_regulator,
  415. };
  416. static struct regulator_ops regulator_ops_variable_sleepable = {
  417. .enable = ab3100_enable_regulator,
  418. .disable = ab3100_disable_regulator,
  419. .is_enabled = ab3100_is_enabled_regulator,
  420. .get_voltage = ab3100_get_voltage_regulator,
  421. .set_voltage = ab3100_set_voltage_regulator,
  422. .set_suspend_voltage = ab3100_set_suspend_voltage_regulator,
  423. .list_voltage = ab3100_list_voltage_regulator,
  424. .enable_time = ab3100_enable_time_regulator,
  425. };
  426. /*
  427. * LDO EXT is an external regulator so it is really
  428. * not possible to set any voltage locally here, AB3100
  429. * is an on/off switch plain an simple. The external
  430. * voltage is defined in the board set-up if any.
  431. */
  432. static struct regulator_ops regulator_ops_external = {
  433. .enable = ab3100_enable_regulator,
  434. .disable = ab3100_disable_regulator,
  435. .is_enabled = ab3100_is_enabled_regulator,
  436. .get_voltage = ab3100_get_voltage_regulator_external,
  437. };
  438. static struct regulator_desc
  439. ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
  440. {
  441. .name = "LDO_A",
  442. .id = AB3100_LDO_A,
  443. .ops = &regulator_ops_fixed,
  444. .type = REGULATOR_VOLTAGE,
  445. .owner = THIS_MODULE,
  446. },
  447. {
  448. .name = "LDO_C",
  449. .id = AB3100_LDO_C,
  450. .ops = &regulator_ops_fixed,
  451. .type = REGULATOR_VOLTAGE,
  452. .owner = THIS_MODULE,
  453. },
  454. {
  455. .name = "LDO_D",
  456. .id = AB3100_LDO_D,
  457. .ops = &regulator_ops_fixed,
  458. .type = REGULATOR_VOLTAGE,
  459. .owner = THIS_MODULE,
  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. .owner = THIS_MODULE,
  468. },
  469. {
  470. .name = "LDO_F",
  471. .id = AB3100_LDO_F,
  472. .ops = &regulator_ops_variable,
  473. .n_voltages = ARRAY_SIZE(ldo_f_typ_voltages),
  474. .type = REGULATOR_VOLTAGE,
  475. .owner = THIS_MODULE,
  476. },
  477. {
  478. .name = "LDO_G",
  479. .id = AB3100_LDO_G,
  480. .ops = &regulator_ops_variable,
  481. .n_voltages = ARRAY_SIZE(ldo_g_typ_voltages),
  482. .type = REGULATOR_VOLTAGE,
  483. .owner = THIS_MODULE,
  484. },
  485. {
  486. .name = "LDO_H",
  487. .id = AB3100_LDO_H,
  488. .ops = &regulator_ops_variable,
  489. .n_voltages = ARRAY_SIZE(ldo_h_typ_voltages),
  490. .type = REGULATOR_VOLTAGE,
  491. .owner = THIS_MODULE,
  492. },
  493. {
  494. .name = "LDO_K",
  495. .id = AB3100_LDO_K,
  496. .ops = &regulator_ops_variable,
  497. .n_voltages = ARRAY_SIZE(ldo_k_typ_voltages),
  498. .type = REGULATOR_VOLTAGE,
  499. .owner = THIS_MODULE,
  500. },
  501. {
  502. .name = "LDO_EXT",
  503. .id = AB3100_LDO_EXT,
  504. .ops = &regulator_ops_external,
  505. .type = REGULATOR_VOLTAGE,
  506. .owner = THIS_MODULE,
  507. },
  508. {
  509. .name = "BUCK",
  510. .id = AB3100_BUCK,
  511. .ops = &regulator_ops_variable_sleepable,
  512. .n_voltages = ARRAY_SIZE(ldo_e_buck_typ_voltages),
  513. .type = REGULATOR_VOLTAGE,
  514. .owner = THIS_MODULE,
  515. },
  516. };
  517. /*
  518. * NOTE: the following functions are regulators pluralis - it is the
  519. * binding to the AB3100 core driver and the parent platform device
  520. * for all the different regulators.
  521. */
  522. static int __devinit ab3100_regulators_probe(struct platform_device *pdev)
  523. {
  524. struct ab3100_platform_data *plfdata = pdev->dev.platform_data;
  525. int err = 0;
  526. u8 data;
  527. int i;
  528. /* Check chip state */
  529. err = abx500_get_register_interruptible(&pdev->dev, 0,
  530. AB3100_LDO_D, &data);
  531. if (err) {
  532. dev_err(&pdev->dev, "could not read initial status of LDO_D\n");
  533. return err;
  534. }
  535. if (data & 0x10)
  536. dev_notice(&pdev->dev,
  537. "chip is already in active mode (Warm start)\n");
  538. else
  539. dev_notice(&pdev->dev,
  540. "chip is in inactive mode (Cold start)\n");
  541. /* Set up regulators */
  542. for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) {
  543. err = abx500_set_register_interruptible(&pdev->dev, 0,
  544. ab3100_reg_init_order[i],
  545. plfdata->reg_initvals[i]);
  546. if (err) {
  547. dev_err(&pdev->dev, "regulator initialization failed with error %d\n",
  548. err);
  549. return err;
  550. }
  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->dev = &pdev->dev;
  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, NULL);
  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. /* remove the already registered regulators */
  580. while (--i >= 0)
  581. regulator_unregister(ab3100_regulators[i].rdev);
  582. return err;
  583. }
  584. /* Then set a pointer back to the registered regulator */
  585. reg->rdev = rdev;
  586. }
  587. return 0;
  588. }
  589. static int __devexit ab3100_regulators_remove(struct platform_device *pdev)
  590. {
  591. int i;
  592. for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
  593. struct ab3100_regulator *reg = &ab3100_regulators[i];
  594. regulator_unregister(reg->rdev);
  595. }
  596. return 0;
  597. }
  598. static struct platform_driver ab3100_regulators_driver = {
  599. .driver = {
  600. .name = "ab3100-regulators",
  601. .owner = THIS_MODULE,
  602. },
  603. .probe = ab3100_regulators_probe,
  604. .remove = __devexit_p(ab3100_regulators_remove),
  605. };
  606. static __init int ab3100_regulators_init(void)
  607. {
  608. return platform_driver_register(&ab3100_regulators_driver);
  609. }
  610. static __exit void ab3100_regulators_exit(void)
  611. {
  612. platform_driver_unregister(&ab3100_regulators_driver);
  613. }
  614. subsys_initcall(ab3100_regulators_init);
  615. module_exit(ab3100_regulators_exit);
  616. MODULE_AUTHOR("Mattias Wallin <mattias.wallin@stericsson.com>");
  617. MODULE_DESCRIPTION("AB3100 Regulator driver");
  618. MODULE_LICENSE("GPL");
  619. MODULE_ALIAS("platform:ab3100-regulators");