123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- // SPDX-License-Identifier: GPL-2.0-or-later
- /*
- * Marvell ac5 pinctrl driver based on mvebu pinctrl core
- *
- * Copyright (C) 2021 Marvell
- *
- * Noam Liron <[email protected]>
- */
- #include <linux/err.h>
- #include <linux/init.h>
- #include <linux/io.h>
- #include <linux/platform_device.h>
- #include <linux/of.h>
- #include <linux/of_device.h>
- #include <linux/pinctrl/pinctrl.h>
- #include "pinctrl-mvebu.h"
- static struct mvebu_mpp_mode ac5_mpp_modes[] = {
- MPP_MODE(0,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "sdio", "d0"),
- MPP_FUNCTION(2, "nand", "io4")),
- MPP_MODE(1,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "sdio", "d1"),
- MPP_FUNCTION(2, "nand", "io3")),
- MPP_MODE(2,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "sdio", "d2"),
- MPP_FUNCTION(2, "nand", "io2")),
- MPP_MODE(3,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "sdio", "d3"),
- MPP_FUNCTION(2, "nand", "io7")),
- MPP_MODE(4,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "sdio", "d4"),
- MPP_FUNCTION(2, "nand", "io6"),
- MPP_FUNCTION(3, "uart3", "txd"),
- MPP_FUNCTION(4, "uart2", "txd")),
- MPP_MODE(5,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "sdio", "d5"),
- MPP_FUNCTION(2, "nand", "io5"),
- MPP_FUNCTION(3, "uart3", "rxd"),
- MPP_FUNCTION(4, "uart2", "rxd")),
- MPP_MODE(6,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "sdio", "d6"),
- MPP_FUNCTION(2, "nand", "io0"),
- MPP_FUNCTION(3, "i2c1", "sck")),
- MPP_MODE(7,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "sdio", "d7"),
- MPP_FUNCTION(2, "nand", "io1"),
- MPP_FUNCTION(3, "i2c1", "sda")),
- MPP_MODE(8,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "sdio", "clk"),
- MPP_FUNCTION(2, "nand", "wen")),
- MPP_MODE(9,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "sdio", "cmd"),
- MPP_FUNCTION(2, "nand", "ale")),
- MPP_MODE(10,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "sdio", "ds"),
- MPP_FUNCTION(2, "nand", "cle")),
- MPP_MODE(11,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "sdio", "rst"),
- MPP_FUNCTION(2, "nand", "cen")),
- MPP_MODE(12,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "spi0", "clk")),
- MPP_MODE(13,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "spi0", "csn")),
- MPP_MODE(14,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "spi0", "mosi")),
- MPP_MODE(15,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "spi0", "miso")),
- MPP_MODE(16,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "spi0", "wpn"),
- MPP_FUNCTION(2, "nand", "ren"),
- MPP_FUNCTION(3, "uart1", "txd")),
- MPP_MODE(17,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "spi0", "hold"),
- MPP_FUNCTION(2, "nand", "rb"),
- MPP_FUNCTION(3, "uart1", "rxd")),
- MPP_MODE(18,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "tsen_int", NULL),
- MPP_FUNCTION(2, "uart2", "rxd"),
- MPP_FUNCTION(3, "wd_int", NULL)),
- MPP_MODE(19,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "dev_init_done", NULL),
- MPP_FUNCTION(2, "uart2", "txd")),
- MPP_MODE(20,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(2, "i2c1", "sck"),
- MPP_FUNCTION(3, "spi1", "clk"),
- MPP_FUNCTION(4, "uart3", "txd")),
- MPP_MODE(21,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(2, "i2c1", "sda"),
- MPP_FUNCTION(3, "spi1", "csn"),
- MPP_FUNCTION(4, "uart3", "rxd")),
- MPP_MODE(22,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(3, "spi1", "mosi")),
- MPP_MODE(23,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(3, "spi1", "miso")),
- MPP_MODE(24,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "wd_int", NULL),
- MPP_FUNCTION(2, "uart2", "txd"),
- MPP_FUNCTION(3, "uartsd", "txd")),
- MPP_MODE(25,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "int_out", NULL),
- MPP_FUNCTION(2, "uart2", "rxd"),
- MPP_FUNCTION(3, "uartsd", "rxd")),
- MPP_MODE(26,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "i2c0", "sck"),
- MPP_FUNCTION(2, "ptp", "clk1"),
- MPP_FUNCTION(3, "uart3", "txd")),
- MPP_MODE(27,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "i2c0", "sda"),
- MPP_FUNCTION(2, "ptp", "pulse"),
- MPP_FUNCTION(3, "uart3", "rxd")),
- MPP_MODE(28,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "xg", "mdio"),
- MPP_FUNCTION(2, "ge", "mdio"),
- MPP_FUNCTION(3, "uart3", "txd")),
- MPP_MODE(29,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "xg", "mdio"),
- MPP_FUNCTION(2, "ge", "mdio"),
- MPP_FUNCTION(3, "uart3", "rxd")),
- MPP_MODE(30,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "xg", "mdio"),
- MPP_FUNCTION(2, "ge", "mdio"),
- MPP_FUNCTION(3, "ge", "mdio")),
- MPP_MODE(31,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "xg", "mdio"),
- MPP_FUNCTION(2, "ge", "mdio"),
- MPP_FUNCTION(3, "ge", "mdio")),
- MPP_MODE(32,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "uart0", "txd")),
- MPP_MODE(33,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "uart0", "rxd"),
- MPP_FUNCTION(2, "ptp", "clk1"),
- MPP_FUNCTION(3, "ptp", "pulse")),
- MPP_MODE(34,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "ge", "mdio"),
- MPP_FUNCTION(2, "uart3", "rxd")),
- MPP_MODE(35,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "ge", "mdio"),
- MPP_FUNCTION(2, "uart3", "txd"),
- MPP_FUNCTION(3, "pcie", "rstoutn")),
- MPP_MODE(36,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "ptp", "clk0_tp"),
- MPP_FUNCTION(2, "ptp", "clk1_tp")),
- MPP_MODE(37,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "ptp", "pulse_tp"),
- MPP_FUNCTION(2, "wd_int", NULL)),
- MPP_MODE(38,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "synce", "clk_out0")),
- MPP_MODE(39,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "synce", "clk_out1")),
- MPP_MODE(40,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "ptp", "pclk_out0"),
- MPP_FUNCTION(2, "ptp", "pclk_out1")),
- MPP_MODE(41,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "ptp", "ref_clk"),
- MPP_FUNCTION(2, "ptp", "clk1"),
- MPP_FUNCTION(3, "ptp", "pulse"),
- MPP_FUNCTION(4, "uart2", "txd"),
- MPP_FUNCTION(5, "i2c1", "sck")),
- MPP_MODE(42,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "ptp", "clk0"),
- MPP_FUNCTION(2, "ptp", "clk1"),
- MPP_FUNCTION(3, "ptp", "pulse"),
- MPP_FUNCTION(4, "uart2", "rxd"),
- MPP_FUNCTION(5, "i2c1", "sda")),
- MPP_MODE(43,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "led", "clk")),
- MPP_MODE(44,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "led", "stb")),
- MPP_MODE(45,
- MPP_FUNCTION(0, "gpio", NULL),
- MPP_FUNCTION(1, "led", "data")),
- };
- static struct mvebu_pinctrl_soc_info ac5_pinctrl_info;
- static const struct of_device_id ac5_pinctrl_of_match[] = {
- {
- .compatible = "marvell,ac5-pinctrl",
- },
- { },
- };
- static const struct mvebu_mpp_ctrl ac5_mpp_controls[] = {
- MPP_FUNC_CTRL(0, 45, NULL, mvebu_mmio_mpp_ctrl), };
- static struct pinctrl_gpio_range ac5_mpp_gpio_ranges[] = {
- MPP_GPIO_RANGE(0, 0, 0, 46), };
- static int ac5_pinctrl_probe(struct platform_device *pdev)
- {
- struct mvebu_pinctrl_soc_info *soc = &ac5_pinctrl_info;
- soc->variant = 0; /* no variants for ac5 */
- soc->controls = ac5_mpp_controls;
- soc->ncontrols = ARRAY_SIZE(ac5_mpp_controls);
- soc->gpioranges = ac5_mpp_gpio_ranges;
- soc->ngpioranges = ARRAY_SIZE(ac5_mpp_gpio_ranges);
- soc->modes = ac5_mpp_modes;
- soc->nmodes = ac5_mpp_controls[0].npins;
- pdev->dev.platform_data = soc;
- return mvebu_pinctrl_simple_mmio_probe(pdev);
- }
- static struct platform_driver ac5_pinctrl_driver = {
- .driver = {
- .name = "ac5-pinctrl",
- .of_match_table = of_match_ptr(ac5_pinctrl_of_match),
- },
- .probe = ac5_pinctrl_probe,
- };
- builtin_platform_driver(ac5_pinctrl_driver);
|