ab8500.c 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2010
  3. *
  4. * License Terms: GNU General Public License v2
  5. *
  6. * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
  7. * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
  8. * Daniel Willerud <daniel.willerud@stericsson.com> for ST-Ericsson
  9. *
  10. * AB8500 peripheral regulators
  11. *
  12. * AB8500 supports the following regulators:
  13. * VAUX1/2/3, VINTCORE, VTVOUT, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA
  14. *
  15. * AB8505 supports the following regulators:
  16. * VAUX1/2/3/4/5/6, VINTCORE, VADC, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA
  17. */
  18. #include <linux/init.h>
  19. #include <linux/kernel.h>
  20. #include <linux/module.h>
  21. #include <linux/err.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/mfd/abx500.h>
  24. #include <linux/mfd/abx500/ab8500.h>
  25. #include <linux/of.h>
  26. #include <linux/regulator/of_regulator.h>
  27. #include <linux/regulator/driver.h>
  28. #include <linux/regulator/machine.h>
  29. #include <linux/regulator/ab8500.h>
  30. #include <linux/slab.h>
  31. /**
  32. * struct ab8500_regulator_info - ab8500 regulator information
  33. * @dev: device pointer
  34. * @desc: regulator description
  35. * @regulator_dev: regulator device
  36. * @is_enabled: status of regulator (on/off)
  37. * @load_lp_uA: maximum load in idle (low power) mode
  38. * @update_bank: bank to control on/off
  39. * @update_reg: register to control on/off
  40. * @update_mask: mask to enable/disable and set mode of regulator
  41. * @update_val: bits holding the regulator current mode
  42. * @update_val_idle: bits to enable the regulator in idle (low power) mode
  43. * @update_val_normal: bits to enable the regulator in normal (high power) mode
  44. * @voltage_bank: bank to control regulator voltage
  45. * @voltage_reg: register to control regulator voltage
  46. * @voltage_mask: mask to control regulator voltage
  47. * @voltage_shift: shift to control regulator voltage
  48. */
  49. struct ab8500_regulator_info {
  50. struct device *dev;
  51. struct regulator_desc desc;
  52. struct regulator_dev *regulator;
  53. bool is_enabled;
  54. int load_lp_uA;
  55. u8 update_bank;
  56. u8 update_reg;
  57. u8 update_mask;
  58. u8 update_val;
  59. u8 update_val_idle;
  60. u8 update_val_normal;
  61. u8 voltage_bank;
  62. u8 voltage_reg;
  63. u8 voltage_mask;
  64. u8 voltage_shift;
  65. };
  66. /* voltage tables for the vauxn/vintcore supplies */
  67. static const unsigned int ldo_vauxn_voltages[] = {
  68. 1100000,
  69. 1200000,
  70. 1300000,
  71. 1400000,
  72. 1500000,
  73. 1800000,
  74. 1850000,
  75. 1900000,
  76. 2500000,
  77. 2650000,
  78. 2700000,
  79. 2750000,
  80. 2800000,
  81. 2900000,
  82. 3000000,
  83. 3300000,
  84. };
  85. static const unsigned int ldo_vaux3_voltages[] = {
  86. 1200000,
  87. 1500000,
  88. 1800000,
  89. 2100000,
  90. 2500000,
  91. 2750000,
  92. 2790000,
  93. 2910000,
  94. };
  95. static const int ldo_vaux56_voltages[] = {
  96. 1800000,
  97. 1050000,
  98. 1100000,
  99. 1200000,
  100. 1500000,
  101. 2200000,
  102. 2500000,
  103. 2790000,
  104. };
  105. static const unsigned int ldo_vintcore_voltages[] = {
  106. 1200000,
  107. 1225000,
  108. 1250000,
  109. 1275000,
  110. 1300000,
  111. 1325000,
  112. 1350000,
  113. };
  114. static int ab8500_regulator_enable(struct regulator_dev *rdev)
  115. {
  116. int ret;
  117. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  118. if (info == NULL) {
  119. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  120. return -EINVAL;
  121. }
  122. ret = abx500_mask_and_set_register_interruptible(info->dev,
  123. info->update_bank, info->update_reg,
  124. info->update_mask, info->update_val);
  125. if (ret < 0) {
  126. dev_err(rdev_get_dev(rdev),
  127. "couldn't set enable bits for regulator\n");
  128. return ret;
  129. }
  130. info->is_enabled = true;
  131. dev_vdbg(rdev_get_dev(rdev),
  132. "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
  133. info->desc.name, info->update_bank, info->update_reg,
  134. info->update_mask, info->update_val);
  135. return ret;
  136. }
  137. static int ab8500_regulator_disable(struct regulator_dev *rdev)
  138. {
  139. int ret;
  140. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  141. if (info == NULL) {
  142. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  143. return -EINVAL;
  144. }
  145. ret = abx500_mask_and_set_register_interruptible(info->dev,
  146. info->update_bank, info->update_reg,
  147. info->update_mask, 0x0);
  148. if (ret < 0) {
  149. dev_err(rdev_get_dev(rdev),
  150. "couldn't set disable bits for regulator\n");
  151. return ret;
  152. }
  153. info->is_enabled = false;
  154. dev_vdbg(rdev_get_dev(rdev),
  155. "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
  156. info->desc.name, info->update_bank, info->update_reg,
  157. info->update_mask, 0x0);
  158. return ret;
  159. }
  160. static unsigned int ab8500_regulator_get_optimum_mode(
  161. struct regulator_dev *rdev, int input_uV,
  162. int output_uV, int load_uA)
  163. {
  164. unsigned int mode;
  165. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  166. if (info == NULL) {
  167. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  168. return -EINVAL;
  169. }
  170. if (load_uA <= info->load_lp_uA)
  171. mode = REGULATOR_MODE_IDLE;
  172. else
  173. mode = REGULATOR_MODE_NORMAL;
  174. return mode;
  175. }
  176. static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
  177. unsigned int mode)
  178. {
  179. int ret;
  180. u8 update_val;
  181. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  182. if (info == NULL) {
  183. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  184. return -EINVAL;
  185. }
  186. switch (mode) {
  187. case REGULATOR_MODE_NORMAL:
  188. update_val = info->update_val_normal;
  189. break;
  190. case REGULATOR_MODE_IDLE:
  191. update_val = info->update_val_idle;
  192. break;
  193. default:
  194. return -EINVAL;
  195. }
  196. /* ab8500 regulators share mode and enable in the same register bits.
  197. off = 0b00
  198. low power mode= 0b11
  199. full powermode = 0b01
  200. (HW control mode = 0b10)
  201. Thus we don't write to the register when regulator is disabled.
  202. */
  203. if (info->is_enabled) {
  204. ret = abx500_mask_and_set_register_interruptible(info->dev,
  205. info->update_bank, info->update_reg,
  206. info->update_mask, update_val);
  207. if (ret < 0) {
  208. dev_err(rdev_get_dev(rdev),
  209. "couldn't set regulator mode\n");
  210. return ret;
  211. }
  212. dev_vdbg(rdev_get_dev(rdev),
  213. "%s-set_mode (bank, reg, mask, value): "
  214. "0x%x, 0x%x, 0x%x, 0x%x\n",
  215. info->desc.name, info->update_bank, info->update_reg,
  216. info->update_mask, update_val);
  217. }
  218. info->update_val = update_val;
  219. return 0;
  220. }
  221. static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
  222. {
  223. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  224. int ret;
  225. if (info == NULL) {
  226. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  227. return -EINVAL;
  228. }
  229. if (info->update_val == info->update_val_normal)
  230. ret = REGULATOR_MODE_NORMAL;
  231. else if (info->update_val == info->update_val_idle)
  232. ret = REGULATOR_MODE_IDLE;
  233. else
  234. ret = -EINVAL;
  235. return ret;
  236. }
  237. static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
  238. {
  239. int ret;
  240. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  241. u8 regval;
  242. if (info == NULL) {
  243. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  244. return -EINVAL;
  245. }
  246. ret = abx500_get_register_interruptible(info->dev,
  247. info->update_bank, info->update_reg, &regval);
  248. if (ret < 0) {
  249. dev_err(rdev_get_dev(rdev),
  250. "couldn't read 0x%x register\n", info->update_reg);
  251. return ret;
  252. }
  253. dev_vdbg(rdev_get_dev(rdev),
  254. "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
  255. " 0x%x\n",
  256. info->desc.name, info->update_bank, info->update_reg,
  257. info->update_mask, regval);
  258. if (regval & info->update_mask)
  259. info->is_enabled = true;
  260. else
  261. info->is_enabled = false;
  262. return info->is_enabled;
  263. }
  264. static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
  265. {
  266. int ret, val;
  267. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  268. u8 regval;
  269. if (info == NULL) {
  270. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  271. return -EINVAL;
  272. }
  273. ret = abx500_get_register_interruptible(info->dev,
  274. info->voltage_bank, info->voltage_reg, &regval);
  275. if (ret < 0) {
  276. dev_err(rdev_get_dev(rdev),
  277. "couldn't read voltage reg for regulator\n");
  278. return ret;
  279. }
  280. dev_vdbg(rdev_get_dev(rdev),
  281. "%s-get_voltage (bank, reg, mask, shift, value): "
  282. "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
  283. info->desc.name, info->voltage_bank,
  284. info->voltage_reg, info->voltage_mask,
  285. info->voltage_shift, regval);
  286. val = regval & info->voltage_mask;
  287. return val >> info->voltage_shift;
  288. }
  289. static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
  290. unsigned selector)
  291. {
  292. int ret;
  293. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  294. u8 regval;
  295. if (info == NULL) {
  296. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  297. return -EINVAL;
  298. }
  299. /* set the registers for the request */
  300. regval = (u8)selector << info->voltage_shift;
  301. ret = abx500_mask_and_set_register_interruptible(info->dev,
  302. info->voltage_bank, info->voltage_reg,
  303. info->voltage_mask, regval);
  304. if (ret < 0)
  305. dev_err(rdev_get_dev(rdev),
  306. "couldn't set voltage reg for regulator\n");
  307. dev_vdbg(rdev_get_dev(rdev),
  308. "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
  309. " 0x%x\n",
  310. info->desc.name, info->voltage_bank, info->voltage_reg,
  311. info->voltage_mask, regval);
  312. return ret;
  313. }
  314. static struct regulator_ops ab8500_regulator_volt_mode_ops = {
  315. .enable = ab8500_regulator_enable,
  316. .disable = ab8500_regulator_disable,
  317. .is_enabled = ab8500_regulator_is_enabled,
  318. .get_optimum_mode = ab8500_regulator_get_optimum_mode,
  319. .set_mode = ab8500_regulator_set_mode,
  320. .get_mode = ab8500_regulator_get_mode,
  321. .get_voltage_sel = ab8500_regulator_get_voltage_sel,
  322. .set_voltage_sel = ab8500_regulator_set_voltage_sel,
  323. .list_voltage = regulator_list_voltage_table,
  324. };
  325. static struct regulator_ops ab8500_regulator_mode_ops = {
  326. .enable = ab8500_regulator_enable,
  327. .disable = ab8500_regulator_disable,
  328. .is_enabled = ab8500_regulator_is_enabled,
  329. .get_optimum_mode = ab8500_regulator_get_optimum_mode,
  330. .set_mode = ab8500_regulator_set_mode,
  331. .get_mode = ab8500_regulator_get_mode,
  332. .get_voltage_sel = ab8500_regulator_get_voltage_sel,
  333. .list_voltage = regulator_list_voltage_linear,
  334. };
  335. static struct regulator_ops ab8500_regulator_ops = {
  336. .enable = ab8500_regulator_enable,
  337. .disable = ab8500_regulator_disable,
  338. .is_enabled = ab8500_regulator_is_enabled,
  339. .get_voltage_sel = ab8500_regulator_get_voltage_sel,
  340. .list_voltage = regulator_list_voltage_linear,
  341. };
  342. /* AB8500 regulator information */
  343. static struct ab8500_regulator_info
  344. ab8500_regulator_info[AB8500_NUM_REGULATORS] = {
  345. /*
  346. * Variable Voltage Regulators
  347. * name, min mV, max mV,
  348. * update bank, reg, mask, enable val
  349. * volt bank, reg, mask
  350. */
  351. [AB8500_LDO_AUX1] = {
  352. .desc = {
  353. .name = "LDO-AUX1",
  354. .ops = &ab8500_regulator_volt_mode_ops,
  355. .type = REGULATOR_VOLTAGE,
  356. .id = AB8500_LDO_AUX1,
  357. .owner = THIS_MODULE,
  358. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  359. .volt_table = ldo_vauxn_voltages,
  360. .enable_time = 200,
  361. },
  362. .load_lp_uA = 5000,
  363. .update_bank = 0x04,
  364. .update_reg = 0x09,
  365. .update_mask = 0x03,
  366. .update_val = 0x01,
  367. .update_val_idle = 0x03,
  368. .update_val_normal = 0x01,
  369. .voltage_bank = 0x04,
  370. .voltage_reg = 0x1f,
  371. .voltage_mask = 0x0f,
  372. },
  373. [AB8500_LDO_AUX2] = {
  374. .desc = {
  375. .name = "LDO-AUX2",
  376. .ops = &ab8500_regulator_volt_mode_ops,
  377. .type = REGULATOR_VOLTAGE,
  378. .id = AB8500_LDO_AUX2,
  379. .owner = THIS_MODULE,
  380. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  381. .volt_table = ldo_vauxn_voltages,
  382. .enable_time = 200,
  383. },
  384. .load_lp_uA = 5000,
  385. .update_bank = 0x04,
  386. .update_reg = 0x09,
  387. .update_mask = 0x0c,
  388. .update_val = 0x04,
  389. .update_val_idle = 0x0c,
  390. .update_val_normal = 0x04,
  391. .voltage_bank = 0x04,
  392. .voltage_reg = 0x20,
  393. .voltage_mask = 0x0f,
  394. },
  395. [AB8500_LDO_AUX3] = {
  396. .desc = {
  397. .name = "LDO-AUX3",
  398. .ops = &ab8500_regulator_volt_mode_ops,
  399. .type = REGULATOR_VOLTAGE,
  400. .id = AB8500_LDO_AUX3,
  401. .owner = THIS_MODULE,
  402. .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
  403. .volt_table = ldo_vaux3_voltages,
  404. .enable_time = 450,
  405. },
  406. .load_lp_uA = 5000,
  407. .update_bank = 0x04,
  408. .update_reg = 0x0a,
  409. .update_mask = 0x03,
  410. .update_val = 0x01,
  411. .update_val_idle = 0x03,
  412. .update_val_normal = 0x01,
  413. .voltage_bank = 0x04,
  414. .voltage_reg = 0x21,
  415. .voltage_mask = 0x07,
  416. },
  417. [AB8500_LDO_INTCORE] = {
  418. .desc = {
  419. .name = "LDO-INTCORE",
  420. .ops = &ab8500_regulator_volt_mode_ops,
  421. .type = REGULATOR_VOLTAGE,
  422. .id = AB8500_LDO_INTCORE,
  423. .owner = THIS_MODULE,
  424. .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
  425. .volt_table = ldo_vintcore_voltages,
  426. .enable_time = 750,
  427. },
  428. .load_lp_uA = 5000,
  429. .update_bank = 0x03,
  430. .update_reg = 0x80,
  431. .update_mask = 0x44,
  432. .update_val = 0x44,
  433. .update_val_idle = 0x44,
  434. .update_val_normal = 0x04,
  435. .voltage_bank = 0x03,
  436. .voltage_reg = 0x80,
  437. .voltage_mask = 0x38,
  438. .voltage_shift = 3,
  439. },
  440. /*
  441. * Fixed Voltage Regulators
  442. * name, fixed mV,
  443. * update bank, reg, mask, enable val
  444. */
  445. [AB8500_LDO_TVOUT] = {
  446. .desc = {
  447. .name = "LDO-TVOUT",
  448. .ops = &ab8500_regulator_mode_ops,
  449. .type = REGULATOR_VOLTAGE,
  450. .id = AB8500_LDO_TVOUT,
  451. .owner = THIS_MODULE,
  452. .n_voltages = 1,
  453. .min_uV = 2000000,
  454. .enable_time = 500,
  455. },
  456. .load_lp_uA = 1000,
  457. .update_bank = 0x03,
  458. .update_reg = 0x80,
  459. .update_mask = 0x82,
  460. .update_val = 0x02,
  461. .update_val_idle = 0x82,
  462. .update_val_normal = 0x02,
  463. },
  464. [AB8500_LDO_AUDIO] = {
  465. .desc = {
  466. .name = "LDO-AUDIO",
  467. .ops = &ab8500_regulator_ops,
  468. .type = REGULATOR_VOLTAGE,
  469. .id = AB8500_LDO_AUDIO,
  470. .owner = THIS_MODULE,
  471. .n_voltages = 1,
  472. .min_uV = 2000000,
  473. .enable_time = 140,
  474. },
  475. .update_bank = 0x03,
  476. .update_reg = 0x83,
  477. .update_mask = 0x02,
  478. .update_val = 0x02,
  479. },
  480. [AB8500_LDO_ANAMIC1] = {
  481. .desc = {
  482. .name = "LDO-ANAMIC1",
  483. .ops = &ab8500_regulator_ops,
  484. .type = REGULATOR_VOLTAGE,
  485. .id = AB8500_LDO_ANAMIC1,
  486. .owner = THIS_MODULE,
  487. .n_voltages = 1,
  488. .min_uV = 2050000,
  489. .enable_time = 500,
  490. },
  491. .update_bank = 0x03,
  492. .update_reg = 0x83,
  493. .update_mask = 0x08,
  494. .update_val = 0x08,
  495. },
  496. [AB8500_LDO_ANAMIC2] = {
  497. .desc = {
  498. .name = "LDO-ANAMIC2",
  499. .ops = &ab8500_regulator_ops,
  500. .type = REGULATOR_VOLTAGE,
  501. .id = AB8500_LDO_ANAMIC2,
  502. .owner = THIS_MODULE,
  503. .n_voltages = 1,
  504. .min_uV = 2050000,
  505. .enable_time = 500,
  506. },
  507. .update_bank = 0x03,
  508. .update_reg = 0x83,
  509. .update_mask = 0x10,
  510. .update_val = 0x10,
  511. },
  512. [AB8500_LDO_DMIC] = {
  513. .desc = {
  514. .name = "LDO-DMIC",
  515. .ops = &ab8500_regulator_ops,
  516. .type = REGULATOR_VOLTAGE,
  517. .id = AB8500_LDO_DMIC,
  518. .owner = THIS_MODULE,
  519. .n_voltages = 1,
  520. .min_uV = 1800000,
  521. .enable_time = 420,
  522. },
  523. .update_bank = 0x03,
  524. .update_reg = 0x83,
  525. .update_mask = 0x04,
  526. .update_val = 0x04,
  527. },
  528. /*
  529. * Regulators with fixed voltage and normal/idle modes
  530. */
  531. [AB8500_LDO_ANA] = {
  532. .desc = {
  533. .name = "LDO-ANA",
  534. .ops = &ab8500_regulator_mode_ops,
  535. .type = REGULATOR_VOLTAGE,
  536. .id = AB8500_LDO_ANA,
  537. .owner = THIS_MODULE,
  538. .n_voltages = 1,
  539. .min_uV = 1200000,
  540. .enable_time = 140,
  541. },
  542. .load_lp_uA = 1000,
  543. .update_bank = 0x04,
  544. .update_reg = 0x06,
  545. .update_mask = 0x0c,
  546. .update_val = 0x04,
  547. .update_val_idle = 0x0c,
  548. .update_val_normal = 0x04,
  549. },
  550. };
  551. /* AB8505 regulator information */
  552. static struct ab8500_regulator_info
  553. ab8505_regulator_info[AB8505_NUM_REGULATORS] = {
  554. /*
  555. * Variable Voltage Regulators
  556. * name, min mV, max mV,
  557. * update bank, reg, mask, enable val
  558. * volt bank, reg, mask, table, table length
  559. */
  560. [AB8505_LDO_AUX1] = {
  561. .desc = {
  562. .name = "LDO-AUX1",
  563. .ops = &ab8500_regulator_volt_mode_ops,
  564. .type = REGULATOR_VOLTAGE,
  565. .id = AB8500_LDO_AUX1,
  566. .owner = THIS_MODULE,
  567. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  568. },
  569. .min_uV = 1100000,
  570. .max_uV = 3300000,
  571. .load_lp_uA = 5000,
  572. .update_bank = 0x04,
  573. .update_reg = 0x09,
  574. .update_mask = 0x03,
  575. .update_val = 0x01,
  576. .update_val_idle = 0x03,
  577. .update_val_normal = 0x01,
  578. .voltage_bank = 0x04,
  579. .voltage_reg = 0x1f,
  580. .voltage_mask = 0x0f,
  581. .voltages = ldo_vauxn_voltages,
  582. .voltages_len = ARRAY_SIZE(ldo_vauxn_voltages),
  583. },
  584. [AB8505_LDO_AUX2] = {
  585. .desc = {
  586. .name = "LDO-AUX2",
  587. .ops = &ab8500_regulator_volt_mode_ops,
  588. .type = REGULATOR_VOLTAGE,
  589. .id = AB8500_LDO_AUX2,
  590. .owner = THIS_MODULE,
  591. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  592. },
  593. .min_uV = 1100000,
  594. .max_uV = 3300000,
  595. .load_lp_uA = 5000,
  596. .update_bank = 0x04,
  597. .update_reg = 0x09,
  598. .update_mask = 0x0c,
  599. .update_val = 0x04,
  600. .update_val_idle = 0x0c,
  601. .update_val_normal = 0x04,
  602. .voltage_bank = 0x04,
  603. .voltage_reg = 0x20,
  604. .voltage_mask = 0x0f,
  605. .voltages = ldo_vauxn_voltages,
  606. .voltages_len = ARRAY_SIZE(ldo_vauxn_voltages),
  607. },
  608. [AB8505_LDO_AUX3] = {
  609. .desc = {
  610. .name = "LDO-AUX3",
  611. .ops = &ab8500_regulator_volt_mode_ops,
  612. .type = REGULATOR_VOLTAGE,
  613. .id = AB8500_LDO_AUX3,
  614. .owner = THIS_MODULE,
  615. .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
  616. },
  617. .min_uV = 1100000,
  618. .max_uV = 3300000,
  619. .load_lp_uA = 5000,
  620. .update_bank = 0x04,
  621. .update_reg = 0x0a,
  622. .update_mask = 0x03,
  623. .update_val = 0x01,
  624. .update_val_idle = 0x03,
  625. .update_val_normal = 0x01,
  626. .voltage_bank = 0x04,
  627. .voltage_reg = 0x21,
  628. .voltage_mask = 0x07,
  629. .voltages = ldo_vaux3_voltages,
  630. .voltages_len = ARRAY_SIZE(ldo_vaux3_voltages),
  631. },
  632. [AB8505_LDO_AUX4] = {
  633. .desc = {
  634. .name = "LDO-AUX4",
  635. .ops = &ab8500_regulator_volt_mode_ops,
  636. .type = REGULATOR_VOLTAGE,
  637. .id = AB9540_LDO_AUX4,
  638. .owner = THIS_MODULE,
  639. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  640. },
  641. .min_uV = 1100000,
  642. .max_uV = 3300000,
  643. .load_lp_uA = 5000,
  644. /* values for Vaux4Regu register */
  645. .update_bank = 0x04,
  646. .update_reg = 0x2e,
  647. .update_mask = 0x03,
  648. .update_val = 0x01,
  649. .update_val_idle = 0x03,
  650. .update_val_normal = 0x01,
  651. /* values for Vaux4SEL register */
  652. .voltage_bank = 0x04,
  653. .voltage_reg = 0x2f,
  654. .voltage_mask = 0x0f,
  655. .voltages = ldo_vauxn_voltages,
  656. .voltages_len = ARRAY_SIZE(ldo_vauxn_voltages),
  657. },
  658. [AB8505_LDO_AUX5] = {
  659. .desc = {
  660. .name = "LDO-AUX5",
  661. .ops = &ab8500_regulator_volt_mode_ops,
  662. .type = REGULATOR_VOLTAGE,
  663. .id = AB8505_LDO_AUX5,
  664. .owner = THIS_MODULE,
  665. .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
  666. },
  667. .min_uV = 1050000,
  668. .max_uV = 2790000,
  669. .load_lp_uA = 2000,
  670. /* values for CtrlVaux5 register */
  671. .update_bank = 0x01,
  672. .update_reg = 0x55,
  673. .update_mask = 0x08,
  674. .update_val = 0x00,
  675. .update_val_idle = 0x01,
  676. .update_val_normal = 0x00,
  677. .voltage_bank = 0x01,
  678. .voltage_reg = 0x55,
  679. .voltage_mask = 0x07,
  680. .voltages = ldo_vaux56_voltages,
  681. .voltages_len = ARRAY_SIZE(ldo_vaux56_voltages),
  682. },
  683. [AB8505_LDO_AUX6] = {
  684. .desc = {
  685. .name = "LDO-AUX6",
  686. .ops = &ab8500_regulator_volt_mode_ops,
  687. .type = REGULATOR_VOLTAGE,
  688. .id = AB8505_LDO_AUX6,
  689. .owner = THIS_MODULE,
  690. .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
  691. },
  692. .min_uV = 1050000,
  693. .max_uV = 2790000,
  694. .load_lp_uA = 2000,
  695. /* values for CtrlVaux6 register */
  696. .update_bank = 0x01,
  697. .update_reg = 0x56,
  698. .update_mask = 0x08,
  699. .update_val = 0x00,
  700. .update_val_idle = 0x01,
  701. .update_val_normal = 0x00,
  702. .voltage_bank = 0x01,
  703. .voltage_reg = 0x56,
  704. .voltage_mask = 0x07,
  705. .voltages = ldo_vaux56_voltages,
  706. .voltages_len = ARRAY_SIZE(ldo_vaux56_voltages),
  707. },
  708. [AB8505_LDO_INTCORE] = {
  709. .desc = {
  710. .name = "LDO-INTCORE",
  711. .ops = &ab8500_regulator_volt_mode_ops,
  712. .type = REGULATOR_VOLTAGE,
  713. .id = AB8500_LDO_INTCORE,
  714. .owner = THIS_MODULE,
  715. .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
  716. },
  717. .min_uV = 1100000,
  718. .max_uV = 3300000,
  719. .load_lp_uA = 5000,
  720. .update_bank = 0x03,
  721. .update_reg = 0x80,
  722. .update_mask = 0x44,
  723. .update_val = 0x04,
  724. .update_val_idle = 0x44,
  725. .update_val_normal = 0x04,
  726. .voltage_bank = 0x03,
  727. .voltage_reg = 0x80,
  728. .voltage_mask = 0x38,
  729. .voltages = ldo_vintcore_voltages,
  730. .voltages_len = ARRAY_SIZE(ldo_vintcore_voltages),
  731. .voltage_shift = 3,
  732. },
  733. /*
  734. * Fixed Voltage Regulators
  735. * name, fixed mV,
  736. * update bank, reg, mask, enable val
  737. */
  738. [AB8505_LDO_ADC] = {
  739. .desc = {
  740. .name = "LDO-ADC",
  741. .ops = &ab8500_regulator_mode_ops,
  742. .type = REGULATOR_VOLTAGE,
  743. .id = AB8505_LDO_ADC,
  744. .owner = THIS_MODULE,
  745. .n_voltages = 1,
  746. },
  747. .delay = 10000,
  748. .fixed_uV = 2000000,
  749. .load_lp_uA = 1000,
  750. .update_bank = 0x03,
  751. .update_reg = 0x80,
  752. .update_mask = 0x82,
  753. .update_val = 0x02,
  754. .update_val_idle = 0x82,
  755. .update_val_normal = 0x02,
  756. },
  757. [AB8505_LDO_USB] = {
  758. .desc = {
  759. .name = "LDO-USB",
  760. .ops = &ab8500_regulator_mode_ops,
  761. .type = REGULATOR_VOLTAGE,
  762. .id = AB9540_LDO_USB,
  763. .owner = THIS_MODULE,
  764. .n_voltages = 1,
  765. },
  766. .fixed_uV = 3300000,
  767. .update_bank = 0x03,
  768. .update_reg = 0x82,
  769. .update_mask = 0x03,
  770. .update_val = 0x01,
  771. .update_val_idle = 0x03,
  772. .update_val_normal = 0x01,
  773. },
  774. [AB8505_LDO_AUDIO] = {
  775. .desc = {
  776. .name = "LDO-AUDIO",
  777. .ops = &ab8500_regulator_ops,
  778. .type = REGULATOR_VOLTAGE,
  779. .id = AB8500_LDO_AUDIO,
  780. .owner = THIS_MODULE,
  781. .n_voltages = 1,
  782. },
  783. .fixed_uV = 2000000,
  784. .update_bank = 0x03,
  785. .update_reg = 0x83,
  786. .update_mask = 0x02,
  787. .update_val = 0x02,
  788. },
  789. [AB8505_LDO_ANAMIC1] = {
  790. .desc = {
  791. .name = "LDO-ANAMIC1",
  792. .ops = &ab8500_regulator_ops,
  793. .type = REGULATOR_VOLTAGE,
  794. .id = AB8500_LDO_ANAMIC1,
  795. .owner = THIS_MODULE,
  796. .n_voltages = 1,
  797. },
  798. .fixed_uV = 2050000,
  799. .update_bank = 0x03,
  800. .update_reg = 0x83,
  801. .update_mask = 0x08,
  802. .update_val = 0x08,
  803. },
  804. [AB8505_LDO_ANAMIC2] = {
  805. .desc = {
  806. .name = "LDO-ANAMIC2",
  807. .ops = &ab8500_regulator_ops,
  808. .type = REGULATOR_VOLTAGE,
  809. .id = AB8500_LDO_ANAMIC2,
  810. .owner = THIS_MODULE,
  811. .n_voltages = 1,
  812. },
  813. .fixed_uV = 2050000,
  814. .update_bank = 0x03,
  815. .update_reg = 0x83,
  816. .update_mask = 0x10,
  817. .update_val = 0x10,
  818. },
  819. [AB8505_LDO_AUX8] = {
  820. .desc = {
  821. .name = "LDO-AUX8",
  822. .ops = &ab8500_regulator_ops,
  823. .type = REGULATOR_VOLTAGE,
  824. .id = AB8505_LDO_AUX8,
  825. .owner = THIS_MODULE,
  826. .n_voltages = 1,
  827. },
  828. .fixed_uV = 1800000,
  829. .update_bank = 0x03,
  830. .update_reg = 0x83,
  831. .update_mask = 0x04,
  832. .update_val = 0x04,
  833. },
  834. /*
  835. * Regulators with fixed voltage and normal/idle modes
  836. */
  837. [AB8505_LDO_ANA] = {
  838. .desc = {
  839. .name = "LDO-ANA",
  840. .ops = &ab8500_regulator_mode_ops,
  841. .type = REGULATOR_VOLTAGE,
  842. .id = AB8500_LDO_ANA,
  843. .owner = THIS_MODULE,
  844. .n_voltages = 1,
  845. },
  846. .fixed_uV = 1200000,
  847. .load_lp_uA = 1000,
  848. .update_bank = 0x04,
  849. .update_reg = 0x06,
  850. .update_mask = 0x0c,
  851. .update_val = 0x04,
  852. .update_val_idle = 0x0c,
  853. .update_val_normal = 0x04,
  854. },
  855. };
  856. /* AB9540 regulator information */
  857. static struct ab8500_regulator_info
  858. ab9540_regulator_info[AB9540_NUM_REGULATORS] = {
  859. /*
  860. * Variable Voltage Regulators
  861. * name, min mV, max mV,
  862. * update bank, reg, mask, enable val
  863. * volt bank, reg, mask, table, table length
  864. */
  865. [AB9540_LDO_AUX1] = {
  866. .desc = {
  867. .name = "LDO-AUX1",
  868. .ops = &ab8500_regulator_volt_mode_ops,
  869. .type = REGULATOR_VOLTAGE,
  870. .id = AB8500_LDO_AUX1,
  871. .owner = THIS_MODULE,
  872. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  873. },
  874. .min_uV = 1100000,
  875. .max_uV = 3300000,
  876. .load_lp_uA = 5000,
  877. .update_bank = 0x04,
  878. .update_reg = 0x09,
  879. .update_mask = 0x03,
  880. .update_val = 0x01,
  881. .update_val_idle = 0x03,
  882. .update_val_normal = 0x01,
  883. .voltage_bank = 0x04,
  884. .voltage_reg = 0x1f,
  885. .voltage_mask = 0x0f,
  886. .voltages = ldo_vauxn_voltages,
  887. .voltages_len = ARRAY_SIZE(ldo_vauxn_voltages),
  888. },
  889. [AB9540_LDO_AUX2] = {
  890. .desc = {
  891. .name = "LDO-AUX2",
  892. .ops = &ab8500_regulator_volt_mode_ops,
  893. .type = REGULATOR_VOLTAGE,
  894. .id = AB8500_LDO_AUX2,
  895. .owner = THIS_MODULE,
  896. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  897. },
  898. .min_uV = 1100000,
  899. .max_uV = 3300000,
  900. .load_lp_uA = 5000,
  901. .update_bank = 0x04,
  902. .update_reg = 0x09,
  903. .update_mask = 0x0c,
  904. .update_val = 0x04,
  905. .update_val_idle = 0x0c,
  906. .update_val_normal = 0x04,
  907. .voltage_bank = 0x04,
  908. .voltage_reg = 0x20,
  909. .voltage_mask = 0x0f,
  910. .voltages = ldo_vauxn_voltages,
  911. .voltages_len = ARRAY_SIZE(ldo_vauxn_voltages),
  912. },
  913. [AB9540_LDO_AUX3] = {
  914. .desc = {
  915. .name = "LDO-AUX3",
  916. .ops = &ab8500_regulator_volt_mode_ops,
  917. .type = REGULATOR_VOLTAGE,
  918. .id = AB8500_LDO_AUX3,
  919. .owner = THIS_MODULE,
  920. .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
  921. },
  922. .min_uV = 1100000,
  923. .max_uV = 3300000,
  924. .load_lp_uA = 5000,
  925. .update_bank = 0x04,
  926. .update_reg = 0x0a,
  927. .update_mask = 0x03,
  928. .update_val = 0x01,
  929. .update_val_idle = 0x03,
  930. .update_val_normal = 0x01,
  931. .voltage_bank = 0x04,
  932. .voltage_reg = 0x21,
  933. .voltage_mask = 0x07,
  934. .voltages = ldo_vaux3_voltages,
  935. .voltages_len = ARRAY_SIZE(ldo_vaux3_voltages),
  936. },
  937. [AB9540_LDO_AUX4] = {
  938. .desc = {
  939. .name = "LDO-AUX4",
  940. .ops = &ab8500_regulator_volt_mode_ops,
  941. .type = REGULATOR_VOLTAGE,
  942. .id = AB9540_LDO_AUX4,
  943. .owner = THIS_MODULE,
  944. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  945. },
  946. .min_uV = 1100000,
  947. .max_uV = 3300000,
  948. .load_lp_uA = 5000,
  949. /* values for Vaux4Regu register */
  950. .update_bank = 0x04,
  951. .update_reg = 0x2e,
  952. .update_mask = 0x03,
  953. .update_val = 0x01,
  954. .update_val_idle = 0x03,
  955. .update_val_normal = 0x01,
  956. /* values for Vaux4SEL register */
  957. .voltage_bank = 0x04,
  958. .voltage_reg = 0x2f,
  959. .voltage_mask = 0x0f,
  960. .voltages = ldo_vauxn_voltages,
  961. .voltages_len = ARRAY_SIZE(ldo_vauxn_voltages),
  962. },
  963. [AB9540_LDO_INTCORE] = {
  964. .desc = {
  965. .name = "LDO-INTCORE",
  966. .ops = &ab8500_regulator_volt_mode_ops,
  967. .type = REGULATOR_VOLTAGE,
  968. .id = AB8500_LDO_INTCORE,
  969. .owner = THIS_MODULE,
  970. .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
  971. },
  972. .min_uV = 1100000,
  973. .max_uV = 3300000,
  974. .load_lp_uA = 5000,
  975. .update_bank = 0x03,
  976. .update_reg = 0x80,
  977. .update_mask = 0x44,
  978. .update_val = 0x44,
  979. .update_val_idle = 0x44,
  980. .update_val_normal = 0x04,
  981. .voltage_bank = 0x03,
  982. .voltage_reg = 0x80,
  983. .voltage_mask = 0x38,
  984. .voltages = ldo_vintcore_voltages,
  985. .voltages_len = ARRAY_SIZE(ldo_vintcore_voltages),
  986. .voltage_shift = 3,
  987. },
  988. /*
  989. * Fixed Voltage Regulators
  990. * name, fixed mV,
  991. * update bank, reg, mask, enable val
  992. */
  993. [AB9540_LDO_TVOUT] = {
  994. .desc = {
  995. .name = "LDO-TVOUT",
  996. .ops = &ab8500_regulator_mode_ops,
  997. .type = REGULATOR_VOLTAGE,
  998. .id = AB8500_LDO_TVOUT,
  999. .owner = THIS_MODULE,
  1000. .n_voltages = 1,
  1001. },
  1002. .delay = 10000,
  1003. .fixed_uV = 2000000,
  1004. .load_lp_uA = 1000,
  1005. .update_bank = 0x03,
  1006. .update_reg = 0x80,
  1007. .update_mask = 0x82,
  1008. .update_val = 0x02,
  1009. .update_val_idle = 0x82,
  1010. .update_val_normal = 0x02,
  1011. },
  1012. [AB9540_LDO_USB] = {
  1013. .desc = {
  1014. .name = "LDO-USB",
  1015. .ops = &ab8500_regulator_ops,
  1016. .type = REGULATOR_VOLTAGE,
  1017. .id = AB9540_LDO_USB,
  1018. .owner = THIS_MODULE,
  1019. .n_voltages = 1,
  1020. },
  1021. .fixed_uV = 3300000,
  1022. .update_bank = 0x03,
  1023. .update_reg = 0x82,
  1024. .update_mask = 0x03,
  1025. .update_val = 0x01,
  1026. .update_val_idle = 0x03,
  1027. .update_val_normal = 0x01,
  1028. },
  1029. [AB9540_LDO_AUDIO] = {
  1030. .desc = {
  1031. .name = "LDO-AUDIO",
  1032. .ops = &ab8500_regulator_ops,
  1033. .type = REGULATOR_VOLTAGE,
  1034. .id = AB8500_LDO_AUDIO,
  1035. .owner = THIS_MODULE,
  1036. .n_voltages = 1,
  1037. },
  1038. .fixed_uV = 2000000,
  1039. .update_bank = 0x03,
  1040. .update_reg = 0x83,
  1041. .update_mask = 0x02,
  1042. .update_val = 0x02,
  1043. },
  1044. [AB9540_LDO_ANAMIC1] = {
  1045. .desc = {
  1046. .name = "LDO-ANAMIC1",
  1047. .ops = &ab8500_regulator_ops,
  1048. .type = REGULATOR_VOLTAGE,
  1049. .id = AB8500_LDO_ANAMIC1,
  1050. .owner = THIS_MODULE,
  1051. .n_voltages = 1,
  1052. },
  1053. .fixed_uV = 2050000,
  1054. .update_bank = 0x03,
  1055. .update_reg = 0x83,
  1056. .update_mask = 0x08,
  1057. .update_val = 0x08,
  1058. },
  1059. [AB9540_LDO_ANAMIC2] = {
  1060. .desc = {
  1061. .name = "LDO-ANAMIC2",
  1062. .ops = &ab8500_regulator_ops,
  1063. .type = REGULATOR_VOLTAGE,
  1064. .id = AB8500_LDO_ANAMIC2,
  1065. .owner = THIS_MODULE,
  1066. .n_voltages = 1,
  1067. },
  1068. .fixed_uV = 2050000,
  1069. .update_bank = 0x03,
  1070. .update_reg = 0x83,
  1071. .update_mask = 0x10,
  1072. .update_val = 0x10,
  1073. },
  1074. [AB9540_LDO_DMIC] = {
  1075. .desc = {
  1076. .name = "LDO-DMIC",
  1077. .ops = &ab8500_regulator_ops,
  1078. .type = REGULATOR_VOLTAGE,
  1079. .id = AB8500_LDO_DMIC,
  1080. .owner = THIS_MODULE,
  1081. .n_voltages = 1,
  1082. },
  1083. .fixed_uV = 1800000,
  1084. .update_bank = 0x03,
  1085. .update_reg = 0x83,
  1086. .update_mask = 0x04,
  1087. .update_val = 0x04,
  1088. },
  1089. /*
  1090. * Regulators with fixed voltage and normal/idle modes
  1091. */
  1092. [AB9540_LDO_ANA] = {
  1093. .desc = {
  1094. .name = "LDO-ANA",
  1095. .ops = &ab8500_regulator_mode_ops,
  1096. .type = REGULATOR_VOLTAGE,
  1097. .id = AB8500_LDO_ANA,
  1098. .owner = THIS_MODULE,
  1099. .n_voltages = 1,
  1100. },
  1101. .fixed_uV = 1200000,
  1102. .load_lp_uA = 1000,
  1103. .update_bank = 0x04,
  1104. .update_reg = 0x06,
  1105. .update_mask = 0x0c,
  1106. .update_val = 0x08,
  1107. .update_val_idle = 0x0c,
  1108. .update_val_normal = 0x08,
  1109. },
  1110. };
  1111. struct ab8500_reg_init {
  1112. u8 bank;
  1113. u8 addr;
  1114. u8 mask;
  1115. };
  1116. #define REG_INIT(_id, _bank, _addr, _mask) \
  1117. [_id] = { \
  1118. .bank = _bank, \
  1119. .addr = _addr, \
  1120. .mask = _mask, \
  1121. }
  1122. /* AB8500 register init */
  1123. static struct ab8500_reg_init ab8500_reg_init[] = {
  1124. /*
  1125. * 0x30, VanaRequestCtrl
  1126. * 0xc0, VextSupply1RequestCtrl
  1127. */
  1128. REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xf0),
  1129. /*
  1130. * 0x03, VextSupply2RequestCtrl
  1131. * 0x0c, VextSupply3RequestCtrl
  1132. * 0x30, Vaux1RequestCtrl
  1133. * 0xc0, Vaux2RequestCtrl
  1134. */
  1135. REG_INIT(AB8500_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
  1136. /*
  1137. * 0x03, Vaux3RequestCtrl
  1138. * 0x04, SwHPReq
  1139. */
  1140. REG_INIT(AB8500_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
  1141. /*
  1142. * 0x08, VanaSysClkReq1HPValid
  1143. * 0x20, Vaux1SysClkReq1HPValid
  1144. * 0x40, Vaux2SysClkReq1HPValid
  1145. * 0x80, Vaux3SysClkReq1HPValid
  1146. */
  1147. REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xe8),
  1148. /*
  1149. * 0x10, VextSupply1SysClkReq1HPValid
  1150. * 0x20, VextSupply2SysClkReq1HPValid
  1151. * 0x40, VextSupply3SysClkReq1HPValid
  1152. */
  1153. REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x70),
  1154. /*
  1155. * 0x08, VanaHwHPReq1Valid
  1156. * 0x20, Vaux1HwHPReq1Valid
  1157. * 0x40, Vaux2HwHPReq1Valid
  1158. * 0x80, Vaux3HwHPReq1Valid
  1159. */
  1160. REG_INIT(AB8500_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xe8),
  1161. /*
  1162. * 0x01, VextSupply1HwHPReq1Valid
  1163. * 0x02, VextSupply2HwHPReq1Valid
  1164. * 0x04, VextSupply3HwHPReq1Valid
  1165. */
  1166. REG_INIT(AB8500_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
  1167. /*
  1168. * 0x08, VanaHwHPReq2Valid
  1169. * 0x20, Vaux1HwHPReq2Valid
  1170. * 0x40, Vaux2HwHPReq2Valid
  1171. * 0x80, Vaux3HwHPReq2Valid
  1172. */
  1173. REG_INIT(AB8500_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xe8),
  1174. /*
  1175. * 0x01, VextSupply1HwHPReq2Valid
  1176. * 0x02, VextSupply2HwHPReq2Valid
  1177. * 0x04, VextSupply3HwHPReq2Valid
  1178. */
  1179. REG_INIT(AB8500_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
  1180. /*
  1181. * 0x20, VanaSwHPReqValid
  1182. * 0x80, Vaux1SwHPReqValid
  1183. */
  1184. REG_INIT(AB8500_REGUSWHPREQVALID1, 0x03, 0x0d, 0xa0),
  1185. /*
  1186. * 0x01, Vaux2SwHPReqValid
  1187. * 0x02, Vaux3SwHPReqValid
  1188. * 0x04, VextSupply1SwHPReqValid
  1189. * 0x08, VextSupply2SwHPReqValid
  1190. * 0x10, VextSupply3SwHPReqValid
  1191. */
  1192. REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
  1193. /*
  1194. * 0x02, SysClkReq2Valid1
  1195. * 0x04, SysClkReq3Valid1
  1196. * 0x08, SysClkReq4Valid1
  1197. * 0x10, SysClkReq5Valid1
  1198. * 0x20, SysClkReq6Valid1
  1199. * 0x40, SysClkReq7Valid1
  1200. * 0x80, SysClkReq8Valid1
  1201. */
  1202. REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
  1203. /*
  1204. * 0x02, SysClkReq2Valid2
  1205. * 0x04, SysClkReq3Valid2
  1206. * 0x08, SysClkReq4Valid2
  1207. * 0x10, SysClkReq5Valid2
  1208. * 0x20, SysClkReq6Valid2
  1209. * 0x40, SysClkReq7Valid2
  1210. * 0x80, SysClkReq8Valid2
  1211. */
  1212. REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
  1213. /*
  1214. * 0x02, VTVoutEna
  1215. * 0x04, Vintcore12Ena
  1216. * 0x38, Vintcore12Sel
  1217. * 0x40, Vintcore12LP
  1218. * 0x80, VTVoutLP
  1219. */
  1220. REG_INIT(AB8500_REGUMISC1, 0x03, 0x80, 0xfe),
  1221. /*
  1222. * 0x02, VaudioEna
  1223. * 0x04, VdmicEna
  1224. * 0x08, Vamic1Ena
  1225. * 0x10, Vamic2Ena
  1226. */
  1227. REG_INIT(AB8500_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
  1228. /*
  1229. * 0x01, Vamic1_dzout
  1230. * 0x02, Vamic2_dzout
  1231. */
  1232. REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
  1233. /*
  1234. * 0x03, VpllRegu (NOTE! PRCMU register bits)
  1235. * 0x0c, VanaRegu
  1236. */
  1237. REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f),
  1238. /*
  1239. * 0x01, VrefDDREna
  1240. * 0x02, VrefDDRSleepMode
  1241. */
  1242. REG_INIT(AB8500_VREFDDR, 0x04, 0x07, 0x03),
  1243. /*
  1244. * 0x03, VextSupply1Regu
  1245. * 0x0c, VextSupply2Regu
  1246. * 0x30, VextSupply3Regu
  1247. * 0x40, ExtSupply2Bypass
  1248. * 0x80, ExtSupply3Bypass
  1249. */
  1250. REG_INIT(AB8500_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
  1251. /*
  1252. * 0x03, Vaux1Regu
  1253. * 0x0c, Vaux2Regu
  1254. */
  1255. REG_INIT(AB8500_VAUX12REGU, 0x04, 0x09, 0x0f),
  1256. /*
  1257. * 0x03, Vaux3Regu
  1258. */
  1259. REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x03),
  1260. /*
  1261. * 0x0f, Vaux1Sel
  1262. */
  1263. REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f),
  1264. /*
  1265. * 0x0f, Vaux2Sel
  1266. */
  1267. REG_INIT(AB8500_VAUX2SEL, 0x04, 0x20, 0x0f),
  1268. /*
  1269. * 0x07, Vaux3Sel
  1270. */
  1271. REG_INIT(AB8500_VRF1VAUX3SEL, 0x04, 0x21, 0x07),
  1272. /*
  1273. * 0x01, VextSupply12LP
  1274. */
  1275. REG_INIT(AB8500_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
  1276. /*
  1277. * 0x04, Vaux1Disch
  1278. * 0x08, Vaux2Disch
  1279. * 0x10, Vaux3Disch
  1280. * 0x20, Vintcore12Disch
  1281. * 0x40, VTVoutDisch
  1282. * 0x80, VaudioDisch
  1283. */
  1284. REG_INIT(AB8500_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
  1285. /*
  1286. * 0x02, VanaDisch
  1287. * 0x04, VdmicPullDownEna
  1288. * 0x10, VdmicDisch
  1289. */
  1290. REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
  1291. };
  1292. /* AB8505 register init */
  1293. static struct ab8500_reg_init ab8505_reg_init[] = {
  1294. /*
  1295. * 0x03, VarmRequestCtrl
  1296. * 0x0c, VsmpsCRequestCtrl
  1297. * 0x30, VsmpsARequestCtrl
  1298. * 0xc0, VsmpsBRequestCtrl
  1299. */
  1300. REG_INIT(AB8505_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
  1301. /*
  1302. * 0x03, VsafeRequestCtrl
  1303. * 0x0c, VpllRequestCtrl
  1304. * 0x30, VanaRequestCtrl
  1305. */
  1306. REG_INIT(AB8505_REGUREQUESTCTRL2, 0x03, 0x04, 0x3f),
  1307. /*
  1308. * 0x30, Vaux1RequestCtrl
  1309. * 0xc0, Vaux2RequestCtrl
  1310. */
  1311. REG_INIT(AB8505_REGUREQUESTCTRL3, 0x03, 0x05, 0xf0),
  1312. /*
  1313. * 0x03, Vaux3RequestCtrl
  1314. * 0x04, SwHPReq
  1315. */
  1316. REG_INIT(AB8505_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
  1317. /*
  1318. * 0x01, VsmpsASysClkReq1HPValid
  1319. * 0x02, VsmpsBSysClkReq1HPValid
  1320. * 0x04, VsafeSysClkReq1HPValid
  1321. * 0x08, VanaSysClkReq1HPValid
  1322. * 0x10, VpllSysClkReq1HPValid
  1323. * 0x20, Vaux1SysClkReq1HPValid
  1324. * 0x40, Vaux2SysClkReq1HPValid
  1325. * 0x80, Vaux3SysClkReq1HPValid
  1326. */
  1327. REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
  1328. /*
  1329. * 0x01, VsmpsCSysClkReq1HPValid
  1330. * 0x02, VarmSysClkReq1HPValid
  1331. * 0x04, VbbSysClkReq1HPValid
  1332. * 0x08, VsmpsMSysClkReq1HPValid
  1333. */
  1334. REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x0f),
  1335. /*
  1336. * 0x01, VsmpsAHwHPReq1Valid
  1337. * 0x02, VsmpsBHwHPReq1Valid
  1338. * 0x04, VsafeHwHPReq1Valid
  1339. * 0x08, VanaHwHPReq1Valid
  1340. * 0x10, VpllHwHPReq1Valid
  1341. * 0x20, Vaux1HwHPReq1Valid
  1342. * 0x40, Vaux2HwHPReq1Valid
  1343. * 0x80, Vaux3HwHPReq1Valid
  1344. */
  1345. REG_INIT(AB8505_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
  1346. /*
  1347. * 0x08, VsmpsMHwHPReq1Valid
  1348. */
  1349. REG_INIT(AB8505_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x08),
  1350. /*
  1351. * 0x01, VsmpsAHwHPReq2Valid
  1352. * 0x02, VsmpsBHwHPReq2Valid
  1353. * 0x04, VsafeHwHPReq2Valid
  1354. * 0x08, VanaHwHPReq2Valid
  1355. * 0x10, VpllHwHPReq2Valid
  1356. * 0x20, Vaux1HwHPReq2Valid
  1357. * 0x40, Vaux2HwHPReq2Valid
  1358. * 0x80, Vaux3HwHPReq2Valid
  1359. */
  1360. REG_INIT(AB8505_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
  1361. /*
  1362. * 0x08, VsmpsMHwHPReq2Valid
  1363. */
  1364. REG_INIT(AB8505_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x08),
  1365. /*
  1366. * 0x01, VsmpsCSwHPReqValid
  1367. * 0x02, VarmSwHPReqValid
  1368. * 0x04, VsmpsASwHPReqValid
  1369. * 0x08, VsmpsBSwHPReqValid
  1370. * 0x10, VsafeSwHPReqValid
  1371. * 0x20, VanaSwHPReqValid
  1372. * 0x40, VpllSwHPReqValid
  1373. * 0x80, Vaux1SwHPReqValid
  1374. */
  1375. REG_INIT(AB8505_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
  1376. /*
  1377. * 0x01, Vaux2SwHPReqValid
  1378. * 0x02, Vaux3SwHPReqValid
  1379. * 0x20, VsmpsMSwHPReqValid
  1380. */
  1381. REG_INIT(AB8505_REGUSWHPREQVALID2, 0x03, 0x0e, 0x23),
  1382. /*
  1383. * 0x02, SysClkReq2Valid1
  1384. * 0x04, SysClkReq3Valid1
  1385. * 0x08, SysClkReq4Valid1
  1386. */
  1387. REG_INIT(AB8505_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0x0e),
  1388. /*
  1389. * 0x02, SysClkReq2Valid2
  1390. * 0x04, SysClkReq3Valid2
  1391. * 0x08, SysClkReq4Valid2
  1392. */
  1393. REG_INIT(AB8505_REGUSYSCLKREQVALID2, 0x03, 0x10, 0x0e),
  1394. /*
  1395. * 0x01, Vaux4SwHPReqValid
  1396. * 0x02, Vaux4HwHPReq2Valid
  1397. * 0x04, Vaux4HwHPReq1Valid
  1398. * 0x08, Vaux4SysClkReq1HPValid
  1399. */
  1400. REG_INIT(AB8505_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
  1401. /*
  1402. * 0x02, VadcEna
  1403. * 0x04, VintCore12Ena
  1404. * 0x38, VintCore12Sel
  1405. * 0x40, VintCore12LP
  1406. * 0x80, VadcLP
  1407. */
  1408. REG_INIT(AB8505_REGUMISC1, 0x03, 0x80, 0xfe),
  1409. /*
  1410. * 0x02, VaudioEna
  1411. * 0x04, VdmicEna
  1412. * 0x08, Vamic1Ena
  1413. * 0x10, Vamic2Ena
  1414. */
  1415. REG_INIT(AB8505_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
  1416. /*
  1417. * 0x01, Vamic1_dzout
  1418. * 0x02, Vamic2_dzout
  1419. */
  1420. REG_INIT(AB8505_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
  1421. /*
  1422. * 0x03, VsmpsARegu
  1423. * 0x0c, VsmpsASelCtrl
  1424. * 0x10, VsmpsAAutoMode
  1425. * 0x20, VsmpsAPWMMode
  1426. */
  1427. REG_INIT(AB8505_VSMPSAREGU, 0x04, 0x03, 0x3f),
  1428. /*
  1429. * 0x03, VsmpsBRegu
  1430. * 0x0c, VsmpsBSelCtrl
  1431. * 0x10, VsmpsBAutoMode
  1432. * 0x20, VsmpsBPWMMode
  1433. */
  1434. REG_INIT(AB8505_VSMPSBREGU, 0x04, 0x04, 0x3f),
  1435. /*
  1436. * 0x03, VsafeRegu
  1437. * 0x0c, VsafeSelCtrl
  1438. * 0x10, VsafeAutoMode
  1439. * 0x20, VsafePWMMode
  1440. */
  1441. REG_INIT(AB8505_VSAFEREGU, 0x04, 0x05, 0x3f),
  1442. /*
  1443. * 0x03, VpllRegu (NOTE! PRCMU register bits)
  1444. * 0x0c, VanaRegu
  1445. */
  1446. REG_INIT(AB8505_VPLLVANAREGU, 0x04, 0x06, 0x0f),
  1447. /*
  1448. * 0x03, VextSupply1Regu
  1449. * 0x0c, VextSupply2Regu
  1450. * 0x30, VextSupply3Regu
  1451. * 0x40, ExtSupply2Bypass
  1452. * 0x80, ExtSupply3Bypass
  1453. */
  1454. REG_INIT(AB8505_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
  1455. /*
  1456. * 0x03, Vaux1Regu
  1457. * 0x0c, Vaux2Regu
  1458. */
  1459. REG_INIT(AB8505_VAUX12REGU, 0x04, 0x09, 0x0f),
  1460. /*
  1461. * 0x0f, Vaux3Regu
  1462. */
  1463. REG_INIT(AB8505_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
  1464. /*
  1465. * 0x3f, VsmpsASel1
  1466. */
  1467. REG_INIT(AB8505_VSMPSASEL1, 0x04, 0x13, 0x3f),
  1468. /*
  1469. * 0x3f, VsmpsASel2
  1470. */
  1471. REG_INIT(AB8505_VSMPSASEL2, 0x04, 0x14, 0x3f),
  1472. /*
  1473. * 0x3f, VsmpsASel3
  1474. */
  1475. REG_INIT(AB8505_VSMPSASEL3, 0x04, 0x15, 0x3f),
  1476. /*
  1477. * 0x3f, VsmpsBSel1
  1478. */
  1479. REG_INIT(AB8505_VSMPSBSEL1, 0x04, 0x17, 0x3f),
  1480. /*
  1481. * 0x3f, VsmpsBSel2
  1482. */
  1483. REG_INIT(AB8505_VSMPSBSEL2, 0x04, 0x18, 0x3f),
  1484. /*
  1485. * 0x3f, VsmpsBSel3
  1486. */
  1487. REG_INIT(AB8505_VSMPSBSEL3, 0x04, 0x19, 0x3f),
  1488. /*
  1489. * 0x7f, VsafeSel1
  1490. */
  1491. REG_INIT(AB8505_VSAFESEL1, 0x04, 0x1b, 0x7f),
  1492. /*
  1493. * 0x3f, VsafeSel2
  1494. */
  1495. REG_INIT(AB8505_VSAFESEL2, 0x04, 0x1c, 0x7f),
  1496. /*
  1497. * 0x3f, VsafeSel3
  1498. */
  1499. REG_INIT(AB8505_VSAFESEL3, 0x04, 0x1d, 0x7f),
  1500. /*
  1501. * 0x0f, Vaux1Sel
  1502. */
  1503. REG_INIT(AB8505_VAUX1SEL, 0x04, 0x1f, 0x0f),
  1504. /*
  1505. * 0x0f, Vaux2Sel
  1506. */
  1507. REG_INIT(AB8505_VAUX2SEL, 0x04, 0x20, 0x0f),
  1508. /*
  1509. * 0x07, Vaux3Sel
  1510. * 0x30, VRF1Sel
  1511. */
  1512. REG_INIT(AB8505_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
  1513. /*
  1514. * 0x03, Vaux4RequestCtrl
  1515. */
  1516. REG_INIT(AB8505_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
  1517. /*
  1518. * 0x03, Vaux4Regu
  1519. */
  1520. REG_INIT(AB8505_VAUX4REGU, 0x04, 0x2e, 0x03),
  1521. /*
  1522. * 0x0f, Vaux4Sel
  1523. */
  1524. REG_INIT(AB8505_VAUX4SEL, 0x04, 0x2f, 0x0f),
  1525. /*
  1526. * 0x04, Vaux1Disch
  1527. * 0x08, Vaux2Disch
  1528. * 0x10, Vaux3Disch
  1529. * 0x20, Vintcore12Disch
  1530. * 0x40, VTVoutDisch
  1531. * 0x80, VaudioDisch
  1532. */
  1533. REG_INIT(AB8505_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
  1534. /*
  1535. * 0x02, VanaDisch
  1536. * 0x04, VdmicPullDownEna
  1537. * 0x10, VdmicDisch
  1538. */
  1539. REG_INIT(AB8505_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
  1540. /*
  1541. * 0x01, Vaux4Disch
  1542. */
  1543. REG_INIT(AB8505_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
  1544. /*
  1545. * 0x07, Vaux5Sel
  1546. * 0x08, Vaux5LP
  1547. * 0x10, Vaux5Ena
  1548. * 0x20, Vaux5Disch
  1549. * 0x40, Vaux5DisSfst
  1550. * 0x80, Vaux5DisPulld
  1551. */
  1552. REG_INIT(AB8505_CTRLVAUX5, 0x01, 0x55, 0xff),
  1553. /*
  1554. * 0x07, Vaux6Sel
  1555. * 0x08, Vaux6LP
  1556. * 0x10, Vaux6Ena
  1557. * 0x80, Vaux6DisPulld
  1558. */
  1559. REG_INIT(AB8505_CTRLVAUX6, 0x01, 0x56, 0x9f),
  1560. };
  1561. /* AB9540 register init */
  1562. static struct ab8500_reg_init ab9540_reg_init[] = {
  1563. /*
  1564. * 0x03, VarmRequestCtrl
  1565. * 0x0c, VapeRequestCtrl
  1566. * 0x30, Vsmps1RequestCtrl
  1567. * 0xc0, Vsmps2RequestCtrl
  1568. */
  1569. REG_INIT(AB9540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
  1570. /*
  1571. * 0x03, Vsmps3RequestCtrl
  1572. * 0x0c, VpllRequestCtrl
  1573. * 0x30, VanaRequestCtrl
  1574. * 0xc0, VextSupply1RequestCtrl
  1575. */
  1576. REG_INIT(AB9540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
  1577. /*
  1578. * 0x03, VextSupply2RequestCtrl
  1579. * 0x0c, VextSupply3RequestCtrl
  1580. * 0x30, Vaux1RequestCtrl
  1581. * 0xc0, Vaux2RequestCtrl
  1582. */
  1583. REG_INIT(AB9540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
  1584. /*
  1585. * 0x03, Vaux3RequestCtrl
  1586. * 0x04, SwHPReq
  1587. */
  1588. REG_INIT(AB9540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
  1589. /*
  1590. * 0x01, Vsmps1SysClkReq1HPValid
  1591. * 0x02, Vsmps2SysClkReq1HPValid
  1592. * 0x04, Vsmps3SysClkReq1HPValid
  1593. * 0x08, VanaSysClkReq1HPValid
  1594. * 0x10, VpllSysClkReq1HPValid
  1595. * 0x20, Vaux1SysClkReq1HPValid
  1596. * 0x40, Vaux2SysClkReq1HPValid
  1597. * 0x80, Vaux3SysClkReq1HPValid
  1598. */
  1599. REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
  1600. /*
  1601. * 0x01, VapeSysClkReq1HPValid
  1602. * 0x02, VarmSysClkReq1HPValid
  1603. * 0x04, VbbSysClkReq1HPValid
  1604. * 0x08, VmodSysClkReq1HPValid
  1605. * 0x10, VextSupply1SysClkReq1HPValid
  1606. * 0x20, VextSupply2SysClkReq1HPValid
  1607. * 0x40, VextSupply3SysClkReq1HPValid
  1608. */
  1609. REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x7f),
  1610. /*
  1611. * 0x01, Vsmps1HwHPReq1Valid
  1612. * 0x02, Vsmps2HwHPReq1Valid
  1613. * 0x04, Vsmps3HwHPReq1Valid
  1614. * 0x08, VanaHwHPReq1Valid
  1615. * 0x10, VpllHwHPReq1Valid
  1616. * 0x20, Vaux1HwHPReq1Valid
  1617. * 0x40, Vaux2HwHPReq1Valid
  1618. * 0x80, Vaux3HwHPReq1Valid
  1619. */
  1620. REG_INIT(AB9540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
  1621. /*
  1622. * 0x01, VextSupply1HwHPReq1Valid
  1623. * 0x02, VextSupply2HwHPReq1Valid
  1624. * 0x04, VextSupply3HwHPReq1Valid
  1625. * 0x08, VmodHwHPReq1Valid
  1626. */
  1627. REG_INIT(AB9540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x0f),
  1628. /*
  1629. * 0x01, Vsmps1HwHPReq2Valid
  1630. * 0x02, Vsmps2HwHPReq2Valid
  1631. * 0x03, Vsmps3HwHPReq2Valid
  1632. * 0x08, VanaHwHPReq2Valid
  1633. * 0x10, VpllHwHPReq2Valid
  1634. * 0x20, Vaux1HwHPReq2Valid
  1635. * 0x40, Vaux2HwHPReq2Valid
  1636. * 0x80, Vaux3HwHPReq2Valid
  1637. */
  1638. REG_INIT(AB9540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
  1639. /*
  1640. * 0x01, VextSupply1HwHPReq2Valid
  1641. * 0x02, VextSupply2HwHPReq2Valid
  1642. * 0x04, VextSupply3HwHPReq2Valid
  1643. * 0x08, VmodHwHPReq2Valid
  1644. */
  1645. REG_INIT(AB9540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x0f),
  1646. /*
  1647. * 0x01, VapeSwHPReqValid
  1648. * 0x02, VarmSwHPReqValid
  1649. * 0x04, Vsmps1SwHPReqValid
  1650. * 0x08, Vsmps2SwHPReqValid
  1651. * 0x10, Vsmps3SwHPReqValid
  1652. * 0x20, VanaSwHPReqValid
  1653. * 0x40, VpllSwHPReqValid
  1654. * 0x80, Vaux1SwHPReqValid
  1655. */
  1656. REG_INIT(AB9540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
  1657. /*
  1658. * 0x01, Vaux2SwHPReqValid
  1659. * 0x02, Vaux3SwHPReqValid
  1660. * 0x04, VextSupply1SwHPReqValid
  1661. * 0x08, VextSupply2SwHPReqValid
  1662. * 0x10, VextSupply3SwHPReqValid
  1663. * 0x20, VmodSwHPReqValid
  1664. */
  1665. REG_INIT(AB9540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x3f),
  1666. /*
  1667. * 0x02, SysClkReq2Valid1
  1668. * ...
  1669. * 0x80, SysClkReq8Valid1
  1670. */
  1671. REG_INIT(AB9540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
  1672. /*
  1673. * 0x02, SysClkReq2Valid2
  1674. * ...
  1675. * 0x80, SysClkReq8Valid2
  1676. */
  1677. REG_INIT(AB9540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
  1678. /*
  1679. * 0x01, Vaux4SwHPReqValid
  1680. * 0x02, Vaux4HwHPReq2Valid
  1681. * 0x04, Vaux4HwHPReq1Valid
  1682. * 0x08, Vaux4SysClkReq1HPValid
  1683. */
  1684. REG_INIT(AB9540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
  1685. /*
  1686. * 0x02, VTVoutEna
  1687. * 0x04, Vintcore12Ena
  1688. * 0x38, Vintcore12Sel
  1689. * 0x40, Vintcore12LP
  1690. * 0x80, VTVoutLP
  1691. */
  1692. REG_INIT(AB9540_REGUMISC1, 0x03, 0x80, 0xfe),
  1693. /*
  1694. * 0x02, VaudioEna
  1695. * 0x04, VdmicEna
  1696. * 0x08, Vamic1Ena
  1697. * 0x10, Vamic2Ena
  1698. */
  1699. REG_INIT(AB9540_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
  1700. /*
  1701. * 0x01, Vamic1_dzout
  1702. * 0x02, Vamic2_dzout
  1703. */
  1704. REG_INIT(AB9540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
  1705. /*
  1706. * 0x03, Vsmps1Regu
  1707. * 0x0c, Vsmps1SelCtrl
  1708. * 0x10, Vsmps1AutoMode
  1709. * 0x20, Vsmps1PWMMode
  1710. */
  1711. REG_INIT(AB9540_VSMPS1REGU, 0x04, 0x03, 0x3f),
  1712. /*
  1713. * 0x03, Vsmps2Regu
  1714. * 0x0c, Vsmps2SelCtrl
  1715. * 0x10, Vsmps2AutoMode
  1716. * 0x20, Vsmps2PWMMode
  1717. */
  1718. REG_INIT(AB9540_VSMPS2REGU, 0x04, 0x04, 0x3f),
  1719. /*
  1720. * 0x03, Vsmps3Regu
  1721. * 0x0c, Vsmps3SelCtrl
  1722. * NOTE! PRCMU register
  1723. */
  1724. REG_INIT(AB9540_VSMPS3REGU, 0x04, 0x05, 0x0f),
  1725. /*
  1726. * 0x03, VpllRegu
  1727. * 0x0c, VanaRegu
  1728. */
  1729. REG_INIT(AB9540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
  1730. /*
  1731. * 0x03, VextSupply1Regu
  1732. * 0x0c, VextSupply2Regu
  1733. * 0x30, VextSupply3Regu
  1734. * 0x40, ExtSupply2Bypass
  1735. * 0x80, ExtSupply3Bypass
  1736. */
  1737. REG_INIT(AB9540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
  1738. /*
  1739. * 0x03, Vaux1Regu
  1740. * 0x0c, Vaux2Regu
  1741. */
  1742. REG_INIT(AB9540_VAUX12REGU, 0x04, 0x09, 0x0f),
  1743. /*
  1744. * 0x0c, Vrf1Regu
  1745. * 0x03, Vaux3Regu
  1746. */
  1747. REG_INIT(AB9540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
  1748. /*
  1749. * 0x3f, Vsmps1Sel1
  1750. */
  1751. REG_INIT(AB9540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
  1752. /*
  1753. * 0x3f, Vsmps1Sel2
  1754. */
  1755. REG_INIT(AB9540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
  1756. /*
  1757. * 0x3f, Vsmps1Sel3
  1758. */
  1759. REG_INIT(AB9540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
  1760. /*
  1761. * 0x3f, Vsmps2Sel1
  1762. */
  1763. REG_INIT(AB9540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
  1764. /*
  1765. * 0x3f, Vsmps2Sel2
  1766. */
  1767. REG_INIT(AB9540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
  1768. /*
  1769. * 0x3f, Vsmps2Sel3
  1770. */
  1771. REG_INIT(AB9540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
  1772. /*
  1773. * 0x7f, Vsmps3Sel1
  1774. * NOTE! PRCMU register
  1775. */
  1776. REG_INIT(AB9540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
  1777. /*
  1778. * 0x7f, Vsmps3Sel2
  1779. * NOTE! PRCMU register
  1780. */
  1781. REG_INIT(AB9540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
  1782. /*
  1783. * 0x0f, Vaux1Sel
  1784. */
  1785. REG_INIT(AB9540_VAUX1SEL, 0x04, 0x1f, 0x0f),
  1786. /*
  1787. * 0x0f, Vaux2Sel
  1788. */
  1789. REG_INIT(AB9540_VAUX2SEL, 0x04, 0x20, 0x0f),
  1790. /*
  1791. * 0x07, Vaux3Sel
  1792. * 0x30, Vrf1Sel
  1793. */
  1794. REG_INIT(AB9540_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
  1795. /*
  1796. * 0x01, VextSupply12LP
  1797. */
  1798. REG_INIT(AB9540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
  1799. /*
  1800. * 0x03, Vaux4RequestCtrl
  1801. */
  1802. REG_INIT(AB9540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
  1803. /*
  1804. * 0x03, Vaux4Regu
  1805. */
  1806. REG_INIT(AB9540_VAUX4REGU, 0x04, 0x2e, 0x03),
  1807. /*
  1808. * 0x08, Vaux4Sel
  1809. */
  1810. REG_INIT(AB9540_VAUX4SEL, 0x04, 0x2f, 0x0f),
  1811. /*
  1812. * 0x01, VpllDisch
  1813. * 0x02, Vrf1Disch
  1814. * 0x04, Vaux1Disch
  1815. * 0x08, Vaux2Disch
  1816. * 0x10, Vaux3Disch
  1817. * 0x20, Vintcore12Disch
  1818. * 0x40, VTVoutDisch
  1819. * 0x80, VaudioDisch
  1820. */
  1821. REG_INIT(AB9540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
  1822. /*
  1823. * 0x01, VsimDisch
  1824. * 0x02, VanaDisch
  1825. * 0x04, VdmicPullDownEna
  1826. * 0x08, VpllPullDownEna
  1827. * 0x10, VdmicDisch
  1828. */
  1829. REG_INIT(AB9540_REGUCTRLDISCH2, 0x04, 0x44, 0x1f),
  1830. /*
  1831. * 0x01, Vaux4Disch
  1832. */
  1833. REG_INIT(AB9540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
  1834. };
  1835. static int ab8500_regulator_init_registers(struct platform_device *pdev,
  1836. struct ab8500_reg_init *reg_init,
  1837. int id, int mask, int value)
  1838. {
  1839. int err;
  1840. BUG_ON(value & ~mask);
  1841. BUG_ON(mask & ~reg_init[id].mask);
  1842. /* initialize register */
  1843. err = abx500_mask_and_set_register_interruptible(
  1844. &pdev->dev,
  1845. reg_init[id].bank,
  1846. reg_init[id].addr,
  1847. mask, value);
  1848. if (err < 0) {
  1849. dev_err(&pdev->dev,
  1850. "Failed to initialize 0x%02x, 0x%02x.\n",
  1851. reg_init[id].bank,
  1852. reg_init[id].addr);
  1853. return err;
  1854. }
  1855. dev_vdbg(&pdev->dev,
  1856. " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
  1857. reg_init[id].bank,
  1858. reg_init[id].addr,
  1859. mask, value);
  1860. return 0;
  1861. }
  1862. static int ab8500_regulator_register(struct platform_device *pdev,
  1863. struct regulator_init_data *init_data,
  1864. struct ab8500_regulator_info *regulator_info,
  1865. int id, struct device_node *np)
  1866. {
  1867. struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
  1868. struct ab8500_regulator_info *info = NULL;
  1869. struct regulator_config config = { };
  1870. int err;
  1871. /* assign per-regulator data */
  1872. info = &regulator_info[id];
  1873. info->dev = &pdev->dev;
  1874. config.dev = &pdev->dev;
  1875. config.init_data = init_data;
  1876. config.driver_data = info;
  1877. config.of_node = np;
  1878. /* fix for hardware before ab8500v2.0 */
  1879. if (is_ab8500_1p1_or_earlier(ab8500)) {
  1880. if (info->desc.id == AB8500_LDO_AUX3) {
  1881. info->desc.n_voltages =
  1882. ARRAY_SIZE(ldo_vauxn_voltages);
  1883. info->desc.volt_table = ldo_vauxn_voltages;
  1884. info->voltage_mask = 0xf;
  1885. }
  1886. }
  1887. /* register regulator with framework */
  1888. info->regulator = regulator_register(&info->desc, &config);
  1889. if (IS_ERR(info->regulator)) {
  1890. err = PTR_ERR(info->regulator);
  1891. dev_err(&pdev->dev, "failed to register regulator %s\n",
  1892. info->desc.name);
  1893. /* when we fail, un-register all earlier regulators */
  1894. while (--id >= 0) {
  1895. info = &regulator_info[id];
  1896. regulator_unregister(info->regulator);
  1897. }
  1898. return err;
  1899. }
  1900. return 0;
  1901. }
  1902. static struct of_regulator_match ab8500_regulator_match[] = {
  1903. { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, },
  1904. { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, },
  1905. { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8500_LDO_AUX3, },
  1906. { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8500_LDO_INTCORE, },
  1907. { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8500_LDO_TVOUT, },
  1908. { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8500_LDO_AUDIO, },
  1909. { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8500_LDO_ANAMIC1, },
  1910. { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8500_LDO_ANAMIC2, },
  1911. { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8500_LDO_DMIC, },
  1912. { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, },
  1913. };
  1914. static struct of_regulator_match ab8505_regulator_match[] = {
  1915. { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8505_LDO_AUX1, },
  1916. { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8505_LDO_AUX2, },
  1917. { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8505_LDO_AUX3, },
  1918. { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8505_LDO_AUX4, },
  1919. { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8505_LDO_AUX5, },
  1920. { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8505_LDO_AUX6, },
  1921. { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8505_LDO_INTCORE, },
  1922. { .name = "ab8500_ldo_adc", .driver_data = (void *) AB8505_LDO_ADC, },
  1923. { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8505_LDO_AUDIO, },
  1924. { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8505_LDO_ANAMIC1, },
  1925. { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8505_LDO_ANAMIC2, },
  1926. { .name = "ab8500_ldo_aux8", .driver_data = (void *) AB8505_LDO_AUX8, },
  1927. { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8505_LDO_ANA, },
  1928. };
  1929. static struct of_regulator_match ab9540_regulator_match[] = {
  1930. { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB9540_LDO_AUX1, },
  1931. { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB9540_LDO_AUX2, },
  1932. { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB9540_LDO_AUX3, },
  1933. { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB9540_LDO_AUX4, },
  1934. { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB9540_LDO_INTCORE, },
  1935. { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB9540_LDO_TVOUT, },
  1936. { .name = "ab8500_ldo_audio", .driver_data = (void *) AB9540_LDO_AUDIO, },
  1937. { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB9540_LDO_ANAMIC1, },
  1938. { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB9540_LDO_ANAMIC2, },
  1939. { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB9540_LDO_DMIC, },
  1940. { .name = "ab8500_ldo_ana", .driver_data = (void *) AB9540_LDO_ANA, },
  1941. };
  1942. static int
  1943. ab8500_regulator_of_probe(struct platform_device *pdev,
  1944. struct ab8500_regulator_info *regulator_info,
  1945. int regulator_info_size,
  1946. struct of_regulator_match *match,
  1947. struct device_node *np)
  1948. {
  1949. int err, i;
  1950. for (i = 0; i < regulator_info_size; i++) {
  1951. err = ab8500_regulator_register(
  1952. pdev, match[i].init_data, regulator_info,
  1953. i, match[i].of_node);
  1954. if (err)
  1955. return err;
  1956. }
  1957. return 0;
  1958. }
  1959. static int ab8500_regulator_probe(struct platform_device *pdev)
  1960. {
  1961. struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
  1962. struct device_node *np = pdev->dev.of_node;
  1963. struct of_regulator_match *match;
  1964. struct ab8500_platform_data *ppdata;
  1965. struct ab8500_regulator_platform_data *pdata;
  1966. int i, err;
  1967. struct ab8500_regulator_info *regulator_info;
  1968. int regulator_info_size;
  1969. struct ab8500_reg_init *reg_init;
  1970. int reg_init_size;
  1971. if (is_ab9540(ab8500)) {
  1972. regulator_info = ab9540_regulator_info;
  1973. regulator_info_size = ARRAY_SIZE(ab9540_regulator_info);
  1974. reg_init = ab9540_reg_init;
  1975. reg_init_size = AB9540_NUM_REGULATOR_REGISTERS;
  1976. match = ab9540_regulator_match;
  1977. match_size = ARRAY_SIZE(ab9540_regulator_match)
  1978. } else if (is_ab8505(ab8500)) {
  1979. regulator_info = ab8505_regulator_info;
  1980. regulator_info_size = ARRAY_SIZE(ab8505_regulator_info);
  1981. reg_init = ab8505_reg_init;
  1982. reg_init_size = AB8505_NUM_REGULATOR_REGISTERS;
  1983. } else {
  1984. regulator_info = ab8500_regulator_info;
  1985. regulator_info_size = ARRAY_SIZE(ab8500_regulator_info);
  1986. reg_init = ab8500_reg_init;
  1987. reg_init_size = AB8500_NUM_REGULATOR_REGISTERS;
  1988. match = ab8500_regulator_match;
  1989. match_size = ARRAY_SIZE(ab8500_regulator_match)
  1990. }
  1991. if (np) {
  1992. err = of_regulator_match(&pdev->dev, np, match, match_size);
  1993. if (err < 0) {
  1994. dev_err(&pdev->dev,
  1995. "Error parsing regulator init data: %d\n", err);
  1996. return err;
  1997. }
  1998. err = ab8500_regulator_of_probe(pdev, regulator_info,
  1999. regulator_info_size, match, np);
  2000. return err;
  2001. }
  2002. if (!ab8500) {
  2003. dev_err(&pdev->dev, "null mfd parent\n");
  2004. return -EINVAL;
  2005. }
  2006. ppdata = dev_get_platdata(ab8500->dev);
  2007. if (!ppdata) {
  2008. dev_err(&pdev->dev, "null parent pdata\n");
  2009. return -EINVAL;
  2010. }
  2011. pdata = ppdata->regulator;
  2012. if (!pdata) {
  2013. dev_err(&pdev->dev, "null pdata\n");
  2014. return -EINVAL;
  2015. }
  2016. /* make sure the platform data has the correct size */
  2017. if (pdata->num_regulator != regulator_info_size) {
  2018. dev_err(&pdev->dev, "Configuration error: size mismatch.\n");
  2019. return -EINVAL;
  2020. }
  2021. /* initialize debug (initial state is recorded with this call) */
  2022. err = ab8500_regulator_debug_init(pdev);
  2023. if (err)
  2024. return err;
  2025. /* initialize registers */
  2026. for (i = 0; i < pdata->num_reg_init; i++) {
  2027. int id, mask, value;
  2028. id = pdata->reg_init[i].id;
  2029. mask = pdata->reg_init[i].mask;
  2030. value = pdata->reg_init[i].value;
  2031. /* check for configuration errors */
  2032. BUG_ON(id >= AB8500_NUM_REGULATOR_REGISTERS);
  2033. err = ab8500_regulator_init_registers(pdev, reg_init, id, mask, value);
  2034. if (err < 0)
  2035. return err;
  2036. }
  2037. /* register external regulators (before Vaux1, 2 and 3) */
  2038. err = ab8500_ext_regulator_init(pdev);
  2039. if (err)
  2040. return err;
  2041. /* register all regulators */
  2042. for (i = 0; i < regulator_info_size; i++) {
  2043. err = ab8500_regulator_register(pdev, &pdata->regulator[i],
  2044. regulator_info, i, NULL);
  2045. if (err < 0)
  2046. return err;
  2047. }
  2048. return 0;
  2049. }
  2050. static int ab8500_regulator_remove(struct platform_device *pdev)
  2051. {
  2052. int i, err;
  2053. struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
  2054. struct ab8500_regulator_info *regulator_info;
  2055. int regulator_info_size;
  2056. if (is_ab9540(ab8500)) {
  2057. regulator_info = ab9540_regulator_info;
  2058. regulator_info_size = ARRAY_SIZE(ab9540_regulator_info);
  2059. } else if (is_ab8505(ab8500)) {
  2060. regulator_info = ab8505_regulator_info;
  2061. regulator_info_size = ARRAY_SIZE(ab8505_regulator_info);
  2062. } else {
  2063. regulator_info = ab8500_regulator_info;
  2064. regulator_info_size = ARRAY_SIZE(ab8500_regulator_info);
  2065. }
  2066. for (i = 0; i < regulator_info_size; i++) {
  2067. struct ab8500_regulator_info *info = NULL;
  2068. info = &regulator_info[i];
  2069. dev_vdbg(rdev_get_dev(info->regulator),
  2070. "%s-remove\n", info->desc.name);
  2071. regulator_unregister(info->regulator);
  2072. }
  2073. /* remove external regulators (after Vaux1, 2 and 3) */
  2074. err = ab8500_ext_regulator_exit(pdev);
  2075. if (err)
  2076. return err;
  2077. /* remove regulator debug */
  2078. err = ab8500_regulator_debug_exit(pdev);
  2079. if (err)
  2080. return err;
  2081. return 0;
  2082. }
  2083. static struct platform_driver ab8500_regulator_driver = {
  2084. .probe = ab8500_regulator_probe,
  2085. .remove = ab8500_regulator_remove,
  2086. .driver = {
  2087. .name = "ab8500-regulator",
  2088. .owner = THIS_MODULE,
  2089. },
  2090. };
  2091. static int __init ab8500_regulator_init(void)
  2092. {
  2093. int ret;
  2094. ret = platform_driver_register(&ab8500_regulator_driver);
  2095. if (ret != 0)
  2096. pr_err("Failed to register ab8500 regulator: %d\n", ret);
  2097. return ret;
  2098. }
  2099. subsys_initcall(ab8500_regulator_init);
  2100. static void __exit ab8500_regulator_exit(void)
  2101. {
  2102. platform_driver_unregister(&ab8500_regulator_driver);
  2103. }
  2104. module_exit(ab8500_regulator_exit);
  2105. MODULE_LICENSE("GPL v2");
  2106. MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
  2107. MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
  2108. MODULE_AUTHOR("Daniel Willerud <daniel.willerud@stericsson.com>");
  2109. MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC");
  2110. MODULE_ALIAS("platform:ab8500-regulator");