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