ab8500.c 80 KB

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