Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 
0003 #include <linux/bitops.h>
0004 #include <linux/module.h>
0005 #include <linux/platform_device.h>
0006 #include <linux/of.h>
0007 #include "pinctrl-ralink.h"
0008 
0009 #define RT2880_GPIO_MODE_I2C        BIT(0)
0010 #define RT2880_GPIO_MODE_UART0      BIT(1)
0011 #define RT2880_GPIO_MODE_SPI        BIT(2)
0012 #define RT2880_GPIO_MODE_UART1      BIT(3)
0013 #define RT2880_GPIO_MODE_JTAG       BIT(4)
0014 #define RT2880_GPIO_MODE_MDIO       BIT(5)
0015 #define RT2880_GPIO_MODE_SDRAM      BIT(6)
0016 #define RT2880_GPIO_MODE_PCI        BIT(7)
0017 
0018 static struct ralink_pmx_func i2c_func[] = { FUNC("i2c", 0, 1, 2) };
0019 static struct ralink_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) };
0020 static struct ralink_pmx_func uartlite_func[] = { FUNC("uartlite", 0, 7, 8) };
0021 static struct ralink_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 5) };
0022 static struct ralink_pmx_func mdio_func[] = { FUNC("mdio", 0, 22, 2) };
0023 static struct ralink_pmx_func sdram_func[] = { FUNC("sdram", 0, 24, 16) };
0024 static struct ralink_pmx_func pci_func[] = { FUNC("pci", 0, 40, 32) };
0025 
0026 static struct ralink_pmx_group rt2880_pinmux_data_act[] = {
0027     GRP("i2c", i2c_func, 1, RT2880_GPIO_MODE_I2C),
0028     GRP("spi", spi_func, 1, RT2880_GPIO_MODE_SPI),
0029     GRP("uartlite", uartlite_func, 1, RT2880_GPIO_MODE_UART0),
0030     GRP("jtag", jtag_func, 1, RT2880_GPIO_MODE_JTAG),
0031     GRP("mdio", mdio_func, 1, RT2880_GPIO_MODE_MDIO),
0032     GRP("sdram", sdram_func, 1, RT2880_GPIO_MODE_SDRAM),
0033     GRP("pci", pci_func, 1, RT2880_GPIO_MODE_PCI),
0034     { 0 }
0035 };
0036 
0037 static int rt2880_pinctrl_probe(struct platform_device *pdev)
0038 {
0039     return ralink_pinctrl_init(pdev, rt2880_pinmux_data_act);
0040 }
0041 
0042 static const struct of_device_id rt2880_pinctrl_match[] = {
0043     { .compatible = "ralink,rt2880-pinctrl" },
0044     {}
0045 };
0046 MODULE_DEVICE_TABLE(of, rt2880_pinctrl_match);
0047 
0048 static struct platform_driver rt2880_pinctrl_driver = {
0049     .probe = rt2880_pinctrl_probe,
0050     .driver = {
0051         .name = "rt2880-pinctrl",
0052         .of_match_table = rt2880_pinctrl_match,
0053     },
0054 };
0055 
0056 static int __init rt2880_pinctrl_init(void)
0057 {
0058     return platform_driver_register(&rt2880_pinctrl_driver);
0059 }
0060 core_initcall_sync(rt2880_pinctrl_init);