da9052-regulator.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. /*
  2. * da9052-regulator.c: Regulator driver for DA9052
  3. *
  4. * Copyright(c) 2011 Dialog Semiconductor Ltd.
  5. *
  6. * Author: David Dajun Chen <dchen@diasemi.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. */
  14. #include <linux/module.h>
  15. #include <linux/moduleparam.h>
  16. #include <linux/init.h>
  17. #include <linux/err.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/regulator/driver.h>
  20. #include <linux/regulator/machine.h>
  21. #include <linux/mfd/da9052/da9052.h>
  22. #include <linux/mfd/da9052/reg.h>
  23. #include <linux/mfd/da9052/pdata.h>
  24. /* Buck step size */
  25. #define DA9052_BUCK_PERI_3uV_STEP 100000
  26. #define DA9052_BUCK_PERI_REG_MAP_UPTO_3uV 24
  27. #define DA9052_CONST_3uV 3000000
  28. #define DA9052_MIN_UA 0
  29. #define DA9052_MAX_UA 3
  30. #define DA9052_CURRENT_RANGE 4
  31. /* Bit masks */
  32. #define DA9052_BUCK_ILIM_MASK_EVEN 0x0c
  33. #define DA9052_BUCK_ILIM_MASK_ODD 0xc0
  34. static const u32 da9052_current_limits[3][4] = {
  35. {700000, 800000, 1000000, 1200000}, /* DA9052-BC BUCKs */
  36. {1600000, 2000000, 2400000, 3000000}, /* DA9053-AA/Bx BUCK-CORE */
  37. {800000, 1000000, 1200000, 1500000}, /* DA9053-AA/Bx BUCK-PRO,
  38. * BUCK-MEM and BUCK-PERI
  39. */
  40. };
  41. struct da9052_regulator_info {
  42. struct regulator_desc reg_desc;
  43. int step_uV;
  44. int min_uV;
  45. int max_uV;
  46. unsigned char volt_shift;
  47. unsigned char en_bit;
  48. unsigned char activate_bit;
  49. };
  50. struct da9052_regulator {
  51. struct da9052 *da9052;
  52. struct da9052_regulator_info *info;
  53. struct regulator_dev *rdev;
  54. };
  55. static int verify_range(struct da9052_regulator_info *info,
  56. int min_uV, int max_uV)
  57. {
  58. if (min_uV > info->max_uV || max_uV < info->min_uV)
  59. return -EINVAL;
  60. return 0;
  61. }
  62. static int da9052_regulator_enable(struct regulator_dev *rdev)
  63. {
  64. struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
  65. struct da9052_regulator_info *info = regulator->info;
  66. int offset = rdev_get_id(rdev);
  67. return da9052_reg_update(regulator->da9052,
  68. DA9052_BUCKCORE_REG + offset,
  69. 1 << info->en_bit, 1 << info->en_bit);
  70. }
  71. static int da9052_regulator_disable(struct regulator_dev *rdev)
  72. {
  73. struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
  74. struct da9052_regulator_info *info = regulator->info;
  75. int offset = rdev_get_id(rdev);
  76. return da9052_reg_update(regulator->da9052,
  77. DA9052_BUCKCORE_REG + offset,
  78. 1 << info->en_bit, 0);
  79. }
  80. static int da9052_regulator_is_enabled(struct regulator_dev *rdev)
  81. {
  82. struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
  83. struct da9052_regulator_info *info = regulator->info;
  84. int offset = rdev_get_id(rdev);
  85. int ret;
  86. ret = da9052_reg_read(regulator->da9052, DA9052_BUCKCORE_REG + offset);
  87. if (ret < 0)
  88. return ret;
  89. return ret & (1 << info->en_bit);
  90. }
  91. static int da9052_dcdc_get_current_limit(struct regulator_dev *rdev)
  92. {
  93. struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
  94. int offset = rdev_get_id(rdev);
  95. int ret, row = 2;
  96. ret = da9052_reg_read(regulator->da9052, DA9052_BUCKA_REG + offset/2);
  97. if (ret < 0)
  98. return ret;
  99. /* Determine the even or odd position of the buck current limit
  100. * register field
  101. */
  102. if (offset % 2 == 0)
  103. ret = (ret & DA9052_BUCK_ILIM_MASK_EVEN) >> 2;
  104. else
  105. ret = (ret & DA9052_BUCK_ILIM_MASK_ODD) >> 6;
  106. /* Select the appropriate current limit range */
  107. if (regulator->da9052->chip_id == DA9052)
  108. row = 0;
  109. else if (offset == 0)
  110. row = 1;
  111. return da9052_current_limits[row][ret];
  112. }
  113. static int da9052_dcdc_set_current_limit(struct regulator_dev *rdev, int min_uA,
  114. int max_uA)
  115. {
  116. struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
  117. int offset = rdev_get_id(rdev);
  118. int reg_val = 0;
  119. int i, row = 2;
  120. /* Select the appropriate current limit range */
  121. if (regulator->da9052->chip_id == DA9052)
  122. row = 0;
  123. else if (offset == 0)
  124. row = 1;
  125. if (min_uA > da9052_current_limits[row][DA9052_MAX_UA] ||
  126. max_uA < da9052_current_limits[row][DA9052_MIN_UA])
  127. return -EINVAL;
  128. for (i = 0; i < DA9052_CURRENT_RANGE; i++) {
  129. if (min_uA <= da9052_current_limits[row][i]) {
  130. reg_val = i;
  131. break;
  132. }
  133. }
  134. /* Determine the even or odd position of the buck current limit
  135. * register field
  136. */
  137. if (offset % 2 == 0)
  138. return da9052_reg_update(regulator->da9052,
  139. DA9052_BUCKA_REG + offset/2,
  140. DA9052_BUCK_ILIM_MASK_EVEN,
  141. reg_val << 2);
  142. else
  143. return da9052_reg_update(regulator->da9052,
  144. DA9052_BUCKA_REG + offset/2,
  145. DA9052_BUCK_ILIM_MASK_ODD,
  146. reg_val << 6);
  147. }
  148. static int da9052_list_buckperi_voltage(struct regulator_dev *rdev,
  149. unsigned int selector)
  150. {
  151. struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
  152. struct da9052_regulator_info *info = regulator->info;
  153. int volt_uV;
  154. if ((regulator->da9052->chip_id == DA9052) &&
  155. (selector >= DA9052_BUCK_PERI_REG_MAP_UPTO_3uV)) {
  156. volt_uV = ((DA9052_BUCK_PERI_REG_MAP_UPTO_3uV * info->step_uV)
  157. + info->min_uV);
  158. volt_uV += (selector - DA9052_BUCK_PERI_REG_MAP_UPTO_3uV)
  159. * (DA9052_BUCK_PERI_3uV_STEP);
  160. } else
  161. volt_uV = (selector * info->step_uV) + info->min_uV;
  162. if (volt_uV > info->max_uV)
  163. return -EINVAL;
  164. return volt_uV;
  165. }
  166. static int da9052_list_voltage(struct regulator_dev *rdev,
  167. unsigned int selector)
  168. {
  169. struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
  170. struct da9052_regulator_info *info = regulator->info;
  171. int volt_uV;
  172. volt_uV = info->min_uV + info->step_uV * selector;
  173. if (volt_uV > info->max_uV)
  174. return -EINVAL;
  175. return volt_uV;
  176. }
  177. static int da9052_regulator_set_voltage_int(struct regulator_dev *rdev,
  178. int min_uV, int max_uV,
  179. unsigned int *selector)
  180. {
  181. struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
  182. struct da9052_regulator_info *info = regulator->info;
  183. int offset = rdev_get_id(rdev);
  184. int ret;
  185. ret = verify_range(info, min_uV, max_uV);
  186. if (ret < 0)
  187. return ret;
  188. if (min_uV < info->min_uV)
  189. min_uV = info->min_uV;
  190. *selector = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
  191. ret = da9052_list_voltage(rdev, *selector);
  192. if (ret < 0)
  193. return ret;
  194. return da9052_reg_update(regulator->da9052,
  195. DA9052_BUCKCORE_REG + offset,
  196. (1 << info->volt_shift) - 1, *selector);
  197. }
  198. static int da9052_set_ldo_voltage(struct regulator_dev *rdev,
  199. int min_uV, int max_uV,
  200. unsigned int *selector)
  201. {
  202. return da9052_regulator_set_voltage_int(rdev, min_uV, max_uV, selector);
  203. }
  204. static int da9052_set_ldo5_6_voltage(struct regulator_dev *rdev,
  205. int min_uV, int max_uV,
  206. unsigned int *selector)
  207. {
  208. struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
  209. struct da9052_regulator_info *info = regulator->info;
  210. int ret;
  211. ret = da9052_regulator_set_voltage_int(rdev, min_uV, max_uV, selector);
  212. if (ret < 0)
  213. return ret;
  214. /* Some LDOs are DVC controlled which requires enabling of
  215. * the LDO activate bit to implment the changes on the
  216. * LDO output.
  217. */
  218. return da9052_reg_update(regulator->da9052, DA9052_SUPPLY_REG,
  219. info->activate_bit, info->activate_bit);
  220. }
  221. static int da9052_set_dcdc_voltage(struct regulator_dev *rdev,
  222. int min_uV, int max_uV,
  223. unsigned int *selector)
  224. {
  225. struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
  226. struct da9052_regulator_info *info = regulator->info;
  227. int ret;
  228. ret = da9052_regulator_set_voltage_int(rdev, min_uV, max_uV, selector);
  229. if (ret < 0)
  230. return ret;
  231. /* Some DCDCs are DVC controlled which requires enabling of
  232. * the DCDC activate bit to implment the changes on the
  233. * DCDC output.
  234. */
  235. return da9052_reg_update(regulator->da9052, DA9052_SUPPLY_REG,
  236. info->activate_bit, info->activate_bit);
  237. }
  238. static int da9052_get_regulator_voltage_sel(struct regulator_dev *rdev)
  239. {
  240. struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
  241. struct da9052_regulator_info *info = regulator->info;
  242. int offset = rdev_get_id(rdev);
  243. int ret;
  244. ret = da9052_reg_read(regulator->da9052, DA9052_BUCKCORE_REG + offset);
  245. if (ret < 0)
  246. return ret;
  247. ret &= ((1 << info->volt_shift) - 1);
  248. return ret;
  249. }
  250. static int da9052_set_buckperi_voltage(struct regulator_dev *rdev, int min_uV,
  251. int max_uV, unsigned int *selector)
  252. {
  253. struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
  254. struct da9052_regulator_info *info = regulator->info;
  255. int offset = rdev_get_id(rdev);
  256. int ret;
  257. ret = verify_range(info, min_uV, max_uV);
  258. if (ret < 0)
  259. return ret;
  260. if (min_uV < info->min_uV)
  261. min_uV = info->min_uV;
  262. if ((regulator->da9052->chip_id == DA9052) &&
  263. (min_uV >= DA9052_CONST_3uV))
  264. *selector = DA9052_BUCK_PERI_REG_MAP_UPTO_3uV +
  265. DIV_ROUND_UP(min_uV - DA9052_CONST_3uV,
  266. DA9052_BUCK_PERI_3uV_STEP);
  267. else
  268. *selector = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
  269. ret = da9052_list_buckperi_voltage(rdev, *selector);
  270. if (ret < 0)
  271. return ret;
  272. return da9052_reg_update(regulator->da9052,
  273. DA9052_BUCKCORE_REG + offset,
  274. (1 << info->volt_shift) - 1, *selector);
  275. }
  276. static int da9052_get_buckperi_voltage_sel(struct regulator_dev *rdev)
  277. {
  278. struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
  279. struct da9052_regulator_info *info = regulator->info;
  280. int offset = rdev_get_id(rdev);
  281. int ret;
  282. ret = da9052_reg_read(regulator->da9052, DA9052_BUCKCORE_REG + offset);
  283. if (ret < 0)
  284. return ret;
  285. ret &= ((1 << info->volt_shift) - 1);
  286. return ret;
  287. }
  288. static struct regulator_ops da9052_buckperi_ops = {
  289. .list_voltage = da9052_list_buckperi_voltage,
  290. .get_voltage_sel = da9052_get_buckperi_voltage_sel,
  291. .set_voltage = da9052_set_buckperi_voltage,
  292. .get_current_limit = da9052_dcdc_get_current_limit,
  293. .set_current_limit = da9052_dcdc_set_current_limit,
  294. .is_enabled = da9052_regulator_is_enabled,
  295. .enable = da9052_regulator_enable,
  296. .disable = da9052_regulator_disable,
  297. };
  298. static struct regulator_ops da9052_dcdc_ops = {
  299. .set_voltage = da9052_set_dcdc_voltage,
  300. .get_current_limit = da9052_dcdc_get_current_limit,
  301. .set_current_limit = da9052_dcdc_set_current_limit,
  302. .list_voltage = da9052_list_voltage,
  303. .get_voltage_sel = da9052_get_regulator_voltage_sel,
  304. .is_enabled = da9052_regulator_is_enabled,
  305. .enable = da9052_regulator_enable,
  306. .disable = da9052_regulator_disable,
  307. };
  308. static struct regulator_ops da9052_ldo5_6_ops = {
  309. .set_voltage = da9052_set_ldo5_6_voltage,
  310. .list_voltage = da9052_list_voltage,
  311. .get_voltage_sel = da9052_get_regulator_voltage_sel,
  312. .is_enabled = da9052_regulator_is_enabled,
  313. .enable = da9052_regulator_enable,
  314. .disable = da9052_regulator_disable,
  315. };
  316. static struct regulator_ops da9052_ldo_ops = {
  317. .set_voltage = da9052_set_ldo_voltage,
  318. .list_voltage = da9052_list_voltage,
  319. .get_voltage_sel = da9052_get_regulator_voltage_sel,
  320. .is_enabled = da9052_regulator_is_enabled,
  321. .enable = da9052_regulator_enable,
  322. .disable = da9052_regulator_disable,
  323. };
  324. #define DA9052_LDO5_6(_id, step, min, max, sbits, ebits, abits) \
  325. {\
  326. .reg_desc = {\
  327. .name = "LDO" #_id,\
  328. .ops = &da9052_ldo5_6_ops,\
  329. .type = REGULATOR_VOLTAGE,\
  330. .id = _id,\
  331. .n_voltages = (max - min) / step + 1, \
  332. .owner = THIS_MODULE,\
  333. },\
  334. .min_uV = (min) * 1000,\
  335. .max_uV = (max) * 1000,\
  336. .step_uV = (step) * 1000,\
  337. .volt_shift = (sbits),\
  338. .en_bit = (ebits),\
  339. .activate_bit = (abits),\
  340. }
  341. #define DA9052_LDO(_id, step, min, max, sbits, ebits, abits) \
  342. {\
  343. .reg_desc = {\
  344. .name = "LDO" #_id,\
  345. .ops = &da9052_ldo_ops,\
  346. .type = REGULATOR_VOLTAGE,\
  347. .id = _id,\
  348. .n_voltages = (max - min) / step + 1, \
  349. .owner = THIS_MODULE,\
  350. },\
  351. .min_uV = (min) * 1000,\
  352. .max_uV = (max) * 1000,\
  353. .step_uV = (step) * 1000,\
  354. .volt_shift = (sbits),\
  355. .en_bit = (ebits),\
  356. .activate_bit = (abits),\
  357. }
  358. #define DA9052_DCDC(_id, step, min, max, sbits, ebits, abits) \
  359. {\
  360. .reg_desc = {\
  361. .name = "BUCK" #_id,\
  362. .ops = &da9052_dcdc_ops,\
  363. .type = REGULATOR_VOLTAGE,\
  364. .id = _id,\
  365. .n_voltages = (max - min) / step + 1, \
  366. .owner = THIS_MODULE,\
  367. },\
  368. .min_uV = (min) * 1000,\
  369. .max_uV = (max) * 1000,\
  370. .step_uV = (step) * 1000,\
  371. .volt_shift = (sbits),\
  372. .en_bit = (ebits),\
  373. .activate_bit = (abits),\
  374. }
  375. #define DA9052_BUCKPERI(_id, step, min, max, sbits, ebits, abits) \
  376. {\
  377. .reg_desc = {\
  378. .name = "BUCK" #_id,\
  379. .ops = &da9052_buckperi_ops,\
  380. .type = REGULATOR_VOLTAGE,\
  381. .id = _id,\
  382. .n_voltages = (max - min) / step + 1, \
  383. .owner = THIS_MODULE,\
  384. },\
  385. .min_uV = (min) * 1000,\
  386. .max_uV = (max) * 1000,\
  387. .step_uV = (step) * 1000,\
  388. .volt_shift = (sbits),\
  389. .en_bit = (ebits),\
  390. .activate_bit = (abits),\
  391. }
  392. static struct da9052_regulator_info da9052_regulator_info[] = {
  393. /* Buck1 - 4 */
  394. DA9052_DCDC(0, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO),
  395. DA9052_DCDC(1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO),
  396. DA9052_DCDC(2, 25, 925, 2500, 6, 6, DA9052_SUPPLY_VBMEMGO),
  397. DA9052_BUCKPERI(3, 50, 1800, 3600, 5, 6, 0),
  398. /* LD01 - LDO10 */
  399. DA9052_LDO(4, 50, 600, 1800, 5, 6, 0),
  400. DA9052_LDO5_6(5, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO),
  401. DA9052_LDO5_6(6, 25, 1725, 3300, 6, 6, DA9052_SUPPLY_VLDO3GO),
  402. DA9052_LDO(7, 25, 1725, 3300, 6, 6, 0),
  403. DA9052_LDO(8, 50, 1200, 3600, 6, 6, 0),
  404. DA9052_LDO(9, 50, 1200, 3600, 6, 6, 0),
  405. DA9052_LDO(10, 50, 1200, 3600, 6, 6, 0),
  406. DA9052_LDO(11, 50, 1200, 3600, 6, 6, 0),
  407. DA9052_LDO(12, 50, 1250, 3650, 6, 6, 0),
  408. DA9052_LDO(13, 50, 1200, 3600, 6, 6, 0),
  409. };
  410. static struct da9052_regulator_info da9053_regulator_info[] = {
  411. /* Buck1 - 4 */
  412. DA9052_DCDC(0, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO),
  413. DA9052_DCDC(1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO),
  414. DA9052_DCDC(2, 25, 925, 2500, 6, 6, DA9052_SUPPLY_VBMEMGO),
  415. DA9052_BUCKPERI(3, 25, 925, 2500, 6, 6, 0),
  416. /* LD01 - LDO10 */
  417. DA9052_LDO(4, 50, 600, 1800, 5, 6, 0),
  418. DA9052_LDO5_6(5, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO),
  419. DA9052_LDO5_6(6, 25, 1725, 3300, 6, 6, DA9052_SUPPLY_VLDO3GO),
  420. DA9052_LDO(7, 25, 1725, 3300, 6, 6, 0),
  421. DA9052_LDO(8, 50, 1200, 3600, 6, 6, 0),
  422. DA9052_LDO(9, 50, 1200, 3600, 6, 6, 0),
  423. DA9052_LDO(10, 50, 1200, 3600, 6, 6, 0),
  424. DA9052_LDO(11, 50, 1200, 3600, 6, 6, 0),
  425. DA9052_LDO(12, 50, 1250, 3650, 6, 6, 0),
  426. DA9052_LDO(13, 50, 1200, 3600, 6, 6, 0),
  427. };
  428. static inline struct da9052_regulator_info *find_regulator_info(u8 chip_id,
  429. int id)
  430. {
  431. struct da9052_regulator_info *info;
  432. int i;
  433. switch (chip_id) {
  434. case DA9052:
  435. for (i = 0; i < ARRAY_SIZE(da9052_regulator_info); i++) {
  436. info = &da9052_regulator_info[i];
  437. if (info->reg_desc.id == id)
  438. return info;
  439. }
  440. break;
  441. case DA9053_AA:
  442. case DA9053_BA:
  443. case DA9053_BB:
  444. for (i = 0; i < ARRAY_SIZE(da9053_regulator_info); i++) {
  445. info = &da9053_regulator_info[i];
  446. if (info->reg_desc.id == id)
  447. return info;
  448. }
  449. break;
  450. }
  451. return NULL;
  452. }
  453. static int __devinit da9052_regulator_probe(struct platform_device *pdev)
  454. {
  455. struct da9052_regulator *regulator;
  456. struct da9052 *da9052;
  457. struct da9052_pdata *pdata;
  458. int ret;
  459. regulator = devm_kzalloc(&pdev->dev, sizeof(struct da9052_regulator),
  460. GFP_KERNEL);
  461. if (!regulator)
  462. return -ENOMEM;
  463. da9052 = dev_get_drvdata(pdev->dev.parent);
  464. pdata = da9052->dev->platform_data;
  465. regulator->da9052 = da9052;
  466. regulator->info = find_regulator_info(regulator->da9052->chip_id,
  467. pdev->id);
  468. if (regulator->info == NULL) {
  469. dev_err(&pdev->dev, "invalid regulator ID specified\n");
  470. ret = -EINVAL;
  471. goto err;
  472. }
  473. regulator->rdev = regulator_register(&regulator->info->reg_desc,
  474. &pdev->dev,
  475. pdata->regulators[pdev->id],
  476. regulator, NULL);
  477. if (IS_ERR(regulator->rdev)) {
  478. dev_err(&pdev->dev, "failed to register regulator %s\n",
  479. regulator->info->reg_desc.name);
  480. ret = PTR_ERR(regulator->rdev);
  481. goto err;
  482. }
  483. platform_set_drvdata(pdev, regulator);
  484. return 0;
  485. err:
  486. devm_kfree(&pdev->dev, regulator);
  487. return ret;
  488. }
  489. static int __devexit da9052_regulator_remove(struct platform_device *pdev)
  490. {
  491. struct da9052_regulator *regulator = platform_get_drvdata(pdev);
  492. regulator_unregister(regulator->rdev);
  493. devm_kfree(&pdev->dev, regulator);
  494. return 0;
  495. }
  496. static struct platform_driver da9052_regulator_driver = {
  497. .probe = da9052_regulator_probe,
  498. .remove = __devexit_p(da9052_regulator_remove),
  499. .driver = {
  500. .name = "da9052-regulator",
  501. .owner = THIS_MODULE,
  502. },
  503. };
  504. static int __init da9052_regulator_init(void)
  505. {
  506. return platform_driver_register(&da9052_regulator_driver);
  507. }
  508. subsys_initcall(da9052_regulator_init);
  509. static void __exit da9052_regulator_exit(void)
  510. {
  511. platform_driver_unregister(&da9052_regulator_driver);
  512. }
  513. module_exit(da9052_regulator_exit);
  514. MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>");
  515. MODULE_DESCRIPTION("Power Regulator driver for Dialog DA9052 PMIC");
  516. MODULE_LICENSE("GPL");
  517. MODULE_ALIAS("platform:da9052-regulator");