twl-regulator.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  1. /*
  2. * twl-regulator.c -- support regulators in twl4030/twl6030 family chips
  3. *
  4. * Copyright (C) 2008 David Brownell
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/init.h>
  13. #include <linux/err.h>
  14. #include <linux/delay.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/regulator/driver.h>
  17. #include <linux/regulator/machine.h>
  18. #include <linux/i2c/twl.h>
  19. /*
  20. * The TWL4030/TW5030/TPS659x0/TWL6030 family chips include power management, a
  21. * USB OTG transceiver, an RTC, ADC, PWM, and lots more. Some versions
  22. * include an audio codec, battery charger, and more voltage regulators.
  23. * These chips are often used in OMAP-based systems.
  24. *
  25. * This driver implements software-based resource control for various
  26. * voltage regulators. This is usually augmented with state machine
  27. * based control.
  28. */
  29. struct twlreg_info {
  30. /* start of regulator's PM_RECEIVER control register bank */
  31. u8 base;
  32. /* twl resource ID, for resource control state machine */
  33. u8 id;
  34. /* voltage in mV = table[VSEL]; table_len must be a power-of-two */
  35. u8 table_len;
  36. const u16 *table;
  37. /* regulator specific turn-on delay */
  38. u16 delay;
  39. /* State REMAP default configuration */
  40. u8 remap;
  41. /* chip constraints on regulator behavior */
  42. u16 min_mV;
  43. u16 max_mV;
  44. u8 flags;
  45. /* used by regulator core */
  46. struct regulator_desc desc;
  47. /* chip specific features */
  48. unsigned long features;
  49. /*
  50. * optional override functions for voltage set/get
  51. * these are currently only used for SMPS regulators
  52. */
  53. int (*get_voltage)(void *data);
  54. int (*set_voltage)(void *data, int target_uV);
  55. /* data passed from board for external get/set voltage */
  56. void *data;
  57. };
  58. /* LDO control registers ... offset is from the base of its register bank.
  59. * The first three registers of all power resource banks help hardware to
  60. * manage the various resource groups.
  61. */
  62. /* Common offset in TWL4030/6030 */
  63. #define VREG_GRP 0
  64. /* TWL4030 register offsets */
  65. #define VREG_TYPE 1
  66. #define VREG_REMAP 2
  67. #define VREG_DEDICATED 3 /* LDO control */
  68. #define VREG_VOLTAGE_SMPS_4030 9
  69. /* TWL6030 register offsets */
  70. #define VREG_TRANS 1
  71. #define VREG_STATE 2
  72. #define VREG_VOLTAGE 3
  73. #define VREG_VOLTAGE_SMPS 4
  74. /* TWL6030 Misc register offsets */
  75. #define VREG_BC_ALL 1
  76. #define VREG_BC_REF 2
  77. #define VREG_BC_PROC 3
  78. #define VREG_BC_CLK_RST 4
  79. /* TWL6030 LDO register values for CFG_STATE */
  80. #define TWL6030_CFG_STATE_OFF 0x00
  81. #define TWL6030_CFG_STATE_ON 0x01
  82. #define TWL6030_CFG_STATE_OFF2 0x02
  83. #define TWL6030_CFG_STATE_SLEEP 0x03
  84. #define TWL6030_CFG_STATE_GRP_SHIFT 5
  85. #define TWL6030_CFG_STATE_APP_SHIFT 2
  86. #define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT)
  87. #define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\
  88. TWL6030_CFG_STATE_APP_SHIFT)
  89. /* Flags for SMPS Voltage reading */
  90. #define SMPS_OFFSET_EN BIT(0)
  91. #define SMPS_EXTENDED_EN BIT(1)
  92. /* twl6025 SMPS EPROM values */
  93. #define TWL6030_SMPS_OFFSET 0xB0
  94. #define TWL6030_SMPS_MULT 0xB3
  95. #define SMPS_MULTOFFSET_SMPS4 BIT(0)
  96. #define SMPS_MULTOFFSET_VIO BIT(1)
  97. #define SMPS_MULTOFFSET_SMPS3 BIT(6)
  98. static inline int
  99. twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset)
  100. {
  101. u8 value;
  102. int status;
  103. status = twl_i2c_read_u8(slave_subgp,
  104. &value, info->base + offset);
  105. return (status < 0) ? status : value;
  106. }
  107. static inline int
  108. twlreg_write(struct twlreg_info *info, unsigned slave_subgp, unsigned offset,
  109. u8 value)
  110. {
  111. return twl_i2c_write_u8(slave_subgp,
  112. value, info->base + offset);
  113. }
  114. /*----------------------------------------------------------------------*/
  115. /* generic power resource operations, which work on all regulators */
  116. static int twlreg_grp(struct regulator_dev *rdev)
  117. {
  118. return twlreg_read(rdev_get_drvdata(rdev), TWL_MODULE_PM_RECEIVER,
  119. VREG_GRP);
  120. }
  121. /*
  122. * Enable/disable regulators by joining/leaving the P1 (processor) group.
  123. * We assume nobody else is updating the DEV_GRP registers.
  124. */
  125. /* definition for 4030 family */
  126. #define P3_GRP_4030 BIT(7) /* "peripherals" */
  127. #define P2_GRP_4030 BIT(6) /* secondary processor, modem, etc */
  128. #define P1_GRP_4030 BIT(5) /* CPU/Linux */
  129. /* definition for 6030 family */
  130. #define P3_GRP_6030 BIT(2) /* secondary processor, modem, etc */
  131. #define P2_GRP_6030 BIT(1) /* "peripherals" */
  132. #define P1_GRP_6030 BIT(0) /* CPU/Linux */
  133. static int twl4030reg_is_enabled(struct regulator_dev *rdev)
  134. {
  135. int state = twlreg_grp(rdev);
  136. if (state < 0)
  137. return state;
  138. return state & P1_GRP_4030;
  139. }
  140. static int twl6030reg_is_enabled(struct regulator_dev *rdev)
  141. {
  142. struct twlreg_info *info = rdev_get_drvdata(rdev);
  143. int grp = 0, val;
  144. if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
  145. grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
  146. if (grp < 0)
  147. return grp;
  148. if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
  149. grp &= P1_GRP_6030;
  150. else
  151. grp = 1;
  152. val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
  153. val = TWL6030_CFG_STATE_APP(val);
  154. return grp && (val == TWL6030_CFG_STATE_ON);
  155. }
  156. static int twl4030reg_enable(struct regulator_dev *rdev)
  157. {
  158. struct twlreg_info *info = rdev_get_drvdata(rdev);
  159. int grp;
  160. int ret;
  161. grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
  162. if (grp < 0)
  163. return grp;
  164. grp |= P1_GRP_4030;
  165. ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
  166. udelay(info->delay);
  167. return ret;
  168. }
  169. static int twl6030reg_enable(struct regulator_dev *rdev)
  170. {
  171. struct twlreg_info *info = rdev_get_drvdata(rdev);
  172. int grp = 0;
  173. int ret;
  174. if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
  175. grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
  176. if (grp < 0)
  177. return grp;
  178. ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE,
  179. grp << TWL6030_CFG_STATE_GRP_SHIFT |
  180. TWL6030_CFG_STATE_ON);
  181. udelay(info->delay);
  182. return ret;
  183. }
  184. static int twl4030reg_disable(struct regulator_dev *rdev)
  185. {
  186. struct twlreg_info *info = rdev_get_drvdata(rdev);
  187. int grp;
  188. int ret;
  189. grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
  190. if (grp < 0)
  191. return grp;
  192. grp &= ~(P1_GRP_4030 | P2_GRP_4030 | P3_GRP_4030);
  193. ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
  194. return ret;
  195. }
  196. static int twl6030reg_disable(struct regulator_dev *rdev)
  197. {
  198. struct twlreg_info *info = rdev_get_drvdata(rdev);
  199. int grp = 0;
  200. int ret;
  201. if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
  202. grp = P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030;
  203. /* For 6030, set the off state for all grps enabled */
  204. ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE,
  205. (grp) << TWL6030_CFG_STATE_GRP_SHIFT |
  206. TWL6030_CFG_STATE_OFF);
  207. return ret;
  208. }
  209. static int twl4030reg_get_status(struct regulator_dev *rdev)
  210. {
  211. int state = twlreg_grp(rdev);
  212. if (state < 0)
  213. return state;
  214. state &= 0x0f;
  215. /* assume state != WARM_RESET; we'd not be running... */
  216. if (!state)
  217. return REGULATOR_STATUS_OFF;
  218. return (state & BIT(3))
  219. ? REGULATOR_STATUS_NORMAL
  220. : REGULATOR_STATUS_STANDBY;
  221. }
  222. static int twl6030reg_get_status(struct regulator_dev *rdev)
  223. {
  224. struct twlreg_info *info = rdev_get_drvdata(rdev);
  225. int val;
  226. val = twlreg_grp(rdev);
  227. if (val < 0)
  228. return val;
  229. val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
  230. switch (TWL6030_CFG_STATE_APP(val)) {
  231. case TWL6030_CFG_STATE_ON:
  232. return REGULATOR_STATUS_NORMAL;
  233. case TWL6030_CFG_STATE_SLEEP:
  234. return REGULATOR_STATUS_STANDBY;
  235. case TWL6030_CFG_STATE_OFF:
  236. case TWL6030_CFG_STATE_OFF2:
  237. default:
  238. break;
  239. }
  240. return REGULATOR_STATUS_OFF;
  241. }
  242. static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode)
  243. {
  244. struct twlreg_info *info = rdev_get_drvdata(rdev);
  245. unsigned message;
  246. int status;
  247. /* We can only set the mode through state machine commands... */
  248. switch (mode) {
  249. case REGULATOR_MODE_NORMAL:
  250. message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_ACTIVE);
  251. break;
  252. case REGULATOR_MODE_STANDBY:
  253. message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_SLEEP);
  254. break;
  255. default:
  256. return -EINVAL;
  257. }
  258. /* Ensure the resource is associated with some group */
  259. status = twlreg_grp(rdev);
  260. if (status < 0)
  261. return status;
  262. if (!(status & (P3_GRP_4030 | P2_GRP_4030 | P1_GRP_4030)))
  263. return -EACCES;
  264. status = twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
  265. message >> 8, TWL4030_PM_MASTER_PB_WORD_MSB);
  266. if (status < 0)
  267. return status;
  268. return twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
  269. message & 0xff, TWL4030_PM_MASTER_PB_WORD_LSB);
  270. }
  271. static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode)
  272. {
  273. struct twlreg_info *info = rdev_get_drvdata(rdev);
  274. int grp = 0;
  275. int val;
  276. if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
  277. grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
  278. if (grp < 0)
  279. return grp;
  280. /* Compose the state register settings */
  281. val = grp << TWL6030_CFG_STATE_GRP_SHIFT;
  282. /* We can only set the mode through state machine commands... */
  283. switch (mode) {
  284. case REGULATOR_MODE_NORMAL:
  285. val |= TWL6030_CFG_STATE_ON;
  286. break;
  287. case REGULATOR_MODE_STANDBY:
  288. val |= TWL6030_CFG_STATE_SLEEP;
  289. break;
  290. default:
  291. return -EINVAL;
  292. }
  293. return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, val);
  294. }
  295. /*----------------------------------------------------------------------*/
  296. /*
  297. * Support for adjustable-voltage LDOs uses a four bit (or less) voltage
  298. * select field in its control register. We use tables indexed by VSEL
  299. * to record voltages in milliVolts. (Accuracy is about three percent.)
  300. *
  301. * Note that VSEL values for VAUX2 changed in twl5030 and newer silicon;
  302. * currently handled by listing two slightly different VAUX2 regulators,
  303. * only one of which will be configured.
  304. *
  305. * VSEL values documented as "TI cannot support these values" are flagged
  306. * in these tables as UNSUP() values; we normally won't assign them.
  307. *
  308. * VAUX3 at 3V is incorrectly listed in some TI manuals as unsupported.
  309. * TI are revising the twl5030/tps659x0 specs to support that 3.0V setting.
  310. */
  311. #ifdef CONFIG_TWL4030_ALLOW_UNSUPPORTED
  312. #define UNSUP_MASK 0x0000
  313. #else
  314. #define UNSUP_MASK 0x8000
  315. #endif
  316. #define UNSUP(x) (UNSUP_MASK | (x))
  317. #define IS_UNSUP(x) (UNSUP_MASK & (x))
  318. #define LDO_MV(x) (~UNSUP_MASK & (x))
  319. static const u16 VAUX1_VSEL_table[] = {
  320. UNSUP(1500), UNSUP(1800), 2500, 2800,
  321. 3000, 3000, 3000, 3000,
  322. };
  323. static const u16 VAUX2_4030_VSEL_table[] = {
  324. UNSUP(1000), UNSUP(1000), UNSUP(1200), 1300,
  325. 1500, 1800, UNSUP(1850), 2500,
  326. UNSUP(2600), 2800, UNSUP(2850), UNSUP(3000),
  327. UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
  328. };
  329. static const u16 VAUX2_VSEL_table[] = {
  330. 1700, 1700, 1900, 1300,
  331. 1500, 1800, 2000, 2500,
  332. 2100, 2800, 2200, 2300,
  333. 2400, 2400, 2400, 2400,
  334. };
  335. static const u16 VAUX3_VSEL_table[] = {
  336. 1500, 1800, 2500, 2800,
  337. 3000, 3000, 3000, 3000,
  338. };
  339. static const u16 VAUX4_VSEL_table[] = {
  340. 700, 1000, 1200, UNSUP(1300),
  341. 1500, 1800, UNSUP(1850), 2500,
  342. UNSUP(2600), 2800, UNSUP(2850), UNSUP(3000),
  343. UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
  344. };
  345. static const u16 VMMC1_VSEL_table[] = {
  346. 1850, 2850, 3000, 3150,
  347. };
  348. static const u16 VMMC2_VSEL_table[] = {
  349. UNSUP(1000), UNSUP(1000), UNSUP(1200), UNSUP(1300),
  350. UNSUP(1500), UNSUP(1800), 1850, UNSUP(2500),
  351. 2600, 2800, 2850, 3000,
  352. 3150, 3150, 3150, 3150,
  353. };
  354. static const u16 VPLL1_VSEL_table[] = {
  355. 1000, 1200, 1300, 1800,
  356. UNSUP(2800), UNSUP(3000), UNSUP(3000), UNSUP(3000),
  357. };
  358. static const u16 VPLL2_VSEL_table[] = {
  359. 700, 1000, 1200, 1300,
  360. UNSUP(1500), 1800, UNSUP(1850), UNSUP(2500),
  361. UNSUP(2600), UNSUP(2800), UNSUP(2850), UNSUP(3000),
  362. UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
  363. };
  364. static const u16 VSIM_VSEL_table[] = {
  365. UNSUP(1000), UNSUP(1200), UNSUP(1300), 1800,
  366. 2800, 3000, 3000, 3000,
  367. };
  368. static const u16 VDAC_VSEL_table[] = {
  369. 1200, 1300, 1800, 1800,
  370. };
  371. static const u16 VDD1_VSEL_table[] = {
  372. 800, 1450,
  373. };
  374. static const u16 VDD2_VSEL_table[] = {
  375. 800, 1450, 1500,
  376. };
  377. static const u16 VIO_VSEL_table[] = {
  378. 1800, 1850,
  379. };
  380. static const u16 VINTANA2_VSEL_table[] = {
  381. 2500, 2750,
  382. };
  383. static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
  384. {
  385. struct twlreg_info *info = rdev_get_drvdata(rdev);
  386. int mV = info->table[index];
  387. return IS_UNSUP(mV) ? 0 : (LDO_MV(mV) * 1000);
  388. }
  389. static int
  390. twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
  391. unsigned *selector)
  392. {
  393. struct twlreg_info *info = rdev_get_drvdata(rdev);
  394. int vsel;
  395. for (vsel = 0; vsel < info->table_len; vsel++) {
  396. int mV = info->table[vsel];
  397. int uV;
  398. if (IS_UNSUP(mV))
  399. continue;
  400. uV = LDO_MV(mV) * 1000;
  401. /* REVISIT for VAUX2, first match may not be best/lowest */
  402. /* use the first in-range value */
  403. if (min_uV <= uV && uV <= max_uV) {
  404. *selector = vsel;
  405. return twlreg_write(info, TWL_MODULE_PM_RECEIVER,
  406. VREG_VOLTAGE, vsel);
  407. }
  408. }
  409. return -EDOM;
  410. }
  411. static int twl4030ldo_get_voltage(struct regulator_dev *rdev)
  412. {
  413. struct twlreg_info *info = rdev_get_drvdata(rdev);
  414. int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
  415. VREG_VOLTAGE);
  416. if (vsel < 0)
  417. return vsel;
  418. vsel &= info->table_len - 1;
  419. return LDO_MV(info->table[vsel]) * 1000;
  420. }
  421. static struct regulator_ops twl4030ldo_ops = {
  422. .list_voltage = twl4030ldo_list_voltage,
  423. .set_voltage = twl4030ldo_set_voltage,
  424. .get_voltage = twl4030ldo_get_voltage,
  425. .enable = twl4030reg_enable,
  426. .disable = twl4030reg_disable,
  427. .is_enabled = twl4030reg_is_enabled,
  428. .set_mode = twl4030reg_set_mode,
  429. .get_status = twl4030reg_get_status,
  430. };
  431. static int
  432. twl4030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
  433. unsigned *selector)
  434. {
  435. struct twlreg_info *info = rdev_get_drvdata(rdev);
  436. int vsel = DIV_ROUND_UP(min_uV - 600000, 12500);
  437. if (info->set_voltage) {
  438. return info->set_voltage(info->data, min_uV);
  439. } else {
  440. twlreg_write(info, TWL_MODULE_PM_RECEIVER,
  441. VREG_VOLTAGE_SMPS_4030, vsel);
  442. }
  443. return 0;
  444. }
  445. static int twl4030smps_get_voltage(struct regulator_dev *rdev)
  446. {
  447. struct twlreg_info *info = rdev_get_drvdata(rdev);
  448. int vsel;
  449. if (info->get_voltage)
  450. return info->get_voltage(info->data);
  451. vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
  452. VREG_VOLTAGE_SMPS_4030);
  453. return vsel * 12500 + 600000;
  454. }
  455. static struct regulator_ops twl4030smps_ops = {
  456. .set_voltage = twl4030smps_set_voltage,
  457. .get_voltage = twl4030smps_get_voltage,
  458. };
  459. static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
  460. {
  461. struct twlreg_info *info = rdev_get_drvdata(rdev);
  462. return ((info->min_mV + (index * 100)) * 1000);
  463. }
  464. static int
  465. twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
  466. unsigned *selector)
  467. {
  468. struct twlreg_info *info = rdev_get_drvdata(rdev);
  469. int vsel;
  470. if ((min_uV/1000 < info->min_mV) || (max_uV/1000 > info->max_mV))
  471. return -EDOM;
  472. /*
  473. * Use the below formula to calculate vsel
  474. * mV = 1000mv + 100mv * (vsel - 1)
  475. */
  476. vsel = (min_uV/1000 - 1000)/100 + 1;
  477. *selector = vsel;
  478. return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel);
  479. }
  480. static int twl6030ldo_get_voltage(struct regulator_dev *rdev)
  481. {
  482. struct twlreg_info *info = rdev_get_drvdata(rdev);
  483. int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
  484. VREG_VOLTAGE);
  485. if (vsel < 0)
  486. return vsel;
  487. /*
  488. * Use the below formula to calculate vsel
  489. * mV = 1000mv + 100mv * (vsel - 1)
  490. */
  491. return (1000 + (100 * (vsel - 1))) * 1000;
  492. }
  493. static struct regulator_ops twl6030ldo_ops = {
  494. .list_voltage = twl6030ldo_list_voltage,
  495. .set_voltage = twl6030ldo_set_voltage,
  496. .get_voltage = twl6030ldo_get_voltage,
  497. .enable = twl6030reg_enable,
  498. .disable = twl6030reg_disable,
  499. .is_enabled = twl6030reg_is_enabled,
  500. .set_mode = twl6030reg_set_mode,
  501. .get_status = twl6030reg_get_status,
  502. };
  503. /*----------------------------------------------------------------------*/
  504. /*
  505. * Fixed voltage LDOs don't have a VSEL field to update.
  506. */
  507. static int twlfixed_list_voltage(struct regulator_dev *rdev, unsigned index)
  508. {
  509. struct twlreg_info *info = rdev_get_drvdata(rdev);
  510. return info->min_mV * 1000;
  511. }
  512. static int twlfixed_get_voltage(struct regulator_dev *rdev)
  513. {
  514. struct twlreg_info *info = rdev_get_drvdata(rdev);
  515. return info->min_mV * 1000;
  516. }
  517. static struct regulator_ops twl4030fixed_ops = {
  518. .list_voltage = twlfixed_list_voltage,
  519. .get_voltage = twlfixed_get_voltage,
  520. .enable = twl4030reg_enable,
  521. .disable = twl4030reg_disable,
  522. .is_enabled = twl4030reg_is_enabled,
  523. .set_mode = twl4030reg_set_mode,
  524. .get_status = twl4030reg_get_status,
  525. };
  526. static struct regulator_ops twl6030fixed_ops = {
  527. .list_voltage = twlfixed_list_voltage,
  528. .get_voltage = twlfixed_get_voltage,
  529. .enable = twl6030reg_enable,
  530. .disable = twl6030reg_disable,
  531. .is_enabled = twl6030reg_is_enabled,
  532. .set_mode = twl6030reg_set_mode,
  533. .get_status = twl6030reg_get_status,
  534. };
  535. static struct regulator_ops twl6030_fixed_resource = {
  536. .enable = twl6030reg_enable,
  537. .disable = twl6030reg_disable,
  538. .is_enabled = twl6030reg_is_enabled,
  539. .get_status = twl6030reg_get_status,
  540. };
  541. /*
  542. * SMPS status and control
  543. */
  544. static int twl6030smps_list_voltage(struct regulator_dev *rdev, unsigned index)
  545. {
  546. struct twlreg_info *info = rdev_get_drvdata(rdev);
  547. int voltage = 0;
  548. switch (info->flags) {
  549. case SMPS_OFFSET_EN:
  550. voltage = 100000;
  551. /* fall through */
  552. case 0:
  553. switch (index) {
  554. case 0:
  555. voltage = 0;
  556. break;
  557. case 58:
  558. voltage = 1350 * 1000;
  559. break;
  560. case 59:
  561. voltage = 1500 * 1000;
  562. break;
  563. case 60:
  564. voltage = 1800 * 1000;
  565. break;
  566. case 61:
  567. voltage = 1900 * 1000;
  568. break;
  569. case 62:
  570. voltage = 2100 * 1000;
  571. break;
  572. default:
  573. voltage += (600000 + (12500 * (index - 1)));
  574. }
  575. break;
  576. case SMPS_EXTENDED_EN:
  577. switch (index) {
  578. case 0:
  579. voltage = 0;
  580. break;
  581. case 58:
  582. voltage = 2084 * 1000;
  583. break;
  584. case 59:
  585. voltage = 2315 * 1000;
  586. break;
  587. case 60:
  588. voltage = 2778 * 1000;
  589. break;
  590. case 61:
  591. voltage = 2932 * 1000;
  592. break;
  593. case 62:
  594. voltage = 3241 * 1000;
  595. break;
  596. default:
  597. voltage = (1852000 + (38600 * (index - 1)));
  598. }
  599. break;
  600. case SMPS_OFFSET_EN | SMPS_EXTENDED_EN:
  601. switch (index) {
  602. case 0:
  603. voltage = 0;
  604. break;
  605. case 58:
  606. voltage = 4167 * 1000;
  607. break;
  608. case 59:
  609. voltage = 2315 * 1000;
  610. break;
  611. case 60:
  612. voltage = 2778 * 1000;
  613. break;
  614. case 61:
  615. voltage = 2932 * 1000;
  616. break;
  617. case 62:
  618. voltage = 3241 * 1000;
  619. break;
  620. default:
  621. voltage = (2161000 + (38600 * (index - 1)));
  622. }
  623. break;
  624. }
  625. return voltage;
  626. }
  627. static int
  628. twl6030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
  629. unsigned int *selector)
  630. {
  631. struct twlreg_info *info = rdev_get_drvdata(rdev);
  632. int vsel = 0;
  633. switch (info->flags) {
  634. case 0:
  635. if (min_uV == 0)
  636. vsel = 0;
  637. else if ((min_uV >= 600000) && (min_uV <= 1300000)) {
  638. int calc_uV;
  639. vsel = (min_uV - 600000) / 125;
  640. if (vsel % 100)
  641. vsel += 100;
  642. vsel /= 100;
  643. vsel++;
  644. calc_uV = twl6030smps_list_voltage(rdev, vsel);
  645. if (calc_uV > max_uV)
  646. return -EINVAL;
  647. }
  648. /* Values 1..57 for vsel are linear and can be calculated
  649. * values 58..62 are non linear.
  650. */
  651. else if ((min_uV > 1900000) && (max_uV >= 2100000))
  652. vsel = 62;
  653. else if ((min_uV > 1800000) && (max_uV >= 1900000))
  654. vsel = 61;
  655. else if ((min_uV > 1500000) && (max_uV >= 1800000))
  656. vsel = 60;
  657. else if ((min_uV > 1350000) && (max_uV >= 1500000))
  658. vsel = 59;
  659. else if ((min_uV > 1300000) && (max_uV >= 1350000))
  660. vsel = 58;
  661. else
  662. return -EINVAL;
  663. break;
  664. case SMPS_OFFSET_EN:
  665. if (min_uV == 0)
  666. vsel = 0;
  667. else if ((min_uV >= 700000) && (min_uV <= 1420000)) {
  668. int calc_uV;
  669. vsel = (min_uV - 700000) / 125;
  670. if (vsel % 100)
  671. vsel += 100;
  672. vsel /= 100;
  673. vsel++;
  674. calc_uV = twl6030smps_list_voltage(rdev, vsel);
  675. if (calc_uV > max_uV)
  676. return -EINVAL;
  677. }
  678. /* Values 1..57 for vsel are linear and can be calculated
  679. * values 58..62 are non linear.
  680. */
  681. else if ((min_uV > 1900000) && (max_uV >= 2100000))
  682. vsel = 62;
  683. else if ((min_uV > 1800000) && (max_uV >= 1900000))
  684. vsel = 61;
  685. else if ((min_uV > 1350000) && (max_uV >= 1800000))
  686. vsel = 60;
  687. else if ((min_uV > 1350000) && (max_uV >= 1500000))
  688. vsel = 59;
  689. else if ((min_uV > 1300000) && (max_uV >= 1350000))
  690. vsel = 58;
  691. else
  692. return -EINVAL;
  693. break;
  694. case SMPS_EXTENDED_EN:
  695. if (min_uV == 0)
  696. vsel = 0;
  697. else if ((min_uV >= 1852000) && (max_uV <= 4013600)) {
  698. vsel = (min_uV - 1852000) / 386;
  699. if (vsel % 100)
  700. vsel += 100;
  701. vsel /= 100;
  702. vsel++;
  703. }
  704. break;
  705. case SMPS_OFFSET_EN|SMPS_EXTENDED_EN:
  706. if (min_uV == 0)
  707. vsel = 0;
  708. else if ((min_uV >= 2161000) && (max_uV <= 4321000)) {
  709. vsel = (min_uV - 2161000) / 386;
  710. if (vsel % 100)
  711. vsel += 100;
  712. vsel /= 100;
  713. vsel++;
  714. }
  715. break;
  716. }
  717. *selector = vsel;
  718. return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS,
  719. vsel);
  720. }
  721. static int twl6030smps_get_voltage_sel(struct regulator_dev *rdev)
  722. {
  723. struct twlreg_info *info = rdev_get_drvdata(rdev);
  724. return twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS);
  725. }
  726. static struct regulator_ops twlsmps_ops = {
  727. .list_voltage = twl6030smps_list_voltage,
  728. .set_voltage = twl6030smps_set_voltage,
  729. .get_voltage_sel = twl6030smps_get_voltage_sel,
  730. .enable = twl6030reg_enable,
  731. .disable = twl6030reg_disable,
  732. .is_enabled = twl6030reg_is_enabled,
  733. .set_mode = twl6030reg_set_mode,
  734. .get_status = twl6030reg_get_status,
  735. };
  736. /*----------------------------------------------------------------------*/
  737. #define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
  738. remap_conf) \
  739. TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
  740. remap_conf, TWL4030, twl4030fixed_ops)
  741. #define TWL6030_FIXED_LDO(label, offset, mVolts, turnon_delay) \
  742. TWL_FIXED_LDO(label, offset, mVolts, 0x0, turnon_delay, \
  743. 0x0, TWL6030, twl6030fixed_ops)
  744. #define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) { \
  745. .base = offset, \
  746. .id = num, \
  747. .table_len = ARRAY_SIZE(label##_VSEL_table), \
  748. .table = label##_VSEL_table, \
  749. .delay = turnon_delay, \
  750. .remap = remap_conf, \
  751. .desc = { \
  752. .name = #label, \
  753. .id = TWL4030_REG_##label, \
  754. .n_voltages = ARRAY_SIZE(label##_VSEL_table), \
  755. .ops = &twl4030ldo_ops, \
  756. .type = REGULATOR_VOLTAGE, \
  757. .owner = THIS_MODULE, \
  758. }, \
  759. }
  760. #define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf) \
  761. { \
  762. .base = offset, \
  763. .id = num, \
  764. .delay = turnon_delay, \
  765. .remap = remap_conf, \
  766. .desc = { \
  767. .name = #label, \
  768. .id = TWL4030_REG_##label, \
  769. .ops = &twl4030smps_ops, \
  770. .type = REGULATOR_VOLTAGE, \
  771. .owner = THIS_MODULE, \
  772. }, \
  773. }
  774. #define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) { \
  775. .base = offset, \
  776. .min_mV = min_mVolts, \
  777. .max_mV = max_mVolts, \
  778. .desc = { \
  779. .name = #label, \
  780. .id = TWL6030_REG_##label, \
  781. .n_voltages = (max_mVolts - min_mVolts)/100 + 1, \
  782. .ops = &twl6030ldo_ops, \
  783. .type = REGULATOR_VOLTAGE, \
  784. .owner = THIS_MODULE, \
  785. }, \
  786. }
  787. #define TWL6025_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) { \
  788. .base = offset, \
  789. .min_mV = min_mVolts, \
  790. .max_mV = max_mVolts, \
  791. .desc = { \
  792. .name = #label, \
  793. .id = TWL6025_REG_##label, \
  794. .n_voltages = ((max_mVolts - min_mVolts)/100) + 1, \
  795. .ops = &twl6030ldo_ops, \
  796. .type = REGULATOR_VOLTAGE, \
  797. .owner = THIS_MODULE, \
  798. }, \
  799. }
  800. #define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \
  801. family, operations) { \
  802. .base = offset, \
  803. .id = num, \
  804. .min_mV = mVolts, \
  805. .delay = turnon_delay, \
  806. .remap = remap_conf, \
  807. .desc = { \
  808. .name = #label, \
  809. .id = family##_REG_##label, \
  810. .n_voltages = 1, \
  811. .ops = &operations, \
  812. .type = REGULATOR_VOLTAGE, \
  813. .owner = THIS_MODULE, \
  814. }, \
  815. }
  816. #define TWL6030_FIXED_RESOURCE(label, offset, turnon_delay) { \
  817. .base = offset, \
  818. .delay = turnon_delay, \
  819. .desc = { \
  820. .name = #label, \
  821. .id = TWL6030_REG_##label, \
  822. .ops = &twl6030_fixed_resource, \
  823. .type = REGULATOR_VOLTAGE, \
  824. .owner = THIS_MODULE, \
  825. }, \
  826. }
  827. #define TWL6025_ADJUSTABLE_SMPS(label, offset) { \
  828. .base = offset, \
  829. .min_mV = 600, \
  830. .max_mV = 2100, \
  831. .desc = { \
  832. .name = #label, \
  833. .id = TWL6025_REG_##label, \
  834. .n_voltages = 63, \
  835. .ops = &twlsmps_ops, \
  836. .type = REGULATOR_VOLTAGE, \
  837. .owner = THIS_MODULE, \
  838. }, \
  839. }
  840. /*
  841. * We list regulators here if systems need some level of
  842. * software control over them after boot.
  843. */
  844. static struct twlreg_info twl_regs[] = {
  845. TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1, 100, 0x08),
  846. TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2, 100, 0x08),
  847. TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2, 100, 0x08),
  848. TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3, 100, 0x08),
  849. TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4, 100, 0x08),
  850. TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5, 100, 0x08),
  851. TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6, 100, 0x08),
  852. TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7, 100, 0x00),
  853. TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8, 100, 0x08),
  854. TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9, 100, 0x00),
  855. TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08),
  856. TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08),
  857. TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08),
  858. TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08),
  859. TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08),
  860. TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08),
  861. TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08),
  862. TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08),
  863. TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08),
  864. TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08),
  865. /* VUSBCP is managed *only* by the USB subchip */
  866. /* 6030 REG with base as PMC Slave Misc : 0x0030 */
  867. /* Turnon-delay and remap configuration values for 6030 are not
  868. verified since the specification is not public */
  869. TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300),
  870. TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300),
  871. TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300),
  872. TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300),
  873. TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300),
  874. TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300),
  875. TWL6030_FIXED_LDO(VANA, 0x50, 2100, 0),
  876. TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 0),
  877. TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 0),
  878. TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 0),
  879. TWL6030_FIXED_RESOURCE(CLK32KG, 0x8C, 0),
  880. /* 6025 are renamed compared to 6030 versions */
  881. TWL6025_ADJUSTABLE_LDO(LDO2, 0x54, 1000, 3300),
  882. TWL6025_ADJUSTABLE_LDO(LDO4, 0x58, 1000, 3300),
  883. TWL6025_ADJUSTABLE_LDO(LDO3, 0x5c, 1000, 3300),
  884. TWL6025_ADJUSTABLE_LDO(LDO5, 0x68, 1000, 3300),
  885. TWL6025_ADJUSTABLE_LDO(LDO1, 0x6c, 1000, 3300),
  886. TWL6025_ADJUSTABLE_LDO(LDO7, 0x74, 1000, 3300),
  887. TWL6025_ADJUSTABLE_LDO(LDO6, 0x60, 1000, 3300),
  888. TWL6025_ADJUSTABLE_LDO(LDOLN, 0x64, 1000, 3300),
  889. TWL6025_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000, 3300),
  890. TWL6025_ADJUSTABLE_SMPS(SMPS3, 0x34),
  891. TWL6025_ADJUSTABLE_SMPS(SMPS4, 0x10),
  892. TWL6025_ADJUSTABLE_SMPS(VIO, 0x16),
  893. };
  894. static u8 twl_get_smps_offset(void)
  895. {
  896. u8 value;
  897. twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value,
  898. TWL6030_SMPS_OFFSET);
  899. return value;
  900. }
  901. static u8 twl_get_smps_mult(void)
  902. {
  903. u8 value;
  904. twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value,
  905. TWL6030_SMPS_MULT);
  906. return value;
  907. }
  908. static int __devinit twlreg_probe(struct platform_device *pdev)
  909. {
  910. int i;
  911. struct twlreg_info *info;
  912. struct regulator_init_data *initdata;
  913. struct regulation_constraints *c;
  914. struct regulator_dev *rdev;
  915. struct twl_regulator_driver_data *drvdata;
  916. for (i = 0, info = NULL; i < ARRAY_SIZE(twl_regs); i++) {
  917. if (twl_regs[i].desc.id != pdev->id)
  918. continue;
  919. info = twl_regs + i;
  920. break;
  921. }
  922. if (!info)
  923. return -ENODEV;
  924. initdata = pdev->dev.platform_data;
  925. if (!initdata)
  926. return -EINVAL;
  927. drvdata = initdata->driver_data;
  928. if (!drvdata)
  929. return -EINVAL;
  930. /* copy the driver data into regulator data */
  931. info->features = drvdata->features;
  932. info->data = drvdata->data;
  933. info->set_voltage = drvdata->set_voltage;
  934. info->get_voltage = drvdata->get_voltage;
  935. /* Constrain board-specific capabilities according to what
  936. * this driver and the chip itself can actually do.
  937. */
  938. c = &initdata->constraints;
  939. c->valid_modes_mask &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_STANDBY;
  940. c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE
  941. | REGULATOR_CHANGE_MODE
  942. | REGULATOR_CHANGE_STATUS;
  943. switch (pdev->id) {
  944. case TWL4030_REG_VIO:
  945. case TWL4030_REG_VDD1:
  946. case TWL4030_REG_VDD2:
  947. case TWL4030_REG_VPLL1:
  948. case TWL4030_REG_VINTANA1:
  949. case TWL4030_REG_VINTANA2:
  950. case TWL4030_REG_VINTDIG:
  951. c->always_on = true;
  952. break;
  953. default:
  954. break;
  955. }
  956. switch (pdev->id) {
  957. case TWL6025_REG_SMPS3:
  958. if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS3)
  959. info->flags |= SMPS_EXTENDED_EN;
  960. if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS3)
  961. info->flags |= SMPS_OFFSET_EN;
  962. break;
  963. case TWL6025_REG_SMPS4:
  964. if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS4)
  965. info->flags |= SMPS_EXTENDED_EN;
  966. if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS4)
  967. info->flags |= SMPS_OFFSET_EN;
  968. break;
  969. case TWL6025_REG_VIO:
  970. if (twl_get_smps_mult() & SMPS_MULTOFFSET_VIO)
  971. info->flags |= SMPS_EXTENDED_EN;
  972. if (twl_get_smps_offset() & SMPS_MULTOFFSET_VIO)
  973. info->flags |= SMPS_OFFSET_EN;
  974. break;
  975. }
  976. rdev = regulator_register(&info->desc, &pdev->dev, initdata, info, NULL);
  977. if (IS_ERR(rdev)) {
  978. dev_err(&pdev->dev, "can't register %s, %ld\n",
  979. info->desc.name, PTR_ERR(rdev));
  980. return PTR_ERR(rdev);
  981. }
  982. platform_set_drvdata(pdev, rdev);
  983. if (twl_class_is_4030())
  984. twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP,
  985. info->remap);
  986. /* NOTE: many regulators support short-circuit IRQs (presentable
  987. * as REGULATOR_OVER_CURRENT notifications?) configured via:
  988. * - SC_CONFIG
  989. * - SC_DETECT1 (vintana2, vmmc1/2, vaux1/2/3/4)
  990. * - SC_DETECT2 (vusb, vdac, vio, vdd1/2, vpll2)
  991. * - IT_CONFIG
  992. */
  993. return 0;
  994. }
  995. static int __devexit twlreg_remove(struct platform_device *pdev)
  996. {
  997. regulator_unregister(platform_get_drvdata(pdev));
  998. return 0;
  999. }
  1000. MODULE_ALIAS("platform:twl_reg");
  1001. static struct platform_driver twlreg_driver = {
  1002. .probe = twlreg_probe,
  1003. .remove = __devexit_p(twlreg_remove),
  1004. /* NOTE: short name, to work around driver model truncation of
  1005. * "twl_regulator.12" (and friends) to "twl_regulator.1".
  1006. */
  1007. .driver.name = "twl_reg",
  1008. .driver.owner = THIS_MODULE,
  1009. };
  1010. static int __init twlreg_init(void)
  1011. {
  1012. return platform_driver_register(&twlreg_driver);
  1013. }
  1014. subsys_initcall(twlreg_init);
  1015. static void __exit twlreg_exit(void)
  1016. {
  1017. platform_driver_unregister(&twlreg_driver);
  1018. }
  1019. module_exit(twlreg_exit)
  1020. MODULE_DESCRIPTION("TWL regulator driver");
  1021. MODULE_LICENSE("GPL");