ab3100.c 16 KB

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