max8997.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217
  1. /*
  2. * max8997.c - Regulator driver for the Maxim 8997/8966
  3. *
  4. * Copyright (C) 2011 Samsung Electronics
  5. * MyungJoo Ham <myungjoo.ham@smasung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. * This driver is based on max8998.c
  22. */
  23. #include <linux/bug.h>
  24. #include <linux/delay.h>
  25. #include <linux/err.h>
  26. #include <linux/gpio.h>
  27. #include <linux/slab.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/regulator/driver.h>
  30. #include <linux/regulator/machine.h>
  31. #include <linux/mfd/max8997.h>
  32. #include <linux/mfd/max8997-private.h>
  33. struct max8997_data {
  34. struct device *dev;
  35. struct max8997_dev *iodev;
  36. int num_regulators;
  37. struct regulator_dev **rdev;
  38. int ramp_delay; /* in mV/us */
  39. bool buck1_gpiodvs;
  40. bool buck2_gpiodvs;
  41. bool buck5_gpiodvs;
  42. u8 buck1_vol[8];
  43. u8 buck2_vol[8];
  44. u8 buck5_vol[8];
  45. int buck125_gpios[3];
  46. int buck125_gpioindex;
  47. bool ignore_gpiodvs_side_effect;
  48. u8 saved_states[MAX8997_REG_MAX];
  49. };
  50. static inline void max8997_set_gpio(struct max8997_data *max8997)
  51. {
  52. int set3 = (max8997->buck125_gpioindex) & 0x1;
  53. int set2 = ((max8997->buck125_gpioindex) >> 1) & 0x1;
  54. int set1 = ((max8997->buck125_gpioindex) >> 2) & 0x1;
  55. gpio_set_value(max8997->buck125_gpios[0], set1);
  56. gpio_set_value(max8997->buck125_gpios[1], set2);
  57. gpio_set_value(max8997->buck125_gpios[2], set3);
  58. }
  59. struct voltage_map_desc {
  60. int min;
  61. int max;
  62. int step;
  63. unsigned int n_bits;
  64. };
  65. /* Voltage maps in mV */
  66. static const struct voltage_map_desc ldo_voltage_map_desc = {
  67. .min = 800, .max = 3950, .step = 50, .n_bits = 6,
  68. }; /* LDO1 ~ 18, 21 all */
  69. static const struct voltage_map_desc buck1245_voltage_map_desc = {
  70. .min = 650, .max = 2225, .step = 25, .n_bits = 6,
  71. }; /* Buck1, 2, 4, 5 */
  72. static const struct voltage_map_desc buck37_voltage_map_desc = {
  73. .min = 750, .max = 3900, .step = 50, .n_bits = 6,
  74. }; /* Buck3, 7 */
  75. /* current map in mA */
  76. static const struct voltage_map_desc charger_current_map_desc = {
  77. .min = 200, .max = 950, .step = 50, .n_bits = 4,
  78. };
  79. static const struct voltage_map_desc topoff_current_map_desc = {
  80. .min = 50, .max = 200, .step = 10, .n_bits = 4,
  81. };
  82. static const struct voltage_map_desc *reg_voltage_map[] = {
  83. [MAX8997_LDO1] = &ldo_voltage_map_desc,
  84. [MAX8997_LDO2] = &ldo_voltage_map_desc,
  85. [MAX8997_LDO3] = &ldo_voltage_map_desc,
  86. [MAX8997_LDO4] = &ldo_voltage_map_desc,
  87. [MAX8997_LDO5] = &ldo_voltage_map_desc,
  88. [MAX8997_LDO6] = &ldo_voltage_map_desc,
  89. [MAX8997_LDO7] = &ldo_voltage_map_desc,
  90. [MAX8997_LDO8] = &ldo_voltage_map_desc,
  91. [MAX8997_LDO9] = &ldo_voltage_map_desc,
  92. [MAX8997_LDO10] = &ldo_voltage_map_desc,
  93. [MAX8997_LDO11] = &ldo_voltage_map_desc,
  94. [MAX8997_LDO12] = &ldo_voltage_map_desc,
  95. [MAX8997_LDO13] = &ldo_voltage_map_desc,
  96. [MAX8997_LDO14] = &ldo_voltage_map_desc,
  97. [MAX8997_LDO15] = &ldo_voltage_map_desc,
  98. [MAX8997_LDO16] = &ldo_voltage_map_desc,
  99. [MAX8997_LDO17] = &ldo_voltage_map_desc,
  100. [MAX8997_LDO18] = &ldo_voltage_map_desc,
  101. [MAX8997_LDO21] = &ldo_voltage_map_desc,
  102. [MAX8997_BUCK1] = &buck1245_voltage_map_desc,
  103. [MAX8997_BUCK2] = &buck1245_voltage_map_desc,
  104. [MAX8997_BUCK3] = &buck37_voltage_map_desc,
  105. [MAX8997_BUCK4] = &buck1245_voltage_map_desc,
  106. [MAX8997_BUCK5] = &buck1245_voltage_map_desc,
  107. [MAX8997_BUCK6] = NULL,
  108. [MAX8997_BUCK7] = &buck37_voltage_map_desc,
  109. [MAX8997_EN32KHZ_AP] = NULL,
  110. [MAX8997_EN32KHZ_CP] = NULL,
  111. [MAX8997_ENVICHG] = NULL,
  112. [MAX8997_ESAFEOUT1] = NULL,
  113. [MAX8997_ESAFEOUT2] = NULL,
  114. [MAX8997_CHARGER_CV] = NULL,
  115. [MAX8997_CHARGER] = &charger_current_map_desc,
  116. [MAX8997_CHARGER_TOPOFF] = &topoff_current_map_desc,
  117. };
  118. static inline int max8997_get_rid(struct regulator_dev *rdev)
  119. {
  120. return rdev_get_id(rdev);
  121. }
  122. static int max8997_list_voltage_safeout(struct regulator_dev *rdev,
  123. unsigned int selector)
  124. {
  125. int rid = max8997_get_rid(rdev);
  126. if (rid == MAX8997_ESAFEOUT1 || rid == MAX8997_ESAFEOUT2) {
  127. switch (selector) {
  128. case 0:
  129. return 4850000;
  130. case 1:
  131. return 4900000;
  132. case 2:
  133. return 4950000;
  134. case 3:
  135. return 3300000;
  136. default:
  137. return -EINVAL;
  138. }
  139. }
  140. return -EINVAL;
  141. }
  142. static int max8997_list_voltage_charger_cv(struct regulator_dev *rdev,
  143. unsigned int selector)
  144. {
  145. int rid = max8997_get_rid(rdev);
  146. if (rid != MAX8997_CHARGER_CV)
  147. goto err;
  148. switch (selector) {
  149. case 0x00:
  150. return 4200000;
  151. case 0x01 ... 0x0E:
  152. return 4000000 + 20000 * (selector - 0x01);
  153. case 0x0F:
  154. return 4350000;
  155. default:
  156. return -EINVAL;
  157. }
  158. err:
  159. return -EINVAL;
  160. }
  161. static int max8997_list_voltage(struct regulator_dev *rdev,
  162. unsigned int selector)
  163. {
  164. const struct voltage_map_desc *desc;
  165. int rid = max8997_get_rid(rdev);
  166. int val;
  167. if (rid >= ARRAY_SIZE(reg_voltage_map) ||
  168. rid < 0)
  169. return -EINVAL;
  170. desc = reg_voltage_map[rid];
  171. if (desc == NULL)
  172. return -EINVAL;
  173. val = desc->min + desc->step * selector;
  174. if (val > desc->max)
  175. return -EINVAL;
  176. return val * 1000;
  177. }
  178. static int max8997_get_enable_register(struct regulator_dev *rdev,
  179. int *reg, int *mask, int *pattern)
  180. {
  181. int rid = max8997_get_rid(rdev);
  182. switch (rid) {
  183. case MAX8997_LDO1 ... MAX8997_LDO21:
  184. *reg = MAX8997_REG_LDO1CTRL + (rid - MAX8997_LDO1);
  185. *mask = 0xC0;
  186. *pattern = 0xC0;
  187. break;
  188. case MAX8997_BUCK1:
  189. *reg = MAX8997_REG_BUCK1CTRL;
  190. *mask = 0x01;
  191. *pattern = 0x01;
  192. break;
  193. case MAX8997_BUCK2:
  194. *reg = MAX8997_REG_BUCK2CTRL;
  195. *mask = 0x01;
  196. *pattern = 0x01;
  197. break;
  198. case MAX8997_BUCK3:
  199. *reg = MAX8997_REG_BUCK3CTRL;
  200. *mask = 0x01;
  201. *pattern = 0x01;
  202. break;
  203. case MAX8997_BUCK4:
  204. *reg = MAX8997_REG_BUCK4CTRL;
  205. *mask = 0x01;
  206. *pattern = 0x01;
  207. break;
  208. case MAX8997_BUCK5:
  209. *reg = MAX8997_REG_BUCK5CTRL;
  210. *mask = 0x01;
  211. *pattern = 0x01;
  212. break;
  213. case MAX8997_BUCK6:
  214. *reg = MAX8997_REG_BUCK6CTRL;
  215. *mask = 0x01;
  216. *pattern = 0x01;
  217. break;
  218. case MAX8997_BUCK7:
  219. *reg = MAX8997_REG_BUCK7CTRL;
  220. *mask = 0x01;
  221. *pattern = 0x01;
  222. break;
  223. case MAX8997_EN32KHZ_AP ... MAX8997_EN32KHZ_CP:
  224. *reg = MAX8997_REG_MAINCON1;
  225. *mask = 0x01 << (rid - MAX8997_EN32KHZ_AP);
  226. *pattern = 0x01 << (rid - MAX8997_EN32KHZ_AP);
  227. break;
  228. case MAX8997_ENVICHG:
  229. *reg = MAX8997_REG_MBCCTRL1;
  230. *mask = 0x80;
  231. *pattern = 0x80;
  232. break;
  233. case MAX8997_ESAFEOUT1 ... MAX8997_ESAFEOUT2:
  234. *reg = MAX8997_REG_SAFEOUTCTRL;
  235. *mask = 0x40 << (rid - MAX8997_ESAFEOUT1);
  236. *pattern = 0x40 << (rid - MAX8997_ESAFEOUT1);
  237. break;
  238. case MAX8997_CHARGER:
  239. *reg = MAX8997_REG_MBCCTRL2;
  240. *mask = 0x40;
  241. *pattern = 0x40;
  242. break;
  243. default:
  244. /* Not controllable or not exists */
  245. return -EINVAL;
  246. }
  247. return 0;
  248. }
  249. static int max8997_reg_is_enabled(struct regulator_dev *rdev)
  250. {
  251. struct max8997_data *max8997 = rdev_get_drvdata(rdev);
  252. struct i2c_client *i2c = max8997->iodev->i2c;
  253. int ret, reg, mask, pattern;
  254. u8 val;
  255. ret = max8997_get_enable_register(rdev, &reg, &mask, &pattern);
  256. if (ret == -EINVAL)
  257. return 1; /* "not controllable" */
  258. else if (ret)
  259. return ret;
  260. ret = max8997_read_reg(i2c, reg, &val);
  261. if (ret)
  262. return ret;
  263. return (val & mask) == pattern;
  264. }
  265. static int max8997_reg_enable(struct regulator_dev *rdev)
  266. {
  267. struct max8997_data *max8997 = rdev_get_drvdata(rdev);
  268. struct i2c_client *i2c = max8997->iodev->i2c;
  269. int ret, reg, mask, pattern;
  270. ret = max8997_get_enable_register(rdev, &reg, &mask, &pattern);
  271. if (ret)
  272. return ret;
  273. return max8997_update_reg(i2c, reg, pattern, mask);
  274. }
  275. static int max8997_reg_disable(struct regulator_dev *rdev)
  276. {
  277. struct max8997_data *max8997 = rdev_get_drvdata(rdev);
  278. struct i2c_client *i2c = max8997->iodev->i2c;
  279. int ret, reg, mask, pattern;
  280. ret = max8997_get_enable_register(rdev, &reg, &mask, &pattern);
  281. if (ret)
  282. return ret;
  283. return max8997_update_reg(i2c, reg, ~pattern, mask);
  284. }
  285. static int max8997_get_voltage_register(struct regulator_dev *rdev,
  286. int *_reg, int *_shift, int *_mask)
  287. {
  288. int rid = max8997_get_rid(rdev);
  289. int reg, shift = 0, mask = 0x3f;
  290. switch (rid) {
  291. case MAX8997_LDO1 ... MAX8997_LDO21:
  292. reg = MAX8997_REG_LDO1CTRL + (rid - MAX8997_LDO1);
  293. break;
  294. case MAX8997_BUCK1:
  295. reg = MAX8997_REG_BUCK1DVS1;
  296. break;
  297. case MAX8997_BUCK2:
  298. reg = MAX8997_REG_BUCK2DVS1;
  299. break;
  300. case MAX8997_BUCK3:
  301. reg = MAX8997_REG_BUCK3DVS;
  302. break;
  303. case MAX8997_BUCK4:
  304. reg = MAX8997_REG_BUCK4DVS;
  305. break;
  306. case MAX8997_BUCK5:
  307. reg = MAX8997_REG_BUCK5DVS1;
  308. break;
  309. case MAX8997_BUCK7:
  310. reg = MAX8997_REG_BUCK7DVS;
  311. break;
  312. case MAX8997_ESAFEOUT1 ... MAX8997_ESAFEOUT2:
  313. reg = MAX8997_REG_SAFEOUTCTRL;
  314. shift = (rid == MAX8997_ESAFEOUT2) ? 2 : 0;
  315. mask = 0x3;
  316. break;
  317. case MAX8997_CHARGER_CV:
  318. reg = MAX8997_REG_MBCCTRL3;
  319. shift = 0;
  320. mask = 0xf;
  321. break;
  322. case MAX8997_CHARGER:
  323. reg = MAX8997_REG_MBCCTRL4;
  324. shift = 0;
  325. mask = 0xf;
  326. break;
  327. case MAX8997_CHARGER_TOPOFF:
  328. reg = MAX8997_REG_MBCCTRL5;
  329. shift = 0;
  330. mask = 0xf;
  331. break;
  332. default:
  333. return -EINVAL;
  334. }
  335. *_reg = reg;
  336. *_shift = shift;
  337. *_mask = mask;
  338. return 0;
  339. }
  340. static int max8997_get_voltage(struct regulator_dev *rdev)
  341. {
  342. struct max8997_data *max8997 = rdev_get_drvdata(rdev);
  343. struct i2c_client *i2c = max8997->iodev->i2c;
  344. int reg, shift, mask, ret;
  345. int rid = max8997_get_rid(rdev);
  346. u8 val;
  347. ret = max8997_get_voltage_register(rdev, &reg, &shift, &mask);
  348. if (ret)
  349. return ret;
  350. if ((rid == MAX8997_BUCK1 && max8997->buck1_gpiodvs) ||
  351. (rid == MAX8997_BUCK2 && max8997->buck2_gpiodvs) ||
  352. (rid == MAX8997_BUCK5 && max8997->buck5_gpiodvs))
  353. reg += max8997->buck125_gpioindex;
  354. ret = max8997_read_reg(i2c, reg, &val);
  355. if (ret)
  356. return ret;
  357. val >>= shift;
  358. val &= mask;
  359. if (rdev->desc && rdev->desc->ops && rdev->desc->ops->list_voltage)
  360. return rdev->desc->ops->list_voltage(rdev, val);
  361. /*
  362. * max8997_list_voltage returns value for any rdev with voltage_map,
  363. * which works for "CHARGER" and "CHARGER TOPOFF" that do not have
  364. * list_voltage ops (they are current regulators).
  365. */
  366. return max8997_list_voltage(rdev, val);
  367. }
  368. static inline int max8997_get_voltage_proper_val(
  369. const struct voltage_map_desc *desc,
  370. int min_vol, int max_vol)
  371. {
  372. int i = 0;
  373. if (desc == NULL)
  374. return -EINVAL;
  375. if (max_vol < desc->min || min_vol > desc->max)
  376. return -EINVAL;
  377. while (desc->min + desc->step * i < min_vol &&
  378. desc->min + desc->step * i < desc->max)
  379. i++;
  380. if (desc->min + desc->step * i > max_vol)
  381. return -EINVAL;
  382. if (i >= (1 << desc->n_bits))
  383. return -EINVAL;
  384. return i;
  385. }
  386. static int max8997_set_voltage_charger_cv(struct regulator_dev *rdev,
  387. int min_uV, int max_uV, unsigned *selector)
  388. {
  389. struct max8997_data *max8997 = rdev_get_drvdata(rdev);
  390. struct i2c_client *i2c = max8997->iodev->i2c;
  391. int rid = max8997_get_rid(rdev);
  392. int lb, ub;
  393. int reg, shift = 0, mask, ret = 0;
  394. u8 val = 0x0;
  395. if (rid != MAX8997_CHARGER_CV)
  396. return -EINVAL;
  397. ret = max8997_get_voltage_register(rdev, &reg, &shift, &mask);
  398. if (ret)
  399. return ret;
  400. if (max_uV < 4000000 || min_uV > 4350000)
  401. return -EINVAL;
  402. if (min_uV <= 4000000) {
  403. if (max_uV >= 4000000)
  404. return -EINVAL;
  405. else
  406. val = 0x1;
  407. } else if (min_uV <= 4200000 && max_uV >= 4200000)
  408. val = 0x0;
  409. else {
  410. lb = (min_uV - 4000001) / 20000 + 2;
  411. ub = (max_uV - 4000000) / 20000 + 1;
  412. if (lb > ub)
  413. return -EINVAL;
  414. if (lb < 0xf)
  415. val = lb;
  416. else {
  417. if (ub >= 0xf)
  418. val = 0xf;
  419. else
  420. return -EINVAL;
  421. }
  422. }
  423. *selector = val;
  424. ret = max8997_update_reg(i2c, reg, val << shift, mask);
  425. return ret;
  426. }
  427. /*
  428. * For LDO1 ~ LDO21, BUCK1~5, BUCK7, CHARGER, CHARGER_TOPOFF
  429. * BUCK1, 2, and 5 are available if they are not controlled by gpio
  430. */
  431. static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev,
  432. int min_uV, int max_uV, unsigned *selector)
  433. {
  434. struct max8997_data *max8997 = rdev_get_drvdata(rdev);
  435. struct i2c_client *i2c = max8997->iodev->i2c;
  436. int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
  437. const struct voltage_map_desc *desc;
  438. int rid = max8997_get_rid(rdev);
  439. int reg, shift = 0, mask, ret;
  440. int i;
  441. u8 org;
  442. switch (rid) {
  443. case MAX8997_LDO1 ... MAX8997_LDO21:
  444. break;
  445. case MAX8997_BUCK1 ... MAX8997_BUCK5:
  446. break;
  447. case MAX8997_BUCK6:
  448. return -EINVAL;
  449. case MAX8997_BUCK7:
  450. break;
  451. case MAX8997_CHARGER:
  452. break;
  453. case MAX8997_CHARGER_TOPOFF:
  454. break;
  455. default:
  456. return -EINVAL;
  457. }
  458. desc = reg_voltage_map[rid];
  459. i = max8997_get_voltage_proper_val(desc, min_vol, max_vol);
  460. if (i < 0)
  461. return i;
  462. ret = max8997_get_voltage_register(rdev, &reg, &shift, &mask);
  463. if (ret)
  464. return ret;
  465. max8997_read_reg(i2c, reg, &org);
  466. org = (org & mask) >> shift;
  467. ret = max8997_update_reg(i2c, reg, i << shift, mask << shift);
  468. *selector = i;
  469. if (rid == MAX8997_BUCK1 || rid == MAX8997_BUCK2 ||
  470. rid == MAX8997_BUCK4 || rid == MAX8997_BUCK5) {
  471. /* If the voltage is increasing */
  472. if (org < i)
  473. udelay(DIV_ROUND_UP(desc->step * (i - org),
  474. max8997->ramp_delay));
  475. }
  476. return ret;
  477. }
  478. /*
  479. * Assess the damage on the voltage setting of BUCK1,2,5 by the change.
  480. *
  481. * When GPIO-DVS mode is used for multiple bucks, changing the voltage value
  482. * of one of the bucks may affect that of another buck, which is the side
  483. * effect of the change (set_voltage). This function examines the GPIO-DVS
  484. * configurations and checks whether such side-effect exists.
  485. */
  486. static int max8997_assess_side_effect(struct regulator_dev *rdev,
  487. u8 new_val, int *best)
  488. {
  489. struct max8997_data *max8997 = rdev_get_drvdata(rdev);
  490. int rid = max8997_get_rid(rdev);
  491. u8 *buckx_val[3];
  492. bool buckx_gpiodvs[3];
  493. int side_effect[8];
  494. int min_side_effect = INT_MAX;
  495. int i;
  496. *best = -1;
  497. switch (rid) {
  498. case MAX8997_BUCK1:
  499. rid = 0;
  500. break;
  501. case MAX8997_BUCK2:
  502. rid = 1;
  503. break;
  504. case MAX8997_BUCK5:
  505. rid = 2;
  506. break;
  507. default:
  508. return -EINVAL;
  509. }
  510. buckx_val[0] = max8997->buck1_vol;
  511. buckx_val[1] = max8997->buck2_vol;
  512. buckx_val[2] = max8997->buck5_vol;
  513. buckx_gpiodvs[0] = max8997->buck1_gpiodvs;
  514. buckx_gpiodvs[1] = max8997->buck2_gpiodvs;
  515. buckx_gpiodvs[2] = max8997->buck5_gpiodvs;
  516. for (i = 0; i < 8; i++) {
  517. int others;
  518. if (new_val != (buckx_val[rid])[i]) {
  519. side_effect[i] = -1;
  520. continue;
  521. }
  522. side_effect[i] = 0;
  523. for (others = 0; others < 3; others++) {
  524. int diff;
  525. if (others == rid)
  526. continue;
  527. if (buckx_gpiodvs[others] == false)
  528. continue; /* Not affected */
  529. diff = (buckx_val[others])[i] -
  530. (buckx_val[others])[max8997->buck125_gpioindex];
  531. if (diff > 0)
  532. side_effect[i] += diff;
  533. else if (diff < 0)
  534. side_effect[i] -= diff;
  535. }
  536. if (side_effect[i] == 0) {
  537. *best = i;
  538. return 0; /* NO SIDE EFFECT! Use This! */
  539. }
  540. if (side_effect[i] < min_side_effect) {
  541. min_side_effect = side_effect[i];
  542. *best = i;
  543. }
  544. }
  545. if (*best == -1)
  546. return -EINVAL;
  547. return side_effect[*best];
  548. }
  549. /*
  550. * For Buck 1 ~ 5 and 7. If it is not controlled by GPIO, this calls
  551. * max8997_set_voltage_ldobuck to do the job.
  552. */
  553. static int max8997_set_voltage_buck(struct regulator_dev *rdev,
  554. int min_uV, int max_uV, unsigned *selector)
  555. {
  556. struct max8997_data *max8997 = rdev_get_drvdata(rdev);
  557. int rid = max8997_get_rid(rdev);
  558. const struct voltage_map_desc *desc;
  559. int new_val, new_idx, damage, tmp_val, tmp_idx, tmp_dmg;
  560. bool gpio_dvs_mode = false;
  561. int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
  562. if (rid < MAX8997_BUCK1 || rid > MAX8997_BUCK7)
  563. return -EINVAL;
  564. switch (rid) {
  565. case MAX8997_BUCK1:
  566. if (max8997->buck1_gpiodvs)
  567. gpio_dvs_mode = true;
  568. break;
  569. case MAX8997_BUCK2:
  570. if (max8997->buck2_gpiodvs)
  571. gpio_dvs_mode = true;
  572. break;
  573. case MAX8997_BUCK5:
  574. if (max8997->buck5_gpiodvs)
  575. gpio_dvs_mode = true;
  576. break;
  577. }
  578. if (!gpio_dvs_mode)
  579. return max8997_set_voltage_ldobuck(rdev, min_uV, max_uV,
  580. selector);
  581. desc = reg_voltage_map[rid];
  582. new_val = max8997_get_voltage_proper_val(desc, min_vol, max_vol);
  583. if (new_val < 0)
  584. return new_val;
  585. tmp_dmg = INT_MAX;
  586. tmp_idx = -1;
  587. tmp_val = -1;
  588. do {
  589. damage = max8997_assess_side_effect(rdev, new_val, &new_idx);
  590. if (damage == 0)
  591. goto out;
  592. if (tmp_dmg > damage) {
  593. tmp_idx = new_idx;
  594. tmp_val = new_val;
  595. tmp_dmg = damage;
  596. }
  597. new_val++;
  598. } while (desc->min + desc->step + new_val <= desc->max);
  599. new_idx = tmp_idx;
  600. new_val = tmp_val;
  601. if (max8997->ignore_gpiodvs_side_effect == false)
  602. return -EINVAL;
  603. dev_warn(&rdev->dev, "MAX8997 GPIO-DVS Side Effect Warning: GPIO SET:"
  604. " %d -> %d\n", max8997->buck125_gpioindex, tmp_idx);
  605. out:
  606. if (new_idx < 0 || new_val < 0)
  607. return -EINVAL;
  608. max8997->buck125_gpioindex = new_idx;
  609. max8997_set_gpio(max8997);
  610. *selector = new_val;
  611. return 0;
  612. }
  613. static const int safeoutvolt[] = {
  614. 3300000,
  615. 4850000,
  616. 4900000,
  617. 4950000,
  618. };
  619. /* For SAFEOUT1 and SAFEOUT2 */
  620. static int max8997_set_voltage_safeout(struct regulator_dev *rdev,
  621. int min_uV, int max_uV, unsigned *selector)
  622. {
  623. struct max8997_data *max8997 = rdev_get_drvdata(rdev);
  624. struct i2c_client *i2c = max8997->iodev->i2c;
  625. int rid = max8997_get_rid(rdev);
  626. int reg, shift = 0, mask, ret;
  627. int i = 0;
  628. u8 val;
  629. if (rid != MAX8997_ESAFEOUT1 && rid != MAX8997_ESAFEOUT2)
  630. return -EINVAL;
  631. for (i = 0; i < ARRAY_SIZE(safeoutvolt); i++) {
  632. if (min_uV <= safeoutvolt[i] &&
  633. max_uV >= safeoutvolt[i])
  634. break;
  635. }
  636. if (i >= ARRAY_SIZE(safeoutvolt))
  637. return -EINVAL;
  638. if (i == 0)
  639. val = 0x3;
  640. else
  641. val = i - 1;
  642. ret = max8997_get_voltage_register(rdev, &reg, &shift, &mask);
  643. if (ret)
  644. return ret;
  645. ret = max8997_update_reg(i2c, reg, val << shift, mask << shift);
  646. *selector = val;
  647. return ret;
  648. }
  649. static int max8997_reg_enable_suspend(struct regulator_dev *rdev)
  650. {
  651. return 0;
  652. }
  653. static int max8997_reg_disable_suspend(struct regulator_dev *rdev)
  654. {
  655. struct max8997_data *max8997 = rdev_get_drvdata(rdev);
  656. struct i2c_client *i2c = max8997->iodev->i2c;
  657. int ret, reg, mask, pattern;
  658. int rid = max8997_get_rid(rdev);
  659. ret = max8997_get_enable_register(rdev, &reg, &mask, &pattern);
  660. if (ret)
  661. return ret;
  662. max8997_read_reg(i2c, reg, &max8997->saved_states[rid]);
  663. if (rid == MAX8997_LDO1 ||
  664. rid == MAX8997_LDO10 ||
  665. rid == MAX8997_LDO21) {
  666. dev_dbg(&rdev->dev, "Conditional Power-Off for %s\n",
  667. rdev->desc->name);
  668. return max8997_update_reg(i2c, reg, 0x40, mask);
  669. }
  670. dev_dbg(&rdev->dev, "Full Power-Off for %s (%xh -> %xh)\n",
  671. rdev->desc->name, max8997->saved_states[rid] & mask,
  672. (~pattern) & mask);
  673. return max8997_update_reg(i2c, reg, ~pattern, mask);
  674. }
  675. static struct regulator_ops max8997_ldo_ops = {
  676. .list_voltage = max8997_list_voltage,
  677. .is_enabled = max8997_reg_is_enabled,
  678. .enable = max8997_reg_enable,
  679. .disable = max8997_reg_disable,
  680. .get_voltage = max8997_get_voltage,
  681. .set_voltage = max8997_set_voltage_ldobuck,
  682. .set_suspend_enable = max8997_reg_enable_suspend,
  683. .set_suspend_disable = max8997_reg_disable_suspend,
  684. };
  685. static struct regulator_ops max8997_buck_ops = {
  686. .list_voltage = max8997_list_voltage,
  687. .is_enabled = max8997_reg_is_enabled,
  688. .enable = max8997_reg_enable,
  689. .disable = max8997_reg_disable,
  690. .get_voltage = max8997_get_voltage,
  691. .set_voltage = max8997_set_voltage_buck,
  692. .set_suspend_enable = max8997_reg_enable_suspend,
  693. .set_suspend_disable = max8997_reg_disable_suspend,
  694. };
  695. static struct regulator_ops max8997_fixedvolt_ops = {
  696. .list_voltage = max8997_list_voltage,
  697. .is_enabled = max8997_reg_is_enabled,
  698. .enable = max8997_reg_enable,
  699. .disable = max8997_reg_disable,
  700. .set_suspend_enable = max8997_reg_enable_suspend,
  701. .set_suspend_disable = max8997_reg_disable_suspend,
  702. };
  703. static struct regulator_ops max8997_safeout_ops = {
  704. .list_voltage = max8997_list_voltage_safeout,
  705. .is_enabled = max8997_reg_is_enabled,
  706. .enable = max8997_reg_enable,
  707. .disable = max8997_reg_disable,
  708. .get_voltage = max8997_get_voltage,
  709. .set_voltage = max8997_set_voltage_safeout,
  710. .set_suspend_enable = max8997_reg_enable_suspend,
  711. .set_suspend_disable = max8997_reg_disable_suspend,
  712. };
  713. static struct regulator_ops max8997_fixedstate_ops = {
  714. .list_voltage = max8997_list_voltage_charger_cv,
  715. .get_voltage = max8997_get_voltage,
  716. .set_voltage = max8997_set_voltage_charger_cv,
  717. };
  718. static int max8997_set_voltage_ldobuck_wrap(struct regulator_dev *rdev,
  719. int min_uV, int max_uV)
  720. {
  721. unsigned dummy;
  722. return max8997_set_voltage_ldobuck(rdev, min_uV, max_uV, &dummy);
  723. }
  724. static struct regulator_ops max8997_charger_ops = {
  725. .is_enabled = max8997_reg_is_enabled,
  726. .enable = max8997_reg_enable,
  727. .disable = max8997_reg_disable,
  728. .get_current_limit = max8997_get_voltage,
  729. .set_current_limit = max8997_set_voltage_ldobuck_wrap,
  730. };
  731. static struct regulator_ops max8997_charger_fixedstate_ops = {
  732. .is_enabled = max8997_reg_is_enabled,
  733. .get_current_limit = max8997_get_voltage,
  734. .set_current_limit = max8997_set_voltage_ldobuck_wrap,
  735. };
  736. #define regulator_desc_ldo(num) { \
  737. .name = "LDO"#num, \
  738. .id = MAX8997_LDO##num, \
  739. .ops = &max8997_ldo_ops, \
  740. .type = REGULATOR_VOLTAGE, \
  741. .owner = THIS_MODULE, \
  742. }
  743. #define regulator_desc_buck(num) { \
  744. .name = "BUCK"#num, \
  745. .id = MAX8997_BUCK##num, \
  746. .ops = &max8997_buck_ops, \
  747. .type = REGULATOR_VOLTAGE, \
  748. .owner = THIS_MODULE, \
  749. }
  750. static struct regulator_desc regulators[] = {
  751. regulator_desc_ldo(1),
  752. regulator_desc_ldo(2),
  753. regulator_desc_ldo(3),
  754. regulator_desc_ldo(4),
  755. regulator_desc_ldo(5),
  756. regulator_desc_ldo(6),
  757. regulator_desc_ldo(7),
  758. regulator_desc_ldo(8),
  759. regulator_desc_ldo(9),
  760. regulator_desc_ldo(10),
  761. regulator_desc_ldo(11),
  762. regulator_desc_ldo(12),
  763. regulator_desc_ldo(13),
  764. regulator_desc_ldo(14),
  765. regulator_desc_ldo(15),
  766. regulator_desc_ldo(16),
  767. regulator_desc_ldo(17),
  768. regulator_desc_ldo(18),
  769. regulator_desc_ldo(21),
  770. regulator_desc_buck(1),
  771. regulator_desc_buck(2),
  772. regulator_desc_buck(3),
  773. regulator_desc_buck(4),
  774. regulator_desc_buck(5),
  775. {
  776. .name = "BUCK6",
  777. .id = MAX8997_BUCK6,
  778. .ops = &max8997_fixedvolt_ops,
  779. .type = REGULATOR_VOLTAGE,
  780. .owner = THIS_MODULE,
  781. },
  782. regulator_desc_buck(7),
  783. {
  784. .name = "EN32KHz AP",
  785. .id = MAX8997_EN32KHZ_AP,
  786. .ops = &max8997_fixedvolt_ops,
  787. .type = REGULATOR_VOLTAGE,
  788. .owner = THIS_MODULE,
  789. }, {
  790. .name = "EN32KHz CP",
  791. .id = MAX8997_EN32KHZ_CP,
  792. .ops = &max8997_fixedvolt_ops,
  793. .type = REGULATOR_VOLTAGE,
  794. .owner = THIS_MODULE,
  795. }, {
  796. .name = "ENVICHG",
  797. .id = MAX8997_ENVICHG,
  798. .ops = &max8997_fixedvolt_ops,
  799. .type = REGULATOR_VOLTAGE,
  800. .owner = THIS_MODULE,
  801. }, {
  802. .name = "ESAFEOUT1",
  803. .id = MAX8997_ESAFEOUT1,
  804. .ops = &max8997_safeout_ops,
  805. .type = REGULATOR_VOLTAGE,
  806. .owner = THIS_MODULE,
  807. }, {
  808. .name = "ESAFEOUT2",
  809. .id = MAX8997_ESAFEOUT2,
  810. .ops = &max8997_safeout_ops,
  811. .type = REGULATOR_VOLTAGE,
  812. .owner = THIS_MODULE,
  813. }, {
  814. .name = "CHARGER CV",
  815. .id = MAX8997_CHARGER_CV,
  816. .ops = &max8997_fixedstate_ops,
  817. .type = REGULATOR_VOLTAGE,
  818. .owner = THIS_MODULE,
  819. }, {
  820. .name = "CHARGER",
  821. .id = MAX8997_CHARGER,
  822. .ops = &max8997_charger_ops,
  823. .type = REGULATOR_CURRENT,
  824. .owner = THIS_MODULE,
  825. }, {
  826. .name = "CHARGER TOPOFF",
  827. .id = MAX8997_CHARGER_TOPOFF,
  828. .ops = &max8997_charger_fixedstate_ops,
  829. .type = REGULATOR_CURRENT,
  830. .owner = THIS_MODULE,
  831. },
  832. };
  833. static __devinit int max8997_pmic_probe(struct platform_device *pdev)
  834. {
  835. struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
  836. struct max8997_platform_data *pdata = dev_get_platdata(iodev->dev);
  837. struct regulator_dev **rdev;
  838. struct max8997_data *max8997;
  839. struct i2c_client *i2c;
  840. int i, ret, size;
  841. u8 max_buck1 = 0, max_buck2 = 0, max_buck5 = 0;
  842. if (!pdata) {
  843. dev_err(pdev->dev.parent, "No platform init data supplied.\n");
  844. return -ENODEV;
  845. }
  846. max8997 = kzalloc(sizeof(struct max8997_data), GFP_KERNEL);
  847. if (!max8997)
  848. return -ENOMEM;
  849. size = sizeof(struct regulator_dev *) * pdata->num_regulators;
  850. max8997->rdev = kzalloc(size, GFP_KERNEL);
  851. if (!max8997->rdev) {
  852. kfree(max8997);
  853. return -ENOMEM;
  854. }
  855. rdev = max8997->rdev;
  856. max8997->dev = &pdev->dev;
  857. max8997->iodev = iodev;
  858. max8997->num_regulators = pdata->num_regulators;
  859. platform_set_drvdata(pdev, max8997);
  860. i2c = max8997->iodev->i2c;
  861. max8997->buck125_gpioindex = pdata->buck125_default_idx;
  862. max8997->buck1_gpiodvs = pdata->buck1_gpiodvs;
  863. max8997->buck2_gpiodvs = pdata->buck2_gpiodvs;
  864. max8997->buck5_gpiodvs = pdata->buck5_gpiodvs;
  865. memcpy(max8997->buck125_gpios, pdata->buck125_gpios, sizeof(int) * 3);
  866. max8997->ignore_gpiodvs_side_effect = pdata->ignore_gpiodvs_side_effect;
  867. for (i = 0; i < 8; i++) {
  868. max8997->buck1_vol[i] = ret =
  869. max8997_get_voltage_proper_val(
  870. &buck1245_voltage_map_desc,
  871. pdata->buck1_voltage[i] / 1000,
  872. pdata->buck1_voltage[i] / 1000 +
  873. buck1245_voltage_map_desc.step);
  874. if (ret < 0)
  875. goto err_alloc;
  876. max8997->buck2_vol[i] = ret =
  877. max8997_get_voltage_proper_val(
  878. &buck1245_voltage_map_desc,
  879. pdata->buck2_voltage[i] / 1000,
  880. pdata->buck2_voltage[i] / 1000 +
  881. buck1245_voltage_map_desc.step);
  882. if (ret < 0)
  883. goto err_alloc;
  884. max8997->buck5_vol[i] = ret =
  885. max8997_get_voltage_proper_val(
  886. &buck1245_voltage_map_desc,
  887. pdata->buck5_voltage[i] / 1000,
  888. pdata->buck5_voltage[i] / 1000 +
  889. buck1245_voltage_map_desc.step);
  890. if (ret < 0)
  891. goto err_alloc;
  892. if (max_buck1 < max8997->buck1_vol[i])
  893. max_buck1 = max8997->buck1_vol[i];
  894. if (max_buck2 < max8997->buck2_vol[i])
  895. max_buck2 = max8997->buck2_vol[i];
  896. if (max_buck5 < max8997->buck5_vol[i])
  897. max_buck5 = max8997->buck5_vol[i];
  898. }
  899. /* For the safety, set max voltage before setting up */
  900. for (i = 0; i < 8; i++) {
  901. max8997_update_reg(i2c, MAX8997_REG_BUCK1DVS1 + i,
  902. max_buck1, 0x3f);
  903. max8997_update_reg(i2c, MAX8997_REG_BUCK2DVS1 + i,
  904. max_buck2, 0x3f);
  905. max8997_update_reg(i2c, MAX8997_REG_BUCK5DVS1 + i,
  906. max_buck5, 0x3f);
  907. }
  908. /*
  909. * If buck 1, 2, and 5 do not care DVS GPIO settings, ignore them.
  910. * If at least one of them cares, set gpios.
  911. */
  912. if (pdata->buck1_gpiodvs || pdata->buck2_gpiodvs ||
  913. pdata->buck5_gpiodvs) {
  914. bool gpio1set = false, gpio2set = false;
  915. if (!gpio_is_valid(pdata->buck125_gpios[0]) ||
  916. !gpio_is_valid(pdata->buck125_gpios[1]) ||
  917. !gpio_is_valid(pdata->buck125_gpios[2])) {
  918. dev_err(&pdev->dev, "GPIO NOT VALID\n");
  919. ret = -EINVAL;
  920. goto err_alloc;
  921. }
  922. ret = gpio_request(pdata->buck125_gpios[0],
  923. "MAX8997 SET1");
  924. if (ret == -EBUSY)
  925. dev_warn(&pdev->dev, "Duplicated gpio request"
  926. " on SET1\n");
  927. else if (ret)
  928. goto err_alloc;
  929. else
  930. gpio1set = true;
  931. ret = gpio_request(pdata->buck125_gpios[1],
  932. "MAX8997 SET2");
  933. if (ret == -EBUSY)
  934. dev_warn(&pdev->dev, "Duplicated gpio request"
  935. " on SET2\n");
  936. else if (ret) {
  937. if (gpio1set)
  938. gpio_free(pdata->buck125_gpios[0]);
  939. goto err_alloc;
  940. } else
  941. gpio2set = true;
  942. ret = gpio_request(pdata->buck125_gpios[2],
  943. "MAX8997 SET3");
  944. if (ret == -EBUSY)
  945. dev_warn(&pdev->dev, "Duplicated gpio request"
  946. " on SET3\n");
  947. else if (ret) {
  948. if (gpio1set)
  949. gpio_free(pdata->buck125_gpios[0]);
  950. if (gpio2set)
  951. gpio_free(pdata->buck125_gpios[1]);
  952. goto err_alloc;
  953. }
  954. gpio_direction_output(pdata->buck125_gpios[0],
  955. (max8997->buck125_gpioindex >> 2)
  956. & 0x1); /* SET1 */
  957. gpio_direction_output(pdata->buck125_gpios[1],
  958. (max8997->buck125_gpioindex >> 1)
  959. & 0x1); /* SET2 */
  960. gpio_direction_output(pdata->buck125_gpios[2],
  961. (max8997->buck125_gpioindex >> 0)
  962. & 0x1); /* SET3 */
  963. ret = 0;
  964. }
  965. /* DVS-GPIO disabled */
  966. max8997_update_reg(i2c, MAX8997_REG_BUCK1CTRL, (pdata->buck1_gpiodvs) ?
  967. (1 << 1) : (0 << 1), 1 << 1);
  968. max8997_update_reg(i2c, MAX8997_REG_BUCK2CTRL, (pdata->buck2_gpiodvs) ?
  969. (1 << 1) : (0 << 1), 1 << 1);
  970. max8997_update_reg(i2c, MAX8997_REG_BUCK5CTRL, (pdata->buck5_gpiodvs) ?
  971. (1 << 1) : (0 << 1), 1 << 1);
  972. /* Initialize all the DVS related BUCK registers */
  973. for (i = 0; i < 8; i++) {
  974. max8997_update_reg(i2c, MAX8997_REG_BUCK1DVS1 + i,
  975. max8997->buck1_vol[i],
  976. 0x3f);
  977. max8997_update_reg(i2c, MAX8997_REG_BUCK2DVS1 + i,
  978. max8997->buck2_vol[i],
  979. 0x3f);
  980. max8997_update_reg(i2c, MAX8997_REG_BUCK5DVS1 + i,
  981. max8997->buck5_vol[i],
  982. 0x3f);
  983. }
  984. /* Misc Settings */
  985. max8997->ramp_delay = 10; /* set 10mV/us, which is the default */
  986. max8997_write_reg(i2c, MAX8997_REG_BUCKRAMP, (0xf << 4) | 0x9);
  987. for (i = 0; i < pdata->num_regulators; i++) {
  988. const struct voltage_map_desc *desc;
  989. int id = pdata->regulators[i].id;
  990. desc = reg_voltage_map[id];
  991. if (desc)
  992. regulators[id].n_voltages =
  993. (desc->max - desc->min) / desc->step + 1;
  994. else if (id == MAX8997_ESAFEOUT1 || id == MAX8997_ESAFEOUT2)
  995. regulators[id].n_voltages = 4;
  996. else if (id == MAX8997_CHARGER_CV)
  997. regulators[id].n_voltages = 16;
  998. rdev[i] = regulator_register(&regulators[id], max8997->dev,
  999. pdata->regulators[i].initdata, max8997);
  1000. if (IS_ERR(rdev[i])) {
  1001. ret = PTR_ERR(rdev[i]);
  1002. dev_err(max8997->dev, "regulator init failed for %d\n",
  1003. id);
  1004. rdev[i] = NULL;
  1005. goto err;
  1006. }
  1007. }
  1008. return 0;
  1009. err:
  1010. for (i = 0; i < max8997->num_regulators; i++)
  1011. if (rdev[i])
  1012. regulator_unregister(rdev[i]);
  1013. err_alloc:
  1014. kfree(max8997->rdev);
  1015. kfree(max8997);
  1016. return ret;
  1017. }
  1018. static int __devexit max8997_pmic_remove(struct platform_device *pdev)
  1019. {
  1020. struct max8997_data *max8997 = platform_get_drvdata(pdev);
  1021. struct regulator_dev **rdev = max8997->rdev;
  1022. int i;
  1023. for (i = 0; i < max8997->num_regulators; i++)
  1024. if (rdev[i])
  1025. regulator_unregister(rdev[i]);
  1026. kfree(max8997->rdev);
  1027. kfree(max8997);
  1028. return 0;
  1029. }
  1030. static const struct platform_device_id max8997_pmic_id[] = {
  1031. { "max8997-pmic", 0},
  1032. { },
  1033. };
  1034. MODULE_DEVICE_TABLE(platform, max8997_pmic_id);
  1035. static struct platform_driver max8997_pmic_driver = {
  1036. .driver = {
  1037. .name = "max8997-pmic",
  1038. .owner = THIS_MODULE,
  1039. },
  1040. .probe = max8997_pmic_probe,
  1041. .remove = __devexit_p(max8997_pmic_remove),
  1042. .id_table = max8997_pmic_id,
  1043. };
  1044. static int __init max8997_pmic_init(void)
  1045. {
  1046. return platform_driver_register(&max8997_pmic_driver);
  1047. }
  1048. subsys_initcall(max8997_pmic_init);
  1049. static void __exit max8997_pmic_cleanup(void)
  1050. {
  1051. platform_driver_unregister(&max8997_pmic_driver);
  1052. }
  1053. module_exit(max8997_pmic_cleanup);
  1054. MODULE_DESCRIPTION("MAXIM 8997/8966 Regulator Driver");
  1055. MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>");
  1056. MODULE_LICENSE("GPL");