pinctrl-sunxi.c 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021
  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 int sunxi_pctrl_get_groups_count(struct pinctrl_dev *pctldev)
  1382. {
  1383. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1384. return pctl->ngroups;
  1385. }
  1386. static const char *sunxi_pctrl_get_group_name(struct pinctrl_dev *pctldev,
  1387. unsigned group)
  1388. {
  1389. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1390. return pctl->groups[group].name;
  1391. }
  1392. static int sunxi_pctrl_get_group_pins(struct pinctrl_dev *pctldev,
  1393. unsigned group,
  1394. const unsigned **pins,
  1395. unsigned *num_pins)
  1396. {
  1397. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1398. *pins = (unsigned *)&pctl->groups[group].pin;
  1399. *num_pins = 1;
  1400. return 0;
  1401. }
  1402. static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
  1403. struct device_node *node,
  1404. struct pinctrl_map **map,
  1405. unsigned *num_maps)
  1406. {
  1407. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1408. unsigned long *pinconfig;
  1409. struct property *prop;
  1410. const char *function;
  1411. const char *group;
  1412. int ret, nmaps, i = 0;
  1413. u32 val;
  1414. *map = NULL;
  1415. *num_maps = 0;
  1416. ret = of_property_read_string(node, "allwinner,function", &function);
  1417. if (ret) {
  1418. dev_err(pctl->dev,
  1419. "missing allwinner,function property in node %s\n",
  1420. node->name);
  1421. return -EINVAL;
  1422. }
  1423. nmaps = of_property_count_strings(node, "allwinner,pins") * 2;
  1424. if (nmaps < 0) {
  1425. dev_err(pctl->dev,
  1426. "missing allwinner,pins property in node %s\n",
  1427. node->name);
  1428. return -EINVAL;
  1429. }
  1430. *map = kmalloc(nmaps * sizeof(struct pinctrl_map), GFP_KERNEL);
  1431. if (!map)
  1432. return -ENOMEM;
  1433. of_property_for_each_string(node, "allwinner,pins", prop, group) {
  1434. struct sunxi_pinctrl_group *grp =
  1435. sunxi_pinctrl_find_group_by_name(pctl, group);
  1436. int j = 0, configlen = 0;
  1437. if (!grp) {
  1438. dev_err(pctl->dev, "unknown pin %s", group);
  1439. continue;
  1440. }
  1441. if (!sunxi_pinctrl_desc_find_function_by_name(pctl,
  1442. grp->name,
  1443. function)) {
  1444. dev_err(pctl->dev, "unsupported function %s on pin %s",
  1445. function, group);
  1446. continue;
  1447. }
  1448. (*map)[i].type = PIN_MAP_TYPE_MUX_GROUP;
  1449. (*map)[i].data.mux.group = group;
  1450. (*map)[i].data.mux.function = function;
  1451. i++;
  1452. (*map)[i].type = PIN_MAP_TYPE_CONFIGS_GROUP;
  1453. (*map)[i].data.configs.group_or_pin = group;
  1454. if (of_find_property(node, "allwinner,drive", NULL))
  1455. configlen++;
  1456. if (of_find_property(node, "allwinner,pull", NULL))
  1457. configlen++;
  1458. pinconfig = kzalloc(configlen * sizeof(*pinconfig), GFP_KERNEL);
  1459. if (!of_property_read_u32(node, "allwinner,drive", &val)) {
  1460. u16 strength = (val + 1) * 10;
  1461. pinconfig[j++] =
  1462. pinconf_to_config_packed(PIN_CONFIG_DRIVE_STRENGTH,
  1463. strength);
  1464. }
  1465. if (!of_property_read_u32(node, "allwinner,pull", &val)) {
  1466. enum pin_config_param pull = PIN_CONFIG_END;
  1467. if (val == 1)
  1468. pull = PIN_CONFIG_BIAS_PULL_UP;
  1469. else if (val == 2)
  1470. pull = PIN_CONFIG_BIAS_PULL_DOWN;
  1471. pinconfig[j++] = pinconf_to_config_packed(pull, 0);
  1472. }
  1473. (*map)[i].data.configs.configs = pinconfig;
  1474. (*map)[i].data.configs.num_configs = configlen;
  1475. i++;
  1476. }
  1477. *num_maps = nmaps;
  1478. return 0;
  1479. }
  1480. static void sunxi_pctrl_dt_free_map(struct pinctrl_dev *pctldev,
  1481. struct pinctrl_map *map,
  1482. unsigned num_maps)
  1483. {
  1484. int i;
  1485. for (i = 0; i < num_maps; i++) {
  1486. if (map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP)
  1487. kfree(map[i].data.configs.configs);
  1488. }
  1489. kfree(map);
  1490. }
  1491. static const struct pinctrl_ops sunxi_pctrl_ops = {
  1492. .dt_node_to_map = sunxi_pctrl_dt_node_to_map,
  1493. .dt_free_map = sunxi_pctrl_dt_free_map,
  1494. .get_groups_count = sunxi_pctrl_get_groups_count,
  1495. .get_group_name = sunxi_pctrl_get_group_name,
  1496. .get_group_pins = sunxi_pctrl_get_group_pins,
  1497. };
  1498. static int sunxi_pconf_group_get(struct pinctrl_dev *pctldev,
  1499. unsigned group,
  1500. unsigned long *config)
  1501. {
  1502. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1503. *config = pctl->groups[group].config;
  1504. return 0;
  1505. }
  1506. static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev,
  1507. unsigned group,
  1508. unsigned long config)
  1509. {
  1510. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1511. struct sunxi_pinctrl_group *g = &pctl->groups[group];
  1512. u32 val, mask;
  1513. u16 strength;
  1514. u8 dlevel;
  1515. switch (pinconf_to_config_param(config)) {
  1516. case PIN_CONFIG_DRIVE_STRENGTH:
  1517. strength = pinconf_to_config_argument(config);
  1518. if (strength > 40)
  1519. return -EINVAL;
  1520. /*
  1521. * We convert from mA to what the register expects:
  1522. * 0: 10mA
  1523. * 1: 20mA
  1524. * 2: 30mA
  1525. * 3: 40mA
  1526. */
  1527. dlevel = strength / 10 - 1;
  1528. val = readl(pctl->membase + sunxi_dlevel_reg(g->pin));
  1529. mask = DLEVEL_PINS_MASK << sunxi_dlevel_offset(g->pin);
  1530. writel((val & ~mask) | dlevel << sunxi_dlevel_offset(g->pin),
  1531. pctl->membase + sunxi_dlevel_reg(g->pin));
  1532. break;
  1533. case PIN_CONFIG_BIAS_PULL_UP:
  1534. val = readl(pctl->membase + sunxi_pull_reg(g->pin));
  1535. mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin);
  1536. writel((val & ~mask) | 1 << sunxi_pull_offset(g->pin),
  1537. pctl->membase + sunxi_pull_reg(g->pin));
  1538. break;
  1539. case PIN_CONFIG_BIAS_PULL_DOWN:
  1540. val = readl(pctl->membase + sunxi_pull_reg(g->pin));
  1541. mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin);
  1542. writel((val & ~mask) | 2 << sunxi_pull_offset(g->pin),
  1543. pctl->membase + sunxi_pull_reg(g->pin));
  1544. break;
  1545. default:
  1546. break;
  1547. }
  1548. /* cache the config value */
  1549. g->config = config;
  1550. return 0;
  1551. }
  1552. static const struct pinconf_ops sunxi_pconf_ops = {
  1553. .pin_config_group_get = sunxi_pconf_group_get,
  1554. .pin_config_group_set = sunxi_pconf_group_set,
  1555. };
  1556. static int sunxi_pmx_get_funcs_cnt(struct pinctrl_dev *pctldev)
  1557. {
  1558. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1559. return pctl->nfunctions;
  1560. }
  1561. static const char *sunxi_pmx_get_func_name(struct pinctrl_dev *pctldev,
  1562. unsigned function)
  1563. {
  1564. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1565. return pctl->functions[function].name;
  1566. }
  1567. static int sunxi_pmx_get_func_groups(struct pinctrl_dev *pctldev,
  1568. unsigned function,
  1569. const char * const **groups,
  1570. unsigned * const num_groups)
  1571. {
  1572. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1573. *groups = pctl->functions[function].groups;
  1574. *num_groups = pctl->functions[function].ngroups;
  1575. return 0;
  1576. }
  1577. static void sunxi_pmx_set(struct pinctrl_dev *pctldev,
  1578. unsigned pin,
  1579. u8 config)
  1580. {
  1581. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1582. u32 val = readl(pctl->membase + sunxi_mux_reg(pin));
  1583. u32 mask = MUX_PINS_MASK << sunxi_mux_offset(pin);
  1584. writel((val & ~mask) | config << sunxi_mux_offset(pin),
  1585. pctl->membase + sunxi_mux_reg(pin));
  1586. }
  1587. static int sunxi_pmx_enable(struct pinctrl_dev *pctldev,
  1588. unsigned function,
  1589. unsigned group)
  1590. {
  1591. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1592. struct sunxi_pinctrl_group *g = pctl->groups + group;
  1593. struct sunxi_pinctrl_function *func = pctl->functions + function;
  1594. struct sunxi_desc_function *desc =
  1595. sunxi_pinctrl_desc_find_function_by_name(pctl,
  1596. g->name,
  1597. func->name);
  1598. if (!desc)
  1599. return -EINVAL;
  1600. sunxi_pmx_set(pctldev, g->pin, desc->muxval);
  1601. return 0;
  1602. }
  1603. static int
  1604. sunxi_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
  1605. struct pinctrl_gpio_range *range,
  1606. unsigned offset,
  1607. bool input)
  1608. {
  1609. struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
  1610. struct sunxi_desc_function *desc;
  1611. char pin_name[SUNXI_PIN_NAME_MAX_LEN];
  1612. const char *func;
  1613. u8 bank, pin;
  1614. int ret;
  1615. bank = (offset) / PINS_PER_BANK;
  1616. pin = (offset) % PINS_PER_BANK;
  1617. ret = sprintf(pin_name, "P%c%d", 'A' + bank, pin);
  1618. if (!ret)
  1619. goto error;
  1620. if (input)
  1621. func = "gpio_in";
  1622. else
  1623. func = "gpio_out";
  1624. desc = sunxi_pinctrl_desc_find_function_by_name(pctl,
  1625. pin_name,
  1626. func);
  1627. if (!desc) {
  1628. ret = -EINVAL;
  1629. goto error;
  1630. }
  1631. sunxi_pmx_set(pctldev, offset, desc->muxval);
  1632. ret = 0;
  1633. error:
  1634. return ret;
  1635. }
  1636. static const struct pinmux_ops sunxi_pmx_ops = {
  1637. .get_functions_count = sunxi_pmx_get_funcs_cnt,
  1638. .get_function_name = sunxi_pmx_get_func_name,
  1639. .get_function_groups = sunxi_pmx_get_func_groups,
  1640. .enable = sunxi_pmx_enable,
  1641. .gpio_set_direction = sunxi_pmx_gpio_set_direction,
  1642. };
  1643. static struct pinctrl_desc sunxi_pctrl_desc = {
  1644. .confops = &sunxi_pconf_ops,
  1645. .pctlops = &sunxi_pctrl_ops,
  1646. .pmxops = &sunxi_pmx_ops,
  1647. };
  1648. static int sunxi_pinctrl_gpio_request(struct gpio_chip *chip, unsigned offset)
  1649. {
  1650. return pinctrl_request_gpio(chip->base + offset);
  1651. }
  1652. static void sunxi_pinctrl_gpio_free(struct gpio_chip *chip, unsigned offset)
  1653. {
  1654. pinctrl_free_gpio(chip->base + offset);
  1655. }
  1656. static int sunxi_pinctrl_gpio_direction_input(struct gpio_chip *chip,
  1657. unsigned offset)
  1658. {
  1659. return pinctrl_gpio_direction_input(chip->base + offset);
  1660. }
  1661. static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset)
  1662. {
  1663. struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev);
  1664. u32 reg = sunxi_data_reg(offset);
  1665. u8 index = sunxi_data_offset(offset);
  1666. u32 val = (readl(pctl->membase + reg) >> index) & DATA_PINS_MASK;
  1667. return val;
  1668. }
  1669. static int sunxi_pinctrl_gpio_direction_output(struct gpio_chip *chip,
  1670. unsigned offset, int value)
  1671. {
  1672. return pinctrl_gpio_direction_output(chip->base + offset);
  1673. }
  1674. static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip,
  1675. unsigned offset, int value)
  1676. {
  1677. struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev);
  1678. u32 reg = sunxi_data_reg(offset);
  1679. u8 index = sunxi_data_offset(offset);
  1680. writel((value & DATA_PINS_MASK) << index, pctl->membase + reg);
  1681. }
  1682. static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc,
  1683. const struct of_phandle_args *gpiospec,
  1684. u32 *flags)
  1685. {
  1686. int pin, base;
  1687. base = PINS_PER_BANK * gpiospec->args[0];
  1688. pin = base + gpiospec->args[1];
  1689. if (pin > (gc->base + gc->ngpio))
  1690. return -EINVAL;
  1691. if (flags)
  1692. *flags = gpiospec->args[2];
  1693. return pin;
  1694. }
  1695. static struct gpio_chip sunxi_pinctrl_gpio_chip = {
  1696. .owner = THIS_MODULE,
  1697. .request = sunxi_pinctrl_gpio_request,
  1698. .free = sunxi_pinctrl_gpio_free,
  1699. .direction_input = sunxi_pinctrl_gpio_direction_input,
  1700. .direction_output = sunxi_pinctrl_gpio_direction_output,
  1701. .get = sunxi_pinctrl_gpio_get,
  1702. .set = sunxi_pinctrl_gpio_set,
  1703. .of_xlate = sunxi_pinctrl_gpio_of_xlate,
  1704. .of_gpio_n_cells = 3,
  1705. .can_sleep = 0,
  1706. };
  1707. static struct of_device_id sunxi_pinctrl_match[] = {
  1708. { .compatible = "allwinner,sun4i-a10-pinctrl", .data = (void *)&sun4i_a10_pinctrl_data },
  1709. { .compatible = "allwinner,sun5i-a13-pinctrl", .data = (void *)&sun5i_a13_pinctrl_data },
  1710. {}
  1711. };
  1712. MODULE_DEVICE_TABLE(of, sunxi_pinctrl_match);
  1713. static int sunxi_pinctrl_add_function(struct sunxi_pinctrl *pctl,
  1714. const char *name)
  1715. {
  1716. struct sunxi_pinctrl_function *func = pctl->functions;
  1717. while (func->name) {
  1718. /* function already there */
  1719. if (strcmp(func->name, name) == 0) {
  1720. func->ngroups++;
  1721. return -EEXIST;
  1722. }
  1723. func++;
  1724. }
  1725. func->name = name;
  1726. func->ngroups = 1;
  1727. pctl->nfunctions++;
  1728. return 0;
  1729. }
  1730. static int sunxi_pinctrl_build_state(struct platform_device *pdev)
  1731. {
  1732. struct sunxi_pinctrl *pctl = platform_get_drvdata(pdev);
  1733. int i;
  1734. pctl->ngroups = pctl->desc->npins;
  1735. /* Allocate groups */
  1736. pctl->groups = devm_kzalloc(&pdev->dev,
  1737. pctl->ngroups * sizeof(*pctl->groups),
  1738. GFP_KERNEL);
  1739. if (!pctl->groups)
  1740. return -ENOMEM;
  1741. for (i = 0; i < pctl->desc->npins; i++) {
  1742. const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
  1743. struct sunxi_pinctrl_group *group = pctl->groups + i;
  1744. group->name = pin->pin.name;
  1745. group->pin = pin->pin.number;
  1746. }
  1747. /*
  1748. * We suppose that we won't have any more functions than pins,
  1749. * we'll reallocate that later anyway
  1750. */
  1751. pctl->functions = devm_kzalloc(&pdev->dev,
  1752. pctl->desc->npins * sizeof(*pctl->functions),
  1753. GFP_KERNEL);
  1754. if (!pctl->functions)
  1755. return -ENOMEM;
  1756. /* Count functions and their associated groups */
  1757. for (i = 0; i < pctl->desc->npins; i++) {
  1758. const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
  1759. struct sunxi_desc_function *func = pin->functions;
  1760. while (func->name) {
  1761. sunxi_pinctrl_add_function(pctl, func->name);
  1762. func++;
  1763. }
  1764. }
  1765. pctl->functions = krealloc(pctl->functions,
  1766. pctl->nfunctions * sizeof(*pctl->functions),
  1767. GFP_KERNEL);
  1768. for (i = 0; i < pctl->desc->npins; i++) {
  1769. const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
  1770. struct sunxi_desc_function *func = pin->functions;
  1771. while (func->name) {
  1772. struct sunxi_pinctrl_function *func_item;
  1773. const char **func_grp;
  1774. func_item = sunxi_pinctrl_find_function_by_name(pctl,
  1775. func->name);
  1776. if (!func_item)
  1777. return -EINVAL;
  1778. if (!func_item->groups) {
  1779. func_item->groups =
  1780. devm_kzalloc(&pdev->dev,
  1781. func_item->ngroups * sizeof(*func_item->groups),
  1782. GFP_KERNEL);
  1783. if (!func_item->groups)
  1784. return -ENOMEM;
  1785. }
  1786. func_grp = func_item->groups;
  1787. while (*func_grp)
  1788. func_grp++;
  1789. *func_grp = pin->pin.name;
  1790. func++;
  1791. }
  1792. }
  1793. return 0;
  1794. }
  1795. static int sunxi_pinctrl_probe(struct platform_device *pdev)
  1796. {
  1797. struct device_node *node = pdev->dev.of_node;
  1798. const struct of_device_id *device;
  1799. struct pinctrl_pin_desc *pins;
  1800. struct sunxi_pinctrl *pctl;
  1801. int i, ret, last_pin;
  1802. struct clk *clk;
  1803. pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL);
  1804. if (!pctl)
  1805. return -ENOMEM;
  1806. platform_set_drvdata(pdev, pctl);
  1807. pctl->membase = of_iomap(node, 0);
  1808. if (!pctl->membase)
  1809. return -ENOMEM;
  1810. device = of_match_device(sunxi_pinctrl_match, &pdev->dev);
  1811. if (!device)
  1812. return -ENODEV;
  1813. pctl->desc = (struct sunxi_pinctrl_desc *)device->data;
  1814. ret = sunxi_pinctrl_build_state(pdev);
  1815. if (ret) {
  1816. dev_err(&pdev->dev, "dt probe failed: %d\n", ret);
  1817. return ret;
  1818. }
  1819. pins = devm_kzalloc(&pdev->dev,
  1820. pctl->desc->npins * sizeof(*pins),
  1821. GFP_KERNEL);
  1822. if (!pins)
  1823. return -ENOMEM;
  1824. for (i = 0; i < pctl->desc->npins; i++)
  1825. pins[i] = pctl->desc->pins[i].pin;
  1826. sunxi_pctrl_desc.name = dev_name(&pdev->dev);
  1827. sunxi_pctrl_desc.owner = THIS_MODULE;
  1828. sunxi_pctrl_desc.pins = pins;
  1829. sunxi_pctrl_desc.npins = pctl->desc->npins;
  1830. pctl->dev = &pdev->dev;
  1831. pctl->pctl_dev = pinctrl_register(&sunxi_pctrl_desc,
  1832. &pdev->dev, pctl);
  1833. if (!pctl->pctl_dev) {
  1834. dev_err(&pdev->dev, "couldn't register pinctrl driver\n");
  1835. return -EINVAL;
  1836. }
  1837. pctl->chip = devm_kzalloc(&pdev->dev, sizeof(*pctl->chip), GFP_KERNEL);
  1838. if (!pctl->chip) {
  1839. ret = -ENOMEM;
  1840. goto pinctrl_error;
  1841. }
  1842. last_pin = pctl->desc->pins[pctl->desc->npins - 1].pin.number;
  1843. pctl->chip = &sunxi_pinctrl_gpio_chip;
  1844. pctl->chip->ngpio = round_up(last_pin, PINS_PER_BANK);
  1845. pctl->chip->label = dev_name(&pdev->dev);
  1846. pctl->chip->dev = &pdev->dev;
  1847. pctl->chip->base = 0;
  1848. ret = gpiochip_add(pctl->chip);
  1849. if (ret)
  1850. goto pinctrl_error;
  1851. for (i = 0; i < pctl->desc->npins; i++) {
  1852. const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
  1853. ret = gpiochip_add_pin_range(pctl->chip, dev_name(&pdev->dev),
  1854. pin->pin.number,
  1855. pin->pin.number, 1);
  1856. if (ret)
  1857. goto gpiochip_error;
  1858. }
  1859. clk = devm_clk_get(&pdev->dev, NULL);
  1860. if (IS_ERR(clk))
  1861. goto gpiochip_error;
  1862. clk_prepare_enable(clk);
  1863. dev_info(&pdev->dev, "initialized sunXi PIO driver\n");
  1864. return 0;
  1865. gpiochip_error:
  1866. ret = gpiochip_remove(pctl->chip);
  1867. pinctrl_error:
  1868. pinctrl_unregister(pctl->pctl_dev);
  1869. return ret;
  1870. }
  1871. static struct platform_driver sunxi_pinctrl_driver = {
  1872. .probe = sunxi_pinctrl_probe,
  1873. .driver = {
  1874. .name = "sunxi-pinctrl",
  1875. .owner = THIS_MODULE,
  1876. .of_match_table = sunxi_pinctrl_match,
  1877. },
  1878. };
  1879. module_platform_driver(sunxi_pinctrl_driver);
  1880. MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com");
  1881. MODULE_DESCRIPTION("Allwinner A1X pinctrl driver");
  1882. MODULE_LICENSE("GPL");