ab8500.c 80 KB

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