ab8500.c 80 KB

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