pinctrl-zynq.c 43 KB

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