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