pinctrl-sunxi.c 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187
  1. /*
  2. * Allwinner A1X SoCs pinctrl driver.
  3. *
  4. * Copyright (C) 2012 Maxime Ripard
  5. *
  6. * Maxime Ripard <maxime.ripard@free-electrons.com>
  7. *
  8. * This file is licensed under the terms of the GNU General Public
  9. * License version 2. This program is licensed "as is" without any
  10. * warranty of any kind, whether express or implied.
  11. */
  12. #include <linux/io.h>
  13. #include <linux/clk.h>
  14. #include <linux/gpio.h>
  15. #include <linux/irqdomain.h>
  16. #include <linux/module.h>
  17. #include <linux/of.h>
  18. #include <linux/of_address.h>
  19. #include <linux/of_device.h>
  20. #include <linux/of_irq.h>
  21. #include <linux/pinctrl/consumer.h>
  22. #include <linux/pinctrl/machine.h>
  23. #include <linux/pinctrl/pinctrl.h>
  24. #include <linux/pinctrl/pinconf-generic.h>
  25. #include <linux/pinctrl/pinmux.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/slab.h>
  28. #include "core.h"
  29. #include "pinctrl-sunxi.h"
  30. static const struct sunxi_desc_pin sun4i_a10_pins[] = {
  31. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA0,
  32. SUNXI_FUNCTION(0x0, "gpio_in"),
  33. SUNXI_FUNCTION(0x1, "gpio_out"),
  34. SUNXI_FUNCTION(0x2, "emac"), /* ERXD3 */
  35. SUNXI_FUNCTION(0x3, "spi1"), /* CS0 */
  36. SUNXI_FUNCTION(0x4, "uart2")), /* RTS */
  37. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA1,
  38. SUNXI_FUNCTION(0x0, "gpio_in"),
  39. SUNXI_FUNCTION(0x1, "gpio_out"),
  40. SUNXI_FUNCTION(0x2, "emac"), /* ERXD2 */
  41. SUNXI_FUNCTION(0x3, "spi1"), /* CLK */
  42. SUNXI_FUNCTION(0x4, "uart2")), /* CTS */
  43. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA2,
  44. SUNXI_FUNCTION(0x0, "gpio_in"),
  45. SUNXI_FUNCTION(0x1, "gpio_out"),
  46. SUNXI_FUNCTION(0x2, "emac"), /* ERXD1 */
  47. SUNXI_FUNCTION(0x3, "spi1"), /* MOSI */
  48. SUNXI_FUNCTION(0x4, "uart2")), /* TX */
  49. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA3,
  50. SUNXI_FUNCTION(0x0, "gpio_in"),
  51. SUNXI_FUNCTION(0x1, "gpio_out"),
  52. SUNXI_FUNCTION(0x2, "emac"), /* ERXD0 */
  53. SUNXI_FUNCTION(0x3, "spi1"), /* MISO */
  54. SUNXI_FUNCTION(0x4, "uart2")), /* RX */
  55. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA4,
  56. SUNXI_FUNCTION(0x0, "gpio_in"),
  57. SUNXI_FUNCTION(0x1, "gpio_out"),
  58. SUNXI_FUNCTION(0x2, "emac"), /* ETXD3 */
  59. SUNXI_FUNCTION(0x3, "spi1")), /* CS1 */
  60. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA5,
  61. SUNXI_FUNCTION(0x0, "gpio_in"),
  62. SUNXI_FUNCTION(0x1, "gpio_out"),
  63. SUNXI_FUNCTION(0x2, "emac"), /* ETXD2 */
  64. SUNXI_FUNCTION(0x3, "spi3")), /* CS0 */
  65. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA6,
  66. SUNXI_FUNCTION(0x0, "gpio_in"),
  67. SUNXI_FUNCTION(0x1, "gpio_out"),
  68. SUNXI_FUNCTION(0x2, "emac"), /* ETXD1 */
  69. SUNXI_FUNCTION(0x3, "spi3")), /* CLK */
  70. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA7,
  71. SUNXI_FUNCTION(0x0, "gpio_in"),
  72. SUNXI_FUNCTION(0x1, "gpio_out"),
  73. SUNXI_FUNCTION(0x2, "emac"), /* ETXD0 */
  74. SUNXI_FUNCTION(0x3, "spi3")), /* MOSI */
  75. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA8,
  76. SUNXI_FUNCTION(0x0, "gpio_in"),
  77. SUNXI_FUNCTION(0x1, "gpio_out"),
  78. SUNXI_FUNCTION(0x2, "emac"), /* ERXCK */
  79. SUNXI_FUNCTION(0x3, "spi3")), /* MISO */
  80. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA9,
  81. SUNXI_FUNCTION(0x0, "gpio_in"),
  82. SUNXI_FUNCTION(0x1, "gpio_out"),
  83. SUNXI_FUNCTION(0x2, "emac"), /* ERXERR */
  84. SUNXI_FUNCTION(0x3, "spi3")), /* CS1 */
  85. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA10,
  86. SUNXI_FUNCTION(0x0, "gpio_in"),
  87. SUNXI_FUNCTION(0x1, "gpio_out"),
  88. SUNXI_FUNCTION(0x2, "emac"), /* ERXDV */
  89. SUNXI_FUNCTION(0x4, "uart1")), /* TX */
  90. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA11,
  91. SUNXI_FUNCTION(0x0, "gpio_in"),
  92. SUNXI_FUNCTION(0x1, "gpio_out"),
  93. SUNXI_FUNCTION(0x2, "emac"), /* EMDC */
  94. SUNXI_FUNCTION(0x4, "uart1")), /* RX */
  95. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA12,
  96. SUNXI_FUNCTION(0x0, "gpio_in"),
  97. SUNXI_FUNCTION(0x1, "gpio_out"),
  98. SUNXI_FUNCTION(0x2, "emac"), /* EMDIO */
  99. SUNXI_FUNCTION(0x3, "uart6"), /* TX */
  100. SUNXI_FUNCTION(0x4, "uart1")), /* RTS */
  101. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA13,
  102. SUNXI_FUNCTION(0x0, "gpio_in"),
  103. SUNXI_FUNCTION(0x1, "gpio_out"),
  104. SUNXI_FUNCTION(0x2, "emac"), /* ETXEN */
  105. SUNXI_FUNCTION(0x3, "uart6"), /* RX */
  106. SUNXI_FUNCTION(0x4, "uart1")), /* CTS */
  107. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA14,
  108. SUNXI_FUNCTION(0x0, "gpio_in"),
  109. SUNXI_FUNCTION(0x1, "gpio_out"),
  110. SUNXI_FUNCTION(0x2, "emac"), /* ETXCK */
  111. SUNXI_FUNCTION(0x3, "uart7"), /* TX */
  112. SUNXI_FUNCTION(0x4, "uart1")), /* DTR */
  113. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA15,
  114. SUNXI_FUNCTION(0x0, "gpio_in"),
  115. SUNXI_FUNCTION(0x1, "gpio_out"),
  116. SUNXI_FUNCTION(0x2, "emac"), /* ECRS */
  117. SUNXI_FUNCTION(0x3, "uart7"), /* RX */
  118. SUNXI_FUNCTION(0x4, "uart1")), /* DSR */
  119. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA16,
  120. SUNXI_FUNCTION(0x0, "gpio_in"),
  121. SUNXI_FUNCTION(0x1, "gpio_out"),
  122. SUNXI_FUNCTION(0x2, "emac"), /* ECOL */
  123. SUNXI_FUNCTION(0x3, "can"), /* TX */
  124. SUNXI_FUNCTION(0x4, "uart1")), /* DCD */
  125. SUNXI_PIN(SUNXI_PINCTRL_PIN_PA17,
  126. SUNXI_FUNCTION(0x0, "gpio_in"),
  127. SUNXI_FUNCTION(0x1, "gpio_out"),
  128. SUNXI_FUNCTION(0x2, "emac"), /* ETXERR */
  129. SUNXI_FUNCTION(0x3, "can"), /* RX */
  130. SUNXI_FUNCTION(0x4, "uart1")), /* RING */
  131. /* Hole */
  132. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB0,
  133. SUNXI_FUNCTION(0x0, "gpio_in"),
  134. SUNXI_FUNCTION(0x1, "gpio_out"),
  135. SUNXI_FUNCTION(0x2, "i2c0")), /* SCK */
  136. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB1,
  137. SUNXI_FUNCTION(0x0, "gpio_in"),
  138. SUNXI_FUNCTION(0x1, "gpio_out"),
  139. SUNXI_FUNCTION(0x2, "i2c0")), /* SDA */
  140. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB2,
  141. SUNXI_FUNCTION(0x0, "gpio_in"),
  142. SUNXI_FUNCTION(0x1, "gpio_out"),
  143. SUNXI_FUNCTION(0x2, "pwm")), /* PWM0 */
  144. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB3,
  145. SUNXI_FUNCTION(0x0, "gpio_in"),
  146. SUNXI_FUNCTION(0x1, "gpio_out"),
  147. SUNXI_FUNCTION(0x2, "ir0")), /* TX */
  148. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB4,
  149. SUNXI_FUNCTION(0x0, "gpio_in"),
  150. SUNXI_FUNCTION(0x1, "gpio_out"),
  151. SUNXI_FUNCTION(0x2, "ir0")), /* RX */
  152. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB5,
  153. SUNXI_FUNCTION(0x0, "gpio_in"),
  154. SUNXI_FUNCTION(0x1, "gpio_out"),
  155. SUNXI_FUNCTION(0x2, "i2s"), /* MCLK */
  156. SUNXI_FUNCTION(0x3, "ac97")), /* MCLK */
  157. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB6,
  158. SUNXI_FUNCTION(0x0, "gpio_in"),
  159. SUNXI_FUNCTION(0x1, "gpio_out"),
  160. SUNXI_FUNCTION(0x2, "i2s"), /* BCLK */
  161. SUNXI_FUNCTION(0x3, "ac97")), /* BCLK */
  162. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB7,
  163. SUNXI_FUNCTION(0x0, "gpio_in"),
  164. SUNXI_FUNCTION(0x1, "gpio_out"),
  165. SUNXI_FUNCTION(0x2, "i2s"), /* LRCK */
  166. SUNXI_FUNCTION(0x3, "ac97")), /* SYNC */
  167. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB8,
  168. SUNXI_FUNCTION(0x0, "gpio_in"),
  169. SUNXI_FUNCTION(0x1, "gpio_out"),
  170. SUNXI_FUNCTION(0x2, "i2s"), /* DO0 */
  171. SUNXI_FUNCTION(0x3, "ac97")), /* DO */
  172. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB9,
  173. SUNXI_FUNCTION(0x0, "gpio_in"),
  174. SUNXI_FUNCTION(0x1, "gpio_out"),
  175. SUNXI_FUNCTION(0x2, "i2s")), /* DO1 */
  176. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB10,
  177. SUNXI_FUNCTION(0x0, "gpio_in"),
  178. SUNXI_FUNCTION(0x1, "gpio_out"),
  179. SUNXI_FUNCTION(0x2, "i2s")), /* DO2 */
  180. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB11,
  181. SUNXI_FUNCTION(0x0, "gpio_in"),
  182. SUNXI_FUNCTION(0x1, "gpio_out"),
  183. SUNXI_FUNCTION(0x2, "i2s")), /* DO3 */
  184. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB12,
  185. SUNXI_FUNCTION(0x0, "gpio_in"),
  186. SUNXI_FUNCTION(0x1, "gpio_out"),
  187. SUNXI_FUNCTION(0x2, "i2s"), /* DI */
  188. SUNXI_FUNCTION(0x3, "ac97")), /* DI */
  189. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB13,
  190. SUNXI_FUNCTION(0x0, "gpio_in"),
  191. SUNXI_FUNCTION(0x1, "gpio_out"),
  192. SUNXI_FUNCTION(0x2, "spi2")), /* CS1 */
  193. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB14,
  194. SUNXI_FUNCTION(0x0, "gpio_in"),
  195. SUNXI_FUNCTION(0x1, "gpio_out"),
  196. SUNXI_FUNCTION(0x2, "spi2"), /* CS0 */
  197. SUNXI_FUNCTION(0x3, "jtag")), /* MS0 */
  198. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB15,
  199. SUNXI_FUNCTION(0x0, "gpio_in"),
  200. SUNXI_FUNCTION(0x1, "gpio_out"),
  201. SUNXI_FUNCTION(0x2, "spi2"), /* CLK */
  202. SUNXI_FUNCTION(0x3, "jtag")), /* CK0 */
  203. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB16,
  204. SUNXI_FUNCTION(0x0, "gpio_in"),
  205. SUNXI_FUNCTION(0x1, "gpio_out"),
  206. SUNXI_FUNCTION(0x2, "spi2"), /* MOSI */
  207. SUNXI_FUNCTION(0x3, "jtag")), /* DO0 */
  208. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB17,
  209. SUNXI_FUNCTION(0x0, "gpio_in"),
  210. SUNXI_FUNCTION(0x1, "gpio_out"),
  211. SUNXI_FUNCTION(0x2, "spi2"), /* MISO */
  212. SUNXI_FUNCTION(0x3, "jtag")), /* DI0 */
  213. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB18,
  214. SUNXI_FUNCTION(0x0, "gpio_in"),
  215. SUNXI_FUNCTION(0x1, "gpio_out"),
  216. SUNXI_FUNCTION(0x2, "i2c1")), /* SCK */
  217. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB19,
  218. SUNXI_FUNCTION(0x0, "gpio_in"),
  219. SUNXI_FUNCTION(0x1, "gpio_out"),
  220. SUNXI_FUNCTION(0x2, "i2c1")), /* SDA */
  221. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB20,
  222. SUNXI_FUNCTION(0x0, "gpio_in"),
  223. SUNXI_FUNCTION(0x1, "gpio_out"),
  224. SUNXI_FUNCTION(0x2, "i2c2")), /* SCK */
  225. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB21,
  226. SUNXI_FUNCTION(0x0, "gpio_in"),
  227. SUNXI_FUNCTION(0x1, "gpio_out"),
  228. SUNXI_FUNCTION(0x2, "i2c2")), /* SDA */
  229. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB22,
  230. SUNXI_FUNCTION(0x0, "gpio_in"),
  231. SUNXI_FUNCTION(0x1, "gpio_out"),
  232. SUNXI_FUNCTION(0x2, "uart0"), /* TX */
  233. SUNXI_FUNCTION(0x3, "ir1")), /* TX */
  234. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB23,
  235. SUNXI_FUNCTION(0x0, "gpio_in"),
  236. SUNXI_FUNCTION(0x1, "gpio_out"),
  237. SUNXI_FUNCTION(0x2, "uart0"), /* RX */
  238. SUNXI_FUNCTION(0x3, "ir1")), /* RX */
  239. /* Hole */
  240. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC0,
  241. SUNXI_FUNCTION(0x0, "gpio_in"),
  242. SUNXI_FUNCTION(0x1, "gpio_out"),
  243. SUNXI_FUNCTION(0x2, "nand0"), /* NWE */
  244. SUNXI_FUNCTION(0x3, "spi0")), /* MOSI */
  245. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC1,
  246. SUNXI_FUNCTION(0x0, "gpio_in"),
  247. SUNXI_FUNCTION(0x1, "gpio_out"),
  248. SUNXI_FUNCTION(0x2, "nand0"), /* NALE */
  249. SUNXI_FUNCTION(0x3, "spi0")), /* MISO */
  250. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC2,
  251. SUNXI_FUNCTION(0x0, "gpio_in"),
  252. SUNXI_FUNCTION(0x1, "gpio_out"),
  253. SUNXI_FUNCTION(0x2, "nand0"), /* NCLE */
  254. SUNXI_FUNCTION(0x3, "spi0")), /* SCK */
  255. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC3,
  256. SUNXI_FUNCTION(0x0, "gpio_in"),
  257. SUNXI_FUNCTION(0x1, "gpio_out"),
  258. SUNXI_FUNCTION(0x2, "nand0")), /* NCE1 */
  259. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC4,
  260. SUNXI_FUNCTION(0x0, "gpio_in"),
  261. SUNXI_FUNCTION(0x1, "gpio_out"),
  262. SUNXI_FUNCTION(0x2, "nand0")), /* NCE0 */
  263. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC5,
  264. SUNXI_FUNCTION(0x0, "gpio_in"),
  265. SUNXI_FUNCTION(0x1, "gpio_out"),
  266. SUNXI_FUNCTION(0x2, "nand0")), /* NRE# */
  267. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC6,
  268. SUNXI_FUNCTION(0x0, "gpio_in"),
  269. SUNXI_FUNCTION(0x1, "gpio_out"),
  270. SUNXI_FUNCTION(0x2, "nand0"), /* NRB0 */
  271. SUNXI_FUNCTION(0x3, "mmc2")), /* CMD */
  272. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC7,
  273. SUNXI_FUNCTION(0x0, "gpio_in"),
  274. SUNXI_FUNCTION(0x1, "gpio_out"),
  275. SUNXI_FUNCTION(0x2, "nand0"), /* NRB1 */
  276. SUNXI_FUNCTION(0x3, "mmc2")), /* CLK */
  277. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC8,
  278. SUNXI_FUNCTION(0x0, "gpio_in"),
  279. SUNXI_FUNCTION(0x1, "gpio_out"),
  280. SUNXI_FUNCTION(0x2, "nand0"), /* NDQ0 */
  281. SUNXI_FUNCTION(0x3, "mmc2")), /* D0 */
  282. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC9,
  283. SUNXI_FUNCTION(0x0, "gpio_in"),
  284. SUNXI_FUNCTION(0x1, "gpio_out"),
  285. SUNXI_FUNCTION(0x2, "nand0"), /* NDQ1 */
  286. SUNXI_FUNCTION(0x3, "mmc2")), /* D1 */
  287. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC10,
  288. SUNXI_FUNCTION(0x0, "gpio_in"),
  289. SUNXI_FUNCTION(0x1, "gpio_out"),
  290. SUNXI_FUNCTION(0x2, "nand0"), /* NDQ2 */
  291. SUNXI_FUNCTION(0x3, "mmc2")), /* D2 */
  292. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC11,
  293. SUNXI_FUNCTION(0x0, "gpio_in"),
  294. SUNXI_FUNCTION(0x1, "gpio_out"),
  295. SUNXI_FUNCTION(0x2, "nand0"), /* NDQ3 */
  296. SUNXI_FUNCTION(0x3, "mmc2")), /* D3 */
  297. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC12,
  298. SUNXI_FUNCTION(0x0, "gpio_in"),
  299. SUNXI_FUNCTION(0x1, "gpio_out"),
  300. SUNXI_FUNCTION(0x2, "nand0")), /* NDQ4 */
  301. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC13,
  302. SUNXI_FUNCTION(0x0, "gpio_in"),
  303. SUNXI_FUNCTION(0x1, "gpio_out"),
  304. SUNXI_FUNCTION(0x2, "nand0")), /* NDQ5 */
  305. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC14,
  306. SUNXI_FUNCTION(0x0, "gpio_in"),
  307. SUNXI_FUNCTION(0x1, "gpio_out"),
  308. SUNXI_FUNCTION(0x2, "nand0")), /* NDQ6 */
  309. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC15,
  310. SUNXI_FUNCTION(0x0, "gpio_in"),
  311. SUNXI_FUNCTION(0x1, "gpio_out"),
  312. SUNXI_FUNCTION(0x2, "nand0")), /* NDQ7 */
  313. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC16,
  314. SUNXI_FUNCTION(0x0, "gpio_in"),
  315. SUNXI_FUNCTION(0x1, "gpio_out"),
  316. SUNXI_FUNCTION(0x2, "nand0")), /* NWP */
  317. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC17,
  318. SUNXI_FUNCTION(0x0, "gpio_in"),
  319. SUNXI_FUNCTION(0x1, "gpio_out"),
  320. SUNXI_FUNCTION(0x2, "nand0")), /* NCE2 */
  321. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC18,
  322. SUNXI_FUNCTION(0x0, "gpio_in"),
  323. SUNXI_FUNCTION(0x1, "gpio_out"),
  324. SUNXI_FUNCTION(0x2, "nand0")), /* NCE3 */
  325. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC19,
  326. SUNXI_FUNCTION(0x0, "gpio_in"),
  327. SUNXI_FUNCTION(0x1, "gpio_out"),
  328. SUNXI_FUNCTION(0x2, "nand0"), /* NCE4 */
  329. SUNXI_FUNCTION(0x3, "spi2")), /* CS0 */
  330. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC20,
  331. SUNXI_FUNCTION(0x0, "gpio_in"),
  332. SUNXI_FUNCTION(0x1, "gpio_out"),
  333. SUNXI_FUNCTION(0x2, "nand0"), /* NCE5 */
  334. SUNXI_FUNCTION(0x3, "spi2")), /* CLK */
  335. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC21,
  336. SUNXI_FUNCTION(0x0, "gpio_in"),
  337. SUNXI_FUNCTION(0x1, "gpio_out"),
  338. SUNXI_FUNCTION(0x2, "nand0"), /* NCE6 */
  339. SUNXI_FUNCTION(0x3, "spi2")), /* MOSI */
  340. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC22,
  341. SUNXI_FUNCTION(0x0, "gpio_in"),
  342. SUNXI_FUNCTION(0x1, "gpio_out"),
  343. SUNXI_FUNCTION(0x2, "nand0"), /* NCE7 */
  344. SUNXI_FUNCTION(0x3, "spi2")), /* MISO */
  345. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC23,
  346. SUNXI_FUNCTION(0x0, "gpio_in"),
  347. SUNXI_FUNCTION(0x1, "gpio_out"),
  348. SUNXI_FUNCTION(0x3, "spi0")), /* CS0 */
  349. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC24,
  350. SUNXI_FUNCTION(0x0, "gpio_in"),
  351. SUNXI_FUNCTION(0x1, "gpio_out"),
  352. SUNXI_FUNCTION(0x2, "nand0")), /* NDQS */
  353. /* Hole */
  354. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD0,
  355. SUNXI_FUNCTION(0x0, "gpio_in"),
  356. SUNXI_FUNCTION(0x1, "gpio_out"),
  357. SUNXI_FUNCTION(0x2, "lcd0"), /* D0 */
  358. SUNXI_FUNCTION(0x3, "lvds0")), /* VP0 */
  359. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD1,
  360. SUNXI_FUNCTION(0x0, "gpio_in"),
  361. SUNXI_FUNCTION(0x1, "gpio_out"),
  362. SUNXI_FUNCTION(0x2, "lcd0"), /* D1 */
  363. SUNXI_FUNCTION(0x3, "lvds0")), /* VN0 */
  364. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD2,
  365. SUNXI_FUNCTION(0x0, "gpio_in"),
  366. SUNXI_FUNCTION(0x1, "gpio_out"),
  367. SUNXI_FUNCTION(0x2, "lcd0"), /* D2 */
  368. SUNXI_FUNCTION(0x3, "lvds0")), /* VP1 */
  369. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD3,
  370. SUNXI_FUNCTION(0x0, "gpio_in"),
  371. SUNXI_FUNCTION(0x1, "gpio_out"),
  372. SUNXI_FUNCTION(0x2, "lcd0"), /* D3 */
  373. SUNXI_FUNCTION(0x3, "lvds0")), /* VN1 */
  374. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD4,
  375. SUNXI_FUNCTION(0x0, "gpio_in"),
  376. SUNXI_FUNCTION(0x1, "gpio_out"),
  377. SUNXI_FUNCTION(0x2, "lcd0"), /* D4 */
  378. SUNXI_FUNCTION(0x3, "lvds0")), /* VP2 */
  379. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD5,
  380. SUNXI_FUNCTION(0x0, "gpio_in"),
  381. SUNXI_FUNCTION(0x1, "gpio_out"),
  382. SUNXI_FUNCTION(0x2, "lcd0"), /* D5 */
  383. SUNXI_FUNCTION(0x3, "lvds0")), /* VN2 */
  384. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD6,
  385. SUNXI_FUNCTION(0x0, "gpio_in"),
  386. SUNXI_FUNCTION(0x1, "gpio_out"),
  387. SUNXI_FUNCTION(0x2, "lcd0"), /* D6 */
  388. SUNXI_FUNCTION(0x3, "lvds0")), /* VPC */
  389. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD7,
  390. SUNXI_FUNCTION(0x0, "gpio_in"),
  391. SUNXI_FUNCTION(0x1, "gpio_out"),
  392. SUNXI_FUNCTION(0x2, "lcd0"), /* D7 */
  393. SUNXI_FUNCTION(0x3, "lvds0")), /* VNC */
  394. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD8,
  395. SUNXI_FUNCTION(0x0, "gpio_in"),
  396. SUNXI_FUNCTION(0x1, "gpio_out"),
  397. SUNXI_FUNCTION(0x2, "lcd0"), /* D8 */
  398. SUNXI_FUNCTION(0x3, "lvds0")), /* VP3 */
  399. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD9,
  400. SUNXI_FUNCTION(0x0, "gpio_in"),
  401. SUNXI_FUNCTION(0x1, "gpio_out"),
  402. SUNXI_FUNCTION(0x2, "lcd0"), /* D9 */
  403. SUNXI_FUNCTION(0x3, "lvds0")), /* VM3 */
  404. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD10,
  405. SUNXI_FUNCTION(0x0, "gpio_in"),
  406. SUNXI_FUNCTION(0x1, "gpio_out"),
  407. SUNXI_FUNCTION(0x2, "lcd0"), /* D10 */
  408. SUNXI_FUNCTION(0x3, "lvds1")), /* VP0 */
  409. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD11,
  410. SUNXI_FUNCTION(0x0, "gpio_in"),
  411. SUNXI_FUNCTION(0x1, "gpio_out"),
  412. SUNXI_FUNCTION(0x2, "lcd0"), /* D11 */
  413. SUNXI_FUNCTION(0x3, "lvds1")), /* VN0 */
  414. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD12,
  415. SUNXI_FUNCTION(0x0, "gpio_in"),
  416. SUNXI_FUNCTION(0x1, "gpio_out"),
  417. SUNXI_FUNCTION(0x2, "lcd0"), /* D12 */
  418. SUNXI_FUNCTION(0x3, "lvds1")), /* VP1 */
  419. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD13,
  420. SUNXI_FUNCTION(0x0, "gpio_in"),
  421. SUNXI_FUNCTION(0x1, "gpio_out"),
  422. SUNXI_FUNCTION(0x2, "lcd0"), /* D13 */
  423. SUNXI_FUNCTION(0x3, "lvds1")), /* VN1 */
  424. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD14,
  425. SUNXI_FUNCTION(0x0, "gpio_in"),
  426. SUNXI_FUNCTION(0x1, "gpio_out"),
  427. SUNXI_FUNCTION(0x2, "lcd0"), /* D14 */
  428. SUNXI_FUNCTION(0x3, "lvds1")), /* VP2 */
  429. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD15,
  430. SUNXI_FUNCTION(0x0, "gpio_in"),
  431. SUNXI_FUNCTION(0x1, "gpio_out"),
  432. SUNXI_FUNCTION(0x2, "lcd0"), /* D15 */
  433. SUNXI_FUNCTION(0x3, "lvds1")), /* VN2 */
  434. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD16,
  435. SUNXI_FUNCTION(0x0, "gpio_in"),
  436. SUNXI_FUNCTION(0x1, "gpio_out"),
  437. SUNXI_FUNCTION(0x2, "lcd0"), /* D16 */
  438. SUNXI_FUNCTION(0x3, "lvds1")), /* VPC */
  439. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD17,
  440. SUNXI_FUNCTION(0x0, "gpio_in"),
  441. SUNXI_FUNCTION(0x1, "gpio_out"),
  442. SUNXI_FUNCTION(0x2, "lcd0"), /* D17 */
  443. SUNXI_FUNCTION(0x3, "lvds1")), /* VNC */
  444. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD18,
  445. SUNXI_FUNCTION(0x0, "gpio_in"),
  446. SUNXI_FUNCTION(0x1, "gpio_out"),
  447. SUNXI_FUNCTION(0x2, "lcd0"), /* D18 */
  448. SUNXI_FUNCTION(0x3, "lvds1")), /* VP3 */
  449. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD19,
  450. SUNXI_FUNCTION(0x0, "gpio_in"),
  451. SUNXI_FUNCTION(0x1, "gpio_out"),
  452. SUNXI_FUNCTION(0x2, "lcd0"), /* D19 */
  453. SUNXI_FUNCTION(0x3, "lvds1")), /* VN3 */
  454. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD20,
  455. SUNXI_FUNCTION(0x0, "gpio_in"),
  456. SUNXI_FUNCTION(0x1, "gpio_out"),
  457. SUNXI_FUNCTION(0x2, "lcd0"), /* D20 */
  458. SUNXI_FUNCTION(0x3, "csi1")), /* MCLK */
  459. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD21,
  460. SUNXI_FUNCTION(0x0, "gpio_in"),
  461. SUNXI_FUNCTION(0x1, "gpio_out"),
  462. SUNXI_FUNCTION(0x2, "lcd0"), /* D21 */
  463. SUNXI_FUNCTION(0x3, "sim")), /* VPPEN */
  464. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD22,
  465. SUNXI_FUNCTION(0x0, "gpio_in"),
  466. SUNXI_FUNCTION(0x1, "gpio_out"),
  467. SUNXI_FUNCTION(0x2, "lcd0"), /* D22 */
  468. SUNXI_FUNCTION(0x3, "sim")), /* VPPPP */
  469. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD23,
  470. SUNXI_FUNCTION(0x0, "gpio_in"),
  471. SUNXI_FUNCTION(0x1, "gpio_out"),
  472. SUNXI_FUNCTION(0x2, "lcd0"), /* D23 */
  473. SUNXI_FUNCTION(0x3, "sim")), /* DET */
  474. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD24,
  475. SUNXI_FUNCTION(0x0, "gpio_in"),
  476. SUNXI_FUNCTION(0x1, "gpio_out"),
  477. SUNXI_FUNCTION(0x2, "lcd0"), /* CLK */
  478. SUNXI_FUNCTION(0x3, "sim")), /* VCCEN */
  479. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD25,
  480. SUNXI_FUNCTION(0x0, "gpio_in"),
  481. SUNXI_FUNCTION(0x1, "gpio_out"),
  482. SUNXI_FUNCTION(0x2, "lcd0"), /* DE */
  483. SUNXI_FUNCTION(0x3, "sim")), /* RST */
  484. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD26,
  485. SUNXI_FUNCTION(0x0, "gpio_in"),
  486. SUNXI_FUNCTION(0x1, "gpio_out"),
  487. SUNXI_FUNCTION(0x2, "lcd0"), /* HSYNC */
  488. SUNXI_FUNCTION(0x3, "sim")), /* SCK */
  489. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD27,
  490. SUNXI_FUNCTION(0x0, "gpio_in"),
  491. SUNXI_FUNCTION(0x1, "gpio_out"),
  492. SUNXI_FUNCTION(0x2, "lcd0"), /* VSYNC */
  493. SUNXI_FUNCTION(0x3, "sim")), /* SDA */
  494. /* Hole */
  495. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE0,
  496. SUNXI_FUNCTION(0x0, "gpio_in"),
  497. SUNXI_FUNCTION(0x1, "gpio_out"),
  498. SUNXI_FUNCTION(0x2, "ts0"), /* CLK */
  499. SUNXI_FUNCTION(0x3, "csi0")), /* PCK */
  500. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE1,
  501. SUNXI_FUNCTION(0x0, "gpio_in"),
  502. SUNXI_FUNCTION(0x1, "gpio_out"),
  503. SUNXI_FUNCTION(0x2, "ts0"), /* ERR */
  504. SUNXI_FUNCTION(0x3, "csi0")), /* CK */
  505. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE2,
  506. SUNXI_FUNCTION(0x0, "gpio_in"),
  507. SUNXI_FUNCTION(0x1, "gpio_out"),
  508. SUNXI_FUNCTION(0x2, "ts0"), /* SYNC */
  509. SUNXI_FUNCTION(0x3, "csi0")), /* HSYNC */
  510. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE3,
  511. SUNXI_FUNCTION(0x0, "gpio_in"),
  512. SUNXI_FUNCTION(0x1, "gpio_out"),
  513. SUNXI_FUNCTION(0x2, "ts0"), /* DVLD */
  514. SUNXI_FUNCTION(0x3, "csi0")), /* VSYNC */
  515. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE4,
  516. SUNXI_FUNCTION(0x0, "gpio_in"),
  517. SUNXI_FUNCTION(0x1, "gpio_out"),
  518. SUNXI_FUNCTION(0x2, "ts0"), /* D0 */
  519. SUNXI_FUNCTION(0x3, "csi0")), /* D0 */
  520. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE5,
  521. SUNXI_FUNCTION(0x0, "gpio_in"),
  522. SUNXI_FUNCTION(0x1, "gpio_out"),
  523. SUNXI_FUNCTION(0x2, "ts0"), /* D1 */
  524. SUNXI_FUNCTION(0x3, "csi0"), /* D1 */
  525. SUNXI_FUNCTION(0x4, "sim")), /* VPPEN */
  526. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE6,
  527. SUNXI_FUNCTION(0x0, "gpio_in"),
  528. SUNXI_FUNCTION(0x1, "gpio_out"),
  529. SUNXI_FUNCTION(0x2, "ts0"), /* D2 */
  530. SUNXI_FUNCTION(0x3, "csi0")), /* D2 */
  531. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE7,
  532. SUNXI_FUNCTION(0x0, "gpio_in"),
  533. SUNXI_FUNCTION(0x1, "gpio_out"),
  534. SUNXI_FUNCTION(0x2, "ts0"), /* D3 */
  535. SUNXI_FUNCTION(0x3, "csi0")), /* D3 */
  536. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE8,
  537. SUNXI_FUNCTION(0x0, "gpio_in"),
  538. SUNXI_FUNCTION(0x1, "gpio_out"),
  539. SUNXI_FUNCTION(0x2, "ts0"), /* D4 */
  540. SUNXI_FUNCTION(0x3, "csi0")), /* D4 */
  541. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE9,
  542. SUNXI_FUNCTION(0x0, "gpio_in"),
  543. SUNXI_FUNCTION(0x1, "gpio_out"),
  544. SUNXI_FUNCTION(0x2, "ts0"), /* D5 */
  545. SUNXI_FUNCTION(0x3, "csi0")), /* D5 */
  546. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE10,
  547. SUNXI_FUNCTION(0x0, "gpio_in"),
  548. SUNXI_FUNCTION(0x1, "gpio_out"),
  549. SUNXI_FUNCTION(0x2, "ts0"), /* D6 */
  550. SUNXI_FUNCTION(0x3, "csi0")), /* D6 */
  551. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE11,
  552. SUNXI_FUNCTION(0x0, "gpio_in"),
  553. SUNXI_FUNCTION(0x1, "gpio_out"),
  554. SUNXI_FUNCTION(0x2, "ts0"), /* D7 */
  555. SUNXI_FUNCTION(0x3, "csi0")), /* D7 */
  556. /* Hole */
  557. SUNXI_PIN(SUNXI_PINCTRL_PIN_PF0,
  558. SUNXI_FUNCTION(0x0, "gpio_in"),
  559. SUNXI_FUNCTION(0x1, "gpio_out"),
  560. SUNXI_FUNCTION(0x2, "mmc0"), /* D1 */
  561. SUNXI_FUNCTION(0x4, "jtag")), /* MSI */
  562. SUNXI_PIN(SUNXI_PINCTRL_PIN_PF1,
  563. SUNXI_FUNCTION(0x0, "gpio_in"),
  564. SUNXI_FUNCTION(0x1, "gpio_out"),
  565. SUNXI_FUNCTION(0x2, "mmc0"), /* D0 */
  566. SUNXI_FUNCTION(0x4, "jtag")), /* DI1 */
  567. SUNXI_PIN(SUNXI_PINCTRL_PIN_PF2,
  568. SUNXI_FUNCTION(0x0, "gpio_in"),
  569. SUNXI_FUNCTION(0x1, "gpio_out"),
  570. SUNXI_FUNCTION(0x2, "mmc0"), /* CLK */
  571. SUNXI_FUNCTION(0x4, "uart0")), /* TX */
  572. SUNXI_PIN(SUNXI_PINCTRL_PIN_PF3,
  573. SUNXI_FUNCTION(0x0, "gpio_in"),
  574. SUNXI_FUNCTION(0x1, "gpio_out"),
  575. SUNXI_FUNCTION(0x2, "mmc0"), /* CMD */
  576. SUNXI_FUNCTION(0x4, "jtag")), /* DO1 */
  577. SUNXI_PIN(SUNXI_PINCTRL_PIN_PF4,
  578. SUNXI_FUNCTION(0x0, "gpio_in"),
  579. SUNXI_FUNCTION(0x1, "gpio_out"),
  580. SUNXI_FUNCTION(0x2, "mmc0"), /* D3 */
  581. SUNXI_FUNCTION(0x4, "uart0")), /* RX */
  582. SUNXI_PIN(SUNXI_PINCTRL_PIN_PF5,
  583. SUNXI_FUNCTION(0x0, "gpio_in"),
  584. SUNXI_FUNCTION(0x1, "gpio_out"),
  585. SUNXI_FUNCTION(0x2, "mmc0"), /* D2 */
  586. SUNXI_FUNCTION(0x4, "jtag")), /* CK1 */
  587. /* Hole */
  588. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG0,
  589. SUNXI_FUNCTION(0x0, "gpio_in"),
  590. SUNXI_FUNCTION(0x1, "gpio_out"),
  591. SUNXI_FUNCTION(0x2, "ts1"), /* CLK */
  592. SUNXI_FUNCTION(0x3, "csi1"), /* PCK */
  593. SUNXI_FUNCTION(0x4, "mmc1")), /* CMD */
  594. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG1,
  595. SUNXI_FUNCTION(0x0, "gpio_in"),
  596. SUNXI_FUNCTION(0x1, "gpio_out"),
  597. SUNXI_FUNCTION(0x2, "ts1"), /* ERR */
  598. SUNXI_FUNCTION(0x3, "csi1"), /* CK */
  599. SUNXI_FUNCTION(0x4, "mmc1")), /* CLK */
  600. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG2,
  601. SUNXI_FUNCTION(0x0, "gpio_in"),
  602. SUNXI_FUNCTION(0x1, "gpio_out"),
  603. SUNXI_FUNCTION(0x2, "ts1"), /* SYNC */
  604. SUNXI_FUNCTION(0x3, "csi1"), /* HSYNC */
  605. SUNXI_FUNCTION(0x4, "mmc1")), /* D0 */
  606. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG3,
  607. SUNXI_FUNCTION(0x0, "gpio_in"),
  608. SUNXI_FUNCTION(0x1, "gpio_out"),
  609. SUNXI_FUNCTION(0x2, "ts1"), /* DVLD */
  610. SUNXI_FUNCTION(0x3, "csi1"), /* VSYNC */
  611. SUNXI_FUNCTION(0x4, "mmc1")), /* D1 */
  612. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG4,
  613. SUNXI_FUNCTION(0x0, "gpio_in"),
  614. SUNXI_FUNCTION(0x1, "gpio_out"),
  615. SUNXI_FUNCTION(0x2, "ts1"), /* D0 */
  616. SUNXI_FUNCTION(0x3, "csi1"), /* D0 */
  617. SUNXI_FUNCTION(0x4, "mmc1"), /* D2 */
  618. SUNXI_FUNCTION(0x5, "csi0")), /* D8 */
  619. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG5,
  620. SUNXI_FUNCTION(0x0, "gpio_in"),
  621. SUNXI_FUNCTION(0x1, "gpio_out"),
  622. SUNXI_FUNCTION(0x2, "ts1"), /* D1 */
  623. SUNXI_FUNCTION(0x3, "csi1"), /* D1 */
  624. SUNXI_FUNCTION(0x4, "mmc1"), /* D3 */
  625. SUNXI_FUNCTION(0x5, "csi0")), /* D9 */
  626. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG6,
  627. SUNXI_FUNCTION(0x0, "gpio_in"),
  628. SUNXI_FUNCTION(0x1, "gpio_out"),
  629. SUNXI_FUNCTION(0x2, "ts1"), /* D2 */
  630. SUNXI_FUNCTION(0x3, "csi1"), /* D2 */
  631. SUNXI_FUNCTION(0x4, "uart3"), /* TX */
  632. SUNXI_FUNCTION(0x5, "csi0")), /* D10 */
  633. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG7,
  634. SUNXI_FUNCTION(0x0, "gpio_in"),
  635. SUNXI_FUNCTION(0x1, "gpio_out"),
  636. SUNXI_FUNCTION(0x2, "ts1"), /* D3 */
  637. SUNXI_FUNCTION(0x3, "csi1"), /* D3 */
  638. SUNXI_FUNCTION(0x4, "uart3"), /* RX */
  639. SUNXI_FUNCTION(0x5, "csi0")), /* D11 */
  640. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG8,
  641. SUNXI_FUNCTION(0x0, "gpio_in"),
  642. SUNXI_FUNCTION(0x1, "gpio_out"),
  643. SUNXI_FUNCTION(0x2, "ts1"), /* D4 */
  644. SUNXI_FUNCTION(0x3, "csi1"), /* D4 */
  645. SUNXI_FUNCTION(0x4, "uart3"), /* RTS */
  646. SUNXI_FUNCTION(0x5, "csi0")), /* D12 */
  647. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG9,
  648. SUNXI_FUNCTION(0x0, "gpio_in"),
  649. SUNXI_FUNCTION(0x1, "gpio_out"),
  650. SUNXI_FUNCTION(0x2, "ts1"), /* D5 */
  651. SUNXI_FUNCTION(0x3, "csi1"), /* D5 */
  652. SUNXI_FUNCTION(0x4, "uart3"), /* CTS */
  653. SUNXI_FUNCTION(0x5, "csi0")), /* D13 */
  654. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG10,
  655. SUNXI_FUNCTION(0x0, "gpio_in"),
  656. SUNXI_FUNCTION(0x1, "gpio_out"),
  657. SUNXI_FUNCTION(0x2, "ts1"), /* D6 */
  658. SUNXI_FUNCTION(0x3, "csi1"), /* D6 */
  659. SUNXI_FUNCTION(0x4, "uart4"), /* TX */
  660. SUNXI_FUNCTION(0x5, "csi0")), /* D14 */
  661. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG11,
  662. SUNXI_FUNCTION(0x0, "gpio_in"),
  663. SUNXI_FUNCTION(0x1, "gpio_out"),
  664. SUNXI_FUNCTION(0x2, "ts1"), /* D7 */
  665. SUNXI_FUNCTION(0x3, "csi1"), /* D7 */
  666. SUNXI_FUNCTION(0x4, "uart4"), /* RX */
  667. SUNXI_FUNCTION(0x5, "csi0")), /* D15 */
  668. /* Hole */
  669. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH0,
  670. SUNXI_FUNCTION(0x0, "gpio_in"),
  671. SUNXI_FUNCTION(0x1, "gpio_out"),
  672. SUNXI_FUNCTION(0x2, "lcd1"), /* D0 */
  673. SUNXI_FUNCTION(0x3, "pata"), /* ATAA0 */
  674. SUNXI_FUNCTION(0x4, "uart3"), /* TX */
  675. SUNXI_FUNCTION(0x7, "csi1")), /* D0 */
  676. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH1,
  677. SUNXI_FUNCTION(0x0, "gpio_in"),
  678. SUNXI_FUNCTION(0x1, "gpio_out"),
  679. SUNXI_FUNCTION(0x2, "lcd1"), /* D1 */
  680. SUNXI_FUNCTION(0x3, "pata"), /* ATAA1 */
  681. SUNXI_FUNCTION(0x4, "uart3"), /* RX */
  682. SUNXI_FUNCTION(0x7, "csi1")), /* D1 */
  683. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH2,
  684. SUNXI_FUNCTION(0x0, "gpio_in"),
  685. SUNXI_FUNCTION(0x1, "gpio_out"),
  686. SUNXI_FUNCTION(0x2, "lcd1"), /* D2 */
  687. SUNXI_FUNCTION(0x3, "pata"), /* ATAA2 */
  688. SUNXI_FUNCTION(0x4, "uart3"), /* RTS */
  689. SUNXI_FUNCTION(0x7, "csi1")), /* D2 */
  690. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH3,
  691. SUNXI_FUNCTION(0x0, "gpio_in"),
  692. SUNXI_FUNCTION(0x1, "gpio_out"),
  693. SUNXI_FUNCTION(0x2, "lcd1"), /* D3 */
  694. SUNXI_FUNCTION(0x3, "pata"), /* ATAIRQ */
  695. SUNXI_FUNCTION(0x4, "uart3"), /* CTS */
  696. SUNXI_FUNCTION(0x7, "csi1")), /* D3 */
  697. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH4,
  698. SUNXI_FUNCTION(0x0, "gpio_in"),
  699. SUNXI_FUNCTION(0x1, "gpio_out"),
  700. SUNXI_FUNCTION(0x2, "lcd1"), /* D4 */
  701. SUNXI_FUNCTION(0x3, "pata"), /* ATAD0 */
  702. SUNXI_FUNCTION(0x4, "uart4"), /* TX */
  703. SUNXI_FUNCTION(0x7, "csi1")), /* D4 */
  704. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH5,
  705. SUNXI_FUNCTION(0x0, "gpio_in"),
  706. SUNXI_FUNCTION(0x1, "gpio_out"),
  707. SUNXI_FUNCTION(0x2, "lcd1"), /* D5 */
  708. SUNXI_FUNCTION(0x3, "pata"), /* ATAD1 */
  709. SUNXI_FUNCTION(0x4, "uart4"), /* RX */
  710. SUNXI_FUNCTION(0x7, "csi1")), /* D5 */
  711. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH6,
  712. SUNXI_FUNCTION(0x0, "gpio_in"),
  713. SUNXI_FUNCTION(0x1, "gpio_out"),
  714. SUNXI_FUNCTION(0x2, "lcd1"), /* D6 */
  715. SUNXI_FUNCTION(0x3, "pata"), /* ATAD2 */
  716. SUNXI_FUNCTION(0x4, "uart5"), /* TX */
  717. SUNXI_FUNCTION(0x5, "ms"), /* BS */
  718. SUNXI_FUNCTION(0x7, "csi1")), /* D6 */
  719. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH7,
  720. SUNXI_FUNCTION(0x0, "gpio_in"),
  721. SUNXI_FUNCTION(0x1, "gpio_out"),
  722. SUNXI_FUNCTION(0x2, "lcd1"), /* D7 */
  723. SUNXI_FUNCTION(0x3, "pata"), /* ATAD3 */
  724. SUNXI_FUNCTION(0x4, "uart5"), /* RX */
  725. SUNXI_FUNCTION(0x5, "ms"), /* CLK */
  726. SUNXI_FUNCTION(0x7, "csi1")), /* D7 */
  727. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH8,
  728. SUNXI_FUNCTION(0x0, "gpio_in"),
  729. SUNXI_FUNCTION(0x1, "gpio_out"),
  730. SUNXI_FUNCTION(0x2, "lcd1"), /* D8 */
  731. SUNXI_FUNCTION(0x3, "pata"), /* ATAD4 */
  732. SUNXI_FUNCTION(0x4, "keypad"), /* IN0 */
  733. SUNXI_FUNCTION(0x5, "ms"), /* D0 */
  734. SUNXI_FUNCTION(0x7, "csi1")), /* D8 */
  735. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH9,
  736. SUNXI_FUNCTION(0x0, "gpio_in"),
  737. SUNXI_FUNCTION(0x1, "gpio_out"),
  738. SUNXI_FUNCTION(0x2, "lcd1"), /* D9 */
  739. SUNXI_FUNCTION(0x3, "pata"), /* ATAD5 */
  740. SUNXI_FUNCTION(0x4, "keypad"), /* IN1 */
  741. SUNXI_FUNCTION(0x5, "ms"), /* D1 */
  742. SUNXI_FUNCTION(0x7, "csi1")), /* D9 */
  743. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH10,
  744. SUNXI_FUNCTION(0x0, "gpio_in"),
  745. SUNXI_FUNCTION(0x1, "gpio_out"),
  746. SUNXI_FUNCTION(0x2, "lcd1"), /* D10 */
  747. SUNXI_FUNCTION(0x3, "pata"), /* ATAD6 */
  748. SUNXI_FUNCTION(0x4, "keypad"), /* IN2 */
  749. SUNXI_FUNCTION(0x5, "ms"), /* D2 */
  750. SUNXI_FUNCTION(0x7, "csi1")), /* D10 */
  751. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH11,
  752. SUNXI_FUNCTION(0x0, "gpio_in"),
  753. SUNXI_FUNCTION(0x1, "gpio_out"),
  754. SUNXI_FUNCTION(0x2, "lcd1"), /* D11 */
  755. SUNXI_FUNCTION(0x3, "pata"), /* ATAD7 */
  756. SUNXI_FUNCTION(0x4, "keypad"), /* IN3 */
  757. SUNXI_FUNCTION(0x5, "ms"), /* D3 */
  758. SUNXI_FUNCTION(0x7, "csi1")), /* D11 */
  759. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH12,
  760. SUNXI_FUNCTION(0x0, "gpio_in"),
  761. SUNXI_FUNCTION(0x1, "gpio_out"),
  762. SUNXI_FUNCTION(0x2, "lcd1"), /* D12 */
  763. SUNXI_FUNCTION(0x3, "pata"), /* ATAD8 */
  764. SUNXI_FUNCTION(0x4, "ps2"), /* SCK1 */
  765. SUNXI_FUNCTION(0x7, "csi1")), /* D12 */
  766. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH13,
  767. SUNXI_FUNCTION(0x0, "gpio_in"),
  768. SUNXI_FUNCTION(0x1, "gpio_out"),
  769. SUNXI_FUNCTION(0x2, "lcd1"), /* D13 */
  770. SUNXI_FUNCTION(0x3, "pata"), /* ATAD9 */
  771. SUNXI_FUNCTION(0x4, "ps2"), /* SDA1 */
  772. SUNXI_FUNCTION(0x5, "sim"), /* RST */
  773. SUNXI_FUNCTION(0x7, "csi1")), /* D13 */
  774. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH14,
  775. SUNXI_FUNCTION(0x0, "gpio_in"),
  776. SUNXI_FUNCTION(0x1, "gpio_out"),
  777. SUNXI_FUNCTION(0x2, "lcd1"), /* D14 */
  778. SUNXI_FUNCTION(0x3, "pata"), /* ATAD10 */
  779. SUNXI_FUNCTION(0x4, "keypad"), /* IN4 */
  780. SUNXI_FUNCTION(0x5, "sim"), /* VPPEN */
  781. SUNXI_FUNCTION(0x7, "csi1")), /* D14 */
  782. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH15,
  783. SUNXI_FUNCTION(0x0, "gpio_in"),
  784. SUNXI_FUNCTION(0x1, "gpio_out"),
  785. SUNXI_FUNCTION(0x2, "lcd1"), /* D15 */
  786. SUNXI_FUNCTION(0x3, "pata"), /* ATAD11 */
  787. SUNXI_FUNCTION(0x4, "keypad"), /* IN5 */
  788. SUNXI_FUNCTION(0x5, "sim"), /* VPPPP */
  789. SUNXI_FUNCTION(0x7, "csi1")), /* D15 */
  790. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH16,
  791. SUNXI_FUNCTION(0x0, "gpio_in"),
  792. SUNXI_FUNCTION(0x1, "gpio_out"),
  793. SUNXI_FUNCTION(0x2, "lcd1"), /* D16 */
  794. SUNXI_FUNCTION(0x3, "pata"), /* ATAD12 */
  795. SUNXI_FUNCTION(0x4, "keypad"), /* IN6 */
  796. SUNXI_FUNCTION(0x7, "csi1")), /* D16 */
  797. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH17,
  798. SUNXI_FUNCTION(0x0, "gpio_in"),
  799. SUNXI_FUNCTION(0x1, "gpio_out"),
  800. SUNXI_FUNCTION(0x2, "lcd1"), /* D17 */
  801. SUNXI_FUNCTION(0x3, "pata"), /* ATAD13 */
  802. SUNXI_FUNCTION(0x4, "keypad"), /* IN7 */
  803. SUNXI_FUNCTION(0x5, "sim"), /* VCCEN */
  804. SUNXI_FUNCTION(0x7, "csi1")), /* D17 */
  805. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH18,
  806. SUNXI_FUNCTION(0x0, "gpio_in"),
  807. SUNXI_FUNCTION(0x1, "gpio_out"),
  808. SUNXI_FUNCTION(0x2, "lcd1"), /* D18 */
  809. SUNXI_FUNCTION(0x3, "pata"), /* ATAD14 */
  810. SUNXI_FUNCTION(0x4, "keypad"), /* OUT0 */
  811. SUNXI_FUNCTION(0x5, "sim"), /* SCK */
  812. SUNXI_FUNCTION(0x7, "csi1")), /* D18 */
  813. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH19,
  814. SUNXI_FUNCTION(0x0, "gpio_in"),
  815. SUNXI_FUNCTION(0x1, "gpio_out"),
  816. SUNXI_FUNCTION(0x2, "lcd1"), /* D19 */
  817. SUNXI_FUNCTION(0x3, "pata"), /* ATAD15 */
  818. SUNXI_FUNCTION(0x4, "keypad"), /* OUT1 */
  819. SUNXI_FUNCTION(0x5, "sim"), /* SDA */
  820. SUNXI_FUNCTION(0x7, "csi1")), /* D19 */
  821. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH20,
  822. SUNXI_FUNCTION(0x0, "gpio_in"),
  823. SUNXI_FUNCTION(0x1, "gpio_out"),
  824. SUNXI_FUNCTION(0x2, "lcd1"), /* D20 */
  825. SUNXI_FUNCTION(0x3, "pata"), /* ATAOE */
  826. SUNXI_FUNCTION(0x4, "can"), /* TX */
  827. SUNXI_FUNCTION(0x7, "csi1")), /* D20 */
  828. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH21,
  829. SUNXI_FUNCTION(0x0, "gpio_in"),
  830. SUNXI_FUNCTION(0x1, "gpio_out"),
  831. SUNXI_FUNCTION(0x2, "lcd1"), /* D21 */
  832. SUNXI_FUNCTION(0x3, "pata"), /* ATADREQ */
  833. SUNXI_FUNCTION(0x4, "can"), /* RX */
  834. SUNXI_FUNCTION(0x7, "csi1")), /* D21 */
  835. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH22,
  836. SUNXI_FUNCTION(0x0, "gpio_in"),
  837. SUNXI_FUNCTION(0x1, "gpio_out"),
  838. SUNXI_FUNCTION(0x2, "lcd1"), /* D22 */
  839. SUNXI_FUNCTION(0x3, "pata"), /* ATADACK */
  840. SUNXI_FUNCTION(0x4, "keypad"), /* OUT2 */
  841. SUNXI_FUNCTION(0x5, "mmc1"), /* CMD */
  842. SUNXI_FUNCTION(0x7, "csi1")), /* D22 */
  843. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH23,
  844. SUNXI_FUNCTION(0x0, "gpio_in"),
  845. SUNXI_FUNCTION(0x1, "gpio_out"),
  846. SUNXI_FUNCTION(0x2, "lcd1"), /* D23 */
  847. SUNXI_FUNCTION(0x3, "pata"), /* ATACS0 */
  848. SUNXI_FUNCTION(0x4, "keypad"), /* OUT3 */
  849. SUNXI_FUNCTION(0x5, "mmc1"), /* CLK */
  850. SUNXI_FUNCTION(0x7, "csi1")), /* D23 */
  851. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH24,
  852. SUNXI_FUNCTION(0x0, "gpio_in"),
  853. SUNXI_FUNCTION(0x1, "gpio_out"),
  854. SUNXI_FUNCTION(0x2, "lcd1"), /* CLK */
  855. SUNXI_FUNCTION(0x3, "pata"), /* ATACS1 */
  856. SUNXI_FUNCTION(0x4, "keypad"), /* OUT4 */
  857. SUNXI_FUNCTION(0x5, "mmc1"), /* D0 */
  858. SUNXI_FUNCTION(0x7, "csi1")), /* PCLK */
  859. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH25,
  860. SUNXI_FUNCTION(0x0, "gpio_in"),
  861. SUNXI_FUNCTION(0x1, "gpio_out"),
  862. SUNXI_FUNCTION(0x2, "lcd1"), /* DE */
  863. SUNXI_FUNCTION(0x3, "pata"), /* ATAIORDY */
  864. SUNXI_FUNCTION(0x4, "keypad"), /* OUT5 */
  865. SUNXI_FUNCTION(0x5, "mmc1"), /* D1 */
  866. SUNXI_FUNCTION(0x7, "csi1")), /* FIELD */
  867. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH26,
  868. SUNXI_FUNCTION(0x0, "gpio_in"),
  869. SUNXI_FUNCTION(0x1, "gpio_out"),
  870. SUNXI_FUNCTION(0x2, "lcd1"), /* HSYNC */
  871. SUNXI_FUNCTION(0x3, "pata"), /* ATAIOR */
  872. SUNXI_FUNCTION(0x4, "keypad"), /* OUT6 */
  873. SUNXI_FUNCTION(0x5, "mmc1"), /* D2 */
  874. SUNXI_FUNCTION(0x7, "csi1")), /* HSYNC */
  875. SUNXI_PIN(SUNXI_PINCTRL_PIN_PH27,
  876. SUNXI_FUNCTION(0x0, "gpio_in"),
  877. SUNXI_FUNCTION(0x1, "gpio_out"),
  878. SUNXI_FUNCTION(0x2, "lcd1"), /* VSYNC */
  879. SUNXI_FUNCTION(0x3, "pata"), /* ATAIOW */
  880. SUNXI_FUNCTION(0x4, "keypad"), /* OUT7 */
  881. SUNXI_FUNCTION(0x5, "mmc1"), /* D3 */
  882. SUNXI_FUNCTION(0x7, "csi1")), /* VSYNC */
  883. /* Hole */
  884. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI0,
  885. SUNXI_FUNCTION(0x0, "gpio_in"),
  886. SUNXI_FUNCTION(0x1, "gpio_out")),
  887. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI1,
  888. SUNXI_FUNCTION(0x0, "gpio_in"),
  889. SUNXI_FUNCTION(0x1, "gpio_out")),
  890. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI2,
  891. SUNXI_FUNCTION(0x0, "gpio_in"),
  892. SUNXI_FUNCTION(0x1, "gpio_out")),
  893. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI3,
  894. SUNXI_FUNCTION(0x0, "gpio_in"),
  895. SUNXI_FUNCTION(0x1, "gpio_out"),
  896. SUNXI_FUNCTION(0x2, "pwm")), /* PWM1 */
  897. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI4,
  898. SUNXI_FUNCTION(0x0, "gpio_in"),
  899. SUNXI_FUNCTION(0x1, "gpio_out"),
  900. SUNXI_FUNCTION(0x2, "mmc3")), /* CMD */
  901. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI5,
  902. SUNXI_FUNCTION(0x0, "gpio_in"),
  903. SUNXI_FUNCTION(0x1, "gpio_out"),
  904. SUNXI_FUNCTION(0x2, "mmc3")), /* CLK */
  905. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI6,
  906. SUNXI_FUNCTION(0x0, "gpio_in"),
  907. SUNXI_FUNCTION(0x1, "gpio_out"),
  908. SUNXI_FUNCTION(0x2, "mmc3")), /* D0 */
  909. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI7,
  910. SUNXI_FUNCTION(0x0, "gpio_in"),
  911. SUNXI_FUNCTION(0x1, "gpio_out"),
  912. SUNXI_FUNCTION(0x2, "mmc3")), /* D1 */
  913. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI8,
  914. SUNXI_FUNCTION(0x0, "gpio_in"),
  915. SUNXI_FUNCTION(0x1, "gpio_out"),
  916. SUNXI_FUNCTION(0x2, "mmc3")), /* D2 */
  917. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI9,
  918. SUNXI_FUNCTION(0x0, "gpio_in"),
  919. SUNXI_FUNCTION(0x1, "gpio_out"),
  920. SUNXI_FUNCTION(0x2, "mmc3")), /* D3 */
  921. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI10,
  922. SUNXI_FUNCTION(0x0, "gpio_in"),
  923. SUNXI_FUNCTION(0x1, "gpio_out"),
  924. SUNXI_FUNCTION(0x2, "spi0"), /* CS0 */
  925. SUNXI_FUNCTION(0x3, "uart5")), /* TX */
  926. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI11,
  927. SUNXI_FUNCTION(0x0, "gpio_in"),
  928. SUNXI_FUNCTION(0x1, "gpio_out"),
  929. SUNXI_FUNCTION(0x2, "spi0"), /* CLK */
  930. SUNXI_FUNCTION(0x3, "uart5")), /* RX */
  931. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI12,
  932. SUNXI_FUNCTION(0x0, "gpio_in"),
  933. SUNXI_FUNCTION(0x1, "gpio_out"),
  934. SUNXI_FUNCTION(0x2, "spi0"), /* MOSI */
  935. SUNXI_FUNCTION(0x3, "uart6")), /* TX */
  936. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI13,
  937. SUNXI_FUNCTION(0x0, "gpio_in"),
  938. SUNXI_FUNCTION(0x1, "gpio_out"),
  939. SUNXI_FUNCTION(0x2, "spi0"), /* MISO */
  940. SUNXI_FUNCTION(0x3, "uart6")), /* RX */
  941. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI14,
  942. SUNXI_FUNCTION(0x0, "gpio_in"),
  943. SUNXI_FUNCTION(0x1, "gpio_out"),
  944. SUNXI_FUNCTION(0x2, "spi0"), /* CS1 */
  945. SUNXI_FUNCTION(0x3, "ps2"), /* SCK1 */
  946. SUNXI_FUNCTION(0x4, "timer4")), /* TCLKIN0 */
  947. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI15,
  948. SUNXI_FUNCTION(0x0, "gpio_in"),
  949. SUNXI_FUNCTION(0x1, "gpio_out"),
  950. SUNXI_FUNCTION(0x2, "spi1"), /* CS1 */
  951. SUNXI_FUNCTION(0x3, "ps2"), /* SDA1 */
  952. SUNXI_FUNCTION(0x4, "timer5")), /* TCLKIN1 */
  953. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI16,
  954. SUNXI_FUNCTION(0x0, "gpio_in"),
  955. SUNXI_FUNCTION(0x1, "gpio_out"),
  956. SUNXI_FUNCTION(0x2, "spi1"), /* CS0 */
  957. SUNXI_FUNCTION(0x3, "uart2")), /* RTS */
  958. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI17,
  959. SUNXI_FUNCTION(0x0, "gpio_in"),
  960. SUNXI_FUNCTION(0x1, "gpio_out"),
  961. SUNXI_FUNCTION(0x2, "spi1"), /* CLK */
  962. SUNXI_FUNCTION(0x3, "uart2")), /* CTS */
  963. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI18,
  964. SUNXI_FUNCTION(0x0, "gpio_in"),
  965. SUNXI_FUNCTION(0x1, "gpio_out"),
  966. SUNXI_FUNCTION(0x2, "spi1"), /* MOSI */
  967. SUNXI_FUNCTION(0x3, "uart2")), /* TX */
  968. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI19,
  969. SUNXI_FUNCTION(0x0, "gpio_in"),
  970. SUNXI_FUNCTION(0x1, "gpio_out"),
  971. SUNXI_FUNCTION(0x2, "spi1"), /* MISO */
  972. SUNXI_FUNCTION(0x3, "uart2")), /* RX */
  973. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI20,
  974. SUNXI_FUNCTION(0x0, "gpio_in"),
  975. SUNXI_FUNCTION(0x1, "gpio_out"),
  976. SUNXI_FUNCTION(0x2, "ps2"), /* SCK0 */
  977. SUNXI_FUNCTION(0x3, "uart7"), /* TX */
  978. SUNXI_FUNCTION(0x4, "hdmi")), /* HSCL */
  979. SUNXI_PIN(SUNXI_PINCTRL_PIN_PI21,
  980. SUNXI_FUNCTION(0x0, "gpio_in"),
  981. SUNXI_FUNCTION(0x1, "gpio_out"),
  982. SUNXI_FUNCTION(0x2, "ps2"), /* SDA0 */
  983. SUNXI_FUNCTION(0x3, "uart7"), /* RX */
  984. SUNXI_FUNCTION(0x4, "hdmi")), /* HSDA */
  985. };
  986. static const struct sunxi_desc_pin sun5i_a13_pins[] = {
  987. /* Hole */
  988. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB0,
  989. SUNXI_FUNCTION(0x0, "gpio_in"),
  990. SUNXI_FUNCTION(0x1, "gpio_out"),
  991. SUNXI_FUNCTION(0x2, "i2c0")), /* SCK */
  992. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB1,
  993. SUNXI_FUNCTION(0x0, "gpio_in"),
  994. SUNXI_FUNCTION(0x1, "gpio_out"),
  995. SUNXI_FUNCTION(0x2, "i2c0")), /* SDA */
  996. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB2,
  997. SUNXI_FUNCTION(0x0, "gpio_in"),
  998. SUNXI_FUNCTION(0x1, "gpio_out"),
  999. SUNXI_FUNCTION(0x2, "pwm")),
  1000. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB3,
  1001. SUNXI_FUNCTION(0x0, "gpio_in"),
  1002. SUNXI_FUNCTION(0x1, "gpio_out"),
  1003. SUNXI_FUNCTION(0x2, "ir0")), /* TX */
  1004. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB4,
  1005. SUNXI_FUNCTION(0x0, "gpio_in"),
  1006. SUNXI_FUNCTION(0x1, "gpio_out"),
  1007. SUNXI_FUNCTION(0x2, "ir0")), /* RX */
  1008. /* Hole */
  1009. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB10,
  1010. SUNXI_FUNCTION(0x0, "gpio_in"),
  1011. SUNXI_FUNCTION(0x1, "gpio_out"),
  1012. SUNXI_FUNCTION(0x2, "spi2")), /* CS1 */
  1013. /* Hole */
  1014. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB15,
  1015. SUNXI_FUNCTION(0x0, "gpio_in"),
  1016. SUNXI_FUNCTION(0x1, "gpio_out"),
  1017. SUNXI_FUNCTION(0x2, "i2c1")), /* SCK */
  1018. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB16,
  1019. SUNXI_FUNCTION(0x0, "gpio_in"),
  1020. SUNXI_FUNCTION(0x1, "gpio_out"),
  1021. SUNXI_FUNCTION(0x2, "i2c1")), /* SDA */
  1022. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB17,
  1023. SUNXI_FUNCTION(0x0, "gpio_in"),
  1024. SUNXI_FUNCTION(0x1, "gpio_out"),
  1025. SUNXI_FUNCTION(0x2, "i2c2")), /* SCK */
  1026. SUNXI_PIN(SUNXI_PINCTRL_PIN_PB18,
  1027. SUNXI_FUNCTION(0x0, "gpio_in"),
  1028. SUNXI_FUNCTION(0x1, "gpio_out"),
  1029. SUNXI_FUNCTION(0x2, "i2c2")), /* SDA */
  1030. /* Hole */
  1031. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC0,
  1032. SUNXI_FUNCTION(0x0, "gpio_in"),
  1033. SUNXI_FUNCTION(0x1, "gpio_out"),
  1034. SUNXI_FUNCTION(0x2, "nand0"), /* NWE */
  1035. SUNXI_FUNCTION(0x3, "spi0")), /* MOSI */
  1036. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC1,
  1037. SUNXI_FUNCTION(0x0, "gpio_in"),
  1038. SUNXI_FUNCTION(0x1, "gpio_out"),
  1039. SUNXI_FUNCTION(0x2, "nand0"), /* NALE */
  1040. SUNXI_FUNCTION(0x3, "spi0")), /* MISO */
  1041. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC2,
  1042. SUNXI_FUNCTION(0x0, "gpio_in"),
  1043. SUNXI_FUNCTION(0x1, "gpio_out"),
  1044. SUNXI_FUNCTION(0x2, "nand0"), /* NCLE */
  1045. SUNXI_FUNCTION(0x3, "spi0")), /* CLK */
  1046. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC3,
  1047. SUNXI_FUNCTION(0x0, "gpio_in"),
  1048. SUNXI_FUNCTION(0x1, "gpio_out"),
  1049. SUNXI_FUNCTION(0x2, "nand0"), /* NCE1 */
  1050. SUNXI_FUNCTION(0x3, "spi0")), /* CS0 */
  1051. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC4,
  1052. SUNXI_FUNCTION(0x0, "gpio_in"),
  1053. SUNXI_FUNCTION(0x1, "gpio_out"),
  1054. SUNXI_FUNCTION(0x2, "nand0")), /* NCE0 */
  1055. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC5,
  1056. SUNXI_FUNCTION(0x0, "gpio_in"),
  1057. SUNXI_FUNCTION(0x1, "gpio_out"),
  1058. SUNXI_FUNCTION(0x2, "nand0")), /* NRE */
  1059. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC6,
  1060. SUNXI_FUNCTION(0x0, "gpio_in"),
  1061. SUNXI_FUNCTION(0x1, "gpio_out"),
  1062. SUNXI_FUNCTION(0x2, "nand0"), /* NRB0 */
  1063. SUNXI_FUNCTION(0x3, "mmc2")), /* CMD */
  1064. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC7,
  1065. SUNXI_FUNCTION(0x0, "gpio_in"),
  1066. SUNXI_FUNCTION(0x1, "gpio_out"),
  1067. SUNXI_FUNCTION(0x2, "nand0"), /* NRB1 */
  1068. SUNXI_FUNCTION(0x3, "mmc2")), /* CLK */
  1069. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC8,
  1070. SUNXI_FUNCTION(0x0, "gpio_in"),
  1071. SUNXI_FUNCTION(0x1, "gpio_out"),
  1072. SUNXI_FUNCTION(0x2, "nand0"), /* NDQ0 */
  1073. SUNXI_FUNCTION(0x3, "mmc2")), /* D0 */
  1074. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC9,
  1075. SUNXI_FUNCTION(0x0, "gpio_in"),
  1076. SUNXI_FUNCTION(0x1, "gpio_out"),
  1077. SUNXI_FUNCTION(0x2, "nand0"), /* NDQ1 */
  1078. SUNXI_FUNCTION(0x3, "mmc2")), /* D1 */
  1079. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC10,
  1080. SUNXI_FUNCTION(0x0, "gpio_in"),
  1081. SUNXI_FUNCTION(0x1, "gpio_out"),
  1082. SUNXI_FUNCTION(0x2, "nand0"), /* NDQ2 */
  1083. SUNXI_FUNCTION(0x3, "mmc2")), /* D2 */
  1084. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC11,
  1085. SUNXI_FUNCTION(0x0, "gpio_in"),
  1086. SUNXI_FUNCTION(0x1, "gpio_out"),
  1087. SUNXI_FUNCTION(0x2, "nand0"), /* NDQ3 */
  1088. SUNXI_FUNCTION(0x3, "mmc2")), /* D3 */
  1089. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC12,
  1090. SUNXI_FUNCTION(0x0, "gpio_in"),
  1091. SUNXI_FUNCTION(0x1, "gpio_out"),
  1092. SUNXI_FUNCTION(0x2, "nand0"), /* NDQ4 */
  1093. SUNXI_FUNCTION(0x3, "mmc2")), /* D4 */
  1094. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC13,
  1095. SUNXI_FUNCTION(0x0, "gpio_in"),
  1096. SUNXI_FUNCTION(0x1, "gpio_out"),
  1097. SUNXI_FUNCTION(0x2, "nand0"), /* NDQ5 */
  1098. SUNXI_FUNCTION(0x3, "mmc2")), /* D5 */
  1099. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC14,
  1100. SUNXI_FUNCTION(0x0, "gpio_in"),
  1101. SUNXI_FUNCTION(0x1, "gpio_out"),
  1102. SUNXI_FUNCTION(0x2, "nand0"), /* NDQ6 */
  1103. SUNXI_FUNCTION(0x3, "mmc2")), /* D6 */
  1104. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC15,
  1105. SUNXI_FUNCTION(0x0, "gpio_in"),
  1106. SUNXI_FUNCTION(0x1, "gpio_out"),
  1107. SUNXI_FUNCTION(0x2, "nand0"), /* NDQ7 */
  1108. SUNXI_FUNCTION(0x3, "mmc2")), /* D7 */
  1109. /* Hole */
  1110. SUNXI_PIN(SUNXI_PINCTRL_PIN_PC19,
  1111. SUNXI_FUNCTION(0x0, "gpio_in"),
  1112. SUNXI_FUNCTION(0x1, "gpio_out"),
  1113. SUNXI_FUNCTION(0x2, "nand0"), /* NDQS */
  1114. SUNXI_FUNCTION(0x4, "uart3")), /* RTS */
  1115. /* Hole */
  1116. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD2,
  1117. SUNXI_FUNCTION(0x0, "gpio_in"),
  1118. SUNXI_FUNCTION(0x1, "gpio_out"),
  1119. SUNXI_FUNCTION(0x2, "lcd0")), /* D2 */
  1120. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD3,
  1121. SUNXI_FUNCTION(0x0, "gpio_in"),
  1122. SUNXI_FUNCTION(0x1, "gpio_out"),
  1123. SUNXI_FUNCTION(0x2, "lcd0")), /* D3 */
  1124. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD4,
  1125. SUNXI_FUNCTION(0x0, "gpio_in"),
  1126. SUNXI_FUNCTION(0x1, "gpio_out"),
  1127. SUNXI_FUNCTION(0x2, "lcd0")), /* D4 */
  1128. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD5,
  1129. SUNXI_FUNCTION(0x0, "gpio_in"),
  1130. SUNXI_FUNCTION(0x1, "gpio_out"),
  1131. SUNXI_FUNCTION(0x2, "lcd0")), /* D5 */
  1132. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD6,
  1133. SUNXI_FUNCTION(0x0, "gpio_in"),
  1134. SUNXI_FUNCTION(0x1, "gpio_out"),
  1135. SUNXI_FUNCTION(0x2, "lcd0")), /* D6 */
  1136. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD7,
  1137. SUNXI_FUNCTION(0x0, "gpio_in"),
  1138. SUNXI_FUNCTION(0x1, "gpio_out"),
  1139. SUNXI_FUNCTION(0x2, "lcd0")), /* D7 */
  1140. /* Hole */
  1141. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD10,
  1142. SUNXI_FUNCTION(0x0, "gpio_in"),
  1143. SUNXI_FUNCTION(0x1, "gpio_out"),
  1144. SUNXI_FUNCTION(0x2, "lcd0")), /* D10 */
  1145. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD11,
  1146. SUNXI_FUNCTION(0x0, "gpio_in"),
  1147. SUNXI_FUNCTION(0x1, "gpio_out"),
  1148. SUNXI_FUNCTION(0x2, "lcd0")), /* D11 */
  1149. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD12,
  1150. SUNXI_FUNCTION(0x0, "gpio_in"),
  1151. SUNXI_FUNCTION(0x1, "gpio_out"),
  1152. SUNXI_FUNCTION(0x2, "lcd0")), /* D12 */
  1153. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD13,
  1154. SUNXI_FUNCTION(0x0, "gpio_in"),
  1155. SUNXI_FUNCTION(0x1, "gpio_out"),
  1156. SUNXI_FUNCTION(0x2, "lcd0")), /* D13 */
  1157. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD14,
  1158. SUNXI_FUNCTION(0x0, "gpio_in"),
  1159. SUNXI_FUNCTION(0x1, "gpio_out"),
  1160. SUNXI_FUNCTION(0x2, "lcd0")), /* D14 */
  1161. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD15,
  1162. SUNXI_FUNCTION(0x0, "gpio_in"),
  1163. SUNXI_FUNCTION(0x1, "gpio_out"),
  1164. SUNXI_FUNCTION(0x2, "lcd0")), /* D15 */
  1165. /* Hole */
  1166. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD18,
  1167. SUNXI_FUNCTION(0x0, "gpio_in"),
  1168. SUNXI_FUNCTION(0x1, "gpio_out"),
  1169. SUNXI_FUNCTION(0x2, "lcd0")), /* D18 */
  1170. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD19,
  1171. SUNXI_FUNCTION(0x0, "gpio_in"),
  1172. SUNXI_FUNCTION(0x1, "gpio_out"),
  1173. SUNXI_FUNCTION(0x2, "lcd0")), /* D19 */
  1174. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD20,
  1175. SUNXI_FUNCTION(0x0, "gpio_in"),
  1176. SUNXI_FUNCTION(0x1, "gpio_out"),
  1177. SUNXI_FUNCTION(0x2, "lcd0")), /* D20 */
  1178. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD21,
  1179. SUNXI_FUNCTION(0x0, "gpio_in"),
  1180. SUNXI_FUNCTION(0x1, "gpio_out"),
  1181. SUNXI_FUNCTION(0x2, "lcd0")), /* D21 */
  1182. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD22,
  1183. SUNXI_FUNCTION(0x0, "gpio_in"),
  1184. SUNXI_FUNCTION(0x1, "gpio_out"),
  1185. SUNXI_FUNCTION(0x2, "lcd0")), /* D22 */
  1186. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD23,
  1187. SUNXI_FUNCTION(0x0, "gpio_in"),
  1188. SUNXI_FUNCTION(0x1, "gpio_out"),
  1189. SUNXI_FUNCTION(0x2, "lcd0")), /* D23 */
  1190. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD24,
  1191. SUNXI_FUNCTION(0x0, "gpio_in"),
  1192. SUNXI_FUNCTION(0x1, "gpio_out"),
  1193. SUNXI_FUNCTION(0x2, "lcd0")), /* CLK */
  1194. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD25,
  1195. SUNXI_FUNCTION(0x0, "gpio_in"),
  1196. SUNXI_FUNCTION(0x1, "gpio_out"),
  1197. SUNXI_FUNCTION(0x2, "lcd0")), /* DE */
  1198. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD26,
  1199. SUNXI_FUNCTION(0x0, "gpio_in"),
  1200. SUNXI_FUNCTION(0x1, "gpio_out"),
  1201. SUNXI_FUNCTION(0x2, "lcd0")), /* HSYNC */
  1202. SUNXI_PIN(SUNXI_PINCTRL_PIN_PD27,
  1203. SUNXI_FUNCTION(0x0, "gpio_in"),
  1204. SUNXI_FUNCTION(0x1, "gpio_out"),
  1205. SUNXI_FUNCTION(0x2, "lcd0")), /* VSYNC */
  1206. /* Hole */
  1207. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE0,
  1208. SUNXI_FUNCTION(0x0, "gpio_in"),
  1209. SUNXI_FUNCTION(0x3, "csi0"), /* PCLK */
  1210. SUNXI_FUNCTION(0x4, "spi2")), /* CS0 */
  1211. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE1,
  1212. SUNXI_FUNCTION(0x0, "gpio_in"),
  1213. SUNXI_FUNCTION(0x3, "csi0"), /* MCLK */
  1214. SUNXI_FUNCTION(0x4, "spi2")), /* CLK */
  1215. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE2,
  1216. SUNXI_FUNCTION(0x0, "gpio_in"),
  1217. SUNXI_FUNCTION(0x3, "csi0"), /* HSYNC */
  1218. SUNXI_FUNCTION(0x4, "spi2")), /* MOSI */
  1219. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE3,
  1220. SUNXI_FUNCTION(0x0, "gpio_in"),
  1221. SUNXI_FUNCTION(0x1, "gpio_out"),
  1222. SUNXI_FUNCTION(0x3, "csi0"), /* VSYNC */
  1223. SUNXI_FUNCTION(0x4, "spi2")), /* MISO */
  1224. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE4,
  1225. SUNXI_FUNCTION(0x0, "gpio_in"),
  1226. SUNXI_FUNCTION(0x1, "gpio_out"),
  1227. SUNXI_FUNCTION(0x3, "csi0"), /* D0 */
  1228. SUNXI_FUNCTION(0x4, "mmc2")), /* D0 */
  1229. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE5,
  1230. SUNXI_FUNCTION(0x0, "gpio_in"),
  1231. SUNXI_FUNCTION(0x1, "gpio_out"),
  1232. SUNXI_FUNCTION(0x3, "csi0"), /* D1 */
  1233. SUNXI_FUNCTION(0x4, "mmc2")), /* D1 */
  1234. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE6,
  1235. SUNXI_FUNCTION(0x0, "gpio_in"),
  1236. SUNXI_FUNCTION(0x1, "gpio_out"),
  1237. SUNXI_FUNCTION(0x3, "csi0"), /* D2 */
  1238. SUNXI_FUNCTION(0x4, "mmc2")), /* D2 */
  1239. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE7,
  1240. SUNXI_FUNCTION(0x0, "gpio_in"),
  1241. SUNXI_FUNCTION(0x1, "gpio_out"),
  1242. SUNXI_FUNCTION(0x3, "csi0"), /* D3 */
  1243. SUNXI_FUNCTION(0x4, "mmc2")), /* D3 */
  1244. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE8,
  1245. SUNXI_FUNCTION(0x0, "gpio_in"),
  1246. SUNXI_FUNCTION(0x1, "gpio_out"),
  1247. SUNXI_FUNCTION(0x3, "csi0"), /* D4 */
  1248. SUNXI_FUNCTION(0x4, "mmc2")), /* CMD */
  1249. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE9,
  1250. SUNXI_FUNCTION(0x0, "gpio_in"),
  1251. SUNXI_FUNCTION(0x1, "gpio_out"),
  1252. SUNXI_FUNCTION(0x3, "csi0"), /* D5 */
  1253. SUNXI_FUNCTION(0x4, "mmc2")), /* CLK */
  1254. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE10,
  1255. SUNXI_FUNCTION(0x0, "gpio_in"),
  1256. SUNXI_FUNCTION(0x1, "gpio_out"),
  1257. SUNXI_FUNCTION(0x3, "csi0"), /* D6 */
  1258. SUNXI_FUNCTION(0x4, "uart1")), /* TX */
  1259. SUNXI_PIN(SUNXI_PINCTRL_PIN_PE11,
  1260. SUNXI_FUNCTION(0x0, "gpio_in"),
  1261. SUNXI_FUNCTION(0x1, "gpio_out"),
  1262. SUNXI_FUNCTION(0x3, "csi0"), /* D7 */
  1263. SUNXI_FUNCTION(0x4, "uart1")), /* RX */
  1264. /* Hole */
  1265. SUNXI_PIN(SUNXI_PINCTRL_PIN_PF0,
  1266. SUNXI_FUNCTION(0x0, "gpio_in"),
  1267. SUNXI_FUNCTION(0x1, "gpio_out"),
  1268. SUNXI_FUNCTION(0x4, "mmc0")), /* D1 */
  1269. SUNXI_PIN(SUNXI_PINCTRL_PIN_PF1,
  1270. SUNXI_FUNCTION(0x0, "gpio_in"),
  1271. SUNXI_FUNCTION(0x1, "gpio_out"),
  1272. SUNXI_FUNCTION(0x4, "mmc0")), /* D0 */
  1273. SUNXI_PIN(SUNXI_PINCTRL_PIN_PF2,
  1274. SUNXI_FUNCTION(0x0, "gpio_in"),
  1275. SUNXI_FUNCTION(0x1, "gpio_out"),
  1276. SUNXI_FUNCTION(0x4, "mmc0")), /* CLK */
  1277. SUNXI_PIN(SUNXI_PINCTRL_PIN_PF3,
  1278. SUNXI_FUNCTION(0x0, "gpio_in"),
  1279. SUNXI_FUNCTION(0x1, "gpio_out"),
  1280. SUNXI_FUNCTION(0x4, "mmc0")), /* CMD */
  1281. SUNXI_PIN(SUNXI_PINCTRL_PIN_PF4,
  1282. SUNXI_FUNCTION(0x0, "gpio_in"),
  1283. SUNXI_FUNCTION(0x1, "gpio_out"),
  1284. SUNXI_FUNCTION(0x4, "mmc0")), /* D3 */
  1285. SUNXI_PIN(SUNXI_PINCTRL_PIN_PF5,
  1286. SUNXI_FUNCTION(0x0, "gpio_in"),
  1287. SUNXI_FUNCTION(0x1, "gpio_out"),
  1288. SUNXI_FUNCTION(0x4, "mmc0")), /* D2 */
  1289. /* Hole */
  1290. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG0,
  1291. SUNXI_FUNCTION(0x0, "gpio_in"),
  1292. SUNXI_FUNCTION(0x1, "gpio_out")),
  1293. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG1,
  1294. SUNXI_FUNCTION(0x0, "gpio_in"),
  1295. SUNXI_FUNCTION(0x1, "gpio_out")),
  1296. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG2,
  1297. SUNXI_FUNCTION(0x0, "gpio_in"),
  1298. SUNXI_FUNCTION(0x1, "gpio_out")),
  1299. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG3,
  1300. SUNXI_FUNCTION(0x0, "gpio_in"),
  1301. SUNXI_FUNCTION(0x1, "gpio_out"),
  1302. SUNXI_FUNCTION(0x2, "mmc1"), /* CMD */
  1303. SUNXI_FUNCTION(0x4, "uart1")), /* TX */
  1304. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG4,
  1305. SUNXI_FUNCTION(0x0, "gpio_in"),
  1306. SUNXI_FUNCTION(0x1, "gpio_out"),
  1307. SUNXI_FUNCTION(0x2, "mmc1"), /* CLK */
  1308. SUNXI_FUNCTION(0x4, "uart1")), /* RX */
  1309. /* Hole */
  1310. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG9,
  1311. SUNXI_FUNCTION(0x0, "gpio_in"),
  1312. SUNXI_FUNCTION(0x1, "gpio_out"),
  1313. SUNXI_FUNCTION(0x2, "spi1"), /* CS0 */
  1314. SUNXI_FUNCTION(0x3, "uart3")), /* TX */
  1315. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG10,
  1316. SUNXI_FUNCTION(0x0, "gpio_in"),
  1317. SUNXI_FUNCTION(0x1, "gpio_out"),
  1318. SUNXI_FUNCTION(0x2, "spi1"), /* CLK */
  1319. SUNXI_FUNCTION(0x3, "uart3")), /* RX */
  1320. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG11,
  1321. SUNXI_FUNCTION(0x0, "gpio_in"),
  1322. SUNXI_FUNCTION(0x1, "gpio_out"),
  1323. SUNXI_FUNCTION(0x2, "spi1"), /* MOSI */
  1324. SUNXI_FUNCTION(0x3, "uart3")), /* CTS */
  1325. SUNXI_PIN(SUNXI_PINCTRL_PIN_PG12,
  1326. SUNXI_FUNCTION(0x0, "gpio_in"),
  1327. SUNXI_FUNCTION(0x1, "gpio_out"),
  1328. SUNXI_FUNCTION(0x2, "spi1"), /* MISO */
  1329. SUNXI_FUNCTION(0x3, "uart3")), /* RTS */
  1330. };
  1331. static const struct sunxi_pinctrl_desc sun4i_a10_pinctrl_data = {
  1332. .pins = sun4i_a10_pins,
  1333. .npins = ARRAY_SIZE(sun4i_a10_pins),
  1334. };
  1335. static const struct sunxi_pinctrl_desc sun5i_a13_pinctrl_data = {
  1336. .pins = sun5i_a13_pins,
  1337. .npins = ARRAY_SIZE(sun5i_a13_pins),
  1338. };
  1339. static struct sunxi_pinctrl_group *
  1340. sunxi_pinctrl_find_group_by_name(struct sunxi_pinctrl *pctl, const char *group)
  1341. {
  1342. int i;
  1343. for (i = 0; i < pctl->ngroups; i++) {
  1344. struct sunxi_pinctrl_group *grp = pctl->groups + i;
  1345. if (!strcmp(grp->name, group))
  1346. return grp;
  1347. }
  1348. return NULL;
  1349. }
  1350. static struct sunxi_pinctrl_function *
  1351. sunxi_pinctrl_find_function_by_name(struct sunxi_pinctrl *pctl,
  1352. const char *name)
  1353. {
  1354. struct sunxi_pinctrl_function *func = pctl->functions;
  1355. int i;
  1356. for (i = 0; i < pctl->nfunctions; i++) {
  1357. if (!func[i].name)
  1358. break;
  1359. if (!strcmp(func[i].name, name))
  1360. return func + i;
  1361. }
  1362. return NULL;
  1363. }
  1364. static struct sunxi_desc_function *
  1365. sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl,
  1366. const char *pin_name,
  1367. const char *func_name)
  1368. {
  1369. int i;
  1370. for (i = 0; i < pctl->desc->npins; i++) {
  1371. const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
  1372. if (!strcmp(pin->pin.name, pin_name)) {
  1373. struct sunxi_desc_function *func = pin->functions;
  1374. while (func->name) {
  1375. if (!strcmp(func->name, func_name))
  1376. return func;
  1377. func++;
  1378. }
  1379. }
  1380. }
  1381. return NULL;
  1382. }
  1383. static struct sunxi_desc_function *
  1384. sunxi_pinctrl_desc_find_function_by_pin(struct sunxi_pinctrl *pctl,
  1385. const u16 pin_num,
  1386. const char *func_name)
  1387. {
  1388. int i;
  1389. for (i = 0; i < pctl->desc->npins; i++) {
  1390. const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
  1391. if (pin->pin.number == pin_num) {
  1392. struct sunxi_desc_function *func = pin->functions;
  1393. while (func->name) {
  1394. if (!strcmp(func->name, func_name))
  1395. return func;
  1396. func++;
  1397. }
  1398. }
  1399. }
  1400. return NULL;
  1401. }
  1402. static int sunxi_pctrl_get_groups_count(struct pinctrl_dev *pctldev)
  1403. {
  1404. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1405. return pctl->ngroups;
  1406. }
  1407. static const char *sunxi_pctrl_get_group_name(struct pinctrl_dev *pctldev,
  1408. unsigned group)
  1409. {
  1410. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1411. return pctl->groups[group].name;
  1412. }
  1413. static int sunxi_pctrl_get_group_pins(struct pinctrl_dev *pctldev,
  1414. unsigned group,
  1415. const unsigned **pins,
  1416. unsigned *num_pins)
  1417. {
  1418. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1419. *pins = (unsigned *)&pctl->groups[group].pin;
  1420. *num_pins = 1;
  1421. return 0;
  1422. }
  1423. static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
  1424. struct device_node *node,
  1425. struct pinctrl_map **map,
  1426. unsigned *num_maps)
  1427. {
  1428. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1429. unsigned long *pinconfig;
  1430. struct property *prop;
  1431. const char *function;
  1432. const char *group;
  1433. int ret, nmaps, i = 0;
  1434. u32 val;
  1435. *map = NULL;
  1436. *num_maps = 0;
  1437. ret = of_property_read_string(node, "allwinner,function", &function);
  1438. if (ret) {
  1439. dev_err(pctl->dev,
  1440. "missing allwinner,function property in node %s\n",
  1441. node->name);
  1442. return -EINVAL;
  1443. }
  1444. nmaps = of_property_count_strings(node, "allwinner,pins") * 2;
  1445. if (nmaps < 0) {
  1446. dev_err(pctl->dev,
  1447. "missing allwinner,pins property in node %s\n",
  1448. node->name);
  1449. return -EINVAL;
  1450. }
  1451. *map = kmalloc(nmaps * sizeof(struct pinctrl_map), GFP_KERNEL);
  1452. if (!map)
  1453. return -ENOMEM;
  1454. of_property_for_each_string(node, "allwinner,pins", prop, group) {
  1455. struct sunxi_pinctrl_group *grp =
  1456. sunxi_pinctrl_find_group_by_name(pctl, group);
  1457. int j = 0, configlen = 0;
  1458. if (!grp) {
  1459. dev_err(pctl->dev, "unknown pin %s", group);
  1460. continue;
  1461. }
  1462. if (!sunxi_pinctrl_desc_find_function_by_name(pctl,
  1463. grp->name,
  1464. function)) {
  1465. dev_err(pctl->dev, "unsupported function %s on pin %s",
  1466. function, group);
  1467. continue;
  1468. }
  1469. (*map)[i].type = PIN_MAP_TYPE_MUX_GROUP;
  1470. (*map)[i].data.mux.group = group;
  1471. (*map)[i].data.mux.function = function;
  1472. i++;
  1473. (*map)[i].type = PIN_MAP_TYPE_CONFIGS_GROUP;
  1474. (*map)[i].data.configs.group_or_pin = group;
  1475. if (of_find_property(node, "allwinner,drive", NULL))
  1476. configlen++;
  1477. if (of_find_property(node, "allwinner,pull", NULL))
  1478. configlen++;
  1479. pinconfig = kzalloc(configlen * sizeof(*pinconfig), GFP_KERNEL);
  1480. if (!of_property_read_u32(node, "allwinner,drive", &val)) {
  1481. u16 strength = (val + 1) * 10;
  1482. pinconfig[j++] =
  1483. pinconf_to_config_packed(PIN_CONFIG_DRIVE_STRENGTH,
  1484. strength);
  1485. }
  1486. if (!of_property_read_u32(node, "allwinner,pull", &val)) {
  1487. enum pin_config_param pull = PIN_CONFIG_END;
  1488. if (val == 1)
  1489. pull = PIN_CONFIG_BIAS_PULL_UP;
  1490. else if (val == 2)
  1491. pull = PIN_CONFIG_BIAS_PULL_DOWN;
  1492. pinconfig[j++] = pinconf_to_config_packed(pull, 0);
  1493. }
  1494. (*map)[i].data.configs.configs = pinconfig;
  1495. (*map)[i].data.configs.num_configs = configlen;
  1496. i++;
  1497. }
  1498. *num_maps = nmaps;
  1499. return 0;
  1500. }
  1501. static void sunxi_pctrl_dt_free_map(struct pinctrl_dev *pctldev,
  1502. struct pinctrl_map *map,
  1503. unsigned num_maps)
  1504. {
  1505. int i;
  1506. for (i = 0; i < num_maps; i++) {
  1507. if (map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP)
  1508. kfree(map[i].data.configs.configs);
  1509. }
  1510. kfree(map);
  1511. }
  1512. static const struct pinctrl_ops sunxi_pctrl_ops = {
  1513. .dt_node_to_map = sunxi_pctrl_dt_node_to_map,
  1514. .dt_free_map = sunxi_pctrl_dt_free_map,
  1515. .get_groups_count = sunxi_pctrl_get_groups_count,
  1516. .get_group_name = sunxi_pctrl_get_group_name,
  1517. .get_group_pins = sunxi_pctrl_get_group_pins,
  1518. };
  1519. static int sunxi_pconf_group_get(struct pinctrl_dev *pctldev,
  1520. unsigned group,
  1521. unsigned long *config)
  1522. {
  1523. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1524. *config = pctl->groups[group].config;
  1525. return 0;
  1526. }
  1527. static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev,
  1528. unsigned group,
  1529. unsigned long config)
  1530. {
  1531. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1532. struct sunxi_pinctrl_group *g = &pctl->groups[group];
  1533. u32 val, mask;
  1534. u16 strength;
  1535. u8 dlevel;
  1536. switch (pinconf_to_config_param(config)) {
  1537. case PIN_CONFIG_DRIVE_STRENGTH:
  1538. strength = pinconf_to_config_argument(config);
  1539. if (strength > 40)
  1540. return -EINVAL;
  1541. /*
  1542. * We convert from mA to what the register expects:
  1543. * 0: 10mA
  1544. * 1: 20mA
  1545. * 2: 30mA
  1546. * 3: 40mA
  1547. */
  1548. dlevel = strength / 10 - 1;
  1549. val = readl(pctl->membase + sunxi_dlevel_reg(g->pin));
  1550. mask = DLEVEL_PINS_MASK << sunxi_dlevel_offset(g->pin);
  1551. writel((val & ~mask) | dlevel << sunxi_dlevel_offset(g->pin),
  1552. pctl->membase + sunxi_dlevel_reg(g->pin));
  1553. break;
  1554. case PIN_CONFIG_BIAS_PULL_UP:
  1555. val = readl(pctl->membase + sunxi_pull_reg(g->pin));
  1556. mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin);
  1557. writel((val & ~mask) | 1 << sunxi_pull_offset(g->pin),
  1558. pctl->membase + sunxi_pull_reg(g->pin));
  1559. break;
  1560. case PIN_CONFIG_BIAS_PULL_DOWN:
  1561. val = readl(pctl->membase + sunxi_pull_reg(g->pin));
  1562. mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin);
  1563. writel((val & ~mask) | 2 << sunxi_pull_offset(g->pin),
  1564. pctl->membase + sunxi_pull_reg(g->pin));
  1565. break;
  1566. default:
  1567. break;
  1568. }
  1569. /* cache the config value */
  1570. g->config = config;
  1571. return 0;
  1572. }
  1573. static const struct pinconf_ops sunxi_pconf_ops = {
  1574. .pin_config_group_get = sunxi_pconf_group_get,
  1575. .pin_config_group_set = sunxi_pconf_group_set,
  1576. };
  1577. static int sunxi_pmx_get_funcs_cnt(struct pinctrl_dev *pctldev)
  1578. {
  1579. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1580. return pctl->nfunctions;
  1581. }
  1582. static const char *sunxi_pmx_get_func_name(struct pinctrl_dev *pctldev,
  1583. unsigned function)
  1584. {
  1585. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1586. return pctl->functions[function].name;
  1587. }
  1588. static int sunxi_pmx_get_func_groups(struct pinctrl_dev *pctldev,
  1589. unsigned function,
  1590. const char * const **groups,
  1591. unsigned * const num_groups)
  1592. {
  1593. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1594. *groups = pctl->functions[function].groups;
  1595. *num_groups = pctl->functions[function].ngroups;
  1596. return 0;
  1597. }
  1598. static void sunxi_pmx_set(struct pinctrl_dev *pctldev,
  1599. unsigned pin,
  1600. u8 config)
  1601. {
  1602. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1603. u32 val = readl(pctl->membase + sunxi_mux_reg(pin));
  1604. u32 mask = MUX_PINS_MASK << sunxi_mux_offset(pin);
  1605. writel((val & ~mask) | config << sunxi_mux_offset(pin),
  1606. pctl->membase + sunxi_mux_reg(pin));
  1607. }
  1608. static int sunxi_pmx_enable(struct pinctrl_dev *pctldev,
  1609. unsigned function,
  1610. unsigned group)
  1611. {
  1612. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1613. struct sunxi_pinctrl_group *g = pctl->groups + group;
  1614. struct sunxi_pinctrl_function *func = pctl->functions + function;
  1615. struct sunxi_desc_function *desc =
  1616. sunxi_pinctrl_desc_find_function_by_name(pctl,
  1617. g->name,
  1618. func->name);
  1619. if (!desc)
  1620. return -EINVAL;
  1621. sunxi_pmx_set(pctldev, g->pin, desc->muxval);
  1622. return 0;
  1623. }
  1624. static int
  1625. sunxi_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
  1626. struct pinctrl_gpio_range *range,
  1627. unsigned offset,
  1628. bool input)
  1629. {
  1630. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1631. struct sunxi_desc_function *desc;
  1632. const char *func;
  1633. if (input)
  1634. func = "gpio_in";
  1635. else
  1636. func = "gpio_out";
  1637. desc = sunxi_pinctrl_desc_find_function_by_pin(pctl, offset, func);
  1638. if (!desc)
  1639. return -EINVAL;
  1640. sunxi_pmx_set(pctldev, offset, desc->muxval);
  1641. return 0;
  1642. }
  1643. static const struct pinmux_ops sunxi_pmx_ops = {
  1644. .get_functions_count = sunxi_pmx_get_funcs_cnt,
  1645. .get_function_name = sunxi_pmx_get_func_name,
  1646. .get_function_groups = sunxi_pmx_get_func_groups,
  1647. .enable = sunxi_pmx_enable,
  1648. .gpio_set_direction = sunxi_pmx_gpio_set_direction,
  1649. };
  1650. static struct pinctrl_desc sunxi_pctrl_desc = {
  1651. .confops = &sunxi_pconf_ops,
  1652. .pctlops = &sunxi_pctrl_ops,
  1653. .pmxops = &sunxi_pmx_ops,
  1654. };
  1655. static int sunxi_pinctrl_gpio_request(struct gpio_chip *chip, unsigned offset)
  1656. {
  1657. return pinctrl_request_gpio(chip->base + offset);
  1658. }
  1659. static void sunxi_pinctrl_gpio_free(struct gpio_chip *chip, unsigned offset)
  1660. {
  1661. pinctrl_free_gpio(chip->base + offset);
  1662. }
  1663. static int sunxi_pinctrl_gpio_direction_input(struct gpio_chip *chip,
  1664. unsigned offset)
  1665. {
  1666. return pinctrl_gpio_direction_input(chip->base + offset);
  1667. }
  1668. static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset)
  1669. {
  1670. struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev);
  1671. u32 reg = sunxi_data_reg(offset);
  1672. u8 index = sunxi_data_offset(offset);
  1673. u32 val = (readl(pctl->membase + reg) >> index) & DATA_PINS_MASK;
  1674. return val;
  1675. }
  1676. static int sunxi_pinctrl_gpio_direction_output(struct gpio_chip *chip,
  1677. unsigned offset, int value)
  1678. {
  1679. return pinctrl_gpio_direction_output(chip->base + offset);
  1680. }
  1681. static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip,
  1682. unsigned offset, int value)
  1683. {
  1684. struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev);
  1685. u32 reg = sunxi_data_reg(offset);
  1686. u8 index = sunxi_data_offset(offset);
  1687. writel((value & DATA_PINS_MASK) << index, pctl->membase + reg);
  1688. }
  1689. static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc,
  1690. const struct of_phandle_args *gpiospec,
  1691. u32 *flags)
  1692. {
  1693. int pin, base;
  1694. base = PINS_PER_BANK * gpiospec->args[0];
  1695. pin = base + gpiospec->args[1];
  1696. if (pin > (gc->base + gc->ngpio))
  1697. return -EINVAL;
  1698. if (flags)
  1699. *flags = gpiospec->args[2];
  1700. return pin;
  1701. }
  1702. static int sunxi_pinctrl_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
  1703. {
  1704. struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev);
  1705. struct sunxi_desc_function *desc;
  1706. if (offset > chip->ngpio)
  1707. return -ENXIO;
  1708. desc = sunxi_pinctrl_desc_find_function_by_pin(pctl, offset, "irq");
  1709. if (!desc)
  1710. return -EINVAL;
  1711. pctl->irq_array[desc->irqnum] = offset;
  1712. dev_dbg(chip->dev, "%s: request IRQ for GPIO %d, return %d\n",
  1713. chip->label, offset + chip->base, desc->irqnum);
  1714. return irq_find_mapping(pctl->domain, desc->irqnum);
  1715. }
  1716. static struct gpio_chip sunxi_pinctrl_gpio_chip = {
  1717. .owner = THIS_MODULE,
  1718. .request = sunxi_pinctrl_gpio_request,
  1719. .free = sunxi_pinctrl_gpio_free,
  1720. .direction_input = sunxi_pinctrl_gpio_direction_input,
  1721. .direction_output = sunxi_pinctrl_gpio_direction_output,
  1722. .get = sunxi_pinctrl_gpio_get,
  1723. .set = sunxi_pinctrl_gpio_set,
  1724. .of_xlate = sunxi_pinctrl_gpio_of_xlate,
  1725. .to_irq = sunxi_pinctrl_gpio_to_irq,
  1726. .of_gpio_n_cells = 3,
  1727. .can_sleep = 0,
  1728. };
  1729. static int sunxi_pinctrl_irq_set_type(struct irq_data *d,
  1730. unsigned int type)
  1731. {
  1732. struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
  1733. u32 reg = sunxi_irq_cfg_reg(d->hwirq);
  1734. u8 index = sunxi_irq_cfg_offset(d->hwirq);
  1735. u8 mode;
  1736. switch (type) {
  1737. case IRQ_TYPE_EDGE_RISING:
  1738. mode = IRQ_EDGE_RISING;
  1739. break;
  1740. case IRQ_TYPE_EDGE_FALLING:
  1741. mode = IRQ_EDGE_FALLING;
  1742. break;
  1743. case IRQ_TYPE_EDGE_BOTH:
  1744. mode = IRQ_EDGE_BOTH;
  1745. break;
  1746. case IRQ_TYPE_LEVEL_HIGH:
  1747. mode = IRQ_LEVEL_HIGH;
  1748. break;
  1749. case IRQ_TYPE_LEVEL_LOW:
  1750. mode = IRQ_LEVEL_LOW;
  1751. break;
  1752. default:
  1753. return -EINVAL;
  1754. }
  1755. writel((mode & IRQ_CFG_IRQ_MASK) << index, pctl->membase + reg);
  1756. return 0;
  1757. }
  1758. static void sunxi_pinctrl_irq_mask_ack(struct irq_data *d)
  1759. {
  1760. struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
  1761. u32 ctrl_reg = sunxi_irq_ctrl_reg(d->hwirq);
  1762. u8 ctrl_idx = sunxi_irq_ctrl_offset(d->hwirq);
  1763. u32 status_reg = sunxi_irq_status_reg(d->hwirq);
  1764. u8 status_idx = sunxi_irq_status_offset(d->hwirq);
  1765. u32 val;
  1766. /* Mask the IRQ */
  1767. val = readl(pctl->membase + ctrl_reg);
  1768. writel(val & ~(1 << ctrl_idx), pctl->membase + ctrl_reg);
  1769. /* Clear the IRQ */
  1770. writel(1 << status_idx, pctl->membase + status_reg);
  1771. }
  1772. static void sunxi_pinctrl_irq_mask(struct irq_data *d)
  1773. {
  1774. struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
  1775. u32 reg = sunxi_irq_ctrl_reg(d->hwirq);
  1776. u8 idx = sunxi_irq_ctrl_offset(d->hwirq);
  1777. u32 val;
  1778. /* Mask the IRQ */
  1779. val = readl(pctl->membase + reg);
  1780. writel(val & ~(1 << idx), pctl->membase + reg);
  1781. }
  1782. static void sunxi_pinctrl_irq_unmask(struct irq_data *d)
  1783. {
  1784. struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
  1785. struct sunxi_desc_function *func;
  1786. u32 reg = sunxi_irq_ctrl_reg(d->hwirq);
  1787. u8 idx = sunxi_irq_ctrl_offset(d->hwirq);
  1788. u32 val;
  1789. func = sunxi_pinctrl_desc_find_function_by_pin(pctl,
  1790. pctl->irq_array[d->hwirq],
  1791. "irq");
  1792. /* Change muxing to INT mode */
  1793. sunxi_pmx_set(pctl->pctl_dev, pctl->irq_array[d->hwirq], func->muxval);
  1794. /* Unmask the IRQ */
  1795. val = readl(pctl->membase + reg);
  1796. writel(val | (1 << idx), pctl->membase + reg);
  1797. }
  1798. static struct irq_chip sunxi_pinctrl_irq_chip = {
  1799. .irq_mask = sunxi_pinctrl_irq_mask,
  1800. .irq_mask_ack = sunxi_pinctrl_irq_mask_ack,
  1801. .irq_unmask = sunxi_pinctrl_irq_unmask,
  1802. .irq_set_type = sunxi_pinctrl_irq_set_type,
  1803. };
  1804. static void sunxi_pinctrl_irq_handler(unsigned irq, struct irq_desc *desc)
  1805. {
  1806. struct sunxi_pinctrl *pctl = irq_get_handler_data(irq);
  1807. const unsigned long reg = readl(pctl->membase + IRQ_STATUS_REG);
  1808. /* Clear all interrupts */
  1809. writel(reg, pctl->membase + IRQ_STATUS_REG);
  1810. if (reg) {
  1811. int irqoffset;
  1812. for_each_set_bit(irqoffset, &reg, SUNXI_IRQ_NUMBER) {
  1813. int pin_irq = irq_find_mapping(pctl->domain, irqoffset);
  1814. generic_handle_irq(pin_irq);
  1815. }
  1816. }
  1817. }
  1818. static struct of_device_id sunxi_pinctrl_match[] = {
  1819. { .compatible = "allwinner,sun4i-a10-pinctrl", .data = (void *)&sun4i_a10_pinctrl_data },
  1820. { .compatible = "allwinner,sun5i-a13-pinctrl", .data = (void *)&sun5i_a13_pinctrl_data },
  1821. {}
  1822. };
  1823. MODULE_DEVICE_TABLE(of, sunxi_pinctrl_match);
  1824. static int sunxi_pinctrl_add_function(struct sunxi_pinctrl *pctl,
  1825. const char *name)
  1826. {
  1827. struct sunxi_pinctrl_function *func = pctl->functions;
  1828. while (func->name) {
  1829. /* function already there */
  1830. if (strcmp(func->name, name) == 0) {
  1831. func->ngroups++;
  1832. return -EEXIST;
  1833. }
  1834. func++;
  1835. }
  1836. func->name = name;
  1837. func->ngroups = 1;
  1838. pctl->nfunctions++;
  1839. return 0;
  1840. }
  1841. static int sunxi_pinctrl_build_state(struct platform_device *pdev)
  1842. {
  1843. struct sunxi_pinctrl *pctl = platform_get_drvdata(pdev);
  1844. int i;
  1845. pctl->ngroups = pctl->desc->npins;
  1846. /* Allocate groups */
  1847. pctl->groups = devm_kzalloc(&pdev->dev,
  1848. pctl->ngroups * sizeof(*pctl->groups),
  1849. GFP_KERNEL);
  1850. if (!pctl->groups)
  1851. return -ENOMEM;
  1852. for (i = 0; i < pctl->desc->npins; i++) {
  1853. const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
  1854. struct sunxi_pinctrl_group *group = pctl->groups + i;
  1855. group->name = pin->pin.name;
  1856. group->pin = pin->pin.number;
  1857. }
  1858. /*
  1859. * We suppose that we won't have any more functions than pins,
  1860. * we'll reallocate that later anyway
  1861. */
  1862. pctl->functions = devm_kzalloc(&pdev->dev,
  1863. pctl->desc->npins * sizeof(*pctl->functions),
  1864. GFP_KERNEL);
  1865. if (!pctl->functions)
  1866. return -ENOMEM;
  1867. /* Count functions and their associated groups */
  1868. for (i = 0; i < pctl->desc->npins; i++) {
  1869. const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
  1870. struct sunxi_desc_function *func = pin->functions;
  1871. while (func->name) {
  1872. sunxi_pinctrl_add_function(pctl, func->name);
  1873. func++;
  1874. }
  1875. }
  1876. pctl->functions = krealloc(pctl->functions,
  1877. pctl->nfunctions * sizeof(*pctl->functions),
  1878. GFP_KERNEL);
  1879. for (i = 0; i < pctl->desc->npins; i++) {
  1880. const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
  1881. struct sunxi_desc_function *func = pin->functions;
  1882. while (func->name) {
  1883. struct sunxi_pinctrl_function *func_item;
  1884. const char **func_grp;
  1885. func_item = sunxi_pinctrl_find_function_by_name(pctl,
  1886. func->name);
  1887. if (!func_item)
  1888. return -EINVAL;
  1889. if (!func_item->groups) {
  1890. func_item->groups =
  1891. devm_kzalloc(&pdev->dev,
  1892. func_item->ngroups * sizeof(*func_item->groups),
  1893. GFP_KERNEL);
  1894. if (!func_item->groups)
  1895. return -ENOMEM;
  1896. }
  1897. func_grp = func_item->groups;
  1898. while (*func_grp)
  1899. func_grp++;
  1900. *func_grp = pin->pin.name;
  1901. func++;
  1902. }
  1903. }
  1904. return 0;
  1905. }
  1906. static int sunxi_pinctrl_probe(struct platform_device *pdev)
  1907. {
  1908. struct device_node *node = pdev->dev.of_node;
  1909. const struct of_device_id *device;
  1910. struct pinctrl_pin_desc *pins;
  1911. struct sunxi_pinctrl *pctl;
  1912. int i, ret, last_pin;
  1913. struct clk *clk;
  1914. pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL);
  1915. if (!pctl)
  1916. return -ENOMEM;
  1917. platform_set_drvdata(pdev, pctl);
  1918. pctl->membase = of_iomap(node, 0);
  1919. if (!pctl->membase)
  1920. return -ENOMEM;
  1921. device = of_match_device(sunxi_pinctrl_match, &pdev->dev);
  1922. if (!device)
  1923. return -ENODEV;
  1924. pctl->desc = (struct sunxi_pinctrl_desc *)device->data;
  1925. ret = sunxi_pinctrl_build_state(pdev);
  1926. if (ret) {
  1927. dev_err(&pdev->dev, "dt probe failed: %d\n", ret);
  1928. return ret;
  1929. }
  1930. pins = devm_kzalloc(&pdev->dev,
  1931. pctl->desc->npins * sizeof(*pins),
  1932. GFP_KERNEL);
  1933. if (!pins)
  1934. return -ENOMEM;
  1935. for (i = 0; i < pctl->desc->npins; i++)
  1936. pins[i] = pctl->desc->pins[i].pin;
  1937. sunxi_pctrl_desc.name = dev_name(&pdev->dev);
  1938. sunxi_pctrl_desc.owner = THIS_MODULE;
  1939. sunxi_pctrl_desc.pins = pins;
  1940. sunxi_pctrl_desc.npins = pctl->desc->npins;
  1941. pctl->dev = &pdev->dev;
  1942. pctl->pctl_dev = pinctrl_register(&sunxi_pctrl_desc,
  1943. &pdev->dev, pctl);
  1944. if (!pctl->pctl_dev) {
  1945. dev_err(&pdev->dev, "couldn't register pinctrl driver\n");
  1946. return -EINVAL;
  1947. }
  1948. pctl->chip = devm_kzalloc(&pdev->dev, sizeof(*pctl->chip), GFP_KERNEL);
  1949. if (!pctl->chip) {
  1950. ret = -ENOMEM;
  1951. goto pinctrl_error;
  1952. }
  1953. last_pin = pctl->desc->pins[pctl->desc->npins - 1].pin.number;
  1954. pctl->chip = &sunxi_pinctrl_gpio_chip;
  1955. pctl->chip->ngpio = round_up(last_pin, PINS_PER_BANK);
  1956. pctl->chip->label = dev_name(&pdev->dev);
  1957. pctl->chip->dev = &pdev->dev;
  1958. pctl->chip->base = 0;
  1959. ret = gpiochip_add(pctl->chip);
  1960. if (ret)
  1961. goto pinctrl_error;
  1962. for (i = 0; i < pctl->desc->npins; i++) {
  1963. const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
  1964. ret = gpiochip_add_pin_range(pctl->chip, dev_name(&pdev->dev),
  1965. pin->pin.number,
  1966. pin->pin.number, 1);
  1967. if (ret)
  1968. goto gpiochip_error;
  1969. }
  1970. clk = devm_clk_get(&pdev->dev, NULL);
  1971. if (IS_ERR(clk)) {
  1972. ret = PTR_ERR(clk);
  1973. goto gpiochip_error;
  1974. }
  1975. clk_prepare_enable(clk);
  1976. pctl->irq = irq_of_parse_and_map(node, 0);
  1977. if (!pctl->irq) {
  1978. ret = -EINVAL;
  1979. goto gpiochip_error;
  1980. }
  1981. pctl->domain = irq_domain_add_linear(node, SUNXI_IRQ_NUMBER,
  1982. &irq_domain_simple_ops, NULL);
  1983. if (!pctl->domain) {
  1984. dev_err(&pdev->dev, "Couldn't register IRQ domain\n");
  1985. ret = -ENOMEM;
  1986. goto gpiochip_error;
  1987. }
  1988. for (i = 0; i < SUNXI_IRQ_NUMBER; i++) {
  1989. int irqno = irq_create_mapping(pctl->domain, i);
  1990. irq_set_chip_and_handler(irqno, &sunxi_pinctrl_irq_chip,
  1991. handle_simple_irq);
  1992. irq_set_chip_data(irqno, pctl);
  1993. };
  1994. irq_set_chained_handler(pctl->irq, sunxi_pinctrl_irq_handler);
  1995. irq_set_handler_data(pctl->irq, pctl);
  1996. dev_info(&pdev->dev, "initialized sunXi PIO driver\n");
  1997. return 0;
  1998. gpiochip_error:
  1999. if (gpiochip_remove(pctl->chip))
  2000. dev_err(&pdev->dev, "failed to remove gpio chip\n");
  2001. pinctrl_error:
  2002. pinctrl_unregister(pctl->pctl_dev);
  2003. return ret;
  2004. }
  2005. static struct platform_driver sunxi_pinctrl_driver = {
  2006. .probe = sunxi_pinctrl_probe,
  2007. .driver = {
  2008. .name = "sunxi-pinctrl",
  2009. .owner = THIS_MODULE,
  2010. .of_match_table = sunxi_pinctrl_match,
  2011. },
  2012. };
  2013. module_platform_driver(sunxi_pinctrl_driver);
  2014. MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com");
  2015. MODULE_DESCRIPTION("Allwinner A1X pinctrl driver");
  2016. MODULE_LICENSE("GPL");