162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * The MT7629 driver based on Linux generic pinctrl binding.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2018 MediaTek Inc.
662306a36Sopenharmony_ci * Author: Ryder Lee <ryder.lee@mediatek.com>
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include "pinctrl-moore.h"
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#define MT7629_PIN(_number, _name, _eint_n)				\
1262306a36Sopenharmony_ci	MTK_PIN(_number, _name, 0, _eint_n, DRV_GRP1)
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_cistatic const struct mtk_pin_field_calc mt7629_pin_mode_range[] = {
1562306a36Sopenharmony_ci	PIN_FIELD(0, 78, 0x300, 0x10, 0, 4),
1662306a36Sopenharmony_ci};
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_cistatic const struct mtk_pin_field_calc mt7629_pin_dir_range[] = {
1962306a36Sopenharmony_ci	PIN_FIELD(0, 78, 0x0, 0x10, 0, 1),
2062306a36Sopenharmony_ci};
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_cistatic const struct mtk_pin_field_calc mt7629_pin_di_range[] = {
2362306a36Sopenharmony_ci	PIN_FIELD(0, 78, 0x200, 0x10, 0, 1),
2462306a36Sopenharmony_ci};
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_cistatic const struct mtk_pin_field_calc mt7629_pin_do_range[] = {
2762306a36Sopenharmony_ci	PIN_FIELD(0, 78, 0x100, 0x10, 0, 1),
2862306a36Sopenharmony_ci};
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_cistatic const struct mtk_pin_field_calc mt7629_pin_ies_range[] = {
3162306a36Sopenharmony_ci	PIN_FIELD(0, 10, 0x1000, 0x10, 0, 1),
3262306a36Sopenharmony_ci	PIN_FIELD(11, 18, 0x2000, 0x10, 0, 1),
3362306a36Sopenharmony_ci	PIN_FIELD(19, 32, 0x3000, 0x10, 0, 1),
3462306a36Sopenharmony_ci	PIN_FIELD(33, 48, 0x4000, 0x10, 0, 1),
3562306a36Sopenharmony_ci	PIN_FIELD(49, 50, 0x5000, 0x10, 0, 1),
3662306a36Sopenharmony_ci	PIN_FIELD(51, 69, 0x6000, 0x10, 0, 1),
3762306a36Sopenharmony_ci	PIN_FIELD(70, 78, 0x7000, 0x10, 0, 1),
3862306a36Sopenharmony_ci};
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_cistatic const struct mtk_pin_field_calc mt7629_pin_smt_range[] = {
4162306a36Sopenharmony_ci	PIN_FIELD(0, 10, 0x1100, 0x10, 0, 1),
4262306a36Sopenharmony_ci	PIN_FIELD(11, 18, 0x2100, 0x10, 0, 1),
4362306a36Sopenharmony_ci	PIN_FIELD(19, 32, 0x3100, 0x10, 0, 1),
4462306a36Sopenharmony_ci	PIN_FIELD(33, 48, 0x4100, 0x10, 0, 1),
4562306a36Sopenharmony_ci	PIN_FIELD(49, 50, 0x5100, 0x10, 0, 1),
4662306a36Sopenharmony_ci	PIN_FIELD(51, 69, 0x6100, 0x10, 0, 1),
4762306a36Sopenharmony_ci	PIN_FIELD(70, 78, 0x7100, 0x10, 0, 1),
4862306a36Sopenharmony_ci};
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_cistatic const struct mtk_pin_field_calc mt7629_pin_pullen_range[] = {
5162306a36Sopenharmony_ci	PIN_FIELD(0, 10, 0x1400, 0x10, 0, 1),
5262306a36Sopenharmony_ci	PIN_FIELD(11, 18, 0x2400, 0x10, 0, 1),
5362306a36Sopenharmony_ci	PIN_FIELD(19, 32, 0x3400, 0x10, 0, 1),
5462306a36Sopenharmony_ci	PIN_FIELD(33, 48, 0x4400, 0x10, 0, 1),
5562306a36Sopenharmony_ci	PIN_FIELD(49, 50, 0x5400, 0x10, 0, 1),
5662306a36Sopenharmony_ci	PIN_FIELD(51, 69, 0x6400, 0x10, 0, 1),
5762306a36Sopenharmony_ci	PIN_FIELD(70, 78, 0x7400, 0x10, 0, 1),
5862306a36Sopenharmony_ci};
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_cistatic const struct mtk_pin_field_calc mt7629_pin_pullsel_range[] = {
6162306a36Sopenharmony_ci	PIN_FIELD(0, 10, 0x1500, 0x10, 0, 1),
6262306a36Sopenharmony_ci	PIN_FIELD(11, 18, 0x2500, 0x10, 0, 1),
6362306a36Sopenharmony_ci	PIN_FIELD(19, 32, 0x3500, 0x10, 0, 1),
6462306a36Sopenharmony_ci	PIN_FIELD(33, 48, 0x4500, 0x10, 0, 1),
6562306a36Sopenharmony_ci	PIN_FIELD(49, 50, 0x5500, 0x10, 0, 1),
6662306a36Sopenharmony_ci	PIN_FIELD(51, 69, 0x6500, 0x10, 0, 1),
6762306a36Sopenharmony_ci	PIN_FIELD(70, 78, 0x7500, 0x10, 0, 1),
6862306a36Sopenharmony_ci};
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_cistatic const struct mtk_pin_field_calc mt7629_pin_drv_range[] = {
7162306a36Sopenharmony_ci	PIN_FIELD(0, 10, 0x1600, 0x10, 0, 4),
7262306a36Sopenharmony_ci	PIN_FIELD(11, 18, 0x2600, 0x10, 0, 4),
7362306a36Sopenharmony_ci	PIN_FIELD(19, 32, 0x3600, 0x10, 0, 4),
7462306a36Sopenharmony_ci	PIN_FIELD(33, 48, 0x4600, 0x10, 0, 4),
7562306a36Sopenharmony_ci	PIN_FIELD(49, 50, 0x5600, 0x10, 0, 4),
7662306a36Sopenharmony_ci	PIN_FIELD(51, 69, 0x6600, 0x10, 0, 4),
7762306a36Sopenharmony_ci	PIN_FIELD(70, 78, 0x7600, 0x10, 0, 4),
7862306a36Sopenharmony_ci};
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_cistatic const struct mtk_pin_field_calc mt7629_pin_tdsel_range[] = {
8162306a36Sopenharmony_ci	PIN_FIELD(0, 10, 0x1200, 0x10, 0, 4),
8262306a36Sopenharmony_ci	PIN_FIELD(11, 18, 0x2200, 0x10, 0, 4),
8362306a36Sopenharmony_ci	PIN_FIELD(19, 32, 0x3200, 0x10, 0, 4),
8462306a36Sopenharmony_ci	PIN_FIELD(33, 48, 0x4200, 0x10, 0, 4),
8562306a36Sopenharmony_ci	PIN_FIELD(49, 50, 0x5200, 0x10, 0, 4),
8662306a36Sopenharmony_ci	PIN_FIELD(51, 69, 0x6200, 0x10, 0, 4),
8762306a36Sopenharmony_ci	PIN_FIELD(70, 78, 0x7200, 0x10, 0, 4),
8862306a36Sopenharmony_ci};
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_cistatic const struct mtk_pin_field_calc mt7629_pin_rdsel_range[] = {
9162306a36Sopenharmony_ci	PIN_FIELD(0, 10, 0x1300, 0x10, 0, 4),
9262306a36Sopenharmony_ci	PIN_FIELD(11, 18, 0x2300, 0x10, 0, 4),
9362306a36Sopenharmony_ci	PIN_FIELD(19, 32, 0x3300, 0x10, 0, 4),
9462306a36Sopenharmony_ci	PIN_FIELD(33, 48, 0x4300, 0x10, 0, 4),
9562306a36Sopenharmony_ci	PIN_FIELD(49, 50, 0x5300, 0x10, 0, 4),
9662306a36Sopenharmony_ci	PIN_FIELD(51, 69, 0x6300, 0x10, 0, 4),
9762306a36Sopenharmony_ci	PIN_FIELD(70, 78, 0x7300, 0x10, 0, 4),
9862306a36Sopenharmony_ci};
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_cistatic const struct mtk_pin_reg_calc mt7629_reg_cals[] = {
10162306a36Sopenharmony_ci	[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7629_pin_mode_range),
10262306a36Sopenharmony_ci	[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7629_pin_dir_range),
10362306a36Sopenharmony_ci	[PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7629_pin_di_range),
10462306a36Sopenharmony_ci	[PINCTRL_PIN_REG_DO] = MTK_RANGE(mt7629_pin_do_range),
10562306a36Sopenharmony_ci	[PINCTRL_PIN_REG_IES] = MTK_RANGE(mt7629_pin_ies_range),
10662306a36Sopenharmony_ci	[PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt7629_pin_smt_range),
10762306a36Sopenharmony_ci	[PINCTRL_PIN_REG_PULLSEL] = MTK_RANGE(mt7629_pin_pullsel_range),
10862306a36Sopenharmony_ci	[PINCTRL_PIN_REG_PULLEN] = MTK_RANGE(mt7629_pin_pullen_range),
10962306a36Sopenharmony_ci	[PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt7629_pin_drv_range),
11062306a36Sopenharmony_ci	[PINCTRL_PIN_REG_TDSEL] = MTK_RANGE(mt7629_pin_tdsel_range),
11162306a36Sopenharmony_ci	[PINCTRL_PIN_REG_RDSEL] = MTK_RANGE(mt7629_pin_rdsel_range),
11262306a36Sopenharmony_ci};
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_cistatic const struct mtk_pin_desc mt7629_pins[] = {
11562306a36Sopenharmony_ci	MT7629_PIN(0, "TOP_5G_CLK", 53),
11662306a36Sopenharmony_ci	MT7629_PIN(1, "TOP_5G_DATA", 54),
11762306a36Sopenharmony_ci	MT7629_PIN(2, "WF0_5G_HB0", 55),
11862306a36Sopenharmony_ci	MT7629_PIN(3, "WF0_5G_HB1", 56),
11962306a36Sopenharmony_ci	MT7629_PIN(4, "WF0_5G_HB2", 57),
12062306a36Sopenharmony_ci	MT7629_PIN(5, "WF0_5G_HB3", 58),
12162306a36Sopenharmony_ci	MT7629_PIN(6, "WF0_5G_HB4", 59),
12262306a36Sopenharmony_ci	MT7629_PIN(7, "WF0_5G_HB5", 60),
12362306a36Sopenharmony_ci	MT7629_PIN(8, "WF0_5G_HB6", 61),
12462306a36Sopenharmony_ci	MT7629_PIN(9, "XO_REQ", 9),
12562306a36Sopenharmony_ci	MT7629_PIN(10, "TOP_RST_N", 10),
12662306a36Sopenharmony_ci	MT7629_PIN(11, "SYS_WATCHDOG", 11),
12762306a36Sopenharmony_ci	MT7629_PIN(12, "EPHY_LED0_N_JTDO", 12),
12862306a36Sopenharmony_ci	MT7629_PIN(13, "EPHY_LED1_N_JTDI", 13),
12962306a36Sopenharmony_ci	MT7629_PIN(14, "EPHY_LED2_N_JTMS", 14),
13062306a36Sopenharmony_ci	MT7629_PIN(15, "EPHY_LED3_N_JTCLK", 15),
13162306a36Sopenharmony_ci	MT7629_PIN(16, "EPHY_LED4_N_JTRST_N", 16),
13262306a36Sopenharmony_ci	MT7629_PIN(17, "WF2G_LED_N", 17),
13362306a36Sopenharmony_ci	MT7629_PIN(18, "WF5G_LED_N", 18),
13462306a36Sopenharmony_ci	MT7629_PIN(19, "I2C_SDA", 19),
13562306a36Sopenharmony_ci	MT7629_PIN(20, "I2C_SCL", 20),
13662306a36Sopenharmony_ci	MT7629_PIN(21, "GPIO_9", 21),
13762306a36Sopenharmony_ci	MT7629_PIN(22, "GPIO_10", 22),
13862306a36Sopenharmony_ci	MT7629_PIN(23, "GPIO_11", 23),
13962306a36Sopenharmony_ci	MT7629_PIN(24, "GPIO_12", 24),
14062306a36Sopenharmony_ci	MT7629_PIN(25, "UART1_TXD", 25),
14162306a36Sopenharmony_ci	MT7629_PIN(26, "UART1_RXD", 26),
14262306a36Sopenharmony_ci	MT7629_PIN(27, "UART1_CTS", 27),
14362306a36Sopenharmony_ci	MT7629_PIN(28, "UART1_RTS", 28),
14462306a36Sopenharmony_ci	MT7629_PIN(29, "UART2_TXD", 29),
14562306a36Sopenharmony_ci	MT7629_PIN(30, "UART2_RXD", 30),
14662306a36Sopenharmony_ci	MT7629_PIN(31, "UART2_CTS", 31),
14762306a36Sopenharmony_ci	MT7629_PIN(32, "UART2_RTS", 32),
14862306a36Sopenharmony_ci	MT7629_PIN(33, "MDI_TP_P1", 33),
14962306a36Sopenharmony_ci	MT7629_PIN(34, "MDI_TN_P1", 34),
15062306a36Sopenharmony_ci	MT7629_PIN(35, "MDI_RP_P1", 35),
15162306a36Sopenharmony_ci	MT7629_PIN(36, "MDI_RN_P1", 36),
15262306a36Sopenharmony_ci	MT7629_PIN(37, "MDI_RP_P2", 37),
15362306a36Sopenharmony_ci	MT7629_PIN(38, "MDI_RN_P2", 38),
15462306a36Sopenharmony_ci	MT7629_PIN(39, "MDI_TP_P2", 39),
15562306a36Sopenharmony_ci	MT7629_PIN(40, "MDI_TN_P2", 40),
15662306a36Sopenharmony_ci	MT7629_PIN(41, "MDI_TP_P3", 41),
15762306a36Sopenharmony_ci	MT7629_PIN(42, "MDI_TN_P3", 42),
15862306a36Sopenharmony_ci	MT7629_PIN(43, "MDI_RP_P3", 43),
15962306a36Sopenharmony_ci	MT7629_PIN(44, "MDI_RN_P3", 44),
16062306a36Sopenharmony_ci	MT7629_PIN(45, "MDI_RP_P4", 45),
16162306a36Sopenharmony_ci	MT7629_PIN(46, "MDI_RN_P4", 46),
16262306a36Sopenharmony_ci	MT7629_PIN(47, "MDI_TP_P4", 47),
16362306a36Sopenharmony_ci	MT7629_PIN(48, "MDI_TN_P4", 48),
16462306a36Sopenharmony_ci	MT7629_PIN(49, "SMI_MDC", 49),
16562306a36Sopenharmony_ci	MT7629_PIN(50, "SMI_MDIO", 50),
16662306a36Sopenharmony_ci	MT7629_PIN(51, "PCIE_PERESET_N", 51),
16762306a36Sopenharmony_ci	MT7629_PIN(52, "PWM_0", 52),
16862306a36Sopenharmony_ci	MT7629_PIN(53, "GPIO_0", 0),
16962306a36Sopenharmony_ci	MT7629_PIN(54, "GPIO_1", 1),
17062306a36Sopenharmony_ci	MT7629_PIN(55, "GPIO_2", 2),
17162306a36Sopenharmony_ci	MT7629_PIN(56, "GPIO_3", 3),
17262306a36Sopenharmony_ci	MT7629_PIN(57, "GPIO_4", 4),
17362306a36Sopenharmony_ci	MT7629_PIN(58, "GPIO_5", 5),
17462306a36Sopenharmony_ci	MT7629_PIN(59, "GPIO_6", 6),
17562306a36Sopenharmony_ci	MT7629_PIN(60, "GPIO_7", 7),
17662306a36Sopenharmony_ci	MT7629_PIN(61, "GPIO_8", 8),
17762306a36Sopenharmony_ci	MT7629_PIN(62, "SPI_CLK", 62),
17862306a36Sopenharmony_ci	MT7629_PIN(63, "SPI_CS", 63),
17962306a36Sopenharmony_ci	MT7629_PIN(64, "SPI_MOSI", 64),
18062306a36Sopenharmony_ci	MT7629_PIN(65, "SPI_MISO", 65),
18162306a36Sopenharmony_ci	MT7629_PIN(66, "SPI_WP", 66),
18262306a36Sopenharmony_ci	MT7629_PIN(67, "SPI_HOLD", 67),
18362306a36Sopenharmony_ci	MT7629_PIN(68, "UART0_TXD", 68),
18462306a36Sopenharmony_ci	MT7629_PIN(69, "UART0_RXD", 69),
18562306a36Sopenharmony_ci	MT7629_PIN(70, "TOP_2G_CLK", 70),
18662306a36Sopenharmony_ci	MT7629_PIN(71, "TOP_2G_DATA", 71),
18762306a36Sopenharmony_ci	MT7629_PIN(72, "WF0_2G_HB0", 72),
18862306a36Sopenharmony_ci	MT7629_PIN(73, "WF0_2G_HB1", 73),
18962306a36Sopenharmony_ci	MT7629_PIN(74, "WF0_2G_HB2", 74),
19062306a36Sopenharmony_ci	MT7629_PIN(75, "WF0_2G_HB3", 75),
19162306a36Sopenharmony_ci	MT7629_PIN(76, "WF0_2G_HB4", 76),
19262306a36Sopenharmony_ci	MT7629_PIN(77, "WF0_2G_HB5", 77),
19362306a36Sopenharmony_ci	MT7629_PIN(78, "WF0_2G_HB6", 78),
19462306a36Sopenharmony_ci};
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci/* List all groups consisting of these pins dedicated to the enablement of
19762306a36Sopenharmony_ci * certain hardware block and the corresponding mode for all of the pins.
19862306a36Sopenharmony_ci * The hardware probably has multiple combinations of these pinouts.
19962306a36Sopenharmony_ci */
20062306a36Sopenharmony_ci
20162306a36Sopenharmony_ci/* LED for EPHY */
20262306a36Sopenharmony_cistatic int mt7629_ephy_leds_pins[] = { 12, 13, 14, 15, 16, 17, 18, };
20362306a36Sopenharmony_cistatic int mt7629_ephy_leds_funcs[] = { 1, 1, 1, 1, 1, 1, 1, };
20462306a36Sopenharmony_cistatic int mt7629_ephy_led0_pins[] = { 12, };
20562306a36Sopenharmony_cistatic int mt7629_ephy_led0_funcs[] = { 1, };
20662306a36Sopenharmony_cistatic int mt7629_ephy_led1_pins[] = { 13, };
20762306a36Sopenharmony_cistatic int mt7629_ephy_led1_funcs[] = { 1, };
20862306a36Sopenharmony_cistatic int mt7629_ephy_led2_pins[] = { 14, };
20962306a36Sopenharmony_cistatic int mt7629_ephy_led2_funcs[] = { 1, };
21062306a36Sopenharmony_cistatic int mt7629_ephy_led3_pins[] = { 15, };
21162306a36Sopenharmony_cistatic int mt7629_ephy_led3_funcs[] = { 1, };
21262306a36Sopenharmony_cistatic int mt7629_ephy_led4_pins[] = { 16, };
21362306a36Sopenharmony_cistatic int mt7629_ephy_led4_funcs[] = { 1, };
21462306a36Sopenharmony_cistatic int mt7629_wf2g_led_pins[] = { 17, };
21562306a36Sopenharmony_cistatic int mt7629_wf2g_led_funcs[] = { 1, };
21662306a36Sopenharmony_cistatic int mt7629_wf5g_led_pins[] = { 18, };
21762306a36Sopenharmony_cistatic int mt7629_wf5g_led_funcs[] = { 1, };
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_ci/* Watchdog */
22062306a36Sopenharmony_cistatic int mt7629_watchdog_pins[] = { 11, };
22162306a36Sopenharmony_cistatic int mt7629_watchdog_funcs[] = { 1, };
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_ci/* LED for GPHY */
22462306a36Sopenharmony_cistatic int mt7629_gphy_leds_0_pins[] = { 21, 22, 23, };
22562306a36Sopenharmony_cistatic int mt7629_gphy_leds_0_funcs[] = { 2, 2, 2, };
22662306a36Sopenharmony_cistatic int mt7629_gphy_led1_0_pins[] = { 21, };
22762306a36Sopenharmony_cistatic int mt7629_gphy_led1_0_funcs[] = { 2, };
22862306a36Sopenharmony_cistatic int mt7629_gphy_led2_0_pins[] = { 22, };
22962306a36Sopenharmony_cistatic int mt7629_gphy_led2_0_funcs[] = { 2, };
23062306a36Sopenharmony_cistatic int mt7629_gphy_led3_0_pins[] = { 23, };
23162306a36Sopenharmony_cistatic int mt7629_gphy_led3_0_funcs[] = { 2, };
23262306a36Sopenharmony_cistatic int mt7629_gphy_leds_1_pins[] = { 57, 58, 59, };
23362306a36Sopenharmony_cistatic int mt7629_gphy_leds_1_funcs[] = { 1, 1, 1, };
23462306a36Sopenharmony_cistatic int mt7629_gphy_led1_1_pins[] = { 57, };
23562306a36Sopenharmony_cistatic int mt7629_gphy_led1_1_funcs[] = { 1, };
23662306a36Sopenharmony_cistatic int mt7629_gphy_led2_1_pins[] = { 58, };
23762306a36Sopenharmony_cistatic int mt7629_gphy_led2_1_funcs[] = { 1, };
23862306a36Sopenharmony_cistatic int mt7629_gphy_led3_1_pins[] = { 59, };
23962306a36Sopenharmony_cistatic int mt7629_gphy_led3_1_funcs[] = { 1, };
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_ci/* I2C */
24262306a36Sopenharmony_cistatic int mt7629_i2c_0_pins[] = { 19, 20, };
24362306a36Sopenharmony_cistatic int mt7629_i2c_0_funcs[] = { 1, 1, };
24462306a36Sopenharmony_cistatic int mt7629_i2c_1_pins[] = { 53, 54, };
24562306a36Sopenharmony_cistatic int mt7629_i2c_1_funcs[] = { 1, 1, };
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci/* SPI */
24862306a36Sopenharmony_cistatic int mt7629_spi_0_pins[] = { 21, 22, 23, 24, };
24962306a36Sopenharmony_cistatic int mt7629_spi_0_funcs[] = { 1, 1, 1, 1, };
25062306a36Sopenharmony_cistatic int mt7629_spi_1_pins[] = { 62, 63, 64, 65, };
25162306a36Sopenharmony_cistatic int mt7629_spi_1_funcs[] = { 1, 1, 1, 1, };
25262306a36Sopenharmony_cistatic int mt7629_spi_wp_pins[] = { 66, };
25362306a36Sopenharmony_cistatic int mt7629_spi_wp_funcs[] = { 1, };
25462306a36Sopenharmony_cistatic int mt7629_spi_hold_pins[] = { 67, };
25562306a36Sopenharmony_cistatic int mt7629_spi_hold_funcs[] = { 1, };
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_ci/* UART */
25862306a36Sopenharmony_cistatic int mt7629_uart1_0_txd_rxd_pins[] = { 25, 26, };
25962306a36Sopenharmony_cistatic int mt7629_uart1_0_txd_rxd_funcs[] = { 1, 1, };
26062306a36Sopenharmony_cistatic int mt7629_uart1_1_txd_rxd_pins[] = { 53, 54, };
26162306a36Sopenharmony_cistatic int mt7629_uart1_1_txd_rxd_funcs[] = { 2, 2, };
26262306a36Sopenharmony_cistatic int mt7629_uart2_0_txd_rxd_pins[] = { 29, 30, };
26362306a36Sopenharmony_cistatic int mt7629_uart2_0_txd_rxd_funcs[] = { 1, 1, };
26462306a36Sopenharmony_cistatic int mt7629_uart2_1_txd_rxd_pins[] = { 57, 58, };
26562306a36Sopenharmony_cistatic int mt7629_uart2_1_txd_rxd_funcs[] = { 2, 2, };
26662306a36Sopenharmony_cistatic int mt7629_uart1_0_cts_rts_pins[] = { 27, 28, };
26762306a36Sopenharmony_cistatic int mt7629_uart1_0_cts_rts_funcs[] = { 1, 1, };
26862306a36Sopenharmony_cistatic int mt7629_uart1_1_cts_rts_pins[] = { 55, 56, };
26962306a36Sopenharmony_cistatic int mt7629_uart1_1_cts_rts_funcs[] = { 2, 2, };
27062306a36Sopenharmony_cistatic int mt7629_uart2_0_cts_rts_pins[] = { 31, 32, };
27162306a36Sopenharmony_cistatic int mt7629_uart2_0_cts_rts_funcs[] = { 1, 1, };
27262306a36Sopenharmony_cistatic int mt7629_uart2_1_cts_rts_pins[] = { 59, 60, };
27362306a36Sopenharmony_cistatic int mt7629_uart2_1_cts_rts_funcs[] = { 2, 2, };
27462306a36Sopenharmony_cistatic int mt7629_uart0_txd_rxd_pins[] = { 68, 69, };
27562306a36Sopenharmony_cistatic int mt7629_uart0_txd_rxd_funcs[] = { 1, 1, };
27662306a36Sopenharmony_ci
27762306a36Sopenharmony_ci/* MDC/MDIO */
27862306a36Sopenharmony_cistatic int mt7629_mdc_mdio_pins[] = { 49, 50, };
27962306a36Sopenharmony_cistatic int mt7629_mdc_mdio_funcs[] = { 1, 1, };
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_ci/* PCIE */
28262306a36Sopenharmony_cistatic int mt7629_pcie_pereset_pins[] = { 51, };
28362306a36Sopenharmony_cistatic int mt7629_pcie_pereset_funcs[] = { 1, };
28462306a36Sopenharmony_cistatic int mt7629_pcie_wake_pins[] = { 55, };
28562306a36Sopenharmony_cistatic int mt7629_pcie_wake_funcs[] = { 1, };
28662306a36Sopenharmony_cistatic int mt7629_pcie_clkreq_pins[] = { 56, };
28762306a36Sopenharmony_cistatic int mt7629_pcie_clkreq_funcs[] = { 1, };
28862306a36Sopenharmony_ci
28962306a36Sopenharmony_ci/* PWM */
29062306a36Sopenharmony_cistatic int mt7629_pwm_0_pins[] = { 52, };
29162306a36Sopenharmony_cistatic int mt7629_pwm_0_funcs[] = { 1, };
29262306a36Sopenharmony_cistatic int mt7629_pwm_1_pins[] = { 61, };
29362306a36Sopenharmony_cistatic int mt7629_pwm_1_funcs[] = { 2, };
29462306a36Sopenharmony_ci
29562306a36Sopenharmony_ci/* WF 2G */
29662306a36Sopenharmony_cistatic int mt7629_wf0_2g_pins[] = { 70, 71, 72, 73, 74, 75, 76, 77, 78, };
29762306a36Sopenharmony_cistatic int mt7629_wf0_2g_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, };
29862306a36Sopenharmony_ci
29962306a36Sopenharmony_ci/* WF 5G */
30062306a36Sopenharmony_cistatic int mt7629_wf0_5g_pins[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, };
30162306a36Sopenharmony_cistatic int mt7629_wf0_5g_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
30262306a36Sopenharmony_ci
30362306a36Sopenharmony_ci/* SNFI */
30462306a36Sopenharmony_cistatic int mt7629_snfi_pins[] = { 62, 63, 64, 65, 66, 67 };
30562306a36Sopenharmony_cistatic int mt7629_snfi_funcs[] = { 2, 2, 2, 2, 2, 2 };
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_ci/* SPI NOR */
30862306a36Sopenharmony_cistatic int mt7629_snor_pins[] = { 62, 63, 64, 65, 66, 67 };
30962306a36Sopenharmony_cistatic int mt7629_snor_funcs[] = { 1, 1, 1, 1, 1, 1 };
31062306a36Sopenharmony_ci
31162306a36Sopenharmony_cistatic const struct group_desc mt7629_groups[] = {
31262306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("ephy_leds", mt7629_ephy_leds),
31362306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("ephy_led0", mt7629_ephy_led0),
31462306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("ephy_led1", mt7629_ephy_led1),
31562306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("ephy_led2", mt7629_ephy_led2),
31662306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("ephy_led3", mt7629_ephy_led3),
31762306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("ephy_led4", mt7629_ephy_led4),
31862306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("wf2g_led", mt7629_wf2g_led),
31962306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("wf5g_led", mt7629_wf5g_led),
32062306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("watchdog", mt7629_watchdog),
32162306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("gphy_leds_0", mt7629_gphy_leds_0),
32262306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("gphy_led1_0", mt7629_gphy_led1_0),
32362306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("gphy_led2_0", mt7629_gphy_led2_0),
32462306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("gphy_led3_0", mt7629_gphy_led3_0),
32562306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("gphy_leds_1", mt7629_gphy_leds_1),
32662306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("gphy_led1_1", mt7629_gphy_led1_1),
32762306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("gphy_led2_1", mt7629_gphy_led2_1),
32862306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("gphy_led3_1", mt7629_gphy_led3_1),
32962306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("i2c_0", mt7629_i2c_0),
33062306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("i2c_1", mt7629_i2c_1),
33162306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("spi_0", mt7629_spi_0),
33262306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("spi_1", mt7629_spi_1),
33362306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("spi_wp", mt7629_spi_wp),
33462306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("spi_hold", mt7629_spi_hold),
33562306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("uart1_0_txd_rxd", mt7629_uart1_0_txd_rxd),
33662306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("uart1_1_txd_rxd", mt7629_uart1_1_txd_rxd),
33762306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("uart2_0_txd_rxd", mt7629_uart2_0_txd_rxd),
33862306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("uart2_1_txd_rxd", mt7629_uart2_1_txd_rxd),
33962306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("uart1_0_cts_rts", mt7629_uart1_0_cts_rts),
34062306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("uart1_1_cts_rts", mt7629_uart1_1_cts_rts),
34162306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("uart2_0_cts_rts", mt7629_uart2_0_cts_rts),
34262306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("uart2_1_cts_rts", mt7629_uart2_1_cts_rts),
34362306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("uart0_txd_rxd", mt7629_uart0_txd_rxd),
34462306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("mdc_mdio", mt7629_mdc_mdio),
34562306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("pcie_pereset", mt7629_pcie_pereset),
34662306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("pcie_wake", mt7629_pcie_wake),
34762306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("pcie_clkreq", mt7629_pcie_clkreq),
34862306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("pwm_0", mt7629_pwm_0),
34962306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("pwm_1", mt7629_pwm_1),
35062306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("wf0_5g", mt7629_wf0_5g),
35162306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("wf0_2g", mt7629_wf0_2g),
35262306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("snfi", mt7629_snfi),
35362306a36Sopenharmony_ci	PINCTRL_PIN_GROUP("spi_nor", mt7629_snor),
35462306a36Sopenharmony_ci};
35562306a36Sopenharmony_ci
35662306a36Sopenharmony_ci/* Joint those groups owning the same capability in user point of view which
35762306a36Sopenharmony_ci * allows that people tend to use through the device tree.
35862306a36Sopenharmony_ci */
35962306a36Sopenharmony_cistatic const char *mt7629_ethernet_groups[] = { "mdc_mdio", };
36062306a36Sopenharmony_cistatic const char *mt7629_i2c_groups[] = { "i2c_0", "i2c_1", };
36162306a36Sopenharmony_cistatic const char *mt7629_led_groups[] = { "ephy_leds", "ephy_led0",
36262306a36Sopenharmony_ci					   "ephy_led1", "ephy_led2",
36362306a36Sopenharmony_ci					   "ephy_led3", "ephy_led4",
36462306a36Sopenharmony_ci					   "wf2g_led", "wf5g_led",
36562306a36Sopenharmony_ci					   "gphy_leds_0", "gphy_led1_0",
36662306a36Sopenharmony_ci					   "gphy_led2_0", "gphy_led3_0",
36762306a36Sopenharmony_ci					   "gphy_leds_1", "gphy_led1_1",
36862306a36Sopenharmony_ci					   "gphy_led2_1", "gphy_led3_1",};
36962306a36Sopenharmony_cistatic const char *mt7629_pcie_groups[] = { "pcie_pereset", "pcie_wake",
37062306a36Sopenharmony_ci					    "pcie_clkreq", };
37162306a36Sopenharmony_cistatic const char *mt7629_pwm_groups[] = { "pwm_0", "pwm_1", };
37262306a36Sopenharmony_cistatic const char *mt7629_spi_groups[] = { "spi_0", "spi_1", "spi_wp",
37362306a36Sopenharmony_ci					   "spi_hold", };
37462306a36Sopenharmony_cistatic const char *mt7629_uart_groups[] = { "uart1_0_txd_rxd",
37562306a36Sopenharmony_ci					    "uart1_1_txd_rxd",
37662306a36Sopenharmony_ci					    "uart2_0_txd_rxd",
37762306a36Sopenharmony_ci					    "uart2_1_txd_rxd",
37862306a36Sopenharmony_ci					    "uart1_0_cts_rts",
37962306a36Sopenharmony_ci					    "uart1_1_cts_rts",
38062306a36Sopenharmony_ci					    "uart2_0_cts_rts",
38162306a36Sopenharmony_ci					    "uart2_1_cts_rts",
38262306a36Sopenharmony_ci					    "uart0_txd_rxd", };
38362306a36Sopenharmony_cistatic const char *mt7629_wdt_groups[] = { "watchdog", };
38462306a36Sopenharmony_cistatic const char *mt7629_wifi_groups[] = { "wf0_5g", "wf0_2g", };
38562306a36Sopenharmony_cistatic const char *mt7629_flash_groups[] = { "snfi", "spi_nor" };
38662306a36Sopenharmony_ci
38762306a36Sopenharmony_cistatic const struct function_desc mt7629_functions[] = {
38862306a36Sopenharmony_ci	{"eth",	mt7629_ethernet_groups, ARRAY_SIZE(mt7629_ethernet_groups)},
38962306a36Sopenharmony_ci	{"i2c", mt7629_i2c_groups, ARRAY_SIZE(mt7629_i2c_groups)},
39062306a36Sopenharmony_ci	{"led",	mt7629_led_groups, ARRAY_SIZE(mt7629_led_groups)},
39162306a36Sopenharmony_ci	{"pcie", mt7629_pcie_groups, ARRAY_SIZE(mt7629_pcie_groups)},
39262306a36Sopenharmony_ci	{"pwm",	mt7629_pwm_groups, ARRAY_SIZE(mt7629_pwm_groups)},
39362306a36Sopenharmony_ci	{"spi",	mt7629_spi_groups, ARRAY_SIZE(mt7629_spi_groups)},
39462306a36Sopenharmony_ci	{"uart", mt7629_uart_groups, ARRAY_SIZE(mt7629_uart_groups)},
39562306a36Sopenharmony_ci	{"watchdog", mt7629_wdt_groups, ARRAY_SIZE(mt7629_wdt_groups)},
39662306a36Sopenharmony_ci	{"wifi", mt7629_wifi_groups, ARRAY_SIZE(mt7629_wifi_groups)},
39762306a36Sopenharmony_ci	{"flash", mt7629_flash_groups, ARRAY_SIZE(mt7629_flash_groups)},
39862306a36Sopenharmony_ci};
39962306a36Sopenharmony_ci
40062306a36Sopenharmony_cistatic const struct mtk_eint_hw mt7629_eint_hw = {
40162306a36Sopenharmony_ci	.port_mask = 7,
40262306a36Sopenharmony_ci	.ports     = 7,
40362306a36Sopenharmony_ci	.ap_num    = ARRAY_SIZE(mt7629_pins),
40462306a36Sopenharmony_ci	.db_cnt    = 16,
40562306a36Sopenharmony_ci	.db_time   = debounce_time_mt2701,
40662306a36Sopenharmony_ci};
40762306a36Sopenharmony_ci
40862306a36Sopenharmony_cistatic struct mtk_pin_soc mt7629_data = {
40962306a36Sopenharmony_ci	.reg_cal = mt7629_reg_cals,
41062306a36Sopenharmony_ci	.pins = mt7629_pins,
41162306a36Sopenharmony_ci	.npins = ARRAY_SIZE(mt7629_pins),
41262306a36Sopenharmony_ci	.grps = mt7629_groups,
41362306a36Sopenharmony_ci	.ngrps = ARRAY_SIZE(mt7629_groups),
41462306a36Sopenharmony_ci	.funcs = mt7629_functions,
41562306a36Sopenharmony_ci	.nfuncs = ARRAY_SIZE(mt7629_functions),
41662306a36Sopenharmony_ci	.eint_hw = &mt7629_eint_hw,
41762306a36Sopenharmony_ci	.gpio_m = 0,
41862306a36Sopenharmony_ci	.ies_present = true,
41962306a36Sopenharmony_ci	.base_names = mtk_default_register_base_names,
42062306a36Sopenharmony_ci	.nbase_names = ARRAY_SIZE(mtk_default_register_base_names),
42162306a36Sopenharmony_ci	.bias_disable_set = mtk_pinconf_bias_disable_set_rev1,
42262306a36Sopenharmony_ci	.bias_disable_get = mtk_pinconf_bias_disable_get_rev1,
42362306a36Sopenharmony_ci	.bias_set = mtk_pinconf_bias_set_rev1,
42462306a36Sopenharmony_ci	.bias_get = mtk_pinconf_bias_get_rev1,
42562306a36Sopenharmony_ci	.drive_set = mtk_pinconf_drive_set_rev1,
42662306a36Sopenharmony_ci	.drive_get = mtk_pinconf_drive_get_rev1,
42762306a36Sopenharmony_ci};
42862306a36Sopenharmony_ci
42962306a36Sopenharmony_cistatic const struct of_device_id mt7629_pinctrl_of_match[] = {
43062306a36Sopenharmony_ci	{ .compatible = "mediatek,mt7629-pinctrl", },
43162306a36Sopenharmony_ci	{}
43262306a36Sopenharmony_ci};
43362306a36Sopenharmony_ci
43462306a36Sopenharmony_cistatic int mt7629_pinctrl_probe(struct platform_device *pdev)
43562306a36Sopenharmony_ci{
43662306a36Sopenharmony_ci	return mtk_moore_pinctrl_probe(pdev, &mt7629_data);
43762306a36Sopenharmony_ci}
43862306a36Sopenharmony_ci
43962306a36Sopenharmony_cistatic struct platform_driver mt7629_pinctrl_driver = {
44062306a36Sopenharmony_ci	.driver = {
44162306a36Sopenharmony_ci		.name = "mt7629-pinctrl",
44262306a36Sopenharmony_ci		.of_match_table = mt7629_pinctrl_of_match,
44362306a36Sopenharmony_ci	},
44462306a36Sopenharmony_ci	.probe = mt7629_pinctrl_probe,
44562306a36Sopenharmony_ci};
44662306a36Sopenharmony_ci
44762306a36Sopenharmony_cistatic int __init mt7629_pinctrl_init(void)
44862306a36Sopenharmony_ci{
44962306a36Sopenharmony_ci	return platform_driver_register(&mt7629_pinctrl_driver);
45062306a36Sopenharmony_ci}
45162306a36Sopenharmony_ciarch_initcall(mt7629_pinctrl_init);
452