ab8500.c 77 KB

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