1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Author: Lorenzo Bianconi <lorenzo@kernel.org> 4 * Author: Benjamin Larsson <benjamin.larsson@genexis.eu> 5 * Author: Markus Gothe <markus.gothe@genexis.eu> 6 */ 7 8 #include <dt-bindings/pinctrl/mt65xx.h> 9 #include <linux/bitfield.h> 10 #include <linux/bits.h> 11 #include <linux/cleanup.h> 12 #include <linux/gpio/driver.h> 13 #include <linux/interrupt.h> 14 #include <linux/io.h> 15 #include <linux/irq.h> 16 #include <linux/irqdomain.h> 17 #include <linux/mfd/syscon.h> 18 #include <linux/of.h> 19 #include <linux/of_irq.h> 20 #include <linux/of_platform.h> 21 #include <linux/pinctrl/consumer.h> 22 #include <linux/pinctrl/pinctrl.h> 23 #include <linux/pinctrl/pinconf.h> 24 #include <linux/pinctrl/pinconf-generic.h> 25 #include <linux/pinctrl/pinmux.h> 26 #include <linux/platform_device.h> 27 #include <linux/regmap.h> 28 29 #include "../core.h" 30 #include "../pinconf.h" 31 #include "../pinmux.h" 32 33 #define PINCTRL_PIN_GROUP(id, table) \ 34 PINCTRL_PINGROUP(id, table##_pins, ARRAY_SIZE(table##_pins)) 35 36 #define PINCTRL_FUNC_DESC(id, table) \ 37 { \ 38 .desc = PINCTRL_PINFUNCTION(id, table##_groups, \ 39 ARRAY_SIZE(table##_groups)),\ 40 .groups = table##_func_group, \ 41 .group_size = ARRAY_SIZE(table##_func_group), \ 42 } 43 44 #define PINCTRL_CONF_DESC(p, offset, mask) \ 45 { \ 46 .pin = p, \ 47 .reg = { offset, mask }, \ 48 } 49 50 /* MUX */ 51 #define REG_GPIO_2ND_I2C_MODE 0x0214 52 #define GPIO_MDC_IO_MASTER_MODE_MODE BIT(14) 53 #define GPIO_I2C_MASTER_MODE_MODE BIT(13) 54 #define GPIO_I2S_MODE_MASK BIT(12) 55 #define GPIO_I2C_SLAVE_MODE_MODE BIT(11) 56 #define GPIO_LAN3_LED1_MODE_MASK BIT(10) 57 #define GPIO_LAN3_LED0_MODE_MASK BIT(9) 58 #define GPIO_LAN2_LED1_MODE_MASK BIT(8) 59 #define GPIO_LAN2_LED0_MODE_MASK BIT(7) 60 #define GPIO_LAN1_LED1_MODE_MASK BIT(6) 61 #define GPIO_LAN1_LED0_MODE_MASK BIT(5) 62 #define GPIO_LAN0_LED1_MODE_MASK BIT(4) 63 #define GPIO_LAN0_LED0_MODE_MASK BIT(3) 64 #define PON_TOD_1PPS_MODE_MASK BIT(2) 65 #define GSW_TOD_1PPS_MODE_MASK BIT(1) 66 #define GPIO_2ND_I2C_MODE_MASK BIT(0) 67 68 #define REG_GPIO_SPI_CS1_MODE 0x0218 69 #define GPIO_PCM_SPI_CS4_MODE_MASK BIT(21) 70 #define GPIO_PCM_SPI_CS3_MODE_MASK BIT(20) 71 #define GPIO_PCM_SPI_CS2_MODE_P156_MASK BIT(19) 72 #define GPIO_PCM_SPI_CS2_MODE_P128_MASK BIT(18) 73 #define AN7583_GPIO_PCM_SPI_CS2_MODE_MASK BIT(18) 74 #define GPIO_PCM_SPI_CS1_MODE_MASK BIT(17) 75 #define GPIO_PCM_SPI_MODE_MASK BIT(16) 76 #define GPIO_PCM2_MODE_MASK BIT(13) 77 #define GPIO_PCM1_MODE_MASK BIT(12) 78 #define GPIO_PCM_INT_MODE_MASK BIT(9) 79 #define GPIO_PCM_RESET_MODE_MASK BIT(8) 80 #define GPIO_SPI_QUAD_MODE_MASK BIT(4) 81 #define GPIO_SPI_CS4_MODE_MASK BIT(3) 82 #define GPIO_SPI_CS3_MODE_MASK BIT(2) 83 #define GPIO_SPI_CS2_MODE_MASK BIT(1) 84 #define GPIO_SPI_CS1_MODE_MASK BIT(0) 85 86 #define REG_GPIO_PON_MODE 0x021c 87 #define GPIO_PARALLEL_NAND_MODE_MASK BIT(14) 88 #define GPIO_SGMII_MDIO_MODE_MASK BIT(13) 89 #define GPIO_PCIE_RESET2_MASK BIT(12) 90 #define SIPO_RCLK_MODE_MASK BIT(11) 91 #define GPIO_PCIE_RESET1_MASK BIT(10) 92 #define GPIO_PCIE_RESET0_MASK BIT(9) 93 #define GPIO_UART5_MODE_MASK BIT(8) 94 #define GPIO_UART4_MODE_MASK BIT(7) 95 #define GPIO_HSUART_CTS_RTS_MODE_MASK BIT(6) 96 #define GPIO_HSUART_MODE_MASK BIT(5) 97 #define GPIO_UART2_CTS_RTS_MODE_MASK BIT(4) 98 #define GPIO_UART2_MODE_MASK BIT(3) 99 #define GPIO_SIPO_MODE_MASK BIT(2) 100 #define GPIO_EMMC_MODE_MASK BIT(1) 101 #define GPIO_PON_MODE_MASK BIT(0) 102 103 #define REG_NPU_UART_EN 0x0224 104 #define JTAG_UDI_EN_MASK BIT(4) 105 #define JTAG_DFD_EN_MASK BIT(3) 106 107 #define REG_FORCE_GPIO_EN 0x0228 108 #define FORCE_GPIO_EN(n) BIT(n) 109 110 /* LED MAP */ 111 #define REG_LAN_LED0_MAPPING 0x027c 112 #define REG_LAN_LED1_MAPPING 0x0280 113 114 #define LAN4_LED_MAPPING_MASK GENMASK(18, 16) 115 #define LAN4_PHY_LED_MAP(_n) FIELD_PREP_CONST(LAN4_LED_MAPPING_MASK, (_n)) 116 117 #define LAN3_LED_MAPPING_MASK GENMASK(14, 12) 118 #define LAN3_PHY_LED_MAP(_n) FIELD_PREP_CONST(LAN3_LED_MAPPING_MASK, (_n)) 119 120 #define LAN2_LED_MAPPING_MASK GENMASK(10, 8) 121 #define LAN2_PHY_LED_MAP(_n) FIELD_PREP_CONST(LAN2_LED_MAPPING_MASK, (_n)) 122 123 #define LAN1_LED_MAPPING_MASK GENMASK(6, 4) 124 #define LAN1_PHY_LED_MAP(_n) FIELD_PREP_CONST(LAN1_LED_MAPPING_MASK, (_n)) 125 126 #define LAN0_LED_MAPPING_MASK GENMASK(2, 0) 127 #define LAN0_PHY_LED_MAP(_n) FIELD_PREP_CONST(LAN0_LED_MAPPING_MASK, (_n)) 128 129 /* CONF */ 130 #define REG_I2C_SDA_E2 0x001c 131 #define AN7583_I2C1_SCL_E2_MASK BIT(16) 132 #define AN7583_I2C1_SDA_E2_MASK BIT(15) 133 #define SPI_MISO_E2_MASK BIT(14) 134 #define SPI_MOSI_E2_MASK BIT(13) 135 #define SPI_CLK_E2_MASK BIT(12) 136 #define SPI_CS0_E2_MASK BIT(11) 137 #define PCIE2_RESET_E2_MASK BIT(10) 138 #define PCIE1_RESET_E2_MASK BIT(9) 139 #define PCIE0_RESET_E2_MASK BIT(8) 140 #define AN7583_MDIO_0_E2_MASK BIT(5) 141 #define AN7583_MDC_0_E2_MASK BIT(4) 142 #define UART1_RXD_E2_MASK BIT(3) 143 #define UART1_TXD_E2_MASK BIT(2) 144 #define I2C_SCL_E2_MASK BIT(1) 145 #define I2C_SDA_E2_MASK BIT(0) 146 147 #define REG_I2C_SDA_E4 0x0020 148 #define AN7583_I2C1_SCL_E4_MASK BIT(16) 149 #define AN7583_I2C1_SDA_E4_MASK BIT(15) 150 #define SPI_MISO_E4_MASK BIT(14) 151 #define SPI_MOSI_E4_MASK BIT(13) 152 #define SPI_CLK_E4_MASK BIT(12) 153 #define SPI_CS0_E4_MASK BIT(11) 154 #define PCIE2_RESET_E4_MASK BIT(10) 155 #define PCIE1_RESET_E4_MASK BIT(9) 156 #define PCIE0_RESET_E4_MASK BIT(8) 157 #define AN7583_MDIO_0_E4_MASK BIT(5) 158 #define AN7583_MDC_0_E4_MASK BIT(4) 159 #define UART1_RXD_E4_MASK BIT(3) 160 #define UART1_TXD_E4_MASK BIT(2) 161 #define I2C_SCL_E4_MASK BIT(1) 162 #define I2C_SDA_E4_MASK BIT(0) 163 164 #define REG_GPIO_L_E2 0x0024 165 #define REG_GPIO_L_E4 0x0028 166 #define REG_GPIO_H_E2 0x002c 167 #define REG_GPIO_H_E4 0x0030 168 169 #define REG_I2C_SDA_PU 0x0044 170 #define AN7583_I2C1_SCL_PU_MASK BIT(16) 171 #define AN7583_I2C1_SDA_PU_MASK BIT(15) 172 #define SPI_MISO_PU_MASK BIT(14) 173 #define SPI_MOSI_PU_MASK BIT(13) 174 #define SPI_CLK_PU_MASK BIT(12) 175 #define SPI_CS0_PU_MASK BIT(11) 176 #define PCIE2_RESET_PU_MASK BIT(10) 177 #define PCIE1_RESET_PU_MASK BIT(9) 178 #define PCIE0_RESET_PU_MASK BIT(8) 179 #define AN7583_MDIO_0_PU_MASK BIT(5) 180 #define AN7583_MDC_0_PU_MASK BIT(4) 181 #define UART1_RXD_PU_MASK BIT(3) 182 #define UART1_TXD_PU_MASK BIT(2) 183 #define I2C_SCL_PU_MASK BIT(1) 184 #define I2C_SDA_PU_MASK BIT(0) 185 186 #define REG_I2C_SDA_PD 0x0048 187 #define AN7583_I2C1_SDA_PD_MASK BIT(16) 188 #define AN7583_I2C1_SCL_PD_MASK BIT(15) 189 #define SPI_MISO_PD_MASK BIT(14) 190 #define SPI_MOSI_PD_MASK BIT(13) 191 #define SPI_CLK_PD_MASK BIT(12) 192 #define SPI_CS0_PD_MASK BIT(11) 193 #define PCIE2_RESET_PD_MASK BIT(10) 194 #define PCIE1_RESET_PD_MASK BIT(9) 195 #define PCIE0_RESET_PD_MASK BIT(8) 196 #define AN7583_MDIO_0_PD_MASK BIT(5) 197 #define AN7583_MDC_0_PD_MASK BIT(4) 198 #define UART1_RXD_PD_MASK BIT(3) 199 #define UART1_TXD_PD_MASK BIT(2) 200 #define I2C_SCL_PD_MASK BIT(1) 201 #define I2C_SDA_PD_MASK BIT(0) 202 203 #define REG_GPIO_L_PU 0x004c 204 #define REG_GPIO_L_PD 0x0050 205 #define REG_GPIO_H_PU 0x0054 206 #define REG_GPIO_H_PD 0x0058 207 208 #define REG_PCIE_RESET_OD 0x018c 209 #define PCIE2_RESET_OD_MASK BIT(2) 210 #define PCIE1_RESET_OD_MASK BIT(1) 211 #define PCIE0_RESET_OD_MASK BIT(0) 212 213 /* GPIOs */ 214 #define REG_GPIO_CTRL 0x0000 215 #define REG_GPIO_DATA 0x0004 216 #define REG_GPIO_INT 0x0008 217 #define REG_GPIO_INT_EDGE 0x000c 218 #define REG_GPIO_INT_LEVEL 0x0010 219 #define REG_GPIO_OE 0x0014 220 #define REG_GPIO_CTRL1 0x0020 221 222 /* PWM MODE CONF */ 223 #define REG_GPIO_FLASH_MODE_CFG 0x0034 224 #define GPIO15_FLASH_MODE_CFG BIT(15) 225 #define GPIO14_FLASH_MODE_CFG BIT(14) 226 #define GPIO13_FLASH_MODE_CFG BIT(13) 227 #define GPIO12_FLASH_MODE_CFG BIT(12) 228 #define GPIO11_FLASH_MODE_CFG BIT(11) 229 #define GPIO10_FLASH_MODE_CFG BIT(10) 230 #define GPIO9_FLASH_MODE_CFG BIT(9) 231 #define GPIO8_FLASH_MODE_CFG BIT(8) 232 #define GPIO7_FLASH_MODE_CFG BIT(7) 233 #define GPIO6_FLASH_MODE_CFG BIT(6) 234 #define GPIO5_FLASH_MODE_CFG BIT(5) 235 #define GPIO4_FLASH_MODE_CFG BIT(4) 236 #define GPIO3_FLASH_MODE_CFG BIT(3) 237 #define GPIO2_FLASH_MODE_CFG BIT(2) 238 #define GPIO1_FLASH_MODE_CFG BIT(1) 239 #define GPIO0_FLASH_MODE_CFG BIT(0) 240 241 #define REG_GPIO_CTRL2 0x0060 242 #define REG_GPIO_CTRL3 0x0064 243 244 /* PWM MODE CONF EXT */ 245 #define REG_GPIO_FLASH_MODE_CFG_EXT 0x0068 246 #define GPIO51_FLASH_MODE_CFG BIT(31) 247 #define GPIO50_FLASH_MODE_CFG BIT(30) 248 #define GPIO49_FLASH_MODE_CFG BIT(29) 249 #define GPIO48_FLASH_MODE_CFG BIT(28) 250 #define GPIO47_FLASH_MODE_CFG BIT(27) 251 #define GPIO46_FLASH_MODE_CFG BIT(26) 252 #define GPIO45_FLASH_MODE_CFG BIT(25) 253 #define GPIO44_FLASH_MODE_CFG BIT(24) 254 #define GPIO43_FLASH_MODE_CFG BIT(23) 255 #define GPIO42_FLASH_MODE_CFG BIT(22) 256 #define GPIO41_FLASH_MODE_CFG BIT(21) 257 #define GPIO40_FLASH_MODE_CFG BIT(20) 258 #define GPIO39_FLASH_MODE_CFG BIT(19) 259 #define GPIO38_FLASH_MODE_CFG BIT(18) 260 #define GPIO37_FLASH_MODE_CFG BIT(17) 261 #define GPIO36_FLASH_MODE_CFG BIT(16) 262 #define GPIO31_FLASH_MODE_CFG BIT(15) 263 #define GPIO30_FLASH_MODE_CFG BIT(14) 264 #define GPIO29_FLASH_MODE_CFG BIT(13) 265 #define GPIO28_FLASH_MODE_CFG BIT(12) 266 #define GPIO27_FLASH_MODE_CFG BIT(11) 267 #define GPIO26_FLASH_MODE_CFG BIT(10) 268 #define GPIO25_FLASH_MODE_CFG BIT(9) 269 #define GPIO24_FLASH_MODE_CFG BIT(8) 270 #define GPIO23_FLASH_MODE_CFG BIT(7) 271 #define GPIO22_FLASH_MODE_CFG BIT(6) 272 #define GPIO21_FLASH_MODE_CFG BIT(5) 273 #define GPIO20_FLASH_MODE_CFG BIT(4) 274 #define GPIO19_FLASH_MODE_CFG BIT(3) 275 #define GPIO18_FLASH_MODE_CFG BIT(2) 276 #define GPIO17_FLASH_MODE_CFG BIT(1) 277 #define GPIO16_FLASH_MODE_CFG BIT(0) 278 279 #define REG_GPIO_DATA1 0x0070 280 #define REG_GPIO_OE1 0x0078 281 #define REG_GPIO_INT1 0x007c 282 #define REG_GPIO_INT_EDGE1 0x0080 283 #define REG_GPIO_INT_EDGE2 0x0084 284 #define REG_GPIO_INT_EDGE3 0x0088 285 #define REG_GPIO_INT_LEVEL1 0x008c 286 #define REG_GPIO_INT_LEVEL2 0x0090 287 #define REG_GPIO_INT_LEVEL3 0x0094 288 289 #define AIROHA_NUM_PINS 64 290 #define AIROHA_PIN_BANK_SIZE (AIROHA_NUM_PINS / 2) 291 #define AIROHA_REG_GPIOCTRL_NUM_PIN (AIROHA_NUM_PINS / 4) 292 293 static const u32 gpio_data_regs[] = { 294 REG_GPIO_DATA, 295 REG_GPIO_DATA1 296 }; 297 298 static const u32 gpio_out_regs[] = { 299 REG_GPIO_OE, 300 REG_GPIO_OE1 301 }; 302 303 static const u32 gpio_dir_regs[] = { 304 REG_GPIO_CTRL, 305 REG_GPIO_CTRL1, 306 REG_GPIO_CTRL2, 307 REG_GPIO_CTRL3 308 }; 309 310 static const u32 irq_status_regs[] = { 311 REG_GPIO_INT, 312 REG_GPIO_INT1 313 }; 314 315 static const u32 irq_level_regs[] = { 316 REG_GPIO_INT_LEVEL, 317 REG_GPIO_INT_LEVEL1, 318 REG_GPIO_INT_LEVEL2, 319 REG_GPIO_INT_LEVEL3 320 }; 321 322 static const u32 irq_edge_regs[] = { 323 REG_GPIO_INT_EDGE, 324 REG_GPIO_INT_EDGE1, 325 REG_GPIO_INT_EDGE2, 326 REG_GPIO_INT_EDGE3 327 }; 328 329 struct airoha_pinctrl_reg { 330 u32 offset; 331 u32 mask; 332 }; 333 334 enum airoha_pinctrl_mux_func { 335 AIROHA_FUNC_MUX, 336 AIROHA_FUNC_PWM_MUX, 337 AIROHA_FUNC_PWM_EXT_MUX, 338 }; 339 340 struct airoha_pinctrl_func_group { 341 const char *name; 342 struct { 343 enum airoha_pinctrl_mux_func mux; 344 u32 offset; 345 u32 mask; 346 u32 val; 347 } regmap[2]; 348 int regmap_size; 349 }; 350 351 struct airoha_pinctrl_func { 352 const struct pinfunction desc; 353 const struct airoha_pinctrl_func_group *groups; 354 u8 group_size; 355 }; 356 357 struct airoha_pinctrl_conf { 358 u32 pin; 359 struct airoha_pinctrl_reg reg; 360 }; 361 362 struct airoha_pinctrl_gpiochip { 363 struct gpio_chip chip; 364 365 /* gpio */ 366 const u32 *data; 367 const u32 *dir; 368 const u32 *out; 369 /* irq */ 370 const u32 *status; 371 const u32 *level; 372 const u32 *edge; 373 374 u32 irq_type[AIROHA_NUM_PINS]; 375 }; 376 377 struct airoha_pinctrl_confs_info { 378 const struct airoha_pinctrl_conf *confs; 379 unsigned int num_confs; 380 }; 381 382 enum airoha_pinctrl_confs_type { 383 AIROHA_PINCTRL_CONFS_PULLUP, 384 AIROHA_PINCTRL_CONFS_PULLDOWN, 385 AIROHA_PINCTRL_CONFS_DRIVE_E2, 386 AIROHA_PINCTRL_CONFS_DRIVE_E4, 387 AIROHA_PINCTRL_CONFS_PCIE_RST_OD, 388 389 AIROHA_PINCTRL_CONFS_MAX, 390 }; 391 392 struct airoha_pinctrl { 393 struct pinctrl_dev *ctrl; 394 395 struct pinctrl_desc desc; 396 const struct pingroup *grps; 397 const struct airoha_pinctrl_func *funcs; 398 const struct airoha_pinctrl_confs_info *confs_info; 399 400 struct regmap *chip_scu; 401 struct regmap *regmap; 402 403 struct airoha_pinctrl_gpiochip gpiochip; 404 }; 405 406 struct airoha_pinctrl_match_data { 407 const struct pinctrl_pin_desc *pins; 408 const unsigned int num_pins; 409 const struct pingroup *grps; 410 const unsigned int num_grps; 411 const struct airoha_pinctrl_func *funcs; 412 const unsigned int num_funcs; 413 const struct airoha_pinctrl_confs_info confs_info[AIROHA_PINCTRL_CONFS_MAX]; 414 }; 415 416 static struct pinctrl_pin_desc en7581_pinctrl_pins[] = { 417 PINCTRL_PIN(0, "uart1_txd"), 418 PINCTRL_PIN(1, "uart1_rxd"), 419 PINCTRL_PIN(2, "i2c_scl"), 420 PINCTRL_PIN(3, "i2c_sda"), 421 PINCTRL_PIN(4, "spi_cs0"), 422 PINCTRL_PIN(5, "spi_clk"), 423 PINCTRL_PIN(6, "spi_mosi"), 424 PINCTRL_PIN(7, "spi_miso"), 425 PINCTRL_PIN(13, "gpio0"), 426 PINCTRL_PIN(14, "gpio1"), 427 PINCTRL_PIN(15, "gpio2"), 428 PINCTRL_PIN(16, "gpio3"), 429 PINCTRL_PIN(17, "gpio4"), 430 PINCTRL_PIN(18, "gpio5"), 431 PINCTRL_PIN(19, "gpio6"), 432 PINCTRL_PIN(20, "gpio7"), 433 PINCTRL_PIN(21, "gpio8"), 434 PINCTRL_PIN(22, "gpio9"), 435 PINCTRL_PIN(23, "gpio10"), 436 PINCTRL_PIN(24, "gpio11"), 437 PINCTRL_PIN(25, "gpio12"), 438 PINCTRL_PIN(26, "gpio13"), 439 PINCTRL_PIN(27, "gpio14"), 440 PINCTRL_PIN(28, "gpio15"), 441 PINCTRL_PIN(29, "gpio16"), 442 PINCTRL_PIN(30, "gpio17"), 443 PINCTRL_PIN(31, "gpio18"), 444 PINCTRL_PIN(32, "gpio19"), 445 PINCTRL_PIN(33, "gpio20"), 446 PINCTRL_PIN(34, "gpio21"), 447 PINCTRL_PIN(35, "gpio22"), 448 PINCTRL_PIN(36, "gpio23"), 449 PINCTRL_PIN(37, "gpio24"), 450 PINCTRL_PIN(38, "gpio25"), 451 PINCTRL_PIN(39, "gpio26"), 452 PINCTRL_PIN(40, "gpio27"), 453 PINCTRL_PIN(41, "gpio28"), 454 PINCTRL_PIN(42, "gpio29"), 455 PINCTRL_PIN(43, "gpio30"), 456 PINCTRL_PIN(44, "gpio31"), 457 PINCTRL_PIN(45, "gpio32"), 458 PINCTRL_PIN(46, "gpio33"), 459 PINCTRL_PIN(47, "gpio34"), 460 PINCTRL_PIN(48, "gpio35"), 461 PINCTRL_PIN(49, "gpio36"), 462 PINCTRL_PIN(50, "gpio37"), 463 PINCTRL_PIN(51, "gpio38"), 464 PINCTRL_PIN(52, "gpio39"), 465 PINCTRL_PIN(53, "gpio40"), 466 PINCTRL_PIN(54, "gpio41"), 467 PINCTRL_PIN(55, "gpio42"), 468 PINCTRL_PIN(56, "gpio43"), 469 PINCTRL_PIN(57, "gpio44"), 470 PINCTRL_PIN(58, "gpio45"), 471 PINCTRL_PIN(59, "gpio46"), 472 PINCTRL_PIN(61, "pcie_reset0"), 473 PINCTRL_PIN(62, "pcie_reset1"), 474 PINCTRL_PIN(63, "pcie_reset2"), 475 }; 476 477 static const int en7581_pon_pins[] = { 49, 50, 51, 52, 53, 54 }; 478 static const int en7581_pon_tod_1pps_pins[] = { 46 }; 479 static const int en7581_gsw_tod_1pps_pins[] = { 46 }; 480 static const int en7581_sipo_pins[] = { 16, 17 }; 481 static const int en7581_sipo_rclk_pins[] = { 16, 17, 43 }; 482 static const int en7581_mdio_pins[] = { 14, 15 }; 483 static const int en7581_uart2_pins[] = { 48, 55 }; 484 static const int en7581_uart2_cts_rts_pins[] = { 46, 47 }; 485 static const int en7581_hsuart_pins[] = { 28, 29 }; 486 static const int en7581_hsuart_cts_rts_pins[] = { 26, 27 }; 487 static const int en7581_uart4_pins[] = { 38, 39 }; 488 static const int en7581_uart5_pins[] = { 18, 19 }; 489 static const int en7581_i2c0_pins[] = { 2, 3 }; 490 static const int en7581_i2c1_pins[] = { 14, 15 }; 491 static const int en7581_jtag_udi_pins[] = { 16, 17, 18, 19, 20 }; 492 static const int en7581_jtag_dfd_pins[] = { 16, 17, 18, 19, 20 }; 493 static const int en7581_i2s_pins[] = { 26, 27, 28, 29 }; 494 static const int en7581_pcm1_pins[] = { 22, 23, 24, 25 }; 495 static const int en7581_pcm2_pins[] = { 18, 19, 20, 21 }; 496 static const int en7581_spi_quad_pins[] = { 32, 33 }; 497 static const int en7581_spi_pins[] = { 4, 5, 6, 7 }; 498 static const int en7581_spi_cs1_pins[] = { 34 }; 499 static const int en7581_pcm_spi_pins[] = { 18, 19, 20, 21, 22, 23, 24, 25 }; 500 static const int en7581_pcm_spi_int_pins[] = { 14 }; 501 static const int en7581_pcm_spi_rst_pins[] = { 15 }; 502 static const int en7581_pcm_spi_cs1_pins[] = { 43 }; 503 static const int en7581_pcm_spi_cs2_pins[] = { 40 }; 504 static const int en7581_pcm_spi_cs2_p128_pins[] = { 40 }; 505 static const int en7581_pcm_spi_cs2_p156_pins[] = { 40 }; 506 static const int en7581_pcm_spi_cs3_pins[] = { 41 }; 507 static const int en7581_pcm_spi_cs4_pins[] = { 42 }; 508 static const int en7581_emmc_pins[] = { 4, 5, 6, 30, 31, 32, 33, 34, 35, 36, 37 }; 509 static const int en7581_pnand_pins[] = { 4, 5, 6, 7, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 }; 510 static const int en7581_gpio0_pins[] = { 13 }; 511 static const int en7581_gpio1_pins[] = { 14 }; 512 static const int en7581_gpio2_pins[] = { 15 }; 513 static const int en7581_gpio3_pins[] = { 16 }; 514 static const int en7581_gpio4_pins[] = { 17 }; 515 static const int en7581_gpio5_pins[] = { 18 }; 516 static const int en7581_gpio6_pins[] = { 19 }; 517 static const int en7581_gpio7_pins[] = { 20 }; 518 static const int en7581_gpio8_pins[] = { 21 }; 519 static const int en7581_gpio9_pins[] = { 22 }; 520 static const int en7581_gpio10_pins[] = { 23 }; 521 static const int en7581_gpio11_pins[] = { 24 }; 522 static const int en7581_gpio12_pins[] = { 25 }; 523 static const int en7581_gpio13_pins[] = { 26 }; 524 static const int en7581_gpio14_pins[] = { 27 }; 525 static const int en7581_gpio15_pins[] = { 28 }; 526 static const int en7581_gpio16_pins[] = { 29 }; 527 static const int en7581_gpio17_pins[] = { 30 }; 528 static const int en7581_gpio18_pins[] = { 31 }; 529 static const int en7581_gpio19_pins[] = { 32 }; 530 static const int en7581_gpio20_pins[] = { 33 }; 531 static const int en7581_gpio21_pins[] = { 34 }; 532 static const int en7581_gpio22_pins[] = { 35 }; 533 static const int en7581_gpio23_pins[] = { 36 }; 534 static const int en7581_gpio24_pins[] = { 37 }; 535 static const int en7581_gpio25_pins[] = { 38 }; 536 static const int en7581_gpio26_pins[] = { 39 }; 537 static const int en7581_gpio27_pins[] = { 40 }; 538 static const int en7581_gpio28_pins[] = { 41 }; 539 static const int en7581_gpio29_pins[] = { 42 }; 540 static const int en7581_gpio30_pins[] = { 43 }; 541 static const int en7581_gpio31_pins[] = { 44 }; 542 static const int en7581_gpio32_pins[] = { 45 }; 543 static const int en7581_gpio33_pins[] = { 46 }; 544 static const int en7581_gpio34_pins[] = { 47 }; 545 static const int en7581_gpio35_pins[] = { 48 }; 546 static const int en7581_gpio36_pins[] = { 49 }; 547 static const int en7581_gpio37_pins[] = { 50 }; 548 static const int en7581_gpio38_pins[] = { 51 }; 549 static const int en7581_gpio39_pins[] = { 52 }; 550 static const int en7581_gpio40_pins[] = { 53 }; 551 static const int en7581_gpio41_pins[] = { 54 }; 552 static const int en7581_gpio42_pins[] = { 55 }; 553 static const int en7581_gpio43_pins[] = { 56 }; 554 static const int en7581_gpio44_pins[] = { 57 }; 555 static const int en7581_gpio45_pins[] = { 58 }; 556 static const int en7581_gpio46_pins[] = { 59 }; 557 static const int en7581_pcie_reset0_pins[] = { 61 }; 558 static const int en7581_pcie_reset1_pins[] = { 62 }; 559 static const int en7581_pcie_reset2_pins[] = { 63 }; 560 561 static const struct pingroup en7581_pinctrl_groups[] = { 562 PINCTRL_PIN_GROUP("pon", en7581_pon), 563 PINCTRL_PIN_GROUP("pon_tod_1pps", en7581_pon_tod_1pps), 564 PINCTRL_PIN_GROUP("gsw_tod_1pps", en7581_gsw_tod_1pps), 565 PINCTRL_PIN_GROUP("sipo", en7581_sipo), 566 PINCTRL_PIN_GROUP("sipo_rclk", en7581_sipo_rclk), 567 PINCTRL_PIN_GROUP("mdio", en7581_mdio), 568 PINCTRL_PIN_GROUP("uart2", en7581_uart2), 569 PINCTRL_PIN_GROUP("uart2_cts_rts", en7581_uart2_cts_rts), 570 PINCTRL_PIN_GROUP("hsuart", en7581_hsuart), 571 PINCTRL_PIN_GROUP("hsuart_cts_rts", en7581_hsuart_cts_rts), 572 PINCTRL_PIN_GROUP("uart4", en7581_uart4), 573 PINCTRL_PIN_GROUP("uart5", en7581_uart5), 574 PINCTRL_PIN_GROUP("i2c0", en7581_i2c0), 575 PINCTRL_PIN_GROUP("i2c1", en7581_i2c1), 576 PINCTRL_PIN_GROUP("jtag_udi", en7581_jtag_udi), 577 PINCTRL_PIN_GROUP("jtag_dfd", en7581_jtag_dfd), 578 PINCTRL_PIN_GROUP("i2s", en7581_i2s), 579 PINCTRL_PIN_GROUP("pcm1", en7581_pcm1), 580 PINCTRL_PIN_GROUP("pcm2", en7581_pcm2), 581 PINCTRL_PIN_GROUP("spi", en7581_spi), 582 PINCTRL_PIN_GROUP("spi_quad", en7581_spi_quad), 583 PINCTRL_PIN_GROUP("spi_cs1", en7581_spi_cs1), 584 PINCTRL_PIN_GROUP("pcm_spi", en7581_pcm_spi), 585 PINCTRL_PIN_GROUP("pcm_spi_int", en7581_pcm_spi_int), 586 PINCTRL_PIN_GROUP("pcm_spi_rst", en7581_pcm_spi_rst), 587 PINCTRL_PIN_GROUP("pcm_spi_cs1", en7581_pcm_spi_cs1), 588 PINCTRL_PIN_GROUP("pcm_spi_cs2_p128", en7581_pcm_spi_cs2_p128), 589 PINCTRL_PIN_GROUP("pcm_spi_cs2_p156", en7581_pcm_spi_cs2_p156), 590 PINCTRL_PIN_GROUP("pcm_spi_cs2", en7581_pcm_spi_cs2), 591 PINCTRL_PIN_GROUP("pcm_spi_cs3", en7581_pcm_spi_cs3), 592 PINCTRL_PIN_GROUP("pcm_spi_cs4", en7581_pcm_spi_cs4), 593 PINCTRL_PIN_GROUP("emmc", en7581_emmc), 594 PINCTRL_PIN_GROUP("pnand", en7581_pnand), 595 PINCTRL_PIN_GROUP("gpio0", en7581_gpio0), 596 PINCTRL_PIN_GROUP("gpio1", en7581_gpio1), 597 PINCTRL_PIN_GROUP("gpio2", en7581_gpio2), 598 PINCTRL_PIN_GROUP("gpio3", en7581_gpio3), 599 PINCTRL_PIN_GROUP("gpio4", en7581_gpio4), 600 PINCTRL_PIN_GROUP("gpio5", en7581_gpio5), 601 PINCTRL_PIN_GROUP("gpio6", en7581_gpio6), 602 PINCTRL_PIN_GROUP("gpio7", en7581_gpio7), 603 PINCTRL_PIN_GROUP("gpio8", en7581_gpio8), 604 PINCTRL_PIN_GROUP("gpio9", en7581_gpio9), 605 PINCTRL_PIN_GROUP("gpio10", en7581_gpio10), 606 PINCTRL_PIN_GROUP("gpio11", en7581_gpio11), 607 PINCTRL_PIN_GROUP("gpio12", en7581_gpio12), 608 PINCTRL_PIN_GROUP("gpio13", en7581_gpio13), 609 PINCTRL_PIN_GROUP("gpio14", en7581_gpio14), 610 PINCTRL_PIN_GROUP("gpio15", en7581_gpio15), 611 PINCTRL_PIN_GROUP("gpio16", en7581_gpio16), 612 PINCTRL_PIN_GROUP("gpio17", en7581_gpio17), 613 PINCTRL_PIN_GROUP("gpio18", en7581_gpio18), 614 PINCTRL_PIN_GROUP("gpio19", en7581_gpio19), 615 PINCTRL_PIN_GROUP("gpio20", en7581_gpio20), 616 PINCTRL_PIN_GROUP("gpio21", en7581_gpio21), 617 PINCTRL_PIN_GROUP("gpio22", en7581_gpio22), 618 PINCTRL_PIN_GROUP("gpio23", en7581_gpio23), 619 PINCTRL_PIN_GROUP("gpio24", en7581_gpio24), 620 PINCTRL_PIN_GROUP("gpio25", en7581_gpio25), 621 PINCTRL_PIN_GROUP("gpio26", en7581_gpio26), 622 PINCTRL_PIN_GROUP("gpio27", en7581_gpio27), 623 PINCTRL_PIN_GROUP("gpio28", en7581_gpio28), 624 PINCTRL_PIN_GROUP("gpio29", en7581_gpio29), 625 PINCTRL_PIN_GROUP("gpio30", en7581_gpio30), 626 PINCTRL_PIN_GROUP("gpio31", en7581_gpio31), 627 PINCTRL_PIN_GROUP("gpio32", en7581_gpio32), 628 PINCTRL_PIN_GROUP("gpio33", en7581_gpio33), 629 PINCTRL_PIN_GROUP("gpio34", en7581_gpio34), 630 PINCTRL_PIN_GROUP("gpio35", en7581_gpio35), 631 PINCTRL_PIN_GROUP("gpio36", en7581_gpio36), 632 PINCTRL_PIN_GROUP("gpio37", en7581_gpio37), 633 PINCTRL_PIN_GROUP("gpio38", en7581_gpio38), 634 PINCTRL_PIN_GROUP("gpio39", en7581_gpio39), 635 PINCTRL_PIN_GROUP("gpio40", en7581_gpio40), 636 PINCTRL_PIN_GROUP("gpio41", en7581_gpio41), 637 PINCTRL_PIN_GROUP("gpio42", en7581_gpio42), 638 PINCTRL_PIN_GROUP("gpio43", en7581_gpio43), 639 PINCTRL_PIN_GROUP("gpio44", en7581_gpio44), 640 PINCTRL_PIN_GROUP("gpio45", en7581_gpio45), 641 PINCTRL_PIN_GROUP("gpio46", en7581_gpio46), 642 PINCTRL_PIN_GROUP("pcie_reset0", en7581_pcie_reset0), 643 PINCTRL_PIN_GROUP("pcie_reset1", en7581_pcie_reset1), 644 PINCTRL_PIN_GROUP("pcie_reset2", en7581_pcie_reset2), 645 }; 646 647 static struct pinctrl_pin_desc an7583_pinctrl_pins[] = { 648 PINCTRL_PIN(2, "gpio0"), 649 PINCTRL_PIN(3, "gpio1"), 650 PINCTRL_PIN(4, "gpio2"), 651 PINCTRL_PIN(5, "gpio3"), 652 PINCTRL_PIN(6, "gpio4"), 653 PINCTRL_PIN(7, "gpio5"), 654 PINCTRL_PIN(8, "gpio6"), 655 PINCTRL_PIN(9, "gpio7"), 656 PINCTRL_PIN(10, "gpio8"), 657 PINCTRL_PIN(11, "gpio9"), 658 PINCTRL_PIN(12, "gpio10"), 659 PINCTRL_PIN(13, "gpio11"), 660 PINCTRL_PIN(14, "gpio12"), 661 PINCTRL_PIN(15, "gpio13"), 662 PINCTRL_PIN(16, "gpio14"), 663 PINCTRL_PIN(17, "gpio15"), 664 PINCTRL_PIN(18, "gpio16"), 665 PINCTRL_PIN(19, "gpio17"), 666 PINCTRL_PIN(20, "gpio18"), 667 PINCTRL_PIN(21, "gpio19"), 668 PINCTRL_PIN(22, "gpio20"), 669 PINCTRL_PIN(23, "gpio21"), 670 PINCTRL_PIN(24, "gpio22"), 671 PINCTRL_PIN(25, "gpio23"), 672 PINCTRL_PIN(26, "gpio24"), 673 PINCTRL_PIN(27, "gpio25"), 674 PINCTRL_PIN(28, "gpio26"), 675 PINCTRL_PIN(29, "gpio27"), 676 PINCTRL_PIN(30, "gpio28"), 677 PINCTRL_PIN(31, "gpio29"), 678 PINCTRL_PIN(32, "gpio30"), 679 PINCTRL_PIN(33, "gpio31"), 680 PINCTRL_PIN(34, "gpio32"), 681 PINCTRL_PIN(35, "gpio33"), 682 PINCTRL_PIN(36, "gpio34"), 683 PINCTRL_PIN(37, "gpio35"), 684 PINCTRL_PIN(38, "gpio36"), 685 PINCTRL_PIN(39, "gpio37"), 686 PINCTRL_PIN(40, "gpio38"), 687 PINCTRL_PIN(41, "i2c0_scl"), 688 PINCTRL_PIN(42, "i2c0_sda"), 689 PINCTRL_PIN(43, "i2c1_scl"), 690 PINCTRL_PIN(44, "i2c1_sda"), 691 PINCTRL_PIN(45, "spi_clk"), 692 PINCTRL_PIN(46, "spi_cs"), 693 PINCTRL_PIN(47, "spi_mosi"), 694 PINCTRL_PIN(48, "spi_miso"), 695 PINCTRL_PIN(49, "uart_txd"), 696 PINCTRL_PIN(50, "uart_rxd"), 697 PINCTRL_PIN(51, "pcie_reset0"), 698 PINCTRL_PIN(52, "pcie_reset1"), 699 PINCTRL_PIN(53, "mdc_0"), 700 PINCTRL_PIN(54, "mdio_0"), 701 }; 702 703 static const int an7583_pon_pins[] = { 15, 16, 17, 18, 19, 20 }; 704 static const int an7583_pon_tod_1pps_pins[] = { 32 }; 705 static const int an7583_gsw_tod_1pps_pins[] = { 32 }; 706 static const int an7583_sipo_pins[] = { 34, 35 }; 707 static const int an7583_sipo_rclk_pins[] = { 34, 35, 33 }; 708 static const int an7583_mdio_pins[] = { 43, 44 }; 709 static const int an7583_uart2_pins[] = { 34, 35 }; 710 static const int an7583_uart2_cts_rts_pins[] = { 32, 33 }; 711 static const int an7583_hsuart_pins[] = { 30, 31 }; 712 static const int an7583_hsuart_cts_rts_pins[] = { 28, 29 }; 713 static const int an7583_npu_uart_pins[] = { 7, 8 }; 714 static const int an7583_uart4_pins[] = { 7, 8 }; 715 static const int an7583_uart5_pins[] = { 23, 24 }; 716 static const int an7583_i2c0_pins[] = { 41, 42 }; 717 static const int an7583_i2c1_pins[] = { 43, 44 }; 718 static const int an7583_jtag_udi_pins[] = { 23, 24, 22, 25, 26 }; 719 static const int an7583_jtag_dfd_pins[] = { 23, 24, 22, 25, 26 }; 720 static const int an7583_pcm1_pins[] = { 10, 11, 12, 13, 14 }; 721 static const int an7583_pcm2_pins[] = { 28, 29, 30, 31, 24 }; 722 static const int an7583_spi_pins[] = { 28, 29, 30, 31 }; 723 static const int an7583_spi_quad_pins[] = { 25, 26 }; 724 static const int an7583_spi_cs1_pins[] = { 27 }; 725 static const int an7583_pcm_spi_pins[] = { 28, 29, 30, 31, 10, 11, 12, 13 }; 726 static const int an7583_pcm_spi_rst_pins[] = { 14 }; 727 static const int an7583_pcm_spi_cs1_pins[] = { 24 }; 728 static const int an7583_emmc_pins[] = { 7, 8, 9, 22, 23, 24, 25, 26, 45, 46, 47 }; 729 static const int an7583_pnand_pins[] = { 7, 8, 9, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 45, 46, 47, 48 }; 730 static const int an7583_gpio0_pins[] = { 2 }; 731 static const int an7583_gpio1_pins[] = { 3 }; 732 static const int an7583_gpio2_pins[] = { 4 }; 733 static const int an7583_gpio3_pins[] = { 5 }; 734 static const int an7583_gpio4_pins[] = { 6 }; 735 static const int an7583_gpio5_pins[] = { 7 }; 736 static const int an7583_gpio6_pins[] = { 8 }; 737 static const int an7583_gpio7_pins[] = { 9 }; 738 static const int an7583_gpio8_pins[] = { 10 }; 739 static const int an7583_gpio9_pins[] = { 11 }; 740 static const int an7583_gpio10_pins[] = { 12 }; 741 static const int an7583_gpio11_pins[] = { 13 }; 742 static const int an7583_gpio12_pins[] = { 14 }; 743 static const int an7583_gpio13_pins[] = { 15 }; 744 static const int an7583_gpio14_pins[] = { 16 }; 745 static const int an7583_gpio15_pins[] = { 17 }; 746 static const int an7583_gpio16_pins[] = { 18 }; 747 static const int an7583_gpio17_pins[] = { 19 }; 748 static const int an7583_gpio18_pins[] = { 20 }; 749 static const int an7583_gpio19_pins[] = { 21 }; 750 static const int an7583_gpio20_pins[] = { 22 }; 751 static const int an7583_gpio21_pins[] = { 23 }; 752 static const int an7583_gpio22_pins[] = { 24 }; 753 static const int an7583_gpio23_pins[] = { 25 }; 754 static const int an7583_gpio24_pins[] = { 26 }; 755 static const int an7583_gpio25_pins[] = { 27 }; 756 static const int an7583_gpio26_pins[] = { 28 }; 757 static const int an7583_gpio27_pins[] = { 29 }; 758 static const int an7583_gpio28_pins[] = { 30 }; 759 static const int an7583_gpio29_pins[] = { 31 }; 760 static const int an7583_gpio30_pins[] = { 32 }; 761 static const int an7583_gpio31_pins[] = { 33 }; 762 static const int an7583_gpio32_pins[] = { 34 }; 763 static const int an7583_gpio33_pins[] = { 35 }; 764 static const int an7583_gpio34_pins[] = { 36 }; 765 static const int an7583_gpio35_pins[] = { 37 }; 766 static const int an7583_gpio36_pins[] = { 38 }; 767 static const int an7583_gpio37_pins[] = { 39 }; 768 static const int an7583_gpio38_pins[] = { 40 }; 769 static const int an7583_gpio39_pins[] = { 41 }; 770 static const int an7583_gpio40_pins[] = { 42 }; 771 static const int an7583_gpio41_pins[] = { 43 }; 772 static const int an7583_gpio42_pins[] = { 44 }; 773 static const int an7583_gpio43_pins[] = { 45 }; 774 static const int an7583_gpio44_pins[] = { 46 }; 775 static const int an7583_gpio45_pins[] = { 47 }; 776 static const int an7583_gpio46_pins[] = { 48 }; 777 static const int an7583_gpio47_pins[] = { 49 }; 778 static const int an7583_gpio48_pins[] = { 50 }; 779 static const int an7583_pcie_reset0_pins[] = { 51 }; 780 static const int an7583_pcie_reset1_pins[] = { 52 }; 781 782 static const struct pingroup an7583_pinctrl_groups[] = { 783 PINCTRL_PIN_GROUP("pon", an7583_pon), 784 PINCTRL_PIN_GROUP("pon_tod_1pps", an7583_pon_tod_1pps), 785 PINCTRL_PIN_GROUP("gsw_tod_1pps", an7583_gsw_tod_1pps), 786 PINCTRL_PIN_GROUP("sipo", an7583_sipo), 787 PINCTRL_PIN_GROUP("sipo_rclk", an7583_sipo_rclk), 788 PINCTRL_PIN_GROUP("mdio", an7583_mdio), 789 PINCTRL_PIN_GROUP("uart2", an7583_uart2), 790 PINCTRL_PIN_GROUP("uart2_cts_rts", an7583_uart2_cts_rts), 791 PINCTRL_PIN_GROUP("hsuart", an7583_hsuart), 792 PINCTRL_PIN_GROUP("hsuart_cts_rts", an7583_hsuart_cts_rts), 793 PINCTRL_PIN_GROUP("npu_uart", an7583_npu_uart), 794 PINCTRL_PIN_GROUP("uart4", an7583_uart4), 795 PINCTRL_PIN_GROUP("uart5", an7583_uart5), 796 PINCTRL_PIN_GROUP("i2c0", an7583_i2c0), 797 PINCTRL_PIN_GROUP("i2c1", an7583_i2c1), 798 PINCTRL_PIN_GROUP("jtag_udi", an7583_jtag_udi), 799 PINCTRL_PIN_GROUP("jtag_dfd", an7583_jtag_dfd), 800 PINCTRL_PIN_GROUP("pcm1", an7583_pcm1), 801 PINCTRL_PIN_GROUP("pcm2", an7583_pcm2), 802 PINCTRL_PIN_GROUP("spi", an7583_spi), 803 PINCTRL_PIN_GROUP("spi_quad", an7583_spi_quad), 804 PINCTRL_PIN_GROUP("spi_cs1", an7583_spi_cs1), 805 PINCTRL_PIN_GROUP("pcm_spi", an7583_pcm_spi), 806 PINCTRL_PIN_GROUP("pcm_spi_rst", an7583_pcm_spi_rst), 807 PINCTRL_PIN_GROUP("pcm_spi_cs1", an7583_pcm_spi_cs1), 808 PINCTRL_PIN_GROUP("emmc", an7583_emmc), 809 PINCTRL_PIN_GROUP("pnand", an7583_pnand), 810 PINCTRL_PIN_GROUP("gpio0", an7583_gpio0), 811 PINCTRL_PIN_GROUP("gpio1", an7583_gpio1), 812 PINCTRL_PIN_GROUP("gpio2", an7583_gpio2), 813 PINCTRL_PIN_GROUP("gpio3", an7583_gpio3), 814 PINCTRL_PIN_GROUP("gpio4", an7583_gpio4), 815 PINCTRL_PIN_GROUP("gpio5", an7583_gpio5), 816 PINCTRL_PIN_GROUP("gpio6", an7583_gpio6), 817 PINCTRL_PIN_GROUP("gpio7", an7583_gpio7), 818 PINCTRL_PIN_GROUP("gpio8", an7583_gpio8), 819 PINCTRL_PIN_GROUP("gpio9", an7583_gpio9), 820 PINCTRL_PIN_GROUP("gpio10", an7583_gpio10), 821 PINCTRL_PIN_GROUP("gpio11", an7583_gpio11), 822 PINCTRL_PIN_GROUP("gpio12", an7583_gpio12), 823 PINCTRL_PIN_GROUP("gpio13", an7583_gpio13), 824 PINCTRL_PIN_GROUP("gpio14", an7583_gpio14), 825 PINCTRL_PIN_GROUP("gpio15", an7583_gpio15), 826 PINCTRL_PIN_GROUP("gpio16", an7583_gpio16), 827 PINCTRL_PIN_GROUP("gpio17", an7583_gpio17), 828 PINCTRL_PIN_GROUP("gpio18", an7583_gpio18), 829 PINCTRL_PIN_GROUP("gpio19", an7583_gpio19), 830 PINCTRL_PIN_GROUP("gpio20", an7583_gpio20), 831 PINCTRL_PIN_GROUP("gpio21", an7583_gpio21), 832 PINCTRL_PIN_GROUP("gpio22", an7583_gpio22), 833 PINCTRL_PIN_GROUP("gpio23", an7583_gpio23), 834 PINCTRL_PIN_GROUP("gpio24", an7583_gpio24), 835 PINCTRL_PIN_GROUP("gpio25", an7583_gpio25), 836 PINCTRL_PIN_GROUP("gpio26", an7583_gpio26), 837 PINCTRL_PIN_GROUP("gpio27", an7583_gpio27), 838 PINCTRL_PIN_GROUP("gpio28", an7583_gpio28), 839 PINCTRL_PIN_GROUP("gpio29", an7583_gpio29), 840 PINCTRL_PIN_GROUP("gpio30", an7583_gpio30), 841 PINCTRL_PIN_GROUP("gpio31", an7583_gpio31), 842 PINCTRL_PIN_GROUP("gpio32", an7583_gpio32), 843 PINCTRL_PIN_GROUP("gpio33", an7583_gpio33), 844 PINCTRL_PIN_GROUP("gpio34", an7583_gpio34), 845 PINCTRL_PIN_GROUP("gpio35", an7583_gpio35), 846 PINCTRL_PIN_GROUP("gpio36", an7583_gpio36), 847 PINCTRL_PIN_GROUP("gpio37", an7583_gpio37), 848 PINCTRL_PIN_GROUP("gpio38", an7583_gpio38), 849 PINCTRL_PIN_GROUP("gpio39", an7583_gpio39), 850 PINCTRL_PIN_GROUP("gpio40", an7583_gpio40), 851 PINCTRL_PIN_GROUP("gpio41", an7583_gpio41), 852 PINCTRL_PIN_GROUP("gpio42", an7583_gpio42), 853 PINCTRL_PIN_GROUP("gpio43", an7583_gpio43), 854 PINCTRL_PIN_GROUP("gpio44", an7583_gpio44), 855 PINCTRL_PIN_GROUP("gpio45", an7583_gpio45), 856 PINCTRL_PIN_GROUP("gpio46", an7583_gpio46), 857 PINCTRL_PIN_GROUP("gpio47", an7583_gpio47), 858 PINCTRL_PIN_GROUP("gpio48", an7583_gpio48), 859 PINCTRL_PIN_GROUP("pcie_reset0", an7583_pcie_reset0), 860 PINCTRL_PIN_GROUP("pcie_reset1", an7583_pcie_reset1), 861 }; 862 863 static const char *const pon_groups[] = { "pon" }; 864 static const char *const tod_1pps_groups[] = { "pon_tod_1pps", "gsw_tod_1pps" }; 865 static const char *const sipo_groups[] = { "sipo", "sipo_rclk" }; 866 static const char *const mdio_groups[] = { "mdio" }; 867 static const char *const an7583_mdio_groups[] = { "mdio" }; 868 static const char *const uart_groups[] = { "uart2", "uart2_cts_rts", "hsuart", 869 "hsuart_cts_rts", "uart4", 870 "uart5" }; 871 static const char *const i2c_groups[] = { "i2c1" }; 872 static const char *const jtag_groups[] = { "jtag_udi", "jtag_dfd" }; 873 static const char *const pcm_groups[] = { "pcm1", "pcm2" }; 874 static const char *const spi_groups[] = { "spi_quad", "spi_cs1" }; 875 static const char *const pcm_spi_groups[] = { "pcm_spi", "pcm_spi_int", 876 "pcm_spi_rst", "pcm_spi_cs1", 877 "pcm_spi_cs2_p156", 878 "pcm_spi_cs2_p128", 879 "pcm_spi_cs3", "pcm_spi_cs4" }; 880 static const char *const an7583_pcm_spi_groups[] = { "pcm_spi", 881 "pcm_spi_rst", "pcm_spi_cs1" }; 882 static const char *const i2s_groups[] = { "i2s" }; 883 static const char *const emmc_groups[] = { "emmc" }; 884 static const char *const pnand_groups[] = { "pnand" }; 885 static const char *const pcie_reset_groups[] = { "pcie_reset0", "pcie_reset1", 886 "pcie_reset2" }; 887 static const char *const an7583_pcie_reset_groups[] = { "pcie_reset0", "pcie_reset1" }; 888 static const char *const pwm_groups[] = { "gpio0", "gpio1", 889 "gpio2", "gpio3", 890 "gpio4", "gpio5", 891 "gpio6", "gpio7", 892 "gpio8", "gpio9", 893 "gpio10", "gpio11", 894 "gpio12", "gpio13", 895 "gpio14", "gpio15", 896 "gpio16", "gpio17", 897 "gpio18", "gpio19", 898 "gpio20", "gpio21", 899 "gpio22", "gpio23", 900 "gpio24", "gpio25", 901 "gpio26", "gpio27", 902 "gpio28", "gpio29", 903 "gpio30", "gpio31", 904 "gpio36", "gpio37", 905 "gpio38", "gpio39", 906 "gpio40", "gpio41", 907 "gpio42", "gpio43", 908 "gpio44", "gpio45", 909 "gpio46" }; 910 static const char *const an7583_pwm_groups[] = { "gpio0", "gpio1", 911 "gpio2", "gpio3", 912 "gpio4", "gpio5", 913 "gpio6", "gpio7", 914 "gpio8", "gpio9", 915 "gpio10", "gpio11", 916 "gpio12", "gpio13", 917 "gpio14", "gpio15", 918 "gpio16", "gpio17", 919 "gpio18", "gpio19", 920 "gpio20", "gpio21", 921 "gpio22", "gpio23", 922 "gpio24", "gpio25", 923 "gpio26", "gpio27", 924 "gpio28", "gpio29", 925 "gpio30", "gpio31", 926 "gpio36", "gpio37", 927 "gpio38", "gpio39", 928 "gpio40", "gpio41", 929 "gpio42", "gpio43", 930 "gpio44", "gpio45", 931 "gpio46", "gpio47", 932 "gpio48" }; 933 static const char *const phy1_led0_groups[] = { "gpio33", "gpio34", 934 "gpio35", "gpio42" }; 935 static const char *const phy2_led0_groups[] = { "gpio33", "gpio34", 936 "gpio35", "gpio42" }; 937 static const char *const phy3_led0_groups[] = { "gpio33", "gpio34", 938 "gpio35", "gpio42" }; 939 static const char *const phy4_led0_groups[] = { "gpio33", "gpio34", 940 "gpio35", "gpio42" }; 941 static const char *const phy1_led1_groups[] = { "gpio43", "gpio44", 942 "gpio45", "gpio46" }; 943 static const char *const phy2_led1_groups[] = { "gpio43", "gpio44", 944 "gpio45", "gpio46" }; 945 static const char *const phy3_led1_groups[] = { "gpio43", "gpio44", 946 "gpio45", "gpio46" }; 947 static const char *const phy4_led1_groups[] = { "gpio43", "gpio44", 948 "gpio45", "gpio46" }; 949 static const char *const an7583_phy1_led0_groups[] = { "gpio1", "gpio2", 950 "gpio3", "gpio4" }; 951 static const char *const an7583_phy2_led0_groups[] = { "gpio1", "gpio2", 952 "gpio3", "gpio4" }; 953 static const char *const an7583_phy3_led0_groups[] = { "gpio1", "gpio2", 954 "gpio3", "gpio4" }; 955 static const char *const an7583_phy4_led0_groups[] = { "gpio1", "gpio2", 956 "gpio3", "gpio4" }; 957 static const char *const an7583_phy1_led1_groups[] = { "gpio8", "gpio9", 958 "gpio10", "gpio11" }; 959 static const char *const an7583_phy2_led1_groups[] = { "gpio8", "gpio9", 960 "gpio10", "gpio11" }; 961 static const char *const an7583_phy3_led1_groups[] = { "gpio8", "gpio9", 962 "gpio10", "gpio11" }; 963 static const char *const an7583_phy4_led1_groups[] = { "gpio8", "gpio9", 964 "gpio10", "gpio11" }; 965 966 static const struct airoha_pinctrl_func_group pon_func_group[] = { 967 { 968 .name = "pon", 969 .regmap[0] = { 970 AIROHA_FUNC_MUX, 971 REG_GPIO_PON_MODE, 972 GPIO_PON_MODE_MASK, 973 GPIO_PON_MODE_MASK 974 }, 975 .regmap_size = 1, 976 }, 977 }; 978 979 static const struct airoha_pinctrl_func_group tod_1pps_func_group[] = { 980 { 981 .name = "pon_tod_1pps", 982 .regmap[0] = { 983 AIROHA_FUNC_MUX, 984 REG_GPIO_2ND_I2C_MODE, 985 PON_TOD_1PPS_MODE_MASK, 986 PON_TOD_1PPS_MODE_MASK 987 }, 988 .regmap_size = 1, 989 }, { 990 .name = "gsw_tod_1pps", 991 .regmap[0] = { 992 AIROHA_FUNC_MUX, 993 REG_GPIO_2ND_I2C_MODE, 994 GSW_TOD_1PPS_MODE_MASK, 995 GSW_TOD_1PPS_MODE_MASK 996 }, 997 .regmap_size = 1, 998 }, 999 }; 1000 1001 static const struct airoha_pinctrl_func_group sipo_func_group[] = { 1002 { 1003 .name = "sipo", 1004 .regmap[0] = { 1005 AIROHA_FUNC_MUX, 1006 REG_GPIO_PON_MODE, 1007 GPIO_SIPO_MODE_MASK | SIPO_RCLK_MODE_MASK, 1008 GPIO_SIPO_MODE_MASK 1009 }, 1010 .regmap_size = 1, 1011 }, { 1012 .name = "sipo_rclk", 1013 .regmap[0] = { 1014 AIROHA_FUNC_MUX, 1015 REG_GPIO_PON_MODE, 1016 GPIO_SIPO_MODE_MASK | SIPO_RCLK_MODE_MASK, 1017 GPIO_SIPO_MODE_MASK | SIPO_RCLK_MODE_MASK 1018 }, 1019 .regmap_size = 1, 1020 }, 1021 }; 1022 1023 static const struct airoha_pinctrl_func_group mdio_func_group[] = { 1024 { 1025 .name = "mdio", 1026 .regmap[0] = { 1027 AIROHA_FUNC_MUX, 1028 REG_GPIO_2ND_I2C_MODE, 1029 GPIO_MDC_IO_MASTER_MODE_MODE, 1030 GPIO_MDC_IO_MASTER_MODE_MODE 1031 }, 1032 .regmap[1] = { 1033 AIROHA_FUNC_MUX, 1034 REG_FORCE_GPIO_EN, 1035 FORCE_GPIO_EN(1) | FORCE_GPIO_EN(2), 1036 FORCE_GPIO_EN(1) | FORCE_GPIO_EN(2) 1037 }, 1038 .regmap_size = 2, 1039 }, 1040 }; 1041 1042 static const struct airoha_pinctrl_func_group an7583_mdio_func_group[] = { 1043 { 1044 .name = "mdio", 1045 .regmap[0] = { 1046 AIROHA_FUNC_MUX, 1047 REG_GPIO_PON_MODE, 1048 GPIO_SGMII_MDIO_MODE_MASK, 1049 GPIO_SGMII_MDIO_MODE_MASK 1050 }, 1051 .regmap[1] = { 1052 AIROHA_FUNC_MUX, 1053 REG_GPIO_SPI_CS1_MODE, 1054 GPIO_MDC_IO_MASTER_MODE_MODE, 1055 GPIO_MDC_IO_MASTER_MODE_MODE 1056 }, 1057 .regmap_size = 2, 1058 }, 1059 }; 1060 1061 static const struct airoha_pinctrl_func_group uart_func_group[] = { 1062 { 1063 .name = "uart2", 1064 .regmap[0] = { 1065 AIROHA_FUNC_MUX, 1066 REG_GPIO_PON_MODE, 1067 GPIO_UART2_MODE_MASK, 1068 GPIO_UART2_MODE_MASK 1069 }, 1070 .regmap_size = 1, 1071 }, { 1072 .name = "uart2_cts_rts", 1073 .regmap[0] = { 1074 AIROHA_FUNC_MUX, 1075 REG_GPIO_PON_MODE, 1076 GPIO_UART2_MODE_MASK | GPIO_UART2_CTS_RTS_MODE_MASK, 1077 GPIO_UART2_MODE_MASK | GPIO_UART2_CTS_RTS_MODE_MASK 1078 }, 1079 .regmap_size = 1, 1080 }, { 1081 .name = "hsuart", 1082 .regmap[0] = { 1083 AIROHA_FUNC_MUX, 1084 REG_GPIO_PON_MODE, 1085 GPIO_HSUART_MODE_MASK | GPIO_HSUART_CTS_RTS_MODE_MASK, 1086 GPIO_HSUART_MODE_MASK 1087 }, 1088 .regmap_size = 1, 1089 }, 1090 { 1091 .name = "hsuart_cts_rts", 1092 .regmap[0] = { 1093 AIROHA_FUNC_MUX, 1094 REG_GPIO_PON_MODE, 1095 GPIO_HSUART_MODE_MASK | GPIO_HSUART_CTS_RTS_MODE_MASK, 1096 GPIO_HSUART_MODE_MASK | GPIO_HSUART_CTS_RTS_MODE_MASK 1097 }, 1098 .regmap_size = 1, 1099 }, { 1100 .name = "uart4", 1101 .regmap[0] = { 1102 AIROHA_FUNC_MUX, 1103 REG_GPIO_PON_MODE, 1104 GPIO_UART4_MODE_MASK, 1105 GPIO_UART4_MODE_MASK 1106 }, 1107 .regmap_size = 1, 1108 }, { 1109 .name = "uart5", 1110 .regmap[0] = { 1111 AIROHA_FUNC_MUX, 1112 REG_GPIO_PON_MODE, 1113 GPIO_UART5_MODE_MASK, 1114 GPIO_UART5_MODE_MASK 1115 }, 1116 .regmap_size = 1, 1117 }, 1118 }; 1119 1120 static const struct airoha_pinctrl_func_group i2c_func_group[] = { 1121 { 1122 .name = "i2c1", 1123 .regmap[0] = { 1124 AIROHA_FUNC_MUX, 1125 REG_GPIO_2ND_I2C_MODE, 1126 GPIO_2ND_I2C_MODE_MASK, 1127 GPIO_2ND_I2C_MODE_MASK 1128 }, 1129 .regmap_size = 1, 1130 }, 1131 }; 1132 1133 static const struct airoha_pinctrl_func_group jtag_func_group[] = { 1134 { 1135 .name = "jtag_udi", 1136 .regmap[0] = { 1137 AIROHA_FUNC_MUX, 1138 REG_NPU_UART_EN, 1139 JTAG_UDI_EN_MASK, 1140 JTAG_UDI_EN_MASK 1141 }, 1142 .regmap_size = 1, 1143 }, { 1144 .name = "jtag_dfd", 1145 .regmap[0] = { 1146 AIROHA_FUNC_MUX, 1147 REG_NPU_UART_EN, 1148 JTAG_DFD_EN_MASK, 1149 JTAG_DFD_EN_MASK 1150 }, 1151 .regmap_size = 1, 1152 }, 1153 }; 1154 1155 static const struct airoha_pinctrl_func_group pcm_func_group[] = { 1156 { 1157 .name = "pcm1", 1158 .regmap[0] = { 1159 AIROHA_FUNC_MUX, 1160 REG_GPIO_SPI_CS1_MODE, 1161 GPIO_PCM1_MODE_MASK, 1162 GPIO_PCM1_MODE_MASK 1163 }, 1164 .regmap_size = 1, 1165 }, { 1166 .name = "pcm2", 1167 .regmap[0] = { 1168 AIROHA_FUNC_MUX, 1169 REG_GPIO_SPI_CS1_MODE, 1170 GPIO_PCM2_MODE_MASK, 1171 GPIO_PCM2_MODE_MASK 1172 }, 1173 .regmap_size = 1, 1174 }, 1175 }; 1176 1177 static const struct airoha_pinctrl_func_group spi_func_group[] = { 1178 { 1179 .name = "spi_quad", 1180 .regmap[0] = { 1181 AIROHA_FUNC_MUX, 1182 REG_GPIO_SPI_CS1_MODE, 1183 GPIO_SPI_QUAD_MODE_MASK, 1184 GPIO_SPI_QUAD_MODE_MASK 1185 }, 1186 .regmap_size = 1, 1187 }, { 1188 .name = "spi_cs1", 1189 .regmap[0] = { 1190 AIROHA_FUNC_MUX, 1191 REG_GPIO_SPI_CS1_MODE, 1192 GPIO_SPI_CS1_MODE_MASK, 1193 GPIO_SPI_CS1_MODE_MASK 1194 }, 1195 .regmap_size = 1, 1196 }, { 1197 .name = "spi_cs2", 1198 .regmap[0] = { 1199 AIROHA_FUNC_MUX, 1200 REG_GPIO_SPI_CS1_MODE, 1201 GPIO_SPI_CS2_MODE_MASK, 1202 GPIO_SPI_CS2_MODE_MASK 1203 }, 1204 .regmap_size = 1, 1205 }, { 1206 .name = "spi_cs3", 1207 .regmap[0] = { 1208 AIROHA_FUNC_MUX, 1209 REG_GPIO_SPI_CS1_MODE, 1210 GPIO_SPI_CS3_MODE_MASK, 1211 GPIO_SPI_CS3_MODE_MASK 1212 }, 1213 .regmap_size = 1, 1214 }, { 1215 .name = "spi_cs4", 1216 .regmap[0] = { 1217 AIROHA_FUNC_MUX, 1218 REG_GPIO_SPI_CS1_MODE, 1219 GPIO_SPI_CS4_MODE_MASK, 1220 GPIO_SPI_CS4_MODE_MASK 1221 }, 1222 .regmap_size = 1, 1223 }, 1224 }; 1225 1226 static const struct airoha_pinctrl_func_group pcm_spi_func_group[] = { 1227 { 1228 .name = "pcm_spi", 1229 .regmap[0] = { 1230 AIROHA_FUNC_MUX, 1231 REG_GPIO_SPI_CS1_MODE, 1232 GPIO_PCM_SPI_MODE_MASK, 1233 GPIO_PCM_SPI_MODE_MASK 1234 }, 1235 .regmap_size = 1, 1236 }, { 1237 .name = "pcm_spi_int", 1238 .regmap[0] = { 1239 AIROHA_FUNC_MUX, 1240 REG_GPIO_SPI_CS1_MODE, 1241 GPIO_PCM_INT_MODE_MASK, 1242 GPIO_PCM_INT_MODE_MASK 1243 }, 1244 .regmap_size = 1, 1245 }, { 1246 .name = "pcm_spi_rst", 1247 .regmap[0] = { 1248 AIROHA_FUNC_MUX, 1249 REG_GPIO_SPI_CS1_MODE, 1250 GPIO_PCM_RESET_MODE_MASK, 1251 GPIO_PCM_RESET_MODE_MASK 1252 }, 1253 .regmap_size = 1, 1254 }, { 1255 .name = "pcm_spi_cs1", 1256 .regmap[0] = { 1257 AIROHA_FUNC_MUX, 1258 REG_GPIO_SPI_CS1_MODE, 1259 GPIO_PCM_SPI_CS1_MODE_MASK, 1260 GPIO_PCM_SPI_CS1_MODE_MASK 1261 }, 1262 .regmap_size = 1, 1263 }, { 1264 .name = "pcm_spi_cs2_p128", 1265 .regmap[0] = { 1266 AIROHA_FUNC_MUX, 1267 REG_GPIO_SPI_CS1_MODE, 1268 GPIO_PCM_SPI_CS2_MODE_P128_MASK, 1269 GPIO_PCM_SPI_CS2_MODE_P128_MASK 1270 }, 1271 .regmap_size = 1, 1272 }, { 1273 .name = "pcm_spi_cs2_p156", 1274 .regmap[0] = { 1275 AIROHA_FUNC_MUX, 1276 REG_GPIO_SPI_CS1_MODE, 1277 GPIO_PCM_SPI_CS2_MODE_P156_MASK, 1278 GPIO_PCM_SPI_CS2_MODE_P156_MASK 1279 }, 1280 .regmap_size = 1, 1281 }, { 1282 .name = "pcm_spi_cs3", 1283 .regmap[0] = { 1284 AIROHA_FUNC_MUX, 1285 REG_GPIO_SPI_CS1_MODE, 1286 GPIO_PCM_SPI_CS3_MODE_MASK, 1287 GPIO_PCM_SPI_CS3_MODE_MASK 1288 }, 1289 .regmap_size = 1, 1290 }, { 1291 .name = "pcm_spi_cs4", 1292 .regmap[0] = { 1293 AIROHA_FUNC_MUX, 1294 REG_GPIO_SPI_CS1_MODE, 1295 GPIO_PCM_SPI_CS4_MODE_MASK, 1296 GPIO_PCM_SPI_CS4_MODE_MASK 1297 }, 1298 .regmap_size = 1, 1299 }, 1300 }; 1301 1302 static const struct airoha_pinctrl_func_group an7583_pcm_spi_func_group[] = { 1303 { 1304 .name = "pcm_spi", 1305 .regmap[0] = { 1306 AIROHA_FUNC_MUX, 1307 REG_GPIO_SPI_CS1_MODE, 1308 GPIO_PCM_SPI_MODE_MASK, 1309 GPIO_PCM_SPI_MODE_MASK 1310 }, 1311 .regmap_size = 1, 1312 }, { 1313 .name = "pcm_spi_int", 1314 .regmap[0] = { 1315 AIROHA_FUNC_MUX, 1316 REG_GPIO_SPI_CS1_MODE, 1317 GPIO_PCM_INT_MODE_MASK, 1318 GPIO_PCM_INT_MODE_MASK 1319 }, 1320 .regmap_size = 1, 1321 }, { 1322 .name = "pcm_spi_rst", 1323 .regmap[0] = { 1324 AIROHA_FUNC_MUX, 1325 REG_GPIO_SPI_CS1_MODE, 1326 GPIO_PCM_RESET_MODE_MASK, 1327 GPIO_PCM_RESET_MODE_MASK 1328 }, 1329 .regmap_size = 1, 1330 }, { 1331 .name = "pcm_spi_cs1", 1332 .regmap[0] = { 1333 AIROHA_FUNC_MUX, 1334 REG_GPIO_SPI_CS1_MODE, 1335 GPIO_PCM_SPI_CS1_MODE_MASK, 1336 GPIO_PCM_SPI_CS1_MODE_MASK 1337 }, 1338 .regmap_size = 1, 1339 }, { 1340 .name = "pcm_spi_cs2", 1341 .regmap[0] = { 1342 AIROHA_FUNC_MUX, 1343 REG_GPIO_SPI_CS1_MODE, 1344 AN7583_GPIO_PCM_SPI_CS2_MODE_MASK, 1345 AN7583_GPIO_PCM_SPI_CS2_MODE_MASK 1346 }, 1347 .regmap_size = 1, 1348 }, { 1349 .name = "pcm_spi_cs3", 1350 .regmap[0] = { 1351 AIROHA_FUNC_MUX, 1352 REG_GPIO_SPI_CS1_MODE, 1353 GPIO_PCM_SPI_CS3_MODE_MASK, 1354 GPIO_PCM_SPI_CS3_MODE_MASK 1355 }, 1356 .regmap_size = 1, 1357 }, { 1358 .name = "pcm_spi_cs4", 1359 .regmap[0] = { 1360 AIROHA_FUNC_MUX, 1361 REG_GPIO_SPI_CS1_MODE, 1362 GPIO_PCM_SPI_CS4_MODE_MASK, 1363 GPIO_PCM_SPI_CS4_MODE_MASK 1364 }, 1365 .regmap_size = 1, 1366 }, 1367 }; 1368 1369 static const struct airoha_pinctrl_func_group i2s_func_group[] = { 1370 { 1371 .name = "i2s", 1372 .regmap[0] = { 1373 AIROHA_FUNC_MUX, 1374 REG_GPIO_2ND_I2C_MODE, 1375 GPIO_I2S_MODE_MASK, 1376 GPIO_I2S_MODE_MASK 1377 }, 1378 .regmap_size = 1, 1379 }, 1380 }; 1381 1382 static const struct airoha_pinctrl_func_group emmc_func_group[] = { 1383 { 1384 .name = "emmc", 1385 .regmap[0] = { 1386 AIROHA_FUNC_MUX, 1387 REG_GPIO_PON_MODE, 1388 GPIO_EMMC_MODE_MASK, 1389 GPIO_EMMC_MODE_MASK 1390 }, 1391 .regmap_size = 1, 1392 }, 1393 }; 1394 1395 static const struct airoha_pinctrl_func_group pnand_func_group[] = { 1396 { 1397 .name = "pnand", 1398 .regmap[0] = { 1399 AIROHA_FUNC_MUX, 1400 REG_GPIO_PON_MODE, 1401 GPIO_PARALLEL_NAND_MODE_MASK, 1402 GPIO_PARALLEL_NAND_MODE_MASK 1403 }, 1404 .regmap_size = 1, 1405 }, 1406 }; 1407 1408 static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = { 1409 { 1410 .name = "pcie_reset0", 1411 .regmap[0] = { 1412 AIROHA_FUNC_MUX, 1413 REG_GPIO_PON_MODE, 1414 GPIO_PCIE_RESET0_MASK, 1415 GPIO_PCIE_RESET0_MASK 1416 }, 1417 .regmap_size = 1, 1418 }, { 1419 .name = "pcie_reset1", 1420 .regmap[0] = { 1421 AIROHA_FUNC_MUX, 1422 REG_GPIO_PON_MODE, 1423 GPIO_PCIE_RESET1_MASK, 1424 GPIO_PCIE_RESET1_MASK 1425 }, 1426 .regmap_size = 1, 1427 }, { 1428 .name = "pcie_reset2", 1429 .regmap[0] = { 1430 AIROHA_FUNC_MUX, 1431 REG_GPIO_PON_MODE, 1432 GPIO_PCIE_RESET2_MASK, 1433 GPIO_PCIE_RESET2_MASK 1434 }, 1435 .regmap_size = 1, 1436 }, 1437 }; 1438 1439 static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = { 1440 { 1441 .name = "pcie_reset0", 1442 .regmap[0] = { 1443 AIROHA_FUNC_MUX, 1444 REG_GPIO_PON_MODE, 1445 GPIO_PCIE_RESET0_MASK, 1446 GPIO_PCIE_RESET0_MASK 1447 }, 1448 .regmap_size = 1, 1449 }, { 1450 .name = "pcie_reset1", 1451 .regmap[0] = { 1452 AIROHA_FUNC_MUX, 1453 REG_GPIO_PON_MODE, 1454 GPIO_PCIE_RESET1_MASK, 1455 GPIO_PCIE_RESET1_MASK 1456 }, 1457 .regmap_size = 1, 1458 }, 1459 }; 1460 1461 /* PWM */ 1462 #define AIROHA_PINCTRL_PWM(gpio, mux_val) \ 1463 { \ 1464 .name = (gpio), \ 1465 .regmap[0] = { \ 1466 AIROHA_FUNC_PWM_MUX, \ 1467 REG_GPIO_FLASH_MODE_CFG, \ 1468 (mux_val), \ 1469 (mux_val) \ 1470 }, \ 1471 .regmap_size = 1, \ 1472 } \ 1473 1474 #define AIROHA_PINCTRL_PWM_EXT(gpio, mux_val) \ 1475 { \ 1476 .name = (gpio), \ 1477 .regmap[0] = { \ 1478 AIROHA_FUNC_PWM_EXT_MUX, \ 1479 REG_GPIO_FLASH_MODE_CFG_EXT, \ 1480 (mux_val), \ 1481 (mux_val) \ 1482 }, \ 1483 .regmap_size = 1, \ 1484 } \ 1485 1486 static const struct airoha_pinctrl_func_group pwm_func_group[] = { 1487 AIROHA_PINCTRL_PWM("gpio0", GPIO0_FLASH_MODE_CFG), 1488 AIROHA_PINCTRL_PWM("gpio1", GPIO1_FLASH_MODE_CFG), 1489 AIROHA_PINCTRL_PWM("gpio2", GPIO2_FLASH_MODE_CFG), 1490 AIROHA_PINCTRL_PWM("gpio3", GPIO3_FLASH_MODE_CFG), 1491 AIROHA_PINCTRL_PWM("gpio4", GPIO4_FLASH_MODE_CFG), 1492 AIROHA_PINCTRL_PWM("gpio5", GPIO5_FLASH_MODE_CFG), 1493 AIROHA_PINCTRL_PWM("gpio6", GPIO6_FLASH_MODE_CFG), 1494 AIROHA_PINCTRL_PWM("gpio7", GPIO7_FLASH_MODE_CFG), 1495 AIROHA_PINCTRL_PWM("gpio8", GPIO8_FLASH_MODE_CFG), 1496 AIROHA_PINCTRL_PWM("gpio9", GPIO9_FLASH_MODE_CFG), 1497 AIROHA_PINCTRL_PWM("gpio10", GPIO10_FLASH_MODE_CFG), 1498 AIROHA_PINCTRL_PWM("gpio11", GPIO11_FLASH_MODE_CFG), 1499 AIROHA_PINCTRL_PWM("gpio12", GPIO12_FLASH_MODE_CFG), 1500 AIROHA_PINCTRL_PWM("gpio13", GPIO13_FLASH_MODE_CFG), 1501 AIROHA_PINCTRL_PWM("gpio14", GPIO14_FLASH_MODE_CFG), 1502 AIROHA_PINCTRL_PWM("gpio15", GPIO15_FLASH_MODE_CFG), 1503 AIROHA_PINCTRL_PWM_EXT("gpio16", GPIO16_FLASH_MODE_CFG), 1504 AIROHA_PINCTRL_PWM_EXT("gpio17", GPIO17_FLASH_MODE_CFG), 1505 AIROHA_PINCTRL_PWM_EXT("gpio18", GPIO18_FLASH_MODE_CFG), 1506 AIROHA_PINCTRL_PWM_EXT("gpio19", GPIO19_FLASH_MODE_CFG), 1507 AIROHA_PINCTRL_PWM_EXT("gpio20", GPIO20_FLASH_MODE_CFG), 1508 AIROHA_PINCTRL_PWM_EXT("gpio21", GPIO21_FLASH_MODE_CFG), 1509 AIROHA_PINCTRL_PWM_EXT("gpio22", GPIO22_FLASH_MODE_CFG), 1510 AIROHA_PINCTRL_PWM_EXT("gpio23", GPIO23_FLASH_MODE_CFG), 1511 AIROHA_PINCTRL_PWM_EXT("gpio24", GPIO24_FLASH_MODE_CFG), 1512 AIROHA_PINCTRL_PWM_EXT("gpio25", GPIO25_FLASH_MODE_CFG), 1513 AIROHA_PINCTRL_PWM_EXT("gpio26", GPIO26_FLASH_MODE_CFG), 1514 AIROHA_PINCTRL_PWM_EXT("gpio27", GPIO27_FLASH_MODE_CFG), 1515 AIROHA_PINCTRL_PWM_EXT("gpio28", GPIO28_FLASH_MODE_CFG), 1516 AIROHA_PINCTRL_PWM_EXT("gpio29", GPIO29_FLASH_MODE_CFG), 1517 AIROHA_PINCTRL_PWM_EXT("gpio30", GPIO30_FLASH_MODE_CFG), 1518 AIROHA_PINCTRL_PWM_EXT("gpio31", GPIO31_FLASH_MODE_CFG), 1519 AIROHA_PINCTRL_PWM_EXT("gpio36", GPIO36_FLASH_MODE_CFG), 1520 AIROHA_PINCTRL_PWM_EXT("gpio37", GPIO37_FLASH_MODE_CFG), 1521 AIROHA_PINCTRL_PWM_EXT("gpio38", GPIO38_FLASH_MODE_CFG), 1522 AIROHA_PINCTRL_PWM_EXT("gpio39", GPIO39_FLASH_MODE_CFG), 1523 AIROHA_PINCTRL_PWM_EXT("gpio40", GPIO40_FLASH_MODE_CFG), 1524 AIROHA_PINCTRL_PWM_EXT("gpio41", GPIO41_FLASH_MODE_CFG), 1525 AIROHA_PINCTRL_PWM_EXT("gpio42", GPIO42_FLASH_MODE_CFG), 1526 AIROHA_PINCTRL_PWM_EXT("gpio43", GPIO43_FLASH_MODE_CFG), 1527 AIROHA_PINCTRL_PWM_EXT("gpio44", GPIO44_FLASH_MODE_CFG), 1528 AIROHA_PINCTRL_PWM_EXT("gpio45", GPIO45_FLASH_MODE_CFG), 1529 AIROHA_PINCTRL_PWM_EXT("gpio46", GPIO46_FLASH_MODE_CFG), 1530 }; 1531 1532 static const struct airoha_pinctrl_func_group an7583_pwm_func_group[] = { 1533 AIROHA_PINCTRL_PWM("gpio0", GPIO0_FLASH_MODE_CFG), 1534 AIROHA_PINCTRL_PWM("gpio1", GPIO1_FLASH_MODE_CFG), 1535 AIROHA_PINCTRL_PWM("gpio2", GPIO2_FLASH_MODE_CFG), 1536 AIROHA_PINCTRL_PWM("gpio3", GPIO3_FLASH_MODE_CFG), 1537 AIROHA_PINCTRL_PWM("gpio4", GPIO4_FLASH_MODE_CFG), 1538 AIROHA_PINCTRL_PWM("gpio5", GPIO5_FLASH_MODE_CFG), 1539 AIROHA_PINCTRL_PWM("gpio6", GPIO6_FLASH_MODE_CFG), 1540 AIROHA_PINCTRL_PWM("gpio7", GPIO7_FLASH_MODE_CFG), 1541 AIROHA_PINCTRL_PWM("gpio8", GPIO8_FLASH_MODE_CFG), 1542 AIROHA_PINCTRL_PWM("gpio9", GPIO9_FLASH_MODE_CFG), 1543 AIROHA_PINCTRL_PWM("gpio10", GPIO10_FLASH_MODE_CFG), 1544 AIROHA_PINCTRL_PWM("gpio11", GPIO11_FLASH_MODE_CFG), 1545 AIROHA_PINCTRL_PWM("gpio12", GPIO12_FLASH_MODE_CFG), 1546 AIROHA_PINCTRL_PWM("gpio13", GPIO13_FLASH_MODE_CFG), 1547 AIROHA_PINCTRL_PWM("gpio14", GPIO14_FLASH_MODE_CFG), 1548 AIROHA_PINCTRL_PWM("gpio15", GPIO15_FLASH_MODE_CFG), 1549 AIROHA_PINCTRL_PWM_EXT("gpio16", GPIO16_FLASH_MODE_CFG), 1550 AIROHA_PINCTRL_PWM_EXT("gpio17", GPIO17_FLASH_MODE_CFG), 1551 AIROHA_PINCTRL_PWM_EXT("gpio18", GPIO18_FLASH_MODE_CFG), 1552 AIROHA_PINCTRL_PWM_EXT("gpio19", GPIO19_FLASH_MODE_CFG), 1553 AIROHA_PINCTRL_PWM_EXT("gpio20", GPIO20_FLASH_MODE_CFG), 1554 AIROHA_PINCTRL_PWM_EXT("gpio21", GPIO21_FLASH_MODE_CFG), 1555 AIROHA_PINCTRL_PWM_EXT("gpio22", GPIO22_FLASH_MODE_CFG), 1556 AIROHA_PINCTRL_PWM_EXT("gpio23", GPIO23_FLASH_MODE_CFG), 1557 AIROHA_PINCTRL_PWM_EXT("gpio24", GPIO24_FLASH_MODE_CFG), 1558 AIROHA_PINCTRL_PWM_EXT("gpio25", GPIO25_FLASH_MODE_CFG), 1559 AIROHA_PINCTRL_PWM_EXT("gpio26", GPIO26_FLASH_MODE_CFG), 1560 AIROHA_PINCTRL_PWM_EXT("gpio27", GPIO27_FLASH_MODE_CFG), 1561 AIROHA_PINCTRL_PWM_EXT("gpio28", GPIO28_FLASH_MODE_CFG), 1562 AIROHA_PINCTRL_PWM_EXT("gpio29", GPIO29_FLASH_MODE_CFG), 1563 AIROHA_PINCTRL_PWM_EXT("gpio30", GPIO30_FLASH_MODE_CFG), 1564 AIROHA_PINCTRL_PWM_EXT("gpio31", GPIO31_FLASH_MODE_CFG), 1565 AIROHA_PINCTRL_PWM_EXT("gpio36", GPIO36_FLASH_MODE_CFG), 1566 AIROHA_PINCTRL_PWM_EXT("gpio37", GPIO37_FLASH_MODE_CFG), 1567 AIROHA_PINCTRL_PWM_EXT("gpio38", GPIO38_FLASH_MODE_CFG), 1568 AIROHA_PINCTRL_PWM_EXT("gpio39", GPIO39_FLASH_MODE_CFG), 1569 AIROHA_PINCTRL_PWM_EXT("gpio40", GPIO40_FLASH_MODE_CFG), 1570 AIROHA_PINCTRL_PWM_EXT("gpio41", GPIO41_FLASH_MODE_CFG), 1571 AIROHA_PINCTRL_PWM_EXT("gpio42", GPIO42_FLASH_MODE_CFG), 1572 AIROHA_PINCTRL_PWM_EXT("gpio43", GPIO43_FLASH_MODE_CFG), 1573 AIROHA_PINCTRL_PWM_EXT("gpio44", GPIO44_FLASH_MODE_CFG), 1574 AIROHA_PINCTRL_PWM_EXT("gpio45", GPIO45_FLASH_MODE_CFG), 1575 AIROHA_PINCTRL_PWM_EXT("gpio46", GPIO46_FLASH_MODE_CFG), 1576 AIROHA_PINCTRL_PWM_EXT("gpio47", GPIO47_FLASH_MODE_CFG), 1577 AIROHA_PINCTRL_PWM_EXT("gpio48", GPIO48_FLASH_MODE_CFG), 1578 }; 1579 1580 #define AIROHA_PINCTRL_PHY_LED0(gpio, mux_val, map_mask, map_val) \ 1581 { \ 1582 .name = (gpio), \ 1583 .regmap[0] = { \ 1584 AIROHA_FUNC_MUX, \ 1585 REG_GPIO_2ND_I2C_MODE, \ 1586 (mux_val), \ 1587 (mux_val), \ 1588 }, \ 1589 .regmap[1] = { \ 1590 AIROHA_FUNC_MUX, \ 1591 REG_LAN_LED0_MAPPING, \ 1592 (map_mask), \ 1593 (map_val), \ 1594 }, \ 1595 .regmap_size = 2, \ 1596 } 1597 1598 #define AIROHA_PINCTRL_PHY_LED1(gpio, mux_val, map_mask, map_val) \ 1599 { \ 1600 .name = (gpio), \ 1601 .regmap[0] = { \ 1602 AIROHA_FUNC_MUX, \ 1603 REG_GPIO_2ND_I2C_MODE, \ 1604 (mux_val), \ 1605 (mux_val), \ 1606 }, \ 1607 .regmap[1] = { \ 1608 AIROHA_FUNC_MUX, \ 1609 REG_LAN_LED1_MAPPING, \ 1610 (map_mask), \ 1611 (map_val), \ 1612 }, \ 1613 .regmap_size = 2, \ 1614 } 1615 1616 static const struct airoha_pinctrl_func_group phy1_led0_func_group[] = { 1617 AIROHA_PINCTRL_PHY_LED0("gpio33", GPIO_LAN0_LED0_MODE_MASK, 1618 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(0)), 1619 AIROHA_PINCTRL_PHY_LED0("gpio34", GPIO_LAN1_LED0_MODE_MASK, 1620 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(0)), 1621 AIROHA_PINCTRL_PHY_LED0("gpio35", GPIO_LAN2_LED0_MODE_MASK, 1622 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(0)), 1623 AIROHA_PINCTRL_PHY_LED0("gpio42", GPIO_LAN3_LED0_MODE_MASK, 1624 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(0)), 1625 }; 1626 1627 static const struct airoha_pinctrl_func_group phy2_led0_func_group[] = { 1628 AIROHA_PINCTRL_PHY_LED0("gpio33", GPIO_LAN0_LED0_MODE_MASK, 1629 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(1)), 1630 AIROHA_PINCTRL_PHY_LED0("gpio34", GPIO_LAN1_LED0_MODE_MASK, 1631 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(1)), 1632 AIROHA_PINCTRL_PHY_LED0("gpio35", GPIO_LAN2_LED0_MODE_MASK, 1633 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(1)), 1634 AIROHA_PINCTRL_PHY_LED0("gpio42", GPIO_LAN3_LED0_MODE_MASK, 1635 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(1)), 1636 }; 1637 1638 static const struct airoha_pinctrl_func_group phy3_led0_func_group[] = { 1639 AIROHA_PINCTRL_PHY_LED0("gpio33", GPIO_LAN0_LED0_MODE_MASK, 1640 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(2)), 1641 AIROHA_PINCTRL_PHY_LED0("gpio34", GPIO_LAN1_LED0_MODE_MASK, 1642 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(2)), 1643 AIROHA_PINCTRL_PHY_LED0("gpio35", GPIO_LAN2_LED0_MODE_MASK, 1644 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(2)), 1645 AIROHA_PINCTRL_PHY_LED0("gpio42", GPIO_LAN3_LED0_MODE_MASK, 1646 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(2)), 1647 }; 1648 1649 static const struct airoha_pinctrl_func_group phy4_led0_func_group[] = { 1650 AIROHA_PINCTRL_PHY_LED0("gpio33", GPIO_LAN0_LED0_MODE_MASK, 1651 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(3)), 1652 AIROHA_PINCTRL_PHY_LED0("gpio34", GPIO_LAN1_LED0_MODE_MASK, 1653 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(3)), 1654 AIROHA_PINCTRL_PHY_LED0("gpio35", GPIO_LAN2_LED0_MODE_MASK, 1655 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(3)), 1656 AIROHA_PINCTRL_PHY_LED0("gpio42", GPIO_LAN3_LED0_MODE_MASK, 1657 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(3)), 1658 }; 1659 1660 static const struct airoha_pinctrl_func_group phy1_led1_func_group[] = { 1661 AIROHA_PINCTRL_PHY_LED1("gpio43", GPIO_LAN0_LED1_MODE_MASK, 1662 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(0)), 1663 AIROHA_PINCTRL_PHY_LED1("gpio44", GPIO_LAN1_LED1_MODE_MASK, 1664 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(0)), 1665 AIROHA_PINCTRL_PHY_LED1("gpio45", GPIO_LAN2_LED1_MODE_MASK, 1666 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(0)), 1667 AIROHA_PINCTRL_PHY_LED1("gpio46", GPIO_LAN3_LED1_MODE_MASK, 1668 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(0)), 1669 }; 1670 1671 static const struct airoha_pinctrl_func_group phy2_led1_func_group[] = { 1672 AIROHA_PINCTRL_PHY_LED1("gpio43", GPIO_LAN0_LED1_MODE_MASK, 1673 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(1)), 1674 AIROHA_PINCTRL_PHY_LED1("gpio44", GPIO_LAN1_LED1_MODE_MASK, 1675 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(1)), 1676 AIROHA_PINCTRL_PHY_LED1("gpio45", GPIO_LAN2_LED1_MODE_MASK, 1677 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(1)), 1678 AIROHA_PINCTRL_PHY_LED1("gpio46", GPIO_LAN3_LED1_MODE_MASK, 1679 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(1)), 1680 }; 1681 1682 static const struct airoha_pinctrl_func_group phy3_led1_func_group[] = { 1683 AIROHA_PINCTRL_PHY_LED1("gpio43", GPIO_LAN0_LED1_MODE_MASK, 1684 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(2)), 1685 AIROHA_PINCTRL_PHY_LED1("gpio44", GPIO_LAN1_LED1_MODE_MASK, 1686 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(2)), 1687 AIROHA_PINCTRL_PHY_LED1("gpio45", GPIO_LAN2_LED1_MODE_MASK, 1688 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(2)), 1689 AIROHA_PINCTRL_PHY_LED1("gpio46", GPIO_LAN3_LED1_MODE_MASK, 1690 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(2)), 1691 }; 1692 1693 static const struct airoha_pinctrl_func_group phy4_led1_func_group[] = { 1694 AIROHA_PINCTRL_PHY_LED1("gpio43", GPIO_LAN0_LED1_MODE_MASK, 1695 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(3)), 1696 AIROHA_PINCTRL_PHY_LED1("gpio44", GPIO_LAN1_LED1_MODE_MASK, 1697 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(3)), 1698 AIROHA_PINCTRL_PHY_LED1("gpio45", GPIO_LAN2_LED1_MODE_MASK, 1699 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(3)), 1700 AIROHA_PINCTRL_PHY_LED1("gpio46", GPIO_LAN3_LED1_MODE_MASK, 1701 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(3)), 1702 }; 1703 1704 static const struct airoha_pinctrl_func_group an7583_phy1_led0_func_group[] = { 1705 AIROHA_PINCTRL_PHY_LED0("gpio1", GPIO_LAN0_LED0_MODE_MASK, 1706 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(0)), 1707 AIROHA_PINCTRL_PHY_LED0("gpio2", GPIO_LAN1_LED0_MODE_MASK, 1708 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(0)), 1709 AIROHA_PINCTRL_PHY_LED0("gpio3", GPIO_LAN2_LED0_MODE_MASK, 1710 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(0)), 1711 AIROHA_PINCTRL_PHY_LED0("gpio4", GPIO_LAN3_LED0_MODE_MASK, 1712 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(0)), 1713 }; 1714 1715 static const struct airoha_pinctrl_func_group an7583_phy2_led0_func_group[] = { 1716 AIROHA_PINCTRL_PHY_LED0("gpio1", GPIO_LAN0_LED0_MODE_MASK, 1717 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(1)), 1718 AIROHA_PINCTRL_PHY_LED0("gpio2", GPIO_LAN1_LED0_MODE_MASK, 1719 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(1)), 1720 AIROHA_PINCTRL_PHY_LED0("gpio3", GPIO_LAN2_LED0_MODE_MASK, 1721 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(1)), 1722 AIROHA_PINCTRL_PHY_LED0("gpio4", GPIO_LAN3_LED0_MODE_MASK, 1723 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(1)), 1724 }; 1725 1726 static const struct airoha_pinctrl_func_group an7583_phy3_led0_func_group[] = { 1727 AIROHA_PINCTRL_PHY_LED0("gpio1", GPIO_LAN0_LED0_MODE_MASK, 1728 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(2)), 1729 AIROHA_PINCTRL_PHY_LED0("gpio2", GPIO_LAN1_LED0_MODE_MASK, 1730 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(2)), 1731 AIROHA_PINCTRL_PHY_LED0("gpio3", GPIO_LAN2_LED0_MODE_MASK, 1732 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(2)), 1733 AIROHA_PINCTRL_PHY_LED0("gpio4", GPIO_LAN3_LED0_MODE_MASK, 1734 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(2)), 1735 }; 1736 1737 static const struct airoha_pinctrl_func_group an7583_phy4_led0_func_group[] = { 1738 AIROHA_PINCTRL_PHY_LED0("gpio1", GPIO_LAN0_LED0_MODE_MASK, 1739 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(3)), 1740 AIROHA_PINCTRL_PHY_LED0("gpio2", GPIO_LAN1_LED0_MODE_MASK, 1741 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(3)), 1742 AIROHA_PINCTRL_PHY_LED0("gpio3", GPIO_LAN2_LED0_MODE_MASK, 1743 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(3)), 1744 AIROHA_PINCTRL_PHY_LED0("gpio4", GPIO_LAN3_LED0_MODE_MASK, 1745 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(3)), 1746 }; 1747 1748 static const struct airoha_pinctrl_func_group an7583_phy1_led1_func_group[] = { 1749 AIROHA_PINCTRL_PHY_LED1("gpio8", GPIO_LAN0_LED1_MODE_MASK, 1750 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(0)), 1751 AIROHA_PINCTRL_PHY_LED1("gpio9", GPIO_LAN1_LED1_MODE_MASK, 1752 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(0)), 1753 AIROHA_PINCTRL_PHY_LED1("gpio10", GPIO_LAN2_LED1_MODE_MASK, 1754 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(0)), 1755 AIROHA_PINCTRL_PHY_LED1("gpio11", GPIO_LAN3_LED1_MODE_MASK, 1756 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(0)), 1757 }; 1758 1759 static const struct airoha_pinctrl_func_group an7583_phy2_led1_func_group[] = { 1760 AIROHA_PINCTRL_PHY_LED1("gpio8", GPIO_LAN0_LED1_MODE_MASK, 1761 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(1)), 1762 AIROHA_PINCTRL_PHY_LED1("gpio9", GPIO_LAN1_LED1_MODE_MASK, 1763 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(1)), 1764 AIROHA_PINCTRL_PHY_LED1("gpio10", GPIO_LAN2_LED1_MODE_MASK, 1765 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(1)), 1766 AIROHA_PINCTRL_PHY_LED1("gpio11", GPIO_LAN3_LED1_MODE_MASK, 1767 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(1)), 1768 }; 1769 1770 static const struct airoha_pinctrl_func_group an7583_phy3_led1_func_group[] = { 1771 AIROHA_PINCTRL_PHY_LED1("gpio8", GPIO_LAN0_LED1_MODE_MASK, 1772 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(2)), 1773 AIROHA_PINCTRL_PHY_LED1("gpio9", GPIO_LAN1_LED1_MODE_MASK, 1774 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(2)), 1775 AIROHA_PINCTRL_PHY_LED1("gpio10", GPIO_LAN2_LED1_MODE_MASK, 1776 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(2)), 1777 AIROHA_PINCTRL_PHY_LED1("gpio11", GPIO_LAN3_LED1_MODE_MASK, 1778 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(2)), 1779 }; 1780 1781 static const struct airoha_pinctrl_func_group an7583_phy4_led1_func_group[] = { 1782 AIROHA_PINCTRL_PHY_LED1("gpio8", GPIO_LAN0_LED1_MODE_MASK, 1783 LAN0_LED_MAPPING_MASK, LAN0_PHY_LED_MAP(3)), 1784 AIROHA_PINCTRL_PHY_LED1("gpio9", GPIO_LAN1_LED1_MODE_MASK, 1785 LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(3)), 1786 AIROHA_PINCTRL_PHY_LED1("gpio10", GPIO_LAN2_LED1_MODE_MASK, 1787 LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(3)), 1788 AIROHA_PINCTRL_PHY_LED1("gpio11", GPIO_LAN3_LED1_MODE_MASK, 1789 LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(3)), 1790 }; 1791 1792 static const struct airoha_pinctrl_func en7581_pinctrl_funcs[] = { 1793 PINCTRL_FUNC_DESC("pon", pon), 1794 PINCTRL_FUNC_DESC("tod_1pps", tod_1pps), 1795 PINCTRL_FUNC_DESC("sipo", sipo), 1796 PINCTRL_FUNC_DESC("mdio", mdio), 1797 PINCTRL_FUNC_DESC("uart", uart), 1798 PINCTRL_FUNC_DESC("i2c", i2c), 1799 PINCTRL_FUNC_DESC("jtag", jtag), 1800 PINCTRL_FUNC_DESC("pcm", pcm), 1801 PINCTRL_FUNC_DESC("spi", spi), 1802 PINCTRL_FUNC_DESC("pcm_spi", pcm_spi), 1803 PINCTRL_FUNC_DESC("i2s", i2s), 1804 PINCTRL_FUNC_DESC("emmc", emmc), 1805 PINCTRL_FUNC_DESC("pnand", pnand), 1806 PINCTRL_FUNC_DESC("pcie_reset", pcie_reset), 1807 PINCTRL_FUNC_DESC("pwm", pwm), 1808 PINCTRL_FUNC_DESC("phy1_led0", phy1_led0), 1809 PINCTRL_FUNC_DESC("phy2_led0", phy2_led0), 1810 PINCTRL_FUNC_DESC("phy3_led0", phy3_led0), 1811 PINCTRL_FUNC_DESC("phy4_led0", phy4_led0), 1812 PINCTRL_FUNC_DESC("phy1_led1", phy1_led1), 1813 PINCTRL_FUNC_DESC("phy2_led1", phy2_led1), 1814 PINCTRL_FUNC_DESC("phy3_led1", phy3_led1), 1815 PINCTRL_FUNC_DESC("phy4_led1", phy4_led1), 1816 }; 1817 1818 static const struct airoha_pinctrl_func an7583_pinctrl_funcs[] = { 1819 PINCTRL_FUNC_DESC("pon", pon), 1820 PINCTRL_FUNC_DESC("tod_1pps", tod_1pps), 1821 PINCTRL_FUNC_DESC("sipo", sipo), 1822 PINCTRL_FUNC_DESC("mdio", an7583_mdio), 1823 PINCTRL_FUNC_DESC("uart", uart), 1824 PINCTRL_FUNC_DESC("i2c", i2c), 1825 PINCTRL_FUNC_DESC("jtag", jtag), 1826 PINCTRL_FUNC_DESC("pcm", pcm), 1827 PINCTRL_FUNC_DESC("spi", spi), 1828 PINCTRL_FUNC_DESC("pcm_spi", an7583_pcm_spi), 1829 PINCTRL_FUNC_DESC("emmc", emmc), 1830 PINCTRL_FUNC_DESC("pnand", pnand), 1831 PINCTRL_FUNC_DESC("pcie_reset", an7583_pcie_reset), 1832 PINCTRL_FUNC_DESC("pwm", an7583_pwm), 1833 PINCTRL_FUNC_DESC("phy1_led0", an7583_phy1_led0), 1834 PINCTRL_FUNC_DESC("phy2_led0", an7583_phy2_led0), 1835 PINCTRL_FUNC_DESC("phy3_led0", an7583_phy3_led0), 1836 PINCTRL_FUNC_DESC("phy4_led0", an7583_phy4_led0), 1837 PINCTRL_FUNC_DESC("phy1_led1", an7583_phy1_led1), 1838 PINCTRL_FUNC_DESC("phy2_led1", an7583_phy2_led1), 1839 PINCTRL_FUNC_DESC("phy3_led1", an7583_phy3_led1), 1840 PINCTRL_FUNC_DESC("phy4_led1", an7583_phy4_led1), 1841 }; 1842 1843 static const struct airoha_pinctrl_conf en7581_pinctrl_pullup_conf[] = { 1844 PINCTRL_CONF_DESC(0, REG_I2C_SDA_PU, UART1_TXD_PU_MASK), 1845 PINCTRL_CONF_DESC(1, REG_I2C_SDA_PU, UART1_RXD_PU_MASK), 1846 PINCTRL_CONF_DESC(2, REG_I2C_SDA_PU, I2C_SDA_PU_MASK), 1847 PINCTRL_CONF_DESC(3, REG_I2C_SDA_PU, I2C_SCL_PU_MASK), 1848 PINCTRL_CONF_DESC(4, REG_I2C_SDA_PU, SPI_CS0_PU_MASK), 1849 PINCTRL_CONF_DESC(5, REG_I2C_SDA_PU, SPI_CLK_PU_MASK), 1850 PINCTRL_CONF_DESC(6, REG_I2C_SDA_PU, SPI_MOSI_PU_MASK), 1851 PINCTRL_CONF_DESC(7, REG_I2C_SDA_PU, SPI_MISO_PU_MASK), 1852 PINCTRL_CONF_DESC(13, REG_GPIO_L_PU, BIT(0)), 1853 PINCTRL_CONF_DESC(14, REG_GPIO_L_PU, BIT(1)), 1854 PINCTRL_CONF_DESC(15, REG_GPIO_L_PU, BIT(2)), 1855 PINCTRL_CONF_DESC(16, REG_GPIO_L_PU, BIT(3)), 1856 PINCTRL_CONF_DESC(17, REG_GPIO_L_PU, BIT(4)), 1857 PINCTRL_CONF_DESC(18, REG_GPIO_L_PU, BIT(5)), 1858 PINCTRL_CONF_DESC(19, REG_GPIO_L_PU, BIT(6)), 1859 PINCTRL_CONF_DESC(20, REG_GPIO_L_PU, BIT(7)), 1860 PINCTRL_CONF_DESC(21, REG_GPIO_L_PU, BIT(8)), 1861 PINCTRL_CONF_DESC(22, REG_GPIO_L_PU, BIT(9)), 1862 PINCTRL_CONF_DESC(23, REG_GPIO_L_PU, BIT(10)), 1863 PINCTRL_CONF_DESC(24, REG_GPIO_L_PU, BIT(11)), 1864 PINCTRL_CONF_DESC(25, REG_GPIO_L_PU, BIT(12)), 1865 PINCTRL_CONF_DESC(26, REG_GPIO_L_PU, BIT(13)), 1866 PINCTRL_CONF_DESC(27, REG_GPIO_L_PU, BIT(14)), 1867 PINCTRL_CONF_DESC(28, REG_GPIO_L_PU, BIT(15)), 1868 PINCTRL_CONF_DESC(29, REG_GPIO_L_PU, BIT(16)), 1869 PINCTRL_CONF_DESC(30, REG_GPIO_L_PU, BIT(17)), 1870 PINCTRL_CONF_DESC(31, REG_GPIO_L_PU, BIT(18)), 1871 PINCTRL_CONF_DESC(32, REG_GPIO_L_PU, BIT(19)), 1872 PINCTRL_CONF_DESC(33, REG_GPIO_L_PU, BIT(20)), 1873 PINCTRL_CONF_DESC(34, REG_GPIO_L_PU, BIT(21)), 1874 PINCTRL_CONF_DESC(35, REG_GPIO_L_PU, BIT(22)), 1875 PINCTRL_CONF_DESC(36, REG_GPIO_L_PU, BIT(23)), 1876 PINCTRL_CONF_DESC(37, REG_GPIO_L_PU, BIT(24)), 1877 PINCTRL_CONF_DESC(38, REG_GPIO_L_PU, BIT(25)), 1878 PINCTRL_CONF_DESC(39, REG_GPIO_L_PU, BIT(26)), 1879 PINCTRL_CONF_DESC(40, REG_GPIO_L_PU, BIT(27)), 1880 PINCTRL_CONF_DESC(41, REG_GPIO_L_PU, BIT(28)), 1881 PINCTRL_CONF_DESC(42, REG_GPIO_L_PU, BIT(29)), 1882 PINCTRL_CONF_DESC(43, REG_GPIO_L_PU, BIT(30)), 1883 PINCTRL_CONF_DESC(44, REG_GPIO_L_PU, BIT(31)), 1884 PINCTRL_CONF_DESC(45, REG_GPIO_H_PU, BIT(0)), 1885 PINCTRL_CONF_DESC(46, REG_GPIO_H_PU, BIT(1)), 1886 PINCTRL_CONF_DESC(47, REG_GPIO_H_PU, BIT(2)), 1887 PINCTRL_CONF_DESC(48, REG_GPIO_H_PU, BIT(3)), 1888 PINCTRL_CONF_DESC(49, REG_GPIO_H_PU, BIT(4)), 1889 PINCTRL_CONF_DESC(50, REG_GPIO_H_PU, BIT(5)), 1890 PINCTRL_CONF_DESC(51, REG_GPIO_H_PU, BIT(6)), 1891 PINCTRL_CONF_DESC(52, REG_GPIO_H_PU, BIT(7)), 1892 PINCTRL_CONF_DESC(53, REG_GPIO_H_PU, BIT(8)), 1893 PINCTRL_CONF_DESC(54, REG_GPIO_H_PU, BIT(9)), 1894 PINCTRL_CONF_DESC(55, REG_GPIO_H_PU, BIT(10)), 1895 PINCTRL_CONF_DESC(56, REG_GPIO_H_PU, BIT(11)), 1896 PINCTRL_CONF_DESC(57, REG_GPIO_H_PU, BIT(12)), 1897 PINCTRL_CONF_DESC(58, REG_GPIO_H_PU, BIT(13)), 1898 PINCTRL_CONF_DESC(59, REG_GPIO_H_PU, BIT(14)), 1899 PINCTRL_CONF_DESC(61, REG_I2C_SDA_PU, PCIE0_RESET_PU_MASK), 1900 PINCTRL_CONF_DESC(62, REG_I2C_SDA_PU, PCIE1_RESET_PU_MASK), 1901 PINCTRL_CONF_DESC(63, REG_I2C_SDA_PU, PCIE2_RESET_PU_MASK), 1902 }; 1903 1904 static const struct airoha_pinctrl_conf an7583_pinctrl_pullup_conf[] = { 1905 PINCTRL_CONF_DESC(2, REG_GPIO_L_PU, BIT(0)), 1906 PINCTRL_CONF_DESC(3, REG_GPIO_L_PU, BIT(1)), 1907 PINCTRL_CONF_DESC(4, REG_GPIO_L_PU, BIT(2)), 1908 PINCTRL_CONF_DESC(5, REG_GPIO_L_PU, BIT(3)), 1909 PINCTRL_CONF_DESC(6, REG_GPIO_L_PU, BIT(4)), 1910 PINCTRL_CONF_DESC(7, REG_GPIO_L_PU, BIT(5)), 1911 PINCTRL_CONF_DESC(8, REG_GPIO_L_PU, BIT(6)), 1912 PINCTRL_CONF_DESC(9, REG_GPIO_L_PU, BIT(7)), 1913 PINCTRL_CONF_DESC(10, REG_GPIO_L_PU, BIT(8)), 1914 PINCTRL_CONF_DESC(11, REG_GPIO_L_PU, BIT(9)), 1915 PINCTRL_CONF_DESC(12, REG_GPIO_L_PU, BIT(10)), 1916 PINCTRL_CONF_DESC(13, REG_GPIO_L_PU, BIT(11)), 1917 PINCTRL_CONF_DESC(14, REG_GPIO_L_PU, BIT(12)), 1918 PINCTRL_CONF_DESC(15, REG_GPIO_L_PU, BIT(13)), 1919 PINCTRL_CONF_DESC(16, REG_GPIO_L_PU, BIT(14)), 1920 PINCTRL_CONF_DESC(17, REG_GPIO_L_PU, BIT(15)), 1921 PINCTRL_CONF_DESC(18, REG_GPIO_L_PU, BIT(16)), 1922 PINCTRL_CONF_DESC(19, REG_GPIO_L_PU, BIT(17)), 1923 PINCTRL_CONF_DESC(20, REG_GPIO_L_PU, BIT(18)), 1924 PINCTRL_CONF_DESC(21, REG_GPIO_L_PU, BIT(19)), 1925 PINCTRL_CONF_DESC(22, REG_GPIO_L_PU, BIT(20)), 1926 PINCTRL_CONF_DESC(23, REG_GPIO_L_PU, BIT(21)), 1927 PINCTRL_CONF_DESC(24, REG_GPIO_L_PU, BIT(22)), 1928 PINCTRL_CONF_DESC(25, REG_GPIO_L_PU, BIT(23)), 1929 PINCTRL_CONF_DESC(26, REG_GPIO_L_PU, BIT(24)), 1930 PINCTRL_CONF_DESC(27, REG_GPIO_L_PU, BIT(25)), 1931 PINCTRL_CONF_DESC(28, REG_GPIO_L_PU, BIT(26)), 1932 PINCTRL_CONF_DESC(29, REG_GPIO_L_PU, BIT(27)), 1933 PINCTRL_CONF_DESC(30, REG_GPIO_L_PU, BIT(28)), 1934 PINCTRL_CONF_DESC(31, REG_GPIO_L_PU, BIT(29)), 1935 PINCTRL_CONF_DESC(32, REG_GPIO_L_PU, BIT(30)), 1936 PINCTRL_CONF_DESC(33, REG_GPIO_L_PU, BIT(31)), 1937 PINCTRL_CONF_DESC(34, REG_GPIO_H_PU, BIT(0)), 1938 PINCTRL_CONF_DESC(35, REG_GPIO_H_PU, BIT(1)), 1939 PINCTRL_CONF_DESC(36, REG_GPIO_H_PU, BIT(2)), 1940 PINCTRL_CONF_DESC(37, REG_GPIO_H_PU, BIT(3)), 1941 PINCTRL_CONF_DESC(38, REG_GPIO_H_PU, BIT(4)), 1942 PINCTRL_CONF_DESC(39, REG_GPIO_H_PU, BIT(5)), 1943 PINCTRL_CONF_DESC(40, REG_GPIO_H_PU, BIT(6)), 1944 PINCTRL_CONF_DESC(41, REG_I2C_SDA_PU, I2C_SCL_PU_MASK), 1945 PINCTRL_CONF_DESC(42, REG_I2C_SDA_PU, I2C_SDA_PU_MASK), 1946 PINCTRL_CONF_DESC(43, REG_I2C_SDA_PU, AN7583_I2C1_SCL_PU_MASK), 1947 PINCTRL_CONF_DESC(44, REG_I2C_SDA_PU, AN7583_I2C1_SDA_PU_MASK), 1948 PINCTRL_CONF_DESC(45, REG_I2C_SDA_PU, SPI_CLK_PU_MASK), 1949 PINCTRL_CONF_DESC(46, REG_I2C_SDA_PU, SPI_CS0_PU_MASK), 1950 PINCTRL_CONF_DESC(47, REG_I2C_SDA_PU, SPI_MOSI_PU_MASK), 1951 PINCTRL_CONF_DESC(48, REG_I2C_SDA_PU, SPI_MISO_PU_MASK), 1952 PINCTRL_CONF_DESC(49, REG_I2C_SDA_PU, UART1_TXD_PU_MASK), 1953 PINCTRL_CONF_DESC(50, REG_I2C_SDA_PU, UART1_RXD_PU_MASK), 1954 PINCTRL_CONF_DESC(51, REG_I2C_SDA_PU, PCIE0_RESET_PU_MASK), 1955 PINCTRL_CONF_DESC(52, REG_I2C_SDA_PU, PCIE1_RESET_PU_MASK), 1956 PINCTRL_CONF_DESC(53, REG_I2C_SDA_PU, AN7583_MDC_0_PU_MASK), 1957 PINCTRL_CONF_DESC(54, REG_I2C_SDA_PU, AN7583_MDIO_0_PU_MASK), 1958 }; 1959 1960 static const struct airoha_pinctrl_conf en7581_pinctrl_pulldown_conf[] = { 1961 PINCTRL_CONF_DESC(0, REG_I2C_SDA_PD, UART1_TXD_PD_MASK), 1962 PINCTRL_CONF_DESC(1, REG_I2C_SDA_PD, UART1_RXD_PD_MASK), 1963 PINCTRL_CONF_DESC(2, REG_I2C_SDA_PD, I2C_SDA_PD_MASK), 1964 PINCTRL_CONF_DESC(3, REG_I2C_SDA_PD, I2C_SCL_PD_MASK), 1965 PINCTRL_CONF_DESC(4, REG_I2C_SDA_PD, SPI_CS0_PD_MASK), 1966 PINCTRL_CONF_DESC(5, REG_I2C_SDA_PD, SPI_CLK_PD_MASK), 1967 PINCTRL_CONF_DESC(6, REG_I2C_SDA_PD, SPI_MOSI_PD_MASK), 1968 PINCTRL_CONF_DESC(7, REG_I2C_SDA_PD, SPI_MISO_PD_MASK), 1969 PINCTRL_CONF_DESC(13, REG_GPIO_L_PD, BIT(0)), 1970 PINCTRL_CONF_DESC(14, REG_GPIO_L_PD, BIT(1)), 1971 PINCTRL_CONF_DESC(15, REG_GPIO_L_PD, BIT(2)), 1972 PINCTRL_CONF_DESC(16, REG_GPIO_L_PD, BIT(3)), 1973 PINCTRL_CONF_DESC(17, REG_GPIO_L_PD, BIT(4)), 1974 PINCTRL_CONF_DESC(18, REG_GPIO_L_PD, BIT(5)), 1975 PINCTRL_CONF_DESC(19, REG_GPIO_L_PD, BIT(6)), 1976 PINCTRL_CONF_DESC(20, REG_GPIO_L_PD, BIT(7)), 1977 PINCTRL_CONF_DESC(21, REG_GPIO_L_PD, BIT(8)), 1978 PINCTRL_CONF_DESC(22, REG_GPIO_L_PD, BIT(9)), 1979 PINCTRL_CONF_DESC(23, REG_GPIO_L_PD, BIT(10)), 1980 PINCTRL_CONF_DESC(24, REG_GPIO_L_PD, BIT(11)), 1981 PINCTRL_CONF_DESC(25, REG_GPIO_L_PD, BIT(12)), 1982 PINCTRL_CONF_DESC(26, REG_GPIO_L_PD, BIT(13)), 1983 PINCTRL_CONF_DESC(27, REG_GPIO_L_PD, BIT(14)), 1984 PINCTRL_CONF_DESC(28, REG_GPIO_L_PD, BIT(15)), 1985 PINCTRL_CONF_DESC(29, REG_GPIO_L_PD, BIT(16)), 1986 PINCTRL_CONF_DESC(30, REG_GPIO_L_PD, BIT(17)), 1987 PINCTRL_CONF_DESC(31, REG_GPIO_L_PD, BIT(18)), 1988 PINCTRL_CONF_DESC(32, REG_GPIO_L_PD, BIT(19)), 1989 PINCTRL_CONF_DESC(33, REG_GPIO_L_PD, BIT(20)), 1990 PINCTRL_CONF_DESC(34, REG_GPIO_L_PD, BIT(21)), 1991 PINCTRL_CONF_DESC(35, REG_GPIO_L_PD, BIT(22)), 1992 PINCTRL_CONF_DESC(36, REG_GPIO_L_PD, BIT(23)), 1993 PINCTRL_CONF_DESC(37, REG_GPIO_L_PD, BIT(24)), 1994 PINCTRL_CONF_DESC(38, REG_GPIO_L_PD, BIT(25)), 1995 PINCTRL_CONF_DESC(39, REG_GPIO_L_PD, BIT(26)), 1996 PINCTRL_CONF_DESC(40, REG_GPIO_L_PD, BIT(27)), 1997 PINCTRL_CONF_DESC(41, REG_GPIO_L_PD, BIT(28)), 1998 PINCTRL_CONF_DESC(42, REG_GPIO_L_PD, BIT(29)), 1999 PINCTRL_CONF_DESC(43, REG_GPIO_L_PD, BIT(30)), 2000 PINCTRL_CONF_DESC(44, REG_GPIO_L_PD, BIT(31)), 2001 PINCTRL_CONF_DESC(45, REG_GPIO_H_PD, BIT(0)), 2002 PINCTRL_CONF_DESC(46, REG_GPIO_H_PD, BIT(1)), 2003 PINCTRL_CONF_DESC(47, REG_GPIO_H_PD, BIT(2)), 2004 PINCTRL_CONF_DESC(48, REG_GPIO_H_PD, BIT(3)), 2005 PINCTRL_CONF_DESC(49, REG_GPIO_H_PD, BIT(4)), 2006 PINCTRL_CONF_DESC(50, REG_GPIO_H_PD, BIT(5)), 2007 PINCTRL_CONF_DESC(51, REG_GPIO_H_PD, BIT(6)), 2008 PINCTRL_CONF_DESC(52, REG_GPIO_H_PD, BIT(7)), 2009 PINCTRL_CONF_DESC(53, REG_GPIO_H_PD, BIT(8)), 2010 PINCTRL_CONF_DESC(54, REG_GPIO_H_PD, BIT(9)), 2011 PINCTRL_CONF_DESC(55, REG_GPIO_H_PD, BIT(10)), 2012 PINCTRL_CONF_DESC(56, REG_GPIO_H_PD, BIT(11)), 2013 PINCTRL_CONF_DESC(57, REG_GPIO_H_PD, BIT(12)), 2014 PINCTRL_CONF_DESC(58, REG_GPIO_H_PD, BIT(13)), 2015 PINCTRL_CONF_DESC(59, REG_GPIO_H_PD, BIT(14)), 2016 PINCTRL_CONF_DESC(61, REG_I2C_SDA_PD, PCIE0_RESET_PD_MASK), 2017 PINCTRL_CONF_DESC(62, REG_I2C_SDA_PD, PCIE1_RESET_PD_MASK), 2018 PINCTRL_CONF_DESC(63, REG_I2C_SDA_PD, PCIE2_RESET_PD_MASK), 2019 }; 2020 2021 static const struct airoha_pinctrl_conf an7583_pinctrl_pulldown_conf[] = { 2022 PINCTRL_CONF_DESC(2, REG_GPIO_L_PD, BIT(0)), 2023 PINCTRL_CONF_DESC(3, REG_GPIO_L_PD, BIT(1)), 2024 PINCTRL_CONF_DESC(4, REG_GPIO_L_PD, BIT(2)), 2025 PINCTRL_CONF_DESC(5, REG_GPIO_L_PD, BIT(3)), 2026 PINCTRL_CONF_DESC(6, REG_GPIO_L_PD, BIT(4)), 2027 PINCTRL_CONF_DESC(7, REG_GPIO_L_PD, BIT(5)), 2028 PINCTRL_CONF_DESC(8, REG_GPIO_L_PD, BIT(6)), 2029 PINCTRL_CONF_DESC(9, REG_GPIO_L_PD, BIT(7)), 2030 PINCTRL_CONF_DESC(10, REG_GPIO_L_PD, BIT(8)), 2031 PINCTRL_CONF_DESC(11, REG_GPIO_L_PD, BIT(9)), 2032 PINCTRL_CONF_DESC(12, REG_GPIO_L_PD, BIT(10)), 2033 PINCTRL_CONF_DESC(13, REG_GPIO_L_PD, BIT(11)), 2034 PINCTRL_CONF_DESC(14, REG_GPIO_L_PD, BIT(12)), 2035 PINCTRL_CONF_DESC(15, REG_GPIO_L_PD, BIT(13)), 2036 PINCTRL_CONF_DESC(16, REG_GPIO_L_PD, BIT(14)), 2037 PINCTRL_CONF_DESC(17, REG_GPIO_L_PD, BIT(15)), 2038 PINCTRL_CONF_DESC(18, REG_GPIO_L_PD, BIT(16)), 2039 PINCTRL_CONF_DESC(19, REG_GPIO_L_PD, BIT(17)), 2040 PINCTRL_CONF_DESC(20, REG_GPIO_L_PD, BIT(18)), 2041 PINCTRL_CONF_DESC(21, REG_GPIO_L_PD, BIT(19)), 2042 PINCTRL_CONF_DESC(22, REG_GPIO_L_PD, BIT(20)), 2043 PINCTRL_CONF_DESC(23, REG_GPIO_L_PD, BIT(21)), 2044 PINCTRL_CONF_DESC(24, REG_GPIO_L_PD, BIT(22)), 2045 PINCTRL_CONF_DESC(25, REG_GPIO_L_PD, BIT(23)), 2046 PINCTRL_CONF_DESC(26, REG_GPIO_L_PD, BIT(24)), 2047 PINCTRL_CONF_DESC(27, REG_GPIO_L_PD, BIT(25)), 2048 PINCTRL_CONF_DESC(28, REG_GPIO_L_PD, BIT(26)), 2049 PINCTRL_CONF_DESC(29, REG_GPIO_L_PD, BIT(27)), 2050 PINCTRL_CONF_DESC(30, REG_GPIO_L_PD, BIT(28)), 2051 PINCTRL_CONF_DESC(31, REG_GPIO_L_PD, BIT(29)), 2052 PINCTRL_CONF_DESC(32, REG_GPIO_L_PD, BIT(30)), 2053 PINCTRL_CONF_DESC(33, REG_GPIO_L_PD, BIT(31)), 2054 PINCTRL_CONF_DESC(34, REG_GPIO_H_PD, BIT(0)), 2055 PINCTRL_CONF_DESC(35, REG_GPIO_H_PD, BIT(1)), 2056 PINCTRL_CONF_DESC(36, REG_GPIO_H_PD, BIT(2)), 2057 PINCTRL_CONF_DESC(37, REG_GPIO_H_PD, BIT(3)), 2058 PINCTRL_CONF_DESC(38, REG_GPIO_H_PD, BIT(4)), 2059 PINCTRL_CONF_DESC(39, REG_GPIO_H_PD, BIT(5)), 2060 PINCTRL_CONF_DESC(40, REG_GPIO_H_PD, BIT(6)), 2061 PINCTRL_CONF_DESC(41, REG_I2C_SDA_PD, I2C_SCL_PD_MASK), 2062 PINCTRL_CONF_DESC(42, REG_I2C_SDA_PD, I2C_SDA_PD_MASK), 2063 PINCTRL_CONF_DESC(43, REG_I2C_SDA_PD, AN7583_I2C1_SCL_PD_MASK), 2064 PINCTRL_CONF_DESC(44, REG_I2C_SDA_PD, AN7583_I2C1_SDA_PD_MASK), 2065 PINCTRL_CONF_DESC(45, REG_I2C_SDA_PD, SPI_CLK_PD_MASK), 2066 PINCTRL_CONF_DESC(46, REG_I2C_SDA_PD, SPI_CS0_PD_MASK), 2067 PINCTRL_CONF_DESC(47, REG_I2C_SDA_PD, SPI_MOSI_PD_MASK), 2068 PINCTRL_CONF_DESC(48, REG_I2C_SDA_PD, SPI_MISO_PD_MASK), 2069 PINCTRL_CONF_DESC(49, REG_I2C_SDA_PD, UART1_TXD_PD_MASK), 2070 PINCTRL_CONF_DESC(50, REG_I2C_SDA_PD, UART1_RXD_PD_MASK), 2071 PINCTRL_CONF_DESC(51, REG_I2C_SDA_PD, PCIE0_RESET_PD_MASK), 2072 PINCTRL_CONF_DESC(52, REG_I2C_SDA_PD, PCIE1_RESET_PD_MASK), 2073 PINCTRL_CONF_DESC(53, REG_I2C_SDA_PD, AN7583_MDC_0_PD_MASK), 2074 PINCTRL_CONF_DESC(54, REG_I2C_SDA_PD, AN7583_MDIO_0_PD_MASK), 2075 }; 2076 2077 static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e2_conf[] = { 2078 PINCTRL_CONF_DESC(0, REG_I2C_SDA_E2, UART1_TXD_E2_MASK), 2079 PINCTRL_CONF_DESC(1, REG_I2C_SDA_E2, UART1_RXD_E2_MASK), 2080 PINCTRL_CONF_DESC(2, REG_I2C_SDA_E2, I2C_SDA_E2_MASK), 2081 PINCTRL_CONF_DESC(3, REG_I2C_SDA_E2, I2C_SCL_E2_MASK), 2082 PINCTRL_CONF_DESC(4, REG_I2C_SDA_E2, SPI_CS0_E2_MASK), 2083 PINCTRL_CONF_DESC(5, REG_I2C_SDA_E2, SPI_CLK_E2_MASK), 2084 PINCTRL_CONF_DESC(6, REG_I2C_SDA_E2, SPI_MOSI_E2_MASK), 2085 PINCTRL_CONF_DESC(7, REG_I2C_SDA_E2, SPI_MISO_E2_MASK), 2086 PINCTRL_CONF_DESC(13, REG_GPIO_L_E2, BIT(0)), 2087 PINCTRL_CONF_DESC(14, REG_GPIO_L_E2, BIT(1)), 2088 PINCTRL_CONF_DESC(15, REG_GPIO_L_E2, BIT(2)), 2089 PINCTRL_CONF_DESC(16, REG_GPIO_L_E2, BIT(3)), 2090 PINCTRL_CONF_DESC(17, REG_GPIO_L_E2, BIT(4)), 2091 PINCTRL_CONF_DESC(18, REG_GPIO_L_E2, BIT(5)), 2092 PINCTRL_CONF_DESC(19, REG_GPIO_L_E2, BIT(6)), 2093 PINCTRL_CONF_DESC(20, REG_GPIO_L_E2, BIT(7)), 2094 PINCTRL_CONF_DESC(21, REG_GPIO_L_E2, BIT(8)), 2095 PINCTRL_CONF_DESC(22, REG_GPIO_L_E2, BIT(9)), 2096 PINCTRL_CONF_DESC(23, REG_GPIO_L_E2, BIT(10)), 2097 PINCTRL_CONF_DESC(24, REG_GPIO_L_E2, BIT(11)), 2098 PINCTRL_CONF_DESC(25, REG_GPIO_L_E2, BIT(12)), 2099 PINCTRL_CONF_DESC(26, REG_GPIO_L_E2, BIT(13)), 2100 PINCTRL_CONF_DESC(27, REG_GPIO_L_E2, BIT(14)), 2101 PINCTRL_CONF_DESC(28, REG_GPIO_L_E2, BIT(15)), 2102 PINCTRL_CONF_DESC(29, REG_GPIO_L_E2, BIT(16)), 2103 PINCTRL_CONF_DESC(30, REG_GPIO_L_E2, BIT(17)), 2104 PINCTRL_CONF_DESC(31, REG_GPIO_L_E2, BIT(18)), 2105 PINCTRL_CONF_DESC(32, REG_GPIO_L_E2, BIT(19)), 2106 PINCTRL_CONF_DESC(33, REG_GPIO_L_E2, BIT(20)), 2107 PINCTRL_CONF_DESC(34, REG_GPIO_L_E2, BIT(21)), 2108 PINCTRL_CONF_DESC(35, REG_GPIO_L_E2, BIT(22)), 2109 PINCTRL_CONF_DESC(36, REG_GPIO_L_E2, BIT(23)), 2110 PINCTRL_CONF_DESC(37, REG_GPIO_L_E2, BIT(24)), 2111 PINCTRL_CONF_DESC(38, REG_GPIO_L_E2, BIT(25)), 2112 PINCTRL_CONF_DESC(39, REG_GPIO_L_E2, BIT(26)), 2113 PINCTRL_CONF_DESC(40, REG_GPIO_L_E2, BIT(27)), 2114 PINCTRL_CONF_DESC(41, REG_GPIO_L_E2, BIT(28)), 2115 PINCTRL_CONF_DESC(42, REG_GPIO_L_E2, BIT(29)), 2116 PINCTRL_CONF_DESC(43, REG_GPIO_L_E2, BIT(30)), 2117 PINCTRL_CONF_DESC(44, REG_GPIO_L_E2, BIT(31)), 2118 PINCTRL_CONF_DESC(45, REG_GPIO_H_E2, BIT(0)), 2119 PINCTRL_CONF_DESC(46, REG_GPIO_H_E2, BIT(1)), 2120 PINCTRL_CONF_DESC(47, REG_GPIO_H_E2, BIT(2)), 2121 PINCTRL_CONF_DESC(48, REG_GPIO_H_E2, BIT(3)), 2122 PINCTRL_CONF_DESC(49, REG_GPIO_H_E2, BIT(4)), 2123 PINCTRL_CONF_DESC(50, REG_GPIO_H_E2, BIT(5)), 2124 PINCTRL_CONF_DESC(51, REG_GPIO_H_E2, BIT(6)), 2125 PINCTRL_CONF_DESC(52, REG_GPIO_H_E2, BIT(7)), 2126 PINCTRL_CONF_DESC(53, REG_GPIO_H_E2, BIT(8)), 2127 PINCTRL_CONF_DESC(54, REG_GPIO_H_E2, BIT(9)), 2128 PINCTRL_CONF_DESC(55, REG_GPIO_H_E2, BIT(10)), 2129 PINCTRL_CONF_DESC(56, REG_GPIO_H_E2, BIT(11)), 2130 PINCTRL_CONF_DESC(57, REG_GPIO_H_E2, BIT(12)), 2131 PINCTRL_CONF_DESC(58, REG_GPIO_H_E2, BIT(13)), 2132 PINCTRL_CONF_DESC(59, REG_GPIO_H_E2, BIT(14)), 2133 PINCTRL_CONF_DESC(61, REG_I2C_SDA_E2, PCIE0_RESET_E2_MASK), 2134 PINCTRL_CONF_DESC(62, REG_I2C_SDA_E2, PCIE1_RESET_E2_MASK), 2135 PINCTRL_CONF_DESC(63, REG_I2C_SDA_E2, PCIE2_RESET_E2_MASK), 2136 }; 2137 2138 static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e2_conf[] = { 2139 PINCTRL_CONF_DESC(2, REG_GPIO_L_E2, BIT(0)), 2140 PINCTRL_CONF_DESC(3, REG_GPIO_L_E2, BIT(1)), 2141 PINCTRL_CONF_DESC(4, REG_GPIO_L_E2, BIT(2)), 2142 PINCTRL_CONF_DESC(5, REG_GPIO_L_E2, BIT(3)), 2143 PINCTRL_CONF_DESC(6, REG_GPIO_L_E2, BIT(4)), 2144 PINCTRL_CONF_DESC(7, REG_GPIO_L_E2, BIT(5)), 2145 PINCTRL_CONF_DESC(8, REG_GPIO_L_E2, BIT(6)), 2146 PINCTRL_CONF_DESC(9, REG_GPIO_L_E2, BIT(7)), 2147 PINCTRL_CONF_DESC(10, REG_GPIO_L_E2, BIT(8)), 2148 PINCTRL_CONF_DESC(11, REG_GPIO_L_E2, BIT(9)), 2149 PINCTRL_CONF_DESC(12, REG_GPIO_L_E2, BIT(10)), 2150 PINCTRL_CONF_DESC(13, REG_GPIO_L_E2, BIT(11)), 2151 PINCTRL_CONF_DESC(14, REG_GPIO_L_E2, BIT(12)), 2152 PINCTRL_CONF_DESC(15, REG_GPIO_L_E2, BIT(13)), 2153 PINCTRL_CONF_DESC(16, REG_GPIO_L_E2, BIT(14)), 2154 PINCTRL_CONF_DESC(17, REG_GPIO_L_E2, BIT(15)), 2155 PINCTRL_CONF_DESC(18, REG_GPIO_L_E2, BIT(16)), 2156 PINCTRL_CONF_DESC(19, REG_GPIO_L_E2, BIT(17)), 2157 PINCTRL_CONF_DESC(20, REG_GPIO_L_E2, BIT(18)), 2158 PINCTRL_CONF_DESC(21, REG_GPIO_L_E2, BIT(19)), 2159 PINCTRL_CONF_DESC(22, REG_GPIO_L_E2, BIT(20)), 2160 PINCTRL_CONF_DESC(23, REG_GPIO_L_E2, BIT(21)), 2161 PINCTRL_CONF_DESC(24, REG_GPIO_L_E2, BIT(22)), 2162 PINCTRL_CONF_DESC(25, REG_GPIO_L_E2, BIT(23)), 2163 PINCTRL_CONF_DESC(26, REG_GPIO_L_E2, BIT(24)), 2164 PINCTRL_CONF_DESC(27, REG_GPIO_L_E2, BIT(25)), 2165 PINCTRL_CONF_DESC(28, REG_GPIO_L_E2, BIT(26)), 2166 PINCTRL_CONF_DESC(29, REG_GPIO_L_E2, BIT(27)), 2167 PINCTRL_CONF_DESC(30, REG_GPIO_L_E2, BIT(28)), 2168 PINCTRL_CONF_DESC(31, REG_GPIO_L_E2, BIT(29)), 2169 PINCTRL_CONF_DESC(32, REG_GPIO_L_E2, BIT(30)), 2170 PINCTRL_CONF_DESC(33, REG_GPIO_L_E2, BIT(31)), 2171 PINCTRL_CONF_DESC(34, REG_GPIO_H_E2, BIT(0)), 2172 PINCTRL_CONF_DESC(35, REG_GPIO_H_E2, BIT(1)), 2173 PINCTRL_CONF_DESC(36, REG_GPIO_H_E2, BIT(2)), 2174 PINCTRL_CONF_DESC(37, REG_GPIO_H_E2, BIT(3)), 2175 PINCTRL_CONF_DESC(38, REG_GPIO_H_E2, BIT(4)), 2176 PINCTRL_CONF_DESC(39, REG_GPIO_H_E2, BIT(5)), 2177 PINCTRL_CONF_DESC(40, REG_GPIO_H_E2, BIT(6)), 2178 PINCTRL_CONF_DESC(41, REG_I2C_SDA_E2, I2C_SCL_E2_MASK), 2179 PINCTRL_CONF_DESC(42, REG_I2C_SDA_E2, I2C_SDA_E2_MASK), 2180 PINCTRL_CONF_DESC(43, REG_I2C_SDA_E2, AN7583_I2C1_SCL_E2_MASK), 2181 PINCTRL_CONF_DESC(44, REG_I2C_SDA_E2, AN7583_I2C1_SDA_E2_MASK), 2182 PINCTRL_CONF_DESC(45, REG_I2C_SDA_E2, SPI_CLK_E2_MASK), 2183 PINCTRL_CONF_DESC(46, REG_I2C_SDA_E2, SPI_CS0_E2_MASK), 2184 PINCTRL_CONF_DESC(47, REG_I2C_SDA_E2, SPI_MOSI_E2_MASK), 2185 PINCTRL_CONF_DESC(48, REG_I2C_SDA_E2, SPI_MISO_E2_MASK), 2186 PINCTRL_CONF_DESC(49, REG_I2C_SDA_E2, UART1_TXD_E2_MASK), 2187 PINCTRL_CONF_DESC(50, REG_I2C_SDA_E2, UART1_RXD_E2_MASK), 2188 PINCTRL_CONF_DESC(51, REG_I2C_SDA_E2, PCIE0_RESET_E2_MASK), 2189 PINCTRL_CONF_DESC(52, REG_I2C_SDA_E2, PCIE1_RESET_E2_MASK), 2190 PINCTRL_CONF_DESC(53, REG_I2C_SDA_E2, AN7583_MDC_0_E2_MASK), 2191 PINCTRL_CONF_DESC(54, REG_I2C_SDA_E2, AN7583_MDIO_0_E2_MASK), 2192 }; 2193 2194 static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e4_conf[] = { 2195 PINCTRL_CONF_DESC(0, REG_I2C_SDA_E4, UART1_TXD_E4_MASK), 2196 PINCTRL_CONF_DESC(1, REG_I2C_SDA_E4, UART1_RXD_E4_MASK), 2197 PINCTRL_CONF_DESC(2, REG_I2C_SDA_E4, I2C_SDA_E4_MASK), 2198 PINCTRL_CONF_DESC(3, REG_I2C_SDA_E4, I2C_SCL_E4_MASK), 2199 PINCTRL_CONF_DESC(4, REG_I2C_SDA_E4, SPI_CS0_E4_MASK), 2200 PINCTRL_CONF_DESC(5, REG_I2C_SDA_E4, SPI_CLK_E4_MASK), 2201 PINCTRL_CONF_DESC(6, REG_I2C_SDA_E4, SPI_MOSI_E4_MASK), 2202 PINCTRL_CONF_DESC(7, REG_I2C_SDA_E4, SPI_MISO_E4_MASK), 2203 PINCTRL_CONF_DESC(13, REG_GPIO_L_E4, BIT(0)), 2204 PINCTRL_CONF_DESC(14, REG_GPIO_L_E4, BIT(1)), 2205 PINCTRL_CONF_DESC(15, REG_GPIO_L_E4, BIT(2)), 2206 PINCTRL_CONF_DESC(16, REG_GPIO_L_E4, BIT(3)), 2207 PINCTRL_CONF_DESC(17, REG_GPIO_L_E4, BIT(4)), 2208 PINCTRL_CONF_DESC(18, REG_GPIO_L_E4, BIT(5)), 2209 PINCTRL_CONF_DESC(19, REG_GPIO_L_E4, BIT(6)), 2210 PINCTRL_CONF_DESC(20, REG_GPIO_L_E4, BIT(7)), 2211 PINCTRL_CONF_DESC(21, REG_GPIO_L_E4, BIT(8)), 2212 PINCTRL_CONF_DESC(22, REG_GPIO_L_E4, BIT(9)), 2213 PINCTRL_CONF_DESC(23, REG_GPIO_L_E4, BIT(10)), 2214 PINCTRL_CONF_DESC(24, REG_GPIO_L_E4, BIT(11)), 2215 PINCTRL_CONF_DESC(25, REG_GPIO_L_E4, BIT(12)), 2216 PINCTRL_CONF_DESC(26, REG_GPIO_L_E4, BIT(13)), 2217 PINCTRL_CONF_DESC(27, REG_GPIO_L_E4, BIT(14)), 2218 PINCTRL_CONF_DESC(28, REG_GPIO_L_E4, BIT(15)), 2219 PINCTRL_CONF_DESC(29, REG_GPIO_L_E4, BIT(16)), 2220 PINCTRL_CONF_DESC(30, REG_GPIO_L_E4, BIT(17)), 2221 PINCTRL_CONF_DESC(31, REG_GPIO_L_E4, BIT(18)), 2222 PINCTRL_CONF_DESC(32, REG_GPIO_L_E4, BIT(19)), 2223 PINCTRL_CONF_DESC(33, REG_GPIO_L_E4, BIT(20)), 2224 PINCTRL_CONF_DESC(34, REG_GPIO_L_E4, BIT(21)), 2225 PINCTRL_CONF_DESC(35, REG_GPIO_L_E4, BIT(22)), 2226 PINCTRL_CONF_DESC(36, REG_GPIO_L_E4, BIT(23)), 2227 PINCTRL_CONF_DESC(37, REG_GPIO_L_E4, BIT(24)), 2228 PINCTRL_CONF_DESC(38, REG_GPIO_L_E4, BIT(25)), 2229 PINCTRL_CONF_DESC(39, REG_GPIO_L_E4, BIT(26)), 2230 PINCTRL_CONF_DESC(40, REG_GPIO_L_E4, BIT(27)), 2231 PINCTRL_CONF_DESC(41, REG_GPIO_L_E4, BIT(28)), 2232 PINCTRL_CONF_DESC(42, REG_GPIO_L_E4, BIT(29)), 2233 PINCTRL_CONF_DESC(43, REG_GPIO_L_E4, BIT(30)), 2234 PINCTRL_CONF_DESC(44, REG_GPIO_L_E4, BIT(31)), 2235 PINCTRL_CONF_DESC(45, REG_GPIO_H_E4, BIT(0)), 2236 PINCTRL_CONF_DESC(46, REG_GPIO_H_E4, BIT(1)), 2237 PINCTRL_CONF_DESC(47, REG_GPIO_H_E4, BIT(2)), 2238 PINCTRL_CONF_DESC(48, REG_GPIO_H_E4, BIT(3)), 2239 PINCTRL_CONF_DESC(49, REG_GPIO_H_E4, BIT(4)), 2240 PINCTRL_CONF_DESC(50, REG_GPIO_H_E4, BIT(5)), 2241 PINCTRL_CONF_DESC(51, REG_GPIO_H_E4, BIT(6)), 2242 PINCTRL_CONF_DESC(52, REG_GPIO_H_E4, BIT(7)), 2243 PINCTRL_CONF_DESC(53, REG_GPIO_H_E4, BIT(8)), 2244 PINCTRL_CONF_DESC(54, REG_GPIO_H_E4, BIT(9)), 2245 PINCTRL_CONF_DESC(55, REG_GPIO_H_E4, BIT(10)), 2246 PINCTRL_CONF_DESC(56, REG_GPIO_H_E4, BIT(11)), 2247 PINCTRL_CONF_DESC(57, REG_GPIO_H_E4, BIT(12)), 2248 PINCTRL_CONF_DESC(58, REG_GPIO_H_E4, BIT(13)), 2249 PINCTRL_CONF_DESC(59, REG_GPIO_H_E4, BIT(14)), 2250 PINCTRL_CONF_DESC(61, REG_I2C_SDA_E4, PCIE0_RESET_E4_MASK), 2251 PINCTRL_CONF_DESC(62, REG_I2C_SDA_E4, PCIE1_RESET_E4_MASK), 2252 PINCTRL_CONF_DESC(63, REG_I2C_SDA_E4, PCIE2_RESET_E4_MASK), 2253 }; 2254 2255 static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e4_conf[] = { 2256 PINCTRL_CONF_DESC(2, REG_GPIO_L_E4, BIT(0)), 2257 PINCTRL_CONF_DESC(3, REG_GPIO_L_E4, BIT(1)), 2258 PINCTRL_CONF_DESC(4, REG_GPIO_L_E4, BIT(2)), 2259 PINCTRL_CONF_DESC(5, REG_GPIO_L_E4, BIT(3)), 2260 PINCTRL_CONF_DESC(6, REG_GPIO_L_E4, BIT(4)), 2261 PINCTRL_CONF_DESC(7, REG_GPIO_L_E4, BIT(5)), 2262 PINCTRL_CONF_DESC(8, REG_GPIO_L_E4, BIT(6)), 2263 PINCTRL_CONF_DESC(9, REG_GPIO_L_E4, BIT(7)), 2264 PINCTRL_CONF_DESC(10, REG_GPIO_L_E4, BIT(8)), 2265 PINCTRL_CONF_DESC(11, REG_GPIO_L_E4, BIT(9)), 2266 PINCTRL_CONF_DESC(12, REG_GPIO_L_E4, BIT(10)), 2267 PINCTRL_CONF_DESC(13, REG_GPIO_L_E4, BIT(11)), 2268 PINCTRL_CONF_DESC(14, REG_GPIO_L_E4, BIT(12)), 2269 PINCTRL_CONF_DESC(15, REG_GPIO_L_E4, BIT(13)), 2270 PINCTRL_CONF_DESC(16, REG_GPIO_L_E4, BIT(14)), 2271 PINCTRL_CONF_DESC(17, REG_GPIO_L_E4, BIT(15)), 2272 PINCTRL_CONF_DESC(18, REG_GPIO_L_E4, BIT(16)), 2273 PINCTRL_CONF_DESC(19, REG_GPIO_L_E4, BIT(17)), 2274 PINCTRL_CONF_DESC(20, REG_GPIO_L_E4, BIT(18)), 2275 PINCTRL_CONF_DESC(21, REG_GPIO_L_E4, BIT(19)), 2276 PINCTRL_CONF_DESC(22, REG_GPIO_L_E4, BIT(20)), 2277 PINCTRL_CONF_DESC(23, REG_GPIO_L_E4, BIT(21)), 2278 PINCTRL_CONF_DESC(24, REG_GPIO_L_E4, BIT(22)), 2279 PINCTRL_CONF_DESC(25, REG_GPIO_L_E4, BIT(23)), 2280 PINCTRL_CONF_DESC(26, REG_GPIO_L_E4, BIT(24)), 2281 PINCTRL_CONF_DESC(27, REG_GPIO_L_E4, BIT(25)), 2282 PINCTRL_CONF_DESC(28, REG_GPIO_L_E4, BIT(26)), 2283 PINCTRL_CONF_DESC(29, REG_GPIO_L_E4, BIT(27)), 2284 PINCTRL_CONF_DESC(30, REG_GPIO_L_E4, BIT(28)), 2285 PINCTRL_CONF_DESC(31, REG_GPIO_L_E4, BIT(29)), 2286 PINCTRL_CONF_DESC(32, REG_GPIO_L_E4, BIT(30)), 2287 PINCTRL_CONF_DESC(33, REG_GPIO_L_E4, BIT(31)), 2288 PINCTRL_CONF_DESC(34, REG_GPIO_H_E4, BIT(0)), 2289 PINCTRL_CONF_DESC(35, REG_GPIO_H_E4, BIT(1)), 2290 PINCTRL_CONF_DESC(36, REG_GPIO_H_E4, BIT(2)), 2291 PINCTRL_CONF_DESC(37, REG_GPIO_H_E4, BIT(3)), 2292 PINCTRL_CONF_DESC(38, REG_GPIO_H_E4, BIT(4)), 2293 PINCTRL_CONF_DESC(39, REG_GPIO_H_E4, BIT(5)), 2294 PINCTRL_CONF_DESC(40, REG_GPIO_H_E4, BIT(6)), 2295 PINCTRL_CONF_DESC(41, REG_I2C_SDA_E4, I2C_SCL_E4_MASK), 2296 PINCTRL_CONF_DESC(42, REG_I2C_SDA_E4, I2C_SDA_E4_MASK), 2297 PINCTRL_CONF_DESC(43, REG_I2C_SDA_E4, AN7583_I2C1_SCL_E4_MASK), 2298 PINCTRL_CONF_DESC(44, REG_I2C_SDA_E4, AN7583_I2C1_SDA_E4_MASK), 2299 PINCTRL_CONF_DESC(45, REG_I2C_SDA_E4, SPI_CLK_E4_MASK), 2300 PINCTRL_CONF_DESC(46, REG_I2C_SDA_E4, SPI_CS0_E4_MASK), 2301 PINCTRL_CONF_DESC(47, REG_I2C_SDA_E4, SPI_MOSI_E4_MASK), 2302 PINCTRL_CONF_DESC(48, REG_I2C_SDA_E4, SPI_MISO_E4_MASK), 2303 PINCTRL_CONF_DESC(49, REG_I2C_SDA_E4, UART1_TXD_E4_MASK), 2304 PINCTRL_CONF_DESC(50, REG_I2C_SDA_E4, UART1_RXD_E4_MASK), 2305 PINCTRL_CONF_DESC(51, REG_I2C_SDA_E4, PCIE0_RESET_E4_MASK), 2306 PINCTRL_CONF_DESC(52, REG_I2C_SDA_E4, PCIE1_RESET_E4_MASK), 2307 PINCTRL_CONF_DESC(53, REG_I2C_SDA_E4, AN7583_MDC_0_E4_MASK), 2308 PINCTRL_CONF_DESC(54, REG_I2C_SDA_E4, AN7583_MDIO_0_E4_MASK), 2309 }; 2310 2311 static const struct airoha_pinctrl_conf en7581_pinctrl_pcie_rst_od_conf[] = { 2312 PINCTRL_CONF_DESC(61, REG_PCIE_RESET_OD, PCIE0_RESET_OD_MASK), 2313 PINCTRL_CONF_DESC(62, REG_PCIE_RESET_OD, PCIE1_RESET_OD_MASK), 2314 PINCTRL_CONF_DESC(63, REG_PCIE_RESET_OD, PCIE2_RESET_OD_MASK), 2315 }; 2316 2317 static const struct airoha_pinctrl_conf an7583_pinctrl_pcie_rst_od_conf[] = { 2318 PINCTRL_CONF_DESC(51, REG_PCIE_RESET_OD, PCIE0_RESET_OD_MASK), 2319 PINCTRL_CONF_DESC(52, REG_PCIE_RESET_OD, PCIE1_RESET_OD_MASK), 2320 }; 2321 2322 static int airoha_convert_pin_to_reg_offset(struct pinctrl_dev *pctrl_dev, 2323 struct pinctrl_gpio_range *range, 2324 int pin) 2325 { 2326 if (!range) 2327 range = pinctrl_find_gpio_range_from_pin_nolock(pctrl_dev, 2328 pin); 2329 if (!range) 2330 return -EINVAL; 2331 2332 return pin - range->pin_base; 2333 } 2334 2335 /* gpio callbacks */ 2336 static int airoha_gpio_set(struct gpio_chip *chip, unsigned int gpio, 2337 int value) 2338 { 2339 struct airoha_pinctrl *pinctrl = gpiochip_get_data(chip); 2340 u32 offset = gpio % AIROHA_PIN_BANK_SIZE; 2341 u8 index = gpio / AIROHA_PIN_BANK_SIZE; 2342 2343 return regmap_update_bits(pinctrl->regmap, 2344 pinctrl->gpiochip.data[index], 2345 BIT(offset), value ? BIT(offset) : 0); 2346 } 2347 2348 static int airoha_gpio_get(struct gpio_chip *chip, unsigned int gpio) 2349 { 2350 struct airoha_pinctrl *pinctrl = gpiochip_get_data(chip); 2351 u32 val, pin = gpio % AIROHA_PIN_BANK_SIZE; 2352 u8 index = gpio / AIROHA_PIN_BANK_SIZE; 2353 int err; 2354 2355 err = regmap_read(pinctrl->regmap, 2356 pinctrl->gpiochip.data[index], &val); 2357 2358 return err ? err : !!(val & BIT(pin)); 2359 } 2360 2361 static int airoha_gpio_direction_output(struct gpio_chip *chip, 2362 unsigned int gpio, int value) 2363 { 2364 int err; 2365 2366 err = pinctrl_gpio_direction_output(chip, gpio); 2367 if (err) 2368 return err; 2369 2370 return airoha_gpio_set(chip, gpio, value); 2371 } 2372 2373 /* irq callbacks */ 2374 static void airoha_irq_unmask(struct irq_data *data) 2375 { 2376 u8 offset = data->hwirq % AIROHA_REG_GPIOCTRL_NUM_PIN; 2377 u8 index = data->hwirq / AIROHA_REG_GPIOCTRL_NUM_PIN; 2378 u32 mask = GENMASK(2 * offset + 1, 2 * offset); 2379 struct airoha_pinctrl_gpiochip *gpiochip; 2380 struct airoha_pinctrl *pinctrl; 2381 u32 val = BIT(2 * offset); 2382 2383 gpiochip = irq_data_get_irq_chip_data(data); 2384 if (WARN_ON_ONCE(data->hwirq >= ARRAY_SIZE(gpiochip->irq_type))) 2385 return; 2386 2387 pinctrl = container_of(gpiochip, struct airoha_pinctrl, gpiochip); 2388 switch (gpiochip->irq_type[data->hwirq]) { 2389 case IRQ_TYPE_LEVEL_LOW: 2390 val = val << 1; 2391 fallthrough; 2392 case IRQ_TYPE_LEVEL_HIGH: 2393 regmap_update_bits(pinctrl->regmap, gpiochip->level[index], 2394 mask, val); 2395 break; 2396 case IRQ_TYPE_EDGE_FALLING: 2397 val = val << 1; 2398 fallthrough; 2399 case IRQ_TYPE_EDGE_RISING: 2400 regmap_update_bits(pinctrl->regmap, gpiochip->edge[index], 2401 mask, val); 2402 break; 2403 case IRQ_TYPE_EDGE_BOTH: 2404 regmap_set_bits(pinctrl->regmap, gpiochip->edge[index], mask); 2405 break; 2406 default: 2407 break; 2408 } 2409 } 2410 2411 static void airoha_irq_mask(struct irq_data *data) 2412 { 2413 u8 offset = data->hwirq % AIROHA_REG_GPIOCTRL_NUM_PIN; 2414 u8 index = data->hwirq / AIROHA_REG_GPIOCTRL_NUM_PIN; 2415 u32 mask = GENMASK(2 * offset + 1, 2 * offset); 2416 struct airoha_pinctrl_gpiochip *gpiochip; 2417 struct airoha_pinctrl *pinctrl; 2418 2419 gpiochip = irq_data_get_irq_chip_data(data); 2420 pinctrl = container_of(gpiochip, struct airoha_pinctrl, gpiochip); 2421 2422 regmap_clear_bits(pinctrl->regmap, gpiochip->level[index], mask); 2423 regmap_clear_bits(pinctrl->regmap, gpiochip->edge[index], mask); 2424 } 2425 2426 static int airoha_irq_type(struct irq_data *data, unsigned int type) 2427 { 2428 struct airoha_pinctrl_gpiochip *gpiochip; 2429 2430 gpiochip = irq_data_get_irq_chip_data(data); 2431 if (data->hwirq >= ARRAY_SIZE(gpiochip->irq_type)) 2432 return -EINVAL; 2433 2434 if (type == IRQ_TYPE_PROBE) { 2435 if (gpiochip->irq_type[data->hwirq]) 2436 return 0; 2437 2438 type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; 2439 } 2440 gpiochip->irq_type[data->hwirq] = type & IRQ_TYPE_SENSE_MASK; 2441 2442 return 0; 2443 } 2444 2445 static irqreturn_t airoha_irq_handler(int irq, void *data) 2446 { 2447 struct airoha_pinctrl *pinctrl = data; 2448 bool handled = false; 2449 int i; 2450 2451 for (i = 0; i < ARRAY_SIZE(irq_status_regs); i++) { 2452 struct gpio_irq_chip *girq = &pinctrl->gpiochip.chip.irq; 2453 u32 regmap; 2454 unsigned long status; 2455 int irq; 2456 2457 if (regmap_read(pinctrl->regmap, pinctrl->gpiochip.status[i], 2458 ®map)) 2459 continue; 2460 2461 status = regmap; 2462 for_each_set_bit(irq, &status, AIROHA_PIN_BANK_SIZE) { 2463 u32 offset = irq + i * AIROHA_PIN_BANK_SIZE; 2464 2465 generic_handle_irq(irq_find_mapping(girq->domain, 2466 offset)); 2467 regmap_write(pinctrl->regmap, 2468 pinctrl->gpiochip.status[i], BIT(irq)); 2469 } 2470 handled |= !!status; 2471 } 2472 2473 return handled ? IRQ_HANDLED : IRQ_NONE; 2474 } 2475 2476 static const struct irq_chip airoha_gpio_irq_chip = { 2477 .name = "airoha-gpio-irq", 2478 .irq_unmask = airoha_irq_unmask, 2479 .irq_mask = airoha_irq_mask, 2480 .irq_mask_ack = airoha_irq_mask, 2481 .irq_set_type = airoha_irq_type, 2482 .flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_IMMUTABLE, 2483 }; 2484 2485 static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl, 2486 struct platform_device *pdev) 2487 { 2488 struct airoha_pinctrl_gpiochip *chip = &pinctrl->gpiochip; 2489 struct gpio_chip *gc = &chip->chip; 2490 struct gpio_irq_chip *girq = &gc->irq; 2491 struct device *dev = &pdev->dev; 2492 int irq, err; 2493 2494 chip->data = gpio_data_regs; 2495 chip->dir = gpio_dir_regs; 2496 chip->out = gpio_out_regs; 2497 chip->status = irq_status_regs; 2498 chip->level = irq_level_regs; 2499 chip->edge = irq_edge_regs; 2500 2501 gc->parent = dev; 2502 gc->label = dev_name(dev); 2503 gc->request = gpiochip_generic_request; 2504 gc->free = gpiochip_generic_free; 2505 gc->direction_input = pinctrl_gpio_direction_input; 2506 gc->direction_output = airoha_gpio_direction_output; 2507 gc->set = airoha_gpio_set; 2508 gc->get = airoha_gpio_get; 2509 gc->base = -1; 2510 gc->ngpio = AIROHA_NUM_PINS; 2511 2512 girq->default_type = IRQ_TYPE_NONE; 2513 girq->handler = handle_simple_irq; 2514 gpio_irq_chip_set_chip(girq, &airoha_gpio_irq_chip); 2515 2516 irq = platform_get_irq(pdev, 0); 2517 if (irq < 0) 2518 return irq; 2519 2520 err = devm_request_irq(dev, irq, airoha_irq_handler, IRQF_SHARED, 2521 dev_name(dev), pinctrl); 2522 if (err) { 2523 dev_err(dev, "error requesting irq %d: %d\n", irq, err); 2524 return err; 2525 } 2526 2527 return devm_gpiochip_add_data(dev, gc, pinctrl); 2528 } 2529 2530 /* pinmux callbacks */ 2531 static int airoha_pinmux_set_mux(struct pinctrl_dev *pctrl_dev, 2532 unsigned int selector, 2533 unsigned int group) 2534 { 2535 struct airoha_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 2536 const struct airoha_pinctrl_func *func; 2537 const struct function_desc *desc; 2538 struct group_desc *grp; 2539 int i; 2540 2541 desc = pinmux_generic_get_function(pctrl_dev, selector); 2542 if (!desc) 2543 return -EINVAL; 2544 2545 grp = pinctrl_generic_get_group(pctrl_dev, group); 2546 if (!grp) 2547 return -EINVAL; 2548 2549 dev_dbg(pctrl_dev->dev, "enable function %s group %s\n", 2550 desc->func->name, grp->grp.name); 2551 2552 func = desc->data; 2553 for (i = 0; i < func->group_size; i++) { 2554 const struct airoha_pinctrl_func_group *group; 2555 int j; 2556 2557 group = &func->groups[i]; 2558 if (strcmp(group->name, grp->grp.name)) 2559 continue; 2560 2561 for (j = 0; j < group->regmap_size; j++) { 2562 switch (group->regmap[j].mux) { 2563 case AIROHA_FUNC_PWM_EXT_MUX: 2564 case AIROHA_FUNC_PWM_MUX: 2565 regmap_update_bits(pinctrl->regmap, 2566 group->regmap[j].offset, 2567 group->regmap[j].mask, 2568 group->regmap[j].val); 2569 break; 2570 default: 2571 regmap_update_bits(pinctrl->chip_scu, 2572 group->regmap[j].offset, 2573 group->regmap[j].mask, 2574 group->regmap[j].val); 2575 break; 2576 } 2577 } 2578 return 0; 2579 } 2580 2581 return -EINVAL; 2582 } 2583 2584 static int airoha_pinmux_set_direction(struct pinctrl_dev *pctrl_dev, 2585 struct pinctrl_gpio_range *range, 2586 unsigned int p, bool input) 2587 { 2588 struct airoha_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 2589 u32 mask, index; 2590 int err, pin; 2591 2592 pin = airoha_convert_pin_to_reg_offset(pctrl_dev, range, p); 2593 if (pin < 0) 2594 return pin; 2595 2596 /* set output enable */ 2597 mask = BIT(pin % AIROHA_PIN_BANK_SIZE); 2598 index = pin / AIROHA_PIN_BANK_SIZE; 2599 err = regmap_update_bits(pinctrl->regmap, pinctrl->gpiochip.out[index], 2600 mask, !input ? mask : 0); 2601 if (err) 2602 return err; 2603 2604 /* set direction */ 2605 mask = BIT(2 * (pin % AIROHA_REG_GPIOCTRL_NUM_PIN)); 2606 index = pin / AIROHA_REG_GPIOCTRL_NUM_PIN; 2607 return regmap_update_bits(pinctrl->regmap, 2608 pinctrl->gpiochip.dir[index], mask, 2609 !input ? mask : 0); 2610 } 2611 2612 static const struct pinmux_ops airoha_pmxops = { 2613 .get_functions_count = pinmux_generic_get_function_count, 2614 .get_function_name = pinmux_generic_get_function_name, 2615 .get_function_groups = pinmux_generic_get_function_groups, 2616 .gpio_set_direction = airoha_pinmux_set_direction, 2617 .set_mux = airoha_pinmux_set_mux, 2618 .strict = true, 2619 }; 2620 2621 /* pinconf callbacks */ 2622 static const struct airoha_pinctrl_reg * 2623 airoha_pinctrl_get_conf_reg(const struct airoha_pinctrl_conf *conf, 2624 int conf_size, int pin) 2625 { 2626 int i; 2627 2628 for (i = 0; i < conf_size; i++) { 2629 if (conf[i].pin == pin) 2630 return &conf[i].reg; 2631 } 2632 2633 return NULL; 2634 } 2635 2636 static int airoha_pinctrl_get_conf(struct airoha_pinctrl *pinctrl, 2637 enum airoha_pinctrl_confs_type conf_type, 2638 int pin, u32 *val) 2639 { 2640 const struct airoha_pinctrl_confs_info *confs_info; 2641 const struct airoha_pinctrl_reg *reg; 2642 2643 confs_info = &pinctrl->confs_info[conf_type]; 2644 2645 reg = airoha_pinctrl_get_conf_reg(confs_info->confs, 2646 confs_info->num_confs, 2647 pin); 2648 if (!reg) 2649 return -EINVAL; 2650 2651 if (regmap_read(pinctrl->chip_scu, reg->offset, val)) 2652 return -EINVAL; 2653 2654 *val = (*val & reg->mask) >> __ffs(reg->mask); 2655 2656 return 0; 2657 } 2658 2659 static int airoha_pinctrl_set_conf(struct airoha_pinctrl *pinctrl, 2660 enum airoha_pinctrl_confs_type conf_type, 2661 int pin, u32 val) 2662 { 2663 const struct airoha_pinctrl_confs_info *confs_info; 2664 const struct airoha_pinctrl_reg *reg = NULL; 2665 2666 confs_info = &pinctrl->confs_info[conf_type]; 2667 2668 reg = airoha_pinctrl_get_conf_reg(confs_info->confs, 2669 confs_info->num_confs, 2670 pin); 2671 if (!reg) 2672 return -EINVAL; 2673 2674 2675 if (regmap_update_bits(pinctrl->chip_scu, reg->offset, reg->mask, 2676 val << __ffs(reg->mask))) 2677 return -EINVAL; 2678 2679 return 0; 2680 } 2681 2682 #define airoha_pinctrl_get_pullup_conf(pinctrl, pin, val) \ 2683 airoha_pinctrl_get_conf((pinctrl), AIROHA_PINCTRL_CONFS_PULLUP, \ 2684 (pin), (val)) 2685 #define airoha_pinctrl_get_pulldown_conf(pinctrl, pin, val) \ 2686 airoha_pinctrl_get_conf((pinctrl), AIROHA_PINCTRL_CONFS_PULLDOWN, \ 2687 (pin), (val)) 2688 #define airoha_pinctrl_get_drive_e2_conf(pinctrl, pin, val) \ 2689 airoha_pinctrl_get_conf((pinctrl), AIROHA_PINCTRL_CONFS_DRIVE_E2, \ 2690 (pin), (val)) 2691 #define airoha_pinctrl_get_drive_e4_conf(pinctrl, pin, val) \ 2692 airoha_pinctrl_get_conf((pinctrl), AIROHA_PINCTRL_CONFS_DRIVE_E4, \ 2693 (pin), (val)) 2694 #define airoha_pinctrl_get_pcie_rst_od_conf(pinctrl, pin, val) \ 2695 airoha_pinctrl_get_conf((pinctrl), AIROHA_PINCTRL_CONFS_PCIE_RST_OD, \ 2696 (pin), (val)) 2697 #define airoha_pinctrl_set_pullup_conf(pinctrl, pin, val) \ 2698 airoha_pinctrl_set_conf((pinctrl), AIROHA_PINCTRL_CONFS_PULLUP, \ 2699 (pin), (val)) 2700 #define airoha_pinctrl_set_pulldown_conf(pinctrl, pin, val) \ 2701 airoha_pinctrl_set_conf((pinctrl), AIROHA_PINCTRL_CONFS_PULLDOWN, \ 2702 (pin), (val)) 2703 #define airoha_pinctrl_set_drive_e2_conf(pinctrl, pin, val) \ 2704 airoha_pinctrl_set_conf((pinctrl), AIROHA_PINCTRL_CONFS_DRIVE_E2, \ 2705 (pin), (val)) 2706 #define airoha_pinctrl_set_drive_e4_conf(pinctrl, pin, val) \ 2707 airoha_pinctrl_set_conf((pinctrl), AIROHA_PINCTRL_CONFS_DRIVE_E4, \ 2708 (pin), (val)) 2709 #define airoha_pinctrl_set_pcie_rst_od_conf(pinctrl, pin, val) \ 2710 airoha_pinctrl_set_conf((pinctrl), AIROHA_PINCTRL_CONFS_PCIE_RST_OD, \ 2711 (pin), (val)) 2712 2713 static int airoha_pinconf_get_direction(struct pinctrl_dev *pctrl_dev, u32 p) 2714 { 2715 struct airoha_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 2716 u32 val, mask; 2717 int err, pin; 2718 u8 index; 2719 2720 pin = airoha_convert_pin_to_reg_offset(pctrl_dev, NULL, p); 2721 if (pin < 0) 2722 return pin; 2723 2724 index = pin / AIROHA_REG_GPIOCTRL_NUM_PIN; 2725 err = regmap_read(pinctrl->regmap, pinctrl->gpiochip.dir[index], &val); 2726 if (err) 2727 return err; 2728 2729 mask = BIT(2 * (pin % AIROHA_REG_GPIOCTRL_NUM_PIN)); 2730 return val & mask ? PIN_CONFIG_OUTPUT_ENABLE : PIN_CONFIG_INPUT_ENABLE; 2731 } 2732 2733 static int airoha_pinconf_get(struct pinctrl_dev *pctrl_dev, 2734 unsigned int pin, unsigned long *config) 2735 { 2736 struct airoha_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 2737 enum pin_config_param param = pinconf_to_config_param(*config); 2738 u32 arg; 2739 2740 switch (param) { 2741 case PIN_CONFIG_BIAS_PULL_DOWN: 2742 case PIN_CONFIG_BIAS_DISABLE: 2743 case PIN_CONFIG_BIAS_PULL_UP: { 2744 u32 pull_up, pull_down; 2745 2746 if (airoha_pinctrl_get_pullup_conf(pinctrl, pin, &pull_up) || 2747 airoha_pinctrl_get_pulldown_conf(pinctrl, pin, &pull_down)) 2748 return -EINVAL; 2749 2750 if (param == PIN_CONFIG_BIAS_PULL_UP && 2751 !(pull_up && !pull_down)) 2752 return -EINVAL; 2753 else if (param == PIN_CONFIG_BIAS_PULL_DOWN && 2754 !(pull_down && !pull_up)) 2755 return -EINVAL; 2756 else if (pull_up || pull_down) 2757 return -EINVAL; 2758 2759 arg = 1; 2760 break; 2761 } 2762 case PIN_CONFIG_DRIVE_STRENGTH: { 2763 u32 e2, e4; 2764 2765 if (airoha_pinctrl_get_drive_e2_conf(pinctrl, pin, &e2) || 2766 airoha_pinctrl_get_drive_e4_conf(pinctrl, pin, &e4)) 2767 return -EINVAL; 2768 2769 arg = e4 << 1 | e2; 2770 break; 2771 } 2772 case PIN_CONFIG_DRIVE_OPEN_DRAIN: 2773 if (airoha_pinctrl_get_pcie_rst_od_conf(pinctrl, pin, &arg)) 2774 return -EINVAL; 2775 break; 2776 case PIN_CONFIG_OUTPUT_ENABLE: 2777 case PIN_CONFIG_INPUT_ENABLE: 2778 arg = airoha_pinconf_get_direction(pctrl_dev, pin); 2779 if (arg != param) 2780 return -EINVAL; 2781 2782 arg = 1; 2783 break; 2784 default: 2785 return -ENOTSUPP; 2786 } 2787 2788 *config = pinconf_to_config_packed(param, arg); 2789 2790 return 0; 2791 } 2792 2793 static int airoha_pinconf_set_pin_value(struct pinctrl_dev *pctrl_dev, 2794 unsigned int p, bool value) 2795 { 2796 struct airoha_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 2797 int pin; 2798 2799 pin = airoha_convert_pin_to_reg_offset(pctrl_dev, NULL, p); 2800 if (pin < 0) 2801 return pin; 2802 2803 return airoha_gpio_set(&pinctrl->gpiochip.chip, pin, value); 2804 } 2805 2806 static int airoha_pinconf_set(struct pinctrl_dev *pctrl_dev, 2807 unsigned int pin, unsigned long *configs, 2808 unsigned int num_configs) 2809 { 2810 struct airoha_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 2811 int i; 2812 2813 for (i = 0; i < num_configs; i++) { 2814 u32 param = pinconf_to_config_param(configs[i]); 2815 u32 arg = pinconf_to_config_argument(configs[i]); 2816 2817 switch (param) { 2818 case PIN_CONFIG_BIAS_DISABLE: 2819 airoha_pinctrl_set_pulldown_conf(pinctrl, pin, 0); 2820 airoha_pinctrl_set_pullup_conf(pinctrl, pin, 0); 2821 break; 2822 case PIN_CONFIG_BIAS_PULL_UP: 2823 airoha_pinctrl_set_pulldown_conf(pinctrl, pin, 0); 2824 airoha_pinctrl_set_pullup_conf(pinctrl, pin, 1); 2825 break; 2826 case PIN_CONFIG_BIAS_PULL_DOWN: 2827 airoha_pinctrl_set_pulldown_conf(pinctrl, pin, 1); 2828 airoha_pinctrl_set_pullup_conf(pinctrl, pin, 0); 2829 break; 2830 case PIN_CONFIG_DRIVE_STRENGTH: { 2831 u32 e2 = 0, e4 = 0; 2832 2833 switch (arg) { 2834 case MTK_DRIVE_2mA: 2835 break; 2836 case MTK_DRIVE_4mA: 2837 e2 = 1; 2838 break; 2839 case MTK_DRIVE_6mA: 2840 e4 = 1; 2841 break; 2842 case MTK_DRIVE_8mA: 2843 e2 = 1; 2844 e4 = 1; 2845 break; 2846 default: 2847 return -EINVAL; 2848 } 2849 2850 airoha_pinctrl_set_drive_e2_conf(pinctrl, pin, e2); 2851 airoha_pinctrl_set_drive_e4_conf(pinctrl, pin, e4); 2852 break; 2853 } 2854 case PIN_CONFIG_DRIVE_OPEN_DRAIN: 2855 airoha_pinctrl_set_pcie_rst_od_conf(pinctrl, pin, !!arg); 2856 break; 2857 case PIN_CONFIG_OUTPUT_ENABLE: 2858 case PIN_CONFIG_INPUT_ENABLE: 2859 case PIN_CONFIG_LEVEL: { 2860 bool input = param == PIN_CONFIG_INPUT_ENABLE; 2861 int err; 2862 2863 err = airoha_pinmux_set_direction(pctrl_dev, NULL, pin, 2864 input); 2865 if (err) 2866 return err; 2867 2868 if (param == PIN_CONFIG_LEVEL) { 2869 err = airoha_pinconf_set_pin_value(pctrl_dev, 2870 pin, !!arg); 2871 if (err) 2872 return err; 2873 } 2874 break; 2875 } 2876 default: 2877 return -ENOTSUPP; 2878 } 2879 } 2880 2881 return 0; 2882 } 2883 2884 static int airoha_pinconf_group_get(struct pinctrl_dev *pctrl_dev, 2885 unsigned int group, unsigned long *config) 2886 { 2887 struct airoha_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 2888 unsigned long cur_config = 0; 2889 int i; 2890 2891 for (i = 0; i < pinctrl->grps[group].npins; i++) { 2892 if (airoha_pinconf_get(pctrl_dev, 2893 pinctrl->grps[group].pins[i], 2894 config)) 2895 return -ENOTSUPP; 2896 2897 if (i && cur_config != *config) 2898 return -ENOTSUPP; 2899 2900 cur_config = *config; 2901 } 2902 2903 return 0; 2904 } 2905 2906 static int airoha_pinconf_group_set(struct pinctrl_dev *pctrl_dev, 2907 unsigned int group, unsigned long *configs, 2908 unsigned int num_configs) 2909 { 2910 struct airoha_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 2911 int i; 2912 2913 for (i = 0; i < pinctrl->grps[group].npins; i++) { 2914 int err; 2915 2916 err = airoha_pinconf_set(pctrl_dev, 2917 pinctrl->grps[group].pins[i], 2918 configs, num_configs); 2919 if (err) 2920 return err; 2921 } 2922 2923 return 0; 2924 } 2925 2926 static const struct pinconf_ops airoha_confops = { 2927 .is_generic = true, 2928 .pin_config_get = airoha_pinconf_get, 2929 .pin_config_set = airoha_pinconf_set, 2930 .pin_config_group_get = airoha_pinconf_group_get, 2931 .pin_config_group_set = airoha_pinconf_group_set, 2932 .pin_config_config_dbg_show = pinconf_generic_dump_config, 2933 }; 2934 2935 static const struct pinctrl_ops airoha_pctlops = { 2936 .get_groups_count = pinctrl_generic_get_group_count, 2937 .get_group_name = pinctrl_generic_get_group_name, 2938 .get_group_pins = pinctrl_generic_get_group_pins, 2939 .dt_node_to_map = pinconf_generic_dt_node_to_map_all, 2940 .dt_free_map = pinconf_generic_dt_free_map, 2941 }; 2942 2943 static int airoha_pinctrl_probe(struct platform_device *pdev) 2944 { 2945 const struct airoha_pinctrl_match_data *data; 2946 struct device *dev = &pdev->dev; 2947 struct airoha_pinctrl *pinctrl; 2948 struct regmap *map; 2949 int err, i; 2950 2951 data = device_get_match_data(dev); 2952 2953 pinctrl = devm_kzalloc(dev, sizeof(*pinctrl), GFP_KERNEL); 2954 if (!pinctrl) 2955 return -ENOMEM; 2956 2957 pinctrl->regmap = device_node_to_regmap(dev->parent->of_node); 2958 if (IS_ERR(pinctrl->regmap)) 2959 return PTR_ERR(pinctrl->regmap); 2960 2961 map = syscon_regmap_lookup_by_compatible("airoha,en7581-chip-scu"); 2962 if (IS_ERR(map)) 2963 return PTR_ERR(map); 2964 2965 pinctrl->chip_scu = map; 2966 2967 /* Init pinctrl desc struct */ 2968 pinctrl->desc.name = KBUILD_MODNAME; 2969 pinctrl->desc.owner = THIS_MODULE; 2970 pinctrl->desc.pctlops = &airoha_pctlops; 2971 pinctrl->desc.pmxops = &airoha_pmxops; 2972 pinctrl->desc.confops = &airoha_confops; 2973 pinctrl->desc.pins = data->pins; 2974 pinctrl->desc.npins = data->num_pins; 2975 2976 err = devm_pinctrl_register_and_init(dev, &pinctrl->desc, 2977 pinctrl, &pinctrl->ctrl); 2978 if (err) 2979 return err; 2980 2981 /* build pin groups */ 2982 for (i = 0; i < data->num_grps; i++) { 2983 const struct pingroup *grp = &data->grps[i]; 2984 2985 err = pinctrl_generic_add_group(pinctrl->ctrl, grp->name, 2986 grp->pins, grp->npins, 2987 (void *)grp); 2988 if (err < 0) { 2989 dev_err(&pdev->dev, "Failed to register group %s\n", 2990 grp->name); 2991 return err; 2992 } 2993 } 2994 2995 /* build functions */ 2996 for (i = 0; i < data->num_funcs; i++) { 2997 const struct airoha_pinctrl_func *func; 2998 2999 func = &data->funcs[i]; 3000 err = pinmux_generic_add_pinfunction(pinctrl->ctrl, 3001 &func->desc, 3002 (void *)func); 3003 if (err < 0) { 3004 dev_err(dev, "Failed to register function %s\n", 3005 func->desc.name); 3006 return err; 3007 } 3008 } 3009 3010 pinctrl->grps = data->grps; 3011 pinctrl->funcs = data->funcs; 3012 pinctrl->confs_info = data->confs_info; 3013 3014 err = pinctrl_enable(pinctrl->ctrl); 3015 if (err) 3016 return err; 3017 3018 /* build gpio-chip */ 3019 return airoha_pinctrl_add_gpiochip(pinctrl, pdev); 3020 } 3021 3022 static const struct airoha_pinctrl_match_data en7581_pinctrl_match_data = { 3023 .pins = en7581_pinctrl_pins, 3024 .num_pins = ARRAY_SIZE(en7581_pinctrl_pins), 3025 .grps = en7581_pinctrl_groups, 3026 .num_grps = ARRAY_SIZE(en7581_pinctrl_groups), 3027 .funcs = en7581_pinctrl_funcs, 3028 .num_funcs = ARRAY_SIZE(en7581_pinctrl_funcs), 3029 .confs_info = { 3030 [AIROHA_PINCTRL_CONFS_PULLUP] = { 3031 .confs = en7581_pinctrl_pullup_conf, 3032 .num_confs = ARRAY_SIZE(en7581_pinctrl_pullup_conf), 3033 }, 3034 [AIROHA_PINCTRL_CONFS_PULLDOWN] = { 3035 .confs = en7581_pinctrl_pulldown_conf, 3036 .num_confs = ARRAY_SIZE(en7581_pinctrl_pulldown_conf), 3037 }, 3038 [AIROHA_PINCTRL_CONFS_DRIVE_E2] = { 3039 .confs = en7581_pinctrl_drive_e2_conf, 3040 .num_confs = ARRAY_SIZE(en7581_pinctrl_drive_e2_conf), 3041 }, 3042 [AIROHA_PINCTRL_CONFS_DRIVE_E4] = { 3043 .confs = en7581_pinctrl_drive_e4_conf, 3044 .num_confs = ARRAY_SIZE(en7581_pinctrl_drive_e4_conf), 3045 }, 3046 [AIROHA_PINCTRL_CONFS_PCIE_RST_OD] = { 3047 .confs = en7581_pinctrl_pcie_rst_od_conf, 3048 .num_confs = ARRAY_SIZE(en7581_pinctrl_pcie_rst_od_conf), 3049 }, 3050 }, 3051 }; 3052 3053 static const struct airoha_pinctrl_match_data an7583_pinctrl_match_data = { 3054 .pins = an7583_pinctrl_pins, 3055 .num_pins = ARRAY_SIZE(an7583_pinctrl_pins), 3056 .grps = an7583_pinctrl_groups, 3057 .num_grps = ARRAY_SIZE(an7583_pinctrl_groups), 3058 .funcs = an7583_pinctrl_funcs, 3059 .num_funcs = ARRAY_SIZE(an7583_pinctrl_funcs), 3060 .confs_info = { 3061 [AIROHA_PINCTRL_CONFS_PULLUP] = { 3062 .confs = an7583_pinctrl_pullup_conf, 3063 .num_confs = ARRAY_SIZE(an7583_pinctrl_pullup_conf), 3064 }, 3065 [AIROHA_PINCTRL_CONFS_PULLDOWN] = { 3066 .confs = an7583_pinctrl_pulldown_conf, 3067 .num_confs = ARRAY_SIZE(an7583_pinctrl_pulldown_conf), 3068 }, 3069 [AIROHA_PINCTRL_CONFS_DRIVE_E2] = { 3070 .confs = an7583_pinctrl_drive_e2_conf, 3071 .num_confs = ARRAY_SIZE(an7583_pinctrl_drive_e2_conf), 3072 }, 3073 [AIROHA_PINCTRL_CONFS_DRIVE_E4] = { 3074 .confs = an7583_pinctrl_drive_e4_conf, 3075 .num_confs = ARRAY_SIZE(an7583_pinctrl_drive_e4_conf), 3076 }, 3077 [AIROHA_PINCTRL_CONFS_PCIE_RST_OD] = { 3078 .confs = an7583_pinctrl_pcie_rst_od_conf, 3079 .num_confs = ARRAY_SIZE(an7583_pinctrl_pcie_rst_od_conf), 3080 }, 3081 }, 3082 }; 3083 3084 static const struct of_device_id airoha_pinctrl_of_match[] = { 3085 { .compatible = "airoha,en7581-pinctrl", .data = &en7581_pinctrl_match_data }, 3086 { .compatible = "airoha,an7583-pinctrl", .data = &an7583_pinctrl_match_data }, 3087 { /* sentinel */ } 3088 }; 3089 MODULE_DEVICE_TABLE(of, airoha_pinctrl_of_match); 3090 3091 static struct platform_driver airoha_pinctrl_driver = { 3092 .probe = airoha_pinctrl_probe, 3093 .driver = { 3094 .name = "pinctrl-airoha", 3095 .of_match_table = airoha_pinctrl_of_match, 3096 }, 3097 }; 3098 module_platform_driver(airoha_pinctrl_driver); 3099 3100 MODULE_LICENSE("GPL"); 3101 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>"); 3102 MODULE_AUTHOR("Benjamin Larsson <benjamin.larsson@genexis.eu>"); 3103 MODULE_AUTHOR("Markus Gothe <markus.gothe@genexis.eu>"); 3104 MODULE_DESCRIPTION("Pinctrl driver for Airoha SoC"); 3105