pinctrl-sunxi.c 65 KB

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