pinctrl-mt7629.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * The MT7629 driver based on Linux generic pinctrl binding.
  4. *
  5. * Copyright (C) 2018 MediaTek Inc.
  6. * Author: Ryder Lee <[email protected]>
  7. */
  8. #include "pinctrl-moore.h"
  9. #define MT7629_PIN(_number, _name, _eint_n) \
  10. MTK_PIN(_number, _name, 0, _eint_n, DRV_GRP1)
  11. static const struct mtk_pin_field_calc mt7629_pin_mode_range[] = {
  12. PIN_FIELD(0, 78, 0x300, 0x10, 0, 4),
  13. };
  14. static const struct mtk_pin_field_calc mt7629_pin_dir_range[] = {
  15. PIN_FIELD(0, 78, 0x0, 0x10, 0, 1),
  16. };
  17. static const struct mtk_pin_field_calc mt7629_pin_di_range[] = {
  18. PIN_FIELD(0, 78, 0x200, 0x10, 0, 1),
  19. };
  20. static const struct mtk_pin_field_calc mt7629_pin_do_range[] = {
  21. PIN_FIELD(0, 78, 0x100, 0x10, 0, 1),
  22. };
  23. static const struct mtk_pin_field_calc mt7629_pin_ies_range[] = {
  24. PIN_FIELD(0, 10, 0x1000, 0x10, 0, 1),
  25. PIN_FIELD(11, 18, 0x2000, 0x10, 0, 1),
  26. PIN_FIELD(19, 32, 0x3000, 0x10, 0, 1),
  27. PIN_FIELD(33, 48, 0x4000, 0x10, 0, 1),
  28. PIN_FIELD(49, 50, 0x5000, 0x10, 0, 1),
  29. PIN_FIELD(51, 69, 0x6000, 0x10, 0, 1),
  30. PIN_FIELD(70, 78, 0x7000, 0x10, 0, 1),
  31. };
  32. static const struct mtk_pin_field_calc mt7629_pin_smt_range[] = {
  33. PIN_FIELD(0, 10, 0x1100, 0x10, 0, 1),
  34. PIN_FIELD(11, 18, 0x2100, 0x10, 0, 1),
  35. PIN_FIELD(19, 32, 0x3100, 0x10, 0, 1),
  36. PIN_FIELD(33, 48, 0x4100, 0x10, 0, 1),
  37. PIN_FIELD(49, 50, 0x5100, 0x10, 0, 1),
  38. PIN_FIELD(51, 69, 0x6100, 0x10, 0, 1),
  39. PIN_FIELD(70, 78, 0x7100, 0x10, 0, 1),
  40. };
  41. static const struct mtk_pin_field_calc mt7629_pin_pullen_range[] = {
  42. PIN_FIELD(0, 10, 0x1400, 0x10, 0, 1),
  43. PIN_FIELD(11, 18, 0x2400, 0x10, 0, 1),
  44. PIN_FIELD(19, 32, 0x3400, 0x10, 0, 1),
  45. PIN_FIELD(33, 48, 0x4400, 0x10, 0, 1),
  46. PIN_FIELD(49, 50, 0x5400, 0x10, 0, 1),
  47. PIN_FIELD(51, 69, 0x6400, 0x10, 0, 1),
  48. PIN_FIELD(70, 78, 0x7400, 0x10, 0, 1),
  49. };
  50. static const struct mtk_pin_field_calc mt7629_pin_pullsel_range[] = {
  51. PIN_FIELD(0, 10, 0x1500, 0x10, 0, 1),
  52. PIN_FIELD(11, 18, 0x2500, 0x10, 0, 1),
  53. PIN_FIELD(19, 32, 0x3500, 0x10, 0, 1),
  54. PIN_FIELD(33, 48, 0x4500, 0x10, 0, 1),
  55. PIN_FIELD(49, 50, 0x5500, 0x10, 0, 1),
  56. PIN_FIELD(51, 69, 0x6500, 0x10, 0, 1),
  57. PIN_FIELD(70, 78, 0x7500, 0x10, 0, 1),
  58. };
  59. static const struct mtk_pin_field_calc mt7629_pin_drv_range[] = {
  60. PIN_FIELD(0, 10, 0x1600, 0x10, 0, 4),
  61. PIN_FIELD(11, 18, 0x2600, 0x10, 0, 4),
  62. PIN_FIELD(19, 32, 0x3600, 0x10, 0, 4),
  63. PIN_FIELD(33, 48, 0x4600, 0x10, 0, 4),
  64. PIN_FIELD(49, 50, 0x5600, 0x10, 0, 4),
  65. PIN_FIELD(51, 69, 0x6600, 0x10, 0, 4),
  66. PIN_FIELD(70, 78, 0x7600, 0x10, 0, 4),
  67. };
  68. static const struct mtk_pin_field_calc mt7629_pin_tdsel_range[] = {
  69. PIN_FIELD(0, 10, 0x1200, 0x10, 0, 4),
  70. PIN_FIELD(11, 18, 0x2200, 0x10, 0, 4),
  71. PIN_FIELD(19, 32, 0x3200, 0x10, 0, 4),
  72. PIN_FIELD(33, 48, 0x4200, 0x10, 0, 4),
  73. PIN_FIELD(49, 50, 0x5200, 0x10, 0, 4),
  74. PIN_FIELD(51, 69, 0x6200, 0x10, 0, 4),
  75. PIN_FIELD(70, 78, 0x7200, 0x10, 0, 4),
  76. };
  77. static const struct mtk_pin_field_calc mt7629_pin_rdsel_range[] = {
  78. PIN_FIELD(0, 10, 0x1300, 0x10, 0, 4),
  79. PIN_FIELD(11, 18, 0x2300, 0x10, 0, 4),
  80. PIN_FIELD(19, 32, 0x3300, 0x10, 0, 4),
  81. PIN_FIELD(33, 48, 0x4300, 0x10, 0, 4),
  82. PIN_FIELD(49, 50, 0x5300, 0x10, 0, 4),
  83. PIN_FIELD(51, 69, 0x6300, 0x10, 0, 4),
  84. PIN_FIELD(70, 78, 0x7300, 0x10, 0, 4),
  85. };
  86. static const struct mtk_pin_reg_calc mt7629_reg_cals[] = {
  87. [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7629_pin_mode_range),
  88. [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7629_pin_dir_range),
  89. [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7629_pin_di_range),
  90. [PINCTRL_PIN_REG_DO] = MTK_RANGE(mt7629_pin_do_range),
  91. [PINCTRL_PIN_REG_IES] = MTK_RANGE(mt7629_pin_ies_range),
  92. [PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt7629_pin_smt_range),
  93. [PINCTRL_PIN_REG_PULLSEL] = MTK_RANGE(mt7629_pin_pullsel_range),
  94. [PINCTRL_PIN_REG_PULLEN] = MTK_RANGE(mt7629_pin_pullen_range),
  95. [PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt7629_pin_drv_range),
  96. [PINCTRL_PIN_REG_TDSEL] = MTK_RANGE(mt7629_pin_tdsel_range),
  97. [PINCTRL_PIN_REG_RDSEL] = MTK_RANGE(mt7629_pin_rdsel_range),
  98. };
  99. static const struct mtk_pin_desc mt7629_pins[] = {
  100. MT7629_PIN(0, "TOP_5G_CLK", 53),
  101. MT7629_PIN(1, "TOP_5G_DATA", 54),
  102. MT7629_PIN(2, "WF0_5G_HB0", 55),
  103. MT7629_PIN(3, "WF0_5G_HB1", 56),
  104. MT7629_PIN(4, "WF0_5G_HB2", 57),
  105. MT7629_PIN(5, "WF0_5G_HB3", 58),
  106. MT7629_PIN(6, "WF0_5G_HB4", 59),
  107. MT7629_PIN(7, "WF0_5G_HB5", 60),
  108. MT7629_PIN(8, "WF0_5G_HB6", 61),
  109. MT7629_PIN(9, "XO_REQ", 9),
  110. MT7629_PIN(10, "TOP_RST_N", 10),
  111. MT7629_PIN(11, "SYS_WATCHDOG", 11),
  112. MT7629_PIN(12, "EPHY_LED0_N_JTDO", 12),
  113. MT7629_PIN(13, "EPHY_LED1_N_JTDI", 13),
  114. MT7629_PIN(14, "EPHY_LED2_N_JTMS", 14),
  115. MT7629_PIN(15, "EPHY_LED3_N_JTCLK", 15),
  116. MT7629_PIN(16, "EPHY_LED4_N_JTRST_N", 16),
  117. MT7629_PIN(17, "WF2G_LED_N", 17),
  118. MT7629_PIN(18, "WF5G_LED_N", 18),
  119. MT7629_PIN(19, "I2C_SDA", 19),
  120. MT7629_PIN(20, "I2C_SCL", 20),
  121. MT7629_PIN(21, "GPIO_9", 21),
  122. MT7629_PIN(22, "GPIO_10", 22),
  123. MT7629_PIN(23, "GPIO_11", 23),
  124. MT7629_PIN(24, "GPIO_12", 24),
  125. MT7629_PIN(25, "UART1_TXD", 25),
  126. MT7629_PIN(26, "UART1_RXD", 26),
  127. MT7629_PIN(27, "UART1_CTS", 27),
  128. MT7629_PIN(28, "UART1_RTS", 28),
  129. MT7629_PIN(29, "UART2_TXD", 29),
  130. MT7629_PIN(30, "UART2_RXD", 30),
  131. MT7629_PIN(31, "UART2_CTS", 31),
  132. MT7629_PIN(32, "UART2_RTS", 32),
  133. MT7629_PIN(33, "MDI_TP_P1", 33),
  134. MT7629_PIN(34, "MDI_TN_P1", 34),
  135. MT7629_PIN(35, "MDI_RP_P1", 35),
  136. MT7629_PIN(36, "MDI_RN_P1", 36),
  137. MT7629_PIN(37, "MDI_RP_P2", 37),
  138. MT7629_PIN(38, "MDI_RN_P2", 38),
  139. MT7629_PIN(39, "MDI_TP_P2", 39),
  140. MT7629_PIN(40, "MDI_TN_P2", 40),
  141. MT7629_PIN(41, "MDI_TP_P3", 41),
  142. MT7629_PIN(42, "MDI_TN_P3", 42),
  143. MT7629_PIN(43, "MDI_RP_P3", 43),
  144. MT7629_PIN(44, "MDI_RN_P3", 44),
  145. MT7629_PIN(45, "MDI_RP_P4", 45),
  146. MT7629_PIN(46, "MDI_RN_P4", 46),
  147. MT7629_PIN(47, "MDI_TP_P4", 47),
  148. MT7629_PIN(48, "MDI_TN_P4", 48),
  149. MT7629_PIN(49, "SMI_MDC", 49),
  150. MT7629_PIN(50, "SMI_MDIO", 50),
  151. MT7629_PIN(51, "PCIE_PERESET_N", 51),
  152. MT7629_PIN(52, "PWM_0", 52),
  153. MT7629_PIN(53, "GPIO_0", 0),
  154. MT7629_PIN(54, "GPIO_1", 1),
  155. MT7629_PIN(55, "GPIO_2", 2),
  156. MT7629_PIN(56, "GPIO_3", 3),
  157. MT7629_PIN(57, "GPIO_4", 4),
  158. MT7629_PIN(58, "GPIO_5", 5),
  159. MT7629_PIN(59, "GPIO_6", 6),
  160. MT7629_PIN(60, "GPIO_7", 7),
  161. MT7629_PIN(61, "GPIO_8", 8),
  162. MT7629_PIN(62, "SPI_CLK", 62),
  163. MT7629_PIN(63, "SPI_CS", 63),
  164. MT7629_PIN(64, "SPI_MOSI", 64),
  165. MT7629_PIN(65, "SPI_MISO", 65),
  166. MT7629_PIN(66, "SPI_WP", 66),
  167. MT7629_PIN(67, "SPI_HOLD", 67),
  168. MT7629_PIN(68, "UART0_TXD", 68),
  169. MT7629_PIN(69, "UART0_RXD", 69),
  170. MT7629_PIN(70, "TOP_2G_CLK", 70),
  171. MT7629_PIN(71, "TOP_2G_DATA", 71),
  172. MT7629_PIN(72, "WF0_2G_HB0", 72),
  173. MT7629_PIN(73, "WF0_2G_HB1", 73),
  174. MT7629_PIN(74, "WF0_2G_HB2", 74),
  175. MT7629_PIN(75, "WF0_2G_HB3", 75),
  176. MT7629_PIN(76, "WF0_2G_HB4", 76),
  177. MT7629_PIN(77, "WF0_2G_HB5", 77),
  178. MT7629_PIN(78, "WF0_2G_HB6", 78),
  179. };
  180. /* List all groups consisting of these pins dedicated to the enablement of
  181. * certain hardware block and the corresponding mode for all of the pins.
  182. * The hardware probably has multiple combinations of these pinouts.
  183. */
  184. /* LED for EPHY */
  185. static int mt7629_ephy_leds_pins[] = { 12, 13, 14, 15, 16, 17, 18, };
  186. static int mt7629_ephy_leds_funcs[] = { 1, 1, 1, 1, 1, 1, 1, };
  187. static int mt7629_ephy_led0_pins[] = { 12, };
  188. static int mt7629_ephy_led0_funcs[] = { 1, };
  189. static int mt7629_ephy_led1_pins[] = { 13, };
  190. static int mt7629_ephy_led1_funcs[] = { 1, };
  191. static int mt7629_ephy_led2_pins[] = { 14, };
  192. static int mt7629_ephy_led2_funcs[] = { 1, };
  193. static int mt7629_ephy_led3_pins[] = { 15, };
  194. static int mt7629_ephy_led3_funcs[] = { 1, };
  195. static int mt7629_ephy_led4_pins[] = { 16, };
  196. static int mt7629_ephy_led4_funcs[] = { 1, };
  197. static int mt7629_wf2g_led_pins[] = { 17, };
  198. static int mt7629_wf2g_led_funcs[] = { 1, };
  199. static int mt7629_wf5g_led_pins[] = { 18, };
  200. static int mt7629_wf5g_led_funcs[] = { 1, };
  201. /* Watchdog */
  202. static int mt7629_watchdog_pins[] = { 11, };
  203. static int mt7629_watchdog_funcs[] = { 1, };
  204. /* LED for GPHY */
  205. static int mt7629_gphy_leds_0_pins[] = { 21, 22, 23, };
  206. static int mt7629_gphy_leds_0_funcs[] = { 2, 2, 2, };
  207. static int mt7629_gphy_led1_0_pins[] = { 21, };
  208. static int mt7629_gphy_led1_0_funcs[] = { 2, };
  209. static int mt7629_gphy_led2_0_pins[] = { 22, };
  210. static int mt7629_gphy_led2_0_funcs[] = { 2, };
  211. static int mt7629_gphy_led3_0_pins[] = { 23, };
  212. static int mt7629_gphy_led3_0_funcs[] = { 2, };
  213. static int mt7629_gphy_leds_1_pins[] = { 57, 58, 59, };
  214. static int mt7629_gphy_leds_1_funcs[] = { 1, 1, 1, };
  215. static int mt7629_gphy_led1_1_pins[] = { 57, };
  216. static int mt7629_gphy_led1_1_funcs[] = { 1, };
  217. static int mt7629_gphy_led2_1_pins[] = { 58, };
  218. static int mt7629_gphy_led2_1_funcs[] = { 1, };
  219. static int mt7629_gphy_led3_1_pins[] = { 59, };
  220. static int mt7629_gphy_led3_1_funcs[] = { 1, };
  221. /* I2C */
  222. static int mt7629_i2c_0_pins[] = { 19, 20, };
  223. static int mt7629_i2c_0_funcs[] = { 1, 1, };
  224. static int mt7629_i2c_1_pins[] = { 53, 54, };
  225. static int mt7629_i2c_1_funcs[] = { 1, 1, };
  226. /* SPI */
  227. static int mt7629_spi_0_pins[] = { 21, 22, 23, 24, };
  228. static int mt7629_spi_0_funcs[] = { 1, 1, 1, 1, };
  229. static int mt7629_spi_1_pins[] = { 62, 63, 64, 65, };
  230. static int mt7629_spi_1_funcs[] = { 1, 1, 1, 1, };
  231. static int mt7629_spi_wp_pins[] = { 66, };
  232. static int mt7629_spi_wp_funcs[] = { 1, };
  233. static int mt7629_spi_hold_pins[] = { 67, };
  234. static int mt7629_spi_hold_funcs[] = { 1, };
  235. /* UART */
  236. static int mt7629_uart1_0_txd_rxd_pins[] = { 25, 26, };
  237. static int mt7629_uart1_0_txd_rxd_funcs[] = { 1, 1, };
  238. static int mt7629_uart1_1_txd_rxd_pins[] = { 53, 54, };
  239. static int mt7629_uart1_1_txd_rxd_funcs[] = { 2, 2, };
  240. static int mt7629_uart2_0_txd_rxd_pins[] = { 29, 30, };
  241. static int mt7629_uart2_0_txd_rxd_funcs[] = { 1, 1, };
  242. static int mt7629_uart2_1_txd_rxd_pins[] = { 57, 58, };
  243. static int mt7629_uart2_1_txd_rxd_funcs[] = { 2, 2, };
  244. static int mt7629_uart1_0_cts_rts_pins[] = { 27, 28, };
  245. static int mt7629_uart1_0_cts_rts_funcs[] = { 1, 1, };
  246. static int mt7629_uart1_1_cts_rts_pins[] = { 55, 56, };
  247. static int mt7629_uart1_1_cts_rts_funcs[] = { 2, 2, };
  248. static int mt7629_uart2_0_cts_rts_pins[] = { 31, 32, };
  249. static int mt7629_uart2_0_cts_rts_funcs[] = { 1, 1, };
  250. static int mt7629_uart2_1_cts_rts_pins[] = { 59, 60, };
  251. static int mt7629_uart2_1_cts_rts_funcs[] = { 2, 2, };
  252. static int mt7629_uart0_txd_rxd_pins[] = { 68, 69, };
  253. static int mt7629_uart0_txd_rxd_funcs[] = { 1, 1, };
  254. /* MDC/MDIO */
  255. static int mt7629_mdc_mdio_pins[] = { 49, 50, };
  256. static int mt7629_mdc_mdio_funcs[] = { 1, 1, };
  257. /* PCIE */
  258. static int mt7629_pcie_pereset_pins[] = { 51, };
  259. static int mt7629_pcie_pereset_funcs[] = { 1, };
  260. static int mt7629_pcie_wake_pins[] = { 55, };
  261. static int mt7629_pcie_wake_funcs[] = { 1, };
  262. static int mt7629_pcie_clkreq_pins[] = { 56, };
  263. static int mt7629_pcie_clkreq_funcs[] = { 1, };
  264. /* PWM */
  265. static int mt7629_pwm_0_pins[] = { 52, };
  266. static int mt7629_pwm_0_funcs[] = { 1, };
  267. static int mt7629_pwm_1_pins[] = { 61, };
  268. static int mt7629_pwm_1_funcs[] = { 2, };
  269. /* WF 2G */
  270. static int mt7629_wf0_2g_pins[] = { 70, 71, 72, 73, 74, 75, 76, 77, 78, };
  271. static int mt7629_wf0_2g_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, };
  272. /* WF 5G */
  273. static int mt7629_wf0_5g_pins[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, };
  274. static int mt7629_wf0_5g_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
  275. /* SNFI */
  276. static int mt7629_snfi_pins[] = { 62, 63, 64, 65, 66, 67 };
  277. static int mt7629_snfi_funcs[] = { 2, 2, 2, 2, 2, 2 };
  278. /* SPI NOR */
  279. static int mt7629_snor_pins[] = { 62, 63, 64, 65, 66, 67 };
  280. static int mt7629_snor_funcs[] = { 1, 1, 1, 1, 1, 1 };
  281. static const struct group_desc mt7629_groups[] = {
  282. PINCTRL_PIN_GROUP("ephy_leds", mt7629_ephy_leds),
  283. PINCTRL_PIN_GROUP("ephy_led0", mt7629_ephy_led0),
  284. PINCTRL_PIN_GROUP("ephy_led1", mt7629_ephy_led1),
  285. PINCTRL_PIN_GROUP("ephy_led2", mt7629_ephy_led2),
  286. PINCTRL_PIN_GROUP("ephy_led3", mt7629_ephy_led3),
  287. PINCTRL_PIN_GROUP("ephy_led4", mt7629_ephy_led4),
  288. PINCTRL_PIN_GROUP("wf2g_led", mt7629_wf2g_led),
  289. PINCTRL_PIN_GROUP("wf5g_led", mt7629_wf5g_led),
  290. PINCTRL_PIN_GROUP("watchdog", mt7629_watchdog),
  291. PINCTRL_PIN_GROUP("gphy_leds_0", mt7629_gphy_leds_0),
  292. PINCTRL_PIN_GROUP("gphy_led1_0", mt7629_gphy_led1_0),
  293. PINCTRL_PIN_GROUP("gphy_led2_0", mt7629_gphy_led2_0),
  294. PINCTRL_PIN_GROUP("gphy_led3_0", mt7629_gphy_led3_0),
  295. PINCTRL_PIN_GROUP("gphy_leds_1", mt7629_gphy_leds_1),
  296. PINCTRL_PIN_GROUP("gphy_led1_1", mt7629_gphy_led1_1),
  297. PINCTRL_PIN_GROUP("gphy_led2_1", mt7629_gphy_led2_1),
  298. PINCTRL_PIN_GROUP("gphy_led3_1", mt7629_gphy_led3_1),
  299. PINCTRL_PIN_GROUP("i2c_0", mt7629_i2c_0),
  300. PINCTRL_PIN_GROUP("i2c_1", mt7629_i2c_1),
  301. PINCTRL_PIN_GROUP("spi_0", mt7629_spi_0),
  302. PINCTRL_PIN_GROUP("spi_1", mt7629_spi_1),
  303. PINCTRL_PIN_GROUP("spi_wp", mt7629_spi_wp),
  304. PINCTRL_PIN_GROUP("spi_hold", mt7629_spi_hold),
  305. PINCTRL_PIN_GROUP("uart1_0_txd_rxd", mt7629_uart1_0_txd_rxd),
  306. PINCTRL_PIN_GROUP("uart1_1_txd_rxd", mt7629_uart1_1_txd_rxd),
  307. PINCTRL_PIN_GROUP("uart2_0_txd_rxd", mt7629_uart2_0_txd_rxd),
  308. PINCTRL_PIN_GROUP("uart2_1_txd_rxd", mt7629_uart2_1_txd_rxd),
  309. PINCTRL_PIN_GROUP("uart1_0_cts_rts", mt7629_uart1_0_cts_rts),
  310. PINCTRL_PIN_GROUP("uart1_1_cts_rts", mt7629_uart1_1_cts_rts),
  311. PINCTRL_PIN_GROUP("uart2_0_cts_rts", mt7629_uart2_0_cts_rts),
  312. PINCTRL_PIN_GROUP("uart2_1_cts_rts", mt7629_uart2_1_cts_rts),
  313. PINCTRL_PIN_GROUP("uart0_txd_rxd", mt7629_uart0_txd_rxd),
  314. PINCTRL_PIN_GROUP("mdc_mdio", mt7629_mdc_mdio),
  315. PINCTRL_PIN_GROUP("pcie_pereset", mt7629_pcie_pereset),
  316. PINCTRL_PIN_GROUP("pcie_wake", mt7629_pcie_wake),
  317. PINCTRL_PIN_GROUP("pcie_clkreq", mt7629_pcie_clkreq),
  318. PINCTRL_PIN_GROUP("pwm_0", mt7629_pwm_0),
  319. PINCTRL_PIN_GROUP("pwm_1", mt7629_pwm_1),
  320. PINCTRL_PIN_GROUP("wf0_5g", mt7629_wf0_5g),
  321. PINCTRL_PIN_GROUP("wf0_2g", mt7629_wf0_2g),
  322. PINCTRL_PIN_GROUP("snfi", mt7629_snfi),
  323. PINCTRL_PIN_GROUP("spi_nor", mt7629_snor),
  324. };
  325. /* Joint those groups owning the same capability in user point of view which
  326. * allows that people tend to use through the device tree.
  327. */
  328. static const char *mt7629_ethernet_groups[] = { "mdc_mdio", };
  329. static const char *mt7629_i2c_groups[] = { "i2c_0", "i2c_1", };
  330. static const char *mt7629_led_groups[] = { "ephy_leds", "ephy_led0",
  331. "ephy_led1", "ephy_led2",
  332. "ephy_led3", "ephy_led4",
  333. "wf2g_led", "wf5g_led",
  334. "gphy_leds_0", "gphy_led1_0",
  335. "gphy_led2_0", "gphy_led3_0",
  336. "gphy_leds_1", "gphy_led1_1",
  337. "gphy_led2_1", "gphy_led3_1",};
  338. static const char *mt7629_pcie_groups[] = { "pcie_pereset", "pcie_wake",
  339. "pcie_clkreq", };
  340. static const char *mt7629_pwm_groups[] = { "pwm_0", "pwm_1", };
  341. static const char *mt7629_spi_groups[] = { "spi_0", "spi_1", "spi_wp",
  342. "spi_hold", };
  343. static const char *mt7629_uart_groups[] = { "uart1_0_txd_rxd",
  344. "uart1_1_txd_rxd",
  345. "uart2_0_txd_rxd",
  346. "uart2_1_txd_rxd",
  347. "uart1_0_cts_rts",
  348. "uart1_1_cts_rts",
  349. "uart2_0_cts_rts",
  350. "uart2_1_cts_rts",
  351. "uart0_txd_rxd", };
  352. static const char *mt7629_wdt_groups[] = { "watchdog", };
  353. static const char *mt7629_wifi_groups[] = { "wf0_5g", "wf0_2g", };
  354. static const char *mt7629_flash_groups[] = { "snfi", "spi_nor" };
  355. static const struct function_desc mt7629_functions[] = {
  356. {"eth", mt7629_ethernet_groups, ARRAY_SIZE(mt7629_ethernet_groups)},
  357. {"i2c", mt7629_i2c_groups, ARRAY_SIZE(mt7629_i2c_groups)},
  358. {"led", mt7629_led_groups, ARRAY_SIZE(mt7629_led_groups)},
  359. {"pcie", mt7629_pcie_groups, ARRAY_SIZE(mt7629_pcie_groups)},
  360. {"pwm", mt7629_pwm_groups, ARRAY_SIZE(mt7629_pwm_groups)},
  361. {"spi", mt7629_spi_groups, ARRAY_SIZE(mt7629_spi_groups)},
  362. {"uart", mt7629_uart_groups, ARRAY_SIZE(mt7629_uart_groups)},
  363. {"watchdog", mt7629_wdt_groups, ARRAY_SIZE(mt7629_wdt_groups)},
  364. {"wifi", mt7629_wifi_groups, ARRAY_SIZE(mt7629_wifi_groups)},
  365. {"flash", mt7629_flash_groups, ARRAY_SIZE(mt7629_flash_groups)},
  366. };
  367. static const struct mtk_eint_hw mt7629_eint_hw = {
  368. .port_mask = 7,
  369. .ports = 7,
  370. .ap_num = ARRAY_SIZE(mt7629_pins),
  371. .db_cnt = 16,
  372. .db_time = debounce_time_mt2701,
  373. };
  374. static struct mtk_pin_soc mt7629_data = {
  375. .reg_cal = mt7629_reg_cals,
  376. .pins = mt7629_pins,
  377. .npins = ARRAY_SIZE(mt7629_pins),
  378. .grps = mt7629_groups,
  379. .ngrps = ARRAY_SIZE(mt7629_groups),
  380. .funcs = mt7629_functions,
  381. .nfuncs = ARRAY_SIZE(mt7629_functions),
  382. .eint_hw = &mt7629_eint_hw,
  383. .gpio_m = 0,
  384. .ies_present = true,
  385. .base_names = mtk_default_register_base_names,
  386. .nbase_names = ARRAY_SIZE(mtk_default_register_base_names),
  387. .bias_disable_set = mtk_pinconf_bias_disable_set_rev1,
  388. .bias_disable_get = mtk_pinconf_bias_disable_get_rev1,
  389. .bias_set = mtk_pinconf_bias_set_rev1,
  390. .bias_get = mtk_pinconf_bias_get_rev1,
  391. .drive_set = mtk_pinconf_drive_set_rev1,
  392. .drive_get = mtk_pinconf_drive_get_rev1,
  393. };
  394. static const struct of_device_id mt7629_pinctrl_of_match[] = {
  395. { .compatible = "mediatek,mt7629-pinctrl", },
  396. {}
  397. };
  398. static int mt7629_pinctrl_probe(struct platform_device *pdev)
  399. {
  400. return mtk_moore_pinctrl_probe(pdev, &mt7629_data);
  401. }
  402. static struct platform_driver mt7629_pinctrl_driver = {
  403. .driver = {
  404. .name = "mt7629-pinctrl",
  405. .of_match_table = mt7629_pinctrl_of_match,
  406. },
  407. .probe = mt7629_pinctrl_probe,
  408. };
  409. static int __init mt7629_pinctrl_init(void)
  410. {
  411. return platform_driver_register(&mt7629_pinctrl_driver);
  412. }
  413. arch_initcall(mt7629_pinctrl_init);