ab3100.c 16 KB

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