max8997.c 30 KB

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