0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/err.h>
0011 #include <linux/init.h>
0012 #include <linux/io.h>
0013 #include <linux/platform_device.h>
0014 #include <linux/of.h>
0015 #include <linux/of_device.h>
0016 #include <linux/pinctrl/pinctrl.h>
0017
0018 #include "pinctrl-mvebu.h"
0019
0020 static struct mvebu_mpp_mode ac5_mpp_modes[] = {
0021 MPP_MODE(0,
0022 MPP_FUNCTION(0, "gpio", NULL),
0023 MPP_FUNCTION(1, "sdio", "d0"),
0024 MPP_FUNCTION(2, "nand", "io4")),
0025 MPP_MODE(1,
0026 MPP_FUNCTION(0, "gpio", NULL),
0027 MPP_FUNCTION(1, "sdio", "d1"),
0028 MPP_FUNCTION(2, "nand", "io3")),
0029 MPP_MODE(2,
0030 MPP_FUNCTION(0, "gpio", NULL),
0031 MPP_FUNCTION(1, "sdio", "d2"),
0032 MPP_FUNCTION(2, "nand", "io2")),
0033 MPP_MODE(3,
0034 MPP_FUNCTION(0, "gpio", NULL),
0035 MPP_FUNCTION(1, "sdio", "d3"),
0036 MPP_FUNCTION(2, "nand", "io7")),
0037 MPP_MODE(4,
0038 MPP_FUNCTION(0, "gpio", NULL),
0039 MPP_FUNCTION(1, "sdio", "d4"),
0040 MPP_FUNCTION(2, "nand", "io6"),
0041 MPP_FUNCTION(3, "uart3", "txd"),
0042 MPP_FUNCTION(4, "uart2", "txd")),
0043 MPP_MODE(5,
0044 MPP_FUNCTION(0, "gpio", NULL),
0045 MPP_FUNCTION(1, "sdio", "d5"),
0046 MPP_FUNCTION(2, "nand", "io5"),
0047 MPP_FUNCTION(3, "uart3", "rxd"),
0048 MPP_FUNCTION(4, "uart2", "rxd")),
0049 MPP_MODE(6,
0050 MPP_FUNCTION(0, "gpio", NULL),
0051 MPP_FUNCTION(1, "sdio", "d6"),
0052 MPP_FUNCTION(2, "nand", "io0"),
0053 MPP_FUNCTION(3, "i2c1", "sck")),
0054 MPP_MODE(7,
0055 MPP_FUNCTION(0, "gpio", NULL),
0056 MPP_FUNCTION(1, "sdio", "d7"),
0057 MPP_FUNCTION(2, "nand", "io1"),
0058 MPP_FUNCTION(3, "i2c1", "sda")),
0059 MPP_MODE(8,
0060 MPP_FUNCTION(0, "gpio", NULL),
0061 MPP_FUNCTION(1, "sdio", "clk"),
0062 MPP_FUNCTION(2, "nand", "wen")),
0063 MPP_MODE(9,
0064 MPP_FUNCTION(0, "gpio", NULL),
0065 MPP_FUNCTION(1, "sdio", "cmd"),
0066 MPP_FUNCTION(2, "nand", "ale")),
0067 MPP_MODE(10,
0068 MPP_FUNCTION(0, "gpio", NULL),
0069 MPP_FUNCTION(1, "sdio", "ds"),
0070 MPP_FUNCTION(2, "nand", "cle")),
0071 MPP_MODE(11,
0072 MPP_FUNCTION(0, "gpio", NULL),
0073 MPP_FUNCTION(1, "sdio", "rst"),
0074 MPP_FUNCTION(2, "nand", "cen")),
0075 MPP_MODE(12,
0076 MPP_FUNCTION(0, "gpio", NULL),
0077 MPP_FUNCTION(1, "spi0", "clk")),
0078 MPP_MODE(13,
0079 MPP_FUNCTION(0, "gpio", NULL),
0080 MPP_FUNCTION(1, "spi0", "csn")),
0081 MPP_MODE(14,
0082 MPP_FUNCTION(0, "gpio", NULL),
0083 MPP_FUNCTION(1, "spi0", "mosi")),
0084 MPP_MODE(15,
0085 MPP_FUNCTION(0, "gpio", NULL),
0086 MPP_FUNCTION(1, "spi0", "miso")),
0087 MPP_MODE(16,
0088 MPP_FUNCTION(0, "gpio", NULL),
0089 MPP_FUNCTION(1, "spi0", "wpn"),
0090 MPP_FUNCTION(2, "nand", "ren"),
0091 MPP_FUNCTION(3, "uart1", "txd")),
0092 MPP_MODE(17,
0093 MPP_FUNCTION(0, "gpio", NULL),
0094 MPP_FUNCTION(1, "spi0", "hold"),
0095 MPP_FUNCTION(2, "nand", "rb"),
0096 MPP_FUNCTION(3, "uart1", "rxd")),
0097 MPP_MODE(18,
0098 MPP_FUNCTION(0, "gpio", NULL),
0099 MPP_FUNCTION(1, "tsen_int", NULL),
0100 MPP_FUNCTION(2, "uart2", "rxd"),
0101 MPP_FUNCTION(3, "wd_int", NULL)),
0102 MPP_MODE(19,
0103 MPP_FUNCTION(0, "gpio", NULL),
0104 MPP_FUNCTION(1, "dev_init_done", NULL),
0105 MPP_FUNCTION(2, "uart2", "txd")),
0106 MPP_MODE(20,
0107 MPP_FUNCTION(0, "gpio", NULL),
0108 MPP_FUNCTION(2, "i2c1", "sck"),
0109 MPP_FUNCTION(3, "spi1", "clk"),
0110 MPP_FUNCTION(4, "uart3", "txd")),
0111 MPP_MODE(21,
0112 MPP_FUNCTION(0, "gpio", NULL),
0113 MPP_FUNCTION(2, "i2c1", "sda"),
0114 MPP_FUNCTION(3, "spi1", "csn"),
0115 MPP_FUNCTION(4, "uart3", "rxd")),
0116 MPP_MODE(22,
0117 MPP_FUNCTION(0, "gpio", NULL),
0118 MPP_FUNCTION(3, "spi1", "mosi")),
0119 MPP_MODE(23,
0120 MPP_FUNCTION(0, "gpio", NULL),
0121 MPP_FUNCTION(3, "spi1", "miso")),
0122 MPP_MODE(24,
0123 MPP_FUNCTION(0, "gpio", NULL),
0124 MPP_FUNCTION(1, "wd_int", NULL),
0125 MPP_FUNCTION(2, "uart2", "txd"),
0126 MPP_FUNCTION(3, "uartsd", "txd")),
0127 MPP_MODE(25,
0128 MPP_FUNCTION(0, "gpio", NULL),
0129 MPP_FUNCTION(1, "int_out", NULL),
0130 MPP_FUNCTION(2, "uart2", "rxd"),
0131 MPP_FUNCTION(3, "uartsd", "rxd")),
0132 MPP_MODE(26,
0133 MPP_FUNCTION(0, "gpio", NULL),
0134 MPP_FUNCTION(1, "i2c0", "sck"),
0135 MPP_FUNCTION(2, "ptp", "clk1"),
0136 MPP_FUNCTION(3, "uart3", "txd")),
0137 MPP_MODE(27,
0138 MPP_FUNCTION(0, "gpio", NULL),
0139 MPP_FUNCTION(1, "i2c0", "sda"),
0140 MPP_FUNCTION(2, "ptp", "pulse"),
0141 MPP_FUNCTION(3, "uart3", "rxd")),
0142 MPP_MODE(28,
0143 MPP_FUNCTION(0, "gpio", NULL),
0144 MPP_FUNCTION(1, "xg", "mdio"),
0145 MPP_FUNCTION(2, "ge", "mdio"),
0146 MPP_FUNCTION(3, "uart3", "txd")),
0147 MPP_MODE(29,
0148 MPP_FUNCTION(0, "gpio", NULL),
0149 MPP_FUNCTION(1, "xg", "mdio"),
0150 MPP_FUNCTION(2, "ge", "mdio"),
0151 MPP_FUNCTION(3, "uart3", "rxd")),
0152 MPP_MODE(30,
0153 MPP_FUNCTION(0, "gpio", NULL),
0154 MPP_FUNCTION(1, "xg", "mdio"),
0155 MPP_FUNCTION(2, "ge", "mdio"),
0156 MPP_FUNCTION(3, "ge", "mdio")),
0157 MPP_MODE(31,
0158 MPP_FUNCTION(0, "gpio", NULL),
0159 MPP_FUNCTION(1, "xg", "mdio"),
0160 MPP_FUNCTION(2, "ge", "mdio"),
0161 MPP_FUNCTION(3, "ge", "mdio")),
0162 MPP_MODE(32,
0163 MPP_FUNCTION(0, "gpio", NULL),
0164 MPP_FUNCTION(1, "uart0", "txd")),
0165 MPP_MODE(33,
0166 MPP_FUNCTION(0, "gpio", NULL),
0167 MPP_FUNCTION(1, "uart0", "rxd"),
0168 MPP_FUNCTION(2, "ptp", "clk1"),
0169 MPP_FUNCTION(3, "ptp", "pulse")),
0170 MPP_MODE(34,
0171 MPP_FUNCTION(0, "gpio", NULL),
0172 MPP_FUNCTION(1, "ge", "mdio"),
0173 MPP_FUNCTION(2, "uart3", "rxd")),
0174 MPP_MODE(35,
0175 MPP_FUNCTION(0, "gpio", NULL),
0176 MPP_FUNCTION(1, "ge", "mdio"),
0177 MPP_FUNCTION(2, "uart3", "txd"),
0178 MPP_FUNCTION(3, "pcie", "rstoutn")),
0179 MPP_MODE(36,
0180 MPP_FUNCTION(0, "gpio", NULL),
0181 MPP_FUNCTION(1, "ptp", "clk0_tp"),
0182 MPP_FUNCTION(2, "ptp", "clk1_tp")),
0183 MPP_MODE(37,
0184 MPP_FUNCTION(0, "gpio", NULL),
0185 MPP_FUNCTION(1, "ptp", "pulse_tp"),
0186 MPP_FUNCTION(2, "wd_int", NULL)),
0187 MPP_MODE(38,
0188 MPP_FUNCTION(0, "gpio", NULL),
0189 MPP_FUNCTION(1, "synce", "clk_out0")),
0190 MPP_MODE(39,
0191 MPP_FUNCTION(0, "gpio", NULL),
0192 MPP_FUNCTION(1, "synce", "clk_out1")),
0193 MPP_MODE(40,
0194 MPP_FUNCTION(0, "gpio", NULL),
0195 MPP_FUNCTION(1, "ptp", "pclk_out0"),
0196 MPP_FUNCTION(2, "ptp", "pclk_out1")),
0197 MPP_MODE(41,
0198 MPP_FUNCTION(0, "gpio", NULL),
0199 MPP_FUNCTION(1, "ptp", "ref_clk"),
0200 MPP_FUNCTION(2, "ptp", "clk1"),
0201 MPP_FUNCTION(3, "ptp", "pulse"),
0202 MPP_FUNCTION(4, "uart2", "txd"),
0203 MPP_FUNCTION(5, "i2c1", "sck")),
0204 MPP_MODE(42,
0205 MPP_FUNCTION(0, "gpio", NULL),
0206 MPP_FUNCTION(1, "ptp", "clk0"),
0207 MPP_FUNCTION(2, "ptp", "clk1"),
0208 MPP_FUNCTION(3, "ptp", "pulse"),
0209 MPP_FUNCTION(4, "uart2", "rxd"),
0210 MPP_FUNCTION(5, "i2c1", "sda")),
0211 MPP_MODE(43,
0212 MPP_FUNCTION(0, "gpio", NULL),
0213 MPP_FUNCTION(1, "led", "clk")),
0214 MPP_MODE(44,
0215 MPP_FUNCTION(0, "gpio", NULL),
0216 MPP_FUNCTION(1, "led", "stb")),
0217 MPP_MODE(45,
0218 MPP_FUNCTION(0, "gpio", NULL),
0219 MPP_FUNCTION(1, "led", "data")),
0220 };
0221
0222 static struct mvebu_pinctrl_soc_info ac5_pinctrl_info;
0223
0224 static const struct of_device_id ac5_pinctrl_of_match[] = {
0225 {
0226 .compatible = "marvell,ac5-pinctrl",
0227 },
0228 { },
0229 };
0230
0231 static const struct mvebu_mpp_ctrl ac5_mpp_controls[] = {
0232 MPP_FUNC_CTRL(0, 45, NULL, mvebu_mmio_mpp_ctrl), };
0233
0234 static struct pinctrl_gpio_range ac5_mpp_gpio_ranges[] = {
0235 MPP_GPIO_RANGE(0, 0, 0, 46), };
0236
0237 static int ac5_pinctrl_probe(struct platform_device *pdev)
0238 {
0239 struct mvebu_pinctrl_soc_info *soc = &ac5_pinctrl_info;
0240
0241 soc->variant = 0;
0242 soc->controls = ac5_mpp_controls;
0243 soc->ncontrols = ARRAY_SIZE(ac5_mpp_controls);
0244 soc->gpioranges = ac5_mpp_gpio_ranges;
0245 soc->ngpioranges = ARRAY_SIZE(ac5_mpp_gpio_ranges);
0246 soc->modes = ac5_mpp_modes;
0247 soc->nmodes = ac5_mpp_controls[0].npins;
0248
0249 pdev->dev.platform_data = soc;
0250
0251 return mvebu_pinctrl_simple_mmio_probe(pdev);
0252 }
0253
0254 static struct platform_driver ac5_pinctrl_driver = {
0255 .driver = {
0256 .name = "ac5-pinctrl",
0257 .of_match_table = of_match_ptr(ac5_pinctrl_of_match),
0258 },
0259 .probe = ac5_pinctrl_probe,
0260 };
0261 builtin_platform_driver(ac5_pinctrl_driver);