ab8500.c 80 KB

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