pinctrl-zynq.c 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180
  1. /*
  2. * Zynq pin controller
  3. *
  4. * Copyright (C) 2014 Xilinx
  5. *
  6. * Sören Brinkmann <soren.brinkmann@xilinx.com>
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <linux/io.h>
  22. #include <linux/mfd/syscon.h>
  23. #include <linux/module.h>
  24. #include <linux/of.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/pinctrl/pinctrl.h>
  27. #include <linux/pinctrl/pinmux.h>
  28. #include <linux/pinctrl/pinconf.h>
  29. #include <linux/pinctrl/pinconf-generic.h>
  30. #include <linux/regmap.h>
  31. #include "pinctrl-utils.h"
  32. #include "core.h"
  33. #define ZYNQ_NUM_MIOS 54
  34. #define ZYNQ_PCTRL_MIO_MST_TRI0 0x10c
  35. #define ZYNQ_PCTRL_MIO_MST_TRI1 0x110
  36. #define ZYNQ_PINMUX_MUX_SHIFT 1
  37. #define ZYNQ_PINMUX_MUX_MASK (0x7f << ZYNQ_PINMUX_MUX_SHIFT)
  38. /**
  39. * struct zynq_pinctrl - driver data
  40. * @pctrl: Pinctrl device
  41. * @syscon: Syscon regmap
  42. * @pctrl_offset: Offset for pinctrl into the @syscon space
  43. * @groups: Pingroups
  44. * @ngroupos: Number of @groups
  45. * @funcs: Pinmux functions
  46. * @nfuncs: Number of @funcs
  47. */
  48. struct zynq_pinctrl {
  49. struct pinctrl_dev *pctrl;
  50. struct regmap *syscon;
  51. u32 pctrl_offset;
  52. const struct zynq_pctrl_group *groups;
  53. unsigned int ngroups;
  54. const struct zynq_pinmux_function *funcs;
  55. unsigned int nfuncs;
  56. };
  57. struct zynq_pctrl_group {
  58. const char *name;
  59. const unsigned int *pins;
  60. const unsigned npins;
  61. };
  62. /**
  63. * struct zynq_pinmux_function - a pinmux function
  64. * @name: Name of the pinmux function.
  65. * @groups: List of pingroups for this function.
  66. * @ngroups: Number of entries in @groups.
  67. * @mux_val: Selector for this function
  68. * @mux: Offset of function specific mux
  69. * @mux_mask: Mask for function specific selector
  70. * @mux_shift: Shift for function specific selector
  71. */
  72. struct zynq_pinmux_function {
  73. const char *name;
  74. const char * const *groups;
  75. unsigned int ngroups;
  76. unsigned int mux_val;
  77. u32 mux;
  78. u32 mux_mask;
  79. u8 mux_shift;
  80. };
  81. enum zynq_pinmux_functions {
  82. ZYNQ_PMUX_can0,
  83. ZYNQ_PMUX_can1,
  84. ZYNQ_PMUX_ethernet0,
  85. ZYNQ_PMUX_ethernet1,
  86. ZYNQ_PMUX_gpio0,
  87. ZYNQ_PMUX_i2c0,
  88. ZYNQ_PMUX_i2c1,
  89. ZYNQ_PMUX_mdio0,
  90. ZYNQ_PMUX_mdio1,
  91. ZYNQ_PMUX_qspi0,
  92. ZYNQ_PMUX_qspi1,
  93. ZYNQ_PMUX_qspi_fbclk,
  94. ZYNQ_PMUX_qspi_cs1,
  95. ZYNQ_PMUX_spi0,
  96. ZYNQ_PMUX_spi1,
  97. ZYNQ_PMUX_sdio0,
  98. ZYNQ_PMUX_sdio0_pc,
  99. ZYNQ_PMUX_sdio0_cd,
  100. ZYNQ_PMUX_sdio0_wp,
  101. ZYNQ_PMUX_sdio1,
  102. ZYNQ_PMUX_sdio1_pc,
  103. ZYNQ_PMUX_sdio1_cd,
  104. ZYNQ_PMUX_sdio1_wp,
  105. ZYNQ_PMUX_smc0_nor,
  106. ZYNQ_PMUX_smc0_nor_cs1,
  107. ZYNQ_PMUX_smc0_nor_addr25,
  108. ZYNQ_PMUX_smc0_nand,
  109. ZYNQ_PMUX_ttc0,
  110. ZYNQ_PMUX_ttc1,
  111. ZYNQ_PMUX_uart0,
  112. ZYNQ_PMUX_uart1,
  113. ZYNQ_PMUX_usb0,
  114. ZYNQ_PMUX_usb1,
  115. ZYNQ_PMUX_swdt0,
  116. ZYNQ_PMUX_MAX_FUNC
  117. };
  118. const struct pinctrl_pin_desc zynq_pins[] = {
  119. PINCTRL_PIN(0, "MIO0"),
  120. PINCTRL_PIN(1, "MIO1"),
  121. PINCTRL_PIN(2, "MIO2"),
  122. PINCTRL_PIN(3, "MIO3"),
  123. PINCTRL_PIN(4, "MIO4"),
  124. PINCTRL_PIN(5, "MIO5"),
  125. PINCTRL_PIN(6, "MIO6"),
  126. PINCTRL_PIN(7, "MIO7"),
  127. PINCTRL_PIN(8, "MIO8"),
  128. PINCTRL_PIN(9, "MIO9"),
  129. PINCTRL_PIN(10, "MIO10"),
  130. PINCTRL_PIN(11, "MIO11"),
  131. PINCTRL_PIN(12, "MIO12"),
  132. PINCTRL_PIN(13, "MIO13"),
  133. PINCTRL_PIN(14, "MIO14"),
  134. PINCTRL_PIN(15, "MIO15"),
  135. PINCTRL_PIN(16, "MIO16"),
  136. PINCTRL_PIN(17, "MIO17"),
  137. PINCTRL_PIN(18, "MIO18"),
  138. PINCTRL_PIN(19, "MIO19"),
  139. PINCTRL_PIN(20, "MIO20"),
  140. PINCTRL_PIN(21, "MIO21"),
  141. PINCTRL_PIN(22, "MIO22"),
  142. PINCTRL_PIN(23, "MIO23"),
  143. PINCTRL_PIN(24, "MIO24"),
  144. PINCTRL_PIN(25, "MIO25"),
  145. PINCTRL_PIN(26, "MIO26"),
  146. PINCTRL_PIN(27, "MIO27"),
  147. PINCTRL_PIN(28, "MIO28"),
  148. PINCTRL_PIN(29, "MIO29"),
  149. PINCTRL_PIN(30, "MIO30"),
  150. PINCTRL_PIN(31, "MIO31"),
  151. PINCTRL_PIN(32, "MIO32"),
  152. PINCTRL_PIN(33, "MIO33"),
  153. PINCTRL_PIN(34, "MIO34"),
  154. PINCTRL_PIN(35, "MIO35"),
  155. PINCTRL_PIN(36, "MIO36"),
  156. PINCTRL_PIN(37, "MIO37"),
  157. PINCTRL_PIN(38, "MIO38"),
  158. PINCTRL_PIN(39, "MIO39"),
  159. PINCTRL_PIN(40, "MIO40"),
  160. PINCTRL_PIN(41, "MIO41"),
  161. PINCTRL_PIN(42, "MIO42"),
  162. PINCTRL_PIN(43, "MIO43"),
  163. PINCTRL_PIN(44, "MIO44"),
  164. PINCTRL_PIN(45, "MIO45"),
  165. PINCTRL_PIN(46, "MIO46"),
  166. PINCTRL_PIN(47, "MIO47"),
  167. PINCTRL_PIN(48, "MIO48"),
  168. PINCTRL_PIN(49, "MIO49"),
  169. PINCTRL_PIN(50, "MIO50"),
  170. PINCTRL_PIN(51, "MIO51"),
  171. PINCTRL_PIN(52, "MIO52"),
  172. PINCTRL_PIN(53, "MIO53"),
  173. PINCTRL_PIN(54, "EMIO_SD0_WP"),
  174. PINCTRL_PIN(55, "EMIO_SD0_CD"),
  175. PINCTRL_PIN(56, "EMIO_SD1_WP"),
  176. PINCTRL_PIN(57, "EMIO_SD1_CD"),
  177. };
  178. /* pin groups */
  179. static const unsigned int ethernet0_0_pins[] = {16, 17, 18, 19, 20, 21, 22, 23,
  180. 24, 25, 26, 27};
  181. static const unsigned int ethernet1_0_pins[] = {28, 29, 30, 31, 32, 33, 34, 35,
  182. 36, 37, 38, 39};
  183. static const unsigned int mdio0_0_pins[] = {52, 53};
  184. static const unsigned int mdio1_0_pins[] = {52, 53};
  185. static const unsigned int qspi0_0_pins[] = {1, 2, 3, 4, 5, 6};
  186. static const unsigned int qspi1_0_pins[] = {9, 10, 11, 12, 13};
  187. static const unsigned int qspi_cs1_pins[] = {0};
  188. static const unsigned int qspi_fbclk_pins[] = {8};
  189. static const unsigned int spi0_0_pins[] = {16, 17, 18, 19, 20, 21};
  190. static const unsigned int spi0_1_pins[] = {28, 29, 30, 31, 32, 33};
  191. static const unsigned int spi0_2_pins[] = {40, 41, 42, 43, 44, 45};
  192. static const unsigned int spi1_0_pins[] = {10, 11, 12, 13, 14, 15};
  193. static const unsigned int spi1_1_pins[] = {22, 23, 24, 25, 26, 27};
  194. static const unsigned int spi1_2_pins[] = {34, 35, 36, 37, 38, 39};
  195. static const unsigned int spi1_3_pins[] = {46, 47, 48, 49, 40, 51};
  196. static const unsigned int sdio0_0_pins[] = {16, 17, 18, 19, 20, 21};
  197. static const unsigned int sdio0_1_pins[] = {28, 29, 30, 31, 32, 33};
  198. static const unsigned int sdio0_2_pins[] = {40, 41, 42, 43, 44, 45};
  199. static const unsigned int sdio1_0_pins[] = {10, 11, 12, 13, 14, 15};
  200. static const unsigned int sdio1_1_pins[] = {22, 23, 24, 25, 26, 27};
  201. static const unsigned int sdio1_2_pins[] = {34, 35, 36, 37, 38, 39};
  202. static const unsigned int sdio1_3_pins[] = {46, 47, 48, 49, 40, 51};
  203. static const unsigned int sdio0_emio_wp_pins[] = {54};
  204. static const unsigned int sdio0_emio_cd_pins[] = {55};
  205. static const unsigned int sdio1_emio_wp_pins[] = {56};
  206. static const unsigned int sdio1_emio_cd_pins[] = {57};
  207. static const unsigned int smc0_nor_pins[] = {0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13,
  208. 15, 16, 17, 18, 19, 20, 21, 22, 23,
  209. 24, 25, 26, 27, 28, 29, 30, 31, 32,
  210. 33, 34, 35, 36, 37, 38, 39};
  211. static const unsigned int smc0_nor_cs1_pins[] = {1};
  212. static const unsigned int smc0_nor_addr25_pins[] = {1};
  213. static const unsigned int smc0_nand_pins[] = {0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  214. 12, 13, 14, 16, 17, 18, 19, 20,
  215. 21, 22, 23};
  216. /* Note: CAN MIO clock inputs are modeled in the clock framework */
  217. static const unsigned int can0_0_pins[] = {10, 11};
  218. static const unsigned int can0_1_pins[] = {14, 15};
  219. static const unsigned int can0_2_pins[] = {18, 19};
  220. static const unsigned int can0_3_pins[] = {22, 23};
  221. static const unsigned int can0_4_pins[] = {26, 27};
  222. static const unsigned int can0_5_pins[] = {30, 31};
  223. static const unsigned int can0_6_pins[] = {34, 35};
  224. static const unsigned int can0_7_pins[] = {38, 39};
  225. static const unsigned int can0_8_pins[] = {42, 43};
  226. static const unsigned int can0_9_pins[] = {46, 47};
  227. static const unsigned int can0_10_pins[] = {50, 51};
  228. static const unsigned int can1_0_pins[] = {8, 9};
  229. static const unsigned int can1_1_pins[] = {12, 13};
  230. static const unsigned int can1_2_pins[] = {16, 17};
  231. static const unsigned int can1_3_pins[] = {20, 21};
  232. static const unsigned int can1_4_pins[] = {24, 25};
  233. static const unsigned int can1_5_pins[] = {28, 29};
  234. static const unsigned int can1_6_pins[] = {32, 33};
  235. static const unsigned int can1_7_pins[] = {36, 37};
  236. static const unsigned int can1_8_pins[] = {40, 41};
  237. static const unsigned int can1_9_pins[] = {44, 45};
  238. static const unsigned int can1_10_pins[] = {48, 49};
  239. static const unsigned int can1_11_pins[] = {52, 53};
  240. static const unsigned int uart0_0_pins[] = {10, 11};
  241. static const unsigned int uart0_1_pins[] = {14, 15};
  242. static const unsigned int uart0_2_pins[] = {18, 19};
  243. static const unsigned int uart0_3_pins[] = {22, 23};
  244. static const unsigned int uart0_4_pins[] = {26, 27};
  245. static const unsigned int uart0_5_pins[] = {30, 31};
  246. static const unsigned int uart0_6_pins[] = {34, 35};
  247. static const unsigned int uart0_7_pins[] = {38, 39};
  248. static const unsigned int uart0_8_pins[] = {42, 43};
  249. static const unsigned int uart0_9_pins[] = {46, 47};
  250. static const unsigned int uart0_10_pins[] = {50, 51};
  251. static const unsigned int uart1_0_pins[] = {8, 9};
  252. static const unsigned int uart1_1_pins[] = {12, 13};
  253. static const unsigned int uart1_2_pins[] = {16, 17};
  254. static const unsigned int uart1_3_pins[] = {20, 21};
  255. static const unsigned int uart1_4_pins[] = {24, 25};
  256. static const unsigned int uart1_5_pins[] = {28, 29};
  257. static const unsigned int uart1_6_pins[] = {32, 33};
  258. static const unsigned int uart1_7_pins[] = {36, 37};
  259. static const unsigned int uart1_8_pins[] = {40, 41};
  260. static const unsigned int uart1_9_pins[] = {44, 45};
  261. static const unsigned int uart1_10_pins[] = {48, 49};
  262. static const unsigned int uart1_11_pins[] = {52, 53};
  263. static const unsigned int i2c0_0_pins[] = {10, 11};
  264. static const unsigned int i2c0_1_pins[] = {14, 15};
  265. static const unsigned int i2c0_2_pins[] = {18, 19};
  266. static const unsigned int i2c0_3_pins[] = {22, 23};
  267. static const unsigned int i2c0_4_pins[] = {26, 27};
  268. static const unsigned int i2c0_5_pins[] = {30, 31};
  269. static const unsigned int i2c0_6_pins[] = {34, 35};
  270. static const unsigned int i2c0_7_pins[] = {38, 39};
  271. static const unsigned int i2c0_8_pins[] = {42, 43};
  272. static const unsigned int i2c0_9_pins[] = {46, 47};
  273. static const unsigned int i2c0_10_pins[] = {50, 51};
  274. static const unsigned int i2c1_0_pins[] = {12, 13};
  275. static const unsigned int i2c1_1_pins[] = {16, 17};
  276. static const unsigned int i2c1_2_pins[] = {20, 21};
  277. static const unsigned int i2c1_3_pins[] = {24, 25};
  278. static const unsigned int i2c1_4_pins[] = {28, 29};
  279. static const unsigned int i2c1_5_pins[] = {32, 33};
  280. static const unsigned int i2c1_6_pins[] = {36, 37};
  281. static const unsigned int i2c1_7_pins[] = {40, 41};
  282. static const unsigned int i2c1_8_pins[] = {44, 45};
  283. static const unsigned int i2c1_9_pins[] = {48, 49};
  284. static const unsigned int i2c1_10_pins[] = {52, 53};
  285. static const unsigned int ttc0_0_pins[] = {18, 19};
  286. static const unsigned int ttc0_1_pins[] = {30, 31};
  287. static const unsigned int ttc0_2_pins[] = {42, 43};
  288. static const unsigned int ttc1_0_pins[] = {16, 17};
  289. static const unsigned int ttc1_1_pins[] = {28, 29};
  290. static const unsigned int ttc1_2_pins[] = {40, 41};
  291. static const unsigned int swdt0_0_pins[] = {14, 15};
  292. static const unsigned int swdt0_1_pins[] = {26, 27};
  293. static const unsigned int swdt0_2_pins[] = {38, 39};
  294. static const unsigned int swdt0_3_pins[] = {50, 51};
  295. static const unsigned int swdt0_4_pins[] = {52, 53};
  296. static const unsigned int gpio0_0_pins[] = {0};
  297. static const unsigned int gpio0_1_pins[] = {1};
  298. static const unsigned int gpio0_2_pins[] = {2};
  299. static const unsigned int gpio0_3_pins[] = {3};
  300. static const unsigned int gpio0_4_pins[] = {4};
  301. static const unsigned int gpio0_5_pins[] = {5};
  302. static const unsigned int gpio0_6_pins[] = {6};
  303. static const unsigned int gpio0_7_pins[] = {7};
  304. static const unsigned int gpio0_8_pins[] = {8};
  305. static const unsigned int gpio0_9_pins[] = {9};
  306. static const unsigned int gpio0_10_pins[] = {10};
  307. static const unsigned int gpio0_11_pins[] = {11};
  308. static const unsigned int gpio0_12_pins[] = {12};
  309. static const unsigned int gpio0_13_pins[] = {13};
  310. static const unsigned int gpio0_14_pins[] = {14};
  311. static const unsigned int gpio0_15_pins[] = {15};
  312. static const unsigned int gpio0_16_pins[] = {16};
  313. static const unsigned int gpio0_17_pins[] = {17};
  314. static const unsigned int gpio0_18_pins[] = {18};
  315. static const unsigned int gpio0_19_pins[] = {19};
  316. static const unsigned int gpio0_20_pins[] = {20};
  317. static const unsigned int gpio0_21_pins[] = {21};
  318. static const unsigned int gpio0_22_pins[] = {22};
  319. static const unsigned int gpio0_23_pins[] = {23};
  320. static const unsigned int gpio0_24_pins[] = {24};
  321. static const unsigned int gpio0_25_pins[] = {25};
  322. static const unsigned int gpio0_26_pins[] = {26};
  323. static const unsigned int gpio0_27_pins[] = {27};
  324. static const unsigned int gpio0_28_pins[] = {28};
  325. static const unsigned int gpio0_29_pins[] = {29};
  326. static const unsigned int gpio0_30_pins[] = {30};
  327. static const unsigned int gpio0_31_pins[] = {31};
  328. static const unsigned int gpio0_32_pins[] = {32};
  329. static const unsigned int gpio0_33_pins[] = {33};
  330. static const unsigned int gpio0_34_pins[] = {34};
  331. static const unsigned int gpio0_35_pins[] = {35};
  332. static const unsigned int gpio0_36_pins[] = {36};
  333. static const unsigned int gpio0_37_pins[] = {37};
  334. static const unsigned int gpio0_38_pins[] = {38};
  335. static const unsigned int gpio0_39_pins[] = {39};
  336. static const unsigned int gpio0_40_pins[] = {40};
  337. static const unsigned int gpio0_41_pins[] = {41};
  338. static const unsigned int gpio0_42_pins[] = {42};
  339. static const unsigned int gpio0_43_pins[] = {43};
  340. static const unsigned int gpio0_44_pins[] = {44};
  341. static const unsigned int gpio0_45_pins[] = {45};
  342. static const unsigned int gpio0_46_pins[] = {46};
  343. static const unsigned int gpio0_47_pins[] = {47};
  344. static const unsigned int gpio0_48_pins[] = {48};
  345. static const unsigned int gpio0_49_pins[] = {49};
  346. static const unsigned int gpio0_50_pins[] = {50};
  347. static const unsigned int gpio0_51_pins[] = {51};
  348. static const unsigned int gpio0_52_pins[] = {52};
  349. static const unsigned int gpio0_53_pins[] = {53};
  350. static const unsigned int usb0_0_pins[] = {28, 29, 30, 31, 32, 33, 34, 35, 36,
  351. 37, 38, 39};
  352. static const unsigned int usb1_0_pins[] = {40, 41, 42, 43, 44, 45, 46, 47, 48,
  353. 49, 50, 51};
  354. #define DEFINE_ZYNQ_PINCTRL_GRP(nm) \
  355. { \
  356. .name = #nm "_grp", \
  357. .pins = nm ## _pins, \
  358. .npins = ARRAY_SIZE(nm ## _pins), \
  359. }
  360. struct zynq_pctrl_group zynq_pctrl_groups[] = {
  361. DEFINE_ZYNQ_PINCTRL_GRP(ethernet0_0),
  362. DEFINE_ZYNQ_PINCTRL_GRP(ethernet1_0),
  363. DEFINE_ZYNQ_PINCTRL_GRP(mdio0_0),
  364. DEFINE_ZYNQ_PINCTRL_GRP(mdio1_0),
  365. DEFINE_ZYNQ_PINCTRL_GRP(qspi0_0),
  366. DEFINE_ZYNQ_PINCTRL_GRP(qspi1_0),
  367. DEFINE_ZYNQ_PINCTRL_GRP(qspi_fbclk),
  368. DEFINE_ZYNQ_PINCTRL_GRP(qspi_cs1),
  369. DEFINE_ZYNQ_PINCTRL_GRP(spi0_0),
  370. DEFINE_ZYNQ_PINCTRL_GRP(spi0_1),
  371. DEFINE_ZYNQ_PINCTRL_GRP(spi0_2),
  372. DEFINE_ZYNQ_PINCTRL_GRP(spi1_0),
  373. DEFINE_ZYNQ_PINCTRL_GRP(spi1_1),
  374. DEFINE_ZYNQ_PINCTRL_GRP(spi1_2),
  375. DEFINE_ZYNQ_PINCTRL_GRP(spi1_3),
  376. DEFINE_ZYNQ_PINCTRL_GRP(sdio0_0),
  377. DEFINE_ZYNQ_PINCTRL_GRP(sdio0_1),
  378. DEFINE_ZYNQ_PINCTRL_GRP(sdio0_2),
  379. DEFINE_ZYNQ_PINCTRL_GRP(sdio1_0),
  380. DEFINE_ZYNQ_PINCTRL_GRP(sdio1_1),
  381. DEFINE_ZYNQ_PINCTRL_GRP(sdio1_2),
  382. DEFINE_ZYNQ_PINCTRL_GRP(sdio1_3),
  383. DEFINE_ZYNQ_PINCTRL_GRP(sdio0_emio_wp),
  384. DEFINE_ZYNQ_PINCTRL_GRP(sdio0_emio_cd),
  385. DEFINE_ZYNQ_PINCTRL_GRP(sdio1_emio_wp),
  386. DEFINE_ZYNQ_PINCTRL_GRP(sdio1_emio_cd),
  387. DEFINE_ZYNQ_PINCTRL_GRP(smc0_nor),
  388. DEFINE_ZYNQ_PINCTRL_GRP(smc0_nor_cs1),
  389. DEFINE_ZYNQ_PINCTRL_GRP(smc0_nor_addr25),
  390. DEFINE_ZYNQ_PINCTRL_GRP(smc0_nand),
  391. DEFINE_ZYNQ_PINCTRL_GRP(can0_0),
  392. DEFINE_ZYNQ_PINCTRL_GRP(can0_1),
  393. DEFINE_ZYNQ_PINCTRL_GRP(can0_2),
  394. DEFINE_ZYNQ_PINCTRL_GRP(can0_3),
  395. DEFINE_ZYNQ_PINCTRL_GRP(can0_4),
  396. DEFINE_ZYNQ_PINCTRL_GRP(can0_5),
  397. DEFINE_ZYNQ_PINCTRL_GRP(can0_6),
  398. DEFINE_ZYNQ_PINCTRL_GRP(can0_7),
  399. DEFINE_ZYNQ_PINCTRL_GRP(can0_8),
  400. DEFINE_ZYNQ_PINCTRL_GRP(can0_9),
  401. DEFINE_ZYNQ_PINCTRL_GRP(can0_10),
  402. DEFINE_ZYNQ_PINCTRL_GRP(can1_0),
  403. DEFINE_ZYNQ_PINCTRL_GRP(can1_1),
  404. DEFINE_ZYNQ_PINCTRL_GRP(can1_2),
  405. DEFINE_ZYNQ_PINCTRL_GRP(can1_3),
  406. DEFINE_ZYNQ_PINCTRL_GRP(can1_4),
  407. DEFINE_ZYNQ_PINCTRL_GRP(can1_5),
  408. DEFINE_ZYNQ_PINCTRL_GRP(can1_6),
  409. DEFINE_ZYNQ_PINCTRL_GRP(can1_7),
  410. DEFINE_ZYNQ_PINCTRL_GRP(can1_8),
  411. DEFINE_ZYNQ_PINCTRL_GRP(can1_9),
  412. DEFINE_ZYNQ_PINCTRL_GRP(can1_10),
  413. DEFINE_ZYNQ_PINCTRL_GRP(can1_11),
  414. DEFINE_ZYNQ_PINCTRL_GRP(uart0_0),
  415. DEFINE_ZYNQ_PINCTRL_GRP(uart0_1),
  416. DEFINE_ZYNQ_PINCTRL_GRP(uart0_2),
  417. DEFINE_ZYNQ_PINCTRL_GRP(uart0_3),
  418. DEFINE_ZYNQ_PINCTRL_GRP(uart0_4),
  419. DEFINE_ZYNQ_PINCTRL_GRP(uart0_5),
  420. DEFINE_ZYNQ_PINCTRL_GRP(uart0_6),
  421. DEFINE_ZYNQ_PINCTRL_GRP(uart0_7),
  422. DEFINE_ZYNQ_PINCTRL_GRP(uart0_8),
  423. DEFINE_ZYNQ_PINCTRL_GRP(uart0_9),
  424. DEFINE_ZYNQ_PINCTRL_GRP(uart0_10),
  425. DEFINE_ZYNQ_PINCTRL_GRP(uart1_0),
  426. DEFINE_ZYNQ_PINCTRL_GRP(uart1_1),
  427. DEFINE_ZYNQ_PINCTRL_GRP(uart1_2),
  428. DEFINE_ZYNQ_PINCTRL_GRP(uart1_3),
  429. DEFINE_ZYNQ_PINCTRL_GRP(uart1_4),
  430. DEFINE_ZYNQ_PINCTRL_GRP(uart1_5),
  431. DEFINE_ZYNQ_PINCTRL_GRP(uart1_6),
  432. DEFINE_ZYNQ_PINCTRL_GRP(uart1_7),
  433. DEFINE_ZYNQ_PINCTRL_GRP(uart1_8),
  434. DEFINE_ZYNQ_PINCTRL_GRP(uart1_9),
  435. DEFINE_ZYNQ_PINCTRL_GRP(uart1_10),
  436. DEFINE_ZYNQ_PINCTRL_GRP(uart1_11),
  437. DEFINE_ZYNQ_PINCTRL_GRP(i2c0_0),
  438. DEFINE_ZYNQ_PINCTRL_GRP(i2c0_1),
  439. DEFINE_ZYNQ_PINCTRL_GRP(i2c0_2),
  440. DEFINE_ZYNQ_PINCTRL_GRP(i2c0_3),
  441. DEFINE_ZYNQ_PINCTRL_GRP(i2c0_4),
  442. DEFINE_ZYNQ_PINCTRL_GRP(i2c0_5),
  443. DEFINE_ZYNQ_PINCTRL_GRP(i2c0_6),
  444. DEFINE_ZYNQ_PINCTRL_GRP(i2c0_7),
  445. DEFINE_ZYNQ_PINCTRL_GRP(i2c0_8),
  446. DEFINE_ZYNQ_PINCTRL_GRP(i2c0_9),
  447. DEFINE_ZYNQ_PINCTRL_GRP(i2c0_10),
  448. DEFINE_ZYNQ_PINCTRL_GRP(i2c1_0),
  449. DEFINE_ZYNQ_PINCTRL_GRP(i2c1_1),
  450. DEFINE_ZYNQ_PINCTRL_GRP(i2c1_2),
  451. DEFINE_ZYNQ_PINCTRL_GRP(i2c1_3),
  452. DEFINE_ZYNQ_PINCTRL_GRP(i2c1_4),
  453. DEFINE_ZYNQ_PINCTRL_GRP(i2c1_5),
  454. DEFINE_ZYNQ_PINCTRL_GRP(i2c1_6),
  455. DEFINE_ZYNQ_PINCTRL_GRP(i2c1_7),
  456. DEFINE_ZYNQ_PINCTRL_GRP(i2c1_8),
  457. DEFINE_ZYNQ_PINCTRL_GRP(i2c1_9),
  458. DEFINE_ZYNQ_PINCTRL_GRP(i2c1_10),
  459. DEFINE_ZYNQ_PINCTRL_GRP(ttc0_0),
  460. DEFINE_ZYNQ_PINCTRL_GRP(ttc0_1),
  461. DEFINE_ZYNQ_PINCTRL_GRP(ttc0_2),
  462. DEFINE_ZYNQ_PINCTRL_GRP(ttc1_0),
  463. DEFINE_ZYNQ_PINCTRL_GRP(ttc1_1),
  464. DEFINE_ZYNQ_PINCTRL_GRP(ttc1_2),
  465. DEFINE_ZYNQ_PINCTRL_GRP(swdt0_0),
  466. DEFINE_ZYNQ_PINCTRL_GRP(swdt0_1),
  467. DEFINE_ZYNQ_PINCTRL_GRP(swdt0_2),
  468. DEFINE_ZYNQ_PINCTRL_GRP(swdt0_3),
  469. DEFINE_ZYNQ_PINCTRL_GRP(swdt0_4),
  470. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_0),
  471. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_1),
  472. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_2),
  473. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_3),
  474. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_4),
  475. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_5),
  476. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_6),
  477. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_7),
  478. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_8),
  479. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_9),
  480. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_10),
  481. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_11),
  482. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_12),
  483. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_13),
  484. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_14),
  485. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_15),
  486. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_16),
  487. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_17),
  488. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_18),
  489. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_19),
  490. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_20),
  491. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_21),
  492. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_22),
  493. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_23),
  494. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_24),
  495. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_25),
  496. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_26),
  497. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_27),
  498. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_28),
  499. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_29),
  500. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_30),
  501. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_31),
  502. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_32),
  503. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_33),
  504. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_34),
  505. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_35),
  506. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_36),
  507. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_37),
  508. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_38),
  509. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_39),
  510. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_40),
  511. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_41),
  512. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_42),
  513. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_43),
  514. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_44),
  515. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_45),
  516. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_46),
  517. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_47),
  518. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_48),
  519. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_49),
  520. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_50),
  521. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_51),
  522. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_52),
  523. DEFINE_ZYNQ_PINCTRL_GRP(gpio0_53),
  524. DEFINE_ZYNQ_PINCTRL_GRP(usb0_0),
  525. DEFINE_ZYNQ_PINCTRL_GRP(usb1_0),
  526. };
  527. /* function groups */
  528. static const char * const ethernet0_groups[] = {"ethernet0_0_grp"};
  529. static const char * const ethernet1_groups[] = {"ethernet1_0_grp"};
  530. static const char * const usb0_groups[] = {"usb0_0_grp"};
  531. static const char * const usb1_groups[] = {"usb1_0_grp"};
  532. static const char * const mdio0_groups[] = {"mdio0_0_grp"};
  533. static const char * const mdio1_groups[] = {"mdio1_0_grp"};
  534. static const char * const qspi0_groups[] = {"qspi0_0_grp"};
  535. static const char * const qspi1_groups[] = {"qspi0_1_grp"};
  536. static const char * const qspi_fbclk_groups[] = {"qspi_fbclk_grp"};
  537. static const char * const qspi_cs1_groups[] = {"qspi_cs1_grp"};
  538. static const char * const spi0_groups[] = {"spi0_0_grp", "spi0_1_grp",
  539. "spi0_2_grp"};
  540. static const char * const spi1_groups[] = {"spi1_0_grp", "spi1_1_grp",
  541. "spi1_2_grp", "spi1_3_grp"};
  542. static const char * const sdio0_groups[] = {"sdio0_0_grp", "sdio0_1_grp",
  543. "sdio0_2_grp"};
  544. static const char * const sdio1_groups[] = {"sdio1_0_grp", "sdio1_1_grp",
  545. "sdio1_2_grp", "sdio1_3_grp"};
  546. static const char * const sdio0_pc_groups[] = {"gpio0_0_grp",
  547. "gpio0_2_grp", "gpio0_4_grp", "gpio0_6_grp",
  548. "gpio0_8_grp", "gpio0_10_grp", "gpio0_12_grp",
  549. "gpio0_14_grp", "gpio0_16_grp", "gpio0_18_grp",
  550. "gpio0_20_grp", "gpio0_22_grp", "gpio0_24_grp",
  551. "gpio0_26_grp", "gpio0_28_grp", "gpio0_30_grp",
  552. "gpio0_32_grp", "gpio0_34_grp", "gpio0_36_grp",
  553. "gpio0_38_grp", "gpio0_40_grp", "gpio0_42_grp",
  554. "gpio0_44_grp", "gpio0_46_grp", "gpio0_48_grp",
  555. "gpio0_50_grp", "gpio0_52_grp"};
  556. static const char * const sdio1_pc_groups[] = {"gpio0_1_grp",
  557. "gpio0_3_grp", "gpio0_5_grp", "gpio0_7_grp",
  558. "gpio0_9_grp", "gpio0_11_grp", "gpio0_13_grp",
  559. "gpio0_15_grp", "gpio0_17_grp", "gpio0_19_grp",
  560. "gpio0_21_grp", "gpio0_23_grp", "gpio0_25_grp",
  561. "gpio0_27_grp", "gpio0_29_grp", "gpio0_31_grp",
  562. "gpio0_33_grp", "gpio0_35_grp", "gpio0_37_grp",
  563. "gpio0_39_grp", "gpio0_41_grp", "gpio0_43_grp",
  564. "gpio0_45_grp", "gpio0_47_grp", "gpio0_49_grp",
  565. "gpio0_51_grp", "gpio0_53_grp"};
  566. static const char * const sdio0_cd_groups[] = {"gpio0_0_grp",
  567. "gpio0_2_grp", "gpio0_4_grp", "gpio0_6_grp",
  568. "gpio0_10_grp", "gpio0_12_grp",
  569. "gpio0_14_grp", "gpio0_16_grp", "gpio0_18_grp",
  570. "gpio0_20_grp", "gpio0_22_grp", "gpio0_24_grp",
  571. "gpio0_26_grp", "gpio0_28_grp", "gpio0_30_grp",
  572. "gpio0_32_grp", "gpio0_34_grp", "gpio0_36_grp",
  573. "gpio0_38_grp", "gpio0_40_grp", "gpio0_42_grp",
  574. "gpio0_44_grp", "gpio0_46_grp", "gpio0_48_grp",
  575. "gpio0_50_grp", "gpio0_52_grp", "gpio0_1_grp",
  576. "gpio0_3_grp", "gpio0_5_grp",
  577. "gpio0_9_grp", "gpio0_11_grp", "gpio0_13_grp",
  578. "gpio0_15_grp", "gpio0_17_grp", "gpio0_19_grp",
  579. "gpio0_21_grp", "gpio0_23_grp", "gpio0_25_grp",
  580. "gpio0_27_grp", "gpio0_29_grp", "gpio0_31_grp",
  581. "gpio0_33_grp", "gpio0_35_grp", "gpio0_37_grp",
  582. "gpio0_39_grp", "gpio0_41_grp", "gpio0_43_grp",
  583. "gpio0_45_grp", "gpio0_47_grp", "gpio0_49_grp",
  584. "gpio0_51_grp", "gpio0_53_grp", "sdio0_emio_cd_grp"};
  585. static const char * const sdio0_wp_groups[] = {"gpio0_0_grp",
  586. "gpio0_2_grp", "gpio0_4_grp", "gpio0_6_grp",
  587. "gpio0_10_grp", "gpio0_12_grp",
  588. "gpio0_14_grp", "gpio0_16_grp", "gpio0_18_grp",
  589. "gpio0_20_grp", "gpio0_22_grp", "gpio0_24_grp",
  590. "gpio0_26_grp", "gpio0_28_grp", "gpio0_30_grp",
  591. "gpio0_32_grp", "gpio0_34_grp", "gpio0_36_grp",
  592. "gpio0_38_grp", "gpio0_40_grp", "gpio0_42_grp",
  593. "gpio0_44_grp", "gpio0_46_grp", "gpio0_48_grp",
  594. "gpio0_50_grp", "gpio0_52_grp", "gpio0_1_grp",
  595. "gpio0_3_grp", "gpio0_5_grp",
  596. "gpio0_9_grp", "gpio0_11_grp", "gpio0_13_grp",
  597. "gpio0_15_grp", "gpio0_17_grp", "gpio0_19_grp",
  598. "gpio0_21_grp", "gpio0_23_grp", "gpio0_25_grp",
  599. "gpio0_27_grp", "gpio0_29_grp", "gpio0_31_grp",
  600. "gpio0_33_grp", "gpio0_35_grp", "gpio0_37_grp",
  601. "gpio0_39_grp", "gpio0_41_grp", "gpio0_43_grp",
  602. "gpio0_45_grp", "gpio0_47_grp", "gpio0_49_grp",
  603. "gpio0_51_grp", "gpio0_53_grp", "sdio0_emio_wp_grp"};
  604. static const char * const sdio1_cd_groups[] = {"gpio0_0_grp",
  605. "gpio0_2_grp", "gpio0_4_grp", "gpio0_6_grp",
  606. "gpio0_10_grp", "gpio0_12_grp",
  607. "gpio0_14_grp", "gpio0_16_grp", "gpio0_18_grp",
  608. "gpio0_20_grp", "gpio0_22_grp", "gpio0_24_grp",
  609. "gpio0_26_grp", "gpio0_28_grp", "gpio0_30_grp",
  610. "gpio0_32_grp", "gpio0_34_grp", "gpio0_36_grp",
  611. "gpio0_38_grp", "gpio0_40_grp", "gpio0_42_grp",
  612. "gpio0_44_grp", "gpio0_46_grp", "gpio0_48_grp",
  613. "gpio0_50_grp", "gpio0_52_grp", "gpio0_1_grp",
  614. "gpio0_3_grp", "gpio0_5_grp",
  615. "gpio0_9_grp", "gpio0_11_grp", "gpio0_13_grp",
  616. "gpio0_15_grp", "gpio0_17_grp", "gpio0_19_grp",
  617. "gpio0_21_grp", "gpio0_23_grp", "gpio0_25_grp",
  618. "gpio0_27_grp", "gpio0_29_grp", "gpio0_31_grp",
  619. "gpio0_33_grp", "gpio0_35_grp", "gpio0_37_grp",
  620. "gpio0_39_grp", "gpio0_41_grp", "gpio0_43_grp",
  621. "gpio0_45_grp", "gpio0_47_grp", "gpio0_49_grp",
  622. "gpio0_51_grp", "gpio0_53_grp", "sdio1_emio_cd_grp"};
  623. static const char * const sdio1_wp_groups[] = {"gpio0_0_grp",
  624. "gpio0_2_grp", "gpio0_4_grp", "gpio0_6_grp",
  625. "gpio0_10_grp", "gpio0_12_grp",
  626. "gpio0_14_grp", "gpio0_16_grp", "gpio0_18_grp",
  627. "gpio0_20_grp", "gpio0_22_grp", "gpio0_24_grp",
  628. "gpio0_26_grp", "gpio0_28_grp", "gpio0_30_grp",
  629. "gpio0_32_grp", "gpio0_34_grp", "gpio0_36_grp",
  630. "gpio0_38_grp", "gpio0_40_grp", "gpio0_42_grp",
  631. "gpio0_44_grp", "gpio0_46_grp", "gpio0_48_grp",
  632. "gpio0_50_grp", "gpio0_52_grp", "gpio0_1_grp",
  633. "gpio0_3_grp", "gpio0_5_grp",
  634. "gpio0_9_grp", "gpio0_11_grp", "gpio0_13_grp",
  635. "gpio0_15_grp", "gpio0_17_grp", "gpio0_19_grp",
  636. "gpio0_21_grp", "gpio0_23_grp", "gpio0_25_grp",
  637. "gpio0_27_grp", "gpio0_29_grp", "gpio0_31_grp",
  638. "gpio0_33_grp", "gpio0_35_grp", "gpio0_37_grp",
  639. "gpio0_39_grp", "gpio0_41_grp", "gpio0_43_grp",
  640. "gpio0_45_grp", "gpio0_47_grp", "gpio0_49_grp",
  641. "gpio0_51_grp", "gpio0_53_grp", "sdio1_emio_wp_grp"};
  642. static const char * const smc0_nor_groups[] = {"smc0_nor"};
  643. static const char * const smc0_nor_cs1_groups[] = {"smc0_nor_cs1_grp"};
  644. static const char * const smc0_nor_addr25_groups[] = {"smc0_nor_addr25_grp"};
  645. static const char * const smc0_nand_groups[] = {"smc0_nand"};
  646. static const char * const can0_groups[] = {"can0_0_grp", "can0_1_grp",
  647. "can0_2_grp", "can0_3_grp", "can0_4_grp", "can0_5_grp",
  648. "can0_6_grp", "can0_7_grp", "can0_8_grp", "can0_9_grp",
  649. "can0_10_grp"};
  650. static const char * const can1_groups[] = {"can1_0_grp", "can1_1_grp",
  651. "can1_2_grp", "can1_3_grp", "can1_4_grp", "can1_5_grp",
  652. "can1_6_grp", "can1_7_grp", "can1_8_grp", "can1_9_grp",
  653. "can1_10_grp", "can1_11_grp"};
  654. static const char * const uart0_groups[] = {"uart0_0_grp", "uart0_1_grp",
  655. "uart0_2_grp", "uart0_3_grp", "uart0_4_grp", "uart0_5_grp",
  656. "uart0_6_grp", "uart0_7_grp", "uart0_8_grp", "uart0_9_grp",
  657. "uart0_10_grp"};
  658. static const char * const uart1_groups[] = {"uart1_0_grp", "uart1_1_grp",
  659. "uart1_2_grp", "uart1_3_grp", "uart1_4_grp", "uart1_5_grp",
  660. "uart1_6_grp", "uart1_7_grp", "uart1_8_grp", "uart1_9_grp",
  661. "uart1_10_grp", "uart1_11_grp"};
  662. static const char * const i2c0_groups[] = {"i2c0_0_grp", "i2c0_1_grp",
  663. "i2c0_2_grp", "i2c0_3_grp", "i2c0_4_grp", "i2c0_5_grp",
  664. "i2c0_6_grp", "i2c0_7_grp", "i2c0_8_grp", "i2c0_9_grp",
  665. "i2c0_10_grp"};
  666. static const char * const i2c1_groups[] = {"i2c1_0_grp", "i2c1_1_grp",
  667. "i2c1_2_grp", "i2c1_3_grp", "i2c1_4_grp", "i2c1_5_grp",
  668. "i2c1_6_grp", "i2c1_7_grp", "i2c1_8_grp", "i2c1_9_grp",
  669. "i2c1_10_grp"};
  670. static const char * const ttc0_groups[] = {"ttc0_0_grp", "ttc0_1_grp",
  671. "ttc0_2_grp"};
  672. static const char * const ttc1_groups[] = {"ttc1_0_grp", "ttc1_1_grp",
  673. "ttc1_2_grp"};
  674. static const char * const swdt0_groups[] = {"swdt0_0_grp", "swdt0_1_grp",
  675. "swdt0_2_grp", "swdt0_3_grp", "swdt0_4_grp"};
  676. static const char * const gpio0_groups[] = {"gpio0_0_grp",
  677. "gpio0_2_grp", "gpio0_4_grp", "gpio0_6_grp",
  678. "gpio0_8_grp", "gpio0_10_grp", "gpio0_12_grp",
  679. "gpio0_14_grp", "gpio0_16_grp", "gpio0_18_grp",
  680. "gpio0_20_grp", "gpio0_22_grp", "gpio0_24_grp",
  681. "gpio0_26_grp", "gpio0_28_grp", "gpio0_30_grp",
  682. "gpio0_32_grp", "gpio0_34_grp", "gpio0_36_grp",
  683. "gpio0_38_grp", "gpio0_40_grp", "gpio0_42_grp",
  684. "gpio0_44_grp", "gpio0_46_grp", "gpio0_48_grp",
  685. "gpio0_50_grp", "gpio0_52_grp", "gpio0_1_grp",
  686. "gpio0_3_grp", "gpio0_5_grp", "gpio0_7_grp",
  687. "gpio0_9_grp", "gpio0_11_grp", "gpio0_13_grp",
  688. "gpio0_15_grp", "gpio0_17_grp", "gpio0_19_grp",
  689. "gpio0_21_grp", "gpio0_23_grp", "gpio0_25_grp",
  690. "gpio0_27_grp", "gpio0_29_grp", "gpio0_31_grp",
  691. "gpio0_33_grp", "gpio0_35_grp", "gpio0_37_grp",
  692. "gpio0_39_grp", "gpio0_41_grp", "gpio0_43_grp",
  693. "gpio0_45_grp", "gpio0_47_grp", "gpio0_49_grp",
  694. "gpio0_51_grp", "gpio0_53_grp"};
  695. #define DEFINE_ZYNQ_PINMUX_FUNCTION(fname, mval) \
  696. [ZYNQ_PMUX_##fname] = { \
  697. .name = #fname, \
  698. .groups = fname##_groups, \
  699. .ngroups = ARRAY_SIZE(fname##_groups), \
  700. .mux_val = mval, \
  701. }
  702. #define DEFINE_ZYNQ_PINMUX_FUNCTION_MUX(fname, mval, mux, mask, shift) \
  703. [ZYNQ_PMUX_##fname] = { \
  704. .name = #fname, \
  705. .groups = fname##_groups, \
  706. .ngroups = ARRAY_SIZE(fname##_groups), \
  707. .mux_val = mval, \
  708. .mux_mask = mask, \
  709. .mux_shift = shift, \
  710. }
  711. #define ZYNQ_SDIO_WP_SHIFT 0
  712. #define ZYNQ_SDIO_WP_MASK (0x3f << ZYNQ_SDIO_WP_SHIFT)
  713. #define ZYNQ_SDIO_CD_SHIFT 16
  714. #define ZYNQ_SDIO_CD_MASK (0x3f << ZYNQ_SDIO_CD_SHIFT)
  715. static const struct zynq_pinmux_function zynq_pmux_functions[] = {
  716. DEFINE_ZYNQ_PINMUX_FUNCTION(ethernet0, 1),
  717. DEFINE_ZYNQ_PINMUX_FUNCTION(ethernet1, 1),
  718. DEFINE_ZYNQ_PINMUX_FUNCTION(usb0, 2),
  719. DEFINE_ZYNQ_PINMUX_FUNCTION(usb1, 2),
  720. DEFINE_ZYNQ_PINMUX_FUNCTION(mdio0, 0x40),
  721. DEFINE_ZYNQ_PINMUX_FUNCTION(mdio1, 0x50),
  722. DEFINE_ZYNQ_PINMUX_FUNCTION(qspi0, 1),
  723. DEFINE_ZYNQ_PINMUX_FUNCTION(qspi1, 1),
  724. DEFINE_ZYNQ_PINMUX_FUNCTION(qspi_fbclk, 1),
  725. DEFINE_ZYNQ_PINMUX_FUNCTION(qspi_cs1, 1),
  726. DEFINE_ZYNQ_PINMUX_FUNCTION(spi0, 0x50),
  727. DEFINE_ZYNQ_PINMUX_FUNCTION(spi1, 0x50),
  728. DEFINE_ZYNQ_PINMUX_FUNCTION(sdio0, 0x40),
  729. DEFINE_ZYNQ_PINMUX_FUNCTION(sdio0_pc, 0xc),
  730. DEFINE_ZYNQ_PINMUX_FUNCTION_MUX(sdio0_wp, 0, 130, ZYNQ_SDIO_WP_MASK,
  731. ZYNQ_SDIO_WP_SHIFT),
  732. DEFINE_ZYNQ_PINMUX_FUNCTION_MUX(sdio0_cd, 0, 130, ZYNQ_SDIO_CD_MASK,
  733. ZYNQ_SDIO_CD_SHIFT),
  734. DEFINE_ZYNQ_PINMUX_FUNCTION(sdio1, 0x40),
  735. DEFINE_ZYNQ_PINMUX_FUNCTION(sdio1_pc, 0xc),
  736. DEFINE_ZYNQ_PINMUX_FUNCTION_MUX(sdio1_wp, 0, 134, ZYNQ_SDIO_WP_MASK,
  737. ZYNQ_SDIO_WP_SHIFT),
  738. DEFINE_ZYNQ_PINMUX_FUNCTION_MUX(sdio1_cd, 0, 134, ZYNQ_SDIO_CD_MASK,
  739. ZYNQ_SDIO_CD_SHIFT),
  740. DEFINE_ZYNQ_PINMUX_FUNCTION(smc0_nor, 4),
  741. DEFINE_ZYNQ_PINMUX_FUNCTION(smc0_nor_cs1, 8),
  742. DEFINE_ZYNQ_PINMUX_FUNCTION(smc0_nor_addr25, 4),
  743. DEFINE_ZYNQ_PINMUX_FUNCTION(smc0_nand, 8),
  744. DEFINE_ZYNQ_PINMUX_FUNCTION(can0, 0x10),
  745. DEFINE_ZYNQ_PINMUX_FUNCTION(can1, 0x10),
  746. DEFINE_ZYNQ_PINMUX_FUNCTION(uart0, 0x70),
  747. DEFINE_ZYNQ_PINMUX_FUNCTION(uart1, 0x70),
  748. DEFINE_ZYNQ_PINMUX_FUNCTION(i2c0, 0x20),
  749. DEFINE_ZYNQ_PINMUX_FUNCTION(i2c1, 0x20),
  750. DEFINE_ZYNQ_PINMUX_FUNCTION(ttc0, 0x60),
  751. DEFINE_ZYNQ_PINMUX_FUNCTION(ttc1, 0x60),
  752. DEFINE_ZYNQ_PINMUX_FUNCTION(swdt0, 0x30),
  753. DEFINE_ZYNQ_PINMUX_FUNCTION(gpio0, 0),
  754. };
  755. /* pinctrl */
  756. static int zynq_pctrl_get_groups_count(struct pinctrl_dev *pctldev)
  757. {
  758. struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  759. return pctrl->ngroups;
  760. }
  761. static const char *zynq_pctrl_get_group_name(struct pinctrl_dev *pctldev,
  762. unsigned selector)
  763. {
  764. struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  765. return pctrl->groups[selector].name;
  766. }
  767. static int zynq_pctrl_get_group_pins(struct pinctrl_dev *pctldev,
  768. unsigned selector,
  769. const unsigned **pins,
  770. unsigned *num_pins)
  771. {
  772. struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  773. *pins = pctrl->groups[selector].pins;
  774. *num_pins = pctrl->groups[selector].npins;
  775. return 0;
  776. }
  777. static const struct pinctrl_ops zynq_pctrl_ops = {
  778. .get_groups_count = zynq_pctrl_get_groups_count,
  779. .get_group_name = zynq_pctrl_get_group_name,
  780. .get_group_pins = zynq_pctrl_get_group_pins,
  781. .dt_node_to_map = pinconf_generic_dt_node_to_map_all,
  782. .dt_free_map = pinctrl_utils_dt_free_map,
  783. };
  784. /* pinmux */
  785. static int zynq_pmux_get_functions_count(struct pinctrl_dev *pctldev)
  786. {
  787. struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  788. return pctrl->nfuncs;
  789. }
  790. static const char *zynq_pmux_get_function_name(struct pinctrl_dev *pctldev,
  791. unsigned selector)
  792. {
  793. struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  794. return pctrl->funcs[selector].name;
  795. }
  796. static int zynq_pmux_get_function_groups(struct pinctrl_dev *pctldev,
  797. unsigned selector,
  798. const char * const **groups,
  799. unsigned * const num_groups)
  800. {
  801. struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  802. *groups = pctrl->funcs[selector].groups;
  803. *num_groups = pctrl->funcs[selector].ngroups;
  804. return 0;
  805. }
  806. static int zynq_pinmux_set_mux(struct pinctrl_dev *pctldev,
  807. unsigned function,
  808. unsigned group)
  809. {
  810. int i, ret;
  811. struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  812. const struct zynq_pctrl_group *pgrp = &pctrl->groups[group];
  813. const struct zynq_pinmux_function *func = &pctrl->funcs[function];
  814. /*
  815. * SD WP & CD are special. They have dedicated registers
  816. * to mux them in
  817. */
  818. if (function == ZYNQ_PMUX_sdio0_cd || function == ZYNQ_PMUX_sdio0_wp ||
  819. function == ZYNQ_PMUX_sdio1_cd ||
  820. function == ZYNQ_PMUX_sdio1_wp) {
  821. u32 reg;
  822. ret = regmap_read(pctrl->syscon,
  823. pctrl->pctrl_offset + func->mux, &reg);
  824. if (ret)
  825. return ret;
  826. reg &= ~func->mux_mask;
  827. reg |= pgrp->pins[0] << func->mux_shift;
  828. ret = regmap_write(pctrl->syscon,
  829. pctrl->pctrl_offset + func->mux, reg);
  830. if (ret)
  831. return ret;
  832. } else {
  833. for (i = 0; i < pgrp->npins; i++) {
  834. unsigned int pin = pgrp->pins[i];
  835. u32 reg, addr = pctrl->pctrl_offset + (4 * pin);
  836. ret = regmap_read(pctrl->syscon, addr, &reg);
  837. if (ret)
  838. return ret;
  839. reg &= ~ZYNQ_PINMUX_MUX_MASK;
  840. reg |= func->mux_val << ZYNQ_PINMUX_MUX_SHIFT;
  841. ret = regmap_write(pctrl->syscon, addr, reg);
  842. if (ret)
  843. return ret;
  844. }
  845. }
  846. return 0;
  847. }
  848. static const struct pinmux_ops zynq_pinmux_ops = {
  849. .get_functions_count = zynq_pmux_get_functions_count,
  850. .get_function_name = zynq_pmux_get_function_name,
  851. .get_function_groups = zynq_pmux_get_function_groups,
  852. .set_mux = zynq_pinmux_set_mux,
  853. };
  854. /* pinconfig */
  855. #define ZYNQ_PINCONF_TRISTATE BIT(0)
  856. #define ZYNQ_PINCONF_SPEED BIT(8)
  857. #define ZYNQ_PINCONF_PULLUP BIT(12)
  858. #define ZYNQ_PINCONF_DISABLE_RECVR BIT(13)
  859. #define ZYNQ_PINCONF_IOTYPE_SHIFT 9
  860. #define ZYNQ_PINCONF_IOTYPE_MASK (7 << ZYNQ_PINCONF_IOTYPE_SHIFT)
  861. enum zynq_io_standards {
  862. zynq_iostd_min,
  863. zynq_iostd_lvcmos18,
  864. zynq_iostd_lvcmos25,
  865. zynq_iostd_lvcmos33,
  866. zynq_iostd_hstl,
  867. zynq_iostd_max
  868. };
  869. /**
  870. * enum zynq_pin_config_param - possible pin configuration parameters
  871. * @PIN_CONFIG_IOSTANDARD: if the pin can select an IO standard, the argument to
  872. * this parameter (on a custom format) tells the driver which alternative
  873. * IO standard to use.
  874. */
  875. enum zynq_pin_config_param {
  876. PIN_CONFIG_IOSTANDARD = PIN_CONFIG_END + 1,
  877. };
  878. static const struct pinconf_generic_params zynq_dt_params[] = {
  879. {"io-standard", PIN_CONFIG_IOSTANDARD, zynq_iostd_lvcmos18},
  880. };
  881. #ifdef CONFIG_DEBUG_FS
  882. static const struct pin_config_item zynq_conf_items[ARRAY_SIZE(zynq_dt_params)] = {
  883. PCONFDUMP(PIN_CONFIG_IOSTANDARD, "IO-standard", NULL, true),
  884. };
  885. #endif
  886. static unsigned int zynq_pinconf_iostd_get(u32 reg)
  887. {
  888. return (reg & ZYNQ_PINCONF_IOTYPE_MASK) >> ZYNQ_PINCONF_IOTYPE_SHIFT;
  889. }
  890. static int zynq_pinconf_cfg_get(struct pinctrl_dev *pctldev,
  891. unsigned pin,
  892. unsigned long *config)
  893. {
  894. u32 reg;
  895. int ret;
  896. unsigned int arg = 0;
  897. unsigned int param = pinconf_to_config_param(*config);
  898. struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  899. if (pin >= ZYNQ_NUM_MIOS)
  900. return -ENOTSUPP;
  901. ret = regmap_read(pctrl->syscon, pctrl->pctrl_offset + (4 * pin), &reg);
  902. if (ret)
  903. return -EIO;
  904. switch (param) {
  905. case PIN_CONFIG_BIAS_PULL_UP:
  906. if (!(reg & ZYNQ_PINCONF_PULLUP))
  907. return -EINVAL;
  908. arg = 1;
  909. break;
  910. case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
  911. if (!(reg & ZYNQ_PINCONF_TRISTATE))
  912. return -EINVAL;
  913. arg = 1;
  914. break;
  915. case PIN_CONFIG_BIAS_DISABLE:
  916. if (reg & ZYNQ_PINCONF_PULLUP || reg & ZYNQ_PINCONF_TRISTATE)
  917. return -EINVAL;
  918. break;
  919. case PIN_CONFIG_SLEW_RATE:
  920. arg = !!(reg & ZYNQ_PINCONF_SPEED);
  921. break;
  922. case PIN_CONFIG_LOW_POWER_MODE:
  923. {
  924. enum zynq_io_standards iostd = zynq_pinconf_iostd_get(reg);
  925. if (iostd != zynq_iostd_hstl)
  926. return -EINVAL;
  927. if (!(reg & ZYNQ_PINCONF_DISABLE_RECVR))
  928. return -EINVAL;
  929. arg = !!(reg & ZYNQ_PINCONF_DISABLE_RECVR);
  930. break;
  931. }
  932. case PIN_CONFIG_IOSTANDARD:
  933. arg = zynq_pinconf_iostd_get(reg);
  934. break;
  935. default:
  936. return -ENOTSUPP;
  937. }
  938. *config = pinconf_to_config_packed(param, arg);
  939. return 0;
  940. }
  941. static int zynq_pinconf_cfg_set(struct pinctrl_dev *pctldev,
  942. unsigned pin,
  943. unsigned long *configs,
  944. unsigned num_configs)
  945. {
  946. int i, ret;
  947. u32 reg;
  948. u32 pullup = 0;
  949. u32 tristate = 0;
  950. struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  951. if (pin >= ZYNQ_NUM_MIOS)
  952. return -ENOTSUPP;
  953. ret = regmap_read(pctrl->syscon, pctrl->pctrl_offset + (4 * pin), &reg);
  954. if (ret)
  955. return -EIO;
  956. for (i = 0; i < num_configs; i++) {
  957. unsigned int param = pinconf_to_config_param(configs[i]);
  958. unsigned int arg = pinconf_to_config_argument(configs[i]);
  959. switch (param) {
  960. case PIN_CONFIG_BIAS_PULL_UP:
  961. pullup = ZYNQ_PINCONF_PULLUP;
  962. break;
  963. case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
  964. tristate = ZYNQ_PINCONF_TRISTATE;
  965. break;
  966. case PIN_CONFIG_BIAS_DISABLE:
  967. reg &= ~(ZYNQ_PINCONF_PULLUP | ZYNQ_PINCONF_TRISTATE);
  968. break;
  969. case PIN_CONFIG_SLEW_RATE:
  970. if (arg)
  971. reg |= ZYNQ_PINCONF_SPEED;
  972. else
  973. reg &= ~ZYNQ_PINCONF_SPEED;
  974. break;
  975. case PIN_CONFIG_IOSTANDARD:
  976. if (arg <= zynq_iostd_min || arg >= zynq_iostd_max) {
  977. dev_warn(pctldev->dev,
  978. "unsupported IO standard '%u'\n",
  979. param);
  980. break;
  981. }
  982. reg &= ~ZYNQ_PINCONF_IOTYPE_MASK;
  983. reg |= arg << ZYNQ_PINCONF_IOTYPE_SHIFT;
  984. break;
  985. case PIN_CONFIG_LOW_POWER_MODE:
  986. if (arg)
  987. reg |= ZYNQ_PINCONF_DISABLE_RECVR;
  988. else
  989. reg &= ~ZYNQ_PINCONF_DISABLE_RECVR;
  990. break;
  991. default:
  992. dev_warn(pctldev->dev,
  993. "unsupported configuration parameter '%u'\n",
  994. param);
  995. continue;
  996. }
  997. }
  998. if (tristate || pullup) {
  999. reg &= ~(ZYNQ_PINCONF_PULLUP | ZYNQ_PINCONF_TRISTATE);
  1000. reg |= tristate | pullup;
  1001. }
  1002. ret = regmap_write(pctrl->syscon, pctrl->pctrl_offset + (4 * pin), reg);
  1003. if (ret)
  1004. return -EIO;
  1005. return 0;
  1006. }
  1007. static int zynq_pinconf_group_set(struct pinctrl_dev *pctldev,
  1008. unsigned selector,
  1009. unsigned long *configs,
  1010. unsigned num_configs)
  1011. {
  1012. int i, ret;
  1013. struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  1014. const struct zynq_pctrl_group *pgrp = &pctrl->groups[selector];
  1015. for (i = 0; i < pgrp->npins; i++) {
  1016. ret = zynq_pinconf_cfg_set(pctldev, pgrp->pins[i], configs,
  1017. num_configs);
  1018. if (ret)
  1019. return ret;
  1020. }
  1021. return 0;
  1022. }
  1023. static const struct pinconf_ops zynq_pinconf_ops = {
  1024. .is_generic = true,
  1025. .pin_config_get = zynq_pinconf_cfg_get,
  1026. .pin_config_set = zynq_pinconf_cfg_set,
  1027. .pin_config_group_set = zynq_pinconf_group_set,
  1028. };
  1029. static struct pinctrl_desc zynq_desc = {
  1030. .name = "zynq_pinctrl",
  1031. .pins = zynq_pins,
  1032. .npins = ARRAY_SIZE(zynq_pins),
  1033. .pctlops = &zynq_pctrl_ops,
  1034. .pmxops = &zynq_pinmux_ops,
  1035. .confops = &zynq_pinconf_ops,
  1036. .num_custom_params = ARRAY_SIZE(zynq_dt_params),
  1037. .custom_params = zynq_dt_params,
  1038. #ifdef CONFIG_DEBUG_FS
  1039. .custom_conf_items = zynq_conf_items,
  1040. #endif
  1041. .owner = THIS_MODULE,
  1042. };
  1043. static int zynq_pinctrl_probe(struct platform_device *pdev)
  1044. {
  1045. struct resource *res;
  1046. struct zynq_pinctrl *pctrl;
  1047. pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
  1048. if (!pctrl)
  1049. return -ENOMEM;
  1050. pctrl->syscon = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
  1051. "syscon");
  1052. if (IS_ERR(pctrl->syscon)) {
  1053. dev_err(&pdev->dev, "unable to get syscon\n");
  1054. return PTR_ERR(pctrl->syscon);
  1055. }
  1056. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1057. if (!res) {
  1058. dev_err(&pdev->dev, "missing IO resource\n");
  1059. return -ENODEV;
  1060. }
  1061. pctrl->pctrl_offset = res->start;
  1062. pctrl->groups = zynq_pctrl_groups;
  1063. pctrl->ngroups = ARRAY_SIZE(zynq_pctrl_groups);
  1064. pctrl->funcs = zynq_pmux_functions;
  1065. pctrl->nfuncs = ARRAY_SIZE(zynq_pmux_functions);
  1066. pctrl->pctrl = pinctrl_register(&zynq_desc, &pdev->dev, pctrl);
  1067. if (!pctrl->pctrl)
  1068. return -ENOMEM;
  1069. platform_set_drvdata(pdev, pctrl);
  1070. dev_info(&pdev->dev, "zynq pinctrl initialized\n");
  1071. return 0;
  1072. }
  1073. int zynq_pinctrl_remove(struct platform_device *pdev)
  1074. {
  1075. struct zynq_pinctrl *pctrl = platform_get_drvdata(pdev);
  1076. pinctrl_unregister(pctrl->pctrl);
  1077. return 0;
  1078. }
  1079. static const struct of_device_id zynq_pinctrl_of_match[] = {
  1080. { .compatible = "xlnx,pinctrl-zynq" },
  1081. { }
  1082. };
  1083. MODULE_DEVICE_TABLE(of, zynq_pinctrl_of_match);
  1084. static struct platform_driver zynq_pinctrl_driver = {
  1085. .driver = {
  1086. .name = "zynq-pinctrl",
  1087. .of_match_table = zynq_pinctrl_of_match,
  1088. },
  1089. .probe = zynq_pinctrl_probe,
  1090. .remove = zynq_pinctrl_remove,
  1091. };
  1092. module_platform_driver(zynq_pinctrl_driver);
  1093. MODULE_AUTHOR("Sören Brinkmann <soren.brinkmann@xilinx.com>");
  1094. MODULE_DESCRIPTION("Xilinx Zynq pinctrl driver");
  1095. MODULE_LICENSE("GPL");