ab3100.c 17 KB

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