|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
| 2 | + |
| 3 | +#include <linux/module.h> |
| 4 | +#include <linux/platform_device.h> |
| 5 | +#include <linux/of.h> |
| 6 | +#include "pinmux.h" |
| 7 | + |
| 8 | +#define MT7621_GPIO_MODE_UART1 1 |
| 9 | +#define MT7621_GPIO_MODE_I2C 2 |
| 10 | +#define MT7621_GPIO_MODE_UART3_MASK 0x3 |
| 11 | +#define MT7621_GPIO_MODE_UART3_SHIFT 3 |
| 12 | +#define MT7621_GPIO_MODE_UART3_GPIO 1 |
| 13 | +#define MT7621_GPIO_MODE_UART2_MASK 0x3 |
| 14 | +#define MT7621_GPIO_MODE_UART2_SHIFT 5 |
| 15 | +#define MT7621_GPIO_MODE_UART2_GPIO 1 |
| 16 | +#define MT7621_GPIO_MODE_JTAG 7 |
| 17 | +#define MT7621_GPIO_MODE_WDT_MASK 0x3 |
| 18 | +#define MT7621_GPIO_MODE_WDT_SHIFT 8 |
| 19 | +#define MT7621_GPIO_MODE_WDT_GPIO 1 |
| 20 | +#define MT7621_GPIO_MODE_PCIE_RST 0 |
| 21 | +#define MT7621_GPIO_MODE_PCIE_REF 2 |
| 22 | +#define MT7621_GPIO_MODE_PCIE_MASK 0x3 |
| 23 | +#define MT7621_GPIO_MODE_PCIE_SHIFT 10 |
| 24 | +#define MT7621_GPIO_MODE_PCIE_GPIO 1 |
| 25 | +#define MT7621_GPIO_MODE_MDIO_MASK 0x3 |
| 26 | +#define MT7621_GPIO_MODE_MDIO_SHIFT 12 |
| 27 | +#define MT7621_GPIO_MODE_MDIO_GPIO 1 |
| 28 | +#define MT7621_GPIO_MODE_RGMII1 14 |
| 29 | +#define MT7621_GPIO_MODE_RGMII2 15 |
| 30 | +#define MT7621_GPIO_MODE_SPI_MASK 0x3 |
| 31 | +#define MT7621_GPIO_MODE_SPI_SHIFT 16 |
| 32 | +#define MT7621_GPIO_MODE_SPI_GPIO 1 |
| 33 | +#define MT7621_GPIO_MODE_SDHCI_MASK 0x3 |
| 34 | +#define MT7621_GPIO_MODE_SDHCI_SHIFT 18 |
| 35 | +#define MT7621_GPIO_MODE_SDHCI_GPIO 1 |
| 36 | + |
| 37 | +static struct rt2880_pmx_func uart1_grp[] = { FUNC("uart1", 0, 1, 2) }; |
| 38 | +static struct rt2880_pmx_func i2c_grp[] = { FUNC("i2c", 0, 3, 2) }; |
| 39 | +static struct rt2880_pmx_func uart3_grp[] = { |
| 40 | + FUNC("uart3", 0, 5, 4), |
| 41 | + FUNC("i2s", 2, 5, 4), |
| 42 | + FUNC("spdif3", 3, 5, 4), |
| 43 | +}; |
| 44 | +static struct rt2880_pmx_func uart2_grp[] = { |
| 45 | + FUNC("uart2", 0, 9, 4), |
| 46 | + FUNC("pcm", 2, 9, 4), |
| 47 | + FUNC("spdif2", 3, 9, 4), |
| 48 | +}; |
| 49 | +static struct rt2880_pmx_func jtag_grp[] = { FUNC("jtag", 0, 13, 5) }; |
| 50 | +static struct rt2880_pmx_func wdt_grp[] = { |
| 51 | + FUNC("wdt rst", 0, 18, 1), |
| 52 | + FUNC("wdt refclk", 2, 18, 1), |
| 53 | +}; |
| 54 | +static struct rt2880_pmx_func pcie_rst_grp[] = { |
| 55 | + FUNC("pcie rst", MT7621_GPIO_MODE_PCIE_RST, 19, 1), |
| 56 | + FUNC("pcie refclk", MT7621_GPIO_MODE_PCIE_REF, 19, 1) |
| 57 | +}; |
| 58 | +static struct rt2880_pmx_func mdio_grp[] = { FUNC("mdio", 0, 20, 2) }; |
| 59 | +static struct rt2880_pmx_func rgmii2_grp[] = { FUNC("rgmii2", 0, 22, 12) }; |
| 60 | +static struct rt2880_pmx_func spi_grp[] = { |
| 61 | + FUNC("spi", 0, 34, 7), |
| 62 | + FUNC("nand1", 2, 34, 7), |
| 63 | +}; |
| 64 | +static struct rt2880_pmx_func sdhci_grp[] = { |
| 65 | + FUNC("sdhci", 0, 41, 8), |
| 66 | + FUNC("nand2", 2, 41, 8), |
| 67 | +}; |
| 68 | +static struct rt2880_pmx_func rgmii1_grp[] = { FUNC("rgmii1", 0, 49, 12) }; |
| 69 | + |
| 70 | +static struct rt2880_pmx_group mt7621_pinmux_data[] = { |
| 71 | + GRP("uart1", uart1_grp, 1, MT7621_GPIO_MODE_UART1), |
| 72 | + GRP("i2c", i2c_grp, 1, MT7621_GPIO_MODE_I2C), |
| 73 | + GRP_G("uart3", uart3_grp, MT7621_GPIO_MODE_UART3_MASK, |
| 74 | + MT7621_GPIO_MODE_UART3_GPIO, MT7621_GPIO_MODE_UART3_SHIFT), |
| 75 | + GRP_G("uart2", uart2_grp, MT7621_GPIO_MODE_UART2_MASK, |
| 76 | + MT7621_GPIO_MODE_UART2_GPIO, MT7621_GPIO_MODE_UART2_SHIFT), |
| 77 | + GRP("jtag", jtag_grp, 1, MT7621_GPIO_MODE_JTAG), |
| 78 | + GRP_G("wdt", wdt_grp, MT7621_GPIO_MODE_WDT_MASK, |
| 79 | + MT7621_GPIO_MODE_WDT_GPIO, MT7621_GPIO_MODE_WDT_SHIFT), |
| 80 | + GRP_G("pcie", pcie_rst_grp, MT7621_GPIO_MODE_PCIE_MASK, |
| 81 | + MT7621_GPIO_MODE_PCIE_GPIO, MT7621_GPIO_MODE_PCIE_SHIFT), |
| 82 | + GRP_G("mdio", mdio_grp, MT7621_GPIO_MODE_MDIO_MASK, |
| 83 | + MT7621_GPIO_MODE_MDIO_GPIO, MT7621_GPIO_MODE_MDIO_SHIFT), |
| 84 | + GRP("rgmii2", rgmii2_grp, 1, MT7621_GPIO_MODE_RGMII2), |
| 85 | + GRP_G("spi", spi_grp, MT7621_GPIO_MODE_SPI_MASK, |
| 86 | + MT7621_GPIO_MODE_SPI_GPIO, MT7621_GPIO_MODE_SPI_SHIFT), |
| 87 | + GRP_G("sdhci", sdhci_grp, MT7621_GPIO_MODE_SDHCI_MASK, |
| 88 | + MT7621_GPIO_MODE_SDHCI_GPIO, MT7621_GPIO_MODE_SDHCI_SHIFT), |
| 89 | + GRP("rgmii1", rgmii1_grp, 1, MT7621_GPIO_MODE_RGMII1), |
| 90 | + { 0 } |
| 91 | +}; |
| 92 | + |
| 93 | +static int mt7621_pinmux_probe(struct platform_device *pdev) |
| 94 | +{ |
| 95 | + return rt2880_pinmux_init(pdev, mt7621_pinmux_data); |
| 96 | +} |
| 97 | + |
| 98 | +static const struct of_device_id mt7621_pinmux_match[] = { |
| 99 | + { .compatible = "ralink,rt2880-pinmux" }, |
| 100 | + {} |
| 101 | +}; |
| 102 | +MODULE_DEVICE_TABLE(of, mt7621_pinmux_match); |
| 103 | + |
| 104 | +static struct platform_driver mt7621_pinmux_driver = { |
| 105 | + .probe = mt7621_pinmux_probe, |
| 106 | + .driver = { |
| 107 | + .name = "rt2880-pinmux", |
| 108 | + .of_match_table = mt7621_pinmux_match, |
| 109 | + }, |
| 110 | +}; |
| 111 | + |
| 112 | +static int __init mt7621_pinmux_init(void) |
| 113 | +{ |
| 114 | + return platform_driver_register(&mt7621_pinmux_driver); |
| 115 | +} |
| 116 | +core_initcall_sync(mt7621_pinmux_init); |
0 commit comments