ab8500.c 81 KB

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