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