ab8500.c 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870
  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 unsigned 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_vaux3_ab8540_voltages[] = {
  106. 1200000,
  107. 1500000,
  108. 1800000,
  109. 2100000,
  110. 2500000,
  111. 2750000,
  112. 2790000,
  113. 2910000,
  114. 3050000,
  115. };
  116. static const unsigned int ldo_vintcore_voltages[] = {
  117. 1200000,
  118. 1225000,
  119. 1250000,
  120. 1275000,
  121. 1300000,
  122. 1325000,
  123. 1350000,
  124. };
  125. static const unsigned int ldo_sdio_voltages[] = {
  126. 1160000,
  127. 1050000,
  128. 1100000,
  129. 1500000,
  130. 1800000,
  131. 2200000,
  132. 2910000,
  133. 3050000,
  134. };
  135. static const unsigned int fixed_1200000_voltage[] = {
  136. 1200000,
  137. };
  138. static const unsigned int fixed_1800000_voltage[] = {
  139. 1800000,
  140. };
  141. static const unsigned int fixed_2000000_voltage[] = {
  142. 2000000,
  143. };
  144. static const unsigned int fixed_2050000_voltage[] = {
  145. 2050000,
  146. };
  147. static const unsigned int fixed_3300000_voltage[] = {
  148. 3300000,
  149. };
  150. static int ab8500_regulator_enable(struct regulator_dev *rdev)
  151. {
  152. int ret;
  153. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  154. if (info == NULL) {
  155. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  156. return -EINVAL;
  157. }
  158. ret = abx500_mask_and_set_register_interruptible(info->dev,
  159. info->update_bank, info->update_reg,
  160. info->update_mask, info->update_val);
  161. if (ret < 0) {
  162. dev_err(rdev_get_dev(rdev),
  163. "couldn't set enable bits for regulator\n");
  164. return ret;
  165. }
  166. info->is_enabled = true;
  167. dev_vdbg(rdev_get_dev(rdev),
  168. "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
  169. info->desc.name, info->update_bank, info->update_reg,
  170. info->update_mask, info->update_val);
  171. return ret;
  172. }
  173. static int ab8500_regulator_disable(struct regulator_dev *rdev)
  174. {
  175. int ret;
  176. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  177. if (info == NULL) {
  178. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  179. return -EINVAL;
  180. }
  181. ret = abx500_mask_and_set_register_interruptible(info->dev,
  182. info->update_bank, info->update_reg,
  183. info->update_mask, 0x0);
  184. if (ret < 0) {
  185. dev_err(rdev_get_dev(rdev),
  186. "couldn't set disable bits for regulator\n");
  187. return ret;
  188. }
  189. info->is_enabled = false;
  190. dev_vdbg(rdev_get_dev(rdev),
  191. "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
  192. info->desc.name, info->update_bank, info->update_reg,
  193. info->update_mask, 0x0);
  194. return ret;
  195. }
  196. static unsigned int ab8500_regulator_get_optimum_mode(
  197. struct regulator_dev *rdev, int input_uV,
  198. int output_uV, int load_uA)
  199. {
  200. unsigned int mode;
  201. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  202. if (info == NULL) {
  203. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  204. return -EINVAL;
  205. }
  206. if (load_uA <= info->load_lp_uA)
  207. mode = REGULATOR_MODE_IDLE;
  208. else
  209. mode = REGULATOR_MODE_NORMAL;
  210. return mode;
  211. }
  212. static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
  213. unsigned int mode)
  214. {
  215. int ret;
  216. u8 update_val;
  217. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  218. if (info == NULL) {
  219. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  220. return -EINVAL;
  221. }
  222. switch (mode) {
  223. case REGULATOR_MODE_NORMAL:
  224. update_val = info->update_val_normal;
  225. break;
  226. case REGULATOR_MODE_IDLE:
  227. update_val = info->update_val_idle;
  228. break;
  229. default:
  230. return -EINVAL;
  231. }
  232. /* ab8500 regulators share mode and enable in the same register bits.
  233. off = 0b00
  234. low power mode= 0b11
  235. full powermode = 0b01
  236. (HW control mode = 0b10)
  237. Thus we don't write to the register when regulator is disabled.
  238. */
  239. if (info->is_enabled) {
  240. ret = abx500_mask_and_set_register_interruptible(info->dev,
  241. info->update_bank, info->update_reg,
  242. info->update_mask, update_val);
  243. if (ret < 0) {
  244. dev_err(rdev_get_dev(rdev),
  245. "couldn't set regulator mode\n");
  246. return ret;
  247. }
  248. dev_vdbg(rdev_get_dev(rdev),
  249. "%s-set_mode (bank, reg, mask, value): "
  250. "0x%x, 0x%x, 0x%x, 0x%x\n",
  251. info->desc.name, info->update_bank, info->update_reg,
  252. info->update_mask, update_val);
  253. }
  254. info->update_val = update_val;
  255. return 0;
  256. }
  257. static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
  258. {
  259. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  260. int ret;
  261. if (info == NULL) {
  262. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  263. return -EINVAL;
  264. }
  265. if (info->update_val == info->update_val_normal)
  266. ret = REGULATOR_MODE_NORMAL;
  267. else if (info->update_val == info->update_val_idle)
  268. ret = REGULATOR_MODE_IDLE;
  269. else
  270. ret = -EINVAL;
  271. return ret;
  272. }
  273. static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
  274. {
  275. int ret;
  276. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  277. u8 regval;
  278. if (info == NULL) {
  279. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  280. return -EINVAL;
  281. }
  282. ret = abx500_get_register_interruptible(info->dev,
  283. info->update_bank, info->update_reg, &regval);
  284. if (ret < 0) {
  285. dev_err(rdev_get_dev(rdev),
  286. "couldn't read 0x%x register\n", info->update_reg);
  287. return ret;
  288. }
  289. dev_vdbg(rdev_get_dev(rdev),
  290. "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
  291. " 0x%x\n",
  292. info->desc.name, info->update_bank, info->update_reg,
  293. info->update_mask, regval);
  294. if (regval & info->update_mask)
  295. info->is_enabled = true;
  296. else
  297. info->is_enabled = false;
  298. return info->is_enabled;
  299. }
  300. static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
  301. {
  302. int ret, val;
  303. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  304. u8 regval;
  305. if (info == NULL) {
  306. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  307. return -EINVAL;
  308. }
  309. ret = abx500_get_register_interruptible(info->dev,
  310. info->voltage_bank, info->voltage_reg, &regval);
  311. if (ret < 0) {
  312. dev_err(rdev_get_dev(rdev),
  313. "couldn't read voltage reg for regulator\n");
  314. return ret;
  315. }
  316. dev_vdbg(rdev_get_dev(rdev),
  317. "%s-get_voltage (bank, reg, mask, shift, value): "
  318. "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
  319. info->desc.name, info->voltage_bank,
  320. info->voltage_reg, info->voltage_mask,
  321. info->voltage_shift, regval);
  322. val = regval & info->voltage_mask;
  323. return val >> info->voltage_shift;
  324. }
  325. static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
  326. unsigned selector)
  327. {
  328. int ret;
  329. struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
  330. u8 regval;
  331. if (info == NULL) {
  332. dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
  333. return -EINVAL;
  334. }
  335. /* set the registers for the request */
  336. regval = (u8)selector << info->voltage_shift;
  337. ret = abx500_mask_and_set_register_interruptible(info->dev,
  338. info->voltage_bank, info->voltage_reg,
  339. info->voltage_mask, regval);
  340. if (ret < 0)
  341. dev_err(rdev_get_dev(rdev),
  342. "couldn't set voltage reg for regulator\n");
  343. dev_vdbg(rdev_get_dev(rdev),
  344. "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
  345. " 0x%x\n",
  346. info->desc.name, info->voltage_bank, info->voltage_reg,
  347. info->voltage_mask, regval);
  348. return ret;
  349. }
  350. static struct regulator_ops ab8500_regulator_volt_mode_ops = {
  351. .enable = ab8500_regulator_enable,
  352. .disable = ab8500_regulator_disable,
  353. .is_enabled = ab8500_regulator_is_enabled,
  354. .get_optimum_mode = ab8500_regulator_get_optimum_mode,
  355. .set_mode = ab8500_regulator_set_mode,
  356. .get_mode = ab8500_regulator_get_mode,
  357. .get_voltage_sel = ab8500_regulator_get_voltage_sel,
  358. .set_voltage_sel = ab8500_regulator_set_voltage_sel,
  359. .list_voltage = regulator_list_voltage_table,
  360. };
  361. static struct regulator_ops ab8500_regulator_mode_ops = {
  362. .enable = ab8500_regulator_enable,
  363. .disable = ab8500_regulator_disable,
  364. .is_enabled = ab8500_regulator_is_enabled,
  365. .get_optimum_mode = ab8500_regulator_get_optimum_mode,
  366. .set_mode = ab8500_regulator_set_mode,
  367. .get_mode = ab8500_regulator_get_mode,
  368. .list_voltage = regulator_list_voltage_linear,
  369. };
  370. static struct regulator_ops ab8500_regulator_ops = {
  371. .enable = ab8500_regulator_enable,
  372. .disable = ab8500_regulator_disable,
  373. .is_enabled = ab8500_regulator_is_enabled,
  374. .list_voltage = regulator_list_voltage_linear,
  375. };
  376. /* AB8500 regulator information */
  377. static struct ab8500_regulator_info
  378. ab8500_regulator_info[AB8500_NUM_REGULATORS] = {
  379. /*
  380. * Variable Voltage Regulators
  381. * name, min mV, max mV,
  382. * update bank, reg, mask, enable val
  383. * volt bank, reg, mask
  384. */
  385. [AB8500_LDO_AUX1] = {
  386. .desc = {
  387. .name = "LDO-AUX1",
  388. .ops = &ab8500_regulator_volt_mode_ops,
  389. .type = REGULATOR_VOLTAGE,
  390. .id = AB8500_LDO_AUX1,
  391. .owner = THIS_MODULE,
  392. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  393. .volt_table = ldo_vauxn_voltages,
  394. .enable_time = 200,
  395. },
  396. .load_lp_uA = 5000,
  397. .update_bank = 0x04,
  398. .update_reg = 0x09,
  399. .update_mask = 0x03,
  400. .update_val = 0x01,
  401. .update_val_idle = 0x03,
  402. .update_val_normal = 0x01,
  403. .voltage_bank = 0x04,
  404. .voltage_reg = 0x1f,
  405. .voltage_mask = 0x0f,
  406. },
  407. [AB8500_LDO_AUX2] = {
  408. .desc = {
  409. .name = "LDO-AUX2",
  410. .ops = &ab8500_regulator_volt_mode_ops,
  411. .type = REGULATOR_VOLTAGE,
  412. .id = AB8500_LDO_AUX2,
  413. .owner = THIS_MODULE,
  414. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  415. .volt_table = ldo_vauxn_voltages,
  416. .enable_time = 200,
  417. },
  418. .load_lp_uA = 5000,
  419. .update_bank = 0x04,
  420. .update_reg = 0x09,
  421. .update_mask = 0x0c,
  422. .update_val = 0x04,
  423. .update_val_idle = 0x0c,
  424. .update_val_normal = 0x04,
  425. .voltage_bank = 0x04,
  426. .voltage_reg = 0x20,
  427. .voltage_mask = 0x0f,
  428. },
  429. [AB8500_LDO_AUX3] = {
  430. .desc = {
  431. .name = "LDO-AUX3",
  432. .ops = &ab8500_regulator_volt_mode_ops,
  433. .type = REGULATOR_VOLTAGE,
  434. .id = AB8500_LDO_AUX3,
  435. .owner = THIS_MODULE,
  436. .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
  437. .volt_table = ldo_vaux3_voltages,
  438. .enable_time = 450,
  439. },
  440. .load_lp_uA = 5000,
  441. .update_bank = 0x04,
  442. .update_reg = 0x0a,
  443. .update_mask = 0x03,
  444. .update_val = 0x01,
  445. .update_val_idle = 0x03,
  446. .update_val_normal = 0x01,
  447. .voltage_bank = 0x04,
  448. .voltage_reg = 0x21,
  449. .voltage_mask = 0x07,
  450. },
  451. [AB8500_LDO_INTCORE] = {
  452. .desc = {
  453. .name = "LDO-INTCORE",
  454. .ops = &ab8500_regulator_volt_mode_ops,
  455. .type = REGULATOR_VOLTAGE,
  456. .id = AB8500_LDO_INTCORE,
  457. .owner = THIS_MODULE,
  458. .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
  459. .volt_table = ldo_vintcore_voltages,
  460. .enable_time = 750,
  461. },
  462. .load_lp_uA = 5000,
  463. .update_bank = 0x03,
  464. .update_reg = 0x80,
  465. .update_mask = 0x44,
  466. .update_val = 0x44,
  467. .update_val_idle = 0x44,
  468. .update_val_normal = 0x04,
  469. .voltage_bank = 0x03,
  470. .voltage_reg = 0x80,
  471. .voltage_mask = 0x38,
  472. .voltage_shift = 3,
  473. },
  474. /*
  475. * Fixed Voltage Regulators
  476. * name, fixed mV,
  477. * update bank, reg, mask, enable val
  478. */
  479. [AB8500_LDO_TVOUT] = {
  480. .desc = {
  481. .name = "LDO-TVOUT",
  482. .ops = &ab8500_regulator_mode_ops,
  483. .type = REGULATOR_VOLTAGE,
  484. .id = AB8500_LDO_TVOUT,
  485. .owner = THIS_MODULE,
  486. .n_voltages = 1,
  487. .volt_table = fixed_2000000_voltage,
  488. .enable_time = 500,
  489. },
  490. .load_lp_uA = 1000,
  491. .update_bank = 0x03,
  492. .update_reg = 0x80,
  493. .update_mask = 0x82,
  494. .update_val = 0x02,
  495. .update_val_idle = 0x82,
  496. .update_val_normal = 0x02,
  497. },
  498. [AB8500_LDO_AUDIO] = {
  499. .desc = {
  500. .name = "LDO-AUDIO",
  501. .ops = &ab8500_regulator_ops,
  502. .type = REGULATOR_VOLTAGE,
  503. .id = AB8500_LDO_AUDIO,
  504. .owner = THIS_MODULE,
  505. .n_voltages = 1,
  506. .enable_time = 140,
  507. .volt_table = fixed_2000000_voltage,
  508. },
  509. .update_bank = 0x03,
  510. .update_reg = 0x83,
  511. .update_mask = 0x02,
  512. .update_val = 0x02,
  513. },
  514. [AB8500_LDO_ANAMIC1] = {
  515. .desc = {
  516. .name = "LDO-ANAMIC1",
  517. .ops = &ab8500_regulator_ops,
  518. .type = REGULATOR_VOLTAGE,
  519. .id = AB8500_LDO_ANAMIC1,
  520. .owner = THIS_MODULE,
  521. .n_voltages = 1,
  522. .enable_time = 500,
  523. .volt_table = fixed_2050000_voltage,
  524. },
  525. .update_bank = 0x03,
  526. .update_reg = 0x83,
  527. .update_mask = 0x08,
  528. .update_val = 0x08,
  529. },
  530. [AB8500_LDO_ANAMIC2] = {
  531. .desc = {
  532. .name = "LDO-ANAMIC2",
  533. .ops = &ab8500_regulator_ops,
  534. .type = REGULATOR_VOLTAGE,
  535. .id = AB8500_LDO_ANAMIC2,
  536. .owner = THIS_MODULE,
  537. .n_voltages = 1,
  538. .enable_time = 500,
  539. .volt_table = fixed_2050000_voltage,
  540. },
  541. .update_bank = 0x03,
  542. .update_reg = 0x83,
  543. .update_mask = 0x10,
  544. .update_val = 0x10,
  545. },
  546. [AB8500_LDO_DMIC] = {
  547. .desc = {
  548. .name = "LDO-DMIC",
  549. .ops = &ab8500_regulator_ops,
  550. .type = REGULATOR_VOLTAGE,
  551. .id = AB8500_LDO_DMIC,
  552. .owner = THIS_MODULE,
  553. .n_voltages = 1,
  554. .enable_time = 420,
  555. .volt_table = fixed_1800000_voltage,
  556. },
  557. .update_bank = 0x03,
  558. .update_reg = 0x83,
  559. .update_mask = 0x04,
  560. .update_val = 0x04,
  561. },
  562. /*
  563. * Regulators with fixed voltage and normal/idle modes
  564. */
  565. [AB8500_LDO_ANA] = {
  566. .desc = {
  567. .name = "LDO-ANA",
  568. .ops = &ab8500_regulator_mode_ops,
  569. .type = REGULATOR_VOLTAGE,
  570. .id = AB8500_LDO_ANA,
  571. .owner = THIS_MODULE,
  572. .n_voltages = 1,
  573. .enable_time = 140,
  574. .volt_table = fixed_1200000_voltage,
  575. },
  576. .load_lp_uA = 1000,
  577. .update_bank = 0x04,
  578. .update_reg = 0x06,
  579. .update_mask = 0x0c,
  580. .update_val = 0x04,
  581. .update_val_idle = 0x0c,
  582. .update_val_normal = 0x04,
  583. },
  584. };
  585. /* AB8505 regulator information */
  586. static struct ab8500_regulator_info
  587. ab8505_regulator_info[AB8505_NUM_REGULATORS] = {
  588. /*
  589. * Variable Voltage Regulators
  590. * name, min mV, max mV,
  591. * update bank, reg, mask, enable val
  592. * volt bank, reg, mask, table, table length
  593. */
  594. [AB8505_LDO_AUX1] = {
  595. .desc = {
  596. .name = "LDO-AUX1",
  597. .ops = &ab8500_regulator_volt_mode_ops,
  598. .type = REGULATOR_VOLTAGE,
  599. .id = AB8505_LDO_AUX1,
  600. .owner = THIS_MODULE,
  601. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  602. .volt_table = ldo_vauxn_voltages,
  603. },
  604. .load_lp_uA = 5000,
  605. .update_bank = 0x04,
  606. .update_reg = 0x09,
  607. .update_mask = 0x03,
  608. .update_val = 0x01,
  609. .update_val_idle = 0x03,
  610. .update_val_normal = 0x01,
  611. .voltage_bank = 0x04,
  612. .voltage_reg = 0x1f,
  613. .voltage_mask = 0x0f,
  614. },
  615. [AB8505_LDO_AUX2] = {
  616. .desc = {
  617. .name = "LDO-AUX2",
  618. .ops = &ab8500_regulator_volt_mode_ops,
  619. .type = REGULATOR_VOLTAGE,
  620. .id = AB8505_LDO_AUX2,
  621. .owner = THIS_MODULE,
  622. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  623. .volt_table = ldo_vauxn_voltages,
  624. },
  625. .load_lp_uA = 5000,
  626. .update_bank = 0x04,
  627. .update_reg = 0x09,
  628. .update_mask = 0x0c,
  629. .update_val = 0x04,
  630. .update_val_idle = 0x0c,
  631. .update_val_normal = 0x04,
  632. .voltage_bank = 0x04,
  633. .voltage_reg = 0x20,
  634. .voltage_mask = 0x0f,
  635. },
  636. [AB8505_LDO_AUX3] = {
  637. .desc = {
  638. .name = "LDO-AUX3",
  639. .ops = &ab8500_regulator_volt_mode_ops,
  640. .type = REGULATOR_VOLTAGE,
  641. .id = AB8505_LDO_AUX3,
  642. .owner = THIS_MODULE,
  643. .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
  644. .volt_table = ldo_vaux3_voltages,
  645. },
  646. .load_lp_uA = 5000,
  647. .update_bank = 0x04,
  648. .update_reg = 0x0a,
  649. .update_mask = 0x03,
  650. .update_val = 0x01,
  651. .update_val_idle = 0x03,
  652. .update_val_normal = 0x01,
  653. .voltage_bank = 0x04,
  654. .voltage_reg = 0x21,
  655. .voltage_mask = 0x07,
  656. },
  657. [AB8505_LDO_AUX4] = {
  658. .desc = {
  659. .name = "LDO-AUX4",
  660. .ops = &ab8500_regulator_volt_mode_ops,
  661. .type = REGULATOR_VOLTAGE,
  662. .id = AB8505_LDO_AUX4,
  663. .owner = THIS_MODULE,
  664. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  665. .volt_table = ldo_vauxn_voltages,
  666. },
  667. .load_lp_uA = 5000,
  668. /* values for Vaux4Regu register */
  669. .update_bank = 0x04,
  670. .update_reg = 0x2e,
  671. .update_mask = 0x03,
  672. .update_val = 0x01,
  673. .update_val_idle = 0x03,
  674. .update_val_normal = 0x01,
  675. /* values for Vaux4SEL register */
  676. .voltage_bank = 0x04,
  677. .voltage_reg = 0x2f,
  678. .voltage_mask = 0x0f,
  679. },
  680. [AB8505_LDO_AUX5] = {
  681. .desc = {
  682. .name = "LDO-AUX5",
  683. .ops = &ab8500_regulator_volt_mode_ops,
  684. .type = REGULATOR_VOLTAGE,
  685. .id = AB8505_LDO_AUX5,
  686. .owner = THIS_MODULE,
  687. .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
  688. .volt_table = ldo_vaux56_voltages,
  689. },
  690. .load_lp_uA = 2000,
  691. /* values for CtrlVaux5 register */
  692. .update_bank = 0x01,
  693. .update_reg = 0x55,
  694. .update_mask = 0x18,
  695. .update_val = 0x10,
  696. .update_val_idle = 0x18,
  697. .update_val_normal = 0x10,
  698. .voltage_bank = 0x01,
  699. .voltage_reg = 0x55,
  700. .voltage_mask = 0x07,
  701. },
  702. [AB8505_LDO_AUX6] = {
  703. .desc = {
  704. .name = "LDO-AUX6",
  705. .ops = &ab8500_regulator_volt_mode_ops,
  706. .type = REGULATOR_VOLTAGE,
  707. .id = AB8505_LDO_AUX6,
  708. .owner = THIS_MODULE,
  709. .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
  710. .volt_table = ldo_vaux56_voltages,
  711. },
  712. .load_lp_uA = 2000,
  713. /* values for CtrlVaux6 register */
  714. .update_bank = 0x01,
  715. .update_reg = 0x56,
  716. .update_mask = 0x18,
  717. .update_val = 0x10,
  718. .update_val_idle = 0x18,
  719. .update_val_normal = 0x10,
  720. .voltage_bank = 0x01,
  721. .voltage_reg = 0x56,
  722. .voltage_mask = 0x07,
  723. },
  724. [AB8505_LDO_INTCORE] = {
  725. .desc = {
  726. .name = "LDO-INTCORE",
  727. .ops = &ab8500_regulator_volt_mode_ops,
  728. .type = REGULATOR_VOLTAGE,
  729. .id = AB8505_LDO_INTCORE,
  730. .owner = THIS_MODULE,
  731. .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
  732. .volt_table = ldo_vintcore_voltages,
  733. },
  734. .load_lp_uA = 5000,
  735. .update_bank = 0x03,
  736. .update_reg = 0x80,
  737. .update_mask = 0x44,
  738. .update_val = 0x04,
  739. .update_val_idle = 0x44,
  740. .update_val_normal = 0x04,
  741. .voltage_bank = 0x03,
  742. .voltage_reg = 0x80,
  743. .voltage_mask = 0x38,
  744. .voltage_shift = 3,
  745. },
  746. /*
  747. * Fixed Voltage Regulators
  748. * name, fixed mV,
  749. * update bank, reg, mask, enable val
  750. */
  751. [AB8505_LDO_ADC] = {
  752. .desc = {
  753. .name = "LDO-ADC",
  754. .ops = &ab8500_regulator_mode_ops,
  755. .type = REGULATOR_VOLTAGE,
  756. .id = AB8505_LDO_ADC,
  757. .owner = THIS_MODULE,
  758. .n_voltages = 1,
  759. .volt_table = fixed_2000000_voltage,
  760. },
  761. .delay = 10000,
  762. .load_lp_uA = 1000,
  763. .update_bank = 0x03,
  764. .update_reg = 0x80,
  765. .update_mask = 0x82,
  766. .update_val = 0x02,
  767. .update_val_idle = 0x82,
  768. .update_val_normal = 0x02,
  769. },
  770. [AB8505_LDO_USB] = {
  771. .desc = {
  772. .name = "LDO-USB",
  773. .ops = &ab8500_regulator_mode_ops,
  774. .type = REGULATOR_VOLTAGE,
  775. .id = AB8505_LDO_USB,
  776. .owner = THIS_MODULE,
  777. .n_voltages = 1,
  778. .volt_table = fixed_3300000_voltage,
  779. },
  780. .update_bank = 0x03,
  781. .update_reg = 0x82,
  782. .update_mask = 0x03,
  783. .update_val = 0x01,
  784. .update_val_idle = 0x03,
  785. .update_val_normal = 0x01,
  786. },
  787. [AB8505_LDO_AUDIO] = {
  788. .desc = {
  789. .name = "LDO-AUDIO",
  790. .ops = &ab8500_regulator_ops,
  791. .type = REGULATOR_VOLTAGE,
  792. .id = AB8505_LDO_AUDIO,
  793. .owner = THIS_MODULE,
  794. .n_voltages = 1,
  795. .volt_table = fixed_2000000_voltage,
  796. },
  797. .update_bank = 0x03,
  798. .update_reg = 0x83,
  799. .update_mask = 0x02,
  800. .update_val = 0x02,
  801. },
  802. [AB8505_LDO_ANAMIC1] = {
  803. .desc = {
  804. .name = "LDO-ANAMIC1",
  805. .ops = &ab8500_regulator_ops,
  806. .type = REGULATOR_VOLTAGE,
  807. .id = AB8505_LDO_ANAMIC1,
  808. .owner = THIS_MODULE,
  809. .n_voltages = 1,
  810. .volt_table = fixed_2050000_voltage,
  811. },
  812. .update_bank = 0x03,
  813. .update_reg = 0x83,
  814. .update_mask = 0x08,
  815. .update_val = 0x08,
  816. },
  817. [AB8505_LDO_ANAMIC2] = {
  818. .desc = {
  819. .name = "LDO-ANAMIC2",
  820. .ops = &ab8500_regulator_ops,
  821. .type = REGULATOR_VOLTAGE,
  822. .id = AB8505_LDO_ANAMIC2,
  823. .owner = THIS_MODULE,
  824. .n_voltages = 1,
  825. .volt_table = fixed_2050000_voltage,
  826. },
  827. .update_bank = 0x03,
  828. .update_reg = 0x83,
  829. .update_mask = 0x10,
  830. .update_val = 0x10,
  831. },
  832. [AB8505_LDO_AUX8] = {
  833. .desc = {
  834. .name = "LDO-AUX8",
  835. .ops = &ab8500_regulator_ops,
  836. .type = REGULATOR_VOLTAGE,
  837. .id = AB8505_LDO_AUX8,
  838. .owner = THIS_MODULE,
  839. .n_voltages = 1,
  840. .volt_table = fixed_1800000_voltage,
  841. },
  842. .update_bank = 0x03,
  843. .update_reg = 0x83,
  844. .update_mask = 0x04,
  845. .update_val = 0x04,
  846. },
  847. /*
  848. * Regulators with fixed voltage and normal/idle modes
  849. */
  850. [AB8505_LDO_ANA] = {
  851. .desc = {
  852. .name = "LDO-ANA",
  853. .ops = &ab8500_regulator_mode_ops,
  854. .type = REGULATOR_VOLTAGE,
  855. .id = AB8505_LDO_ANA,
  856. .owner = THIS_MODULE,
  857. .n_voltages = 1,
  858. .volt_table = fixed_1200000_voltage,
  859. },
  860. .load_lp_uA = 1000,
  861. .update_bank = 0x04,
  862. .update_reg = 0x06,
  863. .update_mask = 0x0c,
  864. .update_val = 0x04,
  865. .update_val_idle = 0x0c,
  866. .update_val_normal = 0x04,
  867. },
  868. };
  869. /* AB9540 regulator information */
  870. static struct ab8500_regulator_info
  871. ab9540_regulator_info[AB9540_NUM_REGULATORS] = {
  872. /*
  873. * Variable Voltage Regulators
  874. * name, min mV, max mV,
  875. * update bank, reg, mask, enable val
  876. * volt bank, reg, mask, table, table length
  877. */
  878. [AB9540_LDO_AUX1] = {
  879. .desc = {
  880. .name = "LDO-AUX1",
  881. .ops = &ab8500_regulator_volt_mode_ops,
  882. .type = REGULATOR_VOLTAGE,
  883. .id = AB9540_LDO_AUX1,
  884. .owner = THIS_MODULE,
  885. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  886. .volt_table = ldo_vauxn_voltages,
  887. },
  888. .load_lp_uA = 5000,
  889. .update_bank = 0x04,
  890. .update_reg = 0x09,
  891. .update_mask = 0x03,
  892. .update_val = 0x01,
  893. .update_val_idle = 0x03,
  894. .update_val_normal = 0x01,
  895. .voltage_bank = 0x04,
  896. .voltage_reg = 0x1f,
  897. .voltage_mask = 0x0f,
  898. },
  899. [AB9540_LDO_AUX2] = {
  900. .desc = {
  901. .name = "LDO-AUX2",
  902. .ops = &ab8500_regulator_volt_mode_ops,
  903. .type = REGULATOR_VOLTAGE,
  904. .id = AB9540_LDO_AUX2,
  905. .owner = THIS_MODULE,
  906. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  907. .volt_table = ldo_vauxn_voltages,
  908. },
  909. .load_lp_uA = 5000,
  910. .update_bank = 0x04,
  911. .update_reg = 0x09,
  912. .update_mask = 0x0c,
  913. .update_val = 0x04,
  914. .update_val_idle = 0x0c,
  915. .update_val_normal = 0x04,
  916. .voltage_bank = 0x04,
  917. .voltage_reg = 0x20,
  918. .voltage_mask = 0x0f,
  919. },
  920. [AB9540_LDO_AUX3] = {
  921. .desc = {
  922. .name = "LDO-AUX3",
  923. .ops = &ab8500_regulator_volt_mode_ops,
  924. .type = REGULATOR_VOLTAGE,
  925. .id = AB9540_LDO_AUX3,
  926. .owner = THIS_MODULE,
  927. .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
  928. .volt_table = ldo_vaux3_voltages,
  929. },
  930. .load_lp_uA = 5000,
  931. .update_bank = 0x04,
  932. .update_reg = 0x0a,
  933. .update_mask = 0x03,
  934. .update_val = 0x01,
  935. .update_val_idle = 0x03,
  936. .update_val_normal = 0x01,
  937. .voltage_bank = 0x04,
  938. .voltage_reg = 0x21,
  939. .voltage_mask = 0x07,
  940. },
  941. [AB9540_LDO_AUX4] = {
  942. .desc = {
  943. .name = "LDO-AUX4",
  944. .ops = &ab8500_regulator_volt_mode_ops,
  945. .type = REGULATOR_VOLTAGE,
  946. .id = AB9540_LDO_AUX4,
  947. .owner = THIS_MODULE,
  948. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  949. .volt_table = ldo_vauxn_voltages,
  950. },
  951. .load_lp_uA = 5000,
  952. /* values for Vaux4Regu register */
  953. .update_bank = 0x04,
  954. .update_reg = 0x2e,
  955. .update_mask = 0x03,
  956. .update_val = 0x01,
  957. .update_val_idle = 0x03,
  958. .update_val_normal = 0x01,
  959. /* values for Vaux4SEL register */
  960. .voltage_bank = 0x04,
  961. .voltage_reg = 0x2f,
  962. .voltage_mask = 0x0f,
  963. },
  964. [AB9540_LDO_INTCORE] = {
  965. .desc = {
  966. .name = "LDO-INTCORE",
  967. .ops = &ab8500_regulator_volt_mode_ops,
  968. .type = REGULATOR_VOLTAGE,
  969. .id = AB9540_LDO_INTCORE,
  970. .owner = THIS_MODULE,
  971. .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
  972. .volt_table = ldo_vintcore_voltages,
  973. },
  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. .voltage_shift = 3,
  985. },
  986. /*
  987. * Fixed Voltage Regulators
  988. * name, fixed mV,
  989. * update bank, reg, mask, enable val
  990. */
  991. [AB9540_LDO_TVOUT] = {
  992. .desc = {
  993. .name = "LDO-TVOUT",
  994. .ops = &ab8500_regulator_mode_ops,
  995. .type = REGULATOR_VOLTAGE,
  996. .id = AB9540_LDO_TVOUT,
  997. .owner = THIS_MODULE,
  998. .n_voltages = 1,
  999. .volt_table = fixed_2000000_voltage,
  1000. },
  1001. .delay = 10000,
  1002. .load_lp_uA = 1000,
  1003. .update_bank = 0x03,
  1004. .update_reg = 0x80,
  1005. .update_mask = 0x82,
  1006. .update_val = 0x02,
  1007. .update_val_idle = 0x82,
  1008. .update_val_normal = 0x02,
  1009. },
  1010. [AB9540_LDO_USB] = {
  1011. .desc = {
  1012. .name = "LDO-USB",
  1013. .ops = &ab8500_regulator_ops,
  1014. .type = REGULATOR_VOLTAGE,
  1015. .id = AB9540_LDO_USB,
  1016. .owner = THIS_MODULE,
  1017. .n_voltages = 1,
  1018. .volt_table = fixed_3300000_voltage,
  1019. },
  1020. .update_bank = 0x03,
  1021. .update_reg = 0x82,
  1022. .update_mask = 0x03,
  1023. .update_val = 0x01,
  1024. .update_val_idle = 0x03,
  1025. .update_val_normal = 0x01,
  1026. },
  1027. [AB9540_LDO_AUDIO] = {
  1028. .desc = {
  1029. .name = "LDO-AUDIO",
  1030. .ops = &ab8500_regulator_ops,
  1031. .type = REGULATOR_VOLTAGE,
  1032. .id = AB9540_LDO_AUDIO,
  1033. .owner = THIS_MODULE,
  1034. .n_voltages = 1,
  1035. .volt_table = fixed_2000000_voltage,
  1036. },
  1037. .update_bank = 0x03,
  1038. .update_reg = 0x83,
  1039. .update_mask = 0x02,
  1040. .update_val = 0x02,
  1041. },
  1042. [AB9540_LDO_ANAMIC1] = {
  1043. .desc = {
  1044. .name = "LDO-ANAMIC1",
  1045. .ops = &ab8500_regulator_ops,
  1046. .type = REGULATOR_VOLTAGE,
  1047. .id = AB9540_LDO_ANAMIC1,
  1048. .owner = THIS_MODULE,
  1049. .n_voltages = 1,
  1050. .volt_table = fixed_2050000_voltage,
  1051. },
  1052. .update_bank = 0x03,
  1053. .update_reg = 0x83,
  1054. .update_mask = 0x08,
  1055. .update_val = 0x08,
  1056. },
  1057. [AB9540_LDO_ANAMIC2] = {
  1058. .desc = {
  1059. .name = "LDO-ANAMIC2",
  1060. .ops = &ab8500_regulator_ops,
  1061. .type = REGULATOR_VOLTAGE,
  1062. .id = AB9540_LDO_ANAMIC2,
  1063. .owner = THIS_MODULE,
  1064. .n_voltages = 1,
  1065. .volt_table = fixed_2050000_voltage,
  1066. },
  1067. .update_bank = 0x03,
  1068. .update_reg = 0x83,
  1069. .update_mask = 0x10,
  1070. .update_val = 0x10,
  1071. },
  1072. [AB9540_LDO_DMIC] = {
  1073. .desc = {
  1074. .name = "LDO-DMIC",
  1075. .ops = &ab8500_regulator_ops,
  1076. .type = REGULATOR_VOLTAGE,
  1077. .id = AB9540_LDO_DMIC,
  1078. .owner = THIS_MODULE,
  1079. .n_voltages = 1,
  1080. .volt_table = fixed_1800000_voltage,
  1081. },
  1082. .update_bank = 0x03,
  1083. .update_reg = 0x83,
  1084. .update_mask = 0x04,
  1085. .update_val = 0x04,
  1086. },
  1087. /*
  1088. * Regulators with fixed voltage and normal/idle modes
  1089. */
  1090. [AB9540_LDO_ANA] = {
  1091. .desc = {
  1092. .name = "LDO-ANA",
  1093. .ops = &ab8500_regulator_mode_ops,
  1094. .type = REGULATOR_VOLTAGE,
  1095. .id = AB9540_LDO_ANA,
  1096. .owner = THIS_MODULE,
  1097. .n_voltages = 1,
  1098. .volt_table = fixed_1200000_voltage,
  1099. },
  1100. .load_lp_uA = 1000,
  1101. .update_bank = 0x04,
  1102. .update_reg = 0x06,
  1103. .update_mask = 0x0c,
  1104. .update_val = 0x08,
  1105. .update_val_idle = 0x0c,
  1106. .update_val_normal = 0x08,
  1107. },
  1108. };
  1109. /* AB8540 regulator information */
  1110. static struct ab8500_regulator_info
  1111. ab8540_regulator_info[AB8540_NUM_REGULATORS] = {
  1112. /*
  1113. * Variable Voltage Regulators
  1114. * name, min mV, max mV,
  1115. * update bank, reg, mask, enable val
  1116. * volt bank, reg, mask, table, table length
  1117. */
  1118. [AB8540_LDO_AUX1] = {
  1119. .desc = {
  1120. .name = "LDO-AUX1",
  1121. .ops = &ab8500_regulator_volt_mode_ops,
  1122. .type = REGULATOR_VOLTAGE,
  1123. .id = AB8540_LDO_AUX1,
  1124. .owner = THIS_MODULE,
  1125. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  1126. .volt_table = ldo_vauxn_voltages,
  1127. },
  1128. .load_lp_uA = 5000,
  1129. .update_bank = 0x04,
  1130. .update_reg = 0x09,
  1131. .update_mask = 0x03,
  1132. .update_val = 0x01,
  1133. .update_val_idle = 0x03,
  1134. .update_val_normal = 0x01,
  1135. .voltage_bank = 0x04,
  1136. .voltage_reg = 0x1f,
  1137. .voltage_mask = 0x0f,
  1138. },
  1139. [AB8540_LDO_AUX2] = {
  1140. .desc = {
  1141. .name = "LDO-AUX2",
  1142. .ops = &ab8500_regulator_volt_mode_ops,
  1143. .type = REGULATOR_VOLTAGE,
  1144. .id = AB8540_LDO_AUX2,
  1145. .owner = THIS_MODULE,
  1146. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  1147. .volt_table = ldo_vauxn_voltages,
  1148. },
  1149. .load_lp_uA = 5000,
  1150. .update_bank = 0x04,
  1151. .update_reg = 0x09,
  1152. .update_mask = 0x0c,
  1153. .update_val = 0x04,
  1154. .update_val_idle = 0x0c,
  1155. .update_val_normal = 0x04,
  1156. .voltage_bank = 0x04,
  1157. .voltage_reg = 0x20,
  1158. .voltage_mask = 0x0f,
  1159. },
  1160. [AB8540_LDO_AUX3] = {
  1161. .desc = {
  1162. .name = "LDO-AUX3",
  1163. .ops = &ab8500_regulator_volt_mode_ops,
  1164. .type = REGULATOR_VOLTAGE,
  1165. .id = AB8540_LDO_AUX3,
  1166. .owner = THIS_MODULE,
  1167. .n_voltages = ARRAY_SIZE(ldo_vaux3_ab8540_voltages),
  1168. .volt_table = ldo_vaux3_ab8540_voltages,
  1169. },
  1170. .load_lp_uA = 5000,
  1171. .update_bank = 0x04,
  1172. .update_reg = 0x0a,
  1173. .update_mask = 0x03,
  1174. .update_val = 0x01,
  1175. .update_val_idle = 0x03,
  1176. .update_val_normal = 0x01,
  1177. .voltage_bank = 0x04,
  1178. .voltage_reg = 0x21,
  1179. .voltage_mask = 0x07,
  1180. },
  1181. [AB8540_LDO_AUX4] = {
  1182. .desc = {
  1183. .name = "LDO-AUX4",
  1184. .ops = &ab8500_regulator_volt_mode_ops,
  1185. .type = REGULATOR_VOLTAGE,
  1186. .id = AB8540_LDO_AUX4,
  1187. .owner = THIS_MODULE,
  1188. .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
  1189. .volt_table = ldo_vauxn_voltages,
  1190. },
  1191. .load_lp_uA = 5000,
  1192. /* values for Vaux4Regu register */
  1193. .update_bank = 0x04,
  1194. .update_reg = 0x2e,
  1195. .update_mask = 0x03,
  1196. .update_val = 0x01,
  1197. .update_val_idle = 0x03,
  1198. .update_val_normal = 0x01,
  1199. /* values for Vaux4SEL register */
  1200. .voltage_bank = 0x04,
  1201. .voltage_reg = 0x2f,
  1202. .voltage_mask = 0x0f,
  1203. },
  1204. [AB8540_LDO_INTCORE] = {
  1205. .desc = {
  1206. .name = "LDO-INTCORE",
  1207. .ops = &ab8500_regulator_volt_mode_ops,
  1208. .type = REGULATOR_VOLTAGE,
  1209. .id = AB8540_LDO_INTCORE,
  1210. .owner = THIS_MODULE,
  1211. .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
  1212. .volt_table = ldo_vintcore_voltages,
  1213. },
  1214. .load_lp_uA = 5000,
  1215. .update_bank = 0x03,
  1216. .update_reg = 0x80,
  1217. .update_mask = 0x44,
  1218. .update_val = 0x44,
  1219. .update_val_idle = 0x44,
  1220. .update_val_normal = 0x04,
  1221. .voltage_bank = 0x03,
  1222. .voltage_reg = 0x80,
  1223. .voltage_mask = 0x38,
  1224. .voltage_shift = 3,
  1225. },
  1226. /*
  1227. * Fixed Voltage Regulators
  1228. * name, fixed mV,
  1229. * update bank, reg, mask, enable val
  1230. */
  1231. [AB8540_LDO_TVOUT] = {
  1232. .desc = {
  1233. .name = "LDO-TVOUT",
  1234. .ops = &ab8500_regulator_mode_ops,
  1235. .type = REGULATOR_VOLTAGE,
  1236. .id = AB8540_LDO_TVOUT,
  1237. .owner = THIS_MODULE,
  1238. .n_voltages = 1,
  1239. },
  1240. .delay = 10000,
  1241. .load_lp_uA = 1000,
  1242. .update_bank = 0x03,
  1243. .update_reg = 0x80,
  1244. .update_mask = 0x82,
  1245. .update_val = 0x02,
  1246. .update_val_idle = 0x82,
  1247. .update_val_normal = 0x02,
  1248. },
  1249. [AB8540_LDO_AUDIO] = {
  1250. .desc = {
  1251. .name = "LDO-AUDIO",
  1252. .ops = &ab8500_regulator_ops,
  1253. .type = REGULATOR_VOLTAGE,
  1254. .id = AB8540_LDO_AUDIO,
  1255. .owner = THIS_MODULE,
  1256. .n_voltages = 1,
  1257. .volt_table = fixed_2000000_voltage,
  1258. },
  1259. .update_bank = 0x03,
  1260. .update_reg = 0x83,
  1261. .update_mask = 0x02,
  1262. .update_val = 0x02,
  1263. },
  1264. [AB8540_LDO_ANAMIC1] = {
  1265. .desc = {
  1266. .name = "LDO-ANAMIC1",
  1267. .ops = &ab8500_regulator_ops,
  1268. .type = REGULATOR_VOLTAGE,
  1269. .id = AB8540_LDO_ANAMIC1,
  1270. .owner = THIS_MODULE,
  1271. .n_voltages = 1,
  1272. .volt_table = fixed_2050000_voltage,
  1273. },
  1274. .update_bank = 0x03,
  1275. .update_reg = 0x83,
  1276. .update_mask = 0x08,
  1277. .update_val = 0x08,
  1278. },
  1279. [AB8540_LDO_ANAMIC2] = {
  1280. .desc = {
  1281. .name = "LDO-ANAMIC2",
  1282. .ops = &ab8500_regulator_ops,
  1283. .type = REGULATOR_VOLTAGE,
  1284. .id = AB8540_LDO_ANAMIC2,
  1285. .owner = THIS_MODULE,
  1286. .n_voltages = 1,
  1287. .volt_table = fixed_2050000_voltage,
  1288. },
  1289. .update_bank = 0x03,
  1290. .update_reg = 0x83,
  1291. .update_mask = 0x10,
  1292. .update_val = 0x10,
  1293. },
  1294. [AB8540_LDO_DMIC] = {
  1295. .desc = {
  1296. .name = "LDO-DMIC",
  1297. .ops = &ab8500_regulator_ops,
  1298. .type = REGULATOR_VOLTAGE,
  1299. .id = AB8540_LDO_DMIC,
  1300. .owner = THIS_MODULE,
  1301. .n_voltages = 1,
  1302. },
  1303. .update_bank = 0x03,
  1304. .update_reg = 0x83,
  1305. .update_mask = 0x04,
  1306. .update_val = 0x04,
  1307. },
  1308. /*
  1309. * Regulators with fixed voltage and normal/idle modes
  1310. */
  1311. [AB8540_LDO_ANA] = {
  1312. .desc = {
  1313. .name = "LDO-ANA",
  1314. .ops = &ab8500_regulator_mode_ops,
  1315. .type = REGULATOR_VOLTAGE,
  1316. .id = AB8540_LDO_ANA,
  1317. .owner = THIS_MODULE,
  1318. .n_voltages = 1,
  1319. .volt_table = fixed_1200000_voltage,
  1320. },
  1321. .load_lp_uA = 1000,
  1322. .update_bank = 0x04,
  1323. .update_reg = 0x06,
  1324. .update_mask = 0x0c,
  1325. .update_val = 0x04,
  1326. .update_val_idle = 0x0c,
  1327. .update_val_normal = 0x04,
  1328. },
  1329. [AB8540_LDO_SDIO] = {
  1330. .desc = {
  1331. .name = "LDO-SDIO",
  1332. .ops = &ab8500_regulator_volt_mode_ops,
  1333. .type = REGULATOR_VOLTAGE,
  1334. .id = AB8540_LDO_SDIO,
  1335. .owner = THIS_MODULE,
  1336. .n_voltages = ARRAY_SIZE(ldo_sdio_voltages),
  1337. .volt_table = ldo_sdio_voltages,
  1338. },
  1339. .load_lp_uA = 5000,
  1340. .update_bank = 0x03,
  1341. .update_reg = 0x88,
  1342. .update_mask = 0x30,
  1343. .update_val = 0x10,
  1344. .update_val_idle = 0x30,
  1345. .update_val_normal = 0x10,
  1346. .voltage_bank = 0x03,
  1347. .voltage_reg = 0x88,
  1348. .voltage_mask = 0x07,
  1349. },
  1350. };
  1351. struct ab8500_reg_init {
  1352. u8 bank;
  1353. u8 addr;
  1354. u8 mask;
  1355. };
  1356. #define REG_INIT(_id, _bank, _addr, _mask) \
  1357. [_id] = { \
  1358. .bank = _bank, \
  1359. .addr = _addr, \
  1360. .mask = _mask, \
  1361. }
  1362. /* AB8500 register init */
  1363. static struct ab8500_reg_init ab8500_reg_init[] = {
  1364. /*
  1365. * 0x30, VanaRequestCtrl
  1366. * 0xc0, VextSupply1RequestCtrl
  1367. */
  1368. REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xf0),
  1369. /*
  1370. * 0x03, VextSupply2RequestCtrl
  1371. * 0x0c, VextSupply3RequestCtrl
  1372. * 0x30, Vaux1RequestCtrl
  1373. * 0xc0, Vaux2RequestCtrl
  1374. */
  1375. REG_INIT(AB8500_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
  1376. /*
  1377. * 0x03, Vaux3RequestCtrl
  1378. * 0x04, SwHPReq
  1379. */
  1380. REG_INIT(AB8500_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
  1381. /*
  1382. * 0x08, VanaSysClkReq1HPValid
  1383. * 0x20, Vaux1SysClkReq1HPValid
  1384. * 0x40, Vaux2SysClkReq1HPValid
  1385. * 0x80, Vaux3SysClkReq1HPValid
  1386. */
  1387. REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xe8),
  1388. /*
  1389. * 0x10, VextSupply1SysClkReq1HPValid
  1390. * 0x20, VextSupply2SysClkReq1HPValid
  1391. * 0x40, VextSupply3SysClkReq1HPValid
  1392. */
  1393. REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x70),
  1394. /*
  1395. * 0x08, VanaHwHPReq1Valid
  1396. * 0x20, Vaux1HwHPReq1Valid
  1397. * 0x40, Vaux2HwHPReq1Valid
  1398. * 0x80, Vaux3HwHPReq1Valid
  1399. */
  1400. REG_INIT(AB8500_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xe8),
  1401. /*
  1402. * 0x01, VextSupply1HwHPReq1Valid
  1403. * 0x02, VextSupply2HwHPReq1Valid
  1404. * 0x04, VextSupply3HwHPReq1Valid
  1405. */
  1406. REG_INIT(AB8500_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
  1407. /*
  1408. * 0x08, VanaHwHPReq2Valid
  1409. * 0x20, Vaux1HwHPReq2Valid
  1410. * 0x40, Vaux2HwHPReq2Valid
  1411. * 0x80, Vaux3HwHPReq2Valid
  1412. */
  1413. REG_INIT(AB8500_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xe8),
  1414. /*
  1415. * 0x01, VextSupply1HwHPReq2Valid
  1416. * 0x02, VextSupply2HwHPReq2Valid
  1417. * 0x04, VextSupply3HwHPReq2Valid
  1418. */
  1419. REG_INIT(AB8500_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
  1420. /*
  1421. * 0x20, VanaSwHPReqValid
  1422. * 0x80, Vaux1SwHPReqValid
  1423. */
  1424. REG_INIT(AB8500_REGUSWHPREQVALID1, 0x03, 0x0d, 0xa0),
  1425. /*
  1426. * 0x01, Vaux2SwHPReqValid
  1427. * 0x02, Vaux3SwHPReqValid
  1428. * 0x04, VextSupply1SwHPReqValid
  1429. * 0x08, VextSupply2SwHPReqValid
  1430. * 0x10, VextSupply3SwHPReqValid
  1431. */
  1432. REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
  1433. /*
  1434. * 0x02, SysClkReq2Valid1
  1435. * 0x04, SysClkReq3Valid1
  1436. * 0x08, SysClkReq4Valid1
  1437. * 0x10, SysClkReq5Valid1
  1438. * 0x20, SysClkReq6Valid1
  1439. * 0x40, SysClkReq7Valid1
  1440. * 0x80, SysClkReq8Valid1
  1441. */
  1442. REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
  1443. /*
  1444. * 0x02, SysClkReq2Valid2
  1445. * 0x04, SysClkReq3Valid2
  1446. * 0x08, SysClkReq4Valid2
  1447. * 0x10, SysClkReq5Valid2
  1448. * 0x20, SysClkReq6Valid2
  1449. * 0x40, SysClkReq7Valid2
  1450. * 0x80, SysClkReq8Valid2
  1451. */
  1452. REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
  1453. /*
  1454. * 0x02, VTVoutEna
  1455. * 0x04, Vintcore12Ena
  1456. * 0x38, Vintcore12Sel
  1457. * 0x40, Vintcore12LP
  1458. * 0x80, VTVoutLP
  1459. */
  1460. REG_INIT(AB8500_REGUMISC1, 0x03, 0x80, 0xfe),
  1461. /*
  1462. * 0x02, VaudioEna
  1463. * 0x04, VdmicEna
  1464. * 0x08, Vamic1Ena
  1465. * 0x10, Vamic2Ena
  1466. */
  1467. REG_INIT(AB8500_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
  1468. /*
  1469. * 0x01, Vamic1_dzout
  1470. * 0x02, Vamic2_dzout
  1471. */
  1472. REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
  1473. /*
  1474. * 0x03, VpllRegu (NOTE! PRCMU register bits)
  1475. * 0x0c, VanaRegu
  1476. */
  1477. REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f),
  1478. /*
  1479. * 0x01, VrefDDREna
  1480. * 0x02, VrefDDRSleepMode
  1481. */
  1482. REG_INIT(AB8500_VREFDDR, 0x04, 0x07, 0x03),
  1483. /*
  1484. * 0x03, VextSupply1Regu
  1485. * 0x0c, VextSupply2Regu
  1486. * 0x30, VextSupply3Regu
  1487. * 0x40, ExtSupply2Bypass
  1488. * 0x80, ExtSupply3Bypass
  1489. */
  1490. REG_INIT(AB8500_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
  1491. /*
  1492. * 0x03, Vaux1Regu
  1493. * 0x0c, Vaux2Regu
  1494. */
  1495. REG_INIT(AB8500_VAUX12REGU, 0x04, 0x09, 0x0f),
  1496. /*
  1497. * 0x03, Vaux3Regu
  1498. */
  1499. REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x03),
  1500. /*
  1501. * 0x0f, Vaux1Sel
  1502. */
  1503. REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f),
  1504. /*
  1505. * 0x0f, Vaux2Sel
  1506. */
  1507. REG_INIT(AB8500_VAUX2SEL, 0x04, 0x20, 0x0f),
  1508. /*
  1509. * 0x07, Vaux3Sel
  1510. */
  1511. REG_INIT(AB8500_VRF1VAUX3SEL, 0x04, 0x21, 0x07),
  1512. /*
  1513. * 0x01, VextSupply12LP
  1514. */
  1515. REG_INIT(AB8500_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
  1516. /*
  1517. * 0x04, Vaux1Disch
  1518. * 0x08, Vaux2Disch
  1519. * 0x10, Vaux3Disch
  1520. * 0x20, Vintcore12Disch
  1521. * 0x40, VTVoutDisch
  1522. * 0x80, VaudioDisch
  1523. */
  1524. REG_INIT(AB8500_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
  1525. /*
  1526. * 0x02, VanaDisch
  1527. * 0x04, VdmicPullDownEna
  1528. * 0x10, VdmicDisch
  1529. */
  1530. REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
  1531. };
  1532. /* AB8505 register init */
  1533. static struct ab8500_reg_init ab8505_reg_init[] = {
  1534. /*
  1535. * 0x03, VarmRequestCtrl
  1536. * 0x0c, VsmpsCRequestCtrl
  1537. * 0x30, VsmpsARequestCtrl
  1538. * 0xc0, VsmpsBRequestCtrl
  1539. */
  1540. REG_INIT(AB8505_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
  1541. /*
  1542. * 0x03, VsafeRequestCtrl
  1543. * 0x0c, VpllRequestCtrl
  1544. * 0x30, VanaRequestCtrl
  1545. */
  1546. REG_INIT(AB8505_REGUREQUESTCTRL2, 0x03, 0x04, 0x3f),
  1547. /*
  1548. * 0x30, Vaux1RequestCtrl
  1549. * 0xc0, Vaux2RequestCtrl
  1550. */
  1551. REG_INIT(AB8505_REGUREQUESTCTRL3, 0x03, 0x05, 0xf0),
  1552. /*
  1553. * 0x03, Vaux3RequestCtrl
  1554. * 0x04, SwHPReq
  1555. */
  1556. REG_INIT(AB8505_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
  1557. /*
  1558. * 0x01, VsmpsASysClkReq1HPValid
  1559. * 0x02, VsmpsBSysClkReq1HPValid
  1560. * 0x04, VsafeSysClkReq1HPValid
  1561. * 0x08, VanaSysClkReq1HPValid
  1562. * 0x10, VpllSysClkReq1HPValid
  1563. * 0x20, Vaux1SysClkReq1HPValid
  1564. * 0x40, Vaux2SysClkReq1HPValid
  1565. * 0x80, Vaux3SysClkReq1HPValid
  1566. */
  1567. REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
  1568. /*
  1569. * 0x01, VsmpsCSysClkReq1HPValid
  1570. * 0x02, VarmSysClkReq1HPValid
  1571. * 0x04, VbbSysClkReq1HPValid
  1572. * 0x08, VsmpsMSysClkReq1HPValid
  1573. */
  1574. REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x0f),
  1575. /*
  1576. * 0x01, VsmpsAHwHPReq1Valid
  1577. * 0x02, VsmpsBHwHPReq1Valid
  1578. * 0x04, VsafeHwHPReq1Valid
  1579. * 0x08, VanaHwHPReq1Valid
  1580. * 0x10, VpllHwHPReq1Valid
  1581. * 0x20, Vaux1HwHPReq1Valid
  1582. * 0x40, Vaux2HwHPReq1Valid
  1583. * 0x80, Vaux3HwHPReq1Valid
  1584. */
  1585. REG_INIT(AB8505_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
  1586. /*
  1587. * 0x08, VsmpsMHwHPReq1Valid
  1588. */
  1589. REG_INIT(AB8505_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x08),
  1590. /*
  1591. * 0x01, VsmpsAHwHPReq2Valid
  1592. * 0x02, VsmpsBHwHPReq2Valid
  1593. * 0x04, VsafeHwHPReq2Valid
  1594. * 0x08, VanaHwHPReq2Valid
  1595. * 0x10, VpllHwHPReq2Valid
  1596. * 0x20, Vaux1HwHPReq2Valid
  1597. * 0x40, Vaux2HwHPReq2Valid
  1598. * 0x80, Vaux3HwHPReq2Valid
  1599. */
  1600. REG_INIT(AB8505_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
  1601. /*
  1602. * 0x08, VsmpsMHwHPReq2Valid
  1603. */
  1604. REG_INIT(AB8505_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x08),
  1605. /*
  1606. * 0x01, VsmpsCSwHPReqValid
  1607. * 0x02, VarmSwHPReqValid
  1608. * 0x04, VsmpsASwHPReqValid
  1609. * 0x08, VsmpsBSwHPReqValid
  1610. * 0x10, VsafeSwHPReqValid
  1611. * 0x20, VanaSwHPReqValid
  1612. * 0x40, VpllSwHPReqValid
  1613. * 0x80, Vaux1SwHPReqValid
  1614. */
  1615. REG_INIT(AB8505_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
  1616. /*
  1617. * 0x01, Vaux2SwHPReqValid
  1618. * 0x02, Vaux3SwHPReqValid
  1619. * 0x20, VsmpsMSwHPReqValid
  1620. */
  1621. REG_INIT(AB8505_REGUSWHPREQVALID2, 0x03, 0x0e, 0x23),
  1622. /*
  1623. * 0x02, SysClkReq2Valid1
  1624. * 0x04, SysClkReq3Valid1
  1625. * 0x08, SysClkReq4Valid1
  1626. */
  1627. REG_INIT(AB8505_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0x0e),
  1628. /*
  1629. * 0x02, SysClkReq2Valid2
  1630. * 0x04, SysClkReq3Valid2
  1631. * 0x08, SysClkReq4Valid2
  1632. */
  1633. REG_INIT(AB8505_REGUSYSCLKREQVALID2, 0x03, 0x10, 0x0e),
  1634. /*
  1635. * 0x01, Vaux4SwHPReqValid
  1636. * 0x02, Vaux4HwHPReq2Valid
  1637. * 0x04, Vaux4HwHPReq1Valid
  1638. * 0x08, Vaux4SysClkReq1HPValid
  1639. */
  1640. REG_INIT(AB8505_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
  1641. /*
  1642. * 0x02, VadcEna
  1643. * 0x04, VintCore12Ena
  1644. * 0x38, VintCore12Sel
  1645. * 0x40, VintCore12LP
  1646. * 0x80, VadcLP
  1647. */
  1648. REG_INIT(AB8505_REGUMISC1, 0x03, 0x80, 0xfe),
  1649. /*
  1650. * 0x02, VaudioEna
  1651. * 0x04, VdmicEna
  1652. * 0x08, Vamic1Ena
  1653. * 0x10, Vamic2Ena
  1654. */
  1655. REG_INIT(AB8505_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
  1656. /*
  1657. * 0x01, Vamic1_dzout
  1658. * 0x02, Vamic2_dzout
  1659. */
  1660. REG_INIT(AB8505_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
  1661. /*
  1662. * 0x03, VsmpsARegu
  1663. * 0x0c, VsmpsASelCtrl
  1664. * 0x10, VsmpsAAutoMode
  1665. * 0x20, VsmpsAPWMMode
  1666. */
  1667. REG_INIT(AB8505_VSMPSAREGU, 0x04, 0x03, 0x3f),
  1668. /*
  1669. * 0x03, VsmpsBRegu
  1670. * 0x0c, VsmpsBSelCtrl
  1671. * 0x10, VsmpsBAutoMode
  1672. * 0x20, VsmpsBPWMMode
  1673. */
  1674. REG_INIT(AB8505_VSMPSBREGU, 0x04, 0x04, 0x3f),
  1675. /*
  1676. * 0x03, VsafeRegu
  1677. * 0x0c, VsafeSelCtrl
  1678. * 0x10, VsafeAutoMode
  1679. * 0x20, VsafePWMMode
  1680. */
  1681. REG_INIT(AB8505_VSAFEREGU, 0x04, 0x05, 0x3f),
  1682. /*
  1683. * 0x03, VpllRegu (NOTE! PRCMU register bits)
  1684. * 0x0c, VanaRegu
  1685. */
  1686. REG_INIT(AB8505_VPLLVANAREGU, 0x04, 0x06, 0x0f),
  1687. /*
  1688. * 0x03, VextSupply1Regu
  1689. * 0x0c, VextSupply2Regu
  1690. * 0x30, VextSupply3Regu
  1691. * 0x40, ExtSupply2Bypass
  1692. * 0x80, ExtSupply3Bypass
  1693. */
  1694. REG_INIT(AB8505_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
  1695. /*
  1696. * 0x03, Vaux1Regu
  1697. * 0x0c, Vaux2Regu
  1698. */
  1699. REG_INIT(AB8505_VAUX12REGU, 0x04, 0x09, 0x0f),
  1700. /*
  1701. * 0x0f, Vaux3Regu
  1702. */
  1703. REG_INIT(AB8505_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
  1704. /*
  1705. * 0x3f, VsmpsASel1
  1706. */
  1707. REG_INIT(AB8505_VSMPSASEL1, 0x04, 0x13, 0x3f),
  1708. /*
  1709. * 0x3f, VsmpsASel2
  1710. */
  1711. REG_INIT(AB8505_VSMPSASEL2, 0x04, 0x14, 0x3f),
  1712. /*
  1713. * 0x3f, VsmpsASel3
  1714. */
  1715. REG_INIT(AB8505_VSMPSASEL3, 0x04, 0x15, 0x3f),
  1716. /*
  1717. * 0x3f, VsmpsBSel1
  1718. */
  1719. REG_INIT(AB8505_VSMPSBSEL1, 0x04, 0x17, 0x3f),
  1720. /*
  1721. * 0x3f, VsmpsBSel2
  1722. */
  1723. REG_INIT(AB8505_VSMPSBSEL2, 0x04, 0x18, 0x3f),
  1724. /*
  1725. * 0x3f, VsmpsBSel3
  1726. */
  1727. REG_INIT(AB8505_VSMPSBSEL3, 0x04, 0x19, 0x3f),
  1728. /*
  1729. * 0x7f, VsafeSel1
  1730. */
  1731. REG_INIT(AB8505_VSAFESEL1, 0x04, 0x1b, 0x7f),
  1732. /*
  1733. * 0x3f, VsafeSel2
  1734. */
  1735. REG_INIT(AB8505_VSAFESEL2, 0x04, 0x1c, 0x7f),
  1736. /*
  1737. * 0x3f, VsafeSel3
  1738. */
  1739. REG_INIT(AB8505_VSAFESEL3, 0x04, 0x1d, 0x7f),
  1740. /*
  1741. * 0x0f, Vaux1Sel
  1742. */
  1743. REG_INIT(AB8505_VAUX1SEL, 0x04, 0x1f, 0x0f),
  1744. /*
  1745. * 0x0f, Vaux2Sel
  1746. */
  1747. REG_INIT(AB8505_VAUX2SEL, 0x04, 0x20, 0x0f),
  1748. /*
  1749. * 0x07, Vaux3Sel
  1750. * 0x30, VRF1Sel
  1751. */
  1752. REG_INIT(AB8505_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
  1753. /*
  1754. * 0x03, Vaux4RequestCtrl
  1755. */
  1756. REG_INIT(AB8505_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
  1757. /*
  1758. * 0x03, Vaux4Regu
  1759. */
  1760. REG_INIT(AB8505_VAUX4REGU, 0x04, 0x2e, 0x03),
  1761. /*
  1762. * 0x0f, Vaux4Sel
  1763. */
  1764. REG_INIT(AB8505_VAUX4SEL, 0x04, 0x2f, 0x0f),
  1765. /*
  1766. * 0x04, Vaux1Disch
  1767. * 0x08, Vaux2Disch
  1768. * 0x10, Vaux3Disch
  1769. * 0x20, Vintcore12Disch
  1770. * 0x40, VTVoutDisch
  1771. * 0x80, VaudioDisch
  1772. */
  1773. REG_INIT(AB8505_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
  1774. /*
  1775. * 0x02, VanaDisch
  1776. * 0x04, VdmicPullDownEna
  1777. * 0x10, VdmicDisch
  1778. */
  1779. REG_INIT(AB8505_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
  1780. /*
  1781. * 0x01, Vaux4Disch
  1782. */
  1783. REG_INIT(AB8505_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
  1784. /*
  1785. * 0x07, Vaux5Sel
  1786. * 0x08, Vaux5LP
  1787. * 0x10, Vaux5Ena
  1788. * 0x20, Vaux5Disch
  1789. * 0x40, Vaux5DisSfst
  1790. * 0x80, Vaux5DisPulld
  1791. */
  1792. REG_INIT(AB8505_CTRLVAUX5, 0x01, 0x55, 0xff),
  1793. /*
  1794. * 0x07, Vaux6Sel
  1795. * 0x08, Vaux6LP
  1796. * 0x10, Vaux6Ena
  1797. * 0x80, Vaux6DisPulld
  1798. */
  1799. REG_INIT(AB8505_CTRLVAUX6, 0x01, 0x56, 0x9f),
  1800. };
  1801. /* AB9540 register init */
  1802. static struct ab8500_reg_init ab9540_reg_init[] = {
  1803. /*
  1804. * 0x03, VarmRequestCtrl
  1805. * 0x0c, VapeRequestCtrl
  1806. * 0x30, Vsmps1RequestCtrl
  1807. * 0xc0, Vsmps2RequestCtrl
  1808. */
  1809. REG_INIT(AB9540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
  1810. /*
  1811. * 0x03, Vsmps3RequestCtrl
  1812. * 0x0c, VpllRequestCtrl
  1813. * 0x30, VanaRequestCtrl
  1814. * 0xc0, VextSupply1RequestCtrl
  1815. */
  1816. REG_INIT(AB9540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
  1817. /*
  1818. * 0x03, VextSupply2RequestCtrl
  1819. * 0x0c, VextSupply3RequestCtrl
  1820. * 0x30, Vaux1RequestCtrl
  1821. * 0xc0, Vaux2RequestCtrl
  1822. */
  1823. REG_INIT(AB9540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
  1824. /*
  1825. * 0x03, Vaux3RequestCtrl
  1826. * 0x04, SwHPReq
  1827. */
  1828. REG_INIT(AB9540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
  1829. /*
  1830. * 0x01, Vsmps1SysClkReq1HPValid
  1831. * 0x02, Vsmps2SysClkReq1HPValid
  1832. * 0x04, Vsmps3SysClkReq1HPValid
  1833. * 0x08, VanaSysClkReq1HPValid
  1834. * 0x10, VpllSysClkReq1HPValid
  1835. * 0x20, Vaux1SysClkReq1HPValid
  1836. * 0x40, Vaux2SysClkReq1HPValid
  1837. * 0x80, Vaux3SysClkReq1HPValid
  1838. */
  1839. REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
  1840. /*
  1841. * 0x01, VapeSysClkReq1HPValid
  1842. * 0x02, VarmSysClkReq1HPValid
  1843. * 0x04, VbbSysClkReq1HPValid
  1844. * 0x08, VmodSysClkReq1HPValid
  1845. * 0x10, VextSupply1SysClkReq1HPValid
  1846. * 0x20, VextSupply2SysClkReq1HPValid
  1847. * 0x40, VextSupply3SysClkReq1HPValid
  1848. */
  1849. REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x7f),
  1850. /*
  1851. * 0x01, Vsmps1HwHPReq1Valid
  1852. * 0x02, Vsmps2HwHPReq1Valid
  1853. * 0x04, Vsmps3HwHPReq1Valid
  1854. * 0x08, VanaHwHPReq1Valid
  1855. * 0x10, VpllHwHPReq1Valid
  1856. * 0x20, Vaux1HwHPReq1Valid
  1857. * 0x40, Vaux2HwHPReq1Valid
  1858. * 0x80, Vaux3HwHPReq1Valid
  1859. */
  1860. REG_INIT(AB9540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
  1861. /*
  1862. * 0x01, VextSupply1HwHPReq1Valid
  1863. * 0x02, VextSupply2HwHPReq1Valid
  1864. * 0x04, VextSupply3HwHPReq1Valid
  1865. * 0x08, VmodHwHPReq1Valid
  1866. */
  1867. REG_INIT(AB9540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x0f),
  1868. /*
  1869. * 0x01, Vsmps1HwHPReq2Valid
  1870. * 0x02, Vsmps2HwHPReq2Valid
  1871. * 0x03, Vsmps3HwHPReq2Valid
  1872. * 0x08, VanaHwHPReq2Valid
  1873. * 0x10, VpllHwHPReq2Valid
  1874. * 0x20, Vaux1HwHPReq2Valid
  1875. * 0x40, Vaux2HwHPReq2Valid
  1876. * 0x80, Vaux3HwHPReq2Valid
  1877. */
  1878. REG_INIT(AB9540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
  1879. /*
  1880. * 0x01, VextSupply1HwHPReq2Valid
  1881. * 0x02, VextSupply2HwHPReq2Valid
  1882. * 0x04, VextSupply3HwHPReq2Valid
  1883. * 0x08, VmodHwHPReq2Valid
  1884. */
  1885. REG_INIT(AB9540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x0f),
  1886. /*
  1887. * 0x01, VapeSwHPReqValid
  1888. * 0x02, VarmSwHPReqValid
  1889. * 0x04, Vsmps1SwHPReqValid
  1890. * 0x08, Vsmps2SwHPReqValid
  1891. * 0x10, Vsmps3SwHPReqValid
  1892. * 0x20, VanaSwHPReqValid
  1893. * 0x40, VpllSwHPReqValid
  1894. * 0x80, Vaux1SwHPReqValid
  1895. */
  1896. REG_INIT(AB9540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
  1897. /*
  1898. * 0x01, Vaux2SwHPReqValid
  1899. * 0x02, Vaux3SwHPReqValid
  1900. * 0x04, VextSupply1SwHPReqValid
  1901. * 0x08, VextSupply2SwHPReqValid
  1902. * 0x10, VextSupply3SwHPReqValid
  1903. * 0x20, VmodSwHPReqValid
  1904. */
  1905. REG_INIT(AB9540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x3f),
  1906. /*
  1907. * 0x02, SysClkReq2Valid1
  1908. * ...
  1909. * 0x80, SysClkReq8Valid1
  1910. */
  1911. REG_INIT(AB9540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
  1912. /*
  1913. * 0x02, SysClkReq2Valid2
  1914. * ...
  1915. * 0x80, SysClkReq8Valid2
  1916. */
  1917. REG_INIT(AB9540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
  1918. /*
  1919. * 0x01, Vaux4SwHPReqValid
  1920. * 0x02, Vaux4HwHPReq2Valid
  1921. * 0x04, Vaux4HwHPReq1Valid
  1922. * 0x08, Vaux4SysClkReq1HPValid
  1923. */
  1924. REG_INIT(AB9540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
  1925. /*
  1926. * 0x02, VTVoutEna
  1927. * 0x04, Vintcore12Ena
  1928. * 0x38, Vintcore12Sel
  1929. * 0x40, Vintcore12LP
  1930. * 0x80, VTVoutLP
  1931. */
  1932. REG_INIT(AB9540_REGUMISC1, 0x03, 0x80, 0xfe),
  1933. /*
  1934. * 0x02, VaudioEna
  1935. * 0x04, VdmicEna
  1936. * 0x08, Vamic1Ena
  1937. * 0x10, Vamic2Ena
  1938. */
  1939. REG_INIT(AB9540_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
  1940. /*
  1941. * 0x01, Vamic1_dzout
  1942. * 0x02, Vamic2_dzout
  1943. */
  1944. REG_INIT(AB9540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
  1945. /*
  1946. * 0x03, Vsmps1Regu
  1947. * 0x0c, Vsmps1SelCtrl
  1948. * 0x10, Vsmps1AutoMode
  1949. * 0x20, Vsmps1PWMMode
  1950. */
  1951. REG_INIT(AB9540_VSMPS1REGU, 0x04, 0x03, 0x3f),
  1952. /*
  1953. * 0x03, Vsmps2Regu
  1954. * 0x0c, Vsmps2SelCtrl
  1955. * 0x10, Vsmps2AutoMode
  1956. * 0x20, Vsmps2PWMMode
  1957. */
  1958. REG_INIT(AB9540_VSMPS2REGU, 0x04, 0x04, 0x3f),
  1959. /*
  1960. * 0x03, Vsmps3Regu
  1961. * 0x0c, Vsmps3SelCtrl
  1962. * NOTE! PRCMU register
  1963. */
  1964. REG_INIT(AB9540_VSMPS3REGU, 0x04, 0x05, 0x0f),
  1965. /*
  1966. * 0x03, VpllRegu
  1967. * 0x0c, VanaRegu
  1968. */
  1969. REG_INIT(AB9540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
  1970. /*
  1971. * 0x03, VextSupply1Regu
  1972. * 0x0c, VextSupply2Regu
  1973. * 0x30, VextSupply3Regu
  1974. * 0x40, ExtSupply2Bypass
  1975. * 0x80, ExtSupply3Bypass
  1976. */
  1977. REG_INIT(AB9540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
  1978. /*
  1979. * 0x03, Vaux1Regu
  1980. * 0x0c, Vaux2Regu
  1981. */
  1982. REG_INIT(AB9540_VAUX12REGU, 0x04, 0x09, 0x0f),
  1983. /*
  1984. * 0x0c, Vrf1Regu
  1985. * 0x03, Vaux3Regu
  1986. */
  1987. REG_INIT(AB9540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
  1988. /*
  1989. * 0x3f, Vsmps1Sel1
  1990. */
  1991. REG_INIT(AB9540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
  1992. /*
  1993. * 0x3f, Vsmps1Sel2
  1994. */
  1995. REG_INIT(AB9540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
  1996. /*
  1997. * 0x3f, Vsmps1Sel3
  1998. */
  1999. REG_INIT(AB9540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
  2000. /*
  2001. * 0x3f, Vsmps2Sel1
  2002. */
  2003. REG_INIT(AB9540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
  2004. /*
  2005. * 0x3f, Vsmps2Sel2
  2006. */
  2007. REG_INIT(AB9540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
  2008. /*
  2009. * 0x3f, Vsmps2Sel3
  2010. */
  2011. REG_INIT(AB9540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
  2012. /*
  2013. * 0x7f, Vsmps3Sel1
  2014. * NOTE! PRCMU register
  2015. */
  2016. REG_INIT(AB9540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
  2017. /*
  2018. * 0x7f, Vsmps3Sel2
  2019. * NOTE! PRCMU register
  2020. */
  2021. REG_INIT(AB9540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
  2022. /*
  2023. * 0x0f, Vaux1Sel
  2024. */
  2025. REG_INIT(AB9540_VAUX1SEL, 0x04, 0x1f, 0x0f),
  2026. /*
  2027. * 0x0f, Vaux2Sel
  2028. */
  2029. REG_INIT(AB9540_VAUX2SEL, 0x04, 0x20, 0x0f),
  2030. /*
  2031. * 0x07, Vaux3Sel
  2032. * 0x30, Vrf1Sel
  2033. */
  2034. REG_INIT(AB9540_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
  2035. /*
  2036. * 0x01, VextSupply12LP
  2037. */
  2038. REG_INIT(AB9540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
  2039. /*
  2040. * 0x03, Vaux4RequestCtrl
  2041. */
  2042. REG_INIT(AB9540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
  2043. /*
  2044. * 0x03, Vaux4Regu
  2045. */
  2046. REG_INIT(AB9540_VAUX4REGU, 0x04, 0x2e, 0x03),
  2047. /*
  2048. * 0x08, Vaux4Sel
  2049. */
  2050. REG_INIT(AB9540_VAUX4SEL, 0x04, 0x2f, 0x0f),
  2051. /*
  2052. * 0x01, VpllDisch
  2053. * 0x02, Vrf1Disch
  2054. * 0x04, Vaux1Disch
  2055. * 0x08, Vaux2Disch
  2056. * 0x10, Vaux3Disch
  2057. * 0x20, Vintcore12Disch
  2058. * 0x40, VTVoutDisch
  2059. * 0x80, VaudioDisch
  2060. */
  2061. REG_INIT(AB9540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
  2062. /*
  2063. * 0x01, VsimDisch
  2064. * 0x02, VanaDisch
  2065. * 0x04, VdmicPullDownEna
  2066. * 0x08, VpllPullDownEna
  2067. * 0x10, VdmicDisch
  2068. */
  2069. REG_INIT(AB9540_REGUCTRLDISCH2, 0x04, 0x44, 0x1f),
  2070. /*
  2071. * 0x01, Vaux4Disch
  2072. */
  2073. REG_INIT(AB9540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
  2074. };
  2075. /* AB8540 register init */
  2076. static struct ab8500_reg_init ab8540_reg_init[] = {
  2077. /*
  2078. * 0x01, VSimSycClkReq1Valid
  2079. * 0x02, VSimSycClkReq2Valid
  2080. * 0x04, VSimSycClkReq3Valid
  2081. * 0x08, VSimSycClkReq4Valid
  2082. * 0x10, VSimSycClkReq5Valid
  2083. * 0x20, VSimSycClkReq6Valid
  2084. * 0x40, VSimSycClkReq7Valid
  2085. * 0x80, VSimSycClkReq8Valid
  2086. */
  2087. REG_INIT(AB8540_VSIMSYSCLKCTRL, 0x02, 0x33, 0xff),
  2088. /*
  2089. * 0x03, VarmRequestCtrl
  2090. * 0x0c, VapeRequestCtrl
  2091. * 0x30, Vsmps1RequestCtrl
  2092. * 0xc0, Vsmps2RequestCtrl
  2093. */
  2094. REG_INIT(AB8540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
  2095. /*
  2096. * 0x03, Vsmps3RequestCtrl
  2097. * 0x0c, VpllRequestCtrl
  2098. * 0x30, VanaRequestCtrl
  2099. * 0xc0, VextSupply1RequestCtrl
  2100. */
  2101. REG_INIT(AB8540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
  2102. /*
  2103. * 0x03, VextSupply2RequestCtrl
  2104. * 0x0c, VextSupply3RequestCtrl
  2105. * 0x30, Vaux1RequestCtrl
  2106. * 0xc0, Vaux2RequestCtrl
  2107. */
  2108. REG_INIT(AB8540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
  2109. /*
  2110. * 0x03, Vaux3RequestCtrl
  2111. * 0x04, SwHPReq
  2112. */
  2113. REG_INIT(AB8540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
  2114. /*
  2115. * 0x01, Vsmps1SysClkReq1HPValid
  2116. * 0x02, Vsmps2SysClkReq1HPValid
  2117. * 0x04, Vsmps3SysClkReq1HPValid
  2118. * 0x08, VanaSysClkReq1HPValid
  2119. * 0x10, VpllSysClkReq1HPValid
  2120. * 0x20, Vaux1SysClkReq1HPValid
  2121. * 0x40, Vaux2SysClkReq1HPValid
  2122. * 0x80, Vaux3SysClkReq1HPValid
  2123. */
  2124. REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
  2125. /*
  2126. * 0x01, VapeSysClkReq1HPValid
  2127. * 0x02, VarmSysClkReq1HPValid
  2128. * 0x04, VbbSysClkReq1HPValid
  2129. * 0x10, VextSupply1SysClkReq1HPValid
  2130. * 0x20, VextSupply2SysClkReq1HPValid
  2131. * 0x40, VextSupply3SysClkReq1HPValid
  2132. */
  2133. REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x77),
  2134. /*
  2135. * 0x01, Vsmps1HwHPReq1Valid
  2136. * 0x02, Vsmps2HwHPReq1Valid
  2137. * 0x04, Vsmps3HwHPReq1Valid
  2138. * 0x08, VanaHwHPReq1Valid
  2139. * 0x10, VpllHwHPReq1Valid
  2140. * 0x20, Vaux1HwHPReq1Valid
  2141. * 0x40, Vaux2HwHPReq1Valid
  2142. * 0x80, Vaux3HwHPReq1Valid
  2143. */
  2144. REG_INIT(AB8540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
  2145. /*
  2146. * 0x01, VextSupply1HwHPReq1Valid
  2147. * 0x02, VextSupply2HwHPReq1Valid
  2148. * 0x04, VextSupply3HwHPReq1Valid
  2149. */
  2150. REG_INIT(AB8540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
  2151. /*
  2152. * 0x01, Vsmps1HwHPReq2Valid
  2153. * 0x02, Vsmps2HwHPReq2Valid
  2154. * 0x03, Vsmps3HwHPReq2Valid
  2155. * 0x08, VanaHwHPReq2Valid
  2156. * 0x10, VpllHwHPReq2Valid
  2157. * 0x20, Vaux1HwHPReq2Valid
  2158. * 0x40, Vaux2HwHPReq2Valid
  2159. * 0x80, Vaux3HwHPReq2Valid
  2160. */
  2161. REG_INIT(AB8540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
  2162. /*
  2163. * 0x01, VextSupply1HwHPReq2Valid
  2164. * 0x02, VextSupply2HwHPReq2Valid
  2165. * 0x04, VextSupply3HwHPReq2Valid
  2166. */
  2167. REG_INIT(AB8540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
  2168. /*
  2169. * 0x01, VapeSwHPReqValid
  2170. * 0x02, VarmSwHPReqValid
  2171. * 0x04, Vsmps1SwHPReqValid
  2172. * 0x08, Vsmps2SwHPReqValid
  2173. * 0x10, Vsmps3SwHPReqValid
  2174. * 0x20, VanaSwHPReqValid
  2175. * 0x40, VpllSwHPReqValid
  2176. * 0x80, Vaux1SwHPReqValid
  2177. */
  2178. REG_INIT(AB8540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
  2179. /*
  2180. * 0x01, Vaux2SwHPReqValid
  2181. * 0x02, Vaux3SwHPReqValid
  2182. * 0x04, VextSupply1SwHPReqValid
  2183. * 0x08, VextSupply2SwHPReqValid
  2184. * 0x10, VextSupply3SwHPReqValid
  2185. */
  2186. REG_INIT(AB8540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
  2187. /*
  2188. * 0x02, SysClkReq2Valid1
  2189. * ...
  2190. * 0x80, SysClkReq8Valid1
  2191. */
  2192. REG_INIT(AB8540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xff),
  2193. /*
  2194. * 0x02, SysClkReq2Valid2
  2195. * ...
  2196. * 0x80, SysClkReq8Valid2
  2197. */
  2198. REG_INIT(AB8540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xff),
  2199. /*
  2200. * 0x01, Vaux4SwHPReqValid
  2201. * 0x02, Vaux4HwHPReq2Valid
  2202. * 0x04, Vaux4HwHPReq1Valid
  2203. * 0x08, Vaux4SysClkReq1HPValid
  2204. */
  2205. REG_INIT(AB8540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
  2206. /*
  2207. * 0x01, Vaux5SwHPReqValid
  2208. * 0x02, Vaux5HwHPReq2Valid
  2209. * 0x04, Vaux5HwHPReq1Valid
  2210. * 0x08, Vaux5SysClkReq1HPValid
  2211. */
  2212. REG_INIT(AB8540_REGUVAUX5REQVALID, 0x03, 0x12, 0x0f),
  2213. /*
  2214. * 0x01, Vaux6SwHPReqValid
  2215. * 0x02, Vaux6HwHPReq2Valid
  2216. * 0x04, Vaux6HwHPReq1Valid
  2217. * 0x08, Vaux6SysClkReq1HPValid
  2218. */
  2219. REG_INIT(AB8540_REGUVAUX6REQVALID, 0x03, 0x13, 0x0f),
  2220. /*
  2221. * 0x01, VclkbSwHPReqValid
  2222. * 0x02, VclkbHwHPReq2Valid
  2223. * 0x04, VclkbHwHPReq1Valid
  2224. * 0x08, VclkbSysClkReq1HPValid
  2225. */
  2226. REG_INIT(AB8540_REGUVCLKBREQVALID, 0x03, 0x14, 0x0f),
  2227. /*
  2228. * 0x01, Vrf1SwHPReqValid
  2229. * 0x02, Vrf1HwHPReq2Valid
  2230. * 0x04, Vrf1HwHPReq1Valid
  2231. * 0x08, Vrf1SysClkReq1HPValid
  2232. */
  2233. REG_INIT(AB8540_REGUVRF1REQVALID, 0x03, 0x15, 0x0f),
  2234. /*
  2235. * 0x02, VTVoutEna
  2236. * 0x04, Vintcore12Ena
  2237. * 0x38, Vintcore12Sel
  2238. * 0x40, Vintcore12LP
  2239. * 0x80, VTVoutLP
  2240. */
  2241. REG_INIT(AB8540_REGUMISC1, 0x03, 0x80, 0xfe),
  2242. /*
  2243. * 0x02, VaudioEna
  2244. * 0x04, VdmicEna
  2245. * 0x08, Vamic1Ena
  2246. * 0x10, Vamic2Ena
  2247. * 0x20, Vamic12LP
  2248. * 0xC0, VdmicSel
  2249. */
  2250. REG_INIT(AB8540_VAUDIOSUPPLY, 0x03, 0x83, 0xfe),
  2251. /*
  2252. * 0x01, Vamic1_dzout
  2253. * 0x02, Vamic2_dzout
  2254. */
  2255. REG_INIT(AB8540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
  2256. /*
  2257. * 0x07, VHSICSel
  2258. * 0x08, VHSICOffState
  2259. * 0x10, VHSIEna
  2260. * 0x20, VHSICLP
  2261. */
  2262. REG_INIT(AB8540_VHSIC, 0x03, 0x87, 0x3f),
  2263. /*
  2264. * 0x07, VSDIOSel
  2265. * 0x08, VSDIOOffState
  2266. * 0x10, VSDIOEna
  2267. * 0x20, VSDIOLP
  2268. */
  2269. REG_INIT(AB8540_VSDIO, 0x03, 0x88, 0x3f),
  2270. /*
  2271. * 0x03, Vsmps1Regu
  2272. * 0x0c, Vsmps1SelCtrl
  2273. * 0x10, Vsmps1AutoMode
  2274. * 0x20, Vsmps1PWMMode
  2275. */
  2276. REG_INIT(AB8540_VSMPS1REGU, 0x04, 0x03, 0x3f),
  2277. /*
  2278. * 0x03, Vsmps2Regu
  2279. * 0x0c, Vsmps2SelCtrl
  2280. * 0x10, Vsmps2AutoMode
  2281. * 0x20, Vsmps2PWMMode
  2282. */
  2283. REG_INIT(AB8540_VSMPS2REGU, 0x04, 0x04, 0x3f),
  2284. /*
  2285. * 0x03, Vsmps3Regu
  2286. * 0x0c, Vsmps3SelCtrl
  2287. * 0x10, Vsmps3AutoMode
  2288. * 0x20, Vsmps3PWMMode
  2289. * NOTE! PRCMU register
  2290. */
  2291. REG_INIT(AB8540_VSMPS3REGU, 0x04, 0x05, 0x0f),
  2292. /*
  2293. * 0x03, VpllRegu
  2294. * 0x0c, VanaRegu
  2295. */
  2296. REG_INIT(AB8540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
  2297. /*
  2298. * 0x03, VextSupply1Regu
  2299. * 0x0c, VextSupply2Regu
  2300. * 0x30, VextSupply3Regu
  2301. * 0x40, ExtSupply2Bypass
  2302. * 0x80, ExtSupply3Bypass
  2303. */
  2304. REG_INIT(AB8540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
  2305. /*
  2306. * 0x03, Vaux1Regu
  2307. * 0x0c, Vaux2Regu
  2308. */
  2309. REG_INIT(AB8540_VAUX12REGU, 0x04, 0x09, 0x0f),
  2310. /*
  2311. * 0x0c, VRF1Regu
  2312. * 0x03, Vaux3Regu
  2313. */
  2314. REG_INIT(AB8540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
  2315. /*
  2316. * 0x3f, Vsmps1Sel1
  2317. */
  2318. REG_INIT(AB8540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
  2319. /*
  2320. * 0x3f, Vsmps1Sel2
  2321. */
  2322. REG_INIT(AB8540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
  2323. /*
  2324. * 0x3f, Vsmps1Sel3
  2325. */
  2326. REG_INIT(AB8540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
  2327. /*
  2328. * 0x3f, Vsmps2Sel1
  2329. */
  2330. REG_INIT(AB8540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
  2331. /*
  2332. * 0x3f, Vsmps2Sel2
  2333. */
  2334. REG_INIT(AB8540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
  2335. /*
  2336. * 0x3f, Vsmps2Sel3
  2337. */
  2338. REG_INIT(AB8540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
  2339. /*
  2340. * 0x7f, Vsmps3Sel1
  2341. * NOTE! PRCMU register
  2342. */
  2343. REG_INIT(AB8540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
  2344. /*
  2345. * 0x7f, Vsmps3Sel2
  2346. * NOTE! PRCMU register
  2347. */
  2348. REG_INIT(AB8540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
  2349. /*
  2350. * 0x0f, Vaux1Sel
  2351. */
  2352. REG_INIT(AB8540_VAUX1SEL, 0x04, 0x1f, 0x0f),
  2353. /*
  2354. * 0x0f, Vaux2Sel
  2355. */
  2356. REG_INIT(AB8540_VAUX2SEL, 0x04, 0x20, 0x0f),
  2357. /*
  2358. * 0x07, Vaux3Sel
  2359. * 0x70, Vrf1Sel
  2360. */
  2361. REG_INIT(AB8540_VRF1VAUX3SEL, 0x04, 0x21, 0x77),
  2362. /*
  2363. * 0x01, VextSupply12LP
  2364. */
  2365. REG_INIT(AB8540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
  2366. /*
  2367. * 0x07, Vanasel
  2368. * 0x30, Vpllsel
  2369. */
  2370. REG_INIT(AB8540_VANAVPLLSEL, 0x04, 0x29, 0x37),
  2371. /*
  2372. * 0x03, Vaux4RequestCtrl
  2373. */
  2374. REG_INIT(AB8540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
  2375. /*
  2376. * 0x03, Vaux4Regu
  2377. */
  2378. REG_INIT(AB8540_VAUX4REGU, 0x04, 0x2e, 0x03),
  2379. /*
  2380. * 0x0f, Vaux4Sel
  2381. */
  2382. REG_INIT(AB8540_VAUX4SEL, 0x04, 0x2f, 0x0f),
  2383. /*
  2384. * 0x03, Vaux5RequestCtrl
  2385. */
  2386. REG_INIT(AB8540_VAUX5REQCTRL, 0x04, 0x31, 0x03),
  2387. /*
  2388. * 0x03, Vaux5Regu
  2389. */
  2390. REG_INIT(AB8540_VAUX5REGU, 0x04, 0x32, 0x03),
  2391. /*
  2392. * 0x3f, Vaux5Sel
  2393. */
  2394. REG_INIT(AB8540_VAUX5SEL, 0x04, 0x33, 0x3f),
  2395. /*
  2396. * 0x03, Vaux6RequestCtrl
  2397. */
  2398. REG_INIT(AB8540_VAUX6REQCTRL, 0x04, 0x34, 0x03),
  2399. /*
  2400. * 0x03, Vaux6Regu
  2401. */
  2402. REG_INIT(AB8540_VAUX6REGU, 0x04, 0x35, 0x03),
  2403. /*
  2404. * 0x3f, Vaux6Sel
  2405. */
  2406. REG_INIT(AB8540_VAUX6SEL, 0x04, 0x36, 0x3f),
  2407. /*
  2408. * 0x03, VCLKBRequestCtrl
  2409. */
  2410. REG_INIT(AB8540_VCLKBREQCTRL, 0x04, 0x37, 0x03),
  2411. /*
  2412. * 0x03, VCLKBRegu
  2413. */
  2414. REG_INIT(AB8540_VCLKBREGU, 0x04, 0x38, 0x03),
  2415. /*
  2416. * 0x07, VCLKBSel
  2417. */
  2418. REG_INIT(AB8540_VCLKBSEL, 0x04, 0x39, 0x07),
  2419. /*
  2420. * 0x03, Vrf1RequestCtrl
  2421. */
  2422. REG_INIT(AB8540_VRF1REQCTRL, 0x04, 0x3a, 0x03),
  2423. /*
  2424. * 0x01, VpllDisch
  2425. * 0x02, Vrf1Disch
  2426. * 0x04, Vaux1Disch
  2427. * 0x08, Vaux2Disch
  2428. * 0x10, Vaux3Disch
  2429. * 0x20, Vintcore12Disch
  2430. * 0x40, VTVoutDisch
  2431. * 0x80, VaudioDisch
  2432. */
  2433. REG_INIT(AB8540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
  2434. /*
  2435. * 0x02, VanaDisch
  2436. * 0x04, VdmicPullDownEna
  2437. * 0x08, VpllPullDownEna
  2438. * 0x10, VdmicDisch
  2439. */
  2440. REG_INIT(AB8540_REGUCTRLDISCH2, 0x04, 0x44, 0x1e),
  2441. /*
  2442. * 0x01, Vaux4Disch
  2443. */
  2444. REG_INIT(AB8540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
  2445. /*
  2446. * 0x01, Vaux5Disch
  2447. * 0x02, Vaux6Disch
  2448. * 0x04, VCLKBDisch
  2449. */
  2450. REG_INIT(AB8540_REGUCTRLDISCH4, 0x04, 0x49, 0x07),
  2451. };
  2452. static int ab8500_regulator_init_registers(struct platform_device *pdev,
  2453. struct ab8500_reg_init *reg_init,
  2454. int id, int mask, int value)
  2455. {
  2456. int err;
  2457. BUG_ON(value & ~mask);
  2458. BUG_ON(mask & ~reg_init[id].mask);
  2459. /* initialize register */
  2460. err = abx500_mask_and_set_register_interruptible(
  2461. &pdev->dev,
  2462. reg_init[id].bank,
  2463. reg_init[id].addr,
  2464. mask, value);
  2465. if (err < 0) {
  2466. dev_err(&pdev->dev,
  2467. "Failed to initialize 0x%02x, 0x%02x.\n",
  2468. reg_init[id].bank,
  2469. reg_init[id].addr);
  2470. return err;
  2471. }
  2472. dev_vdbg(&pdev->dev,
  2473. " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
  2474. reg_init[id].bank,
  2475. reg_init[id].addr,
  2476. mask, value);
  2477. return 0;
  2478. }
  2479. static int ab8500_regulator_register(struct platform_device *pdev,
  2480. struct regulator_init_data *init_data,
  2481. struct ab8500_regulator_info *regulator_info,
  2482. int id, struct device_node *np)
  2483. {
  2484. struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
  2485. struct ab8500_regulator_info *info = NULL;
  2486. struct regulator_config config = { };
  2487. int err;
  2488. /* assign per-regulator data */
  2489. info = &regulator_info[id];
  2490. info->dev = &pdev->dev;
  2491. config.dev = &pdev->dev;
  2492. config.init_data = init_data;
  2493. config.driver_data = info;
  2494. config.of_node = np;
  2495. /* fix for hardware before ab8500v2.0 */
  2496. if (is_ab8500_1p1_or_earlier(ab8500)) {
  2497. if (info->desc.id == AB8500_LDO_AUX3) {
  2498. info->desc.n_voltages =
  2499. ARRAY_SIZE(ldo_vauxn_voltages);
  2500. info->desc.volt_table = ldo_vauxn_voltages;
  2501. info->voltage_mask = 0xf;
  2502. }
  2503. }
  2504. /* register regulator with framework */
  2505. info->regulator = regulator_register(&info->desc, &config);
  2506. if (IS_ERR(info->regulator)) {
  2507. err = PTR_ERR(info->regulator);
  2508. dev_err(&pdev->dev, "failed to register regulator %s\n",
  2509. info->desc.name);
  2510. /* when we fail, un-register all earlier regulators */
  2511. while (--id >= 0) {
  2512. info = &regulator_info[id];
  2513. regulator_unregister(info->regulator);
  2514. }
  2515. return err;
  2516. }
  2517. return 0;
  2518. }
  2519. static struct of_regulator_match ab8500_regulator_match[] = {
  2520. { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, },
  2521. { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, },
  2522. { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8500_LDO_AUX3, },
  2523. { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8500_LDO_INTCORE, },
  2524. { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8500_LDO_TVOUT, },
  2525. { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8500_LDO_AUDIO, },
  2526. { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8500_LDO_ANAMIC1, },
  2527. { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8500_LDO_ANAMIC2, },
  2528. { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8500_LDO_DMIC, },
  2529. { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, },
  2530. };
  2531. static struct of_regulator_match ab8505_regulator_match[] = {
  2532. { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8505_LDO_AUX1, },
  2533. { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8505_LDO_AUX2, },
  2534. { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8505_LDO_AUX3, },
  2535. { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8505_LDO_AUX4, },
  2536. { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8505_LDO_AUX5, },
  2537. { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8505_LDO_AUX6, },
  2538. { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8505_LDO_INTCORE, },
  2539. { .name = "ab8500_ldo_adc", .driver_data = (void *) AB8505_LDO_ADC, },
  2540. { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8505_LDO_AUDIO, },
  2541. { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8505_LDO_ANAMIC1, },
  2542. { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8505_LDO_ANAMIC2, },
  2543. { .name = "ab8500_ldo_aux8", .driver_data = (void *) AB8505_LDO_AUX8, },
  2544. { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8505_LDO_ANA, },
  2545. };
  2546. static struct of_regulator_match ab8540_regulator_match[] = {
  2547. { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8540_LDO_AUX1, },
  2548. { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8540_LDO_AUX2, },
  2549. { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8540_LDO_AUX3, },
  2550. { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8540_LDO_AUX4, },
  2551. { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8540_LDO_INTCORE, },
  2552. { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8540_LDO_TVOUT, },
  2553. { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8540_LDO_AUDIO, },
  2554. { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8540_LDO_ANAMIC1, },
  2555. { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8540_LDO_ANAMIC2, },
  2556. { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8540_LDO_DMIC, },
  2557. { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8540_LDO_ANA, },
  2558. { .name = "ab8500_ldo_sdio", .driver_data = (void *) AB8540_LDO_SDIO, },
  2559. };
  2560. static struct of_regulator_match ab9540_regulator_match[] = {
  2561. { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB9540_LDO_AUX1, },
  2562. { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB9540_LDO_AUX2, },
  2563. { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB9540_LDO_AUX3, },
  2564. { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB9540_LDO_AUX4, },
  2565. { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB9540_LDO_INTCORE, },
  2566. { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB9540_LDO_TVOUT, },
  2567. { .name = "ab8500_ldo_audio", .driver_data = (void *) AB9540_LDO_AUDIO, },
  2568. { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB9540_LDO_ANAMIC1, },
  2569. { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB9540_LDO_ANAMIC2, },
  2570. { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB9540_LDO_DMIC, },
  2571. { .name = "ab8500_ldo_ana", .driver_data = (void *) AB9540_LDO_ANA, },
  2572. };
  2573. static int
  2574. ab8500_regulator_of_probe(struct platform_device *pdev,
  2575. struct ab8500_regulator_info *regulator_info,
  2576. int regulator_info_size,
  2577. struct of_regulator_match *match,
  2578. struct device_node *np)
  2579. {
  2580. int err, i;
  2581. for (i = 0; i < regulator_info_size; i++) {
  2582. err = ab8500_regulator_register(
  2583. pdev, match[i].init_data, regulator_info,
  2584. i, match[i].of_node);
  2585. if (err)
  2586. return err;
  2587. }
  2588. return 0;
  2589. }
  2590. static int ab8500_regulator_probe(struct platform_device *pdev)
  2591. {
  2592. struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
  2593. struct device_node *np = pdev->dev.of_node;
  2594. struct of_regulator_match *match;
  2595. struct ab8500_platform_data *ppdata;
  2596. struct ab8500_regulator_platform_data *pdata;
  2597. int i, err;
  2598. struct ab8500_regulator_info *regulator_info;
  2599. int regulator_info_size;
  2600. struct ab8500_reg_init *reg_init;
  2601. int reg_init_size;
  2602. if (is_ab9540(ab8500)) {
  2603. regulator_info = ab9540_regulator_info;
  2604. regulator_info_size = ARRAY_SIZE(ab9540_regulator_info);
  2605. reg_init = ab9540_reg_init;
  2606. reg_init_size = AB9540_NUM_REGULATOR_REGISTERS;
  2607. match = ab9540_regulator_match;
  2608. match_size = ARRAY_SIZE(ab9540_regulator_match)
  2609. } else if (is_ab8505(ab8500)) {
  2610. regulator_info = ab8505_regulator_info;
  2611. regulator_info_size = ARRAY_SIZE(ab8505_regulator_info);
  2612. reg_init = ab8505_reg_init;
  2613. reg_init_size = AB8505_NUM_REGULATOR_REGISTERS;
  2614. } else if (is_ab8540(ab8500)) {
  2615. regulator_info = ab8540_regulator_info;
  2616. regulator_info_size = ARRAY_SIZE(ab8540_regulator_info);
  2617. reg_init = ab8540_reg_init;
  2618. reg_init_size = AB8540_NUM_REGULATOR_REGISTERS;
  2619. } else {
  2620. regulator_info = ab8500_regulator_info;
  2621. regulator_info_size = ARRAY_SIZE(ab8500_regulator_info);
  2622. reg_init = ab8500_reg_init;
  2623. reg_init_size = AB8500_NUM_REGULATOR_REGISTERS;
  2624. match = ab8500_regulator_match;
  2625. match_size = ARRAY_SIZE(ab8500_regulator_match)
  2626. }
  2627. if (np) {
  2628. err = of_regulator_match(&pdev->dev, np, match, match_size);
  2629. if (err < 0) {
  2630. dev_err(&pdev->dev,
  2631. "Error parsing regulator init data: %d\n", err);
  2632. return err;
  2633. }
  2634. err = ab8500_regulator_of_probe(pdev, regulator_info,
  2635. regulator_info_size, match, np);
  2636. return err;
  2637. }
  2638. if (!ab8500) {
  2639. dev_err(&pdev->dev, "null mfd parent\n");
  2640. return -EINVAL;
  2641. }
  2642. ppdata = dev_get_platdata(ab8500->dev);
  2643. if (!ppdata) {
  2644. dev_err(&pdev->dev, "null parent pdata\n");
  2645. return -EINVAL;
  2646. }
  2647. pdata = ppdata->regulator;
  2648. if (!pdata) {
  2649. dev_err(&pdev->dev, "null pdata\n");
  2650. return -EINVAL;
  2651. }
  2652. /* make sure the platform data has the correct size */
  2653. if (pdata->num_regulator != regulator_info_size) {
  2654. dev_err(&pdev->dev, "Configuration error: size mismatch.\n");
  2655. return -EINVAL;
  2656. }
  2657. /* initialize debug (initial state is recorded with this call) */
  2658. err = ab8500_regulator_debug_init(pdev);
  2659. if (err)
  2660. return err;
  2661. /* initialize registers */
  2662. for (i = 0; i < pdata->num_reg_init; i++) {
  2663. int id, mask, value;
  2664. id = pdata->reg_init[i].id;
  2665. mask = pdata->reg_init[i].mask;
  2666. value = pdata->reg_init[i].value;
  2667. /* check for configuration errors */
  2668. BUG_ON(id >= AB8500_NUM_REGULATOR_REGISTERS);
  2669. err = ab8500_regulator_init_registers(pdev, reg_init, id, mask, value);
  2670. if (err < 0)
  2671. return err;
  2672. }
  2673. /* register external regulators (before Vaux1, 2 and 3) */
  2674. err = ab8500_ext_regulator_init(pdev);
  2675. if (err)
  2676. return err;
  2677. /* register all regulators */
  2678. for (i = 0; i < regulator_info_size; i++) {
  2679. err = ab8500_regulator_register(pdev, &pdata->regulator[i],
  2680. regulator_info, i, NULL);
  2681. if (err < 0)
  2682. return err;
  2683. }
  2684. return 0;
  2685. }
  2686. static int ab8500_regulator_remove(struct platform_device *pdev)
  2687. {
  2688. int i, err;
  2689. struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
  2690. struct ab8500_regulator_info *regulator_info;
  2691. int regulator_info_size;
  2692. if (is_ab9540(ab8500)) {
  2693. regulator_info = ab9540_regulator_info;
  2694. regulator_info_size = ARRAY_SIZE(ab9540_regulator_info);
  2695. } else if (is_ab8505(ab8500)) {
  2696. regulator_info = ab8505_regulator_info;
  2697. regulator_info_size = ARRAY_SIZE(ab8505_regulator_info);
  2698. } else {
  2699. regulator_info = ab8500_regulator_info;
  2700. regulator_info_size = ARRAY_SIZE(ab8500_regulator_info);
  2701. }
  2702. for (i = 0; i < regulator_info_size; i++) {
  2703. struct ab8500_regulator_info *info = NULL;
  2704. info = &regulator_info[i];
  2705. dev_vdbg(rdev_get_dev(info->regulator),
  2706. "%s-remove\n", info->desc.name);
  2707. regulator_unregister(info->regulator);
  2708. }
  2709. /* remove external regulators (after Vaux1, 2 and 3) */
  2710. err = ab8500_ext_regulator_exit(pdev);
  2711. if (err)
  2712. return err;
  2713. /* remove regulator debug */
  2714. err = ab8500_regulator_debug_exit(pdev);
  2715. if (err)
  2716. return err;
  2717. return 0;
  2718. }
  2719. static struct platform_driver ab8500_regulator_driver = {
  2720. .probe = ab8500_regulator_probe,
  2721. .remove = ab8500_regulator_remove,
  2722. .driver = {
  2723. .name = "ab8500-regulator",
  2724. .owner = THIS_MODULE,
  2725. },
  2726. };
  2727. static int __init ab8500_regulator_init(void)
  2728. {
  2729. int ret;
  2730. ret = platform_driver_register(&ab8500_regulator_driver);
  2731. if (ret != 0)
  2732. pr_err("Failed to register ab8500 regulator: %d\n", ret);
  2733. return ret;
  2734. }
  2735. subsys_initcall(ab8500_regulator_init);
  2736. static void __exit ab8500_regulator_exit(void)
  2737. {
  2738. platform_driver_unregister(&ab8500_regulator_driver);
  2739. }
  2740. module_exit(ab8500_regulator_exit);
  2741. MODULE_LICENSE("GPL v2");
  2742. MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
  2743. MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
  2744. MODULE_AUTHOR("Daniel Willerud <daniel.willerud@stericsson.com>");
  2745. MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC");
  2746. MODULE_ALIAS("platform:ab8500-regulator");