pinctrl-ingenic.c 181 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Ingenic SoCs pinctrl driver
  4. *
  5. * Copyright (c) 2017 Paul Cercueil <[email protected]>
  6. * Copyright (c) 2017, 2019 Paul Boddie <[email protected]>
  7. * Copyright (c) 2019, 2020 周琰杰 (Zhou Yanjie) <[email protected]>
  8. */
  9. #include <linux/compiler.h>
  10. #include <linux/gpio/driver.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/io.h>
  13. #include <linux/kernel.h>
  14. #include <linux/mod_devicetable.h>
  15. #include <linux/of.h>
  16. #include <linux/pinctrl/pinctrl.h>
  17. #include <linux/pinctrl/pinmux.h>
  18. #include <linux/pinctrl/pinconf.h>
  19. #include <linux/pinctrl/pinconf-generic.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/property.h>
  22. #include <linux/regmap.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/slab.h>
  25. #include "core.h"
  26. #include "pinconf.h"
  27. #include "pinmux.h"
  28. #define GPIO_PIN 0x00
  29. #define GPIO_MSK 0x20
  30. #define JZ4730_GPIO_DATA 0x00
  31. #define JZ4730_GPIO_GPDIR 0x04
  32. #define JZ4730_GPIO_GPPUR 0x0c
  33. #define JZ4730_GPIO_GPALR 0x10
  34. #define JZ4730_GPIO_GPAUR 0x14
  35. #define JZ4730_GPIO_GPIDLR 0x18
  36. #define JZ4730_GPIO_GPIDUR 0x1c
  37. #define JZ4730_GPIO_GPIER 0x20
  38. #define JZ4730_GPIO_GPIMR 0x24
  39. #define JZ4730_GPIO_GPFR 0x28
  40. #define JZ4740_GPIO_DATA 0x10
  41. #define JZ4740_GPIO_PULL_DIS 0x30
  42. #define JZ4740_GPIO_FUNC 0x40
  43. #define JZ4740_GPIO_SELECT 0x50
  44. #define JZ4740_GPIO_DIR 0x60
  45. #define JZ4740_GPIO_TRIG 0x70
  46. #define JZ4740_GPIO_FLAG 0x80
  47. #define JZ4770_GPIO_INT 0x10
  48. #define JZ4770_GPIO_PAT1 0x30
  49. #define JZ4770_GPIO_PAT0 0x40
  50. #define JZ4770_GPIO_FLAG 0x50
  51. #define JZ4770_GPIO_PEN 0x70
  52. #define X1830_GPIO_PEL 0x110
  53. #define X1830_GPIO_PEH 0x120
  54. #define X1830_GPIO_SR 0x150
  55. #define X1830_GPIO_SMT 0x160
  56. #define X2000_GPIO_EDG 0x70
  57. #define X2000_GPIO_PEPU 0x80
  58. #define X2000_GPIO_PEPD 0x90
  59. #define X2000_GPIO_SR 0xd0
  60. #define X2000_GPIO_SMT 0xe0
  61. #define REG_SET(x) ((x) + 0x4)
  62. #define REG_CLEAR(x) ((x) + 0x8)
  63. #define REG_PZ_BASE(x) ((x) * 7)
  64. #define REG_PZ_GID2LD(x) ((x) * 7 + 0xf0)
  65. #define GPIO_PULL_DIS 0
  66. #define GPIO_PULL_UP 1
  67. #define GPIO_PULL_DOWN 2
  68. #define PINS_PER_GPIO_CHIP 32
  69. #define JZ4730_PINS_PER_PAIRED_REG 16
  70. #define INGENIC_PIN_GROUP_FUNCS(name, id, funcs) \
  71. { \
  72. name, \
  73. id##_pins, \
  74. ARRAY_SIZE(id##_pins), \
  75. funcs, \
  76. }
  77. #define INGENIC_PIN_GROUP(name, id, func) \
  78. INGENIC_PIN_GROUP_FUNCS(name, id, (void *)(func))
  79. enum jz_version {
  80. ID_JZ4730,
  81. ID_JZ4740,
  82. ID_JZ4725B,
  83. ID_JZ4750,
  84. ID_JZ4755,
  85. ID_JZ4760,
  86. ID_JZ4770,
  87. ID_JZ4775,
  88. ID_JZ4780,
  89. ID_X1000,
  90. ID_X1500,
  91. ID_X1830,
  92. ID_X2000,
  93. ID_X2100,
  94. };
  95. struct ingenic_chip_info {
  96. unsigned int num_chips;
  97. unsigned int reg_offset;
  98. enum jz_version version;
  99. const struct group_desc *groups;
  100. unsigned int num_groups;
  101. const struct function_desc *functions;
  102. unsigned int num_functions;
  103. const u32 *pull_ups, *pull_downs;
  104. const struct regmap_access_table *access_table;
  105. };
  106. struct ingenic_pinctrl {
  107. struct device *dev;
  108. struct regmap *map;
  109. struct pinctrl_dev *pctl;
  110. struct pinctrl_pin_desc *pdesc;
  111. const struct ingenic_chip_info *info;
  112. };
  113. struct ingenic_gpio_chip {
  114. struct ingenic_pinctrl *jzpc;
  115. struct gpio_chip gc;
  116. unsigned int irq, reg_base;
  117. };
  118. static const unsigned long enabled_socs =
  119. IS_ENABLED(CONFIG_MACH_JZ4730) << ID_JZ4730 |
  120. IS_ENABLED(CONFIG_MACH_JZ4740) << ID_JZ4740 |
  121. IS_ENABLED(CONFIG_MACH_JZ4725B) << ID_JZ4725B |
  122. IS_ENABLED(CONFIG_MACH_JZ4750) << ID_JZ4750 |
  123. IS_ENABLED(CONFIG_MACH_JZ4755) << ID_JZ4755 |
  124. IS_ENABLED(CONFIG_MACH_JZ4760) << ID_JZ4760 |
  125. IS_ENABLED(CONFIG_MACH_JZ4770) << ID_JZ4770 |
  126. IS_ENABLED(CONFIG_MACH_JZ4775) << ID_JZ4775 |
  127. IS_ENABLED(CONFIG_MACH_JZ4780) << ID_JZ4780 |
  128. IS_ENABLED(CONFIG_MACH_X1000) << ID_X1000 |
  129. IS_ENABLED(CONFIG_MACH_X1500) << ID_X1500 |
  130. IS_ENABLED(CONFIG_MACH_X1830) << ID_X1830 |
  131. IS_ENABLED(CONFIG_MACH_X2000) << ID_X2000 |
  132. IS_ENABLED(CONFIG_MACH_X2100) << ID_X2100;
  133. static bool
  134. is_soc_or_above(const struct ingenic_pinctrl *jzpc, enum jz_version version)
  135. {
  136. return (enabled_socs >> version) &&
  137. (!(enabled_socs & GENMASK(version - 1, 0))
  138. || jzpc->info->version >= version);
  139. }
  140. static const u32 jz4730_pull_ups[4] = {
  141. 0x3fa3320f, 0xf200ffff, 0xffffffff, 0xffffffff,
  142. };
  143. static const u32 jz4730_pull_downs[4] = {
  144. 0x00000df0, 0x0dff0000, 0x00000000, 0x00000000,
  145. };
  146. static int jz4730_mmc_1bit_pins[] = { 0x27, 0x26, 0x22, };
  147. static int jz4730_mmc_4bit_pins[] = { 0x23, 0x24, 0x25, };
  148. static int jz4730_uart0_data_pins[] = { 0x7e, 0x7f, };
  149. static int jz4730_uart1_data_pins[] = { 0x18, 0x19, };
  150. static int jz4730_uart2_data_pins[] = { 0x6f, 0x7d, };
  151. static int jz4730_uart3_data_pins[] = { 0x10, 0x15, };
  152. static int jz4730_uart3_hwflow_pins[] = { 0x11, 0x17, };
  153. static int jz4730_lcd_8bit_pins[] = {
  154. 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
  155. 0x3a, 0x39, 0x38,
  156. };
  157. static int jz4730_lcd_16bit_pins[] = {
  158. 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
  159. };
  160. static int jz4730_lcd_special_pins[] = { 0x3d, 0x3c, 0x3e, 0x3f, };
  161. static int jz4730_lcd_generic_pins[] = { 0x3b, };
  162. static int jz4730_nand_cs1_pins[] = { 0x53, };
  163. static int jz4730_nand_cs2_pins[] = { 0x54, };
  164. static int jz4730_nand_cs3_pins[] = { 0x55, };
  165. static int jz4730_nand_cs4_pins[] = { 0x56, };
  166. static int jz4730_nand_cs5_pins[] = { 0x57, };
  167. static int jz4730_pwm_pwm0_pins[] = { 0x5e, };
  168. static int jz4730_pwm_pwm1_pins[] = { 0x5f, };
  169. static u8 jz4730_lcd_8bit_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, };
  170. static const struct group_desc jz4730_groups[] = {
  171. INGENIC_PIN_GROUP("mmc-1bit", jz4730_mmc_1bit, 1),
  172. INGENIC_PIN_GROUP("mmc-4bit", jz4730_mmc_4bit, 1),
  173. INGENIC_PIN_GROUP("uart0-data", jz4730_uart0_data, 1),
  174. INGENIC_PIN_GROUP("uart1-data", jz4730_uart1_data, 1),
  175. INGENIC_PIN_GROUP("uart2-data", jz4730_uart2_data, 1),
  176. INGENIC_PIN_GROUP("uart3-data", jz4730_uart3_data, 1),
  177. INGENIC_PIN_GROUP("uart3-hwflow", jz4730_uart3_hwflow, 1),
  178. INGENIC_PIN_GROUP_FUNCS("lcd-8bit", jz4730_lcd_8bit, jz4730_lcd_8bit_funcs),
  179. INGENIC_PIN_GROUP("lcd-16bit", jz4730_lcd_16bit, 1),
  180. INGENIC_PIN_GROUP("lcd-special", jz4730_lcd_special, 1),
  181. INGENIC_PIN_GROUP("lcd-generic", jz4730_lcd_generic, 1),
  182. INGENIC_PIN_GROUP("nand-cs1", jz4730_nand_cs1, 1),
  183. INGENIC_PIN_GROUP("nand-cs2", jz4730_nand_cs2, 1),
  184. INGENIC_PIN_GROUP("nand-cs3", jz4730_nand_cs3, 1),
  185. INGENIC_PIN_GROUP("nand-cs4", jz4730_nand_cs4, 1),
  186. INGENIC_PIN_GROUP("nand-cs5", jz4730_nand_cs5, 1),
  187. INGENIC_PIN_GROUP("pwm0", jz4730_pwm_pwm0, 1),
  188. INGENIC_PIN_GROUP("pwm1", jz4730_pwm_pwm1, 1),
  189. };
  190. static const char *jz4730_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
  191. static const char *jz4730_uart0_groups[] = { "uart0-data", };
  192. static const char *jz4730_uart1_groups[] = { "uart1-data", };
  193. static const char *jz4730_uart2_groups[] = { "uart2-data", };
  194. static const char *jz4730_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
  195. static const char *jz4730_lcd_groups[] = {
  196. "lcd-8bit", "lcd-16bit", "lcd-special", "lcd-generic",
  197. };
  198. static const char *jz4730_nand_groups[] = {
  199. "nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4", "nand-cs5",
  200. };
  201. static const char *jz4730_pwm0_groups[] = { "pwm0", };
  202. static const char *jz4730_pwm1_groups[] = { "pwm1", };
  203. static const struct function_desc jz4730_functions[] = {
  204. { "mmc", jz4730_mmc_groups, ARRAY_SIZE(jz4730_mmc_groups), },
  205. { "uart0", jz4730_uart0_groups, ARRAY_SIZE(jz4730_uart0_groups), },
  206. { "uart1", jz4730_uart1_groups, ARRAY_SIZE(jz4730_uart1_groups), },
  207. { "uart2", jz4730_uart2_groups, ARRAY_SIZE(jz4730_uart2_groups), },
  208. { "uart3", jz4730_uart3_groups, ARRAY_SIZE(jz4730_uart3_groups), },
  209. { "lcd", jz4730_lcd_groups, ARRAY_SIZE(jz4730_lcd_groups), },
  210. { "nand", jz4730_nand_groups, ARRAY_SIZE(jz4730_nand_groups), },
  211. { "pwm0", jz4730_pwm0_groups, ARRAY_SIZE(jz4730_pwm0_groups), },
  212. { "pwm1", jz4730_pwm1_groups, ARRAY_SIZE(jz4730_pwm1_groups), },
  213. };
  214. static const struct ingenic_chip_info jz4730_chip_info = {
  215. .num_chips = 4,
  216. .reg_offset = 0x30,
  217. .version = ID_JZ4730,
  218. .groups = jz4730_groups,
  219. .num_groups = ARRAY_SIZE(jz4730_groups),
  220. .functions = jz4730_functions,
  221. .num_functions = ARRAY_SIZE(jz4730_functions),
  222. .pull_ups = jz4730_pull_ups,
  223. .pull_downs = jz4730_pull_downs,
  224. };
  225. static const u32 jz4740_pull_ups[4] = {
  226. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  227. };
  228. static const u32 jz4740_pull_downs[4] = {
  229. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  230. };
  231. static int jz4740_mmc_1bit_pins[] = { 0x69, 0x68, 0x6a, };
  232. static int jz4740_mmc_4bit_pins[] = { 0x6b, 0x6c, 0x6d, };
  233. static int jz4740_uart0_data_pins[] = { 0x7a, 0x79, };
  234. static int jz4740_uart0_hwflow_pins[] = { 0x7e, 0x7f, };
  235. static int jz4740_uart1_data_pins[] = { 0x7e, 0x7f, };
  236. static int jz4740_lcd_8bit_pins[] = {
  237. 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
  238. 0x52, 0x53, 0x54,
  239. };
  240. static int jz4740_lcd_16bit_pins[] = {
  241. 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
  242. };
  243. static int jz4740_lcd_18bit_pins[] = { 0x50, 0x51, };
  244. static int jz4740_lcd_special_pins[] = { 0x31, 0x32, 0x56, 0x57, };
  245. static int jz4740_lcd_generic_pins[] = { 0x55, };
  246. static int jz4740_nand_cs1_pins[] = { 0x39, };
  247. static int jz4740_nand_cs2_pins[] = { 0x3a, };
  248. static int jz4740_nand_cs3_pins[] = { 0x3b, };
  249. static int jz4740_nand_cs4_pins[] = { 0x3c, };
  250. static int jz4740_nand_fre_fwe_pins[] = { 0x5c, 0x5d, };
  251. static int jz4740_pwm_pwm0_pins[] = { 0x77, };
  252. static int jz4740_pwm_pwm1_pins[] = { 0x78, };
  253. static int jz4740_pwm_pwm2_pins[] = { 0x79, };
  254. static int jz4740_pwm_pwm3_pins[] = { 0x7a, };
  255. static int jz4740_pwm_pwm4_pins[] = { 0x7b, };
  256. static int jz4740_pwm_pwm5_pins[] = { 0x7c, };
  257. static int jz4740_pwm_pwm6_pins[] = { 0x7e, };
  258. static int jz4740_pwm_pwm7_pins[] = { 0x7f, };
  259. static const struct group_desc jz4740_groups[] = {
  260. INGENIC_PIN_GROUP("mmc-1bit", jz4740_mmc_1bit, 0),
  261. INGENIC_PIN_GROUP("mmc-4bit", jz4740_mmc_4bit, 0),
  262. INGENIC_PIN_GROUP("uart0-data", jz4740_uart0_data, 1),
  263. INGENIC_PIN_GROUP("uart0-hwflow", jz4740_uart0_hwflow, 1),
  264. INGENIC_PIN_GROUP("uart1-data", jz4740_uart1_data, 2),
  265. INGENIC_PIN_GROUP("lcd-8bit", jz4740_lcd_8bit, 0),
  266. INGENIC_PIN_GROUP("lcd-16bit", jz4740_lcd_16bit, 0),
  267. INGENIC_PIN_GROUP("lcd-18bit", jz4740_lcd_18bit, 0),
  268. INGENIC_PIN_GROUP("lcd-special", jz4740_lcd_special, 0),
  269. INGENIC_PIN_GROUP("lcd-generic", jz4740_lcd_generic, 0),
  270. INGENIC_PIN_GROUP("nand-cs1", jz4740_nand_cs1, 0),
  271. INGENIC_PIN_GROUP("nand-cs2", jz4740_nand_cs2, 0),
  272. INGENIC_PIN_GROUP("nand-cs3", jz4740_nand_cs3, 0),
  273. INGENIC_PIN_GROUP("nand-cs4", jz4740_nand_cs4, 0),
  274. INGENIC_PIN_GROUP("nand-fre-fwe", jz4740_nand_fre_fwe, 0),
  275. INGENIC_PIN_GROUP("pwm0", jz4740_pwm_pwm0, 0),
  276. INGENIC_PIN_GROUP("pwm1", jz4740_pwm_pwm1, 0),
  277. INGENIC_PIN_GROUP("pwm2", jz4740_pwm_pwm2, 0),
  278. INGENIC_PIN_GROUP("pwm3", jz4740_pwm_pwm3, 0),
  279. INGENIC_PIN_GROUP("pwm4", jz4740_pwm_pwm4, 0),
  280. INGENIC_PIN_GROUP("pwm5", jz4740_pwm_pwm5, 0),
  281. INGENIC_PIN_GROUP("pwm6", jz4740_pwm_pwm6, 0),
  282. INGENIC_PIN_GROUP("pwm7", jz4740_pwm_pwm7, 0),
  283. };
  284. static const char *jz4740_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
  285. static const char *jz4740_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
  286. static const char *jz4740_uart1_groups[] = { "uart1-data", };
  287. static const char *jz4740_lcd_groups[] = {
  288. "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-special", "lcd-generic",
  289. };
  290. static const char *jz4740_nand_groups[] = {
  291. "nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4", "nand-fre-fwe",
  292. };
  293. static const char *jz4740_pwm0_groups[] = { "pwm0", };
  294. static const char *jz4740_pwm1_groups[] = { "pwm1", };
  295. static const char *jz4740_pwm2_groups[] = { "pwm2", };
  296. static const char *jz4740_pwm3_groups[] = { "pwm3", };
  297. static const char *jz4740_pwm4_groups[] = { "pwm4", };
  298. static const char *jz4740_pwm5_groups[] = { "pwm5", };
  299. static const char *jz4740_pwm6_groups[] = { "pwm6", };
  300. static const char *jz4740_pwm7_groups[] = { "pwm7", };
  301. static const struct function_desc jz4740_functions[] = {
  302. { "mmc", jz4740_mmc_groups, ARRAY_SIZE(jz4740_mmc_groups), },
  303. { "uart0", jz4740_uart0_groups, ARRAY_SIZE(jz4740_uart0_groups), },
  304. { "uart1", jz4740_uart1_groups, ARRAY_SIZE(jz4740_uart1_groups), },
  305. { "lcd", jz4740_lcd_groups, ARRAY_SIZE(jz4740_lcd_groups), },
  306. { "nand", jz4740_nand_groups, ARRAY_SIZE(jz4740_nand_groups), },
  307. { "pwm0", jz4740_pwm0_groups, ARRAY_SIZE(jz4740_pwm0_groups), },
  308. { "pwm1", jz4740_pwm1_groups, ARRAY_SIZE(jz4740_pwm1_groups), },
  309. { "pwm2", jz4740_pwm2_groups, ARRAY_SIZE(jz4740_pwm2_groups), },
  310. { "pwm3", jz4740_pwm3_groups, ARRAY_SIZE(jz4740_pwm3_groups), },
  311. { "pwm4", jz4740_pwm4_groups, ARRAY_SIZE(jz4740_pwm4_groups), },
  312. { "pwm5", jz4740_pwm5_groups, ARRAY_SIZE(jz4740_pwm5_groups), },
  313. { "pwm6", jz4740_pwm6_groups, ARRAY_SIZE(jz4740_pwm6_groups), },
  314. { "pwm7", jz4740_pwm7_groups, ARRAY_SIZE(jz4740_pwm7_groups), },
  315. };
  316. static const struct ingenic_chip_info jz4740_chip_info = {
  317. .num_chips = 4,
  318. .reg_offset = 0x100,
  319. .version = ID_JZ4740,
  320. .groups = jz4740_groups,
  321. .num_groups = ARRAY_SIZE(jz4740_groups),
  322. .functions = jz4740_functions,
  323. .num_functions = ARRAY_SIZE(jz4740_functions),
  324. .pull_ups = jz4740_pull_ups,
  325. .pull_downs = jz4740_pull_downs,
  326. };
  327. static int jz4725b_mmc0_1bit_pins[] = { 0x48, 0x49, 0x5c, };
  328. static int jz4725b_mmc0_4bit_pins[] = { 0x5d, 0x5b, 0x56, };
  329. static int jz4725b_mmc1_1bit_pins[] = { 0x7a, 0x7b, 0x7c, };
  330. static int jz4725b_mmc1_4bit_pins[] = { 0x7d, 0x7e, 0x7f, };
  331. static int jz4725b_uart_data_pins[] = { 0x4c, 0x4d, };
  332. static int jz4725b_lcd_8bit_pins[] = {
  333. 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
  334. 0x72, 0x73, 0x74,
  335. };
  336. static int jz4725b_lcd_16bit_pins[] = {
  337. 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
  338. };
  339. static int jz4725b_lcd_18bit_pins[] = { 0x70, 0x71, };
  340. static int jz4725b_lcd_24bit_pins[] = { 0x76, 0x77, 0x78, 0x79, };
  341. static int jz4725b_lcd_special_pins[] = { 0x76, 0x77, 0x78, 0x79, };
  342. static int jz4725b_lcd_generic_pins[] = { 0x75, };
  343. static int jz4725b_nand_cs1_pins[] = { 0x55, };
  344. static int jz4725b_nand_cs2_pins[] = { 0x56, };
  345. static int jz4725b_nand_cs3_pins[] = { 0x57, };
  346. static int jz4725b_nand_cs4_pins[] = { 0x58, };
  347. static int jz4725b_nand_cle_ale_pins[] = { 0x48, 0x49 };
  348. static int jz4725b_nand_fre_fwe_pins[] = { 0x5c, 0x5d };
  349. static int jz4725b_pwm_pwm0_pins[] = { 0x4a, };
  350. static int jz4725b_pwm_pwm1_pins[] = { 0x4b, };
  351. static int jz4725b_pwm_pwm2_pins[] = { 0x4c, };
  352. static int jz4725b_pwm_pwm3_pins[] = { 0x4d, };
  353. static int jz4725b_pwm_pwm4_pins[] = { 0x4e, };
  354. static int jz4725b_pwm_pwm5_pins[] = { 0x4f, };
  355. static u8 jz4725b_mmc0_4bit_funcs[] = { 1, 0, 1, };
  356. static const struct group_desc jz4725b_groups[] = {
  357. INGENIC_PIN_GROUP("mmc0-1bit", jz4725b_mmc0_1bit, 1),
  358. INGENIC_PIN_GROUP_FUNCS("mmc0-4bit", jz4725b_mmc0_4bit,
  359. jz4725b_mmc0_4bit_funcs),
  360. INGENIC_PIN_GROUP("mmc1-1bit", jz4725b_mmc1_1bit, 0),
  361. INGENIC_PIN_GROUP("mmc1-4bit", jz4725b_mmc1_4bit, 0),
  362. INGENIC_PIN_GROUP("uart-data", jz4725b_uart_data, 1),
  363. INGENIC_PIN_GROUP("lcd-8bit", jz4725b_lcd_8bit, 0),
  364. INGENIC_PIN_GROUP("lcd-16bit", jz4725b_lcd_16bit, 0),
  365. INGENIC_PIN_GROUP("lcd-18bit", jz4725b_lcd_18bit, 0),
  366. INGENIC_PIN_GROUP("lcd-24bit", jz4725b_lcd_24bit, 1),
  367. INGENIC_PIN_GROUP("lcd-special", jz4725b_lcd_special, 0),
  368. INGENIC_PIN_GROUP("lcd-generic", jz4725b_lcd_generic, 0),
  369. INGENIC_PIN_GROUP("nand-cs1", jz4725b_nand_cs1, 0),
  370. INGENIC_PIN_GROUP("nand-cs2", jz4725b_nand_cs2, 0),
  371. INGENIC_PIN_GROUP("nand-cs3", jz4725b_nand_cs3, 0),
  372. INGENIC_PIN_GROUP("nand-cs4", jz4725b_nand_cs4, 0),
  373. INGENIC_PIN_GROUP("nand-cle-ale", jz4725b_nand_cle_ale, 0),
  374. INGENIC_PIN_GROUP("nand-fre-fwe", jz4725b_nand_fre_fwe, 0),
  375. INGENIC_PIN_GROUP("pwm0", jz4725b_pwm_pwm0, 0),
  376. INGENIC_PIN_GROUP("pwm1", jz4725b_pwm_pwm1, 0),
  377. INGENIC_PIN_GROUP("pwm2", jz4725b_pwm_pwm2, 0),
  378. INGENIC_PIN_GROUP("pwm3", jz4725b_pwm_pwm3, 0),
  379. INGENIC_PIN_GROUP("pwm4", jz4725b_pwm_pwm4, 0),
  380. INGENIC_PIN_GROUP("pwm5", jz4725b_pwm_pwm5, 0),
  381. };
  382. static const char *jz4725b_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", };
  383. static const char *jz4725b_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
  384. static const char *jz4725b_uart_groups[] = { "uart-data", };
  385. static const char *jz4725b_lcd_groups[] = {
  386. "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
  387. "lcd-special", "lcd-generic",
  388. };
  389. static const char *jz4725b_nand_groups[] = {
  390. "nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4",
  391. "nand-cle-ale", "nand-fre-fwe",
  392. };
  393. static const char *jz4725b_pwm0_groups[] = { "pwm0", };
  394. static const char *jz4725b_pwm1_groups[] = { "pwm1", };
  395. static const char *jz4725b_pwm2_groups[] = { "pwm2", };
  396. static const char *jz4725b_pwm3_groups[] = { "pwm3", };
  397. static const char *jz4725b_pwm4_groups[] = { "pwm4", };
  398. static const char *jz4725b_pwm5_groups[] = { "pwm5", };
  399. static const struct function_desc jz4725b_functions[] = {
  400. { "mmc0", jz4725b_mmc0_groups, ARRAY_SIZE(jz4725b_mmc0_groups), },
  401. { "mmc1", jz4725b_mmc1_groups, ARRAY_SIZE(jz4725b_mmc1_groups), },
  402. { "uart", jz4725b_uart_groups, ARRAY_SIZE(jz4725b_uart_groups), },
  403. { "nand", jz4725b_nand_groups, ARRAY_SIZE(jz4725b_nand_groups), },
  404. { "pwm0", jz4725b_pwm0_groups, ARRAY_SIZE(jz4725b_pwm0_groups), },
  405. { "pwm1", jz4725b_pwm1_groups, ARRAY_SIZE(jz4725b_pwm1_groups), },
  406. { "pwm2", jz4725b_pwm2_groups, ARRAY_SIZE(jz4725b_pwm2_groups), },
  407. { "pwm3", jz4725b_pwm3_groups, ARRAY_SIZE(jz4725b_pwm3_groups), },
  408. { "pwm4", jz4725b_pwm4_groups, ARRAY_SIZE(jz4725b_pwm4_groups), },
  409. { "pwm5", jz4725b_pwm5_groups, ARRAY_SIZE(jz4725b_pwm5_groups), },
  410. { "lcd", jz4725b_lcd_groups, ARRAY_SIZE(jz4725b_lcd_groups), },
  411. };
  412. static const struct ingenic_chip_info jz4725b_chip_info = {
  413. .num_chips = 4,
  414. .reg_offset = 0x100,
  415. .version = ID_JZ4725B,
  416. .groups = jz4725b_groups,
  417. .num_groups = ARRAY_SIZE(jz4725b_groups),
  418. .functions = jz4725b_functions,
  419. .num_functions = ARRAY_SIZE(jz4725b_functions),
  420. .pull_ups = jz4740_pull_ups,
  421. .pull_downs = jz4740_pull_downs,
  422. };
  423. static const u32 jz4750_pull_ups[6] = {
  424. 0xffffffff, 0xffffffff, 0x3fffffff, 0x7fffffff, 0x1fff3fff, 0x00ffffff,
  425. };
  426. static const u32 jz4750_pull_downs[6] = {
  427. 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  428. };
  429. static int jz4750_uart0_data_pins[] = { 0xa4, 0xa5, };
  430. static int jz4750_uart0_hwflow_pins[] = { 0xa6, 0xa7, };
  431. static int jz4750_uart1_data_pins[] = { 0x90, 0x91, };
  432. static int jz4750_uart1_hwflow_pins[] = { 0x92, 0x93, };
  433. static int jz4750_uart2_data_pins[] = { 0x9b, 0x9a, };
  434. static int jz4750_uart3_data_pins[] = { 0xb0, 0xb1, };
  435. static int jz4750_uart3_hwflow_pins[] = { 0xb2, 0xb3, };
  436. static int jz4750_mmc0_1bit_pins[] = { 0xa8, 0xa9, 0xa0, };
  437. static int jz4750_mmc0_4bit_pins[] = { 0xa1, 0xa2, 0xa3, };
  438. static int jz4750_mmc0_8bit_pins[] = { 0xa4, 0xa5, 0xa6, 0xa7, };
  439. static int jz4750_mmc1_1bit_pins[] = { 0xae, 0xaf, 0xaa, };
  440. static int jz4750_mmc1_4bit_pins[] = { 0xab, 0xac, 0xad, };
  441. static int jz4750_i2c_pins[] = { 0x8c, 0x8d, };
  442. static int jz4750_cim_pins[] = {
  443. 0x89, 0x8b, 0x8a, 0x88,
  444. 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
  445. };
  446. static int jz4750_lcd_8bit_pins[] = {
  447. 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
  448. 0x72, 0x73, 0x74,
  449. };
  450. static int jz4750_lcd_16bit_pins[] = {
  451. 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
  452. };
  453. static int jz4750_lcd_18bit_pins[] = { 0x70, 0x71, };
  454. static int jz4750_lcd_24bit_pins[] = { 0x76, 0x77, 0x78, 0x79, 0xb2, 0xb3, };
  455. static int jz4750_lcd_special_pins[] = { 0x76, 0x77, 0x78, 0x79, };
  456. static int jz4750_lcd_generic_pins[] = { 0x75, };
  457. static int jz4750_nand_cs1_pins[] = { 0x55, };
  458. static int jz4750_nand_cs2_pins[] = { 0x56, };
  459. static int jz4750_nand_cs3_pins[] = { 0x57, };
  460. static int jz4750_nand_cs4_pins[] = { 0x58, };
  461. static int jz4750_nand_fre_fwe_pins[] = { 0x5c, 0x5d, };
  462. static int jz4750_pwm_pwm0_pins[] = { 0x94, };
  463. static int jz4750_pwm_pwm1_pins[] = { 0x95, };
  464. static int jz4750_pwm_pwm2_pins[] = { 0x96, };
  465. static int jz4750_pwm_pwm3_pins[] = { 0x97, };
  466. static int jz4750_pwm_pwm4_pins[] = { 0x98, };
  467. static int jz4750_pwm_pwm5_pins[] = { 0x99, };
  468. static const struct group_desc jz4750_groups[] = {
  469. INGENIC_PIN_GROUP("uart0-data", jz4750_uart0_data, 1),
  470. INGENIC_PIN_GROUP("uart0-hwflow", jz4750_uart0_hwflow, 1),
  471. INGENIC_PIN_GROUP("uart1-data", jz4750_uart1_data, 0),
  472. INGENIC_PIN_GROUP("uart1-hwflow", jz4750_uart1_hwflow, 0),
  473. INGENIC_PIN_GROUP("uart2-data", jz4750_uart2_data, 1),
  474. INGENIC_PIN_GROUP("uart3-data", jz4750_uart3_data, 0),
  475. INGENIC_PIN_GROUP("uart3-hwflow", jz4750_uart3_hwflow, 0),
  476. INGENIC_PIN_GROUP("mmc0-1bit", jz4750_mmc0_1bit, 0),
  477. INGENIC_PIN_GROUP("mmc0-4bit", jz4750_mmc0_4bit, 0),
  478. INGENIC_PIN_GROUP("mmc0-8bit", jz4750_mmc0_8bit, 0),
  479. INGENIC_PIN_GROUP("mmc1-1bit", jz4750_mmc1_1bit, 0),
  480. INGENIC_PIN_GROUP("mmc1-4bit", jz4750_mmc1_4bit, 0),
  481. INGENIC_PIN_GROUP("i2c-data", jz4750_i2c, 0),
  482. INGENIC_PIN_GROUP("cim-data", jz4750_cim, 0),
  483. INGENIC_PIN_GROUP("lcd-8bit", jz4750_lcd_8bit, 0),
  484. INGENIC_PIN_GROUP("lcd-16bit", jz4750_lcd_16bit, 0),
  485. INGENIC_PIN_GROUP("lcd-18bit", jz4750_lcd_18bit, 0),
  486. INGENIC_PIN_GROUP("lcd-24bit", jz4750_lcd_24bit, 1),
  487. INGENIC_PIN_GROUP("lcd-special", jz4750_lcd_special, 0),
  488. INGENIC_PIN_GROUP("lcd-generic", jz4750_lcd_generic, 0),
  489. INGENIC_PIN_GROUP("nand-cs1", jz4750_nand_cs1, 0),
  490. INGENIC_PIN_GROUP("nand-cs2", jz4750_nand_cs2, 0),
  491. INGENIC_PIN_GROUP("nand-cs3", jz4750_nand_cs3, 0),
  492. INGENIC_PIN_GROUP("nand-cs4", jz4750_nand_cs4, 0),
  493. INGENIC_PIN_GROUP("nand-fre-fwe", jz4750_nand_fre_fwe, 0),
  494. INGENIC_PIN_GROUP("pwm0", jz4750_pwm_pwm0, 0),
  495. INGENIC_PIN_GROUP("pwm1", jz4750_pwm_pwm1, 0),
  496. INGENIC_PIN_GROUP("pwm2", jz4750_pwm_pwm2, 0),
  497. INGENIC_PIN_GROUP("pwm3", jz4750_pwm_pwm3, 0),
  498. INGENIC_PIN_GROUP("pwm4", jz4750_pwm_pwm4, 0),
  499. INGENIC_PIN_GROUP("pwm5", jz4750_pwm_pwm5, 0),
  500. };
  501. static const char *jz4750_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
  502. static const char *jz4750_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
  503. static const char *jz4750_uart2_groups[] = { "uart2-data", };
  504. static const char *jz4750_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
  505. static const char *jz4750_mmc0_groups[] = {
  506. "mmc0-1bit", "mmc0-4bit", "mmc0-8bit",
  507. };
  508. static const char *jz4750_mmc1_groups[] = { "mmc0-1bit", "mmc0-4bit", };
  509. static const char *jz4750_i2c_groups[] = { "i2c-data", };
  510. static const char *jz4750_cim_groups[] = { "cim-data", };
  511. static const char *jz4750_lcd_groups[] = {
  512. "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
  513. "lcd-special", "lcd-generic",
  514. };
  515. static const char *jz4750_nand_groups[] = {
  516. "nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4", "nand-fre-fwe",
  517. };
  518. static const char *jz4750_pwm0_groups[] = { "pwm0", };
  519. static const char *jz4750_pwm1_groups[] = { "pwm1", };
  520. static const char *jz4750_pwm2_groups[] = { "pwm2", };
  521. static const char *jz4750_pwm3_groups[] = { "pwm3", };
  522. static const char *jz4750_pwm4_groups[] = { "pwm4", };
  523. static const char *jz4750_pwm5_groups[] = { "pwm5", };
  524. static const struct function_desc jz4750_functions[] = {
  525. { "uart0", jz4750_uart0_groups, ARRAY_SIZE(jz4750_uart0_groups), },
  526. { "uart1", jz4750_uart1_groups, ARRAY_SIZE(jz4750_uart1_groups), },
  527. { "uart2", jz4750_uart2_groups, ARRAY_SIZE(jz4750_uart2_groups), },
  528. { "uart3", jz4750_uart3_groups, ARRAY_SIZE(jz4750_uart3_groups), },
  529. { "mmc0", jz4750_mmc0_groups, ARRAY_SIZE(jz4750_mmc0_groups), },
  530. { "mmc1", jz4750_mmc1_groups, ARRAY_SIZE(jz4750_mmc1_groups), },
  531. { "i2c", jz4750_i2c_groups, ARRAY_SIZE(jz4750_i2c_groups), },
  532. { "cim", jz4750_cim_groups, ARRAY_SIZE(jz4750_cim_groups), },
  533. { "lcd", jz4750_lcd_groups, ARRAY_SIZE(jz4750_lcd_groups), },
  534. { "nand", jz4750_nand_groups, ARRAY_SIZE(jz4750_nand_groups), },
  535. { "pwm0", jz4750_pwm0_groups, ARRAY_SIZE(jz4750_pwm0_groups), },
  536. { "pwm1", jz4750_pwm1_groups, ARRAY_SIZE(jz4750_pwm1_groups), },
  537. { "pwm2", jz4750_pwm2_groups, ARRAY_SIZE(jz4750_pwm2_groups), },
  538. { "pwm3", jz4750_pwm3_groups, ARRAY_SIZE(jz4750_pwm3_groups), },
  539. { "pwm4", jz4750_pwm4_groups, ARRAY_SIZE(jz4750_pwm4_groups), },
  540. { "pwm5", jz4750_pwm5_groups, ARRAY_SIZE(jz4750_pwm5_groups), },
  541. };
  542. static const struct ingenic_chip_info jz4750_chip_info = {
  543. .num_chips = 6,
  544. .reg_offset = 0x100,
  545. .version = ID_JZ4750,
  546. .groups = jz4750_groups,
  547. .num_groups = ARRAY_SIZE(jz4750_groups),
  548. .functions = jz4750_functions,
  549. .num_functions = ARRAY_SIZE(jz4750_functions),
  550. .pull_ups = jz4750_pull_ups,
  551. .pull_downs = jz4750_pull_downs,
  552. };
  553. static const u32 jz4755_pull_ups[6] = {
  554. 0xffffffff, 0xffffffff, 0x0fffffff, 0xffffffff, 0x33dc3fff, 0x0000fc00,
  555. };
  556. static const u32 jz4755_pull_downs[6] = {
  557. 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  558. };
  559. static int jz4755_uart0_data_pins[] = { 0x7c, 0x7d, };
  560. static int jz4755_uart0_hwflow_pins[] = { 0x7e, 0x7f, };
  561. static int jz4755_uart1_data_pins[] = { 0x97, 0x99, };
  562. static int jz4755_uart2_data_pins[] = { 0x9f, };
  563. static int jz4755_ssi_dt_b_pins[] = { 0x3b, };
  564. static int jz4755_ssi_dt_f_pins[] = { 0xa1, };
  565. static int jz4755_ssi_dr_b_pins[] = { 0x3c, };
  566. static int jz4755_ssi_dr_f_pins[] = { 0xa2, };
  567. static int jz4755_ssi_clk_b_pins[] = { 0x3a, };
  568. static int jz4755_ssi_clk_f_pins[] = { 0xa0, };
  569. static int jz4755_ssi_gpc_b_pins[] = { 0x3e, };
  570. static int jz4755_ssi_gpc_f_pins[] = { 0xa4, };
  571. static int jz4755_ssi_ce0_b_pins[] = { 0x3d, };
  572. static int jz4755_ssi_ce0_f_pins[] = { 0xa3, };
  573. static int jz4755_ssi_ce1_b_pins[] = { 0x3f, };
  574. static int jz4755_ssi_ce1_f_pins[] = { 0xa5, };
  575. static int jz4755_mmc0_1bit_pins[] = { 0x2f, 0x50, 0x5c, };
  576. static int jz4755_mmc0_4bit_pins[] = { 0x5d, 0x5b, 0x51, };
  577. static int jz4755_mmc1_1bit_pins[] = { 0x3a, 0x3d, 0x3c, };
  578. static int jz4755_mmc1_4bit_pins[] = { 0x3b, 0x3e, 0x3f, };
  579. static int jz4755_i2c_pins[] = { 0x8c, 0x8d, };
  580. static int jz4755_cim_pins[] = {
  581. 0x89, 0x8b, 0x8a, 0x88,
  582. 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
  583. };
  584. static int jz4755_lcd_8bit_pins[] = {
  585. 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
  586. 0x72, 0x73, 0x74,
  587. };
  588. static int jz4755_lcd_16bit_pins[] = {
  589. 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
  590. };
  591. static int jz4755_lcd_18bit_pins[] = { 0x70, 0x71, };
  592. static int jz4755_lcd_24bit_pins[] = { 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, };
  593. static int jz4755_lcd_special_pins[] = { 0x76, 0x77, 0x78, 0x79, };
  594. static int jz4755_lcd_generic_pins[] = { 0x75, };
  595. static int jz4755_nand_cs1_pins[] = { 0x55, };
  596. static int jz4755_nand_cs2_pins[] = { 0x56, };
  597. static int jz4755_nand_cs3_pins[] = { 0x57, };
  598. static int jz4755_nand_cs4_pins[] = { 0x58, };
  599. static int jz4755_nand_fre_fwe_pins[] = { 0x5c, 0x5d, };
  600. static int jz4755_pwm_pwm0_pins[] = { 0x94, };
  601. static int jz4755_pwm_pwm1_pins[] = { 0xab, };
  602. static int jz4755_pwm_pwm2_pins[] = { 0x96, };
  603. static int jz4755_pwm_pwm3_pins[] = { 0x97, };
  604. static int jz4755_pwm_pwm4_pins[] = { 0x98, };
  605. static int jz4755_pwm_pwm5_pins[] = { 0x99, };
  606. static u8 jz4755_mmc0_1bit_funcs[] = { 2, 2, 1, };
  607. static u8 jz4755_mmc0_4bit_funcs[] = { 1, 0, 1, };
  608. static u8 jz4755_lcd_24bit_funcs[] = { 1, 1, 1, 1, 0, 0, };
  609. static const struct group_desc jz4755_groups[] = {
  610. INGENIC_PIN_GROUP("uart0-data", jz4755_uart0_data, 0),
  611. INGENIC_PIN_GROUP("uart0-hwflow", jz4755_uart0_hwflow, 0),
  612. INGENIC_PIN_GROUP("uart1-data", jz4755_uart1_data, 1),
  613. INGENIC_PIN_GROUP("uart2-data", jz4755_uart2_data, 1),
  614. INGENIC_PIN_GROUP("ssi-dt-b", jz4755_ssi_dt_b, 0),
  615. INGENIC_PIN_GROUP("ssi-dt-f", jz4755_ssi_dt_f, 0),
  616. INGENIC_PIN_GROUP("ssi-dr-b", jz4755_ssi_dr_b, 0),
  617. INGENIC_PIN_GROUP("ssi-dr-f", jz4755_ssi_dr_f, 0),
  618. INGENIC_PIN_GROUP("ssi-clk-b", jz4755_ssi_clk_b, 0),
  619. INGENIC_PIN_GROUP("ssi-clk-f", jz4755_ssi_clk_f, 0),
  620. INGENIC_PIN_GROUP("ssi-gpc-b", jz4755_ssi_gpc_b, 0),
  621. INGENIC_PIN_GROUP("ssi-gpc-f", jz4755_ssi_gpc_f, 0),
  622. INGENIC_PIN_GROUP("ssi-ce0-b", jz4755_ssi_ce0_b, 0),
  623. INGENIC_PIN_GROUP("ssi-ce0-f", jz4755_ssi_ce0_f, 0),
  624. INGENIC_PIN_GROUP("ssi-ce1-b", jz4755_ssi_ce1_b, 0),
  625. INGENIC_PIN_GROUP("ssi-ce1-f", jz4755_ssi_ce1_f, 0),
  626. INGENIC_PIN_GROUP_FUNCS("mmc0-1bit", jz4755_mmc0_1bit,
  627. jz4755_mmc0_1bit_funcs),
  628. INGENIC_PIN_GROUP_FUNCS("mmc0-4bit", jz4755_mmc0_4bit,
  629. jz4755_mmc0_4bit_funcs),
  630. INGENIC_PIN_GROUP("mmc1-1bit", jz4755_mmc1_1bit, 1),
  631. INGENIC_PIN_GROUP("mmc1-4bit", jz4755_mmc1_4bit, 1),
  632. INGENIC_PIN_GROUP("i2c-data", jz4755_i2c, 0),
  633. INGENIC_PIN_GROUP("cim-data", jz4755_cim, 0),
  634. INGENIC_PIN_GROUP("lcd-8bit", jz4755_lcd_8bit, 0),
  635. INGENIC_PIN_GROUP("lcd-16bit", jz4755_lcd_16bit, 0),
  636. INGENIC_PIN_GROUP("lcd-18bit", jz4755_lcd_18bit, 0),
  637. INGENIC_PIN_GROUP_FUNCS("lcd-24bit", jz4755_lcd_24bit,
  638. jz4755_lcd_24bit_funcs),
  639. INGENIC_PIN_GROUP("lcd-special", jz4755_lcd_special, 0),
  640. INGENIC_PIN_GROUP("lcd-generic", jz4755_lcd_generic, 0),
  641. INGENIC_PIN_GROUP("nand-cs1", jz4755_nand_cs1, 0),
  642. INGENIC_PIN_GROUP("nand-cs2", jz4755_nand_cs2, 0),
  643. INGENIC_PIN_GROUP("nand-cs3", jz4755_nand_cs3, 0),
  644. INGENIC_PIN_GROUP("nand-cs4", jz4755_nand_cs4, 0),
  645. INGENIC_PIN_GROUP("nand-fre-fwe", jz4755_nand_fre_fwe, 0),
  646. INGENIC_PIN_GROUP("pwm0", jz4755_pwm_pwm0, 0),
  647. INGENIC_PIN_GROUP("pwm1", jz4755_pwm_pwm1, 1),
  648. INGENIC_PIN_GROUP("pwm2", jz4755_pwm_pwm2, 0),
  649. INGENIC_PIN_GROUP("pwm3", jz4755_pwm_pwm3, 0),
  650. INGENIC_PIN_GROUP("pwm4", jz4755_pwm_pwm4, 0),
  651. INGENIC_PIN_GROUP("pwm5", jz4755_pwm_pwm5, 0),
  652. };
  653. static const char *jz4755_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
  654. static const char *jz4755_uart1_groups[] = { "uart1-data", };
  655. static const char *jz4755_uart2_groups[] = { "uart2-data", };
  656. static const char *jz4755_ssi_groups[] = {
  657. "ssi-dt-b", "ssi-dt-f",
  658. "ssi-dr-b", "ssi-dr-f",
  659. "ssi-clk-b", "ssi-clk-f",
  660. "ssi-gpc-b", "ssi-gpc-f",
  661. "ssi-ce0-b", "ssi-ce0-f",
  662. "ssi-ce1-b", "ssi-ce1-f",
  663. };
  664. static const char *jz4755_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", };
  665. static const char *jz4755_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
  666. static const char *jz4755_i2c_groups[] = { "i2c-data", };
  667. static const char *jz4755_cim_groups[] = { "cim-data", };
  668. static const char *jz4755_lcd_groups[] = {
  669. "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
  670. "lcd-special", "lcd-generic",
  671. };
  672. static const char *jz4755_nand_groups[] = {
  673. "nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4", "nand-fre-fwe",
  674. };
  675. static const char *jz4755_pwm0_groups[] = { "pwm0", };
  676. static const char *jz4755_pwm1_groups[] = { "pwm1", };
  677. static const char *jz4755_pwm2_groups[] = { "pwm2", };
  678. static const char *jz4755_pwm3_groups[] = { "pwm3", };
  679. static const char *jz4755_pwm4_groups[] = { "pwm4", };
  680. static const char *jz4755_pwm5_groups[] = { "pwm5", };
  681. static const struct function_desc jz4755_functions[] = {
  682. { "uart0", jz4755_uart0_groups, ARRAY_SIZE(jz4755_uart0_groups), },
  683. { "uart1", jz4755_uart1_groups, ARRAY_SIZE(jz4755_uart1_groups), },
  684. { "uart2", jz4755_uart2_groups, ARRAY_SIZE(jz4755_uart2_groups), },
  685. { "ssi", jz4755_ssi_groups, ARRAY_SIZE(jz4755_ssi_groups), },
  686. { "mmc0", jz4755_mmc0_groups, ARRAY_SIZE(jz4755_mmc0_groups), },
  687. { "mmc1", jz4755_mmc1_groups, ARRAY_SIZE(jz4755_mmc1_groups), },
  688. { "i2c", jz4755_i2c_groups, ARRAY_SIZE(jz4755_i2c_groups), },
  689. { "cim", jz4755_cim_groups, ARRAY_SIZE(jz4755_cim_groups), },
  690. { "lcd", jz4755_lcd_groups, ARRAY_SIZE(jz4755_lcd_groups), },
  691. { "nand", jz4755_nand_groups, ARRAY_SIZE(jz4755_nand_groups), },
  692. { "pwm0", jz4755_pwm0_groups, ARRAY_SIZE(jz4755_pwm0_groups), },
  693. { "pwm1", jz4755_pwm1_groups, ARRAY_SIZE(jz4755_pwm1_groups), },
  694. { "pwm2", jz4755_pwm2_groups, ARRAY_SIZE(jz4755_pwm2_groups), },
  695. { "pwm3", jz4755_pwm3_groups, ARRAY_SIZE(jz4755_pwm3_groups), },
  696. { "pwm4", jz4755_pwm4_groups, ARRAY_SIZE(jz4755_pwm4_groups), },
  697. { "pwm5", jz4755_pwm5_groups, ARRAY_SIZE(jz4755_pwm5_groups), },
  698. };
  699. static const struct ingenic_chip_info jz4755_chip_info = {
  700. .num_chips = 6,
  701. .reg_offset = 0x100,
  702. .version = ID_JZ4755,
  703. .groups = jz4755_groups,
  704. .num_groups = ARRAY_SIZE(jz4755_groups),
  705. .functions = jz4755_functions,
  706. .num_functions = ARRAY_SIZE(jz4755_functions),
  707. .pull_ups = jz4755_pull_ups,
  708. .pull_downs = jz4755_pull_downs,
  709. };
  710. static const u32 jz4760_pull_ups[6] = {
  711. 0xffffffff, 0xfffcf3ff, 0xffffffff, 0xffffcfff, 0xfffffb7c, 0x0000000f,
  712. };
  713. static const u32 jz4760_pull_downs[6] = {
  714. 0x00000000, 0x00030c00, 0x00000000, 0x00003000, 0x00000483, 0x00000ff0,
  715. };
  716. static int jz4760_uart0_data_pins[] = { 0xa0, 0xa3, };
  717. static int jz4760_uart0_hwflow_pins[] = { 0xa1, 0xa2, };
  718. static int jz4760_uart1_data_pins[] = { 0x7a, 0x7c, };
  719. static int jz4760_uart1_hwflow_pins[] = { 0x7b, 0x7d, };
  720. static int jz4760_uart2_data_pins[] = { 0x5c, 0x5e, };
  721. static int jz4760_uart2_hwflow_pins[] = { 0x5d, 0x5f, };
  722. static int jz4760_uart3_data_pins[] = { 0x6c, 0x85, };
  723. static int jz4760_uart3_hwflow_pins[] = { 0x88, 0x89, };
  724. static int jz4760_ssi0_dt_a_pins[] = { 0x15, };
  725. static int jz4760_ssi0_dt_b_pins[] = { 0x35, };
  726. static int jz4760_ssi0_dt_d_pins[] = { 0x75, };
  727. static int jz4760_ssi0_dt_e_pins[] = { 0x91, };
  728. static int jz4760_ssi0_dr_a_pins[] = { 0x14, };
  729. static int jz4760_ssi0_dr_b_pins[] = { 0x34, };
  730. static int jz4760_ssi0_dr_d_pins[] = { 0x74, };
  731. static int jz4760_ssi0_dr_e_pins[] = { 0x8e, };
  732. static int jz4760_ssi0_clk_a_pins[] = { 0x12, };
  733. static int jz4760_ssi0_clk_b_pins[] = { 0x3c, };
  734. static int jz4760_ssi0_clk_d_pins[] = { 0x78, };
  735. static int jz4760_ssi0_clk_e_pins[] = { 0x8f, };
  736. static int jz4760_ssi0_gpc_b_pins[] = { 0x3e, };
  737. static int jz4760_ssi0_gpc_d_pins[] = { 0x76, };
  738. static int jz4760_ssi0_gpc_e_pins[] = { 0x93, };
  739. static int jz4760_ssi0_ce0_a_pins[] = { 0x13, };
  740. static int jz4760_ssi0_ce0_b_pins[] = { 0x3d, };
  741. static int jz4760_ssi0_ce0_d_pins[] = { 0x79, };
  742. static int jz4760_ssi0_ce0_e_pins[] = { 0x90, };
  743. static int jz4760_ssi0_ce1_b_pins[] = { 0x3f, };
  744. static int jz4760_ssi0_ce1_d_pins[] = { 0x77, };
  745. static int jz4760_ssi0_ce1_e_pins[] = { 0x92, };
  746. static int jz4760_ssi1_dt_b_9_pins[] = { 0x29, };
  747. static int jz4760_ssi1_dt_b_21_pins[] = { 0x35, };
  748. static int jz4760_ssi1_dt_d_12_pins[] = { 0x6c, };
  749. static int jz4760_ssi1_dt_d_21_pins[] = { 0x75, };
  750. static int jz4760_ssi1_dt_e_pins[] = { 0x91, };
  751. static int jz4760_ssi1_dt_f_pins[] = { 0xa3, };
  752. static int jz4760_ssi1_dr_b_6_pins[] = { 0x26, };
  753. static int jz4760_ssi1_dr_b_20_pins[] = { 0x34, };
  754. static int jz4760_ssi1_dr_d_13_pins[] = { 0x6d, };
  755. static int jz4760_ssi1_dr_d_20_pins[] = { 0x74, };
  756. static int jz4760_ssi1_dr_e_pins[] = { 0x8e, };
  757. static int jz4760_ssi1_dr_f_pins[] = { 0xa0, };
  758. static int jz4760_ssi1_clk_b_7_pins[] = { 0x27, };
  759. static int jz4760_ssi1_clk_b_28_pins[] = { 0x3c, };
  760. static int jz4760_ssi1_clk_d_pins[] = { 0x78, };
  761. static int jz4760_ssi1_clk_e_7_pins[] = { 0x87, };
  762. static int jz4760_ssi1_clk_e_15_pins[] = { 0x8f, };
  763. static int jz4760_ssi1_clk_f_pins[] = { 0xa2, };
  764. static int jz4760_ssi1_gpc_b_pins[] = { 0x3e, };
  765. static int jz4760_ssi1_gpc_d_pins[] = { 0x76, };
  766. static int jz4760_ssi1_gpc_e_pins[] = { 0x93, };
  767. static int jz4760_ssi1_ce0_b_8_pins[] = { 0x28, };
  768. static int jz4760_ssi1_ce0_b_29_pins[] = { 0x3d, };
  769. static int jz4760_ssi1_ce0_d_pins[] = { 0x79, };
  770. static int jz4760_ssi1_ce0_e_6_pins[] = { 0x86, };
  771. static int jz4760_ssi1_ce0_e_16_pins[] = { 0x90, };
  772. static int jz4760_ssi1_ce0_f_pins[] = { 0xa1, };
  773. static int jz4760_ssi1_ce1_b_pins[] = { 0x3f, };
  774. static int jz4760_ssi1_ce1_d_pins[] = { 0x77, };
  775. static int jz4760_ssi1_ce1_e_pins[] = { 0x92, };
  776. static int jz4760_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, };
  777. static int jz4760_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, };
  778. static int jz4760_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
  779. static int jz4760_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
  780. static int jz4760_mmc0_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
  781. static int jz4760_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, };
  782. static int jz4760_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, };
  783. static int jz4760_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
  784. static int jz4760_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
  785. static int jz4760_mmc1_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
  786. static int jz4760_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, };
  787. static int jz4760_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, };
  788. static int jz4760_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
  789. static int jz4760_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
  790. static int jz4760_mmc2_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
  791. static int jz4760_nemc_8bit_data_pins[] = {
  792. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  793. };
  794. static int jz4760_nemc_16bit_data_pins[] = {
  795. 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
  796. };
  797. static int jz4760_nemc_cle_ale_pins[] = { 0x20, 0x21, };
  798. static int jz4760_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, };
  799. static int jz4760_nemc_rd_we_pins[] = { 0x10, 0x11, };
  800. static int jz4760_nemc_frd_fwe_pins[] = { 0x12, 0x13, };
  801. static int jz4760_nemc_wait_pins[] = { 0x1b, };
  802. static int jz4760_nemc_cs1_pins[] = { 0x15, };
  803. static int jz4760_nemc_cs2_pins[] = { 0x16, };
  804. static int jz4760_nemc_cs3_pins[] = { 0x17, };
  805. static int jz4760_nemc_cs4_pins[] = { 0x18, };
  806. static int jz4760_nemc_cs5_pins[] = { 0x19, };
  807. static int jz4760_nemc_cs6_pins[] = { 0x1a, };
  808. static int jz4760_i2c0_pins[] = { 0x7e, 0x7f, };
  809. static int jz4760_i2c1_pins[] = { 0x9e, 0x9f, };
  810. static int jz4760_cim_pins[] = {
  811. 0x26, 0x27, 0x28, 0x29,
  812. 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
  813. };
  814. static int jz4760_lcd_8bit_pins[] = {
  815. 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x4c,
  816. 0x4d, 0x52, 0x53,
  817. };
  818. static int jz4760_lcd_16bit_pins[] = {
  819. 0x4e, 0x4f, 0x50, 0x51, 0x56, 0x57, 0x58, 0x59,
  820. };
  821. static int jz4760_lcd_18bit_pins[] = {
  822. 0x5a, 0x5b,
  823. };
  824. static int jz4760_lcd_24bit_pins[] = {
  825. 0x40, 0x41, 0x4a, 0x4b, 0x54, 0x55,
  826. };
  827. static int jz4760_lcd_special_pins[] = { 0x54, 0x4a, 0x41, 0x40, };
  828. static int jz4760_lcd_generic_pins[] = { 0x49, };
  829. static int jz4760_pwm_pwm0_pins[] = { 0x80, };
  830. static int jz4760_pwm_pwm1_pins[] = { 0x81, };
  831. static int jz4760_pwm_pwm2_pins[] = { 0x82, };
  832. static int jz4760_pwm_pwm3_pins[] = { 0x83, };
  833. static int jz4760_pwm_pwm4_pins[] = { 0x84, };
  834. static int jz4760_pwm_pwm5_pins[] = { 0x85, };
  835. static int jz4760_pwm_pwm6_pins[] = { 0x6a, };
  836. static int jz4760_pwm_pwm7_pins[] = { 0x6b, };
  837. static int jz4760_otg_pins[] = { 0x8a, };
  838. static u8 jz4760_uart3_data_funcs[] = { 0, 1, };
  839. static u8 jz4760_mmc0_1bit_a_funcs[] = { 1, 1, 0, };
  840. static const struct group_desc jz4760_groups[] = {
  841. INGENIC_PIN_GROUP("uart0-data", jz4760_uart0_data, 0),
  842. INGENIC_PIN_GROUP("uart0-hwflow", jz4760_uart0_hwflow, 0),
  843. INGENIC_PIN_GROUP("uart1-data", jz4760_uart1_data, 0),
  844. INGENIC_PIN_GROUP("uart1-hwflow", jz4760_uart1_hwflow, 0),
  845. INGENIC_PIN_GROUP("uart2-data", jz4760_uart2_data, 0),
  846. INGENIC_PIN_GROUP("uart2-hwflow", jz4760_uart2_hwflow, 0),
  847. INGENIC_PIN_GROUP_FUNCS("uart3-data", jz4760_uart3_data,
  848. jz4760_uart3_data_funcs),
  849. INGENIC_PIN_GROUP("uart3-hwflow", jz4760_uart3_hwflow, 0),
  850. INGENIC_PIN_GROUP("ssi0-dt-a", jz4760_ssi0_dt_a, 2),
  851. INGENIC_PIN_GROUP("ssi0-dt-b", jz4760_ssi0_dt_b, 1),
  852. INGENIC_PIN_GROUP("ssi0-dt-d", jz4760_ssi0_dt_d, 1),
  853. INGENIC_PIN_GROUP("ssi0-dt-e", jz4760_ssi0_dt_e, 0),
  854. INGENIC_PIN_GROUP("ssi0-dr-a", jz4760_ssi0_dr_a, 1),
  855. INGENIC_PIN_GROUP("ssi0-dr-b", jz4760_ssi0_dr_b, 1),
  856. INGENIC_PIN_GROUP("ssi0-dr-d", jz4760_ssi0_dr_d, 1),
  857. INGENIC_PIN_GROUP("ssi0-dr-e", jz4760_ssi0_dr_e, 0),
  858. INGENIC_PIN_GROUP("ssi0-clk-a", jz4760_ssi0_clk_a, 2),
  859. INGENIC_PIN_GROUP("ssi0-clk-b", jz4760_ssi0_clk_b, 1),
  860. INGENIC_PIN_GROUP("ssi0-clk-d", jz4760_ssi0_clk_d, 1),
  861. INGENIC_PIN_GROUP("ssi0-clk-e", jz4760_ssi0_clk_e, 0),
  862. INGENIC_PIN_GROUP("ssi0-gpc-b", jz4760_ssi0_gpc_b, 1),
  863. INGENIC_PIN_GROUP("ssi0-gpc-d", jz4760_ssi0_gpc_d, 1),
  864. INGENIC_PIN_GROUP("ssi0-gpc-e", jz4760_ssi0_gpc_e, 0),
  865. INGENIC_PIN_GROUP("ssi0-ce0-a", jz4760_ssi0_ce0_a, 2),
  866. INGENIC_PIN_GROUP("ssi0-ce0-b", jz4760_ssi0_ce0_b, 1),
  867. INGENIC_PIN_GROUP("ssi0-ce0-d", jz4760_ssi0_ce0_d, 1),
  868. INGENIC_PIN_GROUP("ssi0-ce0-e", jz4760_ssi0_ce0_e, 0),
  869. INGENIC_PIN_GROUP("ssi0-ce1-b", jz4760_ssi0_ce1_b, 1),
  870. INGENIC_PIN_GROUP("ssi0-ce1-d", jz4760_ssi0_ce1_d, 1),
  871. INGENIC_PIN_GROUP("ssi0-ce1-e", jz4760_ssi0_ce1_e, 0),
  872. INGENIC_PIN_GROUP("ssi1-dt-b-9", jz4760_ssi1_dt_b_9, 2),
  873. INGENIC_PIN_GROUP("ssi1-dt-b-21", jz4760_ssi1_dt_b_21, 2),
  874. INGENIC_PIN_GROUP("ssi1-dt-d-12", jz4760_ssi1_dt_d_12, 2),
  875. INGENIC_PIN_GROUP("ssi1-dt-d-21", jz4760_ssi1_dt_d_21, 2),
  876. INGENIC_PIN_GROUP("ssi1-dt-e", jz4760_ssi1_dt_e, 1),
  877. INGENIC_PIN_GROUP("ssi1-dt-f", jz4760_ssi1_dt_f, 2),
  878. INGENIC_PIN_GROUP("ssi1-dr-b-6", jz4760_ssi1_dr_b_6, 2),
  879. INGENIC_PIN_GROUP("ssi1-dr-b-20", jz4760_ssi1_dr_b_20, 2),
  880. INGENIC_PIN_GROUP("ssi1-dr-d-13", jz4760_ssi1_dr_d_13, 2),
  881. INGENIC_PIN_GROUP("ssi1-dr-d-20", jz4760_ssi1_dr_d_20, 2),
  882. INGENIC_PIN_GROUP("ssi1-dr-e", jz4760_ssi1_dr_e, 1),
  883. INGENIC_PIN_GROUP("ssi1-dr-f", jz4760_ssi1_dr_f, 2),
  884. INGENIC_PIN_GROUP("ssi1-clk-b-7", jz4760_ssi1_clk_b_7, 2),
  885. INGENIC_PIN_GROUP("ssi1-clk-b-28", jz4760_ssi1_clk_b_28, 2),
  886. INGENIC_PIN_GROUP("ssi1-clk-d", jz4760_ssi1_clk_d, 2),
  887. INGENIC_PIN_GROUP("ssi1-clk-e-7", jz4760_ssi1_clk_e_7, 2),
  888. INGENIC_PIN_GROUP("ssi1-clk-e-15", jz4760_ssi1_clk_e_15, 1),
  889. INGENIC_PIN_GROUP("ssi1-clk-f", jz4760_ssi1_clk_f, 2),
  890. INGENIC_PIN_GROUP("ssi1-gpc-b", jz4760_ssi1_gpc_b, 2),
  891. INGENIC_PIN_GROUP("ssi1-gpc-d", jz4760_ssi1_gpc_d, 2),
  892. INGENIC_PIN_GROUP("ssi1-gpc-e", jz4760_ssi1_gpc_e, 1),
  893. INGENIC_PIN_GROUP("ssi1-ce0-b-8", jz4760_ssi1_ce0_b_8, 2),
  894. INGENIC_PIN_GROUP("ssi1-ce0-b-29", jz4760_ssi1_ce0_b_29, 2),
  895. INGENIC_PIN_GROUP("ssi1-ce0-d", jz4760_ssi1_ce0_d, 2),
  896. INGENIC_PIN_GROUP("ssi1-ce0-e-6", jz4760_ssi1_ce0_e_6, 2),
  897. INGENIC_PIN_GROUP("ssi1-ce0-e-16", jz4760_ssi1_ce0_e_16, 1),
  898. INGENIC_PIN_GROUP("ssi1-ce0-f", jz4760_ssi1_ce0_f, 2),
  899. INGENIC_PIN_GROUP("ssi1-ce1-b", jz4760_ssi1_ce1_b, 2),
  900. INGENIC_PIN_GROUP("ssi1-ce1-d", jz4760_ssi1_ce1_d, 2),
  901. INGENIC_PIN_GROUP("ssi1-ce1-e", jz4760_ssi1_ce1_e, 1),
  902. INGENIC_PIN_GROUP_FUNCS("mmc0-1bit-a", jz4760_mmc0_1bit_a,
  903. jz4760_mmc0_1bit_a_funcs),
  904. INGENIC_PIN_GROUP("mmc0-4bit-a", jz4760_mmc0_4bit_a, 1),
  905. INGENIC_PIN_GROUP("mmc0-1bit-e", jz4760_mmc0_1bit_e, 0),
  906. INGENIC_PIN_GROUP("mmc0-4bit-e", jz4760_mmc0_4bit_e, 0),
  907. INGENIC_PIN_GROUP("mmc0-8bit-e", jz4760_mmc0_8bit_e, 0),
  908. INGENIC_PIN_GROUP("mmc1-1bit-d", jz4760_mmc1_1bit_d, 0),
  909. INGENIC_PIN_GROUP("mmc1-4bit-d", jz4760_mmc1_4bit_d, 0),
  910. INGENIC_PIN_GROUP("mmc1-1bit-e", jz4760_mmc1_1bit_e, 1),
  911. INGENIC_PIN_GROUP("mmc1-4bit-e", jz4760_mmc1_4bit_e, 1),
  912. INGENIC_PIN_GROUP("mmc1-8bit-e", jz4760_mmc1_8bit_e, 1),
  913. INGENIC_PIN_GROUP("mmc2-1bit-b", jz4760_mmc2_1bit_b, 0),
  914. INGENIC_PIN_GROUP("mmc2-4bit-b", jz4760_mmc2_4bit_b, 0),
  915. INGENIC_PIN_GROUP("mmc2-1bit-e", jz4760_mmc2_1bit_e, 2),
  916. INGENIC_PIN_GROUP("mmc2-4bit-e", jz4760_mmc2_4bit_e, 2),
  917. INGENIC_PIN_GROUP("mmc2-8bit-e", jz4760_mmc2_8bit_e, 2),
  918. INGENIC_PIN_GROUP("nemc-8bit-data", jz4760_nemc_8bit_data, 0),
  919. INGENIC_PIN_GROUP("nemc-16bit-data", jz4760_nemc_16bit_data, 0),
  920. INGENIC_PIN_GROUP("nemc-cle-ale", jz4760_nemc_cle_ale, 0),
  921. INGENIC_PIN_GROUP("nemc-addr", jz4760_nemc_addr, 0),
  922. INGENIC_PIN_GROUP("nemc-rd-we", jz4760_nemc_rd_we, 0),
  923. INGENIC_PIN_GROUP("nemc-frd-fwe", jz4760_nemc_frd_fwe, 0),
  924. INGENIC_PIN_GROUP("nemc-wait", jz4760_nemc_wait, 0),
  925. INGENIC_PIN_GROUP("nemc-cs1", jz4760_nemc_cs1, 0),
  926. INGENIC_PIN_GROUP("nemc-cs2", jz4760_nemc_cs2, 0),
  927. INGENIC_PIN_GROUP("nemc-cs3", jz4760_nemc_cs3, 0),
  928. INGENIC_PIN_GROUP("nemc-cs4", jz4760_nemc_cs4, 0),
  929. INGENIC_PIN_GROUP("nemc-cs5", jz4760_nemc_cs5, 0),
  930. INGENIC_PIN_GROUP("nemc-cs6", jz4760_nemc_cs6, 0),
  931. INGENIC_PIN_GROUP("i2c0-data", jz4760_i2c0, 0),
  932. INGENIC_PIN_GROUP("i2c1-data", jz4760_i2c1, 0),
  933. INGENIC_PIN_GROUP("cim-data", jz4760_cim, 0),
  934. INGENIC_PIN_GROUP("lcd-8bit", jz4760_lcd_8bit, 0),
  935. INGENIC_PIN_GROUP("lcd-16bit", jz4760_lcd_16bit, 0),
  936. INGENIC_PIN_GROUP("lcd-18bit", jz4760_lcd_18bit, 0),
  937. INGENIC_PIN_GROUP("lcd-24bit", jz4760_lcd_24bit, 0),
  938. INGENIC_PIN_GROUP("lcd-special", jz4760_lcd_special, 1),
  939. INGENIC_PIN_GROUP("lcd-generic", jz4760_lcd_generic, 0),
  940. INGENIC_PIN_GROUP("pwm0", jz4760_pwm_pwm0, 0),
  941. INGENIC_PIN_GROUP("pwm1", jz4760_pwm_pwm1, 0),
  942. INGENIC_PIN_GROUP("pwm2", jz4760_pwm_pwm2, 0),
  943. INGENIC_PIN_GROUP("pwm3", jz4760_pwm_pwm3, 0),
  944. INGENIC_PIN_GROUP("pwm4", jz4760_pwm_pwm4, 0),
  945. INGENIC_PIN_GROUP("pwm5", jz4760_pwm_pwm5, 0),
  946. INGENIC_PIN_GROUP("pwm6", jz4760_pwm_pwm6, 0),
  947. INGENIC_PIN_GROUP("pwm7", jz4760_pwm_pwm7, 0),
  948. INGENIC_PIN_GROUP("otg-vbus", jz4760_otg, 0),
  949. };
  950. static const char *jz4760_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
  951. static const char *jz4760_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
  952. static const char *jz4760_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
  953. static const char *jz4760_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
  954. static const char *jz4760_ssi0_groups[] = {
  955. "ssi0-dt-a", "ssi0-dt-b", "ssi0-dt-d", "ssi0-dt-e",
  956. "ssi0-dr-a", "ssi0-dr-b", "ssi0-dr-d", "ssi0-dr-e",
  957. "ssi0-clk-a", "ssi0-clk-b", "ssi0-clk-d", "ssi0-clk-e",
  958. "ssi0-gpc-b", "ssi0-gpc-d", "ssi0-gpc-e",
  959. "ssi0-ce0-a", "ssi0-ce0-b", "ssi0-ce0-d", "ssi0-ce0-e",
  960. "ssi0-ce1-b", "ssi0-ce1-d", "ssi0-ce1-e",
  961. };
  962. static const char *jz4760_ssi1_groups[] = {
  963. "ssi1-dt-b-9", "ssi1-dt-b-21", "ssi1-dt-d-12", "ssi1-dt-d-21", "ssi1-dt-e", "ssi1-dt-f",
  964. "ssi1-dr-b-6", "ssi1-dr-b-20", "ssi1-dr-d-13", "ssi1-dr-d-20", "ssi1-dr-e", "ssi1-dr-f",
  965. "ssi1-clk-b-7", "ssi1-clk-b-28", "ssi1-clk-d", "ssi1-clk-e-7", "ssi1-clk-e-15", "ssi1-clk-f",
  966. "ssi1-gpc-b", "ssi1-gpc-d", "ssi1-gpc-e",
  967. "ssi1-ce0-b-8", "ssi1-ce0-b-29", "ssi1-ce0-d", "ssi1-ce0-e-6", "ssi1-ce0-e-16", "ssi1-ce0-f",
  968. "ssi1-ce1-b", "ssi1-ce1-d", "ssi1-ce1-e",
  969. };
  970. static const char *jz4760_mmc0_groups[] = {
  971. "mmc0-1bit-a", "mmc0-4bit-a",
  972. "mmc0-1bit-e", "mmc0-4bit-e", "mmc0-8bit-e",
  973. };
  974. static const char *jz4760_mmc1_groups[] = {
  975. "mmc1-1bit-d", "mmc1-4bit-d",
  976. "mmc1-1bit-e", "mmc1-4bit-e", "mmc1-8bit-e",
  977. };
  978. static const char *jz4760_mmc2_groups[] = {
  979. "mmc2-1bit-b", "mmc2-4bit-b",
  980. "mmc2-1bit-e", "mmc2-4bit-e", "mmc2-8bit-e",
  981. };
  982. static const char *jz4760_nemc_groups[] = {
  983. "nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale",
  984. "nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
  985. };
  986. static const char *jz4760_cs1_groups[] = { "nemc-cs1", };
  987. static const char *jz4760_cs2_groups[] = { "nemc-cs2", };
  988. static const char *jz4760_cs3_groups[] = { "nemc-cs3", };
  989. static const char *jz4760_cs4_groups[] = { "nemc-cs4", };
  990. static const char *jz4760_cs5_groups[] = { "nemc-cs5", };
  991. static const char *jz4760_cs6_groups[] = { "nemc-cs6", };
  992. static const char *jz4760_i2c0_groups[] = { "i2c0-data", };
  993. static const char *jz4760_i2c1_groups[] = { "i2c1-data", };
  994. static const char *jz4760_cim_groups[] = { "cim-data", };
  995. static const char *jz4760_lcd_groups[] = {
  996. "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
  997. "lcd-special", "lcd-generic",
  998. };
  999. static const char *jz4760_pwm0_groups[] = { "pwm0", };
  1000. static const char *jz4760_pwm1_groups[] = { "pwm1", };
  1001. static const char *jz4760_pwm2_groups[] = { "pwm2", };
  1002. static const char *jz4760_pwm3_groups[] = { "pwm3", };
  1003. static const char *jz4760_pwm4_groups[] = { "pwm4", };
  1004. static const char *jz4760_pwm5_groups[] = { "pwm5", };
  1005. static const char *jz4760_pwm6_groups[] = { "pwm6", };
  1006. static const char *jz4760_pwm7_groups[] = { "pwm7", };
  1007. static const char *jz4760_otg_groups[] = { "otg-vbus", };
  1008. static const struct function_desc jz4760_functions[] = {
  1009. { "uart0", jz4760_uart0_groups, ARRAY_SIZE(jz4760_uart0_groups), },
  1010. { "uart1", jz4760_uart1_groups, ARRAY_SIZE(jz4760_uart1_groups), },
  1011. { "uart2", jz4760_uart2_groups, ARRAY_SIZE(jz4760_uart2_groups), },
  1012. { "uart3", jz4760_uart3_groups, ARRAY_SIZE(jz4760_uart3_groups), },
  1013. { "ssi0", jz4760_ssi0_groups, ARRAY_SIZE(jz4760_ssi0_groups), },
  1014. { "ssi1", jz4760_ssi1_groups, ARRAY_SIZE(jz4760_ssi1_groups), },
  1015. { "mmc0", jz4760_mmc0_groups, ARRAY_SIZE(jz4760_mmc0_groups), },
  1016. { "mmc1", jz4760_mmc1_groups, ARRAY_SIZE(jz4760_mmc1_groups), },
  1017. { "mmc2", jz4760_mmc2_groups, ARRAY_SIZE(jz4760_mmc2_groups), },
  1018. { "nemc", jz4760_nemc_groups, ARRAY_SIZE(jz4760_nemc_groups), },
  1019. { "nemc-cs1", jz4760_cs1_groups, ARRAY_SIZE(jz4760_cs1_groups), },
  1020. { "nemc-cs2", jz4760_cs2_groups, ARRAY_SIZE(jz4760_cs2_groups), },
  1021. { "nemc-cs3", jz4760_cs3_groups, ARRAY_SIZE(jz4760_cs3_groups), },
  1022. { "nemc-cs4", jz4760_cs4_groups, ARRAY_SIZE(jz4760_cs4_groups), },
  1023. { "nemc-cs5", jz4760_cs5_groups, ARRAY_SIZE(jz4760_cs5_groups), },
  1024. { "nemc-cs6", jz4760_cs6_groups, ARRAY_SIZE(jz4760_cs6_groups), },
  1025. { "i2c0", jz4760_i2c0_groups, ARRAY_SIZE(jz4760_i2c0_groups), },
  1026. { "i2c1", jz4760_i2c1_groups, ARRAY_SIZE(jz4760_i2c1_groups), },
  1027. { "cim", jz4760_cim_groups, ARRAY_SIZE(jz4760_cim_groups), },
  1028. { "lcd", jz4760_lcd_groups, ARRAY_SIZE(jz4760_lcd_groups), },
  1029. { "pwm0", jz4760_pwm0_groups, ARRAY_SIZE(jz4760_pwm0_groups), },
  1030. { "pwm1", jz4760_pwm1_groups, ARRAY_SIZE(jz4760_pwm1_groups), },
  1031. { "pwm2", jz4760_pwm2_groups, ARRAY_SIZE(jz4760_pwm2_groups), },
  1032. { "pwm3", jz4760_pwm3_groups, ARRAY_SIZE(jz4760_pwm3_groups), },
  1033. { "pwm4", jz4760_pwm4_groups, ARRAY_SIZE(jz4760_pwm4_groups), },
  1034. { "pwm5", jz4760_pwm5_groups, ARRAY_SIZE(jz4760_pwm5_groups), },
  1035. { "pwm6", jz4760_pwm6_groups, ARRAY_SIZE(jz4760_pwm6_groups), },
  1036. { "pwm7", jz4760_pwm7_groups, ARRAY_SIZE(jz4760_pwm7_groups), },
  1037. { "otg", jz4760_otg_groups, ARRAY_SIZE(jz4760_otg_groups), },
  1038. };
  1039. static const struct ingenic_chip_info jz4760_chip_info = {
  1040. .num_chips = 6,
  1041. .reg_offset = 0x100,
  1042. .version = ID_JZ4760,
  1043. .groups = jz4760_groups,
  1044. .num_groups = ARRAY_SIZE(jz4760_groups),
  1045. .functions = jz4760_functions,
  1046. .num_functions = ARRAY_SIZE(jz4760_functions),
  1047. .pull_ups = jz4760_pull_ups,
  1048. .pull_downs = jz4760_pull_downs,
  1049. };
  1050. static const u32 jz4770_pull_ups[6] = {
  1051. 0x3fffffff, 0xfff0f3fc, 0xffffffff, 0xffff4fff, 0xfffffb7c, 0x0024f00f,
  1052. };
  1053. static const u32 jz4770_pull_downs[6] = {
  1054. 0x00000000, 0x000f0c03, 0x00000000, 0x0000b000, 0x00000483, 0x005b0ff0,
  1055. };
  1056. static int jz4770_uart0_data_pins[] = { 0xa0, 0xa3, };
  1057. static int jz4770_uart0_hwflow_pins[] = { 0xa1, 0xa2, };
  1058. static int jz4770_uart1_data_pins[] = { 0x7a, 0x7c, };
  1059. static int jz4770_uart1_hwflow_pins[] = { 0x7b, 0x7d, };
  1060. static int jz4770_uart2_data_pins[] = { 0x5c, 0x5e, };
  1061. static int jz4770_uart2_hwflow_pins[] = { 0x5d, 0x5f, };
  1062. static int jz4770_uart3_data_pins[] = { 0x6c, 0x85, };
  1063. static int jz4770_uart3_hwflow_pins[] = { 0x88, 0x89, };
  1064. static int jz4770_ssi0_dt_a_pins[] = { 0x15, };
  1065. static int jz4770_ssi0_dt_b_pins[] = { 0x35, };
  1066. static int jz4770_ssi0_dt_d_pins[] = { 0x75, };
  1067. static int jz4770_ssi0_dt_e_pins[] = { 0x91, };
  1068. static int jz4770_ssi0_dr_a_pins[] = { 0x14, };
  1069. static int jz4770_ssi0_dr_b_pins[] = { 0x34, };
  1070. static int jz4770_ssi0_dr_d_pins[] = { 0x74, };
  1071. static int jz4770_ssi0_dr_e_pins[] = { 0x8e, };
  1072. static int jz4770_ssi0_clk_a_pins[] = { 0x12, };
  1073. static int jz4770_ssi0_clk_b_pins[] = { 0x3c, };
  1074. static int jz4770_ssi0_clk_d_pins[] = { 0x78, };
  1075. static int jz4770_ssi0_clk_e_pins[] = { 0x8f, };
  1076. static int jz4770_ssi0_gpc_b_pins[] = { 0x3e, };
  1077. static int jz4770_ssi0_gpc_d_pins[] = { 0x76, };
  1078. static int jz4770_ssi0_gpc_e_pins[] = { 0x93, };
  1079. static int jz4770_ssi0_ce0_a_pins[] = { 0x13, };
  1080. static int jz4770_ssi0_ce0_b_pins[] = { 0x3d, };
  1081. static int jz4770_ssi0_ce0_d_pins[] = { 0x79, };
  1082. static int jz4770_ssi0_ce0_e_pins[] = { 0x90, };
  1083. static int jz4770_ssi0_ce1_b_pins[] = { 0x3f, };
  1084. static int jz4770_ssi0_ce1_d_pins[] = { 0x77, };
  1085. static int jz4770_ssi0_ce1_e_pins[] = { 0x92, };
  1086. static int jz4770_ssi1_dt_b_pins[] = { 0x35, };
  1087. static int jz4770_ssi1_dt_d_pins[] = { 0x75, };
  1088. static int jz4770_ssi1_dt_e_pins[] = { 0x91, };
  1089. static int jz4770_ssi1_dr_b_pins[] = { 0x34, };
  1090. static int jz4770_ssi1_dr_d_pins[] = { 0x74, };
  1091. static int jz4770_ssi1_dr_e_pins[] = { 0x8e, };
  1092. static int jz4770_ssi1_clk_b_pins[] = { 0x3c, };
  1093. static int jz4770_ssi1_clk_d_pins[] = { 0x78, };
  1094. static int jz4770_ssi1_clk_e_pins[] = { 0x8f, };
  1095. static int jz4770_ssi1_gpc_b_pins[] = { 0x3e, };
  1096. static int jz4770_ssi1_gpc_d_pins[] = { 0x76, };
  1097. static int jz4770_ssi1_gpc_e_pins[] = { 0x93, };
  1098. static int jz4770_ssi1_ce0_b_pins[] = { 0x3d, };
  1099. static int jz4770_ssi1_ce0_d_pins[] = { 0x79, };
  1100. static int jz4770_ssi1_ce0_e_pins[] = { 0x90, };
  1101. static int jz4770_ssi1_ce1_b_pins[] = { 0x3f, };
  1102. static int jz4770_ssi1_ce1_d_pins[] = { 0x77, };
  1103. static int jz4770_ssi1_ce1_e_pins[] = { 0x92, };
  1104. static int jz4770_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, };
  1105. static int jz4770_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, };
  1106. static int jz4770_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
  1107. static int jz4770_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
  1108. static int jz4770_mmc0_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
  1109. static int jz4770_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, };
  1110. static int jz4770_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, };
  1111. static int jz4770_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
  1112. static int jz4770_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
  1113. static int jz4770_mmc1_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
  1114. static int jz4770_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, };
  1115. static int jz4770_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, };
  1116. static int jz4770_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
  1117. static int jz4770_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
  1118. static int jz4770_mmc2_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
  1119. static int jz4770_nemc_8bit_data_pins[] = {
  1120. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  1121. };
  1122. static int jz4770_nemc_16bit_data_pins[] = {
  1123. 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
  1124. };
  1125. static int jz4770_nemc_cle_ale_pins[] = { 0x20, 0x21, };
  1126. static int jz4770_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, };
  1127. static int jz4770_nemc_rd_we_pins[] = { 0x10, 0x11, };
  1128. static int jz4770_nemc_frd_fwe_pins[] = { 0x12, 0x13, };
  1129. static int jz4770_nemc_wait_pins[] = { 0x1b, };
  1130. static int jz4770_nemc_cs1_pins[] = { 0x15, };
  1131. static int jz4770_nemc_cs2_pins[] = { 0x16, };
  1132. static int jz4770_nemc_cs3_pins[] = { 0x17, };
  1133. static int jz4770_nemc_cs4_pins[] = { 0x18, };
  1134. static int jz4770_nemc_cs5_pins[] = { 0x19, };
  1135. static int jz4770_nemc_cs6_pins[] = { 0x1a, };
  1136. static int jz4770_i2c0_pins[] = { 0x7e, 0x7f, };
  1137. static int jz4770_i2c1_pins[] = { 0x9e, 0x9f, };
  1138. static int jz4770_i2c2_pins[] = { 0xb0, 0xb1, };
  1139. static int jz4770_cim_8bit_pins[] = {
  1140. 0x26, 0x27, 0x28, 0x29,
  1141. 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
  1142. };
  1143. static int jz4770_cim_12bit_pins[] = {
  1144. 0x32, 0x33, 0xb0, 0xb1,
  1145. };
  1146. static int jz4770_lcd_8bit_pins[] = {
  1147. 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x4c, 0x4d,
  1148. 0x48, 0x52, 0x53,
  1149. };
  1150. static int jz4770_lcd_16bit_pins[] = {
  1151. 0x4e, 0x4f, 0x50, 0x51, 0x56, 0x57, 0x58, 0x59,
  1152. };
  1153. static int jz4770_lcd_18bit_pins[] = {
  1154. 0x5a, 0x5b,
  1155. };
  1156. static int jz4770_lcd_24bit_pins[] = {
  1157. 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
  1158. 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
  1159. 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
  1160. 0x58, 0x59, 0x5a, 0x5b,
  1161. };
  1162. static int jz4770_lcd_special_pins[] = { 0x54, 0x4a, 0x41, 0x40, };
  1163. static int jz4770_lcd_generic_pins[] = { 0x49, };
  1164. static int jz4770_pwm_pwm0_pins[] = { 0x80, };
  1165. static int jz4770_pwm_pwm1_pins[] = { 0x81, };
  1166. static int jz4770_pwm_pwm2_pins[] = { 0x82, };
  1167. static int jz4770_pwm_pwm3_pins[] = { 0x83, };
  1168. static int jz4770_pwm_pwm4_pins[] = { 0x84, };
  1169. static int jz4770_pwm_pwm5_pins[] = { 0x85, };
  1170. static int jz4770_pwm_pwm6_pins[] = { 0x6a, };
  1171. static int jz4770_pwm_pwm7_pins[] = { 0x6b, };
  1172. static int jz4770_mac_rmii_pins[] = {
  1173. 0xa9, 0xab, 0xaa, 0xac, 0xa5, 0xa4, 0xad, 0xae, 0xa6, 0xa8,
  1174. };
  1175. static int jz4770_mac_mii_pins[] = {
  1176. 0x7b, 0x7a, 0x7d, 0x7c, 0xa7, 0x24, 0xaf,
  1177. };
  1178. static const struct group_desc jz4770_groups[] = {
  1179. INGENIC_PIN_GROUP("uart0-data", jz4770_uart0_data, 0),
  1180. INGENIC_PIN_GROUP("uart0-hwflow", jz4770_uart0_hwflow, 0),
  1181. INGENIC_PIN_GROUP("uart1-data", jz4770_uart1_data, 0),
  1182. INGENIC_PIN_GROUP("uart1-hwflow", jz4770_uart1_hwflow, 0),
  1183. INGENIC_PIN_GROUP("uart2-data", jz4770_uart2_data, 0),
  1184. INGENIC_PIN_GROUP("uart2-hwflow", jz4770_uart2_hwflow, 0),
  1185. INGENIC_PIN_GROUP_FUNCS("uart3-data", jz4770_uart3_data,
  1186. jz4760_uart3_data_funcs),
  1187. INGENIC_PIN_GROUP("uart3-hwflow", jz4770_uart3_hwflow, 0),
  1188. INGENIC_PIN_GROUP("ssi0-dt-a", jz4770_ssi0_dt_a, 2),
  1189. INGENIC_PIN_GROUP("ssi0-dt-b", jz4770_ssi0_dt_b, 1),
  1190. INGENIC_PIN_GROUP("ssi0-dt-d", jz4770_ssi0_dt_d, 1),
  1191. INGENIC_PIN_GROUP("ssi0-dt-e", jz4770_ssi0_dt_e, 0),
  1192. INGENIC_PIN_GROUP("ssi0-dr-a", jz4770_ssi0_dr_a, 1),
  1193. INGENIC_PIN_GROUP("ssi0-dr-b", jz4770_ssi0_dr_b, 1),
  1194. INGENIC_PIN_GROUP("ssi0-dr-d", jz4770_ssi0_dr_d, 1),
  1195. INGENIC_PIN_GROUP("ssi0-dr-e", jz4770_ssi0_dr_e, 0),
  1196. INGENIC_PIN_GROUP("ssi0-clk-a", jz4770_ssi0_clk_a, 2),
  1197. INGENIC_PIN_GROUP("ssi0-clk-b", jz4770_ssi0_clk_b, 1),
  1198. INGENIC_PIN_GROUP("ssi0-clk-d", jz4770_ssi0_clk_d, 1),
  1199. INGENIC_PIN_GROUP("ssi0-clk-e", jz4770_ssi0_clk_e, 0),
  1200. INGENIC_PIN_GROUP("ssi0-gpc-b", jz4770_ssi0_gpc_b, 1),
  1201. INGENIC_PIN_GROUP("ssi0-gpc-d", jz4770_ssi0_gpc_d, 1),
  1202. INGENIC_PIN_GROUP("ssi0-gpc-e", jz4770_ssi0_gpc_e, 0),
  1203. INGENIC_PIN_GROUP("ssi0-ce0-a", jz4770_ssi0_ce0_a, 2),
  1204. INGENIC_PIN_GROUP("ssi0-ce0-b", jz4770_ssi0_ce0_b, 1),
  1205. INGENIC_PIN_GROUP("ssi0-ce0-d", jz4770_ssi0_ce0_d, 1),
  1206. INGENIC_PIN_GROUP("ssi0-ce0-e", jz4770_ssi0_ce0_e, 0),
  1207. INGENIC_PIN_GROUP("ssi0-ce1-b", jz4770_ssi0_ce1_b, 1),
  1208. INGENIC_PIN_GROUP("ssi0-ce1-d", jz4770_ssi0_ce1_d, 1),
  1209. INGENIC_PIN_GROUP("ssi0-ce1-e", jz4770_ssi0_ce1_e, 0),
  1210. INGENIC_PIN_GROUP("ssi1-dt-b", jz4770_ssi1_dt_b, 2),
  1211. INGENIC_PIN_GROUP("ssi1-dt-d", jz4770_ssi1_dt_d, 2),
  1212. INGENIC_PIN_GROUP("ssi1-dt-e", jz4770_ssi1_dt_e, 1),
  1213. INGENIC_PIN_GROUP("ssi1-dr-b", jz4770_ssi1_dr_b, 2),
  1214. INGENIC_PIN_GROUP("ssi1-dr-d", jz4770_ssi1_dr_d, 2),
  1215. INGENIC_PIN_GROUP("ssi1-dr-e", jz4770_ssi1_dr_e, 1),
  1216. INGENIC_PIN_GROUP("ssi1-clk-b", jz4770_ssi1_clk_b, 2),
  1217. INGENIC_PIN_GROUP("ssi1-clk-d", jz4770_ssi1_clk_d, 2),
  1218. INGENIC_PIN_GROUP("ssi1-clk-e", jz4770_ssi1_clk_e, 1),
  1219. INGENIC_PIN_GROUP("ssi1-gpc-b", jz4770_ssi1_gpc_b, 2),
  1220. INGENIC_PIN_GROUP("ssi1-gpc-d", jz4770_ssi1_gpc_d, 2),
  1221. INGENIC_PIN_GROUP("ssi1-gpc-e", jz4770_ssi1_gpc_e, 1),
  1222. INGENIC_PIN_GROUP("ssi1-ce0-b", jz4770_ssi1_ce0_b, 2),
  1223. INGENIC_PIN_GROUP("ssi1-ce0-d", jz4770_ssi1_ce0_d, 2),
  1224. INGENIC_PIN_GROUP("ssi1-ce0-e", jz4770_ssi1_ce0_e, 1),
  1225. INGENIC_PIN_GROUP("ssi1-ce1-b", jz4770_ssi1_ce1_b, 2),
  1226. INGENIC_PIN_GROUP("ssi1-ce1-d", jz4770_ssi1_ce1_d, 2),
  1227. INGENIC_PIN_GROUP("ssi1-ce1-e", jz4770_ssi1_ce1_e, 1),
  1228. INGENIC_PIN_GROUP_FUNCS("mmc0-1bit-a", jz4770_mmc0_1bit_a,
  1229. jz4760_mmc0_1bit_a_funcs),
  1230. INGENIC_PIN_GROUP("mmc0-4bit-a", jz4770_mmc0_4bit_a, 1),
  1231. INGENIC_PIN_GROUP("mmc0-1bit-e", jz4770_mmc0_1bit_e, 0),
  1232. INGENIC_PIN_GROUP("mmc0-4bit-e", jz4770_mmc0_4bit_e, 0),
  1233. INGENIC_PIN_GROUP("mmc0-8bit-e", jz4770_mmc0_8bit_e, 0),
  1234. INGENIC_PIN_GROUP("mmc1-1bit-d", jz4770_mmc1_1bit_d, 0),
  1235. INGENIC_PIN_GROUP("mmc1-4bit-d", jz4770_mmc1_4bit_d, 0),
  1236. INGENIC_PIN_GROUP("mmc1-1bit-e", jz4770_mmc1_1bit_e, 1),
  1237. INGENIC_PIN_GROUP("mmc1-4bit-e", jz4770_mmc1_4bit_e, 1),
  1238. INGENIC_PIN_GROUP("mmc1-8bit-e", jz4770_mmc1_8bit_e, 1),
  1239. INGENIC_PIN_GROUP("mmc2-1bit-b", jz4770_mmc2_1bit_b, 0),
  1240. INGENIC_PIN_GROUP("mmc2-4bit-b", jz4770_mmc2_4bit_b, 0),
  1241. INGENIC_PIN_GROUP("mmc2-1bit-e", jz4770_mmc2_1bit_e, 2),
  1242. INGENIC_PIN_GROUP("mmc2-4bit-e", jz4770_mmc2_4bit_e, 2),
  1243. INGENIC_PIN_GROUP("mmc2-8bit-e", jz4770_mmc2_8bit_e, 2),
  1244. INGENIC_PIN_GROUP("nemc-8bit-data", jz4770_nemc_8bit_data, 0),
  1245. INGENIC_PIN_GROUP("nemc-16bit-data", jz4770_nemc_16bit_data, 0),
  1246. INGENIC_PIN_GROUP("nemc-cle-ale", jz4770_nemc_cle_ale, 0),
  1247. INGENIC_PIN_GROUP("nemc-addr", jz4770_nemc_addr, 0),
  1248. INGENIC_PIN_GROUP("nemc-rd-we", jz4770_nemc_rd_we, 0),
  1249. INGENIC_PIN_GROUP("nemc-frd-fwe", jz4770_nemc_frd_fwe, 0),
  1250. INGENIC_PIN_GROUP("nemc-wait", jz4770_nemc_wait, 0),
  1251. INGENIC_PIN_GROUP("nemc-cs1", jz4770_nemc_cs1, 0),
  1252. INGENIC_PIN_GROUP("nemc-cs2", jz4770_nemc_cs2, 0),
  1253. INGENIC_PIN_GROUP("nemc-cs3", jz4770_nemc_cs3, 0),
  1254. INGENIC_PIN_GROUP("nemc-cs4", jz4770_nemc_cs4, 0),
  1255. INGENIC_PIN_GROUP("nemc-cs5", jz4770_nemc_cs5, 0),
  1256. INGENIC_PIN_GROUP("nemc-cs6", jz4770_nemc_cs6, 0),
  1257. INGENIC_PIN_GROUP("i2c0-data", jz4770_i2c0, 0),
  1258. INGENIC_PIN_GROUP("i2c1-data", jz4770_i2c1, 0),
  1259. INGENIC_PIN_GROUP("i2c2-data", jz4770_i2c2, 2),
  1260. INGENIC_PIN_GROUP("cim-data-8bit", jz4770_cim_8bit, 0),
  1261. INGENIC_PIN_GROUP("cim-data-12bit", jz4770_cim_12bit, 0),
  1262. INGENIC_PIN_GROUP("lcd-8bit", jz4770_lcd_8bit, 0),
  1263. INGENIC_PIN_GROUP("lcd-16bit", jz4770_lcd_16bit, 0),
  1264. INGENIC_PIN_GROUP("lcd-18bit", jz4770_lcd_18bit, 0),
  1265. INGENIC_PIN_GROUP("lcd-24bit", jz4770_lcd_24bit, 0),
  1266. INGENIC_PIN_GROUP("lcd-special", jz4770_lcd_special, 1),
  1267. INGENIC_PIN_GROUP("lcd-generic", jz4770_lcd_generic, 0),
  1268. INGENIC_PIN_GROUP("pwm0", jz4770_pwm_pwm0, 0),
  1269. INGENIC_PIN_GROUP("pwm1", jz4770_pwm_pwm1, 0),
  1270. INGENIC_PIN_GROUP("pwm2", jz4770_pwm_pwm2, 0),
  1271. INGENIC_PIN_GROUP("pwm3", jz4770_pwm_pwm3, 0),
  1272. INGENIC_PIN_GROUP("pwm4", jz4770_pwm_pwm4, 0),
  1273. INGENIC_PIN_GROUP("pwm5", jz4770_pwm_pwm5, 0),
  1274. INGENIC_PIN_GROUP("pwm6", jz4770_pwm_pwm6, 0),
  1275. INGENIC_PIN_GROUP("pwm7", jz4770_pwm_pwm7, 0),
  1276. INGENIC_PIN_GROUP("mac-rmii", jz4770_mac_rmii, 0),
  1277. INGENIC_PIN_GROUP("mac-mii", jz4770_mac_mii, 0),
  1278. INGENIC_PIN_GROUP("otg-vbus", jz4760_otg, 0),
  1279. };
  1280. static const char *jz4770_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
  1281. static const char *jz4770_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
  1282. static const char *jz4770_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
  1283. static const char *jz4770_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
  1284. static const char *jz4770_ssi0_groups[] = {
  1285. "ssi0-dt-a", "ssi0-dt-b", "ssi0-dt-d", "ssi0-dt-e",
  1286. "ssi0-dr-a", "ssi0-dr-b", "ssi0-dr-d", "ssi0-dr-e",
  1287. "ssi0-clk-a", "ssi0-clk-b", "ssi0-clk-d", "ssi0-clk-e",
  1288. "ssi0-gpc-b", "ssi0-gpc-d", "ssi0-gpc-e",
  1289. "ssi0-ce0-a", "ssi0-ce0-b", "ssi0-ce0-d", "ssi0-ce0-e",
  1290. "ssi0-ce1-b", "ssi0-ce1-d", "ssi0-ce1-e",
  1291. };
  1292. static const char *jz4770_ssi1_groups[] = {
  1293. "ssi1-dt-b", "ssi1-dt-d", "ssi1-dt-e",
  1294. "ssi1-dr-b", "ssi1-dr-d", "ssi1-dr-e",
  1295. "ssi1-clk-b", "ssi1-clk-d", "ssi1-clk-e",
  1296. "ssi1-gpc-b", "ssi1-gpc-d", "ssi1-gpc-e",
  1297. "ssi1-ce0-b", "ssi1-ce0-d", "ssi1-ce0-e",
  1298. "ssi1-ce1-b", "ssi1-ce1-d", "ssi1-ce1-e",
  1299. };
  1300. static const char *jz4770_mmc0_groups[] = {
  1301. "mmc0-1bit-a", "mmc0-4bit-a",
  1302. "mmc0-1bit-e", "mmc0-4bit-e", "mmc0-8bit-e",
  1303. };
  1304. static const char *jz4770_mmc1_groups[] = {
  1305. "mmc1-1bit-d", "mmc1-4bit-d",
  1306. "mmc1-1bit-e", "mmc1-4bit-e", "mmc1-8bit-e",
  1307. };
  1308. static const char *jz4770_mmc2_groups[] = {
  1309. "mmc2-1bit-b", "mmc2-4bit-b",
  1310. "mmc2-1bit-e", "mmc2-4bit-e", "mmc2-8bit-e",
  1311. };
  1312. static const char *jz4770_nemc_groups[] = {
  1313. "nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale",
  1314. "nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
  1315. };
  1316. static const char *jz4770_cs1_groups[] = { "nemc-cs1", };
  1317. static const char *jz4770_cs2_groups[] = { "nemc-cs2", };
  1318. static const char *jz4770_cs3_groups[] = { "nemc-cs3", };
  1319. static const char *jz4770_cs4_groups[] = { "nemc-cs4", };
  1320. static const char *jz4770_cs5_groups[] = { "nemc-cs5", };
  1321. static const char *jz4770_cs6_groups[] = { "nemc-cs6", };
  1322. static const char *jz4770_i2c0_groups[] = { "i2c0-data", };
  1323. static const char *jz4770_i2c1_groups[] = { "i2c1-data", };
  1324. static const char *jz4770_i2c2_groups[] = { "i2c2-data", };
  1325. static const char *jz4770_cim_groups[] = { "cim-data-8bit", "cim-data-12bit", };
  1326. static const char *jz4770_lcd_groups[] = {
  1327. "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
  1328. "lcd-special", "lcd-generic",
  1329. };
  1330. static const char *jz4770_pwm0_groups[] = { "pwm0", };
  1331. static const char *jz4770_pwm1_groups[] = { "pwm1", };
  1332. static const char *jz4770_pwm2_groups[] = { "pwm2", };
  1333. static const char *jz4770_pwm3_groups[] = { "pwm3", };
  1334. static const char *jz4770_pwm4_groups[] = { "pwm4", };
  1335. static const char *jz4770_pwm5_groups[] = { "pwm5", };
  1336. static const char *jz4770_pwm6_groups[] = { "pwm6", };
  1337. static const char *jz4770_pwm7_groups[] = { "pwm7", };
  1338. static const char *jz4770_mac_groups[] = { "mac-rmii", "mac-mii", };
  1339. static const struct function_desc jz4770_functions[] = {
  1340. { "uart0", jz4770_uart0_groups, ARRAY_SIZE(jz4770_uart0_groups), },
  1341. { "uart1", jz4770_uart1_groups, ARRAY_SIZE(jz4770_uart1_groups), },
  1342. { "uart2", jz4770_uart2_groups, ARRAY_SIZE(jz4770_uart2_groups), },
  1343. { "uart3", jz4770_uart3_groups, ARRAY_SIZE(jz4770_uart3_groups), },
  1344. { "ssi0", jz4770_ssi0_groups, ARRAY_SIZE(jz4770_ssi0_groups), },
  1345. { "ssi1", jz4770_ssi1_groups, ARRAY_SIZE(jz4770_ssi1_groups), },
  1346. { "mmc0", jz4770_mmc0_groups, ARRAY_SIZE(jz4770_mmc0_groups), },
  1347. { "mmc1", jz4770_mmc1_groups, ARRAY_SIZE(jz4770_mmc1_groups), },
  1348. { "mmc2", jz4770_mmc2_groups, ARRAY_SIZE(jz4770_mmc2_groups), },
  1349. { "nemc", jz4770_nemc_groups, ARRAY_SIZE(jz4770_nemc_groups), },
  1350. { "nemc-cs1", jz4770_cs1_groups, ARRAY_SIZE(jz4770_cs1_groups), },
  1351. { "nemc-cs2", jz4770_cs2_groups, ARRAY_SIZE(jz4770_cs2_groups), },
  1352. { "nemc-cs3", jz4770_cs3_groups, ARRAY_SIZE(jz4770_cs3_groups), },
  1353. { "nemc-cs4", jz4770_cs4_groups, ARRAY_SIZE(jz4770_cs4_groups), },
  1354. { "nemc-cs5", jz4770_cs5_groups, ARRAY_SIZE(jz4770_cs5_groups), },
  1355. { "nemc-cs6", jz4770_cs6_groups, ARRAY_SIZE(jz4770_cs6_groups), },
  1356. { "i2c0", jz4770_i2c0_groups, ARRAY_SIZE(jz4770_i2c0_groups), },
  1357. { "i2c1", jz4770_i2c1_groups, ARRAY_SIZE(jz4770_i2c1_groups), },
  1358. { "i2c2", jz4770_i2c2_groups, ARRAY_SIZE(jz4770_i2c2_groups), },
  1359. { "cim", jz4770_cim_groups, ARRAY_SIZE(jz4770_cim_groups), },
  1360. { "lcd", jz4770_lcd_groups, ARRAY_SIZE(jz4770_lcd_groups), },
  1361. { "pwm0", jz4770_pwm0_groups, ARRAY_SIZE(jz4770_pwm0_groups), },
  1362. { "pwm1", jz4770_pwm1_groups, ARRAY_SIZE(jz4770_pwm1_groups), },
  1363. { "pwm2", jz4770_pwm2_groups, ARRAY_SIZE(jz4770_pwm2_groups), },
  1364. { "pwm3", jz4770_pwm3_groups, ARRAY_SIZE(jz4770_pwm3_groups), },
  1365. { "pwm4", jz4770_pwm4_groups, ARRAY_SIZE(jz4770_pwm4_groups), },
  1366. { "pwm5", jz4770_pwm5_groups, ARRAY_SIZE(jz4770_pwm5_groups), },
  1367. { "pwm6", jz4770_pwm6_groups, ARRAY_SIZE(jz4770_pwm6_groups), },
  1368. { "pwm7", jz4770_pwm7_groups, ARRAY_SIZE(jz4770_pwm7_groups), },
  1369. { "mac", jz4770_mac_groups, ARRAY_SIZE(jz4770_mac_groups), },
  1370. { "otg", jz4760_otg_groups, ARRAY_SIZE(jz4760_otg_groups), },
  1371. };
  1372. static const struct ingenic_chip_info jz4770_chip_info = {
  1373. .num_chips = 6,
  1374. .reg_offset = 0x100,
  1375. .version = ID_JZ4770,
  1376. .groups = jz4770_groups,
  1377. .num_groups = ARRAY_SIZE(jz4770_groups),
  1378. .functions = jz4770_functions,
  1379. .num_functions = ARRAY_SIZE(jz4770_functions),
  1380. .pull_ups = jz4770_pull_ups,
  1381. .pull_downs = jz4770_pull_downs,
  1382. };
  1383. static const u32 jz4775_pull_ups[7] = {
  1384. 0x28ff00ff, 0xf030f3fc, 0x0fffffff, 0xfffe4000, 0xf0f0000c, 0x0000f00f, 0x0000f3c0,
  1385. };
  1386. static const u32 jz4775_pull_downs[7] = {
  1387. 0x00000000, 0x00030c03, 0x00000000, 0x00008000, 0x00000403, 0x00000ff0, 0x00030c00,
  1388. };
  1389. static int jz4775_uart0_data_pins[] = { 0xa0, 0xa3, };
  1390. static int jz4775_uart0_hwflow_pins[] = { 0xa1, 0xa2, };
  1391. static int jz4775_uart1_data_pins[] = { 0x7a, 0x7c, };
  1392. static int jz4775_uart1_hwflow_pins[] = { 0x7b, 0x7d, };
  1393. static int jz4775_uart2_data_c_pins[] = { 0x54, 0x4a, };
  1394. static int jz4775_uart2_data_f_pins[] = { 0xa5, 0xa4, };
  1395. static int jz4775_uart3_data_pins[] = { 0x1e, 0x1f, };
  1396. static int jz4775_ssi_dt_a_pins[] = { 0x13, };
  1397. static int jz4775_ssi_dt_d_pins[] = { 0x75, };
  1398. static int jz4775_ssi_dr_a_pins[] = { 0x14, };
  1399. static int jz4775_ssi_dr_d_pins[] = { 0x74, };
  1400. static int jz4775_ssi_clk_a_pins[] = { 0x12, };
  1401. static int jz4775_ssi_clk_d_pins[] = { 0x78, };
  1402. static int jz4775_ssi_gpc_pins[] = { 0x76, };
  1403. static int jz4775_ssi_ce0_a_pins[] = { 0x17, };
  1404. static int jz4775_ssi_ce0_d_pins[] = { 0x79, };
  1405. static int jz4775_ssi_ce1_pins[] = { 0x77, };
  1406. static int jz4775_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, };
  1407. static int jz4775_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, };
  1408. static int jz4775_mmc0_8bit_a_pins[] = { 0x04, 0x05, 0x06, 0x07, };
  1409. static int jz4775_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
  1410. static int jz4775_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
  1411. static int jz4775_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, };
  1412. static int jz4775_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, };
  1413. static int jz4775_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
  1414. static int jz4775_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
  1415. static int jz4775_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, };
  1416. static int jz4775_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, };
  1417. static int jz4775_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
  1418. static int jz4775_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
  1419. static int jz4775_nemc_8bit_data_pins[] = {
  1420. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  1421. };
  1422. static int jz4775_nemc_16bit_data_pins[] = {
  1423. 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1,
  1424. };
  1425. static int jz4775_nemc_cle_ale_pins[] = { 0x20, 0x21, };
  1426. static int jz4775_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, };
  1427. static int jz4775_nemc_rd_we_pins[] = { 0x10, 0x11, };
  1428. static int jz4775_nemc_frd_fwe_pins[] = { 0x12, 0x13, };
  1429. static int jz4775_nemc_wait_pins[] = { 0x1b, };
  1430. static int jz4775_nemc_cs1_pins[] = { 0x15, };
  1431. static int jz4775_nemc_cs2_pins[] = { 0x16, };
  1432. static int jz4775_nemc_cs3_pins[] = { 0x17, };
  1433. static int jz4775_i2c0_pins[] = { 0x7e, 0x7f, };
  1434. static int jz4775_i2c1_pins[] = { 0x9e, 0x9f, };
  1435. static int jz4775_i2c2_pins[] = { 0x80, 0x83, };
  1436. static int jz4775_i2s_data_tx_pins[] = { 0xa3, };
  1437. static int jz4775_i2s_data_rx_pins[] = { 0xa2, };
  1438. static int jz4775_i2s_clk_txrx_pins[] = { 0xa0, 0xa1, };
  1439. static int jz4775_i2s_sysclk_pins[] = { 0x83, };
  1440. static int jz4775_dmic_pins[] = { 0xaa, 0xab, };
  1441. static int jz4775_cim_pins[] = {
  1442. 0x26, 0x27, 0x28, 0x29,
  1443. 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
  1444. };
  1445. static int jz4775_lcd_8bit_pins[] = {
  1446. 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x4c, 0x4d,
  1447. 0x48, 0x52, 0x53,
  1448. };
  1449. static int jz4775_lcd_16bit_pins[] = {
  1450. 0x4e, 0x4f, 0x50, 0x51, 0x56, 0x57, 0x58, 0x59,
  1451. };
  1452. static int jz4775_lcd_18bit_pins[] = {
  1453. 0x5a, 0x5b,
  1454. };
  1455. static int jz4775_lcd_24bit_pins[] = {
  1456. 0x40, 0x41, 0x4a, 0x4b, 0x54, 0x55,
  1457. };
  1458. static int jz4775_lcd_special_pins[] = { 0x54, 0x4a, 0x41, 0x40, };
  1459. static int jz4775_lcd_generic_pins[] = { 0x49, };
  1460. static int jz4775_pwm_pwm0_pins[] = { 0x80, };
  1461. static int jz4775_pwm_pwm1_pins[] = { 0x81, };
  1462. static int jz4775_pwm_pwm2_pins[] = { 0x82, };
  1463. static int jz4775_pwm_pwm3_pins[] = { 0x83, };
  1464. static int jz4775_mac_rmii_pins[] = {
  1465. 0xa9, 0xab, 0xaa, 0xac, 0xa5, 0xa4, 0xad, 0xae, 0xa6, 0xa8,
  1466. };
  1467. static int jz4775_mac_mii_pins[] = {
  1468. 0x7b, 0x7a, 0x7d, 0x7c, 0xa7, 0x24, 0xaf,
  1469. };
  1470. static int jz4775_mac_rgmii_pins[] = {
  1471. 0xa9, 0x7b, 0x7a, 0xab, 0xaa, 0xac, 0x7d, 0x7c, 0xa5, 0xa4,
  1472. 0xad, 0xae, 0xa7, 0xa6,
  1473. };
  1474. static int jz4775_mac_gmii_pins[] = {
  1475. 0x31, 0x30, 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a,
  1476. 0xa8, 0x28, 0x24, 0xaf,
  1477. };
  1478. static int jz4775_otg_pins[] = { 0x8a, };
  1479. static u8 jz4775_uart3_data_funcs[] = { 0, 1, };
  1480. static u8 jz4775_mac_mii_funcs[] = { 1, 1, 1, 1, 0, 1, 0, };
  1481. static u8 jz4775_mac_rgmii_funcs[] = {
  1482. 0, 1, 1, 0, 0, 0, 1, 1, 0, 0,
  1483. 0, 0, 0, 0,
  1484. };
  1485. static u8 jz4775_mac_gmii_funcs[] = {
  1486. 1, 1, 1, 1, 1, 1, 1, 1,
  1487. 0, 1, 1, 0,
  1488. };
  1489. static const struct group_desc jz4775_groups[] = {
  1490. INGENIC_PIN_GROUP("uart0-data", jz4775_uart0_data, 0),
  1491. INGENIC_PIN_GROUP("uart0-hwflow", jz4775_uart0_hwflow, 0),
  1492. INGENIC_PIN_GROUP("uart1-data", jz4775_uart1_data, 0),
  1493. INGENIC_PIN_GROUP("uart1-hwflow", jz4775_uart1_hwflow, 0),
  1494. INGENIC_PIN_GROUP("uart2-data-c", jz4775_uart2_data_c, 2),
  1495. INGENIC_PIN_GROUP("uart2-data-f", jz4775_uart2_data_f, 1),
  1496. INGENIC_PIN_GROUP_FUNCS("uart3-data", jz4775_uart3_data,
  1497. jz4775_uart3_data_funcs),
  1498. INGENIC_PIN_GROUP("ssi-dt-a", jz4775_ssi_dt_a, 2),
  1499. INGENIC_PIN_GROUP("ssi-dt-d", jz4775_ssi_dt_d, 1),
  1500. INGENIC_PIN_GROUP("ssi-dr-a", jz4775_ssi_dr_a, 2),
  1501. INGENIC_PIN_GROUP("ssi-dr-d", jz4775_ssi_dr_d, 1),
  1502. INGENIC_PIN_GROUP("ssi-clk-a", jz4775_ssi_clk_a, 2),
  1503. INGENIC_PIN_GROUP("ssi-clk-d", jz4775_ssi_clk_d, 1),
  1504. INGENIC_PIN_GROUP("ssi-gpc", jz4775_ssi_gpc, 1),
  1505. INGENIC_PIN_GROUP("ssi-ce0-a", jz4775_ssi_ce0_a, 2),
  1506. INGENIC_PIN_GROUP("ssi-ce0-d", jz4775_ssi_ce0_d, 1),
  1507. INGENIC_PIN_GROUP("ssi-ce1", jz4775_ssi_ce1, 1),
  1508. INGENIC_PIN_GROUP("mmc0-1bit-a", jz4775_mmc0_1bit_a, 1),
  1509. INGENIC_PIN_GROUP("mmc0-4bit-a", jz4775_mmc0_4bit_a, 1),
  1510. INGENIC_PIN_GROUP("mmc0-8bit-a", jz4775_mmc0_8bit_a, 1),
  1511. INGENIC_PIN_GROUP("mmc0-1bit-e", jz4775_mmc0_1bit_e, 0),
  1512. INGENIC_PIN_GROUP("mmc0-4bit-e", jz4775_mmc0_4bit_e, 0),
  1513. INGENIC_PIN_GROUP("mmc1-1bit-d", jz4775_mmc1_1bit_d, 0),
  1514. INGENIC_PIN_GROUP("mmc1-4bit-d", jz4775_mmc1_4bit_d, 0),
  1515. INGENIC_PIN_GROUP("mmc1-1bit-e", jz4775_mmc1_1bit_e, 1),
  1516. INGENIC_PIN_GROUP("mmc1-4bit-e", jz4775_mmc1_4bit_e, 1),
  1517. INGENIC_PIN_GROUP("mmc2-1bit-b", jz4775_mmc2_1bit_b, 0),
  1518. INGENIC_PIN_GROUP("mmc2-4bit-b", jz4775_mmc2_4bit_b, 0),
  1519. INGENIC_PIN_GROUP("mmc2-1bit-e", jz4775_mmc2_1bit_e, 2),
  1520. INGENIC_PIN_GROUP("mmc2-4bit-e", jz4775_mmc2_4bit_e, 2),
  1521. INGENIC_PIN_GROUP("nemc-8bit-data", jz4775_nemc_8bit_data, 0),
  1522. INGENIC_PIN_GROUP("nemc-16bit-data", jz4775_nemc_16bit_data, 1),
  1523. INGENIC_PIN_GROUP("nemc-cle-ale", jz4775_nemc_cle_ale, 0),
  1524. INGENIC_PIN_GROUP("nemc-addr", jz4775_nemc_addr, 0),
  1525. INGENIC_PIN_GROUP("nemc-rd-we", jz4775_nemc_rd_we, 0),
  1526. INGENIC_PIN_GROUP("nemc-frd-fwe", jz4775_nemc_frd_fwe, 0),
  1527. INGENIC_PIN_GROUP("nemc-wait", jz4775_nemc_wait, 0),
  1528. INGENIC_PIN_GROUP("nemc-cs1", jz4775_nemc_cs1, 0),
  1529. INGENIC_PIN_GROUP("nemc-cs2", jz4775_nemc_cs2, 0),
  1530. INGENIC_PIN_GROUP("nemc-cs3", jz4775_nemc_cs3, 0),
  1531. INGENIC_PIN_GROUP("i2c0-data", jz4775_i2c0, 0),
  1532. INGENIC_PIN_GROUP("i2c1-data", jz4775_i2c1, 0),
  1533. INGENIC_PIN_GROUP("i2c2-data", jz4775_i2c2, 1),
  1534. INGENIC_PIN_GROUP("i2s-data-tx", jz4775_i2s_data_tx, 1),
  1535. INGENIC_PIN_GROUP("i2s-data-rx", jz4775_i2s_data_rx, 1),
  1536. INGENIC_PIN_GROUP("i2s-clk-txrx", jz4775_i2s_clk_txrx, 1),
  1537. INGENIC_PIN_GROUP("i2s-sysclk", jz4775_i2s_sysclk, 2),
  1538. INGENIC_PIN_GROUP("dmic", jz4775_dmic, 1),
  1539. INGENIC_PIN_GROUP("cim-data", jz4775_cim, 0),
  1540. INGENIC_PIN_GROUP("lcd-8bit", jz4775_lcd_8bit, 0),
  1541. INGENIC_PIN_GROUP("lcd-16bit", jz4775_lcd_16bit, 0),
  1542. INGENIC_PIN_GROUP("lcd-18bit", jz4775_lcd_18bit, 0),
  1543. INGENIC_PIN_GROUP("lcd-24bit", jz4775_lcd_24bit, 0),
  1544. INGENIC_PIN_GROUP("lcd-generic", jz4775_lcd_generic, 0),
  1545. INGENIC_PIN_GROUP("lcd-special", jz4775_lcd_special, 1),
  1546. INGENIC_PIN_GROUP("pwm0", jz4775_pwm_pwm0, 0),
  1547. INGENIC_PIN_GROUP("pwm1", jz4775_pwm_pwm1, 0),
  1548. INGENIC_PIN_GROUP("pwm2", jz4775_pwm_pwm2, 0),
  1549. INGENIC_PIN_GROUP("pwm3", jz4775_pwm_pwm3, 0),
  1550. INGENIC_PIN_GROUP("mac-rmii", jz4775_mac_rmii, 0),
  1551. INGENIC_PIN_GROUP_FUNCS("mac-mii", jz4775_mac_mii,
  1552. jz4775_mac_mii_funcs),
  1553. INGENIC_PIN_GROUP_FUNCS("mac-rgmii", jz4775_mac_rgmii,
  1554. jz4775_mac_rgmii_funcs),
  1555. INGENIC_PIN_GROUP_FUNCS("mac-gmii", jz4775_mac_gmii,
  1556. jz4775_mac_gmii_funcs),
  1557. INGENIC_PIN_GROUP("otg-vbus", jz4775_otg, 0),
  1558. };
  1559. static const char *jz4775_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
  1560. static const char *jz4775_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
  1561. static const char *jz4775_uart2_groups[] = { "uart2-data-c", "uart2-data-f", };
  1562. static const char *jz4775_uart3_groups[] = { "uart3-data", };
  1563. static const char *jz4775_ssi_groups[] = {
  1564. "ssi-dt-a", "ssi-dt-d",
  1565. "ssi-dr-a", "ssi-dr-d",
  1566. "ssi-clk-a", "ssi-clk-d",
  1567. "ssi-gpc",
  1568. "ssi-ce0-a", "ssi-ce0-d",
  1569. "ssi-ce1",
  1570. };
  1571. static const char *jz4775_mmc0_groups[] = {
  1572. "mmc0-1bit-a", "mmc0-4bit-a", "mmc0-8bit-a",
  1573. "mmc0-1bit-e", "mmc0-4bit-e",
  1574. };
  1575. static const char *jz4775_mmc1_groups[] = {
  1576. "mmc1-1bit-d", "mmc1-4bit-d",
  1577. "mmc1-1bit-e", "mmc1-4bit-e",
  1578. };
  1579. static const char *jz4775_mmc2_groups[] = {
  1580. "mmc2-1bit-b", "mmc2-4bit-b",
  1581. "mmc2-1bit-e", "mmc2-4bit-e",
  1582. };
  1583. static const char *jz4775_nemc_groups[] = {
  1584. "nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale",
  1585. "nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
  1586. };
  1587. static const char *jz4775_cs1_groups[] = { "nemc-cs1", };
  1588. static const char *jz4775_cs2_groups[] = { "nemc-cs2", };
  1589. static const char *jz4775_cs3_groups[] = { "nemc-cs3", };
  1590. static const char *jz4775_i2c0_groups[] = { "i2c0-data", };
  1591. static const char *jz4775_i2c1_groups[] = { "i2c1-data", };
  1592. static const char *jz4775_i2c2_groups[] = { "i2c2-data", };
  1593. static const char *jz4775_i2s_groups[] = {
  1594. "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-sysclk",
  1595. };
  1596. static const char *jz4775_dmic_groups[] = { "dmic", };
  1597. static const char *jz4775_cim_groups[] = { "cim-data", };
  1598. static const char *jz4775_lcd_groups[] = {
  1599. "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
  1600. "lcd-special", "lcd-generic",
  1601. };
  1602. static const char *jz4775_pwm0_groups[] = { "pwm0", };
  1603. static const char *jz4775_pwm1_groups[] = { "pwm1", };
  1604. static const char *jz4775_pwm2_groups[] = { "pwm2", };
  1605. static const char *jz4775_pwm3_groups[] = { "pwm3", };
  1606. static const char *jz4775_mac_groups[] = {
  1607. "mac-rmii", "mac-mii", "mac-rgmii", "mac-gmii",
  1608. };
  1609. static const char *jz4775_otg_groups[] = { "otg-vbus", };
  1610. static const struct function_desc jz4775_functions[] = {
  1611. { "uart0", jz4775_uart0_groups, ARRAY_SIZE(jz4775_uart0_groups), },
  1612. { "uart1", jz4775_uart1_groups, ARRAY_SIZE(jz4775_uart1_groups), },
  1613. { "uart2", jz4775_uart2_groups, ARRAY_SIZE(jz4775_uart2_groups), },
  1614. { "uart3", jz4775_uart3_groups, ARRAY_SIZE(jz4775_uart3_groups), },
  1615. { "ssi", jz4775_ssi_groups, ARRAY_SIZE(jz4775_ssi_groups), },
  1616. { "mmc0", jz4775_mmc0_groups, ARRAY_SIZE(jz4775_mmc0_groups), },
  1617. { "mmc1", jz4775_mmc1_groups, ARRAY_SIZE(jz4775_mmc1_groups), },
  1618. { "mmc2", jz4775_mmc2_groups, ARRAY_SIZE(jz4775_mmc2_groups), },
  1619. { "nemc", jz4775_nemc_groups, ARRAY_SIZE(jz4775_nemc_groups), },
  1620. { "nemc-cs1", jz4775_cs1_groups, ARRAY_SIZE(jz4775_cs1_groups), },
  1621. { "nemc-cs2", jz4775_cs2_groups, ARRAY_SIZE(jz4775_cs2_groups), },
  1622. { "nemc-cs3", jz4775_cs3_groups, ARRAY_SIZE(jz4775_cs3_groups), },
  1623. { "i2c0", jz4775_i2c0_groups, ARRAY_SIZE(jz4775_i2c0_groups), },
  1624. { "i2c1", jz4775_i2c1_groups, ARRAY_SIZE(jz4775_i2c1_groups), },
  1625. { "i2c2", jz4775_i2c2_groups, ARRAY_SIZE(jz4775_i2c2_groups), },
  1626. { "i2s", jz4775_i2s_groups, ARRAY_SIZE(jz4775_i2s_groups), },
  1627. { "dmic", jz4775_dmic_groups, ARRAY_SIZE(jz4775_dmic_groups), },
  1628. { "cim", jz4775_cim_groups, ARRAY_SIZE(jz4775_cim_groups), },
  1629. { "lcd", jz4775_lcd_groups, ARRAY_SIZE(jz4775_lcd_groups), },
  1630. { "pwm0", jz4775_pwm0_groups, ARRAY_SIZE(jz4775_pwm0_groups), },
  1631. { "pwm1", jz4775_pwm1_groups, ARRAY_SIZE(jz4775_pwm1_groups), },
  1632. { "pwm2", jz4775_pwm2_groups, ARRAY_SIZE(jz4775_pwm2_groups), },
  1633. { "pwm3", jz4775_pwm3_groups, ARRAY_SIZE(jz4775_pwm3_groups), },
  1634. { "mac", jz4775_mac_groups, ARRAY_SIZE(jz4775_mac_groups), },
  1635. { "otg", jz4775_otg_groups, ARRAY_SIZE(jz4775_otg_groups), },
  1636. };
  1637. static const struct ingenic_chip_info jz4775_chip_info = {
  1638. .num_chips = 7,
  1639. .reg_offset = 0x100,
  1640. .version = ID_JZ4775,
  1641. .groups = jz4775_groups,
  1642. .num_groups = ARRAY_SIZE(jz4775_groups),
  1643. .functions = jz4775_functions,
  1644. .num_functions = ARRAY_SIZE(jz4775_functions),
  1645. .pull_ups = jz4775_pull_ups,
  1646. .pull_downs = jz4775_pull_downs,
  1647. };
  1648. static const u32 jz4780_pull_ups[6] = {
  1649. 0x3fffffff, 0xfff0f3fc, 0x0fffffff, 0xffff4fff, 0xfffffb7c, 0x7fa7f00f,
  1650. };
  1651. static const u32 jz4780_pull_downs[6] = {
  1652. 0x00000000, 0x000f0c03, 0x00000000, 0x0000b000, 0x00000483, 0x00580ff0,
  1653. };
  1654. static int jz4780_uart2_data_pins[] = { 0x66, 0x67, };
  1655. static int jz4780_uart2_hwflow_pins[] = { 0x65, 0x64, };
  1656. static int jz4780_uart4_data_pins[] = { 0x54, 0x4a, };
  1657. static int jz4780_ssi0_dt_a_19_pins[] = { 0x13, };
  1658. static int jz4780_ssi0_dt_a_21_pins[] = { 0x15, };
  1659. static int jz4780_ssi0_dt_a_28_pins[] = { 0x1c, };
  1660. static int jz4780_ssi0_dt_b_pins[] = { 0x3d, };
  1661. static int jz4780_ssi0_dt_d_pins[] = { 0x79, };
  1662. static int jz4780_ssi0_dr_a_20_pins[] = { 0x14, };
  1663. static int jz4780_ssi0_dr_a_27_pins[] = { 0x1b, };
  1664. static int jz4780_ssi0_dr_b_pins[] = { 0x34, };
  1665. static int jz4780_ssi0_dr_d_pins[] = { 0x74, };
  1666. static int jz4780_ssi0_clk_a_pins[] = { 0x12, };
  1667. static int jz4780_ssi0_clk_b_5_pins[] = { 0x25, };
  1668. static int jz4780_ssi0_clk_b_28_pins[] = { 0x3c, };
  1669. static int jz4780_ssi0_clk_d_pins[] = { 0x78, };
  1670. static int jz4780_ssi0_gpc_b_pins[] = { 0x3e, };
  1671. static int jz4780_ssi0_gpc_d_pins[] = { 0x76, };
  1672. static int jz4780_ssi0_ce0_a_23_pins[] = { 0x17, };
  1673. static int jz4780_ssi0_ce0_a_25_pins[] = { 0x19, };
  1674. static int jz4780_ssi0_ce0_b_pins[] = { 0x3f, };
  1675. static int jz4780_ssi0_ce0_d_pins[] = { 0x77, };
  1676. static int jz4780_ssi0_ce1_b_pins[] = { 0x35, };
  1677. static int jz4780_ssi0_ce1_d_pins[] = { 0x75, };
  1678. static int jz4780_ssi1_dt_b_pins[] = { 0x3d, };
  1679. static int jz4780_ssi1_dt_d_pins[] = { 0x79, };
  1680. static int jz4780_ssi1_dr_b_pins[] = { 0x34, };
  1681. static int jz4780_ssi1_dr_d_pins[] = { 0x74, };
  1682. static int jz4780_ssi1_clk_b_pins[] = { 0x3c, };
  1683. static int jz4780_ssi1_clk_d_pins[] = { 0x78, };
  1684. static int jz4780_ssi1_gpc_b_pins[] = { 0x3e, };
  1685. static int jz4780_ssi1_gpc_d_pins[] = { 0x76, };
  1686. static int jz4780_ssi1_ce0_b_pins[] = { 0x3f, };
  1687. static int jz4780_ssi1_ce0_d_pins[] = { 0x77, };
  1688. static int jz4780_ssi1_ce1_b_pins[] = { 0x35, };
  1689. static int jz4780_ssi1_ce1_d_pins[] = { 0x75, };
  1690. static int jz4780_mmc0_8bit_a_pins[] = { 0x04, 0x05, 0x06, 0x07, 0x18, };
  1691. static int jz4780_i2c3_pins[] = { 0x6a, 0x6b, };
  1692. static int jz4780_i2c4_e_pins[] = { 0x8c, 0x8d, };
  1693. static int jz4780_i2c4_f_pins[] = { 0xb9, 0xb8, };
  1694. static int jz4780_i2s_data_tx_pins[] = { 0x87, };
  1695. static int jz4780_i2s_data_rx_pins[] = { 0x86, };
  1696. static int jz4780_i2s_clk_txrx_pins[] = { 0x6c, 0x6d, };
  1697. static int jz4780_i2s_clk_rx_pins[] = { 0x88, 0x89, };
  1698. static int jz4780_i2s_sysclk_pins[] = { 0x85, };
  1699. static int jz4780_dmic_pins[] = { 0x32, 0x33, };
  1700. static int jz4780_hdmi_ddc_pins[] = { 0xb9, 0xb8, };
  1701. static u8 jz4780_i2s_clk_txrx_funcs[] = { 1, 0, };
  1702. static const struct group_desc jz4780_groups[] = {
  1703. INGENIC_PIN_GROUP("uart0-data", jz4770_uart0_data, 0),
  1704. INGENIC_PIN_GROUP("uart0-hwflow", jz4770_uart0_hwflow, 0),
  1705. INGENIC_PIN_GROUP("uart1-data", jz4770_uart1_data, 0),
  1706. INGENIC_PIN_GROUP("uart1-hwflow", jz4770_uart1_hwflow, 0),
  1707. INGENIC_PIN_GROUP("uart2-data", jz4780_uart2_data, 1),
  1708. INGENIC_PIN_GROUP("uart2-hwflow", jz4780_uart2_hwflow, 1),
  1709. INGENIC_PIN_GROUP_FUNCS("uart3-data", jz4770_uart3_data,
  1710. jz4760_uart3_data_funcs),
  1711. INGENIC_PIN_GROUP("uart3-hwflow", jz4770_uart3_hwflow, 0),
  1712. INGENIC_PIN_GROUP("uart4-data", jz4780_uart4_data, 2),
  1713. INGENIC_PIN_GROUP("ssi0-dt-a-19", jz4780_ssi0_dt_a_19, 2),
  1714. INGENIC_PIN_GROUP("ssi0-dt-a-21", jz4780_ssi0_dt_a_21, 2),
  1715. INGENIC_PIN_GROUP("ssi0-dt-a-28", jz4780_ssi0_dt_a_28, 2),
  1716. INGENIC_PIN_GROUP("ssi0-dt-b", jz4780_ssi0_dt_b, 1),
  1717. INGENIC_PIN_GROUP("ssi0-dt-d", jz4780_ssi0_dt_d, 1),
  1718. INGENIC_PIN_GROUP("ssi0-dt-e", jz4770_ssi0_dt_e, 0),
  1719. INGENIC_PIN_GROUP("ssi0-dr-a-20", jz4780_ssi0_dr_a_20, 2),
  1720. INGENIC_PIN_GROUP("ssi0-dr-a-27", jz4780_ssi0_dr_a_27, 2),
  1721. INGENIC_PIN_GROUP("ssi0-dr-b", jz4780_ssi0_dr_b, 1),
  1722. INGENIC_PIN_GROUP("ssi0-dr-d", jz4780_ssi0_dr_d, 1),
  1723. INGENIC_PIN_GROUP("ssi0-dr-e", jz4770_ssi0_dr_e, 0),
  1724. INGENIC_PIN_GROUP("ssi0-clk-a", jz4780_ssi0_clk_a, 2),
  1725. INGENIC_PIN_GROUP("ssi0-clk-b-5", jz4780_ssi0_clk_b_5, 1),
  1726. INGENIC_PIN_GROUP("ssi0-clk-b-28", jz4780_ssi0_clk_b_28, 1),
  1727. INGENIC_PIN_GROUP("ssi0-clk-d", jz4780_ssi0_clk_d, 1),
  1728. INGENIC_PIN_GROUP("ssi0-clk-e", jz4770_ssi0_clk_e, 0),
  1729. INGENIC_PIN_GROUP("ssi0-gpc-b", jz4780_ssi0_gpc_b, 1),
  1730. INGENIC_PIN_GROUP("ssi0-gpc-d", jz4780_ssi0_gpc_d, 1),
  1731. INGENIC_PIN_GROUP("ssi0-gpc-e", jz4770_ssi0_gpc_e, 0),
  1732. INGENIC_PIN_GROUP("ssi0-ce0-a-23", jz4780_ssi0_ce0_a_23, 2),
  1733. INGENIC_PIN_GROUP("ssi0-ce0-a-25", jz4780_ssi0_ce0_a_25, 2),
  1734. INGENIC_PIN_GROUP("ssi0-ce0-b", jz4780_ssi0_ce0_b, 1),
  1735. INGENIC_PIN_GROUP("ssi0-ce0-d", jz4780_ssi0_ce0_d, 1),
  1736. INGENIC_PIN_GROUP("ssi0-ce0-e", jz4770_ssi0_ce0_e, 0),
  1737. INGENIC_PIN_GROUP("ssi0-ce1-b", jz4780_ssi0_ce1_b, 1),
  1738. INGENIC_PIN_GROUP("ssi0-ce1-d", jz4780_ssi0_ce1_d, 1),
  1739. INGENIC_PIN_GROUP("ssi0-ce1-e", jz4770_ssi0_ce1_e, 0),
  1740. INGENIC_PIN_GROUP("ssi1-dt-b", jz4780_ssi1_dt_b, 2),
  1741. INGENIC_PIN_GROUP("ssi1-dt-d", jz4780_ssi1_dt_d, 2),
  1742. INGENIC_PIN_GROUP("ssi1-dt-e", jz4770_ssi1_dt_e, 1),
  1743. INGENIC_PIN_GROUP("ssi1-dr-b", jz4780_ssi1_dr_b, 2),
  1744. INGENIC_PIN_GROUP("ssi1-dr-d", jz4780_ssi1_dr_d, 2),
  1745. INGENIC_PIN_GROUP("ssi1-dr-e", jz4770_ssi1_dr_e, 1),
  1746. INGENIC_PIN_GROUP("ssi1-clk-b", jz4780_ssi1_clk_b, 2),
  1747. INGENIC_PIN_GROUP("ssi1-clk-d", jz4780_ssi1_clk_d, 2),
  1748. INGENIC_PIN_GROUP("ssi1-clk-e", jz4770_ssi1_clk_e, 1),
  1749. INGENIC_PIN_GROUP("ssi1-gpc-b", jz4780_ssi1_gpc_b, 2),
  1750. INGENIC_PIN_GROUP("ssi1-gpc-d", jz4780_ssi1_gpc_d, 2),
  1751. INGENIC_PIN_GROUP("ssi1-gpc-e", jz4770_ssi1_gpc_e, 1),
  1752. INGENIC_PIN_GROUP("ssi1-ce0-b", jz4780_ssi1_ce0_b, 2),
  1753. INGENIC_PIN_GROUP("ssi1-ce0-d", jz4780_ssi1_ce0_d, 2),
  1754. INGENIC_PIN_GROUP("ssi1-ce0-e", jz4770_ssi1_ce0_e, 1),
  1755. INGENIC_PIN_GROUP("ssi1-ce1-b", jz4780_ssi1_ce1_b, 2),
  1756. INGENIC_PIN_GROUP("ssi1-ce1-d", jz4780_ssi1_ce1_d, 2),
  1757. INGENIC_PIN_GROUP("ssi1-ce1-e", jz4770_ssi1_ce1_e, 1),
  1758. INGENIC_PIN_GROUP_FUNCS("mmc0-1bit-a", jz4770_mmc0_1bit_a,
  1759. jz4760_mmc0_1bit_a_funcs),
  1760. INGENIC_PIN_GROUP("mmc0-4bit-a", jz4770_mmc0_4bit_a, 1),
  1761. INGENIC_PIN_GROUP("mmc0-8bit-a", jz4780_mmc0_8bit_a, 1),
  1762. INGENIC_PIN_GROUP("mmc0-1bit-e", jz4770_mmc0_1bit_e, 0),
  1763. INGENIC_PIN_GROUP("mmc0-4bit-e", jz4770_mmc0_4bit_e, 0),
  1764. INGENIC_PIN_GROUP("mmc1-1bit-d", jz4770_mmc1_1bit_d, 0),
  1765. INGENIC_PIN_GROUP("mmc1-4bit-d", jz4770_mmc1_4bit_d, 0),
  1766. INGENIC_PIN_GROUP("mmc1-1bit-e", jz4770_mmc1_1bit_e, 1),
  1767. INGENIC_PIN_GROUP("mmc1-4bit-e", jz4770_mmc1_4bit_e, 1),
  1768. INGENIC_PIN_GROUP("mmc2-1bit-b", jz4770_mmc2_1bit_b, 0),
  1769. INGENIC_PIN_GROUP("mmc2-4bit-b", jz4770_mmc2_4bit_b, 0),
  1770. INGENIC_PIN_GROUP("mmc2-1bit-e", jz4770_mmc2_1bit_e, 2),
  1771. INGENIC_PIN_GROUP("mmc2-4bit-e", jz4770_mmc2_4bit_e, 2),
  1772. INGENIC_PIN_GROUP("nemc-data", jz4770_nemc_8bit_data, 0),
  1773. INGENIC_PIN_GROUP("nemc-cle-ale", jz4770_nemc_cle_ale, 0),
  1774. INGENIC_PIN_GROUP("nemc-addr", jz4770_nemc_addr, 0),
  1775. INGENIC_PIN_GROUP("nemc-rd-we", jz4770_nemc_rd_we, 0),
  1776. INGENIC_PIN_GROUP("nemc-frd-fwe", jz4770_nemc_frd_fwe, 0),
  1777. INGENIC_PIN_GROUP("nemc-wait", jz4770_nemc_wait, 0),
  1778. INGENIC_PIN_GROUP("nemc-cs1", jz4770_nemc_cs1, 0),
  1779. INGENIC_PIN_GROUP("nemc-cs2", jz4770_nemc_cs2, 0),
  1780. INGENIC_PIN_GROUP("nemc-cs3", jz4770_nemc_cs3, 0),
  1781. INGENIC_PIN_GROUP("nemc-cs4", jz4770_nemc_cs4, 0),
  1782. INGENIC_PIN_GROUP("nemc-cs5", jz4770_nemc_cs5, 0),
  1783. INGENIC_PIN_GROUP("nemc-cs6", jz4770_nemc_cs6, 0),
  1784. INGENIC_PIN_GROUP("i2c0-data", jz4770_i2c0, 0),
  1785. INGENIC_PIN_GROUP("i2c1-data", jz4770_i2c1, 0),
  1786. INGENIC_PIN_GROUP("i2c2-data", jz4770_i2c2, 2),
  1787. INGENIC_PIN_GROUP("i2c3-data", jz4780_i2c3, 1),
  1788. INGENIC_PIN_GROUP("i2c4-data-e", jz4780_i2c4_e, 1),
  1789. INGENIC_PIN_GROUP("i2c4-data-f", jz4780_i2c4_f, 1),
  1790. INGENIC_PIN_GROUP("i2s-data-tx", jz4780_i2s_data_tx, 0),
  1791. INGENIC_PIN_GROUP("i2s-data-rx", jz4780_i2s_data_rx, 0),
  1792. INGENIC_PIN_GROUP_FUNCS("i2s-clk-txrx", jz4780_i2s_clk_txrx,
  1793. jz4780_i2s_clk_txrx_funcs),
  1794. INGENIC_PIN_GROUP("i2s-clk-rx", jz4780_i2s_clk_rx, 1),
  1795. INGENIC_PIN_GROUP("i2s-sysclk", jz4780_i2s_sysclk, 2),
  1796. INGENIC_PIN_GROUP("dmic", jz4780_dmic, 1),
  1797. INGENIC_PIN_GROUP("hdmi-ddc", jz4780_hdmi_ddc, 0),
  1798. INGENIC_PIN_GROUP("cim-data", jz4770_cim_8bit, 0),
  1799. INGENIC_PIN_GROUP("cim-data-12bit", jz4770_cim_12bit, 0),
  1800. INGENIC_PIN_GROUP("lcd-8bit", jz4770_lcd_8bit, 0),
  1801. INGENIC_PIN_GROUP("lcd-16bit", jz4770_lcd_16bit, 0),
  1802. INGENIC_PIN_GROUP("lcd-18bit", jz4770_lcd_18bit, 0),
  1803. INGENIC_PIN_GROUP("lcd-24bit", jz4770_lcd_24bit, 0),
  1804. INGENIC_PIN_GROUP("lcd-special", jz4770_lcd_special, 1),
  1805. INGENIC_PIN_GROUP("lcd-generic", jz4770_lcd_generic, 0),
  1806. INGENIC_PIN_GROUP("pwm0", jz4770_pwm_pwm0, 0),
  1807. INGENIC_PIN_GROUP("pwm1", jz4770_pwm_pwm1, 0),
  1808. INGENIC_PIN_GROUP("pwm2", jz4770_pwm_pwm2, 0),
  1809. INGENIC_PIN_GROUP("pwm3", jz4770_pwm_pwm3, 0),
  1810. INGENIC_PIN_GROUP("pwm4", jz4770_pwm_pwm4, 0),
  1811. INGENIC_PIN_GROUP("pwm5", jz4770_pwm_pwm5, 0),
  1812. INGENIC_PIN_GROUP("pwm6", jz4770_pwm_pwm6, 0),
  1813. INGENIC_PIN_GROUP("pwm7", jz4770_pwm_pwm7, 0),
  1814. };
  1815. static const char *jz4780_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
  1816. static const char *jz4780_uart4_groups[] = { "uart4-data", };
  1817. static const char *jz4780_ssi0_groups[] = {
  1818. "ssi0-dt-a-19", "ssi0-dt-a-21", "ssi0-dt-a-28", "ssi0-dt-b", "ssi0-dt-d", "ssi0-dt-e",
  1819. "ssi0-dr-a-20", "ssi0-dr-a-27", "ssi0-dr-b", "ssi0-dr-d", "ssi0-dr-e",
  1820. "ssi0-clk-a", "ssi0-clk-b-5", "ssi0-clk-b-28", "ssi0-clk-d", "ssi0-clk-e",
  1821. "ssi0-gpc-b", "ssi0-gpc-d", "ssi0-gpc-e",
  1822. "ssi0-ce0-a-23", "ssi0-ce0-a-25", "ssi0-ce0-b", "ssi0-ce0-d", "ssi0-ce0-e",
  1823. "ssi0-ce1-b", "ssi0-ce1-d", "ssi0-ce1-e",
  1824. };
  1825. static const char *jz4780_ssi1_groups[] = {
  1826. "ssi1-dt-b", "ssi1-dt-d", "ssi1-dt-e",
  1827. "ssi1-dr-b", "ssi1-dr-d", "ssi1-dr-e",
  1828. "ssi1-clk-b", "ssi1-clk-d", "ssi1-clk-e",
  1829. "ssi1-gpc-b", "ssi1-gpc-d", "ssi1-gpc-e",
  1830. "ssi1-ce0-b", "ssi1-ce0-d", "ssi1-ce0-e",
  1831. "ssi1-ce1-b", "ssi1-ce1-d", "ssi1-ce1-e",
  1832. };
  1833. static const char *jz4780_mmc0_groups[] = {
  1834. "mmc0-1bit-a", "mmc0-4bit-a", "mmc0-8bit-a",
  1835. "mmc0-1bit-e", "mmc0-4bit-e",
  1836. };
  1837. static const char *jz4780_mmc1_groups[] = {
  1838. "mmc1-1bit-d", "mmc1-4bit-d", "mmc1-1bit-e", "mmc1-4bit-e",
  1839. };
  1840. static const char *jz4780_mmc2_groups[] = {
  1841. "mmc2-1bit-b", "mmc2-4bit-b", "mmc2-1bit-e", "mmc2-4bit-e",
  1842. };
  1843. static const char *jz4780_nemc_groups[] = {
  1844. "nemc-data", "nemc-cle-ale", "nemc-addr",
  1845. "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
  1846. };
  1847. static const char *jz4780_i2c3_groups[] = { "i2c3-data", };
  1848. static const char *jz4780_i2c4_groups[] = { "i2c4-data-e", "i2c4-data-f", };
  1849. static const char *jz4780_i2s_groups[] = {
  1850. "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-clk-rx", "i2s-sysclk",
  1851. };
  1852. static const char *jz4780_dmic_groups[] = { "dmic", };
  1853. static const char *jz4780_cim_groups[] = { "cim-data", };
  1854. static const char *jz4780_hdmi_ddc_groups[] = { "hdmi-ddc", };
  1855. static const struct function_desc jz4780_functions[] = {
  1856. { "uart0", jz4770_uart0_groups, ARRAY_SIZE(jz4770_uart0_groups), },
  1857. { "uart1", jz4770_uart1_groups, ARRAY_SIZE(jz4770_uart1_groups), },
  1858. { "uart2", jz4780_uart2_groups, ARRAY_SIZE(jz4780_uart2_groups), },
  1859. { "uart3", jz4770_uart3_groups, ARRAY_SIZE(jz4770_uart3_groups), },
  1860. { "uart4", jz4780_uart4_groups, ARRAY_SIZE(jz4780_uart4_groups), },
  1861. { "ssi0", jz4780_ssi0_groups, ARRAY_SIZE(jz4780_ssi0_groups), },
  1862. { "ssi1", jz4780_ssi1_groups, ARRAY_SIZE(jz4780_ssi1_groups), },
  1863. { "mmc0", jz4780_mmc0_groups, ARRAY_SIZE(jz4780_mmc0_groups), },
  1864. { "mmc1", jz4780_mmc1_groups, ARRAY_SIZE(jz4780_mmc1_groups), },
  1865. { "mmc2", jz4780_mmc2_groups, ARRAY_SIZE(jz4780_mmc2_groups), },
  1866. { "nemc", jz4780_nemc_groups, ARRAY_SIZE(jz4780_nemc_groups), },
  1867. { "nemc-cs1", jz4770_cs1_groups, ARRAY_SIZE(jz4770_cs1_groups), },
  1868. { "nemc-cs2", jz4770_cs2_groups, ARRAY_SIZE(jz4770_cs2_groups), },
  1869. { "nemc-cs3", jz4770_cs3_groups, ARRAY_SIZE(jz4770_cs3_groups), },
  1870. { "nemc-cs4", jz4770_cs4_groups, ARRAY_SIZE(jz4770_cs4_groups), },
  1871. { "nemc-cs5", jz4770_cs5_groups, ARRAY_SIZE(jz4770_cs5_groups), },
  1872. { "nemc-cs6", jz4770_cs6_groups, ARRAY_SIZE(jz4770_cs6_groups), },
  1873. { "i2c0", jz4770_i2c0_groups, ARRAY_SIZE(jz4770_i2c0_groups), },
  1874. { "i2c1", jz4770_i2c1_groups, ARRAY_SIZE(jz4770_i2c1_groups), },
  1875. { "i2c2", jz4770_i2c2_groups, ARRAY_SIZE(jz4770_i2c2_groups), },
  1876. { "i2c3", jz4780_i2c3_groups, ARRAY_SIZE(jz4780_i2c3_groups), },
  1877. { "i2c4", jz4780_i2c4_groups, ARRAY_SIZE(jz4780_i2c4_groups), },
  1878. { "i2s", jz4780_i2s_groups, ARRAY_SIZE(jz4780_i2s_groups), },
  1879. { "dmic", jz4780_dmic_groups, ARRAY_SIZE(jz4780_dmic_groups), },
  1880. { "cim", jz4780_cim_groups, ARRAY_SIZE(jz4780_cim_groups), },
  1881. { "lcd", jz4770_lcd_groups, ARRAY_SIZE(jz4770_lcd_groups), },
  1882. { "pwm0", jz4770_pwm0_groups, ARRAY_SIZE(jz4770_pwm0_groups), },
  1883. { "pwm1", jz4770_pwm1_groups, ARRAY_SIZE(jz4770_pwm1_groups), },
  1884. { "pwm2", jz4770_pwm2_groups, ARRAY_SIZE(jz4770_pwm2_groups), },
  1885. { "pwm3", jz4770_pwm3_groups, ARRAY_SIZE(jz4770_pwm3_groups), },
  1886. { "pwm4", jz4770_pwm4_groups, ARRAY_SIZE(jz4770_pwm4_groups), },
  1887. { "pwm5", jz4770_pwm5_groups, ARRAY_SIZE(jz4770_pwm5_groups), },
  1888. { "pwm6", jz4770_pwm6_groups, ARRAY_SIZE(jz4770_pwm6_groups), },
  1889. { "pwm7", jz4770_pwm7_groups, ARRAY_SIZE(jz4770_pwm7_groups), },
  1890. { "hdmi-ddc", jz4780_hdmi_ddc_groups,
  1891. ARRAY_SIZE(jz4780_hdmi_ddc_groups), },
  1892. };
  1893. static const struct ingenic_chip_info jz4780_chip_info = {
  1894. .num_chips = 6,
  1895. .reg_offset = 0x100,
  1896. .version = ID_JZ4780,
  1897. .groups = jz4780_groups,
  1898. .num_groups = ARRAY_SIZE(jz4780_groups),
  1899. .functions = jz4780_functions,
  1900. .num_functions = ARRAY_SIZE(jz4780_functions),
  1901. .pull_ups = jz4780_pull_ups,
  1902. .pull_downs = jz4780_pull_downs,
  1903. };
  1904. static const u32 x1000_pull_ups[4] = {
  1905. 0xffffffff, 0xfdffffff, 0x0dffffff, 0x0000003f,
  1906. };
  1907. static const u32 x1000_pull_downs[4] = {
  1908. 0x00000000, 0x02000000, 0x02000000, 0x00000000,
  1909. };
  1910. static int x1000_uart0_data_pins[] = { 0x4a, 0x4b, };
  1911. static int x1000_uart0_hwflow_pins[] = { 0x4c, 0x4d, };
  1912. static int x1000_uart1_data_a_pins[] = { 0x04, 0x05, };
  1913. static int x1000_uart1_data_d_pins[] = { 0x62, 0x63, };
  1914. static int x1000_uart1_hwflow_pins[] = { 0x64, 0x65, };
  1915. static int x1000_uart2_data_a_pins[] = { 0x02, 0x03, };
  1916. static int x1000_uart2_data_d_pins[] = { 0x65, 0x64, };
  1917. static int x1000_sfc_data_pins[] = { 0x1d, 0x1c, 0x1e, 0x1f, };
  1918. static int x1000_sfc_clk_pins[] = { 0x1a, };
  1919. static int x1000_sfc_ce_pins[] = { 0x1b, };
  1920. static int x1000_ssi_dt_a_22_pins[] = { 0x16, };
  1921. static int x1000_ssi_dt_a_29_pins[] = { 0x1d, };
  1922. static int x1000_ssi_dt_d_pins[] = { 0x62, };
  1923. static int x1000_ssi_dr_a_23_pins[] = { 0x17, };
  1924. static int x1000_ssi_dr_a_28_pins[] = { 0x1c, };
  1925. static int x1000_ssi_dr_d_pins[] = { 0x63, };
  1926. static int x1000_ssi_clk_a_24_pins[] = { 0x18, };
  1927. static int x1000_ssi_clk_a_26_pins[] = { 0x1a, };
  1928. static int x1000_ssi_clk_d_pins[] = { 0x60, };
  1929. static int x1000_ssi_gpc_a_20_pins[] = { 0x14, };
  1930. static int x1000_ssi_gpc_a_31_pins[] = { 0x1f, };
  1931. static int x1000_ssi_ce0_a_25_pins[] = { 0x19, };
  1932. static int x1000_ssi_ce0_a_27_pins[] = { 0x1b, };
  1933. static int x1000_ssi_ce0_d_pins[] = { 0x61, };
  1934. static int x1000_ssi_ce1_a_21_pins[] = { 0x15, };
  1935. static int x1000_ssi_ce1_a_30_pins[] = { 0x1e, };
  1936. static int x1000_mmc0_1bit_pins[] = { 0x18, 0x19, 0x17, };
  1937. static int x1000_mmc0_4bit_pins[] = { 0x16, 0x15, 0x14, };
  1938. static int x1000_mmc0_8bit_pins[] = { 0x13, 0x12, 0x11, 0x10, };
  1939. static int x1000_mmc1_1bit_pins[] = { 0x40, 0x41, 0x42, };
  1940. static int x1000_mmc1_4bit_pins[] = { 0x43, 0x44, 0x45, };
  1941. static int x1000_emc_8bit_data_pins[] = {
  1942. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  1943. };
  1944. static int x1000_emc_16bit_data_pins[] = {
  1945. 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
  1946. };
  1947. static int x1000_emc_addr_pins[] = {
  1948. 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
  1949. 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
  1950. };
  1951. static int x1000_emc_rd_we_pins[] = { 0x30, 0x31, };
  1952. static int x1000_emc_wait_pins[] = { 0x34, };
  1953. static int x1000_emc_cs1_pins[] = { 0x32, };
  1954. static int x1000_emc_cs2_pins[] = { 0x33, };
  1955. static int x1000_i2c0_pins[] = { 0x38, 0x37, };
  1956. static int x1000_i2c1_a_pins[] = { 0x01, 0x00, };
  1957. static int x1000_i2c1_c_pins[] = { 0x5b, 0x5a, };
  1958. static int x1000_i2c2_pins[] = { 0x61, 0x60, };
  1959. static int x1000_i2s_data_tx_pins[] = { 0x24, };
  1960. static int x1000_i2s_data_rx_pins[] = { 0x23, };
  1961. static int x1000_i2s_clk_txrx_pins[] = { 0x21, 0x22, };
  1962. static int x1000_i2s_sysclk_pins[] = { 0x20, };
  1963. static int x1000_dmic_if0_pins[] = { 0x35, 0x36, };
  1964. static int x1000_dmic_if1_pins[] = { 0x25, };
  1965. static int x1000_cim_pins[] = {
  1966. 0x08, 0x09, 0x0a, 0x0b,
  1967. 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c,
  1968. };
  1969. static int x1000_lcd_8bit_pins[] = {
  1970. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  1971. 0x30, 0x31, 0x32, 0x33, 0x34,
  1972. };
  1973. static int x1000_lcd_16bit_pins[] = {
  1974. 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
  1975. };
  1976. static int x1000_pwm_pwm0_pins[] = { 0x59, };
  1977. static int x1000_pwm_pwm1_pins[] = { 0x5a, };
  1978. static int x1000_pwm_pwm2_pins[] = { 0x5b, };
  1979. static int x1000_pwm_pwm3_pins[] = { 0x26, };
  1980. static int x1000_pwm_pwm4_pins[] = { 0x58, };
  1981. static int x1000_mac_pins[] = {
  1982. 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x26,
  1983. };
  1984. static const struct group_desc x1000_groups[] = {
  1985. INGENIC_PIN_GROUP("uart0-data", x1000_uart0_data, 0),
  1986. INGENIC_PIN_GROUP("uart0-hwflow", x1000_uart0_hwflow, 0),
  1987. INGENIC_PIN_GROUP("uart1-data-a", x1000_uart1_data_a, 2),
  1988. INGENIC_PIN_GROUP("uart1-data-d", x1000_uart1_data_d, 1),
  1989. INGENIC_PIN_GROUP("uart1-hwflow", x1000_uart1_hwflow, 1),
  1990. INGENIC_PIN_GROUP("uart2-data-a", x1000_uart2_data_a, 2),
  1991. INGENIC_PIN_GROUP("uart2-data-d", x1000_uart2_data_d, 0),
  1992. INGENIC_PIN_GROUP("sfc-data", x1000_sfc_data, 1),
  1993. INGENIC_PIN_GROUP("sfc-clk", x1000_sfc_clk, 1),
  1994. INGENIC_PIN_GROUP("sfc-ce", x1000_sfc_ce, 1),
  1995. INGENIC_PIN_GROUP("ssi-dt-a-22", x1000_ssi_dt_a_22, 2),
  1996. INGENIC_PIN_GROUP("ssi-dt-a-29", x1000_ssi_dt_a_29, 2),
  1997. INGENIC_PIN_GROUP("ssi-dt-d", x1000_ssi_dt_d, 0),
  1998. INGENIC_PIN_GROUP("ssi-dr-a-23", x1000_ssi_dr_a_23, 2),
  1999. INGENIC_PIN_GROUP("ssi-dr-a-28", x1000_ssi_dr_a_28, 2),
  2000. INGENIC_PIN_GROUP("ssi-dr-d", x1000_ssi_dr_d, 0),
  2001. INGENIC_PIN_GROUP("ssi-clk-a-24", x1000_ssi_clk_a_24, 2),
  2002. INGENIC_PIN_GROUP("ssi-clk-a-26", x1000_ssi_clk_a_26, 2),
  2003. INGENIC_PIN_GROUP("ssi-clk-d", x1000_ssi_clk_d, 0),
  2004. INGENIC_PIN_GROUP("ssi-gpc-a-20", x1000_ssi_gpc_a_20, 2),
  2005. INGENIC_PIN_GROUP("ssi-gpc-a-31", x1000_ssi_gpc_a_31, 2),
  2006. INGENIC_PIN_GROUP("ssi-ce0-a-25", x1000_ssi_ce0_a_25, 2),
  2007. INGENIC_PIN_GROUP("ssi-ce0-a-27", x1000_ssi_ce0_a_27, 2),
  2008. INGENIC_PIN_GROUP("ssi-ce0-d", x1000_ssi_ce0_d, 0),
  2009. INGENIC_PIN_GROUP("ssi-ce1-a-21", x1000_ssi_ce1_a_21, 2),
  2010. INGENIC_PIN_GROUP("ssi-ce1-a-30", x1000_ssi_ce1_a_30, 2),
  2011. INGENIC_PIN_GROUP("mmc0-1bit", x1000_mmc0_1bit, 1),
  2012. INGENIC_PIN_GROUP("mmc0-4bit", x1000_mmc0_4bit, 1),
  2013. INGENIC_PIN_GROUP("mmc0-8bit", x1000_mmc0_8bit, 1),
  2014. INGENIC_PIN_GROUP("mmc1-1bit", x1000_mmc1_1bit, 0),
  2015. INGENIC_PIN_GROUP("mmc1-4bit", x1000_mmc1_4bit, 0),
  2016. INGENIC_PIN_GROUP("emc-8bit-data", x1000_emc_8bit_data, 0),
  2017. INGENIC_PIN_GROUP("emc-16bit-data", x1000_emc_16bit_data, 0),
  2018. INGENIC_PIN_GROUP("emc-addr", x1000_emc_addr, 0),
  2019. INGENIC_PIN_GROUP("emc-rd-we", x1000_emc_rd_we, 0),
  2020. INGENIC_PIN_GROUP("emc-wait", x1000_emc_wait, 0),
  2021. INGENIC_PIN_GROUP("emc-cs1", x1000_emc_cs1, 0),
  2022. INGENIC_PIN_GROUP("emc-cs2", x1000_emc_cs2, 0),
  2023. INGENIC_PIN_GROUP("i2c0-data", x1000_i2c0, 0),
  2024. INGENIC_PIN_GROUP("i2c1-data-a", x1000_i2c1_a, 2),
  2025. INGENIC_PIN_GROUP("i2c1-data-c", x1000_i2c1_c, 0),
  2026. INGENIC_PIN_GROUP("i2c2-data", x1000_i2c2, 1),
  2027. INGENIC_PIN_GROUP("i2s-data-tx", x1000_i2s_data_tx, 1),
  2028. INGENIC_PIN_GROUP("i2s-data-rx", x1000_i2s_data_rx, 1),
  2029. INGENIC_PIN_GROUP("i2s-clk-txrx", x1000_i2s_clk_txrx, 1),
  2030. INGENIC_PIN_GROUP("i2s-sysclk", x1000_i2s_sysclk, 1),
  2031. INGENIC_PIN_GROUP("dmic-if0", x1000_dmic_if0, 0),
  2032. INGENIC_PIN_GROUP("dmic-if1", x1000_dmic_if1, 1),
  2033. INGENIC_PIN_GROUP("cim-data", x1000_cim, 2),
  2034. INGENIC_PIN_GROUP("lcd-8bit", x1000_lcd_8bit, 1),
  2035. INGENIC_PIN_GROUP("lcd-16bit", x1000_lcd_16bit, 1),
  2036. INGENIC_PIN_GROUP("pwm0", x1000_pwm_pwm0, 0),
  2037. INGENIC_PIN_GROUP("pwm1", x1000_pwm_pwm1, 1),
  2038. INGENIC_PIN_GROUP("pwm2", x1000_pwm_pwm2, 1),
  2039. INGENIC_PIN_GROUP("pwm3", x1000_pwm_pwm3, 2),
  2040. INGENIC_PIN_GROUP("pwm4", x1000_pwm_pwm4, 0),
  2041. INGENIC_PIN_GROUP("mac", x1000_mac, 1),
  2042. };
  2043. static const char *x1000_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
  2044. static const char *x1000_uart1_groups[] = {
  2045. "uart1-data-a", "uart1-data-d", "uart1-hwflow",
  2046. };
  2047. static const char *x1000_uart2_groups[] = { "uart2-data-a", "uart2-data-d", };
  2048. static const char *x1000_sfc_groups[] = { "sfc-data", "sfc-clk", "sfc-ce", };
  2049. static const char *x1000_ssi_groups[] = {
  2050. "ssi-dt-a-22", "ssi-dt-a-29", "ssi-dt-d",
  2051. "ssi-dr-a-23", "ssi-dr-a-28", "ssi-dr-d",
  2052. "ssi-clk-a-24", "ssi-clk-a-26", "ssi-clk-d",
  2053. "ssi-gpc-a-20", "ssi-gpc-a-31",
  2054. "ssi-ce0-a-25", "ssi-ce0-a-27", "ssi-ce0-d",
  2055. "ssi-ce1-a-21", "ssi-ce1-a-30",
  2056. };
  2057. static const char *x1000_mmc0_groups[] = {
  2058. "mmc0-1bit", "mmc0-4bit", "mmc0-8bit",
  2059. };
  2060. static const char *x1000_mmc1_groups[] = {
  2061. "mmc1-1bit", "mmc1-4bit",
  2062. };
  2063. static const char *x1000_emc_groups[] = {
  2064. "emc-8bit-data", "emc-16bit-data",
  2065. "emc-addr", "emc-rd-we", "emc-wait",
  2066. };
  2067. static const char *x1000_cs1_groups[] = { "emc-cs1", };
  2068. static const char *x1000_cs2_groups[] = { "emc-cs2", };
  2069. static const char *x1000_i2c0_groups[] = { "i2c0-data", };
  2070. static const char *x1000_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", };
  2071. static const char *x1000_i2c2_groups[] = { "i2c2-data", };
  2072. static const char *x1000_i2s_groups[] = {
  2073. "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-sysclk",
  2074. };
  2075. static const char *x1000_dmic_groups[] = { "dmic-if0", "dmic-if1", };
  2076. static const char *x1000_cim_groups[] = { "cim-data", };
  2077. static const char *x1000_lcd_groups[] = { "lcd-8bit", "lcd-16bit", };
  2078. static const char *x1000_pwm0_groups[] = { "pwm0", };
  2079. static const char *x1000_pwm1_groups[] = { "pwm1", };
  2080. static const char *x1000_pwm2_groups[] = { "pwm2", };
  2081. static const char *x1000_pwm3_groups[] = { "pwm3", };
  2082. static const char *x1000_pwm4_groups[] = { "pwm4", };
  2083. static const char *x1000_mac_groups[] = { "mac", };
  2084. static const struct function_desc x1000_functions[] = {
  2085. { "uart0", x1000_uart0_groups, ARRAY_SIZE(x1000_uart0_groups), },
  2086. { "uart1", x1000_uart1_groups, ARRAY_SIZE(x1000_uart1_groups), },
  2087. { "uart2", x1000_uart2_groups, ARRAY_SIZE(x1000_uart2_groups), },
  2088. { "sfc", x1000_sfc_groups, ARRAY_SIZE(x1000_sfc_groups), },
  2089. { "ssi", x1000_ssi_groups, ARRAY_SIZE(x1000_ssi_groups), },
  2090. { "mmc0", x1000_mmc0_groups, ARRAY_SIZE(x1000_mmc0_groups), },
  2091. { "mmc1", x1000_mmc1_groups, ARRAY_SIZE(x1000_mmc1_groups), },
  2092. { "emc", x1000_emc_groups, ARRAY_SIZE(x1000_emc_groups), },
  2093. { "emc-cs1", x1000_cs1_groups, ARRAY_SIZE(x1000_cs1_groups), },
  2094. { "emc-cs2", x1000_cs2_groups, ARRAY_SIZE(x1000_cs2_groups), },
  2095. { "i2c0", x1000_i2c0_groups, ARRAY_SIZE(x1000_i2c0_groups), },
  2096. { "i2c1", x1000_i2c1_groups, ARRAY_SIZE(x1000_i2c1_groups), },
  2097. { "i2c2", x1000_i2c2_groups, ARRAY_SIZE(x1000_i2c2_groups), },
  2098. { "i2s", x1000_i2s_groups, ARRAY_SIZE(x1000_i2s_groups), },
  2099. { "dmic", x1000_dmic_groups, ARRAY_SIZE(x1000_dmic_groups), },
  2100. { "cim", x1000_cim_groups, ARRAY_SIZE(x1000_cim_groups), },
  2101. { "lcd", x1000_lcd_groups, ARRAY_SIZE(x1000_lcd_groups), },
  2102. { "pwm0", x1000_pwm0_groups, ARRAY_SIZE(x1000_pwm0_groups), },
  2103. { "pwm1", x1000_pwm1_groups, ARRAY_SIZE(x1000_pwm1_groups), },
  2104. { "pwm2", x1000_pwm2_groups, ARRAY_SIZE(x1000_pwm2_groups), },
  2105. { "pwm3", x1000_pwm3_groups, ARRAY_SIZE(x1000_pwm3_groups), },
  2106. { "pwm4", x1000_pwm4_groups, ARRAY_SIZE(x1000_pwm4_groups), },
  2107. { "mac", x1000_mac_groups, ARRAY_SIZE(x1000_mac_groups), },
  2108. };
  2109. static const struct regmap_range x1000_access_ranges[] = {
  2110. regmap_reg_range(0x000, 0x400 - 4),
  2111. regmap_reg_range(0x700, 0x800 - 4),
  2112. };
  2113. /* shared with X1500 */
  2114. static const struct regmap_access_table x1000_access_table = {
  2115. .yes_ranges = x1000_access_ranges,
  2116. .n_yes_ranges = ARRAY_SIZE(x1000_access_ranges),
  2117. };
  2118. static const struct ingenic_chip_info x1000_chip_info = {
  2119. .num_chips = 4,
  2120. .reg_offset = 0x100,
  2121. .version = ID_X1000,
  2122. .groups = x1000_groups,
  2123. .num_groups = ARRAY_SIZE(x1000_groups),
  2124. .functions = x1000_functions,
  2125. .num_functions = ARRAY_SIZE(x1000_functions),
  2126. .pull_ups = x1000_pull_ups,
  2127. .pull_downs = x1000_pull_downs,
  2128. .access_table = &x1000_access_table,
  2129. };
  2130. static int x1500_uart0_data_pins[] = { 0x4a, 0x4b, };
  2131. static int x1500_uart0_hwflow_pins[] = { 0x4c, 0x4d, };
  2132. static int x1500_uart1_data_a_pins[] = { 0x04, 0x05, };
  2133. static int x1500_uart1_data_d_pins[] = { 0x62, 0x63, };
  2134. static int x1500_uart1_hwflow_pins[] = { 0x64, 0x65, };
  2135. static int x1500_uart2_data_a_pins[] = { 0x02, 0x03, };
  2136. static int x1500_uart2_data_d_pins[] = { 0x65, 0x64, };
  2137. static int x1500_mmc_1bit_pins[] = { 0x18, 0x19, 0x17, };
  2138. static int x1500_mmc_4bit_pins[] = { 0x16, 0x15, 0x14, };
  2139. static int x1500_i2c0_pins[] = { 0x38, 0x37, };
  2140. static int x1500_i2c1_a_pins[] = { 0x01, 0x00, };
  2141. static int x1500_i2c1_c_pins[] = { 0x5b, 0x5a, };
  2142. static int x1500_i2c2_pins[] = { 0x61, 0x60, };
  2143. static int x1500_i2s_data_tx_pins[] = { 0x24, };
  2144. static int x1500_i2s_data_rx_pins[] = { 0x23, };
  2145. static int x1500_i2s_clk_txrx_pins[] = { 0x21, 0x22, };
  2146. static int x1500_i2s_sysclk_pins[] = { 0x20, };
  2147. static int x1500_dmic_if0_pins[] = { 0x35, 0x36, };
  2148. static int x1500_dmic_if1_pins[] = { 0x25, };
  2149. static int x1500_cim_pins[] = {
  2150. 0x08, 0x09, 0x0a, 0x0b,
  2151. 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c,
  2152. };
  2153. static int x1500_pwm_pwm0_pins[] = { 0x59, };
  2154. static int x1500_pwm_pwm1_pins[] = { 0x5a, };
  2155. static int x1500_pwm_pwm2_pins[] = { 0x5b, };
  2156. static int x1500_pwm_pwm3_pins[] = { 0x26, };
  2157. static int x1500_pwm_pwm4_pins[] = { 0x58, };
  2158. static const struct group_desc x1500_groups[] = {
  2159. INGENIC_PIN_GROUP("uart0-data", x1500_uart0_data, 0),
  2160. INGENIC_PIN_GROUP("uart0-hwflow", x1500_uart0_hwflow, 0),
  2161. INGENIC_PIN_GROUP("uart1-data-a", x1500_uart1_data_a, 2),
  2162. INGENIC_PIN_GROUP("uart1-data-d", x1500_uart1_data_d, 1),
  2163. INGENIC_PIN_GROUP("uart1-hwflow", x1500_uart1_hwflow, 1),
  2164. INGENIC_PIN_GROUP("uart2-data-a", x1500_uart2_data_a, 2),
  2165. INGENIC_PIN_GROUP("uart2-data-d", x1500_uart2_data_d, 0),
  2166. INGENIC_PIN_GROUP("sfc-data", x1000_sfc_data, 1),
  2167. INGENIC_PIN_GROUP("sfc-clk", x1000_sfc_clk, 1),
  2168. INGENIC_PIN_GROUP("sfc-ce", x1000_sfc_ce, 1),
  2169. INGENIC_PIN_GROUP("mmc-1bit", x1500_mmc_1bit, 1),
  2170. INGENIC_PIN_GROUP("mmc-4bit", x1500_mmc_4bit, 1),
  2171. INGENIC_PIN_GROUP("i2c0-data", x1500_i2c0, 0),
  2172. INGENIC_PIN_GROUP("i2c1-data-a", x1500_i2c1_a, 2),
  2173. INGENIC_PIN_GROUP("i2c1-data-c", x1500_i2c1_c, 0),
  2174. INGENIC_PIN_GROUP("i2c2-data", x1500_i2c2, 1),
  2175. INGENIC_PIN_GROUP("i2s-data-tx", x1500_i2s_data_tx, 1),
  2176. INGENIC_PIN_GROUP("i2s-data-rx", x1500_i2s_data_rx, 1),
  2177. INGENIC_PIN_GROUP("i2s-clk-txrx", x1500_i2s_clk_txrx, 1),
  2178. INGENIC_PIN_GROUP("i2s-sysclk", x1500_i2s_sysclk, 1),
  2179. INGENIC_PIN_GROUP("dmic-if0", x1500_dmic_if0, 0),
  2180. INGENIC_PIN_GROUP("dmic-if1", x1500_dmic_if1, 1),
  2181. INGENIC_PIN_GROUP("cim-data", x1500_cim, 2),
  2182. INGENIC_PIN_GROUP("pwm0", x1500_pwm_pwm0, 0),
  2183. INGENIC_PIN_GROUP("pwm1", x1500_pwm_pwm1, 1),
  2184. INGENIC_PIN_GROUP("pwm2", x1500_pwm_pwm2, 1),
  2185. INGENIC_PIN_GROUP("pwm3", x1500_pwm_pwm3, 2),
  2186. INGENIC_PIN_GROUP("pwm4", x1500_pwm_pwm4, 0),
  2187. };
  2188. static const char *x1500_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
  2189. static const char *x1500_uart1_groups[] = {
  2190. "uart1-data-a", "uart1-data-d", "uart1-hwflow",
  2191. };
  2192. static const char *x1500_uart2_groups[] = { "uart2-data-a", "uart2-data-d", };
  2193. static const char *x1500_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
  2194. static const char *x1500_i2c0_groups[] = { "i2c0-data", };
  2195. static const char *x1500_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", };
  2196. static const char *x1500_i2c2_groups[] = { "i2c2-data", };
  2197. static const char *x1500_i2s_groups[] = {
  2198. "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-sysclk",
  2199. };
  2200. static const char *x1500_dmic_groups[] = { "dmic-if0", "dmic-if1", };
  2201. static const char *x1500_cim_groups[] = { "cim-data", };
  2202. static const char *x1500_pwm0_groups[] = { "pwm0", };
  2203. static const char *x1500_pwm1_groups[] = { "pwm1", };
  2204. static const char *x1500_pwm2_groups[] = { "pwm2", };
  2205. static const char *x1500_pwm3_groups[] = { "pwm3", };
  2206. static const char *x1500_pwm4_groups[] = { "pwm4", };
  2207. static const struct function_desc x1500_functions[] = {
  2208. { "uart0", x1500_uart0_groups, ARRAY_SIZE(x1500_uart0_groups), },
  2209. { "uart1", x1500_uart1_groups, ARRAY_SIZE(x1500_uart1_groups), },
  2210. { "uart2", x1500_uart2_groups, ARRAY_SIZE(x1500_uart2_groups), },
  2211. { "sfc", x1000_sfc_groups, ARRAY_SIZE(x1000_sfc_groups), },
  2212. { "mmc", x1500_mmc_groups, ARRAY_SIZE(x1500_mmc_groups), },
  2213. { "i2c0", x1500_i2c0_groups, ARRAY_SIZE(x1500_i2c0_groups), },
  2214. { "i2c1", x1500_i2c1_groups, ARRAY_SIZE(x1500_i2c1_groups), },
  2215. { "i2c2", x1500_i2c2_groups, ARRAY_SIZE(x1500_i2c2_groups), },
  2216. { "i2s", x1500_i2s_groups, ARRAY_SIZE(x1500_i2s_groups), },
  2217. { "dmic", x1500_dmic_groups, ARRAY_SIZE(x1500_dmic_groups), },
  2218. { "cim", x1500_cim_groups, ARRAY_SIZE(x1500_cim_groups), },
  2219. { "pwm0", x1500_pwm0_groups, ARRAY_SIZE(x1500_pwm0_groups), },
  2220. { "pwm1", x1500_pwm1_groups, ARRAY_SIZE(x1500_pwm1_groups), },
  2221. { "pwm2", x1500_pwm2_groups, ARRAY_SIZE(x1500_pwm2_groups), },
  2222. { "pwm3", x1500_pwm3_groups, ARRAY_SIZE(x1500_pwm3_groups), },
  2223. { "pwm4", x1500_pwm4_groups, ARRAY_SIZE(x1500_pwm4_groups), },
  2224. };
  2225. static const struct ingenic_chip_info x1500_chip_info = {
  2226. .num_chips = 4,
  2227. .reg_offset = 0x100,
  2228. .version = ID_X1500,
  2229. .groups = x1500_groups,
  2230. .num_groups = ARRAY_SIZE(x1500_groups),
  2231. .functions = x1500_functions,
  2232. .num_functions = ARRAY_SIZE(x1500_functions),
  2233. .pull_ups = x1000_pull_ups,
  2234. .pull_downs = x1000_pull_downs,
  2235. .access_table = &x1000_access_table,
  2236. };
  2237. static const u32 x1830_pull_ups[4] = {
  2238. 0x5fdfffc0, 0xffffefff, 0x1ffffbff, 0x0fcff3fc,
  2239. };
  2240. static const u32 x1830_pull_downs[4] = {
  2241. 0x5fdfffc0, 0xffffefff, 0x1ffffbff, 0x0fcff3fc,
  2242. };
  2243. static int x1830_uart0_data_pins[] = { 0x33, 0x36, };
  2244. static int x1830_uart0_hwflow_pins[] = { 0x34, 0x35, };
  2245. static int x1830_uart1_data_pins[] = { 0x38, 0x37, };
  2246. static int x1830_sfc_data_pins[] = { 0x17, 0x18, 0x1a, 0x19, };
  2247. static int x1830_sfc_clk_pins[] = { 0x1b, };
  2248. static int x1830_sfc_ce_pins[] = { 0x1c, };
  2249. static int x1830_ssi0_dt_pins[] = { 0x4c, };
  2250. static int x1830_ssi0_dr_pins[] = { 0x4b, };
  2251. static int x1830_ssi0_clk_pins[] = { 0x4f, };
  2252. static int x1830_ssi0_gpc_pins[] = { 0x4d, };
  2253. static int x1830_ssi0_ce0_pins[] = { 0x50, };
  2254. static int x1830_ssi0_ce1_pins[] = { 0x4e, };
  2255. static int x1830_ssi1_dt_c_pins[] = { 0x53, };
  2256. static int x1830_ssi1_dt_d_pins[] = { 0x62, };
  2257. static int x1830_ssi1_dr_c_pins[] = { 0x54, };
  2258. static int x1830_ssi1_dr_d_pins[] = { 0x63, };
  2259. static int x1830_ssi1_clk_c_pins[] = { 0x57, };
  2260. static int x1830_ssi1_clk_d_pins[] = { 0x66, };
  2261. static int x1830_ssi1_gpc_c_pins[] = { 0x55, };
  2262. static int x1830_ssi1_gpc_d_pins[] = { 0x64, };
  2263. static int x1830_ssi1_ce0_c_pins[] = { 0x58, };
  2264. static int x1830_ssi1_ce0_d_pins[] = { 0x67, };
  2265. static int x1830_ssi1_ce1_c_pins[] = { 0x56, };
  2266. static int x1830_ssi1_ce1_d_pins[] = { 0x65, };
  2267. static int x1830_mmc0_1bit_pins[] = { 0x24, 0x25, 0x20, };
  2268. static int x1830_mmc0_4bit_pins[] = { 0x21, 0x22, 0x23, };
  2269. static int x1830_mmc1_1bit_pins[] = { 0x42, 0x43, 0x44, };
  2270. static int x1830_mmc1_4bit_pins[] = { 0x45, 0x46, 0x47, };
  2271. static int x1830_i2c0_pins[] = { 0x0c, 0x0d, };
  2272. static int x1830_i2c1_pins[] = { 0x39, 0x3a, };
  2273. static int x1830_i2c2_pins[] = { 0x5b, 0x5c, };
  2274. static int x1830_i2s_data_tx_pins[] = { 0x53, };
  2275. static int x1830_i2s_data_rx_pins[] = { 0x54, };
  2276. static int x1830_i2s_clk_txrx_pins[] = { 0x58, 0x52, };
  2277. static int x1830_i2s_clk_rx_pins[] = { 0x56, 0x55, };
  2278. static int x1830_i2s_sysclk_pins[] = { 0x57, };
  2279. static int x1830_dmic_if0_pins[] = { 0x48, 0x59, };
  2280. static int x1830_dmic_if1_pins[] = { 0x5a, };
  2281. static int x1830_lcd_tft_8bit_pins[] = {
  2282. 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
  2283. 0x68, 0x73, 0x72, 0x69,
  2284. };
  2285. static int x1830_lcd_tft_24bit_pins[] = {
  2286. 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71,
  2287. 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b,
  2288. };
  2289. static int x1830_lcd_slcd_8bit_pins[] = {
  2290. 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x6c, 0x6d,
  2291. 0x69, 0x72, 0x73, 0x7b, 0x7a,
  2292. };
  2293. static int x1830_lcd_slcd_16bit_pins[] = {
  2294. 0x6e, 0x6f, 0x70, 0x71, 0x76, 0x77, 0x78, 0x79,
  2295. };
  2296. static int x1830_pwm_pwm0_b_pins[] = { 0x31, };
  2297. static int x1830_pwm_pwm0_c_pins[] = { 0x4b, };
  2298. static int x1830_pwm_pwm1_b_pins[] = { 0x32, };
  2299. static int x1830_pwm_pwm1_c_pins[] = { 0x4c, };
  2300. static int x1830_pwm_pwm2_c_8_pins[] = { 0x48, };
  2301. static int x1830_pwm_pwm2_c_13_pins[] = { 0x4d, };
  2302. static int x1830_pwm_pwm3_c_9_pins[] = { 0x49, };
  2303. static int x1830_pwm_pwm3_c_14_pins[] = { 0x4e, };
  2304. static int x1830_pwm_pwm4_c_15_pins[] = { 0x4f, };
  2305. static int x1830_pwm_pwm4_c_25_pins[] = { 0x59, };
  2306. static int x1830_pwm_pwm5_c_16_pins[] = { 0x50, };
  2307. static int x1830_pwm_pwm5_c_26_pins[] = { 0x5a, };
  2308. static int x1830_pwm_pwm6_c_17_pins[] = { 0x51, };
  2309. static int x1830_pwm_pwm6_c_27_pins[] = { 0x5b, };
  2310. static int x1830_pwm_pwm7_c_18_pins[] = { 0x52, };
  2311. static int x1830_pwm_pwm7_c_28_pins[] = { 0x5c, };
  2312. static int x1830_mac_pins[] = {
  2313. 0x29, 0x30, 0x2f, 0x28, 0x2e, 0x2d, 0x2a, 0x2b, 0x26, 0x27,
  2314. };
  2315. static const struct group_desc x1830_groups[] = {
  2316. INGENIC_PIN_GROUP("uart0-data", x1830_uart0_data, 0),
  2317. INGENIC_PIN_GROUP("uart0-hwflow", x1830_uart0_hwflow, 0),
  2318. INGENIC_PIN_GROUP("uart1-data", x1830_uart1_data, 0),
  2319. INGENIC_PIN_GROUP("sfc-data", x1830_sfc_data, 1),
  2320. INGENIC_PIN_GROUP("sfc-clk", x1830_sfc_clk, 1),
  2321. INGENIC_PIN_GROUP("sfc-ce", x1830_sfc_ce, 1),
  2322. INGENIC_PIN_GROUP("ssi0-dt", x1830_ssi0_dt, 0),
  2323. INGENIC_PIN_GROUP("ssi0-dr", x1830_ssi0_dr, 0),
  2324. INGENIC_PIN_GROUP("ssi0-clk", x1830_ssi0_clk, 0),
  2325. INGENIC_PIN_GROUP("ssi0-gpc", x1830_ssi0_gpc, 0),
  2326. INGENIC_PIN_GROUP("ssi0-ce0", x1830_ssi0_ce0, 0),
  2327. INGENIC_PIN_GROUP("ssi0-ce1", x1830_ssi0_ce1, 0),
  2328. INGENIC_PIN_GROUP("ssi1-dt-c", x1830_ssi1_dt_c, 1),
  2329. INGENIC_PIN_GROUP("ssi1-dr-c", x1830_ssi1_dr_c, 1),
  2330. INGENIC_PIN_GROUP("ssi1-clk-c", x1830_ssi1_clk_c, 1),
  2331. INGENIC_PIN_GROUP("ssi1-gpc-c", x1830_ssi1_gpc_c, 1),
  2332. INGENIC_PIN_GROUP("ssi1-ce0-c", x1830_ssi1_ce0_c, 1),
  2333. INGENIC_PIN_GROUP("ssi1-ce1-c", x1830_ssi1_ce1_c, 1),
  2334. INGENIC_PIN_GROUP("ssi1-dt-d", x1830_ssi1_dt_d, 2),
  2335. INGENIC_PIN_GROUP("ssi1-dr-d", x1830_ssi1_dr_d, 2),
  2336. INGENIC_PIN_GROUP("ssi1-clk-d", x1830_ssi1_clk_d, 2),
  2337. INGENIC_PIN_GROUP("ssi1-gpc-d", x1830_ssi1_gpc_d, 2),
  2338. INGENIC_PIN_GROUP("ssi1-ce0-d", x1830_ssi1_ce0_d, 2),
  2339. INGENIC_PIN_GROUP("ssi1-ce1-d", x1830_ssi1_ce1_d, 2),
  2340. INGENIC_PIN_GROUP("mmc0-1bit", x1830_mmc0_1bit, 0),
  2341. INGENIC_PIN_GROUP("mmc0-4bit", x1830_mmc0_4bit, 0),
  2342. INGENIC_PIN_GROUP("mmc1-1bit", x1830_mmc1_1bit, 0),
  2343. INGENIC_PIN_GROUP("mmc1-4bit", x1830_mmc1_4bit, 0),
  2344. INGENIC_PIN_GROUP("i2c0-data", x1830_i2c0, 1),
  2345. INGENIC_PIN_GROUP("i2c1-data", x1830_i2c1, 0),
  2346. INGENIC_PIN_GROUP("i2c2-data", x1830_i2c2, 1),
  2347. INGENIC_PIN_GROUP("i2s-data-tx", x1830_i2s_data_tx, 0),
  2348. INGENIC_PIN_GROUP("i2s-data-rx", x1830_i2s_data_rx, 0),
  2349. INGENIC_PIN_GROUP("i2s-clk-txrx", x1830_i2s_clk_txrx, 0),
  2350. INGENIC_PIN_GROUP("i2s-clk-rx", x1830_i2s_clk_rx, 0),
  2351. INGENIC_PIN_GROUP("i2s-sysclk", x1830_i2s_sysclk, 0),
  2352. INGENIC_PIN_GROUP("dmic-if0", x1830_dmic_if0, 2),
  2353. INGENIC_PIN_GROUP("dmic-if1", x1830_dmic_if1, 2),
  2354. INGENIC_PIN_GROUP("lcd-tft-8bit", x1830_lcd_tft_8bit, 0),
  2355. INGENIC_PIN_GROUP("lcd-tft-24bit", x1830_lcd_tft_24bit, 0),
  2356. INGENIC_PIN_GROUP("lcd-slcd-8bit", x1830_lcd_slcd_8bit, 1),
  2357. INGENIC_PIN_GROUP("lcd-slcd-16bit", x1830_lcd_slcd_16bit, 1),
  2358. INGENIC_PIN_GROUP("pwm0-b", x1830_pwm_pwm0_b, 0),
  2359. INGENIC_PIN_GROUP("pwm0-c", x1830_pwm_pwm0_c, 1),
  2360. INGENIC_PIN_GROUP("pwm1-b", x1830_pwm_pwm1_b, 0),
  2361. INGENIC_PIN_GROUP("pwm1-c", x1830_pwm_pwm1_c, 1),
  2362. INGENIC_PIN_GROUP("pwm2-c-8", x1830_pwm_pwm2_c_8, 0),
  2363. INGENIC_PIN_GROUP("pwm2-c-13", x1830_pwm_pwm2_c_13, 1),
  2364. INGENIC_PIN_GROUP("pwm3-c-9", x1830_pwm_pwm3_c_9, 0),
  2365. INGENIC_PIN_GROUP("pwm3-c-14", x1830_pwm_pwm3_c_14, 1),
  2366. INGENIC_PIN_GROUP("pwm4-c-15", x1830_pwm_pwm4_c_15, 1),
  2367. INGENIC_PIN_GROUP("pwm4-c-25", x1830_pwm_pwm4_c_25, 0),
  2368. INGENIC_PIN_GROUP("pwm5-c-16", x1830_pwm_pwm5_c_16, 1),
  2369. INGENIC_PIN_GROUP("pwm5-c-26", x1830_pwm_pwm5_c_26, 0),
  2370. INGENIC_PIN_GROUP("pwm6-c-17", x1830_pwm_pwm6_c_17, 1),
  2371. INGENIC_PIN_GROUP("pwm6-c-27", x1830_pwm_pwm6_c_27, 0),
  2372. INGENIC_PIN_GROUP("pwm7-c-18", x1830_pwm_pwm7_c_18, 1),
  2373. INGENIC_PIN_GROUP("pwm7-c-28", x1830_pwm_pwm7_c_28, 0),
  2374. INGENIC_PIN_GROUP("mac", x1830_mac, 0),
  2375. };
  2376. static const char *x1830_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
  2377. static const char *x1830_uart1_groups[] = { "uart1-data", };
  2378. static const char *x1830_sfc_groups[] = { "sfc-data", "sfc-clk", "sfc-ce", };
  2379. static const char *x1830_ssi0_groups[] = {
  2380. "ssi0-dt", "ssi0-dr", "ssi0-clk", "ssi0-gpc", "ssi0-ce0", "ssi0-ce1",
  2381. };
  2382. static const char *x1830_ssi1_groups[] = {
  2383. "ssi1-dt-c", "ssi1-dt-d",
  2384. "ssi1-dr-c", "ssi1-dr-d",
  2385. "ssi1-clk-c", "ssi1-clk-d",
  2386. "ssi1-gpc-c", "ssi1-gpc-d",
  2387. "ssi1-ce0-c", "ssi1-ce0-d",
  2388. "ssi1-ce1-c", "ssi1-ce1-d",
  2389. };
  2390. static const char *x1830_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", };
  2391. static const char *x1830_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
  2392. static const char *x1830_i2c0_groups[] = { "i2c0-data", };
  2393. static const char *x1830_i2c1_groups[] = { "i2c1-data", };
  2394. static const char *x1830_i2c2_groups[] = { "i2c2-data", };
  2395. static const char *x1830_i2s_groups[] = {
  2396. "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-clk-rx", "i2s-sysclk",
  2397. };
  2398. static const char *x1830_dmic_groups[] = { "dmic-if0", "dmic-if1", };
  2399. static const char *x1830_lcd_groups[] = {
  2400. "lcd-tft-8bit", "lcd-tft-24bit", "lcd-slcd-8bit", "lcd-slcd-16bit",
  2401. };
  2402. static const char *x1830_pwm0_groups[] = { "pwm0-b", "pwm0-c", };
  2403. static const char *x1830_pwm1_groups[] = { "pwm1-b", "pwm1-c", };
  2404. static const char *x1830_pwm2_groups[] = { "pwm2-c-8", "pwm2-c-13", };
  2405. static const char *x1830_pwm3_groups[] = { "pwm3-c-9", "pwm3-c-14", };
  2406. static const char *x1830_pwm4_groups[] = { "pwm4-c-15", "pwm4-c-25", };
  2407. static const char *x1830_pwm5_groups[] = { "pwm5-c-16", "pwm5-c-26", };
  2408. static const char *x1830_pwm6_groups[] = { "pwm6-c-17", "pwm6-c-27", };
  2409. static const char *x1830_pwm7_groups[] = { "pwm7-c-18", "pwm7-c-28", };
  2410. static const char *x1830_mac_groups[] = { "mac", };
  2411. static const struct function_desc x1830_functions[] = {
  2412. { "uart0", x1830_uart0_groups, ARRAY_SIZE(x1830_uart0_groups), },
  2413. { "uart1", x1830_uart1_groups, ARRAY_SIZE(x1830_uart1_groups), },
  2414. { "sfc", x1830_sfc_groups, ARRAY_SIZE(x1830_sfc_groups), },
  2415. { "ssi0", x1830_ssi0_groups, ARRAY_SIZE(x1830_ssi0_groups), },
  2416. { "ssi1", x1830_ssi1_groups, ARRAY_SIZE(x1830_ssi1_groups), },
  2417. { "mmc0", x1830_mmc0_groups, ARRAY_SIZE(x1830_mmc0_groups), },
  2418. { "mmc1", x1830_mmc1_groups, ARRAY_SIZE(x1830_mmc1_groups), },
  2419. { "i2c0", x1830_i2c0_groups, ARRAY_SIZE(x1830_i2c0_groups), },
  2420. { "i2c1", x1830_i2c1_groups, ARRAY_SIZE(x1830_i2c1_groups), },
  2421. { "i2c2", x1830_i2c2_groups, ARRAY_SIZE(x1830_i2c2_groups), },
  2422. { "i2s", x1830_i2s_groups, ARRAY_SIZE(x1830_i2s_groups), },
  2423. { "dmic", x1830_dmic_groups, ARRAY_SIZE(x1830_dmic_groups), },
  2424. { "lcd", x1830_lcd_groups, ARRAY_SIZE(x1830_lcd_groups), },
  2425. { "pwm0", x1830_pwm0_groups, ARRAY_SIZE(x1830_pwm0_groups), },
  2426. { "pwm1", x1830_pwm1_groups, ARRAY_SIZE(x1830_pwm1_groups), },
  2427. { "pwm2", x1830_pwm2_groups, ARRAY_SIZE(x1830_pwm2_groups), },
  2428. { "pwm3", x1830_pwm3_groups, ARRAY_SIZE(x1830_pwm3_groups), },
  2429. { "pwm4", x1830_pwm4_groups, ARRAY_SIZE(x1830_pwm4_groups), },
  2430. { "pwm5", x1830_pwm5_groups, ARRAY_SIZE(x1830_pwm4_groups), },
  2431. { "pwm6", x1830_pwm6_groups, ARRAY_SIZE(x1830_pwm4_groups), },
  2432. { "pwm7", x1830_pwm7_groups, ARRAY_SIZE(x1830_pwm4_groups), },
  2433. { "mac", x1830_mac_groups, ARRAY_SIZE(x1830_mac_groups), },
  2434. };
  2435. static const struct regmap_range x1830_access_ranges[] = {
  2436. regmap_reg_range(0x0000, 0x4000 - 4),
  2437. regmap_reg_range(0x7000, 0x8000 - 4),
  2438. };
  2439. static const struct regmap_access_table x1830_access_table = {
  2440. .yes_ranges = x1830_access_ranges,
  2441. .n_yes_ranges = ARRAY_SIZE(x1830_access_ranges),
  2442. };
  2443. static const struct ingenic_chip_info x1830_chip_info = {
  2444. .num_chips = 4,
  2445. .reg_offset = 0x1000,
  2446. .version = ID_X1830,
  2447. .groups = x1830_groups,
  2448. .num_groups = ARRAY_SIZE(x1830_groups),
  2449. .functions = x1830_functions,
  2450. .num_functions = ARRAY_SIZE(x1830_functions),
  2451. .pull_ups = x1830_pull_ups,
  2452. .pull_downs = x1830_pull_downs,
  2453. .access_table = &x1830_access_table,
  2454. };
  2455. static const u32 x2000_pull_ups[5] = {
  2456. 0x0003ffff, 0xffffffff, 0x1ff0ffff, 0xc7fe3f3f, 0x8fff003f,
  2457. };
  2458. static const u32 x2000_pull_downs[5] = {
  2459. 0x0003ffff, 0xffffffff, 0x1ff0ffff, 0x00000000, 0x8fff003f,
  2460. };
  2461. static int x2000_uart0_data_pins[] = { 0x77, 0x78, };
  2462. static int x2000_uart0_hwflow_pins[] = { 0x79, 0x7a, };
  2463. static int x2000_uart1_data_pins[] = { 0x57, 0x58, };
  2464. static int x2000_uart1_hwflow_pins[] = { 0x55, 0x56, };
  2465. static int x2000_uart2_data_pins[] = { 0x7e, 0x7f, };
  2466. static int x2000_uart3_data_c_pins[] = { 0x59, 0x5a, };
  2467. static int x2000_uart3_data_d_pins[] = { 0x62, 0x63, };
  2468. static int x2000_uart3_hwflow_c_pins[] = { 0x5b, 0x5c, };
  2469. static int x2000_uart3_hwflow_d_pins[] = { 0x60, 0x61, };
  2470. static int x2000_uart4_data_a_pins[] = { 0x02, 0x03, };
  2471. static int x2000_uart4_data_c_pins[] = { 0x4b, 0x4c, };
  2472. static int x2000_uart4_hwflow_a_pins[] = { 0x00, 0x01, };
  2473. static int x2000_uart4_hwflow_c_pins[] = { 0x49, 0x4a, };
  2474. static int x2000_uart5_data_a_pins[] = { 0x04, 0x05, };
  2475. static int x2000_uart5_data_c_pins[] = { 0x45, 0x46, };
  2476. static int x2000_uart6_data_a_pins[] = { 0x06, 0x07, };
  2477. static int x2000_uart6_data_c_pins[] = { 0x47, 0x48, };
  2478. static int x2000_uart7_data_a_pins[] = { 0x08, 0x09, };
  2479. static int x2000_uart7_data_c_pins[] = { 0x41, 0x42, };
  2480. static int x2000_uart8_data_pins[] = { 0x3c, 0x3d, };
  2481. static int x2000_uart9_data_pins[] = { 0x3e, 0x3f, };
  2482. static int x2000_sfc_data_if0_d_pins[] = { 0x73, 0x74, 0x75, 0x76, };
  2483. static int x2000_sfc_data_if0_e_pins[] = { 0x92, 0x93, 0x94, 0x95, };
  2484. static int x2000_sfc_data_if1_pins[] = { 0x77, 0x78, 0x79, 0x7a, };
  2485. static int x2000_sfc_clk_d_pins[] = { 0x71, };
  2486. static int x2000_sfc_clk_e_pins[] = { 0x90, };
  2487. static int x2000_sfc_ce_d_pins[] = { 0x72, };
  2488. static int x2000_sfc_ce_e_pins[] = { 0x91, };
  2489. static int x2000_ssi0_dt_b_pins[] = { 0x3e, };
  2490. static int x2000_ssi0_dt_d_pins[] = { 0x69, };
  2491. static int x2000_ssi0_dr_b_pins[] = { 0x3d, };
  2492. static int x2000_ssi0_dr_d_pins[] = { 0x6a, };
  2493. static int x2000_ssi0_clk_b_pins[] = { 0x3f, };
  2494. static int x2000_ssi0_clk_d_pins[] = { 0x68, };
  2495. static int x2000_ssi0_ce_b_pins[] = { 0x3c, };
  2496. static int x2000_ssi0_ce_d_pins[] = { 0x6d, };
  2497. static int x2000_ssi1_dt_c_pins[] = { 0x4b, };
  2498. static int x2000_ssi1_dt_d_pins[] = { 0x72, };
  2499. static int x2000_ssi1_dt_e_pins[] = { 0x91, };
  2500. static int x2000_ssi1_dr_c_pins[] = { 0x4a, };
  2501. static int x2000_ssi1_dr_d_pins[] = { 0x73, };
  2502. static int x2000_ssi1_dr_e_pins[] = { 0x92, };
  2503. static int x2000_ssi1_clk_c_pins[] = { 0x4c, };
  2504. static int x2000_ssi1_clk_d_pins[] = { 0x71, };
  2505. static int x2000_ssi1_clk_e_pins[] = { 0x90, };
  2506. static int x2000_ssi1_ce_c_pins[] = { 0x49, };
  2507. static int x2000_ssi1_ce_d_pins[] = { 0x76, };
  2508. static int x2000_ssi1_ce_e_pins[] = { 0x95, };
  2509. static int x2000_mmc0_1bit_pins[] = { 0x71, 0x72, 0x73, };
  2510. static int x2000_mmc0_4bit_pins[] = { 0x74, 0x75, 0x75, };
  2511. static int x2000_mmc0_8bit_pins[] = { 0x77, 0x78, 0x79, 0x7a, };
  2512. static int x2000_mmc1_1bit_pins[] = { 0x68, 0x69, 0x6a, };
  2513. static int x2000_mmc1_4bit_pins[] = { 0x6b, 0x6c, 0x6d, };
  2514. static int x2000_mmc2_1bit_pins[] = { 0x80, 0x81, 0x82, };
  2515. static int x2000_mmc2_4bit_pins[] = { 0x83, 0x84, 0x85, };
  2516. static int x2000_emc_8bit_data_pins[] = {
  2517. 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
  2518. };
  2519. static int x2000_emc_16bit_data_pins[] = {
  2520. 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
  2521. };
  2522. static int x2000_emc_addr_pins[] = {
  2523. 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
  2524. 0x28, 0x29, 0x2a, 0x2b, 0x2c,
  2525. };
  2526. static int x2000_emc_rd_we_pins[] = { 0x2d, 0x2e, };
  2527. static int x2000_emc_wait_pins[] = { 0x2f, };
  2528. static int x2000_emc_cs1_pins[] = { 0x57, };
  2529. static int x2000_emc_cs2_pins[] = { 0x58, };
  2530. static int x2000_i2c0_pins[] = { 0x4e, 0x4d, };
  2531. static int x2000_i2c1_c_pins[] = { 0x58, 0x57, };
  2532. static int x2000_i2c1_d_pins[] = { 0x6c, 0x6b, };
  2533. static int x2000_i2c2_b_pins[] = { 0x37, 0x36, };
  2534. static int x2000_i2c2_d_pins[] = { 0x75, 0x74, };
  2535. static int x2000_i2c2_e_pins[] = { 0x94, 0x93, };
  2536. static int x2000_i2c3_a_pins[] = { 0x11, 0x10, };
  2537. static int x2000_i2c3_d_pins[] = { 0x7f, 0x7e, };
  2538. static int x2000_i2c4_c_pins[] = { 0x5a, 0x59, };
  2539. static int x2000_i2c4_d_pins[] = { 0x61, 0x60, };
  2540. static int x2000_i2c5_c_pins[] = { 0x5c, 0x5b, };
  2541. static int x2000_i2c5_d_pins[] = { 0x65, 0x64, };
  2542. static int x2000_i2s1_data_tx_pins[] = { 0x47, };
  2543. static int x2000_i2s1_data_rx_pins[] = { 0x44, };
  2544. static int x2000_i2s1_clk_tx_pins[] = { 0x45, 0x46, };
  2545. static int x2000_i2s1_clk_rx_pins[] = { 0x42, 0x43, };
  2546. static int x2000_i2s1_sysclk_tx_pins[] = { 0x48, };
  2547. static int x2000_i2s1_sysclk_rx_pins[] = { 0x41, };
  2548. static int x2000_i2s2_data_rx0_pins[] = { 0x0a, };
  2549. static int x2000_i2s2_data_rx1_pins[] = { 0x0b, };
  2550. static int x2000_i2s2_data_rx2_pins[] = { 0x0c, };
  2551. static int x2000_i2s2_data_rx3_pins[] = { 0x0d, };
  2552. static int x2000_i2s2_clk_rx_pins[] = { 0x11, 0x09, };
  2553. static int x2000_i2s2_sysclk_rx_pins[] = { 0x07, };
  2554. static int x2000_i2s3_data_tx0_pins[] = { 0x03, };
  2555. static int x2000_i2s3_data_tx1_pins[] = { 0x04, };
  2556. static int x2000_i2s3_data_tx2_pins[] = { 0x05, };
  2557. static int x2000_i2s3_data_tx3_pins[] = { 0x06, };
  2558. static int x2000_i2s3_clk_tx_pins[] = { 0x10, 0x02, };
  2559. static int x2000_i2s3_sysclk_tx_pins[] = { 0x00, };
  2560. static int x2000_dmic_if0_pins[] = { 0x54, 0x55, };
  2561. static int x2000_dmic_if1_pins[] = { 0x56, };
  2562. static int x2000_dmic_if2_pins[] = { 0x57, };
  2563. static int x2000_dmic_if3_pins[] = { 0x58, };
  2564. static int x2000_cim_8bit_pins[] = {
  2565. 0x0e, 0x0c, 0x0d, 0x4f,
  2566. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  2567. };
  2568. static int x2000_cim_12bit_pins[] = { 0x08, 0x09, 0x0a, 0x0b, };
  2569. static int x2000_lcd_tft_8bit_pins[] = {
  2570. 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
  2571. 0x38, 0x3a, 0x39, 0x3b,
  2572. };
  2573. static int x2000_lcd_tft_16bit_pins[] = {
  2574. 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
  2575. };
  2576. static int x2000_lcd_tft_18bit_pins[] = {
  2577. 0x30, 0x31,
  2578. };
  2579. static int x2000_lcd_tft_24bit_pins[] = {
  2580. 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
  2581. };
  2582. static int x2000_lcd_slcd_8bit_pins[] = {
  2583. 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
  2584. 0x3a, 0x38, 0x3b, 0x30, 0x39,
  2585. };
  2586. static int x2000_pwm_pwm0_c_pins[] = { 0x40, };
  2587. static int x2000_pwm_pwm0_d_pins[] = { 0x7e, };
  2588. static int x2000_pwm_pwm1_c_pins[] = { 0x41, };
  2589. static int x2000_pwm_pwm1_d_pins[] = { 0x7f, };
  2590. static int x2000_pwm_pwm2_c_pins[] = { 0x42, };
  2591. static int x2000_pwm_pwm2_e_pins[] = { 0x80, };
  2592. static int x2000_pwm_pwm3_c_pins[] = { 0x43, };
  2593. static int x2000_pwm_pwm3_e_pins[] = { 0x81, };
  2594. static int x2000_pwm_pwm4_c_pins[] = { 0x44, };
  2595. static int x2000_pwm_pwm4_e_pins[] = { 0x82, };
  2596. static int x2000_pwm_pwm5_c_pins[] = { 0x45, };
  2597. static int x2000_pwm_pwm5_e_pins[] = { 0x83, };
  2598. static int x2000_pwm_pwm6_c_pins[] = { 0x46, };
  2599. static int x2000_pwm_pwm6_e_pins[] = { 0x84, };
  2600. static int x2000_pwm_pwm7_c_pins[] = { 0x47, };
  2601. static int x2000_pwm_pwm7_e_pins[] = { 0x85, };
  2602. static int x2000_pwm_pwm8_pins[] = { 0x48, };
  2603. static int x2000_pwm_pwm9_pins[] = { 0x49, };
  2604. static int x2000_pwm_pwm10_pins[] = { 0x4a, };
  2605. static int x2000_pwm_pwm11_pins[] = { 0x4b, };
  2606. static int x2000_pwm_pwm12_pins[] = { 0x4c, };
  2607. static int x2000_pwm_pwm13_pins[] = { 0x4d, };
  2608. static int x2000_pwm_pwm14_pins[] = { 0x4e, };
  2609. static int x2000_pwm_pwm15_pins[] = { 0x4f, };
  2610. static int x2000_mac0_rmii_pins[] = {
  2611. 0x4b, 0x47, 0x46, 0x4a, 0x43, 0x42, 0x4c, 0x4d, 0x4e, 0x41,
  2612. };
  2613. static int x2000_mac0_rgmii_pins[] = {
  2614. 0x4b, 0x49, 0x48, 0x47, 0x46, 0x4a, 0x45, 0x44, 0x43, 0x42,
  2615. 0x4c, 0x4d, 0x4f, 0x4e, 0x41,
  2616. };
  2617. static int x2000_mac1_rmii_pins[] = {
  2618. 0x32, 0x2d, 0x2c, 0x31, 0x29, 0x28, 0x33, 0x34, 0x35, 0x37,
  2619. };
  2620. static int x2000_mac1_rgmii_pins[] = {
  2621. 0x32, 0x2f, 0x2e, 0x2d, 0x2c, 0x31, 0x2b, 0x2a, 0x29, 0x28,
  2622. 0x33, 0x34, 0x36, 0x35, 0x37,
  2623. };
  2624. static int x2000_otg_pins[] = { 0x96, };
  2625. static u8 x2000_cim_8bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, };
  2626. static const struct group_desc x2000_groups[] = {
  2627. INGENIC_PIN_GROUP("uart0-data", x2000_uart0_data, 2),
  2628. INGENIC_PIN_GROUP("uart0-hwflow", x2000_uart0_hwflow, 2),
  2629. INGENIC_PIN_GROUP("uart1-data", x2000_uart1_data, 1),
  2630. INGENIC_PIN_GROUP("uart1-hwflow", x2000_uart1_hwflow, 1),
  2631. INGENIC_PIN_GROUP("uart2-data", x2000_uart2_data, 0),
  2632. INGENIC_PIN_GROUP("uart3-data-c", x2000_uart3_data_c, 0),
  2633. INGENIC_PIN_GROUP("uart3-data-d", x2000_uart3_data_d, 1),
  2634. INGENIC_PIN_GROUP("uart3-hwflow-c", x2000_uart3_hwflow_c, 0),
  2635. INGENIC_PIN_GROUP("uart3-hwflow-d", x2000_uart3_hwflow_d, 1),
  2636. INGENIC_PIN_GROUP("uart4-data-a", x2000_uart4_data_a, 1),
  2637. INGENIC_PIN_GROUP("uart4-data-c", x2000_uart4_data_c, 3),
  2638. INGENIC_PIN_GROUP("uart4-hwflow-a", x2000_uart4_hwflow_a, 1),
  2639. INGENIC_PIN_GROUP("uart4-hwflow-c", x2000_uart4_hwflow_c, 3),
  2640. INGENIC_PIN_GROUP("uart5-data-a", x2000_uart5_data_a, 1),
  2641. INGENIC_PIN_GROUP("uart5-data-c", x2000_uart5_data_c, 3),
  2642. INGENIC_PIN_GROUP("uart6-data-a", x2000_uart6_data_a, 1),
  2643. INGENIC_PIN_GROUP("uart6-data-c", x2000_uart6_data_c, 3),
  2644. INGENIC_PIN_GROUP("uart7-data-a", x2000_uart7_data_a, 1),
  2645. INGENIC_PIN_GROUP("uart7-data-c", x2000_uart7_data_c, 3),
  2646. INGENIC_PIN_GROUP("uart8-data", x2000_uart8_data, 3),
  2647. INGENIC_PIN_GROUP("uart9-data", x2000_uart9_data, 3),
  2648. INGENIC_PIN_GROUP("sfc-data-if0-d", x2000_sfc_data_if0_d, 1),
  2649. INGENIC_PIN_GROUP("sfc-data-if0-e", x2000_sfc_data_if0_e, 0),
  2650. INGENIC_PIN_GROUP("sfc-data-if1", x2000_sfc_data_if1, 1),
  2651. INGENIC_PIN_GROUP("sfc-clk-d", x2000_sfc_clk_d, 1),
  2652. INGENIC_PIN_GROUP("sfc-clk-e", x2000_sfc_clk_e, 0),
  2653. INGENIC_PIN_GROUP("sfc-ce-d", x2000_sfc_ce_d, 1),
  2654. INGENIC_PIN_GROUP("sfc-ce-e", x2000_sfc_ce_e, 0),
  2655. INGENIC_PIN_GROUP("ssi0-dt-b", x2000_ssi0_dt_b, 1),
  2656. INGENIC_PIN_GROUP("ssi0-dt-d", x2000_ssi0_dt_d, 1),
  2657. INGENIC_PIN_GROUP("ssi0-dr-b", x2000_ssi0_dr_b, 1),
  2658. INGENIC_PIN_GROUP("ssi0-dr-d", x2000_ssi0_dr_d, 1),
  2659. INGENIC_PIN_GROUP("ssi0-clk-b", x2000_ssi0_clk_b, 1),
  2660. INGENIC_PIN_GROUP("ssi0-clk-d", x2000_ssi0_clk_d, 1),
  2661. INGENIC_PIN_GROUP("ssi0-ce-b", x2000_ssi0_ce_b, 1),
  2662. INGENIC_PIN_GROUP("ssi0-ce-d", x2000_ssi0_ce_d, 1),
  2663. INGENIC_PIN_GROUP("ssi1-dt-c", x2000_ssi1_dt_c, 2),
  2664. INGENIC_PIN_GROUP("ssi1-dt-d", x2000_ssi1_dt_d, 2),
  2665. INGENIC_PIN_GROUP("ssi1-dt-e", x2000_ssi1_dt_e, 1),
  2666. INGENIC_PIN_GROUP("ssi1-dr-c", x2000_ssi1_dr_c, 2),
  2667. INGENIC_PIN_GROUP("ssi1-dr-d", x2000_ssi1_dr_d, 2),
  2668. INGENIC_PIN_GROUP("ssi1-dr-e", x2000_ssi1_dr_e, 1),
  2669. INGENIC_PIN_GROUP("ssi1-clk-c", x2000_ssi1_clk_c, 2),
  2670. INGENIC_PIN_GROUP("ssi1-clk-d", x2000_ssi1_clk_d, 2),
  2671. INGENIC_PIN_GROUP("ssi1-clk-e", x2000_ssi1_clk_e, 1),
  2672. INGENIC_PIN_GROUP("ssi1-ce-c", x2000_ssi1_ce_c, 2),
  2673. INGENIC_PIN_GROUP("ssi1-ce-d", x2000_ssi1_ce_d, 2),
  2674. INGENIC_PIN_GROUP("ssi1-ce-e", x2000_ssi1_ce_e, 1),
  2675. INGENIC_PIN_GROUP("mmc0-1bit", x2000_mmc0_1bit, 0),
  2676. INGENIC_PIN_GROUP("mmc0-4bit", x2000_mmc0_4bit, 0),
  2677. INGENIC_PIN_GROUP("mmc0-8bit", x2000_mmc0_8bit, 0),
  2678. INGENIC_PIN_GROUP("mmc1-1bit", x2000_mmc1_1bit, 0),
  2679. INGENIC_PIN_GROUP("mmc1-4bit", x2000_mmc1_4bit, 0),
  2680. INGENIC_PIN_GROUP("mmc2-1bit", x2000_mmc2_1bit, 0),
  2681. INGENIC_PIN_GROUP("mmc2-4bit", x2000_mmc2_4bit, 0),
  2682. INGENIC_PIN_GROUP("emc-8bit-data", x2000_emc_8bit_data, 0),
  2683. INGENIC_PIN_GROUP("emc-16bit-data", x2000_emc_16bit_data, 0),
  2684. INGENIC_PIN_GROUP("emc-addr", x2000_emc_addr, 0),
  2685. INGENIC_PIN_GROUP("emc-rd-we", x2000_emc_rd_we, 0),
  2686. INGENIC_PIN_GROUP("emc-wait", x2000_emc_wait, 0),
  2687. INGENIC_PIN_GROUP("emc-cs1", x2000_emc_cs1, 3),
  2688. INGENIC_PIN_GROUP("emc-cs2", x2000_emc_cs2, 3),
  2689. INGENIC_PIN_GROUP("i2c0-data", x2000_i2c0, 3),
  2690. INGENIC_PIN_GROUP("i2c1-data-c", x2000_i2c1_c, 2),
  2691. INGENIC_PIN_GROUP("i2c1-data-d", x2000_i2c1_d, 1),
  2692. INGENIC_PIN_GROUP("i2c2-data-b", x2000_i2c2_b, 2),
  2693. INGENIC_PIN_GROUP("i2c2-data-d", x2000_i2c2_d, 2),
  2694. INGENIC_PIN_GROUP("i2c2-data-e", x2000_i2c2_e, 1),
  2695. INGENIC_PIN_GROUP("i2c3-data-a", x2000_i2c3_a, 0),
  2696. INGENIC_PIN_GROUP("i2c3-data-d", x2000_i2c3_d, 1),
  2697. INGENIC_PIN_GROUP("i2c4-data-c", x2000_i2c4_c, 1),
  2698. INGENIC_PIN_GROUP("i2c4-data-d", x2000_i2c4_d, 2),
  2699. INGENIC_PIN_GROUP("i2c5-data-c", x2000_i2c5_c, 1),
  2700. INGENIC_PIN_GROUP("i2c5-data-d", x2000_i2c5_d, 1),
  2701. INGENIC_PIN_GROUP("i2s1-data-tx", x2000_i2s1_data_tx, 2),
  2702. INGENIC_PIN_GROUP("i2s1-data-rx", x2000_i2s1_data_rx, 2),
  2703. INGENIC_PIN_GROUP("i2s1-clk-tx", x2000_i2s1_clk_tx, 2),
  2704. INGENIC_PIN_GROUP("i2s1-clk-rx", x2000_i2s1_clk_rx, 2),
  2705. INGENIC_PIN_GROUP("i2s1-sysclk-tx", x2000_i2s1_sysclk_tx, 2),
  2706. INGENIC_PIN_GROUP("i2s1-sysclk-rx", x2000_i2s1_sysclk_rx, 2),
  2707. INGENIC_PIN_GROUP("i2s2-data-rx0", x2000_i2s2_data_rx0, 2),
  2708. INGENIC_PIN_GROUP("i2s2-data-rx1", x2000_i2s2_data_rx1, 2),
  2709. INGENIC_PIN_GROUP("i2s2-data-rx2", x2000_i2s2_data_rx2, 2),
  2710. INGENIC_PIN_GROUP("i2s2-data-rx3", x2000_i2s2_data_rx3, 2),
  2711. INGENIC_PIN_GROUP("i2s2-clk-rx", x2000_i2s2_clk_rx, 2),
  2712. INGENIC_PIN_GROUP("i2s2-sysclk-rx", x2000_i2s2_sysclk_rx, 2),
  2713. INGENIC_PIN_GROUP("i2s3-data-tx0", x2000_i2s3_data_tx0, 2),
  2714. INGENIC_PIN_GROUP("i2s3-data-tx1", x2000_i2s3_data_tx1, 2),
  2715. INGENIC_PIN_GROUP("i2s3-data-tx2", x2000_i2s3_data_tx2, 2),
  2716. INGENIC_PIN_GROUP("i2s3-data-tx3", x2000_i2s3_data_tx3, 2),
  2717. INGENIC_PIN_GROUP("i2s3-clk-tx", x2000_i2s3_clk_tx, 2),
  2718. INGENIC_PIN_GROUP("i2s3-sysclk-tx", x2000_i2s3_sysclk_tx, 2),
  2719. INGENIC_PIN_GROUP("dmic-if0", x2000_dmic_if0, 0),
  2720. INGENIC_PIN_GROUP("dmic-if1", x2000_dmic_if1, 0),
  2721. INGENIC_PIN_GROUP("dmic-if2", x2000_dmic_if2, 0),
  2722. INGENIC_PIN_GROUP("dmic-if3", x2000_dmic_if3, 0),
  2723. INGENIC_PIN_GROUP_FUNCS("cim-data-8bit", x2000_cim_8bit,
  2724. x2000_cim_8bit_funcs),
  2725. INGENIC_PIN_GROUP("cim-data-12bit", x2000_cim_12bit, 0),
  2726. INGENIC_PIN_GROUP("lcd-tft-8bit", x2000_lcd_tft_8bit, 1),
  2727. INGENIC_PIN_GROUP("lcd-tft-16bit", x2000_lcd_tft_16bit, 1),
  2728. INGENIC_PIN_GROUP("lcd-tft-18bit", x2000_lcd_tft_18bit, 1),
  2729. INGENIC_PIN_GROUP("lcd-tft-24bit", x2000_lcd_tft_24bit, 1),
  2730. INGENIC_PIN_GROUP("lcd-slcd-8bit", x2000_lcd_slcd_8bit, 2),
  2731. INGENIC_PIN_GROUP("lcd-slcd-16bit", x2000_lcd_tft_16bit, 2),
  2732. INGENIC_PIN_GROUP("pwm0-c", x2000_pwm_pwm0_c, 0),
  2733. INGENIC_PIN_GROUP("pwm0-d", x2000_pwm_pwm0_d, 2),
  2734. INGENIC_PIN_GROUP("pwm1-c", x2000_pwm_pwm1_c, 0),
  2735. INGENIC_PIN_GROUP("pwm1-d", x2000_pwm_pwm1_d, 2),
  2736. INGENIC_PIN_GROUP("pwm2-c", x2000_pwm_pwm2_c, 0),
  2737. INGENIC_PIN_GROUP("pwm2-e", x2000_pwm_pwm2_e, 1),
  2738. INGENIC_PIN_GROUP("pwm3-c", x2000_pwm_pwm3_c, 0),
  2739. INGENIC_PIN_GROUP("pwm3-e", x2000_pwm_pwm3_e, 1),
  2740. INGENIC_PIN_GROUP("pwm4-c", x2000_pwm_pwm4_c, 0),
  2741. INGENIC_PIN_GROUP("pwm4-e", x2000_pwm_pwm4_e, 1),
  2742. INGENIC_PIN_GROUP("pwm5-c", x2000_pwm_pwm5_c, 0),
  2743. INGENIC_PIN_GROUP("pwm5-e", x2000_pwm_pwm5_e, 1),
  2744. INGENIC_PIN_GROUP("pwm6-c", x2000_pwm_pwm6_c, 0),
  2745. INGENIC_PIN_GROUP("pwm6-e", x2000_pwm_pwm6_e, 1),
  2746. INGENIC_PIN_GROUP("pwm7-c", x2000_pwm_pwm7_c, 0),
  2747. INGENIC_PIN_GROUP("pwm7-e", x2000_pwm_pwm7_e, 1),
  2748. INGENIC_PIN_GROUP("pwm8", x2000_pwm_pwm8, 0),
  2749. INGENIC_PIN_GROUP("pwm9", x2000_pwm_pwm9, 0),
  2750. INGENIC_PIN_GROUP("pwm10", x2000_pwm_pwm10, 0),
  2751. INGENIC_PIN_GROUP("pwm11", x2000_pwm_pwm11, 0),
  2752. INGENIC_PIN_GROUP("pwm12", x2000_pwm_pwm12, 0),
  2753. INGENIC_PIN_GROUP("pwm13", x2000_pwm_pwm13, 0),
  2754. INGENIC_PIN_GROUP("pwm14", x2000_pwm_pwm14, 0),
  2755. INGENIC_PIN_GROUP("pwm15", x2000_pwm_pwm15, 0),
  2756. INGENIC_PIN_GROUP("mac0-rmii", x2000_mac0_rmii, 1),
  2757. INGENIC_PIN_GROUP("mac0-rgmii", x2000_mac0_rgmii, 1),
  2758. INGENIC_PIN_GROUP("mac1-rmii", x2000_mac1_rmii, 3),
  2759. INGENIC_PIN_GROUP("mac1-rgmii", x2000_mac1_rgmii, 3),
  2760. INGENIC_PIN_GROUP("otg-vbus", x2000_otg, 0),
  2761. };
  2762. static const char *x2000_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
  2763. static const char *x2000_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
  2764. static const char *x2000_uart2_groups[] = { "uart2-data", };
  2765. static const char *x2000_uart3_groups[] = {
  2766. "uart3-data-c", "uart3-data-d", "uart3-hwflow-c", "uart3-hwflow-d",
  2767. };
  2768. static const char *x2000_uart4_groups[] = {
  2769. "uart4-data-a", "uart4-data-c", "uart4-hwflow-a", "uart4-hwflow-c",
  2770. };
  2771. static const char *x2000_uart5_groups[] = { "uart5-data-a", "uart5-data-c", };
  2772. static const char *x2000_uart6_groups[] = { "uart6-data-a", "uart6-data-c", };
  2773. static const char *x2000_uart7_groups[] = { "uart7-data-a", "uart7-data-c", };
  2774. static const char *x2000_uart8_groups[] = { "uart8-data", };
  2775. static const char *x2000_uart9_groups[] = { "uart9-data", };
  2776. static const char *x2000_sfc_groups[] = {
  2777. "sfc-data-if0-d", "sfc-data-if0-e", "sfc-data-if1",
  2778. "sfc-clk-d", "sfc-clk-e", "sfc-ce-d", "sfc-ce-e",
  2779. };
  2780. static const char *x2000_ssi0_groups[] = {
  2781. "ssi0-dt-b", "ssi0-dt-d",
  2782. "ssi0-dr-b", "ssi0-dr-d",
  2783. "ssi0-clk-b", "ssi0-clk-d",
  2784. "ssi0-ce-b", "ssi0-ce-d",
  2785. };
  2786. static const char *x2000_ssi1_groups[] = {
  2787. "ssi1-dt-c", "ssi1-dt-d", "ssi1-dt-e",
  2788. "ssi1-dr-c", "ssi1-dr-d", "ssi1-dr-e",
  2789. "ssi1-clk-c", "ssi1-clk-d", "ssi1-clk-e",
  2790. "ssi1-ce-c", "ssi1-ce-d", "ssi1-ce-e",
  2791. };
  2792. static const char *x2000_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", "mmc0-8bit", };
  2793. static const char *x2000_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
  2794. static const char *x2000_mmc2_groups[] = { "mmc2-1bit", "mmc2-4bit", };
  2795. static const char *x2000_emc_groups[] = {
  2796. "emc-8bit-data", "emc-16bit-data",
  2797. "emc-addr", "emc-rd-we", "emc-wait",
  2798. };
  2799. static const char *x2000_cs1_groups[] = { "emc-cs1", };
  2800. static const char *x2000_cs2_groups[] = { "emc-cs2", };
  2801. static const char *x2000_i2c0_groups[] = { "i2c0-data", };
  2802. static const char *x2000_i2c1_groups[] = { "i2c1-data-c", "i2c1-data-d", };
  2803. static const char *x2000_i2c2_groups[] = { "i2c2-data-b", "i2c2-data-d", };
  2804. static const char *x2000_i2c3_groups[] = { "i2c3-data-a", "i2c3-data-d", };
  2805. static const char *x2000_i2c4_groups[] = { "i2c4-data-c", "i2c4-data-d", };
  2806. static const char *x2000_i2c5_groups[] = { "i2c5-data-c", "i2c5-data-d", };
  2807. static const char *x2000_i2s1_groups[] = {
  2808. "i2s1-data-tx", "i2s1-data-rx",
  2809. "i2s1-clk-tx", "i2s1-clk-rx",
  2810. "i2s1-sysclk-tx", "i2s1-sysclk-rx",
  2811. };
  2812. static const char *x2000_i2s2_groups[] = {
  2813. "i2s2-data-rx0", "i2s2-data-rx1", "i2s2-data-rx2", "i2s2-data-rx3",
  2814. "i2s2-clk-rx", "i2s2-sysclk-rx",
  2815. };
  2816. static const char *x2000_i2s3_groups[] = {
  2817. "i2s3-data-tx0", "i2s3-data-tx1", "i2s3-data-tx2", "i2s3-data-tx3",
  2818. "i2s3-clk-tx", "i2s3-sysclk-tx",
  2819. };
  2820. static const char *x2000_dmic_groups[] = {
  2821. "dmic-if0", "dmic-if1", "dmic-if2", "dmic-if3",
  2822. };
  2823. static const char *x2000_cim_groups[] = { "cim-data-8bit", "cim-data-12bit", };
  2824. static const char *x2000_lcd_groups[] = {
  2825. "lcd-tft-8bit", "lcd-tft-16bit", "lcd-tft-18bit", "lcd-tft-24bit",
  2826. "lcd-slcd-8bit", "lcd-slcd-16bit",
  2827. };
  2828. static const char *x2000_pwm0_groups[] = { "pwm0-c", "pwm0-d", };
  2829. static const char *x2000_pwm1_groups[] = { "pwm1-c", "pwm1-d", };
  2830. static const char *x2000_pwm2_groups[] = { "pwm2-c", "pwm2-e", };
  2831. static const char *x2000_pwm3_groups[] = { "pwm3-c", "pwm3-r", };
  2832. static const char *x2000_pwm4_groups[] = { "pwm4-c", "pwm4-e", };
  2833. static const char *x2000_pwm5_groups[] = { "pwm5-c", "pwm5-e", };
  2834. static const char *x2000_pwm6_groups[] = { "pwm6-c", "pwm6-e", };
  2835. static const char *x2000_pwm7_groups[] = { "pwm7-c", "pwm7-e", };
  2836. static const char *x2000_pwm8_groups[] = { "pwm8", };
  2837. static const char *x2000_pwm9_groups[] = { "pwm9", };
  2838. static const char *x2000_pwm10_groups[] = { "pwm10", };
  2839. static const char *x2000_pwm11_groups[] = { "pwm11", };
  2840. static const char *x2000_pwm12_groups[] = { "pwm12", };
  2841. static const char *x2000_pwm13_groups[] = { "pwm13", };
  2842. static const char *x2000_pwm14_groups[] = { "pwm14", };
  2843. static const char *x2000_pwm15_groups[] = { "pwm15", };
  2844. static const char *x2000_mac0_groups[] = { "mac0-rmii", "mac0-rgmii", };
  2845. static const char *x2000_mac1_groups[] = { "mac1-rmii", "mac1-rgmii", };
  2846. static const char *x2000_otg_groups[] = { "otg-vbus", };
  2847. static const struct function_desc x2000_functions[] = {
  2848. { "uart0", x2000_uart0_groups, ARRAY_SIZE(x2000_uart0_groups), },
  2849. { "uart1", x2000_uart1_groups, ARRAY_SIZE(x2000_uart1_groups), },
  2850. { "uart2", x2000_uart2_groups, ARRAY_SIZE(x2000_uart2_groups), },
  2851. { "uart3", x2000_uart3_groups, ARRAY_SIZE(x2000_uart3_groups), },
  2852. { "uart4", x2000_uart4_groups, ARRAY_SIZE(x2000_uart4_groups), },
  2853. { "uart5", x2000_uart5_groups, ARRAY_SIZE(x2000_uart5_groups), },
  2854. { "uart6", x2000_uart6_groups, ARRAY_SIZE(x2000_uart6_groups), },
  2855. { "uart7", x2000_uart7_groups, ARRAY_SIZE(x2000_uart7_groups), },
  2856. { "uart8", x2000_uart8_groups, ARRAY_SIZE(x2000_uart8_groups), },
  2857. { "uart9", x2000_uart9_groups, ARRAY_SIZE(x2000_uart9_groups), },
  2858. { "sfc", x2000_sfc_groups, ARRAY_SIZE(x2000_sfc_groups), },
  2859. { "ssi0", x2000_ssi0_groups, ARRAY_SIZE(x2000_ssi0_groups), },
  2860. { "ssi1", x2000_ssi1_groups, ARRAY_SIZE(x2000_ssi1_groups), },
  2861. { "mmc0", x2000_mmc0_groups, ARRAY_SIZE(x2000_mmc0_groups), },
  2862. { "mmc1", x2000_mmc1_groups, ARRAY_SIZE(x2000_mmc1_groups), },
  2863. { "mmc2", x2000_mmc2_groups, ARRAY_SIZE(x2000_mmc2_groups), },
  2864. { "emc", x2000_emc_groups, ARRAY_SIZE(x2000_emc_groups), },
  2865. { "emc-cs1", x2000_cs1_groups, ARRAY_SIZE(x2000_cs1_groups), },
  2866. { "emc-cs2", x2000_cs2_groups, ARRAY_SIZE(x2000_cs2_groups), },
  2867. { "i2c0", x2000_i2c0_groups, ARRAY_SIZE(x2000_i2c0_groups), },
  2868. { "i2c1", x2000_i2c1_groups, ARRAY_SIZE(x2000_i2c1_groups), },
  2869. { "i2c2", x2000_i2c2_groups, ARRAY_SIZE(x2000_i2c2_groups), },
  2870. { "i2c3", x2000_i2c3_groups, ARRAY_SIZE(x2000_i2c3_groups), },
  2871. { "i2c4", x2000_i2c4_groups, ARRAY_SIZE(x2000_i2c4_groups), },
  2872. { "i2c5", x2000_i2c5_groups, ARRAY_SIZE(x2000_i2c5_groups), },
  2873. { "i2s1", x2000_i2s1_groups, ARRAY_SIZE(x2000_i2s1_groups), },
  2874. { "i2s2", x2000_i2s2_groups, ARRAY_SIZE(x2000_i2s2_groups), },
  2875. { "i2s3", x2000_i2s3_groups, ARRAY_SIZE(x2000_i2s3_groups), },
  2876. { "dmic", x2000_dmic_groups, ARRAY_SIZE(x2000_dmic_groups), },
  2877. { "cim", x2000_cim_groups, ARRAY_SIZE(x2000_cim_groups), },
  2878. { "lcd", x2000_lcd_groups, ARRAY_SIZE(x2000_lcd_groups), },
  2879. { "pwm0", x2000_pwm0_groups, ARRAY_SIZE(x2000_pwm0_groups), },
  2880. { "pwm1", x2000_pwm1_groups, ARRAY_SIZE(x2000_pwm1_groups), },
  2881. { "pwm2", x2000_pwm2_groups, ARRAY_SIZE(x2000_pwm2_groups), },
  2882. { "pwm3", x2000_pwm3_groups, ARRAY_SIZE(x2000_pwm3_groups), },
  2883. { "pwm4", x2000_pwm4_groups, ARRAY_SIZE(x2000_pwm4_groups), },
  2884. { "pwm5", x2000_pwm5_groups, ARRAY_SIZE(x2000_pwm5_groups), },
  2885. { "pwm6", x2000_pwm6_groups, ARRAY_SIZE(x2000_pwm6_groups), },
  2886. { "pwm7", x2000_pwm7_groups, ARRAY_SIZE(x2000_pwm7_groups), },
  2887. { "pwm8", x2000_pwm8_groups, ARRAY_SIZE(x2000_pwm8_groups), },
  2888. { "pwm9", x2000_pwm9_groups, ARRAY_SIZE(x2000_pwm9_groups), },
  2889. { "pwm10", x2000_pwm10_groups, ARRAY_SIZE(x2000_pwm10_groups), },
  2890. { "pwm11", x2000_pwm11_groups, ARRAY_SIZE(x2000_pwm11_groups), },
  2891. { "pwm12", x2000_pwm12_groups, ARRAY_SIZE(x2000_pwm12_groups), },
  2892. { "pwm13", x2000_pwm13_groups, ARRAY_SIZE(x2000_pwm13_groups), },
  2893. { "pwm14", x2000_pwm14_groups, ARRAY_SIZE(x2000_pwm14_groups), },
  2894. { "pwm15", x2000_pwm15_groups, ARRAY_SIZE(x2000_pwm15_groups), },
  2895. { "mac0", x2000_mac0_groups, ARRAY_SIZE(x2000_mac0_groups), },
  2896. { "mac1", x2000_mac1_groups, ARRAY_SIZE(x2000_mac1_groups), },
  2897. { "otg", x2000_otg_groups, ARRAY_SIZE(x2000_otg_groups), },
  2898. };
  2899. static const struct regmap_range x2000_access_ranges[] = {
  2900. regmap_reg_range(0x000, 0x500 - 4),
  2901. regmap_reg_range(0x700, 0x800 - 4),
  2902. };
  2903. /* shared with X2100 */
  2904. static const struct regmap_access_table x2000_access_table = {
  2905. .yes_ranges = x2000_access_ranges,
  2906. .n_yes_ranges = ARRAY_SIZE(x2000_access_ranges),
  2907. };
  2908. static const struct ingenic_chip_info x2000_chip_info = {
  2909. .num_chips = 5,
  2910. .reg_offset = 0x100,
  2911. .version = ID_X2000,
  2912. .groups = x2000_groups,
  2913. .num_groups = ARRAY_SIZE(x2000_groups),
  2914. .functions = x2000_functions,
  2915. .num_functions = ARRAY_SIZE(x2000_functions),
  2916. .pull_ups = x2000_pull_ups,
  2917. .pull_downs = x2000_pull_downs,
  2918. .access_table = &x2000_access_table,
  2919. };
  2920. static const u32 x2100_pull_ups[5] = {
  2921. 0x0003ffff, 0xffffffff, 0x1ff0ffff, 0xc7fe3f3f, 0x0fbf003f,
  2922. };
  2923. static const u32 x2100_pull_downs[5] = {
  2924. 0x0003ffff, 0xffffffff, 0x1ff0ffff, 0x00000000, 0x0fbf003f,
  2925. };
  2926. static int x2100_mac_pins[] = {
  2927. 0x4b, 0x47, 0x46, 0x4a, 0x43, 0x42, 0x4c, 0x4d, 0x4f, 0x41,
  2928. };
  2929. static const struct group_desc x2100_groups[] = {
  2930. INGENIC_PIN_GROUP("uart0-data", x2000_uart0_data, 2),
  2931. INGENIC_PIN_GROUP("uart0-hwflow", x2000_uart0_hwflow, 2),
  2932. INGENIC_PIN_GROUP("uart1-data", x2000_uart1_data, 1),
  2933. INGENIC_PIN_GROUP("uart1-hwflow", x2000_uart1_hwflow, 1),
  2934. INGENIC_PIN_GROUP("uart2-data", x2000_uart2_data, 0),
  2935. INGENIC_PIN_GROUP("uart3-data-c", x2000_uart3_data_c, 0),
  2936. INGENIC_PIN_GROUP("uart3-data-d", x2000_uart3_data_d, 1),
  2937. INGENIC_PIN_GROUP("uart3-hwflow-c", x2000_uart3_hwflow_c, 0),
  2938. INGENIC_PIN_GROUP("uart3-hwflow-d", x2000_uart3_hwflow_d, 1),
  2939. INGENIC_PIN_GROUP("uart4-data-a", x2000_uart4_data_a, 1),
  2940. INGENIC_PIN_GROUP("uart4-data-c", x2000_uart4_data_c, 3),
  2941. INGENIC_PIN_GROUP("uart4-hwflow-a", x2000_uart4_hwflow_a, 1),
  2942. INGENIC_PIN_GROUP("uart4-hwflow-c", x2000_uart4_hwflow_c, 3),
  2943. INGENIC_PIN_GROUP("uart5-data-a", x2000_uart5_data_a, 1),
  2944. INGENIC_PIN_GROUP("uart5-data-c", x2000_uart5_data_c, 3),
  2945. INGENIC_PIN_GROUP("uart6-data-a", x2000_uart6_data_a, 1),
  2946. INGENIC_PIN_GROUP("uart6-data-c", x2000_uart6_data_c, 3),
  2947. INGENIC_PIN_GROUP("uart7-data-a", x2000_uart7_data_a, 1),
  2948. INGENIC_PIN_GROUP("uart7-data-c", x2000_uart7_data_c, 3),
  2949. INGENIC_PIN_GROUP("uart8-data", x2000_uart8_data, 3),
  2950. INGENIC_PIN_GROUP("uart9-data", x2000_uart9_data, 3),
  2951. INGENIC_PIN_GROUP("sfc-data-if0-d", x2000_sfc_data_if0_d, 1),
  2952. INGENIC_PIN_GROUP("sfc-data-if0-e", x2000_sfc_data_if0_e, 0),
  2953. INGENIC_PIN_GROUP("sfc-data-if1", x2000_sfc_data_if1, 1),
  2954. INGENIC_PIN_GROUP("sfc-clk-d", x2000_sfc_clk_d, 1),
  2955. INGENIC_PIN_GROUP("sfc-clk-e", x2000_sfc_clk_e, 0),
  2956. INGENIC_PIN_GROUP("sfc-ce-d", x2000_sfc_ce_d, 1),
  2957. INGENIC_PIN_GROUP("sfc-ce-e", x2000_sfc_ce_e, 0),
  2958. INGENIC_PIN_GROUP("ssi0-dt-b", x2000_ssi0_dt_b, 1),
  2959. INGENIC_PIN_GROUP("ssi0-dt-d", x2000_ssi0_dt_d, 1),
  2960. INGENIC_PIN_GROUP("ssi0-dr-b", x2000_ssi0_dr_b, 1),
  2961. INGENIC_PIN_GROUP("ssi0-dr-d", x2000_ssi0_dr_d, 1),
  2962. INGENIC_PIN_GROUP("ssi0-clk-b", x2000_ssi0_clk_b, 1),
  2963. INGENIC_PIN_GROUP("ssi0-clk-d", x2000_ssi0_clk_d, 1),
  2964. INGENIC_PIN_GROUP("ssi0-ce-b", x2000_ssi0_ce_b, 1),
  2965. INGENIC_PIN_GROUP("ssi0-ce-d", x2000_ssi0_ce_d, 1),
  2966. INGENIC_PIN_GROUP("ssi1-dt-c", x2000_ssi1_dt_c, 2),
  2967. INGENIC_PIN_GROUP("ssi1-dt-d", x2000_ssi1_dt_d, 2),
  2968. INGENIC_PIN_GROUP("ssi1-dt-e", x2000_ssi1_dt_e, 1),
  2969. INGENIC_PIN_GROUP("ssi1-dr-c", x2000_ssi1_dr_c, 2),
  2970. INGENIC_PIN_GROUP("ssi1-dr-d", x2000_ssi1_dr_d, 2),
  2971. INGENIC_PIN_GROUP("ssi1-dr-e", x2000_ssi1_dr_e, 1),
  2972. INGENIC_PIN_GROUP("ssi1-clk-c", x2000_ssi1_clk_c, 2),
  2973. INGENIC_PIN_GROUP("ssi1-clk-d", x2000_ssi1_clk_d, 2),
  2974. INGENIC_PIN_GROUP("ssi1-clk-e", x2000_ssi1_clk_e, 1),
  2975. INGENIC_PIN_GROUP("ssi1-ce-c", x2000_ssi1_ce_c, 2),
  2976. INGENIC_PIN_GROUP("ssi1-ce-d", x2000_ssi1_ce_d, 2),
  2977. INGENIC_PIN_GROUP("ssi1-ce-e", x2000_ssi1_ce_e, 1),
  2978. INGENIC_PIN_GROUP("mmc0-1bit", x2000_mmc0_1bit, 0),
  2979. INGENIC_PIN_GROUP("mmc0-4bit", x2000_mmc0_4bit, 0),
  2980. INGENIC_PIN_GROUP("mmc0-8bit", x2000_mmc0_8bit, 0),
  2981. INGENIC_PIN_GROUP("mmc1-1bit", x2000_mmc1_1bit, 0),
  2982. INGENIC_PIN_GROUP("mmc1-4bit", x2000_mmc1_4bit, 0),
  2983. INGENIC_PIN_GROUP("mmc2-1bit", x2000_mmc2_1bit, 0),
  2984. INGENIC_PIN_GROUP("mmc2-4bit", x2000_mmc2_4bit, 0),
  2985. INGENIC_PIN_GROUP("emc-8bit-data", x2000_emc_8bit_data, 0),
  2986. INGENIC_PIN_GROUP("emc-16bit-data", x2000_emc_16bit_data, 0),
  2987. INGENIC_PIN_GROUP("emc-addr", x2000_emc_addr, 0),
  2988. INGENIC_PIN_GROUP("emc-rd-we", x2000_emc_rd_we, 0),
  2989. INGENIC_PIN_GROUP("emc-wait", x2000_emc_wait, 0),
  2990. INGENIC_PIN_GROUP("emc-cs1", x2000_emc_cs1, 3),
  2991. INGENIC_PIN_GROUP("emc-cs2", x2000_emc_cs2, 3),
  2992. INGENIC_PIN_GROUP("i2c0-data", x2000_i2c0, 3),
  2993. INGENIC_PIN_GROUP("i2c1-data-c", x2000_i2c1_c, 2),
  2994. INGENIC_PIN_GROUP("i2c1-data-d", x2000_i2c1_d, 1),
  2995. INGENIC_PIN_GROUP("i2c2-data-b", x2000_i2c2_b, 2),
  2996. INGENIC_PIN_GROUP("i2c2-data-d", x2000_i2c2_d, 2),
  2997. INGENIC_PIN_GROUP("i2c2-data-e", x2000_i2c2_e, 1),
  2998. INGENIC_PIN_GROUP("i2c3-data-a", x2000_i2c3_a, 0),
  2999. INGENIC_PIN_GROUP("i2c3-data-d", x2000_i2c3_d, 1),
  3000. INGENIC_PIN_GROUP("i2c4-data-c", x2000_i2c4_c, 1),
  3001. INGENIC_PIN_GROUP("i2c4-data-d", x2000_i2c4_d, 2),
  3002. INGENIC_PIN_GROUP("i2c5-data-c", x2000_i2c5_c, 1),
  3003. INGENIC_PIN_GROUP("i2c5-data-d", x2000_i2c5_d, 1),
  3004. INGENIC_PIN_GROUP("i2s1-data-tx", x2000_i2s1_data_tx, 2),
  3005. INGENIC_PIN_GROUP("i2s1-data-rx", x2000_i2s1_data_rx, 2),
  3006. INGENIC_PIN_GROUP("i2s1-clk-tx", x2000_i2s1_clk_tx, 2),
  3007. INGENIC_PIN_GROUP("i2s1-clk-rx", x2000_i2s1_clk_rx, 2),
  3008. INGENIC_PIN_GROUP("i2s1-sysclk-tx", x2000_i2s1_sysclk_tx, 2),
  3009. INGENIC_PIN_GROUP("i2s1-sysclk-rx", x2000_i2s1_sysclk_rx, 2),
  3010. INGENIC_PIN_GROUP("i2s2-data-rx0", x2000_i2s2_data_rx0, 2),
  3011. INGENIC_PIN_GROUP("i2s2-data-rx1", x2000_i2s2_data_rx1, 2),
  3012. INGENIC_PIN_GROUP("i2s2-data-rx2", x2000_i2s2_data_rx2, 2),
  3013. INGENIC_PIN_GROUP("i2s2-data-rx3", x2000_i2s2_data_rx3, 2),
  3014. INGENIC_PIN_GROUP("i2s2-clk-rx", x2000_i2s2_clk_rx, 2),
  3015. INGENIC_PIN_GROUP("i2s2-sysclk-rx", x2000_i2s2_sysclk_rx, 2),
  3016. INGENIC_PIN_GROUP("i2s3-data-tx0", x2000_i2s3_data_tx0, 2),
  3017. INGENIC_PIN_GROUP("i2s3-data-tx1", x2000_i2s3_data_tx1, 2),
  3018. INGENIC_PIN_GROUP("i2s3-data-tx2", x2000_i2s3_data_tx2, 2),
  3019. INGENIC_PIN_GROUP("i2s3-data-tx3", x2000_i2s3_data_tx3, 2),
  3020. INGENIC_PIN_GROUP("i2s3-clk-tx", x2000_i2s3_clk_tx, 2),
  3021. INGENIC_PIN_GROUP("i2s3-sysclk-tx", x2000_i2s3_sysclk_tx, 2),
  3022. INGENIC_PIN_GROUP("dmic-if0", x2000_dmic_if0, 0),
  3023. INGENIC_PIN_GROUP("dmic-if1", x2000_dmic_if1, 0),
  3024. INGENIC_PIN_GROUP("dmic-if2", x2000_dmic_if2, 0),
  3025. INGENIC_PIN_GROUP("dmic-if3", x2000_dmic_if3, 0),
  3026. INGENIC_PIN_GROUP_FUNCS("cim-data-8bit", x2000_cim_8bit,
  3027. x2000_cim_8bit_funcs),
  3028. INGENIC_PIN_GROUP("cim-data-12bit", x2000_cim_12bit, 0),
  3029. INGENIC_PIN_GROUP("lcd-tft-8bit", x2000_lcd_tft_8bit, 1),
  3030. INGENIC_PIN_GROUP("lcd-tft-16bit", x2000_lcd_tft_16bit, 1),
  3031. INGENIC_PIN_GROUP("lcd-tft-18bit", x2000_lcd_tft_18bit, 1),
  3032. INGENIC_PIN_GROUP("lcd-tft-24bit", x2000_lcd_tft_24bit, 1),
  3033. INGENIC_PIN_GROUP("lcd-slcd-8bit", x2000_lcd_slcd_8bit, 2),
  3034. INGENIC_PIN_GROUP("lcd-slcd-16bit", x2000_lcd_tft_16bit, 2),
  3035. INGENIC_PIN_GROUP("pwm0-c", x2000_pwm_pwm0_c, 0),
  3036. INGENIC_PIN_GROUP("pwm0-d", x2000_pwm_pwm0_d, 2),
  3037. INGENIC_PIN_GROUP("pwm1-c", x2000_pwm_pwm1_c, 0),
  3038. INGENIC_PIN_GROUP("pwm1-d", x2000_pwm_pwm1_d, 2),
  3039. INGENIC_PIN_GROUP("pwm2-c", x2000_pwm_pwm2_c, 0),
  3040. INGENIC_PIN_GROUP("pwm2-e", x2000_pwm_pwm2_e, 1),
  3041. INGENIC_PIN_GROUP("pwm3-c", x2000_pwm_pwm3_c, 0),
  3042. INGENIC_PIN_GROUP("pwm3-e", x2000_pwm_pwm3_e, 1),
  3043. INGENIC_PIN_GROUP("pwm4-c", x2000_pwm_pwm4_c, 0),
  3044. INGENIC_PIN_GROUP("pwm4-e", x2000_pwm_pwm4_e, 1),
  3045. INGENIC_PIN_GROUP("pwm5-c", x2000_pwm_pwm5_c, 0),
  3046. INGENIC_PIN_GROUP("pwm5-e", x2000_pwm_pwm5_e, 1),
  3047. INGENIC_PIN_GROUP("pwm6-c", x2000_pwm_pwm6_c, 0),
  3048. INGENIC_PIN_GROUP("pwm6-e", x2000_pwm_pwm6_e, 1),
  3049. INGENIC_PIN_GROUP("pwm7-c", x2000_pwm_pwm7_c, 0),
  3050. INGENIC_PIN_GROUP("pwm7-e", x2000_pwm_pwm7_e, 1),
  3051. INGENIC_PIN_GROUP("pwm8", x2000_pwm_pwm8, 0),
  3052. INGENIC_PIN_GROUP("pwm9", x2000_pwm_pwm9, 0),
  3053. INGENIC_PIN_GROUP("pwm10", x2000_pwm_pwm10, 0),
  3054. INGENIC_PIN_GROUP("pwm11", x2000_pwm_pwm11, 0),
  3055. INGENIC_PIN_GROUP("pwm12", x2000_pwm_pwm12, 0),
  3056. INGENIC_PIN_GROUP("pwm13", x2000_pwm_pwm13, 0),
  3057. INGENIC_PIN_GROUP("pwm14", x2000_pwm_pwm14, 0),
  3058. INGENIC_PIN_GROUP("pwm15", x2000_pwm_pwm15, 0),
  3059. INGENIC_PIN_GROUP("mac", x2100_mac, 1),
  3060. };
  3061. static const char *x2100_mac_groups[] = { "mac", };
  3062. static const struct function_desc x2100_functions[] = {
  3063. { "uart0", x2000_uart0_groups, ARRAY_SIZE(x2000_uart0_groups), },
  3064. { "uart1", x2000_uart1_groups, ARRAY_SIZE(x2000_uart1_groups), },
  3065. { "uart2", x2000_uart2_groups, ARRAY_SIZE(x2000_uart2_groups), },
  3066. { "uart3", x2000_uart3_groups, ARRAY_SIZE(x2000_uart3_groups), },
  3067. { "uart4", x2000_uart4_groups, ARRAY_SIZE(x2000_uart4_groups), },
  3068. { "uart5", x2000_uart5_groups, ARRAY_SIZE(x2000_uart5_groups), },
  3069. { "uart6", x2000_uart6_groups, ARRAY_SIZE(x2000_uart6_groups), },
  3070. { "uart7", x2000_uart7_groups, ARRAY_SIZE(x2000_uart7_groups), },
  3071. { "uart8", x2000_uart8_groups, ARRAY_SIZE(x2000_uart8_groups), },
  3072. { "uart9", x2000_uart9_groups, ARRAY_SIZE(x2000_uart9_groups), },
  3073. { "sfc", x2000_sfc_groups, ARRAY_SIZE(x2000_sfc_groups), },
  3074. { "ssi0", x2000_ssi0_groups, ARRAY_SIZE(x2000_ssi0_groups), },
  3075. { "ssi1", x2000_ssi1_groups, ARRAY_SIZE(x2000_ssi1_groups), },
  3076. { "mmc0", x2000_mmc0_groups, ARRAY_SIZE(x2000_mmc0_groups), },
  3077. { "mmc1", x2000_mmc1_groups, ARRAY_SIZE(x2000_mmc1_groups), },
  3078. { "mmc2", x2000_mmc2_groups, ARRAY_SIZE(x2000_mmc2_groups), },
  3079. { "emc", x2000_emc_groups, ARRAY_SIZE(x2000_emc_groups), },
  3080. { "emc-cs1", x2000_cs1_groups, ARRAY_SIZE(x2000_cs1_groups), },
  3081. { "emc-cs2", x2000_cs2_groups, ARRAY_SIZE(x2000_cs2_groups), },
  3082. { "i2c0", x2000_i2c0_groups, ARRAY_SIZE(x2000_i2c0_groups), },
  3083. { "i2c1", x2000_i2c1_groups, ARRAY_SIZE(x2000_i2c1_groups), },
  3084. { "i2c2", x2000_i2c2_groups, ARRAY_SIZE(x2000_i2c2_groups), },
  3085. { "i2c3", x2000_i2c3_groups, ARRAY_SIZE(x2000_i2c3_groups), },
  3086. { "i2c4", x2000_i2c4_groups, ARRAY_SIZE(x2000_i2c4_groups), },
  3087. { "i2c5", x2000_i2c5_groups, ARRAY_SIZE(x2000_i2c5_groups), },
  3088. { "i2s1", x2000_i2s1_groups, ARRAY_SIZE(x2000_i2s1_groups), },
  3089. { "i2s2", x2000_i2s2_groups, ARRAY_SIZE(x2000_i2s2_groups), },
  3090. { "i2s3", x2000_i2s3_groups, ARRAY_SIZE(x2000_i2s3_groups), },
  3091. { "dmic", x2000_dmic_groups, ARRAY_SIZE(x2000_dmic_groups), },
  3092. { "cim", x2000_cim_groups, ARRAY_SIZE(x2000_cim_groups), },
  3093. { "lcd", x2000_lcd_groups, ARRAY_SIZE(x2000_lcd_groups), },
  3094. { "pwm0", x2000_pwm0_groups, ARRAY_SIZE(x2000_pwm0_groups), },
  3095. { "pwm1", x2000_pwm1_groups, ARRAY_SIZE(x2000_pwm1_groups), },
  3096. { "pwm2", x2000_pwm2_groups, ARRAY_SIZE(x2000_pwm2_groups), },
  3097. { "pwm3", x2000_pwm3_groups, ARRAY_SIZE(x2000_pwm3_groups), },
  3098. { "pwm4", x2000_pwm4_groups, ARRAY_SIZE(x2000_pwm4_groups), },
  3099. { "pwm5", x2000_pwm5_groups, ARRAY_SIZE(x2000_pwm5_groups), },
  3100. { "pwm6", x2000_pwm6_groups, ARRAY_SIZE(x2000_pwm6_groups), },
  3101. { "pwm7", x2000_pwm7_groups, ARRAY_SIZE(x2000_pwm7_groups), },
  3102. { "pwm8", x2000_pwm8_groups, ARRAY_SIZE(x2000_pwm8_groups), },
  3103. { "pwm9", x2000_pwm9_groups, ARRAY_SIZE(x2000_pwm9_groups), },
  3104. { "pwm10", x2000_pwm10_groups, ARRAY_SIZE(x2000_pwm10_groups), },
  3105. { "pwm11", x2000_pwm11_groups, ARRAY_SIZE(x2000_pwm11_groups), },
  3106. { "pwm12", x2000_pwm12_groups, ARRAY_SIZE(x2000_pwm12_groups), },
  3107. { "pwm13", x2000_pwm13_groups, ARRAY_SIZE(x2000_pwm13_groups), },
  3108. { "pwm14", x2000_pwm14_groups, ARRAY_SIZE(x2000_pwm14_groups), },
  3109. { "pwm15", x2000_pwm15_groups, ARRAY_SIZE(x2000_pwm15_groups), },
  3110. { "mac", x2100_mac_groups, ARRAY_SIZE(x2100_mac_groups), },
  3111. };
  3112. static const struct ingenic_chip_info x2100_chip_info = {
  3113. .num_chips = 5,
  3114. .reg_offset = 0x100,
  3115. .version = ID_X2100,
  3116. .groups = x2100_groups,
  3117. .num_groups = ARRAY_SIZE(x2100_groups),
  3118. .functions = x2100_functions,
  3119. .num_functions = ARRAY_SIZE(x2100_functions),
  3120. .pull_ups = x2100_pull_ups,
  3121. .pull_downs = x2100_pull_downs,
  3122. .access_table = &x2000_access_table,
  3123. };
  3124. static u32 ingenic_gpio_read_reg(struct ingenic_gpio_chip *jzgc, u8 reg)
  3125. {
  3126. unsigned int val;
  3127. regmap_read(jzgc->jzpc->map, jzgc->reg_base + reg, &val);
  3128. return (u32) val;
  3129. }
  3130. static void ingenic_gpio_set_bit(struct ingenic_gpio_chip *jzgc,
  3131. u8 reg, u8 offset, bool set)
  3132. {
  3133. if (!is_soc_or_above(jzgc->jzpc, ID_JZ4740)) {
  3134. regmap_update_bits(jzgc->jzpc->map, jzgc->reg_base + reg,
  3135. BIT(offset), set ? BIT(offset) : 0);
  3136. return;
  3137. }
  3138. if (set)
  3139. reg = REG_SET(reg);
  3140. else
  3141. reg = REG_CLEAR(reg);
  3142. regmap_write(jzgc->jzpc->map, jzgc->reg_base + reg, BIT(offset));
  3143. }
  3144. static void ingenic_gpio_shadow_set_bit(struct ingenic_gpio_chip *jzgc,
  3145. u8 reg, u8 offset, bool set)
  3146. {
  3147. if (set)
  3148. reg = REG_SET(reg);
  3149. else
  3150. reg = REG_CLEAR(reg);
  3151. regmap_write(jzgc->jzpc->map, REG_PZ_BASE(
  3152. jzgc->jzpc->info->reg_offset) + reg, BIT(offset));
  3153. }
  3154. static void ingenic_gpio_shadow_set_bit_load(struct ingenic_gpio_chip *jzgc)
  3155. {
  3156. regmap_write(jzgc->jzpc->map, REG_PZ_GID2LD(
  3157. jzgc->jzpc->info->reg_offset),
  3158. jzgc->gc.base / PINS_PER_GPIO_CHIP);
  3159. }
  3160. static void jz4730_gpio_set_bits(struct ingenic_gpio_chip *jzgc,
  3161. u8 reg_upper, u8 reg_lower, u8 offset, u8 value)
  3162. {
  3163. /*
  3164. * JZ4730 function and IRQ registers support two-bits-per-pin
  3165. * definitions, split into two groups of 16.
  3166. */
  3167. u8 reg = offset < JZ4730_PINS_PER_PAIRED_REG ? reg_lower : reg_upper;
  3168. unsigned int idx = offset % JZ4730_PINS_PER_PAIRED_REG;
  3169. unsigned int mask = GENMASK(1, 0) << idx * 2;
  3170. regmap_update_bits(jzgc->jzpc->map, jzgc->reg_base + reg, mask, value << (idx * 2));
  3171. }
  3172. static inline bool ingenic_gpio_get_value(struct ingenic_gpio_chip *jzgc,
  3173. u8 offset)
  3174. {
  3175. unsigned int val = ingenic_gpio_read_reg(jzgc, GPIO_PIN);
  3176. return !!(val & BIT(offset));
  3177. }
  3178. static void ingenic_gpio_set_value(struct ingenic_gpio_chip *jzgc,
  3179. u8 offset, int value)
  3180. {
  3181. if (is_soc_or_above(jzgc->jzpc, ID_JZ4770))
  3182. ingenic_gpio_set_bit(jzgc, JZ4770_GPIO_PAT0, offset, !!value);
  3183. else if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
  3184. ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, offset, !!value);
  3185. else
  3186. ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_DATA, offset, !!value);
  3187. }
  3188. static void irq_set_type(struct ingenic_gpio_chip *jzgc,
  3189. u8 offset, unsigned int type)
  3190. {
  3191. u8 reg1, reg2;
  3192. bool val1, val2, val3;
  3193. switch (type) {
  3194. case IRQ_TYPE_EDGE_BOTH:
  3195. val1 = val2 = false;
  3196. val3 = true;
  3197. break;
  3198. case IRQ_TYPE_EDGE_RISING:
  3199. val1 = val2 = true;
  3200. val3 = false;
  3201. break;
  3202. case IRQ_TYPE_EDGE_FALLING:
  3203. val1 = val3 = false;
  3204. val2 = true;
  3205. break;
  3206. case IRQ_TYPE_LEVEL_HIGH:
  3207. val1 = true;
  3208. val2 = val3 = false;
  3209. break;
  3210. case IRQ_TYPE_LEVEL_LOW:
  3211. default:
  3212. val1 = val2 = val3 = false;
  3213. break;
  3214. }
  3215. if (is_soc_or_above(jzgc->jzpc, ID_JZ4770)) {
  3216. reg1 = JZ4770_GPIO_PAT1;
  3217. reg2 = JZ4770_GPIO_PAT0;
  3218. } else if (is_soc_or_above(jzgc->jzpc, ID_JZ4740)) {
  3219. reg1 = JZ4740_GPIO_TRIG;
  3220. reg2 = JZ4740_GPIO_DIR;
  3221. } else {
  3222. ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_GPDIR, offset, false);
  3223. jz4730_gpio_set_bits(jzgc, JZ4730_GPIO_GPIDUR,
  3224. JZ4730_GPIO_GPIDLR, offset, (val2 << 1) | val1);
  3225. return;
  3226. }
  3227. if (is_soc_or_above(jzgc->jzpc, ID_X2000)) {
  3228. ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, val1);
  3229. ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, val2);
  3230. ingenic_gpio_shadow_set_bit_load(jzgc);
  3231. ingenic_gpio_set_bit(jzgc, X2000_GPIO_EDG, offset, val3);
  3232. } else if (is_soc_or_above(jzgc->jzpc, ID_X1000)) {
  3233. ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, val1);
  3234. ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, val2);
  3235. ingenic_gpio_shadow_set_bit_load(jzgc);
  3236. } else {
  3237. ingenic_gpio_set_bit(jzgc, reg2, offset, val1);
  3238. ingenic_gpio_set_bit(jzgc, reg1, offset, val2);
  3239. }
  3240. }
  3241. static void ingenic_gpio_irq_mask(struct irq_data *irqd)
  3242. {
  3243. struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
  3244. struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
  3245. irq_hw_number_t irq = irqd_to_hwirq(irqd);
  3246. if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
  3247. ingenic_gpio_set_bit(jzgc, GPIO_MSK, irq, true);
  3248. else
  3249. ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_GPIMR, irq, true);
  3250. }
  3251. static void ingenic_gpio_irq_unmask(struct irq_data *irqd)
  3252. {
  3253. struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
  3254. struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
  3255. irq_hw_number_t irq = irqd_to_hwirq(irqd);
  3256. if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
  3257. ingenic_gpio_set_bit(jzgc, GPIO_MSK, irq, false);
  3258. else
  3259. ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_GPIMR, irq, false);
  3260. }
  3261. static void ingenic_gpio_irq_enable(struct irq_data *irqd)
  3262. {
  3263. struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
  3264. struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
  3265. irq_hw_number_t irq = irqd_to_hwirq(irqd);
  3266. gpiochip_enable_irq(gc, irq);
  3267. if (is_soc_or_above(jzgc->jzpc, ID_JZ4770))
  3268. ingenic_gpio_set_bit(jzgc, JZ4770_GPIO_INT, irq, true);
  3269. else if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
  3270. ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, true);
  3271. else
  3272. ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_GPIER, irq, true);
  3273. ingenic_gpio_irq_unmask(irqd);
  3274. }
  3275. static void ingenic_gpio_irq_disable(struct irq_data *irqd)
  3276. {
  3277. struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
  3278. struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
  3279. irq_hw_number_t irq = irqd_to_hwirq(irqd);
  3280. ingenic_gpio_irq_mask(irqd);
  3281. if (is_soc_or_above(jzgc->jzpc, ID_JZ4770))
  3282. ingenic_gpio_set_bit(jzgc, JZ4770_GPIO_INT, irq, false);
  3283. else if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
  3284. ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, false);
  3285. else
  3286. ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_GPIER, irq, false);
  3287. gpiochip_disable_irq(gc, irq);
  3288. }
  3289. static void ingenic_gpio_irq_ack(struct irq_data *irqd)
  3290. {
  3291. struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
  3292. struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
  3293. irq_hw_number_t irq = irqd_to_hwirq(irqd);
  3294. bool high;
  3295. if ((irqd_get_trigger_type(irqd) == IRQ_TYPE_EDGE_BOTH) &&
  3296. !is_soc_or_above(jzgc->jzpc, ID_X2000)) {
  3297. /*
  3298. * Switch to an interrupt for the opposite edge to the one that
  3299. * triggered the interrupt being ACKed.
  3300. */
  3301. high = ingenic_gpio_get_value(jzgc, irq);
  3302. if (high)
  3303. irq_set_type(jzgc, irq, IRQ_TYPE_LEVEL_LOW);
  3304. else
  3305. irq_set_type(jzgc, irq, IRQ_TYPE_LEVEL_HIGH);
  3306. }
  3307. if (is_soc_or_above(jzgc->jzpc, ID_JZ4770))
  3308. ingenic_gpio_set_bit(jzgc, JZ4770_GPIO_FLAG, irq, false);
  3309. else if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
  3310. ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, irq, true);
  3311. else
  3312. ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_GPFR, irq, false);
  3313. }
  3314. static int ingenic_gpio_irq_set_type(struct irq_data *irqd, unsigned int type)
  3315. {
  3316. struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
  3317. struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
  3318. irq_hw_number_t irq = irqd_to_hwirq(irqd);
  3319. switch (type) {
  3320. case IRQ_TYPE_EDGE_BOTH:
  3321. case IRQ_TYPE_EDGE_RISING:
  3322. case IRQ_TYPE_EDGE_FALLING:
  3323. irq_set_handler_locked(irqd, handle_edge_irq);
  3324. break;
  3325. case IRQ_TYPE_LEVEL_HIGH:
  3326. case IRQ_TYPE_LEVEL_LOW:
  3327. irq_set_handler_locked(irqd, handle_level_irq);
  3328. break;
  3329. default:
  3330. irq_set_handler_locked(irqd, handle_bad_irq);
  3331. }
  3332. if ((type == IRQ_TYPE_EDGE_BOTH) && !is_soc_or_above(jzgc->jzpc, ID_X2000)) {
  3333. /*
  3334. * The hardware does not support interrupts on both edges. The
  3335. * best we can do is to set up a single-edge interrupt and then
  3336. * switch to the opposing edge when ACKing the interrupt.
  3337. */
  3338. bool high = ingenic_gpio_get_value(jzgc, irq);
  3339. type = high ? IRQ_TYPE_LEVEL_LOW : IRQ_TYPE_LEVEL_HIGH;
  3340. }
  3341. irq_set_type(jzgc, irq, type);
  3342. return 0;
  3343. }
  3344. static int ingenic_gpio_irq_set_wake(struct irq_data *irqd, unsigned int on)
  3345. {
  3346. struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
  3347. struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
  3348. return irq_set_irq_wake(jzgc->irq, on);
  3349. }
  3350. static void ingenic_gpio_irq_handler(struct irq_desc *desc)
  3351. {
  3352. struct gpio_chip *gc = irq_desc_get_handler_data(desc);
  3353. struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
  3354. struct irq_chip *irq_chip = irq_data_get_irq_chip(&desc->irq_data);
  3355. unsigned long flag, i;
  3356. chained_irq_enter(irq_chip, desc);
  3357. if (is_soc_or_above(jzgc->jzpc, ID_JZ4770))
  3358. flag = ingenic_gpio_read_reg(jzgc, JZ4770_GPIO_FLAG);
  3359. else if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
  3360. flag = ingenic_gpio_read_reg(jzgc, JZ4740_GPIO_FLAG);
  3361. else
  3362. flag = ingenic_gpio_read_reg(jzgc, JZ4730_GPIO_GPFR);
  3363. for_each_set_bit(i, &flag, 32)
  3364. generic_handle_domain_irq(gc->irq.domain, i);
  3365. chained_irq_exit(irq_chip, desc);
  3366. }
  3367. static void ingenic_gpio_set(struct gpio_chip *gc,
  3368. unsigned int offset, int value)
  3369. {
  3370. struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
  3371. ingenic_gpio_set_value(jzgc, offset, value);
  3372. }
  3373. static int ingenic_gpio_get(struct gpio_chip *gc, unsigned int offset)
  3374. {
  3375. struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
  3376. return (int) ingenic_gpio_get_value(jzgc, offset);
  3377. }
  3378. static int ingenic_gpio_direction_input(struct gpio_chip *gc,
  3379. unsigned int offset)
  3380. {
  3381. return pinctrl_gpio_direction_input(gc->base + offset);
  3382. }
  3383. static int ingenic_gpio_direction_output(struct gpio_chip *gc,
  3384. unsigned int offset, int value)
  3385. {
  3386. ingenic_gpio_set(gc, offset, value);
  3387. return pinctrl_gpio_direction_output(gc->base + offset);
  3388. }
  3389. static inline void ingenic_config_pin(struct ingenic_pinctrl *jzpc,
  3390. unsigned int pin, unsigned int reg, bool set)
  3391. {
  3392. unsigned int idx = pin % PINS_PER_GPIO_CHIP;
  3393. unsigned int offt = pin / PINS_PER_GPIO_CHIP;
  3394. if (set) {
  3395. if (is_soc_or_above(jzpc, ID_JZ4740))
  3396. regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
  3397. REG_SET(reg), BIT(idx));
  3398. else
  3399. regmap_set_bits(jzpc->map, offt * jzpc->info->reg_offset +
  3400. reg, BIT(idx));
  3401. } else {
  3402. if (is_soc_or_above(jzpc, ID_JZ4740))
  3403. regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
  3404. REG_CLEAR(reg), BIT(idx));
  3405. else
  3406. regmap_clear_bits(jzpc->map, offt * jzpc->info->reg_offset +
  3407. reg, BIT(idx));
  3408. }
  3409. }
  3410. static inline void ingenic_shadow_config_pin(struct ingenic_pinctrl *jzpc,
  3411. unsigned int pin, u8 reg, bool set)
  3412. {
  3413. unsigned int idx = pin % PINS_PER_GPIO_CHIP;
  3414. regmap_write(jzpc->map, REG_PZ_BASE(jzpc->info->reg_offset) +
  3415. (set ? REG_SET(reg) : REG_CLEAR(reg)), BIT(idx));
  3416. }
  3417. static inline void ingenic_shadow_config_pin_load(struct ingenic_pinctrl *jzpc,
  3418. unsigned int pin)
  3419. {
  3420. regmap_write(jzpc->map, REG_PZ_GID2LD(jzpc->info->reg_offset),
  3421. pin / PINS_PER_GPIO_CHIP);
  3422. }
  3423. static inline void jz4730_config_pin_function(struct ingenic_pinctrl *jzpc,
  3424. unsigned int pin, u8 reg_upper, u8 reg_lower, u8 value)
  3425. {
  3426. /*
  3427. * JZ4730 function and IRQ registers support two-bits-per-pin
  3428. * definitions, split into two groups of 16.
  3429. */
  3430. unsigned int idx = pin % JZ4730_PINS_PER_PAIRED_REG;
  3431. unsigned int mask = GENMASK(1, 0) << idx * 2;
  3432. unsigned int offt = pin / PINS_PER_GPIO_CHIP;
  3433. u8 reg = (pin % PINS_PER_GPIO_CHIP) < JZ4730_PINS_PER_PAIRED_REG ? reg_lower : reg_upper;
  3434. regmap_update_bits(jzpc->map, offt * jzpc->info->reg_offset + reg,
  3435. mask, value << (idx * 2));
  3436. }
  3437. static inline bool ingenic_get_pin_config(struct ingenic_pinctrl *jzpc,
  3438. unsigned int pin, unsigned int reg)
  3439. {
  3440. unsigned int idx = pin % PINS_PER_GPIO_CHIP;
  3441. unsigned int offt = pin / PINS_PER_GPIO_CHIP;
  3442. unsigned int val;
  3443. regmap_read(jzpc->map, offt * jzpc->info->reg_offset + reg, &val);
  3444. return val & BIT(idx);
  3445. }
  3446. static int ingenic_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
  3447. {
  3448. struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
  3449. struct ingenic_pinctrl *jzpc = jzgc->jzpc;
  3450. unsigned int pin = gc->base + offset;
  3451. if (is_soc_or_above(jzpc, ID_JZ4770)) {
  3452. if (ingenic_get_pin_config(jzpc, pin, JZ4770_GPIO_INT) ||
  3453. ingenic_get_pin_config(jzpc, pin, JZ4770_GPIO_PAT1))
  3454. return GPIO_LINE_DIRECTION_IN;
  3455. return GPIO_LINE_DIRECTION_OUT;
  3456. } else if (!is_soc_or_above(jzpc, ID_JZ4740)) {
  3457. if (!ingenic_get_pin_config(jzpc, pin, JZ4730_GPIO_GPDIR))
  3458. return GPIO_LINE_DIRECTION_IN;
  3459. return GPIO_LINE_DIRECTION_OUT;
  3460. }
  3461. if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_SELECT))
  3462. return GPIO_LINE_DIRECTION_IN;
  3463. if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_DIR))
  3464. return GPIO_LINE_DIRECTION_OUT;
  3465. return GPIO_LINE_DIRECTION_IN;
  3466. }
  3467. static const struct pinctrl_ops ingenic_pctlops = {
  3468. .get_groups_count = pinctrl_generic_get_group_count,
  3469. .get_group_name = pinctrl_generic_get_group_name,
  3470. .get_group_pins = pinctrl_generic_get_group_pins,
  3471. .dt_node_to_map = pinconf_generic_dt_node_to_map_all,
  3472. .dt_free_map = pinconf_generic_dt_free_map,
  3473. };
  3474. static int ingenic_gpio_irq_request(struct irq_data *data)
  3475. {
  3476. struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
  3477. irq_hw_number_t irq = irqd_to_hwirq(data);
  3478. int ret;
  3479. ret = ingenic_gpio_direction_input(gpio_chip, irq);
  3480. if (ret)
  3481. return ret;
  3482. return gpiochip_reqres_irq(gpio_chip, irq);
  3483. }
  3484. static void ingenic_gpio_irq_release(struct irq_data *data)
  3485. {
  3486. struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
  3487. irq_hw_number_t irq = irqd_to_hwirq(data);
  3488. return gpiochip_relres_irq(gpio_chip, irq);
  3489. }
  3490. static void ingenic_gpio_irq_print_chip(struct irq_data *data, struct seq_file *p)
  3491. {
  3492. struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
  3493. seq_printf(p, "%s", gpio_chip->label);
  3494. }
  3495. static const struct irq_chip ingenic_gpio_irqchip = {
  3496. .irq_enable = ingenic_gpio_irq_enable,
  3497. .irq_disable = ingenic_gpio_irq_disable,
  3498. .irq_unmask = ingenic_gpio_irq_unmask,
  3499. .irq_mask = ingenic_gpio_irq_mask,
  3500. .irq_ack = ingenic_gpio_irq_ack,
  3501. .irq_set_type = ingenic_gpio_irq_set_type,
  3502. .irq_set_wake = ingenic_gpio_irq_set_wake,
  3503. .irq_request_resources = ingenic_gpio_irq_request,
  3504. .irq_release_resources = ingenic_gpio_irq_release,
  3505. .irq_print_chip = ingenic_gpio_irq_print_chip,
  3506. .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_IMMUTABLE,
  3507. };
  3508. static int ingenic_pinmux_set_pin_fn(struct ingenic_pinctrl *jzpc,
  3509. int pin, int func)
  3510. {
  3511. unsigned int idx = pin % PINS_PER_GPIO_CHIP;
  3512. unsigned int offt = pin / PINS_PER_GPIO_CHIP;
  3513. dev_dbg(jzpc->dev, "set pin P%c%u to function %u\n",
  3514. 'A' + offt, idx, func);
  3515. if (is_soc_or_above(jzpc, ID_X1000)) {
  3516. ingenic_shadow_config_pin(jzpc, pin, JZ4770_GPIO_INT, false);
  3517. ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, false);
  3518. ingenic_shadow_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, func & 0x2);
  3519. ingenic_shadow_config_pin(jzpc, pin, JZ4770_GPIO_PAT0, func & 0x1);
  3520. ingenic_shadow_config_pin_load(jzpc, pin);
  3521. } else if (is_soc_or_above(jzpc, ID_JZ4770)) {
  3522. ingenic_config_pin(jzpc, pin, JZ4770_GPIO_INT, false);
  3523. ingenic_config_pin(jzpc, pin, GPIO_MSK, false);
  3524. ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, func & 0x2);
  3525. ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT0, func & 0x1);
  3526. } else if (is_soc_or_above(jzpc, ID_JZ4740)) {
  3527. ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, true);
  3528. ingenic_config_pin(jzpc, pin, JZ4740_GPIO_TRIG, func & 0x2);
  3529. ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, func & 0x1);
  3530. } else {
  3531. ingenic_config_pin(jzpc, pin, JZ4730_GPIO_GPIER, false);
  3532. jz4730_config_pin_function(jzpc, pin, JZ4730_GPIO_GPAUR, JZ4730_GPIO_GPALR, func);
  3533. }
  3534. return 0;
  3535. }
  3536. static int ingenic_pinmux_set_mux(struct pinctrl_dev *pctldev,
  3537. unsigned int selector, unsigned int group)
  3538. {
  3539. struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
  3540. struct function_desc *func;
  3541. struct group_desc *grp;
  3542. unsigned int i;
  3543. uintptr_t mode;
  3544. u8 *pin_modes;
  3545. func = pinmux_generic_get_function(pctldev, selector);
  3546. if (!func)
  3547. return -EINVAL;
  3548. grp = pinctrl_generic_get_group(pctldev, group);
  3549. if (!grp)
  3550. return -EINVAL;
  3551. dev_dbg(pctldev->dev, "enable function %s group %s\n",
  3552. func->name, grp->name);
  3553. mode = (uintptr_t)grp->data;
  3554. if (mode <= 3) {
  3555. for (i = 0; i < grp->num_pins; i++)
  3556. ingenic_pinmux_set_pin_fn(jzpc, grp->pins[i], mode);
  3557. } else {
  3558. pin_modes = grp->data;
  3559. for (i = 0; i < grp->num_pins; i++)
  3560. ingenic_pinmux_set_pin_fn(jzpc, grp->pins[i], pin_modes[i]);
  3561. }
  3562. return 0;
  3563. }
  3564. static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
  3565. struct pinctrl_gpio_range *range,
  3566. unsigned int pin, bool input)
  3567. {
  3568. struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
  3569. unsigned int idx = pin % PINS_PER_GPIO_CHIP;
  3570. unsigned int offt = pin / PINS_PER_GPIO_CHIP;
  3571. dev_dbg(pctldev->dev, "set pin P%c%u to %sput\n",
  3572. 'A' + offt, idx, input ? "in" : "out");
  3573. if (is_soc_or_above(jzpc, ID_X1000)) {
  3574. ingenic_shadow_config_pin(jzpc, pin, JZ4770_GPIO_INT, false);
  3575. ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, true);
  3576. ingenic_shadow_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, input);
  3577. ingenic_shadow_config_pin_load(jzpc, pin);
  3578. } else if (is_soc_or_above(jzpc, ID_JZ4770)) {
  3579. ingenic_config_pin(jzpc, pin, JZ4770_GPIO_INT, false);
  3580. ingenic_config_pin(jzpc, pin, GPIO_MSK, true);
  3581. ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, input);
  3582. } else if (is_soc_or_above(jzpc, ID_JZ4740)) {
  3583. ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, false);
  3584. ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, !input);
  3585. ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, false);
  3586. } else {
  3587. ingenic_config_pin(jzpc, pin, JZ4730_GPIO_GPIER, false);
  3588. ingenic_config_pin(jzpc, pin, JZ4730_GPIO_GPDIR, !input);
  3589. jz4730_config_pin_function(jzpc, pin, JZ4730_GPIO_GPAUR, JZ4730_GPIO_GPALR, 0);
  3590. }
  3591. return 0;
  3592. }
  3593. static const struct pinmux_ops ingenic_pmxops = {
  3594. .get_functions_count = pinmux_generic_get_function_count,
  3595. .get_function_name = pinmux_generic_get_function_name,
  3596. .get_function_groups = pinmux_generic_get_function_groups,
  3597. .set_mux = ingenic_pinmux_set_mux,
  3598. .gpio_set_direction = ingenic_pinmux_gpio_set_direction,
  3599. };
  3600. static int ingenic_pinconf_get(struct pinctrl_dev *pctldev,
  3601. unsigned int pin, unsigned long *config)
  3602. {
  3603. struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
  3604. enum pin_config_param param = pinconf_to_config_param(*config);
  3605. unsigned int idx = pin % PINS_PER_GPIO_CHIP;
  3606. unsigned int offt = pin / PINS_PER_GPIO_CHIP;
  3607. unsigned int arg = 1;
  3608. unsigned int bias, reg;
  3609. bool pull, pullup, pulldown;
  3610. if (is_soc_or_above(jzpc, ID_X2000)) {
  3611. pullup = ingenic_get_pin_config(jzpc, pin, X2000_GPIO_PEPU) &&
  3612. !ingenic_get_pin_config(jzpc, pin, X2000_GPIO_PEPD) &&
  3613. (jzpc->info->pull_ups[offt] & BIT(idx));
  3614. pulldown = ingenic_get_pin_config(jzpc, pin, X2000_GPIO_PEPD) &&
  3615. !ingenic_get_pin_config(jzpc, pin, X2000_GPIO_PEPU) &&
  3616. (jzpc->info->pull_downs[offt] & BIT(idx));
  3617. } else if (is_soc_or_above(jzpc, ID_X1830)) {
  3618. unsigned int half = PINS_PER_GPIO_CHIP / 2;
  3619. unsigned int idxh = (pin % half) * 2;
  3620. if (idx < half)
  3621. regmap_read(jzpc->map, offt * jzpc->info->reg_offset +
  3622. X1830_GPIO_PEL, &bias);
  3623. else
  3624. regmap_read(jzpc->map, offt * jzpc->info->reg_offset +
  3625. X1830_GPIO_PEH, &bias);
  3626. bias = (bias >> idxh) & (GPIO_PULL_UP | GPIO_PULL_DOWN);
  3627. pullup = (bias == GPIO_PULL_UP) && (jzpc->info->pull_ups[offt] & BIT(idx));
  3628. pulldown = (bias == GPIO_PULL_DOWN) && (jzpc->info->pull_downs[offt] & BIT(idx));
  3629. } else {
  3630. if (is_soc_or_above(jzpc, ID_JZ4770))
  3631. pull = !ingenic_get_pin_config(jzpc, pin, JZ4770_GPIO_PEN);
  3632. else if (is_soc_or_above(jzpc, ID_JZ4740))
  3633. pull = !ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_PULL_DIS);
  3634. else
  3635. pull = ingenic_get_pin_config(jzpc, pin, JZ4730_GPIO_GPPUR);
  3636. pullup = pull && (jzpc->info->pull_ups[offt] & BIT(idx));
  3637. pulldown = pull && (jzpc->info->pull_downs[offt] & BIT(idx));
  3638. }
  3639. switch (param) {
  3640. case PIN_CONFIG_BIAS_DISABLE:
  3641. if (pullup || pulldown)
  3642. return -EINVAL;
  3643. break;
  3644. case PIN_CONFIG_BIAS_PULL_UP:
  3645. if (!pullup)
  3646. return -EINVAL;
  3647. break;
  3648. case PIN_CONFIG_BIAS_PULL_DOWN:
  3649. if (!pulldown)
  3650. return -EINVAL;
  3651. break;
  3652. case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
  3653. if (is_soc_or_above(jzpc, ID_X2000))
  3654. reg = X2000_GPIO_SMT;
  3655. else if (is_soc_or_above(jzpc, ID_X1830))
  3656. reg = X1830_GPIO_SMT;
  3657. else
  3658. return -EINVAL;
  3659. arg = !!ingenic_get_pin_config(jzpc, pin, reg);
  3660. break;
  3661. case PIN_CONFIG_SLEW_RATE:
  3662. if (is_soc_or_above(jzpc, ID_X2000))
  3663. reg = X2000_GPIO_SR;
  3664. else if (is_soc_or_above(jzpc, ID_X1830))
  3665. reg = X1830_GPIO_SR;
  3666. else
  3667. return -EINVAL;
  3668. arg = !!ingenic_get_pin_config(jzpc, pin, reg);
  3669. break;
  3670. default:
  3671. return -ENOTSUPP;
  3672. }
  3673. *config = pinconf_to_config_packed(param, arg);
  3674. return 0;
  3675. }
  3676. static void ingenic_set_bias(struct ingenic_pinctrl *jzpc,
  3677. unsigned int pin, unsigned int bias)
  3678. {
  3679. if (is_soc_or_above(jzpc, ID_X2000)) {
  3680. switch (bias) {
  3681. case GPIO_PULL_UP:
  3682. ingenic_config_pin(jzpc, pin, X2000_GPIO_PEPD, false);
  3683. ingenic_config_pin(jzpc, pin, X2000_GPIO_PEPU, true);
  3684. break;
  3685. case GPIO_PULL_DOWN:
  3686. ingenic_config_pin(jzpc, pin, X2000_GPIO_PEPU, false);
  3687. ingenic_config_pin(jzpc, pin, X2000_GPIO_PEPD, true);
  3688. break;
  3689. case GPIO_PULL_DIS:
  3690. default:
  3691. ingenic_config_pin(jzpc, pin, X2000_GPIO_PEPU, false);
  3692. ingenic_config_pin(jzpc, pin, X2000_GPIO_PEPD, false);
  3693. }
  3694. } else if (is_soc_or_above(jzpc, ID_X1830)) {
  3695. unsigned int idx = pin % PINS_PER_GPIO_CHIP;
  3696. unsigned int half = PINS_PER_GPIO_CHIP / 2;
  3697. unsigned int idxh = (pin % half) * 2;
  3698. unsigned int offt = pin / PINS_PER_GPIO_CHIP;
  3699. if (idx < half) {
  3700. regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
  3701. REG_CLEAR(X1830_GPIO_PEL), 3 << idxh);
  3702. regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
  3703. REG_SET(X1830_GPIO_PEL), bias << idxh);
  3704. } else {
  3705. regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
  3706. REG_CLEAR(X1830_GPIO_PEH), 3 << idxh);
  3707. regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
  3708. REG_SET(X1830_GPIO_PEH), bias << idxh);
  3709. }
  3710. } else if (is_soc_or_above(jzpc, ID_JZ4770)) {
  3711. ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PEN, !bias);
  3712. } else if (is_soc_or_above(jzpc, ID_JZ4740)) {
  3713. ingenic_config_pin(jzpc, pin, JZ4740_GPIO_PULL_DIS, !bias);
  3714. } else {
  3715. ingenic_config_pin(jzpc, pin, JZ4730_GPIO_GPPUR, bias);
  3716. }
  3717. }
  3718. static void ingenic_set_schmitt_trigger(struct ingenic_pinctrl *jzpc,
  3719. unsigned int pin, bool enable)
  3720. {
  3721. if (is_soc_or_above(jzpc, ID_X2000))
  3722. ingenic_config_pin(jzpc, pin, X2000_GPIO_SMT, enable);
  3723. else
  3724. ingenic_config_pin(jzpc, pin, X1830_GPIO_SMT, enable);
  3725. }
  3726. static void ingenic_set_output_level(struct ingenic_pinctrl *jzpc,
  3727. unsigned int pin, bool high)
  3728. {
  3729. if (is_soc_or_above(jzpc, ID_JZ4770))
  3730. ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT0, high);
  3731. else if (is_soc_or_above(jzpc, ID_JZ4740))
  3732. ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DATA, high);
  3733. else
  3734. ingenic_config_pin(jzpc, pin, JZ4730_GPIO_DATA, high);
  3735. }
  3736. static void ingenic_set_slew_rate(struct ingenic_pinctrl *jzpc,
  3737. unsigned int pin, unsigned int slew)
  3738. {
  3739. if (is_soc_or_above(jzpc, ID_X2000))
  3740. ingenic_config_pin(jzpc, pin, X2000_GPIO_SR, slew);
  3741. else
  3742. ingenic_config_pin(jzpc, pin, X1830_GPIO_SR, slew);
  3743. }
  3744. static int ingenic_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
  3745. unsigned long *configs, unsigned int num_configs)
  3746. {
  3747. struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
  3748. unsigned int idx = pin % PINS_PER_GPIO_CHIP;
  3749. unsigned int offt = pin / PINS_PER_GPIO_CHIP;
  3750. unsigned int cfg, arg;
  3751. int ret;
  3752. for (cfg = 0; cfg < num_configs; cfg++) {
  3753. switch (pinconf_to_config_param(configs[cfg])) {
  3754. case PIN_CONFIG_BIAS_DISABLE:
  3755. case PIN_CONFIG_BIAS_PULL_UP:
  3756. case PIN_CONFIG_BIAS_PULL_DOWN:
  3757. case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
  3758. case PIN_CONFIG_OUTPUT:
  3759. case PIN_CONFIG_SLEW_RATE:
  3760. continue;
  3761. default:
  3762. return -ENOTSUPP;
  3763. }
  3764. }
  3765. for (cfg = 0; cfg < num_configs; cfg++) {
  3766. arg = pinconf_to_config_argument(configs[cfg]);
  3767. switch (pinconf_to_config_param(configs[cfg])) {
  3768. case PIN_CONFIG_BIAS_DISABLE:
  3769. dev_dbg(jzpc->dev, "disable pull-over for pin P%c%u\n",
  3770. 'A' + offt, idx);
  3771. ingenic_set_bias(jzpc, pin, GPIO_PULL_DIS);
  3772. break;
  3773. case PIN_CONFIG_BIAS_PULL_UP:
  3774. if (!(jzpc->info->pull_ups[offt] & BIT(idx)))
  3775. return -EINVAL;
  3776. dev_dbg(jzpc->dev, "set pull-up for pin P%c%u\n",
  3777. 'A' + offt, idx);
  3778. ingenic_set_bias(jzpc, pin, GPIO_PULL_UP);
  3779. break;
  3780. case PIN_CONFIG_BIAS_PULL_DOWN:
  3781. if (!(jzpc->info->pull_downs[offt] & BIT(idx)))
  3782. return -EINVAL;
  3783. dev_dbg(jzpc->dev, "set pull-down for pin P%c%u\n",
  3784. 'A' + offt, idx);
  3785. ingenic_set_bias(jzpc, pin, GPIO_PULL_DOWN);
  3786. break;
  3787. case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
  3788. if (!is_soc_or_above(jzpc, ID_X1830))
  3789. return -EINVAL;
  3790. ingenic_set_schmitt_trigger(jzpc, pin, arg);
  3791. break;
  3792. case PIN_CONFIG_OUTPUT:
  3793. ret = pinctrl_gpio_direction_output(pin);
  3794. if (ret)
  3795. return ret;
  3796. ingenic_set_output_level(jzpc, pin, arg);
  3797. break;
  3798. case PIN_CONFIG_SLEW_RATE:
  3799. if (!is_soc_or_above(jzpc, ID_X1830))
  3800. return -EINVAL;
  3801. ingenic_set_slew_rate(jzpc, pin, arg);
  3802. break;
  3803. default:
  3804. /* unreachable */
  3805. break;
  3806. }
  3807. }
  3808. return 0;
  3809. }
  3810. static int ingenic_pinconf_group_get(struct pinctrl_dev *pctldev,
  3811. unsigned int group, unsigned long *config)
  3812. {
  3813. const unsigned int *pins;
  3814. unsigned int i, npins, old = 0;
  3815. int ret;
  3816. ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
  3817. if (ret)
  3818. return ret;
  3819. for (i = 0; i < npins; i++) {
  3820. if (ingenic_pinconf_get(pctldev, pins[i], config))
  3821. return -ENOTSUPP;
  3822. /* configs do not match between two pins */
  3823. if (i && (old != *config))
  3824. return -ENOTSUPP;
  3825. old = *config;
  3826. }
  3827. return 0;
  3828. }
  3829. static int ingenic_pinconf_group_set(struct pinctrl_dev *pctldev,
  3830. unsigned int group, unsigned long *configs,
  3831. unsigned int num_configs)
  3832. {
  3833. const unsigned int *pins;
  3834. unsigned int i, npins;
  3835. int ret;
  3836. ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
  3837. if (ret)
  3838. return ret;
  3839. for (i = 0; i < npins; i++) {
  3840. ret = ingenic_pinconf_set(pctldev,
  3841. pins[i], configs, num_configs);
  3842. if (ret)
  3843. return ret;
  3844. }
  3845. return 0;
  3846. }
  3847. static const struct pinconf_ops ingenic_confops = {
  3848. .is_generic = true,
  3849. .pin_config_get = ingenic_pinconf_get,
  3850. .pin_config_set = ingenic_pinconf_set,
  3851. .pin_config_group_get = ingenic_pinconf_group_get,
  3852. .pin_config_group_set = ingenic_pinconf_group_set,
  3853. };
  3854. static const struct regmap_config ingenic_pinctrl_regmap_config = {
  3855. .reg_bits = 32,
  3856. .val_bits = 32,
  3857. .reg_stride = 4,
  3858. };
  3859. static const struct of_device_id ingenic_gpio_of_matches[] __initconst = {
  3860. { .compatible = "ingenic,jz4730-gpio" },
  3861. { .compatible = "ingenic,jz4740-gpio" },
  3862. { .compatible = "ingenic,jz4725b-gpio" },
  3863. { .compatible = "ingenic,jz4750-gpio" },
  3864. { .compatible = "ingenic,jz4755-gpio" },
  3865. { .compatible = "ingenic,jz4760-gpio" },
  3866. { .compatible = "ingenic,jz4770-gpio" },
  3867. { .compatible = "ingenic,jz4775-gpio" },
  3868. { .compatible = "ingenic,jz4780-gpio" },
  3869. { .compatible = "ingenic,x1000-gpio" },
  3870. { .compatible = "ingenic,x1830-gpio" },
  3871. { .compatible = "ingenic,x2000-gpio" },
  3872. { .compatible = "ingenic,x2100-gpio" },
  3873. {},
  3874. };
  3875. static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,
  3876. struct fwnode_handle *fwnode)
  3877. {
  3878. struct ingenic_gpio_chip *jzgc;
  3879. struct device *dev = jzpc->dev;
  3880. struct gpio_irq_chip *girq;
  3881. unsigned int bank;
  3882. int err;
  3883. err = fwnode_property_read_u32(fwnode, "reg", &bank);
  3884. if (err) {
  3885. dev_err(dev, "Cannot read \"reg\" property: %i\n", err);
  3886. return err;
  3887. }
  3888. jzgc = devm_kzalloc(dev, sizeof(*jzgc), GFP_KERNEL);
  3889. if (!jzgc)
  3890. return -ENOMEM;
  3891. jzgc->jzpc = jzpc;
  3892. jzgc->reg_base = bank * jzpc->info->reg_offset;
  3893. jzgc->gc.label = devm_kasprintf(dev, GFP_KERNEL, "GPIO%c", 'A' + bank);
  3894. if (!jzgc->gc.label)
  3895. return -ENOMEM;
  3896. /* DO NOT EXPAND THIS: FOR BACKWARD GPIO NUMBERSPACE COMPATIBIBILITY
  3897. * ONLY: WORK TO TRANSITION CONSUMERS TO USE THE GPIO DESCRIPTOR API IN
  3898. * <linux/gpio/consumer.h> INSTEAD.
  3899. */
  3900. jzgc->gc.base = bank * 32;
  3901. jzgc->gc.ngpio = 32;
  3902. jzgc->gc.parent = dev;
  3903. jzgc->gc.fwnode = fwnode;
  3904. jzgc->gc.owner = THIS_MODULE;
  3905. jzgc->gc.set = ingenic_gpio_set;
  3906. jzgc->gc.get = ingenic_gpio_get;
  3907. jzgc->gc.direction_input = ingenic_gpio_direction_input;
  3908. jzgc->gc.direction_output = ingenic_gpio_direction_output;
  3909. jzgc->gc.get_direction = ingenic_gpio_get_direction;
  3910. jzgc->gc.request = gpiochip_generic_request;
  3911. jzgc->gc.free = gpiochip_generic_free;
  3912. err = fwnode_irq_get(fwnode, 0);
  3913. if (err < 0)
  3914. return err;
  3915. if (!err)
  3916. return -EINVAL;
  3917. jzgc->irq = err;
  3918. girq = &jzgc->gc.irq;
  3919. gpio_irq_chip_set_chip(girq, &ingenic_gpio_irqchip);
  3920. girq->parent_handler = ingenic_gpio_irq_handler;
  3921. girq->num_parents = 1;
  3922. girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
  3923. GFP_KERNEL);
  3924. if (!girq->parents)
  3925. return -ENOMEM;
  3926. girq->parents[0] = jzgc->irq;
  3927. girq->default_type = IRQ_TYPE_NONE;
  3928. girq->handler = handle_level_irq;
  3929. err = devm_gpiochip_add_data(dev, &jzgc->gc, jzgc);
  3930. if (err)
  3931. return err;
  3932. return 0;
  3933. }
  3934. static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
  3935. {
  3936. struct device *dev = &pdev->dev;
  3937. struct ingenic_pinctrl *jzpc;
  3938. struct pinctrl_desc *pctl_desc;
  3939. void __iomem *base;
  3940. const struct ingenic_chip_info *chip_info;
  3941. struct regmap_config regmap_config;
  3942. struct fwnode_handle *fwnode;
  3943. unsigned int i;
  3944. int err;
  3945. chip_info = device_get_match_data(dev);
  3946. if (!chip_info) {
  3947. dev_err(dev, "Unsupported SoC\n");
  3948. return -EINVAL;
  3949. }
  3950. jzpc = devm_kzalloc(dev, sizeof(*jzpc), GFP_KERNEL);
  3951. if (!jzpc)
  3952. return -ENOMEM;
  3953. base = devm_platform_ioremap_resource(pdev, 0);
  3954. if (IS_ERR(base))
  3955. return PTR_ERR(base);
  3956. regmap_config = ingenic_pinctrl_regmap_config;
  3957. if (chip_info->access_table) {
  3958. regmap_config.rd_table = chip_info->access_table;
  3959. regmap_config.wr_table = chip_info->access_table;
  3960. } else {
  3961. regmap_config.max_register = chip_info->num_chips * chip_info->reg_offset - 4;
  3962. }
  3963. jzpc->map = devm_regmap_init_mmio(dev, base, &regmap_config);
  3964. if (IS_ERR(jzpc->map)) {
  3965. dev_err(dev, "Failed to create regmap\n");
  3966. return PTR_ERR(jzpc->map);
  3967. }
  3968. jzpc->dev = dev;
  3969. jzpc->info = chip_info;
  3970. pctl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctl_desc), GFP_KERNEL);
  3971. if (!pctl_desc)
  3972. return -ENOMEM;
  3973. /* fill in pinctrl_desc structure */
  3974. pctl_desc->name = dev_name(dev);
  3975. pctl_desc->owner = THIS_MODULE;
  3976. pctl_desc->pctlops = &ingenic_pctlops;
  3977. pctl_desc->pmxops = &ingenic_pmxops;
  3978. pctl_desc->confops = &ingenic_confops;
  3979. pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP;
  3980. pctl_desc->pins = jzpc->pdesc = devm_kcalloc(&pdev->dev,
  3981. pctl_desc->npins, sizeof(*jzpc->pdesc), GFP_KERNEL);
  3982. if (!jzpc->pdesc)
  3983. return -ENOMEM;
  3984. for (i = 0; i < pctl_desc->npins; i++) {
  3985. jzpc->pdesc[i].number = i;
  3986. jzpc->pdesc[i].name = kasprintf(GFP_KERNEL, "P%c%d",
  3987. 'A' + (i / PINS_PER_GPIO_CHIP),
  3988. i % PINS_PER_GPIO_CHIP);
  3989. }
  3990. jzpc->pctl = devm_pinctrl_register(dev, pctl_desc, jzpc);
  3991. if (IS_ERR(jzpc->pctl)) {
  3992. dev_err(dev, "Failed to register pinctrl\n");
  3993. return PTR_ERR(jzpc->pctl);
  3994. }
  3995. for (i = 0; i < chip_info->num_groups; i++) {
  3996. const struct group_desc *group = &chip_info->groups[i];
  3997. err = pinctrl_generic_add_group(jzpc->pctl, group->name,
  3998. group->pins, group->num_pins, group->data);
  3999. if (err < 0) {
  4000. dev_err(dev, "Failed to register group %s\n",
  4001. group->name);
  4002. return err;
  4003. }
  4004. }
  4005. for (i = 0; i < chip_info->num_functions; i++) {
  4006. const struct function_desc *func = &chip_info->functions[i];
  4007. err = pinmux_generic_add_function(jzpc->pctl, func->name,
  4008. func->group_names, func->num_group_names,
  4009. func->data);
  4010. if (err < 0) {
  4011. dev_err(dev, "Failed to register function %s\n",
  4012. func->name);
  4013. return err;
  4014. }
  4015. }
  4016. dev_set_drvdata(dev, jzpc->map);
  4017. device_for_each_child_node(dev, fwnode) {
  4018. if (of_match_node(ingenic_gpio_of_matches, to_of_node(fwnode))) {
  4019. err = ingenic_gpio_probe(jzpc, fwnode);
  4020. if (err) {
  4021. fwnode_handle_put(fwnode);
  4022. return err;
  4023. }
  4024. }
  4025. }
  4026. return 0;
  4027. }
  4028. #define IF_ENABLED(cfg, ptr) PTR_IF(IS_ENABLED(cfg), (ptr))
  4029. static const struct of_device_id ingenic_pinctrl_of_matches[] = {
  4030. {
  4031. .compatible = "ingenic,jz4730-pinctrl",
  4032. .data = IF_ENABLED(CONFIG_MACH_JZ4730, &jz4730_chip_info)
  4033. },
  4034. {
  4035. .compatible = "ingenic,jz4740-pinctrl",
  4036. .data = IF_ENABLED(CONFIG_MACH_JZ4740, &jz4740_chip_info)
  4037. },
  4038. {
  4039. .compatible = "ingenic,jz4725b-pinctrl",
  4040. .data = IF_ENABLED(CONFIG_MACH_JZ4725B, &jz4725b_chip_info)
  4041. },
  4042. {
  4043. .compatible = "ingenic,jz4750-pinctrl",
  4044. .data = IF_ENABLED(CONFIG_MACH_JZ4750, &jz4750_chip_info)
  4045. },
  4046. {
  4047. .compatible = "ingenic,jz4755-pinctrl",
  4048. .data = IF_ENABLED(CONFIG_MACH_JZ4755, &jz4755_chip_info)
  4049. },
  4050. {
  4051. .compatible = "ingenic,jz4760-pinctrl",
  4052. .data = IF_ENABLED(CONFIG_MACH_JZ4760, &jz4760_chip_info)
  4053. },
  4054. {
  4055. .compatible = "ingenic,jz4760b-pinctrl",
  4056. .data = IF_ENABLED(CONFIG_MACH_JZ4760, &jz4760_chip_info)
  4057. },
  4058. {
  4059. .compatible = "ingenic,jz4770-pinctrl",
  4060. .data = IF_ENABLED(CONFIG_MACH_JZ4770, &jz4770_chip_info)
  4061. },
  4062. {
  4063. .compatible = "ingenic,jz4775-pinctrl",
  4064. .data = IF_ENABLED(CONFIG_MACH_JZ4775, &jz4775_chip_info)
  4065. },
  4066. {
  4067. .compatible = "ingenic,jz4780-pinctrl",
  4068. .data = IF_ENABLED(CONFIG_MACH_JZ4780, &jz4780_chip_info)
  4069. },
  4070. {
  4071. .compatible = "ingenic,x1000-pinctrl",
  4072. .data = IF_ENABLED(CONFIG_MACH_X1000, &x1000_chip_info)
  4073. },
  4074. {
  4075. .compatible = "ingenic,x1000e-pinctrl",
  4076. .data = IF_ENABLED(CONFIG_MACH_X1000, &x1000_chip_info)
  4077. },
  4078. {
  4079. .compatible = "ingenic,x1500-pinctrl",
  4080. .data = IF_ENABLED(CONFIG_MACH_X1500, &x1500_chip_info)
  4081. },
  4082. {
  4083. .compatible = "ingenic,x1830-pinctrl",
  4084. .data = IF_ENABLED(CONFIG_MACH_X1830, &x1830_chip_info)
  4085. },
  4086. {
  4087. .compatible = "ingenic,x2000-pinctrl",
  4088. .data = IF_ENABLED(CONFIG_MACH_X2000, &x2000_chip_info)
  4089. },
  4090. {
  4091. .compatible = "ingenic,x2000e-pinctrl",
  4092. .data = IF_ENABLED(CONFIG_MACH_X2000, &x2000_chip_info)
  4093. },
  4094. {
  4095. .compatible = "ingenic,x2100-pinctrl",
  4096. .data = IF_ENABLED(CONFIG_MACH_X2100, &x2100_chip_info)
  4097. },
  4098. { /* sentinel */ },
  4099. };
  4100. static struct platform_driver ingenic_pinctrl_driver = {
  4101. .driver = {
  4102. .name = "pinctrl-ingenic",
  4103. .of_match_table = ingenic_pinctrl_of_matches,
  4104. },
  4105. };
  4106. static int __init ingenic_pinctrl_drv_register(void)
  4107. {
  4108. return platform_driver_probe(&ingenic_pinctrl_driver,
  4109. ingenic_pinctrl_probe);
  4110. }
  4111. subsys_initcall(ingenic_pinctrl_drv_register);