1 // SPDX-License-Identifier: GPL-2.0-only
3 * Author: Lorenzo Bianconi <lorenzo@kernel.org>
4 * Author: Benjamin Larsson <benjamin.larsson@genexis.eu>
5 * Author: Markus Gothe <markus.gothe@genexis.eu>
8 #include <dt-bindings/pinctrl/mt65xx.h>
9 #include <linux/bits.h>
10 #include <linux/cleanup.h>
11 #include <linux/gpio/driver.h>
12 #include <linux/interrupt.h>
14 #include <linux/irq.h>
15 #include <linux/irqdomain.h>
16 #include <linux/mfd/syscon.h>
18 #include <linux/of_irq.h>
19 #include <linux/of_platform.h>
20 #include <linux/pinctrl/consumer.h>
21 #include <linux/pinctrl/pinctrl.h>
22 #include <linux/pinctrl/pinconf.h>
23 #include <linux/pinctrl/pinconf-generic.h>
24 #include <linux/pinctrl/pinmux.h>
25 #include <linux/platform_device.h>
26 #include <linux/regmap.h>
29 #include "../pinconf.h"
30 #include "../pinmux.h"
32 #define PINCTRL_PIN_GROUP(id) \
33 PINCTRL_PINGROUP(#id, id##_pins, ARRAY_SIZE(id##_pins))
35 #define PINCTRL_FUNC_DESC(id) \
40 .groups = id##_groups, \
41 .ngroups = ARRAY_SIZE(id##_groups), \
44 .groups = id##_func_group, \
45 .group_size = ARRAY_SIZE(id##_func_group), \
48 #define PINCTRL_CONF_DESC(p, offset, mask) \
51 .reg = { offset, mask }, \
55 #define REG_GPIO_2ND_I2C_MODE 0x0214
56 #define GPIO_MDC_IO_MASTER_MODE_MODE BIT(14)
57 #define GPIO_I2C_MASTER_MODE_MODE BIT(13)
58 #define GPIO_I2S_MODE_MASK BIT(12)
59 #define GPIO_I2C_SLAVE_MODE_MODE BIT(11)
60 #define GPIO_LAN3_LED1_MODE_MASK BIT(10)
61 #define GPIO_LAN3_LED0_MODE_MASK BIT(9)
62 #define GPIO_LAN2_LED1_MODE_MASK BIT(8)
63 #define GPIO_LAN2_LED0_MODE_MASK BIT(7)
64 #define GPIO_LAN1_LED1_MODE_MASK BIT(6)
65 #define GPIO_LAN1_LED0_MODE_MASK BIT(5)
66 #define GPIO_LAN0_LED1_MODE_MASK BIT(4)
67 #define GPIO_LAN0_LED0_MODE_MASK BIT(3)
68 #define PON_TOD_1PPS_MODE_MASK BIT(2)
69 #define GSW_TOD_1PPS_MODE_MASK BIT(1)
70 #define GPIO_2ND_I2C_MODE_MASK BIT(0)
72 #define REG_GPIO_SPI_CS1_MODE 0x0218
73 #define GPIO_PCM_SPI_CS4_MODE_MASK BIT(21)
74 #define GPIO_PCM_SPI_CS3_MODE_MASK BIT(20)
75 #define GPIO_PCM_SPI_CS2_MODE_P156_MASK BIT(19)
76 #define GPIO_PCM_SPI_CS2_MODE_P128_MASK BIT(18)
77 #define GPIO_PCM_SPI_CS1_MODE_MASK BIT(17)
78 #define GPIO_PCM_SPI_MODE_MASK BIT(16)
79 #define GPIO_PCM2_MODE_MASK BIT(13)
80 #define GPIO_PCM1_MODE_MASK BIT(12)
81 #define GPIO_PCM_INT_MODE_MASK BIT(9)
82 #define GPIO_PCM_RESET_MODE_MASK BIT(8)
83 #define GPIO_SPI_QUAD_MODE_MASK BIT(4)
84 #define GPIO_SPI_CS4_MODE_MASK BIT(3)
85 #define GPIO_SPI_CS3_MODE_MASK BIT(2)
86 #define GPIO_SPI_CS2_MODE_MASK BIT(1)
87 #define GPIO_SPI_CS1_MODE_MASK BIT(0)
89 #define REG_GPIO_PON_MODE 0x021c
90 #define GPIO_PARALLEL_NAND_MODE_MASK BIT(14)
91 #define GPIO_SGMII_MDIO_MODE_MASK BIT(13)
92 #define GPIO_PCIE_RESET2_MASK BIT(12)
93 #define SIPO_RCLK_MODE_MASK BIT(11)
94 #define GPIO_PCIE_RESET1_MASK BIT(10)
95 #define GPIO_PCIE_RESET0_MASK BIT(9)
96 #define GPIO_UART5_MODE_MASK BIT(8)
97 #define GPIO_UART4_MODE_MASK BIT(7)
98 #define GPIO_HSUART_CTS_RTS_MODE_MASK BIT(6)
99 #define GPIO_HSUART_MODE_MASK BIT(5)
100 #define GPIO_UART2_CTS_RTS_MODE_MASK BIT(4)
101 #define GPIO_UART2_MODE_MASK BIT(3)
102 #define GPIO_SIPO_MODE_MASK BIT(2)
103 #define GPIO_EMMC_MODE_MASK BIT(1)
104 #define GPIO_PON_MODE_MASK BIT(0)
106 #define REG_NPU_UART_EN 0x0224
107 #define JTAG_UDI_EN_MASK BIT(4)
108 #define JTAG_DFD_EN_MASK BIT(3)
111 #define REG_LAN_LED0_MAPPING 0x027c
112 #define REG_LAN_LED1_MAPPING 0x0280
114 #define LAN4_LED_MAPPING_MASK GENMASK(18, 16)
115 #define LAN4_PHY4_LED_MAP BIT(18)
116 #define LAN4_PHY2_LED_MAP BIT(17)
117 #define LAN4_PHY1_LED_MAP BIT(16)
118 #define LAN4_PHY0_LED_MAP 0
119 #define LAN4_PHY3_LED_MAP GENMASK(17, 16)
121 #define LAN3_LED_MAPPING_MASK GENMASK(14, 12)
122 #define LAN3_PHY4_LED_MAP BIT(14)
123 #define LAN3_PHY2_LED_MAP BIT(13)
124 #define LAN3_PHY1_LED_MAP BIT(12)
125 #define LAN3_PHY0_LED_MAP 0
126 #define LAN3_PHY3_LED_MAP GENMASK(13, 12)
128 #define LAN2_LED_MAPPING_MASK GENMASK(10, 8)
129 #define LAN2_PHY4_LED_MAP BIT(12)
130 #define LAN2_PHY2_LED_MAP BIT(11)
131 #define LAN2_PHY1_LED_MAP BIT(10)
132 #define LAN2_PHY0_LED_MAP 0
133 #define LAN2_PHY3_LED_MAP GENMASK(11, 10)
135 #define LAN1_LED_MAPPING_MASK GENMASK(6, 4)
136 #define LAN1_PHY4_LED_MAP BIT(6)
137 #define LAN1_PHY2_LED_MAP BIT(5)
138 #define LAN1_PHY1_LED_MAP BIT(4)
139 #define LAN1_PHY0_LED_MAP 0
140 #define LAN1_PHY3_LED_MAP GENMASK(5, 4)
142 #define LAN0_LED_MAPPING_MASK GENMASK(2, 0)
143 #define LAN0_PHY4_LED_MAP BIT(3)
144 #define LAN0_PHY2_LED_MAP BIT(2)
145 #define LAN0_PHY1_LED_MAP BIT(1)
146 #define LAN0_PHY0_LED_MAP 0
147 #define LAN0_PHY3_LED_MAP GENMASK(2, 1)
150 #define REG_I2C_SDA_E2 0x001c
151 #define SPI_MISO_E2_MASK BIT(14)
152 #define SPI_MOSI_E2_MASK BIT(13)
153 #define SPI_CLK_E2_MASK BIT(12)
154 #define SPI_CS0_E2_MASK BIT(11)
155 #define PCIE2_RESET_E2_MASK BIT(10)
156 #define PCIE1_RESET_E2_MASK BIT(9)
157 #define PCIE0_RESET_E2_MASK BIT(8)
158 #define UART1_RXD_E2_MASK BIT(3)
159 #define UART1_TXD_E2_MASK BIT(2)
160 #define I2C_SCL_E2_MASK BIT(1)
161 #define I2C_SDA_E2_MASK BIT(0)
163 #define REG_I2C_SDA_E4 0x0020
164 #define SPI_MISO_E4_MASK BIT(14)
165 #define SPI_MOSI_E4_MASK BIT(13)
166 #define SPI_CLK_E4_MASK BIT(12)
167 #define SPI_CS0_E4_MASK BIT(11)
168 #define PCIE2_RESET_E4_MASK BIT(10)
169 #define PCIE1_RESET_E4_MASK BIT(9)
170 #define PCIE0_RESET_E4_MASK BIT(8)
171 #define UART1_RXD_E4_MASK BIT(3)
172 #define UART1_TXD_E4_MASK BIT(2)
173 #define I2C_SCL_E4_MASK BIT(1)
174 #define I2C_SDA_E4_MASK BIT(0)
176 #define REG_GPIO_L_E2 0x0024
177 #define REG_GPIO_L_E4 0x0028
178 #define REG_GPIO_H_E2 0x002c
179 #define REG_GPIO_H_E4 0x0030
181 #define REG_I2C_SDA_PU 0x0044
182 #define SPI_MISO_PU_MASK BIT(14)
183 #define SPI_MOSI_PU_MASK BIT(13)
184 #define SPI_CLK_PU_MASK BIT(12)
185 #define SPI_CS0_PU_MASK BIT(11)
186 #define PCIE2_RESET_PU_MASK BIT(10)
187 #define PCIE1_RESET_PU_MASK BIT(9)
188 #define PCIE0_RESET_PU_MASK BIT(8)
189 #define UART1_RXD_PU_MASK BIT(3)
190 #define UART1_TXD_PU_MASK BIT(2)
191 #define I2C_SCL_PU_MASK BIT(1)
192 #define I2C_SDA_PU_MASK BIT(0)
194 #define REG_I2C_SDA_PD 0x0048
195 #define SPI_MISO_PD_MASK BIT(14)
196 #define SPI_MOSI_PD_MASK BIT(13)
197 #define SPI_CLK_PD_MASK BIT(12)
198 #define SPI_CS0_PD_MASK BIT(11)
199 #define PCIE2_RESET_PD_MASK BIT(10)
200 #define PCIE1_RESET_PD_MASK BIT(9)
201 #define PCIE0_RESET_PD_MASK BIT(8)
202 #define UART1_RXD_PD_MASK BIT(3)
203 #define UART1_TXD_PD_MASK BIT(2)
204 #define I2C_SCL_PD_MASK BIT(1)
205 #define I2C_SDA_PD_MASK BIT(0)
207 #define REG_GPIO_L_PU 0x004c
208 #define REG_GPIO_L_PD 0x0050
209 #define REG_GPIO_H_PU 0x0054
210 #define REG_GPIO_H_PD 0x0058
212 #define REG_PCIE_RESET_OD 0x018c
213 #define PCIE2_RESET_OD_MASK BIT(2)
214 #define PCIE1_RESET_OD_MASK BIT(1)
215 #define PCIE0_RESET_OD_MASK BIT(0)
218 #define REG_GPIO_CTRL 0x0000
219 #define REG_GPIO_DATA 0x0004
220 #define REG_GPIO_INT 0x0008
221 #define REG_GPIO_INT_EDGE 0x000c
222 #define REG_GPIO_INT_LEVEL 0x0010
223 #define REG_GPIO_OE 0x0014
224 #define REG_GPIO_CTRL1 0x0020
227 #define REG_GPIO_FLASH_MODE_CFG 0x0034
228 #define GPIO15_FLASH_MODE_CFG BIT(15)
229 #define GPIO14_FLASH_MODE_CFG BIT(14)
230 #define GPIO13_FLASH_MODE_CFG BIT(13)
231 #define GPIO12_FLASH_MODE_CFG BIT(12)
232 #define GPIO11_FLASH_MODE_CFG BIT(11)
233 #define GPIO10_FLASH_MODE_CFG BIT(10)
234 #define GPIO9_FLASH_MODE_CFG BIT(9)
235 #define GPIO8_FLASH_MODE_CFG BIT(8)
236 #define GPIO7_FLASH_MODE_CFG BIT(7)
237 #define GPIO6_FLASH_MODE_CFG BIT(6)
238 #define GPIO5_FLASH_MODE_CFG BIT(5)
239 #define GPIO4_FLASH_MODE_CFG BIT(4)
240 #define GPIO3_FLASH_MODE_CFG BIT(3)
241 #define GPIO2_FLASH_MODE_CFG BIT(2)
242 #define GPIO1_FLASH_MODE_CFG BIT(1)
243 #define GPIO0_FLASH_MODE_CFG BIT(0)
245 #define REG_GPIO_CTRL2 0x0060
246 #define REG_GPIO_CTRL3 0x0064
248 /* PWM MODE CONF EXT */
249 #define REG_GPIO_FLASH_MODE_CFG_EXT 0x0068
250 #define GPIO51_FLASH_MODE_CFG BIT(31)
251 #define GPIO50_FLASH_MODE_CFG BIT(30)
252 #define GPIO49_FLASH_MODE_CFG BIT(29)
253 #define GPIO48_FLASH_MODE_CFG BIT(28)
254 #define GPIO47_FLASH_MODE_CFG BIT(27)
255 #define GPIO46_FLASH_MODE_CFG BIT(26)
256 #define GPIO45_FLASH_MODE_CFG BIT(25)
257 #define GPIO44_FLASH_MODE_CFG BIT(24)
258 #define GPIO43_FLASH_MODE_CFG BIT(23)
259 #define GPIO42_FLASH_MODE_CFG BIT(22)
260 #define GPIO41_FLASH_MODE_CFG BIT(21)
261 #define GPIO40_FLASH_MODE_CFG BIT(20)
262 #define GPIO39_FLASH_MODE_CFG BIT(19)
263 #define GPIO38_FLASH_MODE_CFG BIT(18)
264 #define GPIO37_FLASH_MODE_CFG BIT(17)
265 #define GPIO36_FLASH_MODE_CFG BIT(16)
266 #define GPIO31_FLASH_MODE_CFG BIT(15)
267 #define GPIO30_FLASH_MODE_CFG BIT(14)
268 #define GPIO29_FLASH_MODE_CFG BIT(13)
269 #define GPIO28_FLASH_MODE_CFG BIT(12)
270 #define GPIO27_FLASH_MODE_CFG BIT(11)
271 #define GPIO26_FLASH_MODE_CFG BIT(10)
272 #define GPIO25_FLASH_MODE_CFG BIT(9)
273 #define GPIO24_FLASH_MODE_CFG BIT(8)
274 #define GPIO23_FLASH_MODE_CFG BIT(7)
275 #define GPIO22_FLASH_MODE_CFG BIT(6)
276 #define GPIO21_FLASH_MODE_CFG BIT(5)
277 #define GPIO20_FLASH_MODE_CFG BIT(4)
278 #define GPIO19_FLASH_MODE_CFG BIT(3)
279 #define GPIO18_FLASH_MODE_CFG BIT(2)
280 #define GPIO17_FLASH_MODE_CFG BIT(1)
281 #define GPIO16_FLASH_MODE_CFG BIT(0)
283 #define REG_GPIO_DATA1 0x0070
284 #define REG_GPIO_OE1 0x0078
285 #define REG_GPIO_INT1 0x007c
286 #define REG_GPIO_INT_EDGE1 0x0080
287 #define REG_GPIO_INT_EDGE2 0x0084
288 #define REG_GPIO_INT_EDGE3 0x0088
289 #define REG_GPIO_INT_LEVEL1 0x008c
290 #define REG_GPIO_INT_LEVEL2 0x0090
291 #define REG_GPIO_INT_LEVEL3 0x0094
293 #define AIROHA_NUM_PINS 64
294 #define AIROHA_PIN_BANK_SIZE (AIROHA_NUM_PINS / 2)
295 #define AIROHA_REG_GPIOCTRL_NUM_PIN (AIROHA_NUM_PINS / 4)
297 static const u32 gpio_data_regs
[] = {
302 static const u32 gpio_out_regs
[] = {
307 static const u32 gpio_dir_regs
[] = {
314 static const u32 irq_status_regs
[] = {
319 static const u32 irq_level_regs
[] = {
326 static const u32 irq_edge_regs
[] = {
333 struct airoha_pinctrl_reg
{
338 enum airoha_pinctrl_mux_func
{
341 AIROHA_FUNC_PWM_EXT_MUX
,
344 struct airoha_pinctrl_func_group
{
347 enum airoha_pinctrl_mux_func mux
;
355 struct airoha_pinctrl_func
{
356 const struct function_desc desc
;
357 const struct airoha_pinctrl_func_group
*groups
;
361 struct airoha_pinctrl_conf
{
363 struct airoha_pinctrl_reg reg
;
366 struct airoha_pinctrl_gpiochip
{
367 struct gpio_chip chip
;
378 u32 irq_type
[AIROHA_NUM_PINS
];
381 struct airoha_pinctrl
{
382 struct pinctrl_dev
*ctrl
;
384 struct regmap
*chip_scu
;
385 struct regmap
*regmap
;
387 struct airoha_pinctrl_gpiochip gpiochip
;
390 static struct pinctrl_pin_desc airoha_pinctrl_pins
[] = {
391 PINCTRL_PIN(0, "uart1_txd"),
392 PINCTRL_PIN(1, "uart1_rxd"),
393 PINCTRL_PIN(2, "i2c_scl"),
394 PINCTRL_PIN(3, "i2c_sda"),
395 PINCTRL_PIN(4, "spi_cs0"),
396 PINCTRL_PIN(5, "spi_clk"),
397 PINCTRL_PIN(6, "spi_mosi"),
398 PINCTRL_PIN(7, "spi_miso"),
399 PINCTRL_PIN(13, "gpio0"),
400 PINCTRL_PIN(14, "gpio1"),
401 PINCTRL_PIN(15, "gpio2"),
402 PINCTRL_PIN(16, "gpio3"),
403 PINCTRL_PIN(17, "gpio4"),
404 PINCTRL_PIN(18, "gpio5"),
405 PINCTRL_PIN(19, "gpio6"),
406 PINCTRL_PIN(20, "gpio7"),
407 PINCTRL_PIN(21, "gpio8"),
408 PINCTRL_PIN(22, "gpio9"),
409 PINCTRL_PIN(23, "gpio10"),
410 PINCTRL_PIN(24, "gpio11"),
411 PINCTRL_PIN(25, "gpio12"),
412 PINCTRL_PIN(26, "gpio13"),
413 PINCTRL_PIN(27, "gpio14"),
414 PINCTRL_PIN(28, "gpio15"),
415 PINCTRL_PIN(29, "gpio16"),
416 PINCTRL_PIN(30, "gpio17"),
417 PINCTRL_PIN(31, "gpio18"),
418 PINCTRL_PIN(32, "gpio19"),
419 PINCTRL_PIN(33, "gpio20"),
420 PINCTRL_PIN(34, "gpio21"),
421 PINCTRL_PIN(35, "gpio22"),
422 PINCTRL_PIN(36, "gpio23"),
423 PINCTRL_PIN(37, "gpio24"),
424 PINCTRL_PIN(38, "gpio25"),
425 PINCTRL_PIN(39, "gpio26"),
426 PINCTRL_PIN(40, "gpio27"),
427 PINCTRL_PIN(41, "gpio28"),
428 PINCTRL_PIN(42, "gpio29"),
429 PINCTRL_PIN(43, "gpio30"),
430 PINCTRL_PIN(44, "gpio31"),
431 PINCTRL_PIN(45, "gpio32"),
432 PINCTRL_PIN(46, "gpio33"),
433 PINCTRL_PIN(47, "gpio34"),
434 PINCTRL_PIN(48, "gpio35"),
435 PINCTRL_PIN(49, "gpio36"),
436 PINCTRL_PIN(50, "gpio37"),
437 PINCTRL_PIN(51, "gpio38"),
438 PINCTRL_PIN(52, "gpio39"),
439 PINCTRL_PIN(53, "gpio40"),
440 PINCTRL_PIN(54, "gpio41"),
441 PINCTRL_PIN(55, "gpio42"),
442 PINCTRL_PIN(56, "gpio43"),
443 PINCTRL_PIN(57, "gpio44"),
444 PINCTRL_PIN(58, "gpio45"),
445 PINCTRL_PIN(59, "gpio46"),
446 PINCTRL_PIN(61, "pcie_reset0"),
447 PINCTRL_PIN(62, "pcie_reset1"),
448 PINCTRL_PIN(63, "pcie_reset2"),
451 static const int pon_pins
[] = { 49, 50, 51, 52, 53, 54 };
452 static const int pon_tod_1pps_pins
[] = { 46 };
453 static const int gsw_tod_1pps_pins
[] = { 46 };
454 static const int sipo_pins
[] = { 16, 17 };
455 static const int sipo_rclk_pins
[] = { 16, 17, 43 };
456 static const int mdio_pins
[] = { 14, 15 };
457 static const int uart2_pins
[] = { 48, 55 };
458 static const int uart2_cts_rts_pins
[] = { 46, 47 };
459 static const int hsuart_pins
[] = { 28, 29 };
460 static const int hsuart_cts_rts_pins
[] = { 26, 27 };
461 static const int uart4_pins
[] = { 38, 39 };
462 static const int uart5_pins
[] = { 18, 19 };
463 static const int i2c0_pins
[] = { 2, 3 };
464 static const int i2c1_pins
[] = { 14, 15 };
465 static const int jtag_udi_pins
[] = { 16, 17, 18, 19, 20 };
466 static const int jtag_dfd_pins
[] = { 16, 17, 18, 19, 20 };
467 static const int i2s_pins
[] = { 26, 27, 28, 29 };
468 static const int pcm1_pins
[] = { 22, 23, 24, 25 };
469 static const int pcm2_pins
[] = { 18, 19, 20, 21 };
470 static const int spi_quad_pins
[] = { 32, 33 };
471 static const int spi_pins
[] = { 4, 5, 6, 7 };
472 static const int spi_cs1_pins
[] = { 34 };
473 static const int pcm_spi_pins
[] = { 18, 19, 20, 21, 22, 23, 24, 25 };
474 static const int pcm_spi_int_pins
[] = { 14 };
475 static const int pcm_spi_rst_pins
[] = { 15 };
476 static const int pcm_spi_cs1_pins
[] = { 43 };
477 static const int pcm_spi_cs2_pins
[] = { 40 };
478 static const int pcm_spi_cs2_p128_pins
[] = { 40 };
479 static const int pcm_spi_cs2_p156_pins
[] = { 40 };
480 static const int pcm_spi_cs3_pins
[] = { 41 };
481 static const int pcm_spi_cs4_pins
[] = { 42 };
482 static const int emmc_pins
[] = { 4, 5, 6, 30, 31, 32, 33, 34, 35, 36, 37 };
483 static const int pnand_pins
[] = { 4, 5, 6, 7, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
484 static const int gpio0_pins
[] = { 13 };
485 static const int gpio1_pins
[] = { 14 };
486 static const int gpio2_pins
[] = { 15 };
487 static const int gpio3_pins
[] = { 16 };
488 static const int gpio4_pins
[] = { 17 };
489 static const int gpio5_pins
[] = { 18 };
490 static const int gpio6_pins
[] = { 19 };
491 static const int gpio7_pins
[] = { 20 };
492 static const int gpio8_pins
[] = { 21 };
493 static const int gpio9_pins
[] = { 22 };
494 static const int gpio10_pins
[] = { 23 };
495 static const int gpio11_pins
[] = { 24 };
496 static const int gpio12_pins
[] = { 25 };
497 static const int gpio13_pins
[] = { 26 };
498 static const int gpio14_pins
[] = { 27 };
499 static const int gpio15_pins
[] = { 28 };
500 static const int gpio16_pins
[] = { 29 };
501 static const int gpio17_pins
[] = { 30 };
502 static const int gpio18_pins
[] = { 31 };
503 static const int gpio19_pins
[] = { 32 };
504 static const int gpio20_pins
[] = { 33 };
505 static const int gpio21_pins
[] = { 34 };
506 static const int gpio22_pins
[] = { 35 };
507 static const int gpio23_pins
[] = { 36 };
508 static const int gpio24_pins
[] = { 37 };
509 static const int gpio25_pins
[] = { 38 };
510 static const int gpio26_pins
[] = { 39 };
511 static const int gpio27_pins
[] = { 40 };
512 static const int gpio28_pins
[] = { 41 };
513 static const int gpio29_pins
[] = { 42 };
514 static const int gpio30_pins
[] = { 43 };
515 static const int gpio31_pins
[] = { 44 };
516 static const int gpio33_pins
[] = { 46 };
517 static const int gpio34_pins
[] = { 47 };
518 static const int gpio35_pins
[] = { 48 };
519 static const int gpio36_pins
[] = { 49 };
520 static const int gpio37_pins
[] = { 50 };
521 static const int gpio38_pins
[] = { 51 };
522 static const int gpio39_pins
[] = { 52 };
523 static const int gpio40_pins
[] = { 53 };
524 static const int gpio41_pins
[] = { 54 };
525 static const int gpio42_pins
[] = { 55 };
526 static const int gpio43_pins
[] = { 56 };
527 static const int gpio44_pins
[] = { 57 };
528 static const int gpio45_pins
[] = { 58 };
529 static const int gpio46_pins
[] = { 59 };
530 static const int pcie_reset0_pins
[] = { 61 };
531 static const int pcie_reset1_pins
[] = { 62 };
532 static const int pcie_reset2_pins
[] = { 63 };
534 static const struct pingroup airoha_pinctrl_groups
[] = {
535 PINCTRL_PIN_GROUP(pon
),
536 PINCTRL_PIN_GROUP(pon_tod_1pps
),
537 PINCTRL_PIN_GROUP(gsw_tod_1pps
),
538 PINCTRL_PIN_GROUP(sipo
),
539 PINCTRL_PIN_GROUP(sipo_rclk
),
540 PINCTRL_PIN_GROUP(mdio
),
541 PINCTRL_PIN_GROUP(uart2
),
542 PINCTRL_PIN_GROUP(uart2_cts_rts
),
543 PINCTRL_PIN_GROUP(hsuart
),
544 PINCTRL_PIN_GROUP(hsuart_cts_rts
),
545 PINCTRL_PIN_GROUP(uart4
),
546 PINCTRL_PIN_GROUP(uart5
),
547 PINCTRL_PIN_GROUP(i2c0
),
548 PINCTRL_PIN_GROUP(i2c1
),
549 PINCTRL_PIN_GROUP(jtag_udi
),
550 PINCTRL_PIN_GROUP(jtag_dfd
),
551 PINCTRL_PIN_GROUP(i2s
),
552 PINCTRL_PIN_GROUP(pcm1
),
553 PINCTRL_PIN_GROUP(pcm2
),
554 PINCTRL_PIN_GROUP(spi
),
555 PINCTRL_PIN_GROUP(spi_quad
),
556 PINCTRL_PIN_GROUP(spi_cs1
),
557 PINCTRL_PIN_GROUP(pcm_spi
),
558 PINCTRL_PIN_GROUP(pcm_spi_int
),
559 PINCTRL_PIN_GROUP(pcm_spi_rst
),
560 PINCTRL_PIN_GROUP(pcm_spi_cs1
),
561 PINCTRL_PIN_GROUP(pcm_spi_cs2_p128
),
562 PINCTRL_PIN_GROUP(pcm_spi_cs2_p156
),
563 PINCTRL_PIN_GROUP(pcm_spi_cs2
),
564 PINCTRL_PIN_GROUP(pcm_spi_cs3
),
565 PINCTRL_PIN_GROUP(pcm_spi_cs4
),
566 PINCTRL_PIN_GROUP(emmc
),
567 PINCTRL_PIN_GROUP(pnand
),
568 PINCTRL_PIN_GROUP(gpio0
),
569 PINCTRL_PIN_GROUP(gpio1
),
570 PINCTRL_PIN_GROUP(gpio2
),
571 PINCTRL_PIN_GROUP(gpio3
),
572 PINCTRL_PIN_GROUP(gpio4
),
573 PINCTRL_PIN_GROUP(gpio5
),
574 PINCTRL_PIN_GROUP(gpio6
),
575 PINCTRL_PIN_GROUP(gpio7
),
576 PINCTRL_PIN_GROUP(gpio8
),
577 PINCTRL_PIN_GROUP(gpio9
),
578 PINCTRL_PIN_GROUP(gpio10
),
579 PINCTRL_PIN_GROUP(gpio11
),
580 PINCTRL_PIN_GROUP(gpio12
),
581 PINCTRL_PIN_GROUP(gpio13
),
582 PINCTRL_PIN_GROUP(gpio14
),
583 PINCTRL_PIN_GROUP(gpio15
),
584 PINCTRL_PIN_GROUP(gpio16
),
585 PINCTRL_PIN_GROUP(gpio17
),
586 PINCTRL_PIN_GROUP(gpio18
),
587 PINCTRL_PIN_GROUP(gpio19
),
588 PINCTRL_PIN_GROUP(gpio20
),
589 PINCTRL_PIN_GROUP(gpio21
),
590 PINCTRL_PIN_GROUP(gpio22
),
591 PINCTRL_PIN_GROUP(gpio23
),
592 PINCTRL_PIN_GROUP(gpio24
),
593 PINCTRL_PIN_GROUP(gpio25
),
594 PINCTRL_PIN_GROUP(gpio26
),
595 PINCTRL_PIN_GROUP(gpio27
),
596 PINCTRL_PIN_GROUP(gpio28
),
597 PINCTRL_PIN_GROUP(gpio29
),
598 PINCTRL_PIN_GROUP(gpio30
),
599 PINCTRL_PIN_GROUP(gpio31
),
600 PINCTRL_PIN_GROUP(gpio33
),
601 PINCTRL_PIN_GROUP(gpio34
),
602 PINCTRL_PIN_GROUP(gpio35
),
603 PINCTRL_PIN_GROUP(gpio36
),
604 PINCTRL_PIN_GROUP(gpio37
),
605 PINCTRL_PIN_GROUP(gpio38
),
606 PINCTRL_PIN_GROUP(gpio39
),
607 PINCTRL_PIN_GROUP(gpio40
),
608 PINCTRL_PIN_GROUP(gpio41
),
609 PINCTRL_PIN_GROUP(gpio42
),
610 PINCTRL_PIN_GROUP(gpio43
),
611 PINCTRL_PIN_GROUP(gpio44
),
612 PINCTRL_PIN_GROUP(gpio45
),
613 PINCTRL_PIN_GROUP(gpio46
),
614 PINCTRL_PIN_GROUP(pcie_reset0
),
615 PINCTRL_PIN_GROUP(pcie_reset1
),
616 PINCTRL_PIN_GROUP(pcie_reset2
),
619 static const char *const pon_groups
[] = { "pon" };
620 static const char *const tod_1pps_groups
[] = { "pon_tod_1pps", "gsw_tod_1pps" };
621 static const char *const sipo_groups
[] = { "sipo", "sipo_rclk" };
622 static const char *const mdio_groups
[] = { "mdio" };
623 static const char *const uart_groups
[] = { "uart2", "uart2_cts_rts", "hsuart",
624 "hsuart_cts_rts", "uart4",
626 static const char *const i2c_groups
[] = { "i2c1" };
627 static const char *const jtag_groups
[] = { "jtag_udi", "jtag_dfd" };
628 static const char *const pcm_groups
[] = { "pcm1", "pcm2" };
629 static const char *const spi_groups
[] = { "spi_quad", "spi_cs1" };
630 static const char *const pcm_spi_groups
[] = { "pcm_spi", "pcm_spi_int",
631 "pcm_spi_rst", "pcm_spi_cs1",
634 "pcm_spi_cs3", "pcm_spi_cs4" };
635 static const char *const i2s_groups
[] = { "i2s" };
636 static const char *const emmc_groups
[] = { "emmc" };
637 static const char *const pnand_groups
[] = { "pnand" };
638 static const char *const pcie_reset_groups
[] = { "pcie_reset0", "pcie_reset1",
640 static const char *const pwm_groups
[] = { "gpio0", "gpio1",
661 "gpio46", "gpio47" };
662 static const char *const phy1_led0_groups
[] = { "gpio33", "gpio34",
663 "gpio35", "gpio42" };
664 static const char *const phy2_led0_groups
[] = { "gpio33", "gpio34",
665 "gpio35", "gpio42" };
666 static const char *const phy3_led0_groups
[] = { "gpio33", "gpio34",
667 "gpio35", "gpio42" };
668 static const char *const phy4_led0_groups
[] = { "gpio33", "gpio34",
669 "gpio35", "gpio42" };
670 static const char *const phy1_led1_groups
[] = { "gpio43", "gpio44",
671 "gpio45", "gpio46" };
672 static const char *const phy2_led1_groups
[] = { "gpio43", "gpio44",
673 "gpio45", "gpio46" };
674 static const char *const phy3_led1_groups
[] = { "gpio43", "gpio44",
675 "gpio45", "gpio46" };
676 static const char *const phy4_led1_groups
[] = { "gpio43", "gpio44",
677 "gpio45", "gpio46" };
679 static const struct airoha_pinctrl_func_group pon_func_group
[] = {
692 static const struct airoha_pinctrl_func_group tod_1pps_func_group
[] = {
694 .name
= "pon_tod_1pps",
697 REG_GPIO_2ND_I2C_MODE
,
698 PON_TOD_1PPS_MODE_MASK
,
699 PON_TOD_1PPS_MODE_MASK
703 .name
= "gsw_tod_1pps",
706 REG_GPIO_2ND_I2C_MODE
,
707 GSW_TOD_1PPS_MODE_MASK
,
708 GSW_TOD_1PPS_MODE_MASK
714 static const struct airoha_pinctrl_func_group sipo_func_group
[] = {
720 GPIO_SIPO_MODE_MASK
| SIPO_RCLK_MODE_MASK
,
729 GPIO_SIPO_MODE_MASK
| SIPO_RCLK_MODE_MASK
,
730 GPIO_SIPO_MODE_MASK
| SIPO_RCLK_MODE_MASK
736 static const struct airoha_pinctrl_func_group mdio_func_group
[] = {
742 GPIO_SGMII_MDIO_MODE_MASK
,
743 GPIO_SGMII_MDIO_MODE_MASK
747 REG_GPIO_2ND_I2C_MODE
,
748 GPIO_MDC_IO_MASTER_MODE_MODE
,
749 GPIO_MDC_IO_MASTER_MODE_MODE
755 static const struct airoha_pinctrl_func_group uart_func_group
[] = {
761 GPIO_UART2_MODE_MASK
,
766 .name
= "uart2_cts_rts",
770 GPIO_UART2_MODE_MASK
| GPIO_UART2_CTS_RTS_MODE_MASK
,
771 GPIO_UART2_MODE_MASK
| GPIO_UART2_CTS_RTS_MODE_MASK
779 GPIO_HSUART_MODE_MASK
| GPIO_HSUART_CTS_RTS_MODE_MASK
,
780 GPIO_HSUART_MODE_MASK
785 .name
= "hsuart_cts_rts",
789 GPIO_HSUART_MODE_MASK
| GPIO_HSUART_CTS_RTS_MODE_MASK
,
790 GPIO_HSUART_MODE_MASK
| GPIO_HSUART_CTS_RTS_MODE_MASK
798 GPIO_UART4_MODE_MASK
,
807 GPIO_UART5_MODE_MASK
,
814 static const struct airoha_pinctrl_func_group i2c_func_group
[] = {
819 REG_GPIO_2ND_I2C_MODE
,
820 GPIO_2ND_I2C_MODE_MASK
,
821 GPIO_2ND_I2C_MODE_MASK
827 static const struct airoha_pinctrl_func_group jtag_func_group
[] = {
849 static const struct airoha_pinctrl_func_group pcm_func_group
[] = {
854 REG_GPIO_SPI_CS1_MODE
,
863 REG_GPIO_SPI_CS1_MODE
,
871 static const struct airoha_pinctrl_func_group spi_func_group
[] = {
876 REG_GPIO_SPI_CS1_MODE
,
877 GPIO_SPI_QUAD_MODE_MASK
,
878 GPIO_SPI_QUAD_MODE_MASK
885 REG_GPIO_SPI_CS1_MODE
,
886 GPIO_SPI_CS1_MODE_MASK
,
887 GPIO_SPI_CS1_MODE_MASK
894 REG_GPIO_SPI_CS1_MODE
,
895 GPIO_SPI_CS2_MODE_MASK
,
896 GPIO_SPI_CS2_MODE_MASK
903 REG_GPIO_SPI_CS1_MODE
,
904 GPIO_SPI_CS3_MODE_MASK
,
905 GPIO_SPI_CS3_MODE_MASK
912 REG_GPIO_SPI_CS1_MODE
,
913 GPIO_SPI_CS4_MODE_MASK
,
914 GPIO_SPI_CS4_MODE_MASK
920 static const struct airoha_pinctrl_func_group pcm_spi_func_group
[] = {
925 REG_GPIO_SPI_CS1_MODE
,
926 GPIO_PCM_SPI_MODE_MASK
,
927 GPIO_PCM_SPI_MODE_MASK
931 .name
= "pcm_spi_int",
934 REG_GPIO_SPI_CS1_MODE
,
935 GPIO_PCM_INT_MODE_MASK
,
936 GPIO_PCM_INT_MODE_MASK
940 .name
= "pcm_spi_rst",
943 REG_GPIO_SPI_CS1_MODE
,
944 GPIO_PCM_RESET_MODE_MASK
,
945 GPIO_PCM_RESET_MODE_MASK
949 .name
= "pcm_spi_cs1",
952 REG_GPIO_SPI_CS1_MODE
,
953 GPIO_PCM_SPI_CS1_MODE_MASK
,
954 GPIO_PCM_SPI_CS1_MODE_MASK
958 .name
= "pcm_spi_cs2_p128",
961 REG_GPIO_SPI_CS1_MODE
,
962 GPIO_PCM_SPI_CS2_MODE_P128_MASK
,
963 GPIO_PCM_SPI_CS2_MODE_P128_MASK
967 .name
= "pcm_spi_cs2_p156",
970 REG_GPIO_SPI_CS1_MODE
,
971 GPIO_PCM_SPI_CS2_MODE_P156_MASK
,
972 GPIO_PCM_SPI_CS2_MODE_P156_MASK
976 .name
= "pcm_spi_cs3",
979 REG_GPIO_SPI_CS1_MODE
,
980 GPIO_PCM_SPI_CS3_MODE_MASK
,
981 GPIO_PCM_SPI_CS3_MODE_MASK
985 .name
= "pcm_spi_cs4",
988 REG_GPIO_SPI_CS1_MODE
,
989 GPIO_PCM_SPI_CS4_MODE_MASK
,
990 GPIO_PCM_SPI_CS4_MODE_MASK
996 static const struct airoha_pinctrl_func_group i2s_func_group
[] = {
1001 REG_GPIO_2ND_I2C_MODE
,
1009 static const struct airoha_pinctrl_func_group emmc_func_group
[] = {
1015 GPIO_EMMC_MODE_MASK
,
1022 static const struct airoha_pinctrl_func_group pnand_func_group
[] = {
1028 GPIO_PARALLEL_NAND_MODE_MASK
,
1029 GPIO_PARALLEL_NAND_MODE_MASK
1035 static const struct airoha_pinctrl_func_group pcie_reset_func_group
[] = {
1037 .name
= "pcie_reset0",
1041 GPIO_PCIE_RESET0_MASK
,
1042 GPIO_PCIE_RESET0_MASK
1046 .name
= "pcie_reset1",
1050 GPIO_PCIE_RESET1_MASK
,
1051 GPIO_PCIE_RESET1_MASK
1055 .name
= "pcie_reset2",
1059 GPIO_PCIE_RESET2_MASK
,
1060 GPIO_PCIE_RESET2_MASK
1067 static const struct airoha_pinctrl_func_group pwm_func_group
[] = {
1071 AIROHA_FUNC_PWM_MUX
,
1072 REG_GPIO_FLASH_MODE_CFG
,
1073 GPIO0_FLASH_MODE_CFG
,
1074 GPIO0_FLASH_MODE_CFG
1080 AIROHA_FUNC_PWM_MUX
,
1081 REG_GPIO_FLASH_MODE_CFG
,
1082 GPIO1_FLASH_MODE_CFG
,
1083 GPIO1_FLASH_MODE_CFG
1089 AIROHA_FUNC_PWM_MUX
,
1090 REG_GPIO_FLASH_MODE_CFG
,
1091 GPIO2_FLASH_MODE_CFG
,
1092 GPIO2_FLASH_MODE_CFG
1098 AIROHA_FUNC_PWM_MUX
,
1099 REG_GPIO_FLASH_MODE_CFG
,
1100 GPIO3_FLASH_MODE_CFG
,
1101 GPIO3_FLASH_MODE_CFG
1107 AIROHA_FUNC_PWM_MUX
,
1108 REG_GPIO_FLASH_MODE_CFG
,
1109 GPIO4_FLASH_MODE_CFG
,
1110 GPIO4_FLASH_MODE_CFG
1116 AIROHA_FUNC_PWM_MUX
,
1117 REG_GPIO_FLASH_MODE_CFG
,
1118 GPIO5_FLASH_MODE_CFG
,
1119 GPIO5_FLASH_MODE_CFG
1125 AIROHA_FUNC_PWM_MUX
,
1126 REG_GPIO_FLASH_MODE_CFG
,
1127 GPIO6_FLASH_MODE_CFG
,
1128 GPIO6_FLASH_MODE_CFG
1134 AIROHA_FUNC_PWM_MUX
,
1135 REG_GPIO_FLASH_MODE_CFG
,
1136 GPIO7_FLASH_MODE_CFG
,
1137 GPIO7_FLASH_MODE_CFG
1143 AIROHA_FUNC_PWM_MUX
,
1144 REG_GPIO_FLASH_MODE_CFG
,
1145 GPIO8_FLASH_MODE_CFG
,
1146 GPIO8_FLASH_MODE_CFG
1152 AIROHA_FUNC_PWM_MUX
,
1153 REG_GPIO_FLASH_MODE_CFG
,
1154 GPIO9_FLASH_MODE_CFG
,
1155 GPIO9_FLASH_MODE_CFG
1161 AIROHA_FUNC_PWM_MUX
,
1162 REG_GPIO_FLASH_MODE_CFG
,
1163 GPIO10_FLASH_MODE_CFG
,
1164 GPIO10_FLASH_MODE_CFG
1170 AIROHA_FUNC_PWM_MUX
,
1171 REG_GPIO_FLASH_MODE_CFG
,
1172 GPIO11_FLASH_MODE_CFG
,
1173 GPIO11_FLASH_MODE_CFG
1179 AIROHA_FUNC_PWM_MUX
,
1180 REG_GPIO_FLASH_MODE_CFG
,
1181 GPIO12_FLASH_MODE_CFG
,
1182 GPIO12_FLASH_MODE_CFG
1188 AIROHA_FUNC_PWM_MUX
,
1189 REG_GPIO_FLASH_MODE_CFG
,
1190 GPIO13_FLASH_MODE_CFG
,
1191 GPIO13_FLASH_MODE_CFG
1197 AIROHA_FUNC_PWM_MUX
,
1198 REG_GPIO_FLASH_MODE_CFG
,
1199 GPIO14_FLASH_MODE_CFG
,
1200 GPIO14_FLASH_MODE_CFG
1206 AIROHA_FUNC_PWM_MUX
,
1207 REG_GPIO_FLASH_MODE_CFG
,
1208 GPIO15_FLASH_MODE_CFG
,
1209 GPIO15_FLASH_MODE_CFG
1215 AIROHA_FUNC_PWM_EXT_MUX
,
1216 REG_GPIO_FLASH_MODE_CFG_EXT
,
1217 GPIO16_FLASH_MODE_CFG
,
1218 GPIO16_FLASH_MODE_CFG
1224 AIROHA_FUNC_PWM_EXT_MUX
,
1225 REG_GPIO_FLASH_MODE_CFG_EXT
,
1226 GPIO17_FLASH_MODE_CFG
,
1227 GPIO17_FLASH_MODE_CFG
1233 AIROHA_FUNC_PWM_EXT_MUX
,
1234 REG_GPIO_FLASH_MODE_CFG_EXT
,
1235 GPIO18_FLASH_MODE_CFG
,
1236 GPIO18_FLASH_MODE_CFG
1242 AIROHA_FUNC_PWM_EXT_MUX
,
1243 REG_GPIO_FLASH_MODE_CFG_EXT
,
1244 GPIO19_FLASH_MODE_CFG
,
1245 GPIO19_FLASH_MODE_CFG
1251 AIROHA_FUNC_PWM_EXT_MUX
,
1252 REG_GPIO_FLASH_MODE_CFG_EXT
,
1253 GPIO20_FLASH_MODE_CFG
,
1254 GPIO20_FLASH_MODE_CFG
1260 AIROHA_FUNC_PWM_EXT_MUX
,
1261 REG_GPIO_FLASH_MODE_CFG_EXT
,
1262 GPIO21_FLASH_MODE_CFG
,
1263 GPIO21_FLASH_MODE_CFG
1269 AIROHA_FUNC_PWM_EXT_MUX
,
1270 REG_GPIO_FLASH_MODE_CFG_EXT
,
1271 GPIO22_FLASH_MODE_CFG
,
1272 GPIO22_FLASH_MODE_CFG
1278 AIROHA_FUNC_PWM_EXT_MUX
,
1279 REG_GPIO_FLASH_MODE_CFG_EXT
,
1280 GPIO23_FLASH_MODE_CFG
,
1281 GPIO23_FLASH_MODE_CFG
1287 AIROHA_FUNC_PWM_EXT_MUX
,
1288 REG_GPIO_FLASH_MODE_CFG_EXT
,
1289 GPIO24_FLASH_MODE_CFG
,
1290 GPIO24_FLASH_MODE_CFG
1296 AIROHA_FUNC_PWM_EXT_MUX
,
1297 REG_GPIO_FLASH_MODE_CFG_EXT
,
1298 GPIO25_FLASH_MODE_CFG
,
1299 GPIO25_FLASH_MODE_CFG
1305 AIROHA_FUNC_PWM_EXT_MUX
,
1306 REG_GPIO_FLASH_MODE_CFG_EXT
,
1307 GPIO26_FLASH_MODE_CFG
,
1308 GPIO26_FLASH_MODE_CFG
1314 AIROHA_FUNC_PWM_EXT_MUX
,
1315 REG_GPIO_FLASH_MODE_CFG_EXT
,
1316 GPIO27_FLASH_MODE_CFG
,
1317 GPIO27_FLASH_MODE_CFG
1323 AIROHA_FUNC_PWM_EXT_MUX
,
1324 REG_GPIO_FLASH_MODE_CFG_EXT
,
1325 GPIO28_FLASH_MODE_CFG
,
1326 GPIO28_FLASH_MODE_CFG
1332 AIROHA_FUNC_PWM_EXT_MUX
,
1333 REG_GPIO_FLASH_MODE_CFG_EXT
,
1334 GPIO29_FLASH_MODE_CFG
,
1335 GPIO29_FLASH_MODE_CFG
1341 AIROHA_FUNC_PWM_EXT_MUX
,
1342 REG_GPIO_FLASH_MODE_CFG_EXT
,
1343 GPIO30_FLASH_MODE_CFG
,
1344 GPIO30_FLASH_MODE_CFG
1350 AIROHA_FUNC_PWM_EXT_MUX
,
1351 REG_GPIO_FLASH_MODE_CFG_EXT
,
1352 GPIO31_FLASH_MODE_CFG
,
1353 GPIO31_FLASH_MODE_CFG
1359 AIROHA_FUNC_PWM_EXT_MUX
,
1360 REG_GPIO_FLASH_MODE_CFG_EXT
,
1361 GPIO36_FLASH_MODE_CFG
,
1362 GPIO36_FLASH_MODE_CFG
1368 AIROHA_FUNC_PWM_EXT_MUX
,
1369 REG_GPIO_FLASH_MODE_CFG_EXT
,
1370 GPIO37_FLASH_MODE_CFG
,
1371 GPIO37_FLASH_MODE_CFG
1377 AIROHA_FUNC_PWM_EXT_MUX
,
1378 REG_GPIO_FLASH_MODE_CFG_EXT
,
1379 GPIO38_FLASH_MODE_CFG
,
1380 GPIO38_FLASH_MODE_CFG
1386 AIROHA_FUNC_PWM_EXT_MUX
,
1387 REG_GPIO_FLASH_MODE_CFG_EXT
,
1388 GPIO39_FLASH_MODE_CFG
,
1389 GPIO39_FLASH_MODE_CFG
1395 AIROHA_FUNC_PWM_EXT_MUX
,
1396 REG_GPIO_FLASH_MODE_CFG_EXT
,
1397 GPIO40_FLASH_MODE_CFG
,
1398 GPIO40_FLASH_MODE_CFG
1404 AIROHA_FUNC_PWM_EXT_MUX
,
1405 REG_GPIO_FLASH_MODE_CFG_EXT
,
1406 GPIO41_FLASH_MODE_CFG
,
1407 GPIO41_FLASH_MODE_CFG
1413 AIROHA_FUNC_PWM_EXT_MUX
,
1414 REG_GPIO_FLASH_MODE_CFG_EXT
,
1415 GPIO42_FLASH_MODE_CFG
,
1416 GPIO42_FLASH_MODE_CFG
1422 AIROHA_FUNC_PWM_EXT_MUX
,
1423 REG_GPIO_FLASH_MODE_CFG_EXT
,
1424 GPIO43_FLASH_MODE_CFG
,
1425 GPIO43_FLASH_MODE_CFG
1431 AIROHA_FUNC_PWM_EXT_MUX
,
1432 REG_GPIO_FLASH_MODE_CFG_EXT
,
1433 GPIO44_FLASH_MODE_CFG
,
1434 GPIO44_FLASH_MODE_CFG
1440 AIROHA_FUNC_PWM_EXT_MUX
,
1441 REG_GPIO_FLASH_MODE_CFG_EXT
,
1442 GPIO45_FLASH_MODE_CFG
,
1443 GPIO45_FLASH_MODE_CFG
1449 AIROHA_FUNC_PWM_EXT_MUX
,
1450 REG_GPIO_FLASH_MODE_CFG_EXT
,
1451 GPIO46_FLASH_MODE_CFG
,
1452 GPIO46_FLASH_MODE_CFG
1458 AIROHA_FUNC_PWM_EXT_MUX
,
1459 REG_GPIO_FLASH_MODE_CFG_EXT
,
1460 GPIO47_FLASH_MODE_CFG
,
1461 GPIO47_FLASH_MODE_CFG
1467 static const struct airoha_pinctrl_func_group phy1_led0_func_group
[] = {
1472 REG_GPIO_2ND_I2C_MODE
,
1473 GPIO_LAN0_LED0_MODE_MASK
,
1474 GPIO_LAN0_LED0_MODE_MASK
1478 REG_LAN_LED0_MAPPING
,
1479 LAN1_LED_MAPPING_MASK
,
1487 REG_GPIO_2ND_I2C_MODE
,
1488 GPIO_LAN1_LED0_MODE_MASK
,
1489 GPIO_LAN1_LED0_MODE_MASK
1493 REG_LAN_LED0_MAPPING
,
1494 LAN2_LED_MAPPING_MASK
,
1502 REG_GPIO_2ND_I2C_MODE
,
1503 GPIO_LAN2_LED0_MODE_MASK
,
1504 GPIO_LAN2_LED0_MODE_MASK
1508 REG_LAN_LED0_MAPPING
,
1509 LAN3_LED_MAPPING_MASK
,
1517 REG_GPIO_2ND_I2C_MODE
,
1518 GPIO_LAN3_LED0_MODE_MASK
,
1519 GPIO_LAN3_LED0_MODE_MASK
1523 REG_LAN_LED0_MAPPING
,
1524 LAN4_LED_MAPPING_MASK
,
1531 static const struct airoha_pinctrl_func_group phy2_led0_func_group
[] = {
1536 REG_GPIO_2ND_I2C_MODE
,
1537 GPIO_LAN0_LED0_MODE_MASK
,
1538 GPIO_LAN0_LED0_MODE_MASK
1542 REG_LAN_LED0_MAPPING
,
1543 LAN1_LED_MAPPING_MASK
,
1551 REG_GPIO_2ND_I2C_MODE
,
1552 GPIO_LAN1_LED0_MODE_MASK
,
1553 GPIO_LAN1_LED0_MODE_MASK
1557 REG_LAN_LED0_MAPPING
,
1558 LAN2_LED_MAPPING_MASK
,
1566 REG_GPIO_2ND_I2C_MODE
,
1567 GPIO_LAN2_LED0_MODE_MASK
,
1568 GPIO_LAN2_LED0_MODE_MASK
1572 REG_LAN_LED0_MAPPING
,
1573 LAN3_LED_MAPPING_MASK
,
1581 REG_GPIO_2ND_I2C_MODE
,
1582 GPIO_LAN3_LED0_MODE_MASK
,
1583 GPIO_LAN3_LED0_MODE_MASK
1587 REG_LAN_LED0_MAPPING
,
1588 LAN4_LED_MAPPING_MASK
,
1595 static const struct airoha_pinctrl_func_group phy3_led0_func_group
[] = {
1600 REG_GPIO_2ND_I2C_MODE
,
1601 GPIO_LAN0_LED0_MODE_MASK
,
1602 GPIO_LAN0_LED0_MODE_MASK
1606 REG_LAN_LED0_MAPPING
,
1607 LAN1_LED_MAPPING_MASK
,
1615 REG_GPIO_2ND_I2C_MODE
,
1616 GPIO_LAN1_LED0_MODE_MASK
,
1617 GPIO_LAN1_LED0_MODE_MASK
1621 REG_LAN_LED0_MAPPING
,
1622 LAN2_LED_MAPPING_MASK
,
1630 REG_GPIO_2ND_I2C_MODE
,
1631 GPIO_LAN2_LED0_MODE_MASK
,
1632 GPIO_LAN2_LED0_MODE_MASK
1636 REG_LAN_LED0_MAPPING
,
1637 LAN3_LED_MAPPING_MASK
,
1645 REG_GPIO_2ND_I2C_MODE
,
1646 GPIO_LAN3_LED0_MODE_MASK
,
1647 GPIO_LAN3_LED0_MODE_MASK
1651 REG_LAN_LED0_MAPPING
,
1652 LAN4_LED_MAPPING_MASK
,
1659 static const struct airoha_pinctrl_func_group phy4_led0_func_group
[] = {
1664 REG_GPIO_2ND_I2C_MODE
,
1665 GPIO_LAN0_LED0_MODE_MASK
,
1666 GPIO_LAN0_LED0_MODE_MASK
1670 REG_LAN_LED0_MAPPING
,
1671 LAN1_LED_MAPPING_MASK
,
1679 REG_GPIO_2ND_I2C_MODE
,
1680 GPIO_LAN1_LED0_MODE_MASK
,
1681 GPIO_LAN1_LED0_MODE_MASK
1685 REG_LAN_LED0_MAPPING
,
1686 LAN2_LED_MAPPING_MASK
,
1694 REG_GPIO_2ND_I2C_MODE
,
1695 GPIO_LAN2_LED0_MODE_MASK
,
1696 GPIO_LAN2_LED0_MODE_MASK
1700 REG_LAN_LED0_MAPPING
,
1701 LAN3_LED_MAPPING_MASK
,
1709 REG_GPIO_2ND_I2C_MODE
,
1710 GPIO_LAN3_LED0_MODE_MASK
,
1711 GPIO_LAN3_LED0_MODE_MASK
1715 REG_LAN_LED0_MAPPING
,
1716 LAN4_LED_MAPPING_MASK
,
1723 static const struct airoha_pinctrl_func_group phy1_led1_func_group
[] = {
1728 REG_GPIO_2ND_I2C_MODE
,
1729 GPIO_LAN0_LED1_MODE_MASK
,
1730 GPIO_LAN0_LED1_MODE_MASK
1734 REG_LAN_LED1_MAPPING
,
1735 LAN1_LED_MAPPING_MASK
,
1743 REG_GPIO_2ND_I2C_MODE
,
1744 GPIO_LAN1_LED1_MODE_MASK
,
1745 GPIO_LAN1_LED1_MODE_MASK
1749 REG_LAN_LED1_MAPPING
,
1750 LAN2_LED_MAPPING_MASK
,
1758 REG_GPIO_2ND_I2C_MODE
,
1759 GPIO_LAN2_LED1_MODE_MASK
,
1760 GPIO_LAN2_LED1_MODE_MASK
1764 REG_LAN_LED1_MAPPING
,
1765 LAN3_LED_MAPPING_MASK
,
1773 REG_GPIO_2ND_I2C_MODE
,
1774 GPIO_LAN3_LED0_MODE_MASK
,
1775 GPIO_LAN3_LED0_MODE_MASK
1779 REG_LAN_LED1_MAPPING
,
1780 LAN4_LED_MAPPING_MASK
,
1787 static const struct airoha_pinctrl_func_group phy2_led1_func_group
[] = {
1792 REG_GPIO_2ND_I2C_MODE
,
1793 GPIO_LAN0_LED1_MODE_MASK
,
1794 GPIO_LAN0_LED1_MODE_MASK
1798 REG_LAN_LED1_MAPPING
,
1799 LAN1_LED_MAPPING_MASK
,
1807 REG_GPIO_2ND_I2C_MODE
,
1808 GPIO_LAN1_LED1_MODE_MASK
,
1809 GPIO_LAN1_LED1_MODE_MASK
1813 REG_LAN_LED1_MAPPING
,
1814 LAN2_LED_MAPPING_MASK
,
1822 REG_GPIO_2ND_I2C_MODE
,
1823 GPIO_LAN2_LED1_MODE_MASK
,
1824 GPIO_LAN2_LED1_MODE_MASK
1828 REG_LAN_LED1_MAPPING
,
1829 LAN3_LED_MAPPING_MASK
,
1837 REG_GPIO_2ND_I2C_MODE
,
1838 GPIO_LAN3_LED0_MODE_MASK
,
1839 GPIO_LAN3_LED0_MODE_MASK
1843 REG_LAN_LED1_MAPPING
,
1844 LAN4_LED_MAPPING_MASK
,
1851 static const struct airoha_pinctrl_func_group phy3_led1_func_group
[] = {
1856 REG_GPIO_2ND_I2C_MODE
,
1857 GPIO_LAN0_LED1_MODE_MASK
,
1858 GPIO_LAN0_LED1_MODE_MASK
1862 REG_LAN_LED1_MAPPING
,
1863 LAN1_LED_MAPPING_MASK
,
1871 REG_GPIO_2ND_I2C_MODE
,
1872 GPIO_LAN1_LED1_MODE_MASK
,
1873 GPIO_LAN1_LED1_MODE_MASK
1877 REG_LAN_LED1_MAPPING
,
1878 LAN2_LED_MAPPING_MASK
,
1886 REG_GPIO_2ND_I2C_MODE
,
1887 GPIO_LAN2_LED1_MODE_MASK
,
1888 GPIO_LAN2_LED1_MODE_MASK
1892 REG_LAN_LED1_MAPPING
,
1893 LAN3_LED_MAPPING_MASK
,
1901 REG_GPIO_2ND_I2C_MODE
,
1902 GPIO_LAN3_LED0_MODE_MASK
,
1903 GPIO_LAN3_LED0_MODE_MASK
1907 REG_LAN_LED1_MAPPING
,
1908 LAN4_LED_MAPPING_MASK
,
1915 static const struct airoha_pinctrl_func_group phy4_led1_func_group
[] = {
1920 REG_GPIO_2ND_I2C_MODE
,
1921 GPIO_LAN0_LED1_MODE_MASK
,
1922 GPIO_LAN0_LED1_MODE_MASK
1926 REG_LAN_LED1_MAPPING
,
1927 LAN1_LED_MAPPING_MASK
,
1935 REG_GPIO_2ND_I2C_MODE
,
1936 GPIO_LAN1_LED1_MODE_MASK
,
1937 GPIO_LAN1_LED1_MODE_MASK
1941 REG_LAN_LED1_MAPPING
,
1942 LAN2_LED_MAPPING_MASK
,
1950 REG_GPIO_2ND_I2C_MODE
,
1951 GPIO_LAN2_LED1_MODE_MASK
,
1952 GPIO_LAN2_LED1_MODE_MASK
1956 REG_LAN_LED1_MAPPING
,
1957 LAN3_LED_MAPPING_MASK
,
1965 REG_GPIO_2ND_I2C_MODE
,
1966 GPIO_LAN3_LED0_MODE_MASK
,
1967 GPIO_LAN3_LED0_MODE_MASK
1971 REG_LAN_LED1_MAPPING
,
1972 LAN4_LED_MAPPING_MASK
,
1979 static const struct airoha_pinctrl_func airoha_pinctrl_funcs
[] = {
1980 PINCTRL_FUNC_DESC(pon
),
1981 PINCTRL_FUNC_DESC(tod_1pps
),
1982 PINCTRL_FUNC_DESC(sipo
),
1983 PINCTRL_FUNC_DESC(mdio
),
1984 PINCTRL_FUNC_DESC(uart
),
1985 PINCTRL_FUNC_DESC(i2c
),
1986 PINCTRL_FUNC_DESC(jtag
),
1987 PINCTRL_FUNC_DESC(pcm
),
1988 PINCTRL_FUNC_DESC(spi
),
1989 PINCTRL_FUNC_DESC(pcm_spi
),
1990 PINCTRL_FUNC_DESC(i2s
),
1991 PINCTRL_FUNC_DESC(emmc
),
1992 PINCTRL_FUNC_DESC(pnand
),
1993 PINCTRL_FUNC_DESC(pcie_reset
),
1994 PINCTRL_FUNC_DESC(pwm
),
1995 PINCTRL_FUNC_DESC(phy1_led0
),
1996 PINCTRL_FUNC_DESC(phy2_led0
),
1997 PINCTRL_FUNC_DESC(phy3_led0
),
1998 PINCTRL_FUNC_DESC(phy4_led0
),
1999 PINCTRL_FUNC_DESC(phy1_led1
),
2000 PINCTRL_FUNC_DESC(phy2_led1
),
2001 PINCTRL_FUNC_DESC(phy3_led1
),
2002 PINCTRL_FUNC_DESC(phy4_led1
),
2005 static const struct airoha_pinctrl_conf airoha_pinctrl_pullup_conf
[] = {
2006 PINCTRL_CONF_DESC(0, REG_I2C_SDA_PU
, UART1_TXD_PU_MASK
),
2007 PINCTRL_CONF_DESC(1, REG_I2C_SDA_PU
, UART1_RXD_PU_MASK
),
2008 PINCTRL_CONF_DESC(2, REG_I2C_SDA_PU
, I2C_SDA_PU_MASK
),
2009 PINCTRL_CONF_DESC(3, REG_I2C_SDA_PU
, I2C_SCL_PU_MASK
),
2010 PINCTRL_CONF_DESC(4, REG_I2C_SDA_PU
, SPI_CS0_PU_MASK
),
2011 PINCTRL_CONF_DESC(5, REG_I2C_SDA_PU
, SPI_CLK_PU_MASK
),
2012 PINCTRL_CONF_DESC(6, REG_I2C_SDA_PU
, SPI_MOSI_PU_MASK
),
2013 PINCTRL_CONF_DESC(7, REG_I2C_SDA_PU
, SPI_MISO_PU_MASK
),
2014 PINCTRL_CONF_DESC(13, REG_GPIO_L_PU
, BIT(0)),
2015 PINCTRL_CONF_DESC(14, REG_GPIO_L_PU
, BIT(1)),
2016 PINCTRL_CONF_DESC(15, REG_GPIO_L_PU
, BIT(2)),
2017 PINCTRL_CONF_DESC(16, REG_GPIO_L_PU
, BIT(3)),
2018 PINCTRL_CONF_DESC(17, REG_GPIO_L_PU
, BIT(4)),
2019 PINCTRL_CONF_DESC(18, REG_GPIO_L_PU
, BIT(5)),
2020 PINCTRL_CONF_DESC(19, REG_GPIO_L_PU
, BIT(6)),
2021 PINCTRL_CONF_DESC(20, REG_GPIO_L_PU
, BIT(7)),
2022 PINCTRL_CONF_DESC(21, REG_GPIO_L_PU
, BIT(8)),
2023 PINCTRL_CONF_DESC(22, REG_GPIO_L_PU
, BIT(9)),
2024 PINCTRL_CONF_DESC(23, REG_GPIO_L_PU
, BIT(10)),
2025 PINCTRL_CONF_DESC(24, REG_GPIO_L_PU
, BIT(11)),
2026 PINCTRL_CONF_DESC(25, REG_GPIO_L_PU
, BIT(12)),
2027 PINCTRL_CONF_DESC(26, REG_GPIO_L_PU
, BIT(13)),
2028 PINCTRL_CONF_DESC(27, REG_GPIO_L_PU
, BIT(14)),
2029 PINCTRL_CONF_DESC(28, REG_GPIO_L_PU
, BIT(15)),
2030 PINCTRL_CONF_DESC(29, REG_GPIO_L_PU
, BIT(16)),
2031 PINCTRL_CONF_DESC(30, REG_GPIO_L_PU
, BIT(17)),
2032 PINCTRL_CONF_DESC(31, REG_GPIO_L_PU
, BIT(18)),
2033 PINCTRL_CONF_DESC(32, REG_GPIO_L_PU
, BIT(18)),
2034 PINCTRL_CONF_DESC(33, REG_GPIO_L_PU
, BIT(20)),
2035 PINCTRL_CONF_DESC(34, REG_GPIO_L_PU
, BIT(21)),
2036 PINCTRL_CONF_DESC(35, REG_GPIO_L_PU
, BIT(22)),
2037 PINCTRL_CONF_DESC(36, REG_GPIO_L_PU
, BIT(23)),
2038 PINCTRL_CONF_DESC(37, REG_GPIO_L_PU
, BIT(24)),
2039 PINCTRL_CONF_DESC(38, REG_GPIO_L_PU
, BIT(25)),
2040 PINCTRL_CONF_DESC(39, REG_GPIO_L_PU
, BIT(26)),
2041 PINCTRL_CONF_DESC(40, REG_GPIO_L_PU
, BIT(27)),
2042 PINCTRL_CONF_DESC(41, REG_GPIO_L_PU
, BIT(28)),
2043 PINCTRL_CONF_DESC(42, REG_GPIO_L_PU
, BIT(29)),
2044 PINCTRL_CONF_DESC(43, REG_GPIO_L_PU
, BIT(30)),
2045 PINCTRL_CONF_DESC(44, REG_GPIO_L_PU
, BIT(31)),
2046 PINCTRL_CONF_DESC(45, REG_GPIO_H_PU
, BIT(0)),
2047 PINCTRL_CONF_DESC(46, REG_GPIO_H_PU
, BIT(1)),
2048 PINCTRL_CONF_DESC(47, REG_GPIO_H_PU
, BIT(2)),
2049 PINCTRL_CONF_DESC(48, REG_GPIO_H_PU
, BIT(3)),
2050 PINCTRL_CONF_DESC(49, REG_GPIO_H_PU
, BIT(4)),
2051 PINCTRL_CONF_DESC(50, REG_GPIO_H_PU
, BIT(5)),
2052 PINCTRL_CONF_DESC(51, REG_GPIO_H_PU
, BIT(6)),
2053 PINCTRL_CONF_DESC(52, REG_GPIO_H_PU
, BIT(7)),
2054 PINCTRL_CONF_DESC(53, REG_GPIO_H_PU
, BIT(8)),
2055 PINCTRL_CONF_DESC(54, REG_GPIO_H_PU
, BIT(9)),
2056 PINCTRL_CONF_DESC(55, REG_GPIO_H_PU
, BIT(10)),
2057 PINCTRL_CONF_DESC(56, REG_GPIO_H_PU
, BIT(11)),
2058 PINCTRL_CONF_DESC(57, REG_GPIO_H_PU
, BIT(12)),
2059 PINCTRL_CONF_DESC(58, REG_GPIO_H_PU
, BIT(13)),
2060 PINCTRL_CONF_DESC(59, REG_GPIO_H_PU
, BIT(14)),
2061 PINCTRL_CONF_DESC(61, REG_I2C_SDA_PU
, PCIE0_RESET_PU_MASK
),
2062 PINCTRL_CONF_DESC(62, REG_I2C_SDA_PU
, PCIE1_RESET_PU_MASK
),
2063 PINCTRL_CONF_DESC(63, REG_I2C_SDA_PU
, PCIE2_RESET_PU_MASK
),
2066 static const struct airoha_pinctrl_conf airoha_pinctrl_pulldown_conf
[] = {
2067 PINCTRL_CONF_DESC(0, REG_I2C_SDA_PD
, UART1_TXD_PD_MASK
),
2068 PINCTRL_CONF_DESC(1, REG_I2C_SDA_PD
, UART1_RXD_PD_MASK
),
2069 PINCTRL_CONF_DESC(2, REG_I2C_SDA_PD
, I2C_SDA_PD_MASK
),
2070 PINCTRL_CONF_DESC(3, REG_I2C_SDA_PD
, I2C_SCL_PD_MASK
),
2071 PINCTRL_CONF_DESC(4, REG_I2C_SDA_PD
, SPI_CS0_PD_MASK
),
2072 PINCTRL_CONF_DESC(5, REG_I2C_SDA_PD
, SPI_CLK_PD_MASK
),
2073 PINCTRL_CONF_DESC(6, REG_I2C_SDA_PD
, SPI_MOSI_PD_MASK
),
2074 PINCTRL_CONF_DESC(7, REG_I2C_SDA_PD
, SPI_MISO_PD_MASK
),
2075 PINCTRL_CONF_DESC(13, REG_GPIO_L_PD
, BIT(0)),
2076 PINCTRL_CONF_DESC(14, REG_GPIO_L_PD
, BIT(1)),
2077 PINCTRL_CONF_DESC(15, REG_GPIO_L_PD
, BIT(2)),
2078 PINCTRL_CONF_DESC(16, REG_GPIO_L_PD
, BIT(3)),
2079 PINCTRL_CONF_DESC(17, REG_GPIO_L_PD
, BIT(4)),
2080 PINCTRL_CONF_DESC(18, REG_GPIO_L_PD
, BIT(5)),
2081 PINCTRL_CONF_DESC(19, REG_GPIO_L_PD
, BIT(6)),
2082 PINCTRL_CONF_DESC(20, REG_GPIO_L_PD
, BIT(7)),
2083 PINCTRL_CONF_DESC(21, REG_GPIO_L_PD
, BIT(8)),
2084 PINCTRL_CONF_DESC(22, REG_GPIO_L_PD
, BIT(9)),
2085 PINCTRL_CONF_DESC(23, REG_GPIO_L_PD
, BIT(10)),
2086 PINCTRL_CONF_DESC(24, REG_GPIO_L_PD
, BIT(11)),
2087 PINCTRL_CONF_DESC(25, REG_GPIO_L_PD
, BIT(12)),
2088 PINCTRL_CONF_DESC(26, REG_GPIO_L_PD
, BIT(13)),
2089 PINCTRL_CONF_DESC(27, REG_GPIO_L_PD
, BIT(14)),
2090 PINCTRL_CONF_DESC(28, REG_GPIO_L_PD
, BIT(15)),
2091 PINCTRL_CONF_DESC(29, REG_GPIO_L_PD
, BIT(16)),
2092 PINCTRL_CONF_DESC(30, REG_GPIO_L_PD
, BIT(17)),
2093 PINCTRL_CONF_DESC(31, REG_GPIO_L_PD
, BIT(18)),
2094 PINCTRL_CONF_DESC(32, REG_GPIO_L_PD
, BIT(18)),
2095 PINCTRL_CONF_DESC(33, REG_GPIO_L_PD
, BIT(20)),
2096 PINCTRL_CONF_DESC(34, REG_GPIO_L_PD
, BIT(21)),
2097 PINCTRL_CONF_DESC(35, REG_GPIO_L_PD
, BIT(22)),
2098 PINCTRL_CONF_DESC(36, REG_GPIO_L_PD
, BIT(23)),
2099 PINCTRL_CONF_DESC(37, REG_GPIO_L_PD
, BIT(24)),
2100 PINCTRL_CONF_DESC(38, REG_GPIO_L_PD
, BIT(25)),
2101 PINCTRL_CONF_DESC(39, REG_GPIO_L_PD
, BIT(26)),
2102 PINCTRL_CONF_DESC(40, REG_GPIO_L_PD
, BIT(27)),
2103 PINCTRL_CONF_DESC(41, REG_GPIO_L_PD
, BIT(28)),
2104 PINCTRL_CONF_DESC(42, REG_GPIO_L_PD
, BIT(29)),
2105 PINCTRL_CONF_DESC(43, REG_GPIO_L_PD
, BIT(30)),
2106 PINCTRL_CONF_DESC(44, REG_GPIO_L_PD
, BIT(31)),
2107 PINCTRL_CONF_DESC(45, REG_GPIO_H_PD
, BIT(0)),
2108 PINCTRL_CONF_DESC(46, REG_GPIO_H_PD
, BIT(1)),
2109 PINCTRL_CONF_DESC(47, REG_GPIO_H_PD
, BIT(2)),
2110 PINCTRL_CONF_DESC(48, REG_GPIO_H_PD
, BIT(3)),
2111 PINCTRL_CONF_DESC(49, REG_GPIO_H_PD
, BIT(4)),
2112 PINCTRL_CONF_DESC(50, REG_GPIO_H_PD
, BIT(5)),
2113 PINCTRL_CONF_DESC(51, REG_GPIO_H_PD
, BIT(6)),
2114 PINCTRL_CONF_DESC(52, REG_GPIO_H_PD
, BIT(7)),
2115 PINCTRL_CONF_DESC(53, REG_GPIO_H_PD
, BIT(8)),
2116 PINCTRL_CONF_DESC(54, REG_GPIO_H_PD
, BIT(9)),
2117 PINCTRL_CONF_DESC(55, REG_GPIO_H_PD
, BIT(10)),
2118 PINCTRL_CONF_DESC(56, REG_GPIO_H_PD
, BIT(11)),
2119 PINCTRL_CONF_DESC(57, REG_GPIO_H_PD
, BIT(12)),
2120 PINCTRL_CONF_DESC(58, REG_GPIO_H_PD
, BIT(13)),
2121 PINCTRL_CONF_DESC(59, REG_GPIO_H_PD
, BIT(14)),
2122 PINCTRL_CONF_DESC(61, REG_I2C_SDA_PD
, PCIE0_RESET_PD_MASK
),
2123 PINCTRL_CONF_DESC(62, REG_I2C_SDA_PD
, PCIE1_RESET_PD_MASK
),
2124 PINCTRL_CONF_DESC(63, REG_I2C_SDA_PD
, PCIE2_RESET_PD_MASK
),
2127 static const struct airoha_pinctrl_conf airoha_pinctrl_drive_e2_conf
[] = {
2128 PINCTRL_CONF_DESC(0, REG_I2C_SDA_E2
, UART1_TXD_E2_MASK
),
2129 PINCTRL_CONF_DESC(1, REG_I2C_SDA_E2
, UART1_RXD_E2_MASK
),
2130 PINCTRL_CONF_DESC(2, REG_I2C_SDA_E2
, I2C_SDA_E2_MASK
),
2131 PINCTRL_CONF_DESC(3, REG_I2C_SDA_E2
, I2C_SCL_E2_MASK
),
2132 PINCTRL_CONF_DESC(4, REG_I2C_SDA_E2
, SPI_CS0_E2_MASK
),
2133 PINCTRL_CONF_DESC(5, REG_I2C_SDA_E2
, SPI_CLK_E2_MASK
),
2134 PINCTRL_CONF_DESC(6, REG_I2C_SDA_E2
, SPI_MOSI_E2_MASK
),
2135 PINCTRL_CONF_DESC(7, REG_I2C_SDA_E2
, SPI_MISO_E2_MASK
),
2136 PINCTRL_CONF_DESC(13, REG_GPIO_L_E2
, BIT(0)),
2137 PINCTRL_CONF_DESC(14, REG_GPIO_L_E2
, BIT(1)),
2138 PINCTRL_CONF_DESC(15, REG_GPIO_L_E2
, BIT(2)),
2139 PINCTRL_CONF_DESC(16, REG_GPIO_L_E2
, BIT(3)),
2140 PINCTRL_CONF_DESC(17, REG_GPIO_L_E2
, BIT(4)),
2141 PINCTRL_CONF_DESC(18, REG_GPIO_L_E2
, BIT(5)),
2142 PINCTRL_CONF_DESC(19, REG_GPIO_L_E2
, BIT(6)),
2143 PINCTRL_CONF_DESC(20, REG_GPIO_L_E2
, BIT(7)),
2144 PINCTRL_CONF_DESC(21, REG_GPIO_L_E2
, BIT(8)),
2145 PINCTRL_CONF_DESC(22, REG_GPIO_L_E2
, BIT(9)),
2146 PINCTRL_CONF_DESC(23, REG_GPIO_L_E2
, BIT(10)),
2147 PINCTRL_CONF_DESC(24, REG_GPIO_L_E2
, BIT(11)),
2148 PINCTRL_CONF_DESC(25, REG_GPIO_L_E2
, BIT(12)),
2149 PINCTRL_CONF_DESC(26, REG_GPIO_L_E2
, BIT(13)),
2150 PINCTRL_CONF_DESC(27, REG_GPIO_L_E2
, BIT(14)),
2151 PINCTRL_CONF_DESC(28, REG_GPIO_L_E2
, BIT(15)),
2152 PINCTRL_CONF_DESC(29, REG_GPIO_L_E2
, BIT(16)),
2153 PINCTRL_CONF_DESC(30, REG_GPIO_L_E2
, BIT(17)),
2154 PINCTRL_CONF_DESC(31, REG_GPIO_L_E2
, BIT(18)),
2155 PINCTRL_CONF_DESC(32, REG_GPIO_L_E2
, BIT(18)),
2156 PINCTRL_CONF_DESC(33, REG_GPIO_L_E2
, BIT(20)),
2157 PINCTRL_CONF_DESC(34, REG_GPIO_L_E2
, BIT(21)),
2158 PINCTRL_CONF_DESC(35, REG_GPIO_L_E2
, BIT(22)),
2159 PINCTRL_CONF_DESC(36, REG_GPIO_L_E2
, BIT(23)),
2160 PINCTRL_CONF_DESC(37, REG_GPIO_L_E2
, BIT(24)),
2161 PINCTRL_CONF_DESC(38, REG_GPIO_L_E2
, BIT(25)),
2162 PINCTRL_CONF_DESC(39, REG_GPIO_L_E2
, BIT(26)),
2163 PINCTRL_CONF_DESC(40, REG_GPIO_L_E2
, BIT(27)),
2164 PINCTRL_CONF_DESC(41, REG_GPIO_L_E2
, BIT(28)),
2165 PINCTRL_CONF_DESC(42, REG_GPIO_L_E2
, BIT(29)),
2166 PINCTRL_CONF_DESC(43, REG_GPIO_L_E2
, BIT(30)),
2167 PINCTRL_CONF_DESC(44, REG_GPIO_L_E2
, BIT(31)),
2168 PINCTRL_CONF_DESC(45, REG_GPIO_H_E2
, BIT(0)),
2169 PINCTRL_CONF_DESC(46, REG_GPIO_H_E2
, BIT(1)),
2170 PINCTRL_CONF_DESC(47, REG_GPIO_H_E2
, BIT(2)),
2171 PINCTRL_CONF_DESC(48, REG_GPIO_H_E2
, BIT(3)),
2172 PINCTRL_CONF_DESC(49, REG_GPIO_H_E2
, BIT(4)),
2173 PINCTRL_CONF_DESC(50, REG_GPIO_H_E2
, BIT(5)),
2174 PINCTRL_CONF_DESC(51, REG_GPIO_H_E2
, BIT(6)),
2175 PINCTRL_CONF_DESC(52, REG_GPIO_H_E2
, BIT(7)),
2176 PINCTRL_CONF_DESC(53, REG_GPIO_H_E2
, BIT(8)),
2177 PINCTRL_CONF_DESC(54, REG_GPIO_H_E2
, BIT(9)),
2178 PINCTRL_CONF_DESC(55, REG_GPIO_H_E2
, BIT(10)),
2179 PINCTRL_CONF_DESC(56, REG_GPIO_H_E2
, BIT(11)),
2180 PINCTRL_CONF_DESC(57, REG_GPIO_H_E2
, BIT(12)),
2181 PINCTRL_CONF_DESC(58, REG_GPIO_H_E2
, BIT(13)),
2182 PINCTRL_CONF_DESC(59, REG_GPIO_H_E2
, BIT(14)),
2183 PINCTRL_CONF_DESC(61, REG_I2C_SDA_E2
, PCIE0_RESET_E2_MASK
),
2184 PINCTRL_CONF_DESC(62, REG_I2C_SDA_E2
, PCIE1_RESET_E2_MASK
),
2185 PINCTRL_CONF_DESC(63, REG_I2C_SDA_E2
, PCIE2_RESET_E2_MASK
),
2188 static const struct airoha_pinctrl_conf airoha_pinctrl_drive_e4_conf
[] = {
2189 PINCTRL_CONF_DESC(0, REG_I2C_SDA_E4
, UART1_TXD_E4_MASK
),
2190 PINCTRL_CONF_DESC(1, REG_I2C_SDA_E4
, UART1_RXD_E4_MASK
),
2191 PINCTRL_CONF_DESC(2, REG_I2C_SDA_E4
, I2C_SDA_E4_MASK
),
2192 PINCTRL_CONF_DESC(3, REG_I2C_SDA_E4
, I2C_SCL_E4_MASK
),
2193 PINCTRL_CONF_DESC(4, REG_I2C_SDA_E4
, SPI_CS0_E4_MASK
),
2194 PINCTRL_CONF_DESC(5, REG_I2C_SDA_E4
, SPI_CLK_E4_MASK
),
2195 PINCTRL_CONF_DESC(6, REG_I2C_SDA_E4
, SPI_MOSI_E4_MASK
),
2196 PINCTRL_CONF_DESC(7, REG_I2C_SDA_E4
, SPI_MISO_E4_MASK
),
2197 PINCTRL_CONF_DESC(13, REG_GPIO_L_E4
, BIT(0)),
2198 PINCTRL_CONF_DESC(14, REG_GPIO_L_E4
, BIT(1)),
2199 PINCTRL_CONF_DESC(15, REG_GPIO_L_E4
, BIT(2)),
2200 PINCTRL_CONF_DESC(16, REG_GPIO_L_E4
, BIT(3)),
2201 PINCTRL_CONF_DESC(17, REG_GPIO_L_E4
, BIT(4)),
2202 PINCTRL_CONF_DESC(18, REG_GPIO_L_E4
, BIT(5)),
2203 PINCTRL_CONF_DESC(19, REG_GPIO_L_E4
, BIT(6)),
2204 PINCTRL_CONF_DESC(20, REG_GPIO_L_E4
, BIT(7)),
2205 PINCTRL_CONF_DESC(21, REG_GPIO_L_E4
, BIT(8)),
2206 PINCTRL_CONF_DESC(22, REG_GPIO_L_E4
, BIT(9)),
2207 PINCTRL_CONF_DESC(23, REG_GPIO_L_E4
, BIT(10)),
2208 PINCTRL_CONF_DESC(24, REG_GPIO_L_E4
, BIT(11)),
2209 PINCTRL_CONF_DESC(25, REG_GPIO_L_E4
, BIT(12)),
2210 PINCTRL_CONF_DESC(26, REG_GPIO_L_E4
, BIT(13)),
2211 PINCTRL_CONF_DESC(27, REG_GPIO_L_E4
, BIT(14)),
2212 PINCTRL_CONF_DESC(28, REG_GPIO_L_E4
, BIT(15)),
2213 PINCTRL_CONF_DESC(29, REG_GPIO_L_E4
, BIT(16)),
2214 PINCTRL_CONF_DESC(30, REG_GPIO_L_E4
, BIT(17)),
2215 PINCTRL_CONF_DESC(31, REG_GPIO_L_E4
, BIT(18)),
2216 PINCTRL_CONF_DESC(32, REG_GPIO_L_E4
, BIT(18)),
2217 PINCTRL_CONF_DESC(33, REG_GPIO_L_E4
, BIT(20)),
2218 PINCTRL_CONF_DESC(34, REG_GPIO_L_E4
, BIT(21)),
2219 PINCTRL_CONF_DESC(35, REG_GPIO_L_E4
, BIT(22)),
2220 PINCTRL_CONF_DESC(36, REG_GPIO_L_E4
, BIT(23)),
2221 PINCTRL_CONF_DESC(37, REG_GPIO_L_E4
, BIT(24)),
2222 PINCTRL_CONF_DESC(38, REG_GPIO_L_E4
, BIT(25)),
2223 PINCTRL_CONF_DESC(39, REG_GPIO_L_E4
, BIT(26)),
2224 PINCTRL_CONF_DESC(40, REG_GPIO_L_E4
, BIT(27)),
2225 PINCTRL_CONF_DESC(41, REG_GPIO_L_E4
, BIT(28)),
2226 PINCTRL_CONF_DESC(42, REG_GPIO_L_E4
, BIT(29)),
2227 PINCTRL_CONF_DESC(43, REG_GPIO_L_E4
, BIT(30)),
2228 PINCTRL_CONF_DESC(44, REG_GPIO_L_E4
, BIT(31)),
2229 PINCTRL_CONF_DESC(45, REG_GPIO_H_E4
, BIT(0)),
2230 PINCTRL_CONF_DESC(46, REG_GPIO_H_E4
, BIT(1)),
2231 PINCTRL_CONF_DESC(47, REG_GPIO_H_E4
, BIT(2)),
2232 PINCTRL_CONF_DESC(48, REG_GPIO_H_E4
, BIT(3)),
2233 PINCTRL_CONF_DESC(49, REG_GPIO_H_E4
, BIT(4)),
2234 PINCTRL_CONF_DESC(50, REG_GPIO_H_E4
, BIT(5)),
2235 PINCTRL_CONF_DESC(51, REG_GPIO_H_E4
, BIT(6)),
2236 PINCTRL_CONF_DESC(52, REG_GPIO_H_E4
, BIT(7)),
2237 PINCTRL_CONF_DESC(53, REG_GPIO_H_E4
, BIT(8)),
2238 PINCTRL_CONF_DESC(54, REG_GPIO_H_E4
, BIT(9)),
2239 PINCTRL_CONF_DESC(55, REG_GPIO_H_E4
, BIT(10)),
2240 PINCTRL_CONF_DESC(56, REG_GPIO_H_E4
, BIT(11)),
2241 PINCTRL_CONF_DESC(57, REG_GPIO_H_E4
, BIT(12)),
2242 PINCTRL_CONF_DESC(58, REG_GPIO_H_E4
, BIT(13)),
2243 PINCTRL_CONF_DESC(59, REG_GPIO_H_E4
, BIT(14)),
2244 PINCTRL_CONF_DESC(61, REG_I2C_SDA_E4
, PCIE0_RESET_E4_MASK
),
2245 PINCTRL_CONF_DESC(62, REG_I2C_SDA_E4
, PCIE1_RESET_E4_MASK
),
2246 PINCTRL_CONF_DESC(63, REG_I2C_SDA_E4
, PCIE2_RESET_E4_MASK
),
2249 static const struct airoha_pinctrl_conf airoha_pinctrl_pcie_rst_od_conf
[] = {
2250 PINCTRL_CONF_DESC(61, REG_PCIE_RESET_OD
, PCIE0_RESET_OD_MASK
),
2251 PINCTRL_CONF_DESC(62, REG_PCIE_RESET_OD
, PCIE1_RESET_OD_MASK
),
2252 PINCTRL_CONF_DESC(63, REG_PCIE_RESET_OD
, PCIE2_RESET_OD_MASK
),
2255 static int airoha_convert_pin_to_reg_offset(struct pinctrl_dev
*pctrl_dev
,
2256 struct pinctrl_gpio_range
*range
,
2260 range
= pinctrl_find_gpio_range_from_pin_nolock(pctrl_dev
,
2265 return pin
- range
->pin_base
;
2268 /* gpio callbacks */
2269 static void airoha_gpio_set(struct gpio_chip
*chip
, unsigned int gpio
,
2272 struct airoha_pinctrl
*pinctrl
= gpiochip_get_data(chip
);
2273 u32 offset
= gpio
% AIROHA_PIN_BANK_SIZE
;
2274 u8 index
= gpio
/ AIROHA_PIN_BANK_SIZE
;
2276 regmap_update_bits(pinctrl
->regmap
, pinctrl
->gpiochip
.data
[index
],
2277 BIT(offset
), value
? BIT(offset
) : 0);
2280 static int airoha_gpio_get(struct gpio_chip
*chip
, unsigned int gpio
)
2282 struct airoha_pinctrl
*pinctrl
= gpiochip_get_data(chip
);
2283 u32 val
, pin
= gpio
% AIROHA_PIN_BANK_SIZE
;
2284 u8 index
= gpio
/ AIROHA_PIN_BANK_SIZE
;
2287 err
= regmap_read(pinctrl
->regmap
,
2288 pinctrl
->gpiochip
.data
[index
], &val
);
2290 return err
? err
: !!(val
& BIT(pin
));
2293 static int airoha_gpio_direction_output(struct gpio_chip
*chip
,
2294 unsigned int gpio
, int value
)
2298 err
= pinctrl_gpio_direction_output(chip
, gpio
);
2302 airoha_gpio_set(chip
, gpio
, value
);
2308 static void airoha_irq_unmask(struct irq_data
*data
)
2310 u8 offset
= data
->hwirq
% AIROHA_REG_GPIOCTRL_NUM_PIN
;
2311 u8 index
= data
->hwirq
/ AIROHA_REG_GPIOCTRL_NUM_PIN
;
2312 u32 mask
= GENMASK(2 * offset
+ 1, 2 * offset
);
2313 struct airoha_pinctrl_gpiochip
*gpiochip
;
2314 struct airoha_pinctrl
*pinctrl
;
2315 u32 val
= BIT(2 * offset
);
2317 gpiochip
= irq_data_get_irq_chip_data(data
);
2318 if (WARN_ON_ONCE(data
->hwirq
>= ARRAY_SIZE(gpiochip
->irq_type
)))
2321 pinctrl
= container_of(gpiochip
, struct airoha_pinctrl
, gpiochip
);
2322 switch (gpiochip
->irq_type
[data
->hwirq
]) {
2323 case IRQ_TYPE_LEVEL_LOW
:
2326 case IRQ_TYPE_LEVEL_HIGH
:
2327 regmap_update_bits(pinctrl
->regmap
, gpiochip
->level
[index
],
2330 case IRQ_TYPE_EDGE_FALLING
:
2333 case IRQ_TYPE_EDGE_RISING
:
2334 regmap_update_bits(pinctrl
->regmap
, gpiochip
->edge
[index
],
2337 case IRQ_TYPE_EDGE_BOTH
:
2338 regmap_set_bits(pinctrl
->regmap
, gpiochip
->edge
[index
], mask
);
2345 static void airoha_irq_mask(struct irq_data
*data
)
2347 u8 offset
= data
->hwirq
% AIROHA_REG_GPIOCTRL_NUM_PIN
;
2348 u8 index
= data
->hwirq
/ AIROHA_REG_GPIOCTRL_NUM_PIN
;
2349 u32 mask
= GENMASK(2 * offset
+ 1, 2 * offset
);
2350 struct airoha_pinctrl_gpiochip
*gpiochip
;
2351 struct airoha_pinctrl
*pinctrl
;
2353 gpiochip
= irq_data_get_irq_chip_data(data
);
2354 pinctrl
= container_of(gpiochip
, struct airoha_pinctrl
, gpiochip
);
2356 regmap_clear_bits(pinctrl
->regmap
, gpiochip
->level
[index
], mask
);
2357 regmap_clear_bits(pinctrl
->regmap
, gpiochip
->edge
[index
], mask
);
2360 static int airoha_irq_type(struct irq_data
*data
, unsigned int type
)
2362 struct airoha_pinctrl_gpiochip
*gpiochip
;
2364 gpiochip
= irq_data_get_irq_chip_data(data
);
2365 if (data
->hwirq
>= ARRAY_SIZE(gpiochip
->irq_type
))
2368 if (type
== IRQ_TYPE_PROBE
) {
2369 if (gpiochip
->irq_type
[data
->hwirq
])
2372 type
= IRQ_TYPE_EDGE_RISING
| IRQ_TYPE_EDGE_FALLING
;
2374 gpiochip
->irq_type
[data
->hwirq
] = type
& IRQ_TYPE_SENSE_MASK
;
2379 static irqreturn_t
airoha_irq_handler(int irq
, void *data
)
2381 struct airoha_pinctrl
*pinctrl
= data
;
2382 bool handled
= false;
2385 for (i
= 0; i
< ARRAY_SIZE(irq_status_regs
); i
++) {
2386 struct gpio_irq_chip
*girq
= &pinctrl
->gpiochip
.chip
.irq
;
2388 unsigned long status
;
2391 if (regmap_read(pinctrl
->regmap
, pinctrl
->gpiochip
.status
[i
],
2396 for_each_set_bit(irq
, &status
, AIROHA_PIN_BANK_SIZE
) {
2397 u32 offset
= irq
+ i
* AIROHA_PIN_BANK_SIZE
;
2399 generic_handle_irq(irq_find_mapping(girq
->domain
,
2401 regmap_write(pinctrl
->regmap
,
2402 pinctrl
->gpiochip
.status
[i
], BIT(irq
));
2404 handled
|= !!status
;
2407 return handled
? IRQ_HANDLED
: IRQ_NONE
;
2410 static const struct irq_chip airoha_gpio_irq_chip
= {
2411 .name
= "airoha-gpio-irq",
2412 .irq_unmask
= airoha_irq_unmask
,
2413 .irq_mask
= airoha_irq_mask
,
2414 .irq_mask_ack
= airoha_irq_mask
,
2415 .irq_set_type
= airoha_irq_type
,
2416 .flags
= IRQCHIP_SET_TYPE_MASKED
| IRQCHIP_IMMUTABLE
,
2419 static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl
*pinctrl
,
2420 struct platform_device
*pdev
)
2422 struct airoha_pinctrl_gpiochip
*chip
= &pinctrl
->gpiochip
;
2423 struct gpio_chip
*gc
= &chip
->chip
;
2424 struct gpio_irq_chip
*girq
= &gc
->irq
;
2425 struct device
*dev
= &pdev
->dev
;
2428 chip
->data
= gpio_data_regs
;
2429 chip
->dir
= gpio_dir_regs
;
2430 chip
->out
= gpio_out_regs
;
2431 chip
->status
= irq_status_regs
;
2432 chip
->level
= irq_level_regs
;
2433 chip
->edge
= irq_edge_regs
;
2436 gc
->label
= dev_name(dev
);
2437 gc
->request
= gpiochip_generic_request
;
2438 gc
->free
= gpiochip_generic_free
;
2439 gc
->direction_input
= pinctrl_gpio_direction_input
;
2440 gc
->direction_output
= airoha_gpio_direction_output
;
2441 gc
->set
= airoha_gpio_set
;
2442 gc
->get
= airoha_gpio_get
;
2444 gc
->ngpio
= AIROHA_NUM_PINS
;
2446 girq
->default_type
= IRQ_TYPE_NONE
;
2447 girq
->handler
= handle_simple_irq
;
2448 gpio_irq_chip_set_chip(girq
, &airoha_gpio_irq_chip
);
2450 irq
= platform_get_irq(pdev
, 0);
2454 err
= devm_request_irq(dev
, irq
, airoha_irq_handler
, IRQF_SHARED
,
2455 dev_name(dev
), pinctrl
);
2457 dev_err(dev
, "error requesting irq %d: %d\n", irq
, err
);
2461 return devm_gpiochip_add_data(dev
, gc
, pinctrl
);
2464 /* pinmux callbacks */
2465 static int airoha_pinmux_set_mux(struct pinctrl_dev
*pctrl_dev
,
2466 unsigned int selector
,
2469 struct airoha_pinctrl
*pinctrl
= pinctrl_dev_get_drvdata(pctrl_dev
);
2470 const struct airoha_pinctrl_func
*func
;
2471 struct function_desc
*desc
;
2472 struct group_desc
*grp
;
2475 desc
= pinmux_generic_get_function(pctrl_dev
, selector
);
2479 grp
= pinctrl_generic_get_group(pctrl_dev
, group
);
2483 dev_dbg(pctrl_dev
->dev
, "enable function %s group %s\n",
2484 desc
->func
.name
, grp
->grp
.name
);
2487 for (i
= 0; i
< func
->group_size
; i
++) {
2488 const struct airoha_pinctrl_func_group
*group
;
2491 group
= &func
->groups
[i
];
2492 if (strcmp(group
->name
, grp
->grp
.name
))
2495 for (j
= 0; j
< group
->regmap_size
; j
++) {
2496 switch (group
->regmap
[j
].mux
) {
2497 case AIROHA_FUNC_PWM_EXT_MUX
:
2498 case AIROHA_FUNC_PWM_MUX
:
2499 regmap_update_bits(pinctrl
->regmap
,
2500 group
->regmap
[j
].offset
,
2501 group
->regmap
[j
].mask
,
2502 group
->regmap
[j
].val
);
2505 regmap_update_bits(pinctrl
->chip_scu
,
2506 group
->regmap
[j
].offset
,
2507 group
->regmap
[j
].mask
,
2508 group
->regmap
[j
].val
);
2518 static int airoha_pinmux_set_direction(struct pinctrl_dev
*pctrl_dev
,
2519 struct pinctrl_gpio_range
*range
,
2520 unsigned int p
, bool input
)
2522 struct airoha_pinctrl
*pinctrl
= pinctrl_dev_get_drvdata(pctrl_dev
);
2526 pin
= airoha_convert_pin_to_reg_offset(pctrl_dev
, range
, p
);
2530 /* set output enable */
2531 mask
= BIT(pin
% AIROHA_PIN_BANK_SIZE
);
2532 index
= pin
/ AIROHA_PIN_BANK_SIZE
;
2533 err
= regmap_update_bits(pinctrl
->regmap
, pinctrl
->gpiochip
.out
[index
],
2534 mask
, !input
? mask
: 0);
2539 mask
= BIT(2 * (pin
% AIROHA_REG_GPIOCTRL_NUM_PIN
));
2540 index
= pin
/ AIROHA_REG_GPIOCTRL_NUM_PIN
;
2541 return regmap_update_bits(pinctrl
->regmap
,
2542 pinctrl
->gpiochip
.dir
[index
], mask
,
2546 static const struct pinmux_ops airoha_pmxops
= {
2547 .get_functions_count
= pinmux_generic_get_function_count
,
2548 .get_function_name
= pinmux_generic_get_function_name
,
2549 .get_function_groups
= pinmux_generic_get_function_groups
,
2550 .gpio_set_direction
= airoha_pinmux_set_direction
,
2551 .set_mux
= airoha_pinmux_set_mux
,
2555 /* pinconf callbacks */
2556 static const struct airoha_pinctrl_reg
*
2557 airoha_pinctrl_get_conf_reg(const struct airoha_pinctrl_conf
*conf
,
2558 int conf_size
, int pin
)
2562 for (i
= 0; i
< conf_size
; i
++) {
2563 if (conf
[i
].pin
== pin
)
2564 return &conf
[i
].reg
;
2570 static int airoha_pinctrl_get_conf(struct airoha_pinctrl
*pinctrl
,
2571 const struct airoha_pinctrl_conf
*conf
,
2572 int conf_size
, int pin
, u32
*val
)
2574 const struct airoha_pinctrl_reg
*reg
;
2576 reg
= airoha_pinctrl_get_conf_reg(conf
, conf_size
, pin
);
2580 if (regmap_read(pinctrl
->chip_scu
, reg
->offset
, val
))
2583 *val
= (*val
& reg
->mask
) >> __ffs(reg
->mask
);
2588 static int airoha_pinctrl_set_conf(struct airoha_pinctrl
*pinctrl
,
2589 const struct airoha_pinctrl_conf
*conf
,
2590 int conf_size
, int pin
, u32 val
)
2592 const struct airoha_pinctrl_reg
*reg
= NULL
;
2594 reg
= airoha_pinctrl_get_conf_reg(conf
, conf_size
, pin
);
2599 if (regmap_update_bits(pinctrl
->chip_scu
, reg
->offset
, reg
->mask
,
2600 val
<< __ffs(reg
->mask
)))
2606 #define airoha_pinctrl_get_pullup_conf(pinctrl, pin, val) \
2607 airoha_pinctrl_get_conf((pinctrl), airoha_pinctrl_pullup_conf, \
2608 ARRAY_SIZE(airoha_pinctrl_pullup_conf), \
2610 #define airoha_pinctrl_get_pulldown_conf(pinctrl, pin, val) \
2611 airoha_pinctrl_get_conf((pinctrl), airoha_pinctrl_pulldown_conf, \
2612 ARRAY_SIZE(airoha_pinctrl_pulldown_conf), \
2614 #define airoha_pinctrl_get_drive_e2_conf(pinctrl, pin, val) \
2615 airoha_pinctrl_get_conf((pinctrl), airoha_pinctrl_drive_e2_conf, \
2616 ARRAY_SIZE(airoha_pinctrl_drive_e2_conf), \
2618 #define airoha_pinctrl_get_drive_e4_conf(pinctrl, pin, val) \
2619 airoha_pinctrl_get_conf((pinctrl), airoha_pinctrl_drive_e4_conf, \
2620 ARRAY_SIZE(airoha_pinctrl_drive_e4_conf), \
2622 #define airoha_pinctrl_get_pcie_rst_od_conf(pinctrl, pin, val) \
2623 airoha_pinctrl_get_conf((pinctrl), airoha_pinctrl_pcie_rst_od_conf, \
2624 ARRAY_SIZE(airoha_pinctrl_pcie_rst_od_conf), \
2626 #define airoha_pinctrl_set_pullup_conf(pinctrl, pin, val) \
2627 airoha_pinctrl_set_conf((pinctrl), airoha_pinctrl_pullup_conf, \
2628 ARRAY_SIZE(airoha_pinctrl_pullup_conf), \
2630 #define airoha_pinctrl_set_pulldown_conf(pinctrl, pin, val) \
2631 airoha_pinctrl_set_conf((pinctrl), airoha_pinctrl_pulldown_conf, \
2632 ARRAY_SIZE(airoha_pinctrl_pulldown_conf), \
2634 #define airoha_pinctrl_set_drive_e2_conf(pinctrl, pin, val) \
2635 airoha_pinctrl_set_conf((pinctrl), airoha_pinctrl_drive_e2_conf, \
2636 ARRAY_SIZE(airoha_pinctrl_drive_e2_conf), \
2638 #define airoha_pinctrl_set_drive_e4_conf(pinctrl, pin, val) \
2639 airoha_pinctrl_set_conf((pinctrl), airoha_pinctrl_drive_e4_conf, \
2640 ARRAY_SIZE(airoha_pinctrl_drive_e4_conf), \
2642 #define airoha_pinctrl_set_pcie_rst_od_conf(pinctrl, pin, val) \
2643 airoha_pinctrl_set_conf((pinctrl), airoha_pinctrl_pcie_rst_od_conf, \
2644 ARRAY_SIZE(airoha_pinctrl_pcie_rst_od_conf), \
2647 static int airoha_pinconf_get_direction(struct pinctrl_dev
*pctrl_dev
, u32 p
)
2649 struct airoha_pinctrl
*pinctrl
= pinctrl_dev_get_drvdata(pctrl_dev
);
2654 pin
= airoha_convert_pin_to_reg_offset(pctrl_dev
, NULL
, p
);
2658 index
= pin
/ AIROHA_REG_GPIOCTRL_NUM_PIN
;
2659 err
= regmap_read(pinctrl
->regmap
, pinctrl
->gpiochip
.dir
[index
], &val
);
2663 mask
= BIT(2 * (pin
% AIROHA_REG_GPIOCTRL_NUM_PIN
));
2664 return val
& mask
? PIN_CONFIG_OUTPUT_ENABLE
: PIN_CONFIG_INPUT_ENABLE
;
2667 static int airoha_pinconf_get(struct pinctrl_dev
*pctrl_dev
,
2668 unsigned int pin
, unsigned long *config
)
2670 struct airoha_pinctrl
*pinctrl
= pinctrl_dev_get_drvdata(pctrl_dev
);
2671 enum pin_config_param param
= pinconf_to_config_param(*config
);
2675 case PIN_CONFIG_BIAS_PULL_DOWN
:
2676 case PIN_CONFIG_BIAS_DISABLE
:
2677 case PIN_CONFIG_BIAS_PULL_UP
: {
2678 u32 pull_up
, pull_down
;
2680 if (airoha_pinctrl_get_pullup_conf(pinctrl
, pin
, &pull_up
) ||
2681 airoha_pinctrl_get_pulldown_conf(pinctrl
, pin
, &pull_down
))
2684 if (param
== PIN_CONFIG_BIAS_PULL_UP
&&
2685 !(pull_up
&& !pull_down
))
2687 else if (param
== PIN_CONFIG_BIAS_PULL_DOWN
&&
2688 !(pull_down
&& !pull_up
))
2690 else if (pull_up
|| pull_down
)
2696 case PIN_CONFIG_DRIVE_STRENGTH
: {
2699 if (airoha_pinctrl_get_drive_e2_conf(pinctrl
, pin
, &e2
) ||
2700 airoha_pinctrl_get_drive_e4_conf(pinctrl
, pin
, &e4
))
2706 case PIN_CONFIG_DRIVE_OPEN_DRAIN
:
2707 if (airoha_pinctrl_get_pcie_rst_od_conf(pinctrl
, pin
, &arg
))
2710 case PIN_CONFIG_OUTPUT_ENABLE
:
2711 case PIN_CONFIG_INPUT_ENABLE
:
2712 arg
= airoha_pinconf_get_direction(pctrl_dev
, pin
);
2722 *config
= pinconf_to_config_packed(param
, arg
);
2727 static int airoha_pinconf_set_pin_value(struct pinctrl_dev
*pctrl_dev
,
2728 unsigned int p
, bool value
)
2730 struct airoha_pinctrl
*pinctrl
= pinctrl_dev_get_drvdata(pctrl_dev
);
2733 pin
= airoha_convert_pin_to_reg_offset(pctrl_dev
, NULL
, p
);
2737 airoha_gpio_set(&pinctrl
->gpiochip
.chip
, pin
, value
);
2742 static int airoha_pinconf_set(struct pinctrl_dev
*pctrl_dev
,
2743 unsigned int pin
, unsigned long *configs
,
2744 unsigned int num_configs
)
2746 struct airoha_pinctrl
*pinctrl
= pinctrl_dev_get_drvdata(pctrl_dev
);
2749 for (i
= 0; i
< num_configs
; i
++) {
2750 u32 param
= pinconf_to_config_param(configs
[i
]);
2751 u32 arg
= pinconf_to_config_argument(configs
[i
]);
2754 case PIN_CONFIG_BIAS_DISABLE
:
2755 airoha_pinctrl_set_pulldown_conf(pinctrl
, pin
, 0);
2756 airoha_pinctrl_set_pullup_conf(pinctrl
, pin
, 0);
2758 case PIN_CONFIG_BIAS_PULL_UP
:
2759 airoha_pinctrl_set_pulldown_conf(pinctrl
, pin
, 0);
2760 airoha_pinctrl_set_pullup_conf(pinctrl
, pin
, 1);
2762 case PIN_CONFIG_BIAS_PULL_DOWN
:
2763 airoha_pinctrl_set_pulldown_conf(pinctrl
, pin
, 1);
2764 airoha_pinctrl_set_pullup_conf(pinctrl
, pin
, 0);
2766 case PIN_CONFIG_DRIVE_STRENGTH
: {
2786 airoha_pinctrl_set_drive_e2_conf(pinctrl
, pin
, e2
);
2787 airoha_pinctrl_set_drive_e4_conf(pinctrl
, pin
, e4
);
2790 case PIN_CONFIG_DRIVE_OPEN_DRAIN
:
2791 airoha_pinctrl_set_pcie_rst_od_conf(pinctrl
, pin
, !!arg
);
2793 case PIN_CONFIG_OUTPUT_ENABLE
:
2794 case PIN_CONFIG_INPUT_ENABLE
:
2795 case PIN_CONFIG_OUTPUT
: {
2796 bool input
= param
== PIN_CONFIG_INPUT_ENABLE
;
2799 err
= airoha_pinmux_set_direction(pctrl_dev
, NULL
, pin
,
2804 if (param
== PIN_CONFIG_OUTPUT
) {
2805 err
= airoha_pinconf_set_pin_value(pctrl_dev
,
2820 static int airoha_pinconf_group_get(struct pinctrl_dev
*pctrl_dev
,
2821 unsigned int group
, unsigned long *config
)
2826 for (i
= 0; i
< airoha_pinctrl_groups
[group
].npins
; i
++) {
2827 if (airoha_pinconf_get(pctrl_dev
,
2828 airoha_pinctrl_groups
[group
].pins
[i
],
2832 if (i
&& cur_config
!= *config
)
2835 cur_config
= *config
;
2841 static int airoha_pinconf_group_set(struct pinctrl_dev
*pctrl_dev
,
2842 unsigned int group
, unsigned long *configs
,
2843 unsigned int num_configs
)
2847 for (i
= 0; i
< airoha_pinctrl_groups
[group
].npins
; i
++) {
2850 err
= airoha_pinconf_set(pctrl_dev
,
2851 airoha_pinctrl_groups
[group
].pins
[i
],
2852 configs
, num_configs
);
2860 static const struct pinconf_ops airoha_confops
= {
2862 .pin_config_get
= airoha_pinconf_get
,
2863 .pin_config_set
= airoha_pinconf_set
,
2864 .pin_config_group_get
= airoha_pinconf_group_get
,
2865 .pin_config_group_set
= airoha_pinconf_group_set
,
2866 .pin_config_config_dbg_show
= pinconf_generic_dump_config
,
2869 static const struct pinctrl_ops airoha_pctlops
= {
2870 .get_groups_count
= pinctrl_generic_get_group_count
,
2871 .get_group_name
= pinctrl_generic_get_group_name
,
2872 .get_group_pins
= pinctrl_generic_get_group_pins
,
2873 .dt_node_to_map
= pinconf_generic_dt_node_to_map_all
,
2874 .dt_free_map
= pinconf_generic_dt_free_map
,
2877 static struct pinctrl_desc airoha_pinctrl_desc
= {
2878 .name
= KBUILD_MODNAME
,
2879 .owner
= THIS_MODULE
,
2880 .pctlops
= &airoha_pctlops
,
2881 .pmxops
= &airoha_pmxops
,
2882 .confops
= &airoha_confops
,
2883 .pins
= airoha_pinctrl_pins
,
2884 .npins
= ARRAY_SIZE(airoha_pinctrl_pins
),
2887 static int airoha_pinctrl_probe(struct platform_device
*pdev
)
2889 struct device
*dev
= &pdev
->dev
;
2890 struct airoha_pinctrl
*pinctrl
;
2894 pinctrl
= devm_kzalloc(dev
, sizeof(*pinctrl
), GFP_KERNEL
);
2898 pinctrl
->regmap
= device_node_to_regmap(dev
->parent
->of_node
);
2899 if (IS_ERR(pinctrl
->regmap
))
2900 return PTR_ERR(pinctrl
->regmap
);
2902 map
= syscon_regmap_lookup_by_compatible("airoha,en7581-chip-scu");
2904 return PTR_ERR(map
);
2906 pinctrl
->chip_scu
= map
;
2908 err
= devm_pinctrl_register_and_init(dev
, &airoha_pinctrl_desc
,
2909 pinctrl
, &pinctrl
->ctrl
);
2913 /* build pin groups */
2914 for (i
= 0; i
< ARRAY_SIZE(airoha_pinctrl_groups
); i
++) {
2915 const struct pingroup
*grp
= &airoha_pinctrl_groups
[i
];
2917 err
= pinctrl_generic_add_group(pinctrl
->ctrl
, grp
->name
,
2918 grp
->pins
, grp
->npins
,
2921 dev_err(&pdev
->dev
, "Failed to register group %s\n",
2927 /* build functions */
2928 for (i
= 0; i
< ARRAY_SIZE(airoha_pinctrl_funcs
); i
++) {
2929 const struct airoha_pinctrl_func
*func
;
2931 func
= &airoha_pinctrl_funcs
[i
];
2932 err
= pinmux_generic_add_function(pinctrl
->ctrl
,
2933 func
->desc
.func
.name
,
2934 func
->desc
.func
.groups
,
2935 func
->desc
.func
.ngroups
,
2938 dev_err(dev
, "Failed to register function %s\n",
2939 func
->desc
.func
.name
);
2944 err
= pinctrl_enable(pinctrl
->ctrl
);
2948 /* build gpio-chip */
2949 return airoha_pinctrl_add_gpiochip(pinctrl
, pdev
);
2952 static const struct of_device_id airoha_pinctrl_of_match
[] = {
2953 { .compatible
= "airoha,en7581-pinctrl" },
2956 MODULE_DEVICE_TABLE(of
, airoha_pinctrl_of_match
);
2958 static struct platform_driver airoha_pinctrl_driver
= {
2959 .probe
= airoha_pinctrl_probe
,
2961 .name
= "pinctrl-airoha",
2962 .of_match_table
= airoha_pinctrl_of_match
,
2965 module_platform_driver(airoha_pinctrl_driver
);
2967 MODULE_LICENSE("GPL");
2968 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>");
2969 MODULE_AUTHOR("Benjamin Larsson <benjamin.larsson@genexis.eu>");
2970 MODULE_AUTHOR("Markus Gothe <markus.gothe@genexis.eu>");
2971 MODULE_DESCRIPTION("Pinctrl driver for Airoha SoC");