ab8500.c 78 KB

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