1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Marvell ac5 pinctrl driver based on mvebu pinctrl core
5 * Copyright (C) 2021 Marvell
7 * Noam Liron <lnoam@marvell.com>
10 #include <linux/err.h>
11 #include <linux/init.h>
13 #include <linux/platform_device.h>
15 #include <linux/pinctrl/pinctrl.h>
17 #include "pinctrl-mvebu.h"
19 static struct mvebu_mpp_mode ac5_mpp_modes
[] = {
21 MPP_FUNCTION(0, "gpio", NULL
),
22 MPP_FUNCTION(1, "sdio", "d0"),
23 MPP_FUNCTION(2, "nand", "io4")),
25 MPP_FUNCTION(0, "gpio", NULL
),
26 MPP_FUNCTION(1, "sdio", "d1"),
27 MPP_FUNCTION(2, "nand", "io3")),
29 MPP_FUNCTION(0, "gpio", NULL
),
30 MPP_FUNCTION(1, "sdio", "d2"),
31 MPP_FUNCTION(2, "nand", "io2")),
33 MPP_FUNCTION(0, "gpio", NULL
),
34 MPP_FUNCTION(1, "sdio", "d3"),
35 MPP_FUNCTION(2, "nand", "io7")),
37 MPP_FUNCTION(0, "gpio", NULL
),
38 MPP_FUNCTION(1, "sdio", "d4"),
39 MPP_FUNCTION(2, "nand", "io6"),
40 MPP_FUNCTION(3, "uart3", "txd"),
41 MPP_FUNCTION(4, "uart2", "txd")),
43 MPP_FUNCTION(0, "gpio", NULL
),
44 MPP_FUNCTION(1, "sdio", "d5"),
45 MPP_FUNCTION(2, "nand", "io5"),
46 MPP_FUNCTION(3, "uart3", "rxd"),
47 MPP_FUNCTION(4, "uart2", "rxd")),
49 MPP_FUNCTION(0, "gpio", NULL
),
50 MPP_FUNCTION(1, "sdio", "d6"),
51 MPP_FUNCTION(2, "nand", "io0"),
52 MPP_FUNCTION(3, "i2c1", "sck")),
54 MPP_FUNCTION(0, "gpio", NULL
),
55 MPP_FUNCTION(1, "sdio", "d7"),
56 MPP_FUNCTION(2, "nand", "io1"),
57 MPP_FUNCTION(3, "i2c1", "sda")),
59 MPP_FUNCTION(0, "gpio", NULL
),
60 MPP_FUNCTION(1, "sdio", "clk"),
61 MPP_FUNCTION(2, "nand", "wen")),
63 MPP_FUNCTION(0, "gpio", NULL
),
64 MPP_FUNCTION(1, "sdio", "cmd"),
65 MPP_FUNCTION(2, "nand", "ale")),
67 MPP_FUNCTION(0, "gpio", NULL
),
68 MPP_FUNCTION(1, "sdio", "ds"),
69 MPP_FUNCTION(2, "nand", "cle")),
71 MPP_FUNCTION(0, "gpio", NULL
),
72 MPP_FUNCTION(1, "sdio", "rst"),
73 MPP_FUNCTION(2, "nand", "cen")),
75 MPP_FUNCTION(0, "gpio", NULL
),
76 MPP_FUNCTION(1, "spi0", "clk")),
78 MPP_FUNCTION(0, "gpio", NULL
),
79 MPP_FUNCTION(1, "spi0", "csn")),
81 MPP_FUNCTION(0, "gpio", NULL
),
82 MPP_FUNCTION(1, "spi0", "mosi")),
84 MPP_FUNCTION(0, "gpio", NULL
),
85 MPP_FUNCTION(1, "spi0", "miso")),
87 MPP_FUNCTION(0, "gpio", NULL
),
88 MPP_FUNCTION(1, "spi0", "wpn"),
89 MPP_FUNCTION(2, "nand", "ren"),
90 MPP_FUNCTION(3, "uart1", "txd")),
92 MPP_FUNCTION(0, "gpio", NULL
),
93 MPP_FUNCTION(1, "spi0", "hold"),
94 MPP_FUNCTION(2, "nand", "rb"),
95 MPP_FUNCTION(3, "uart1", "rxd")),
97 MPP_FUNCTION(0, "gpio", NULL
),
98 MPP_FUNCTION(1, "tsen_int", NULL
),
99 MPP_FUNCTION(2, "uart2", "rxd"),
100 MPP_FUNCTION(3, "wd_int", NULL
)),
102 MPP_FUNCTION(0, "gpio", NULL
),
103 MPP_FUNCTION(1, "dev_init_done", NULL
),
104 MPP_FUNCTION(2, "uart2", "txd")),
106 MPP_FUNCTION(0, "gpio", NULL
),
107 MPP_FUNCTION(2, "i2c1", "sck"),
108 MPP_FUNCTION(3, "spi1", "clk"),
109 MPP_FUNCTION(4, "uart3", "txd")),
111 MPP_FUNCTION(0, "gpio", NULL
),
112 MPP_FUNCTION(2, "i2c1", "sda"),
113 MPP_FUNCTION(3, "spi1", "csn"),
114 MPP_FUNCTION(4, "uart3", "rxd")),
116 MPP_FUNCTION(0, "gpio", NULL
),
117 MPP_FUNCTION(3, "spi1", "mosi")),
119 MPP_FUNCTION(0, "gpio", NULL
),
120 MPP_FUNCTION(3, "spi1", "miso")),
122 MPP_FUNCTION(0, "gpio", NULL
),
123 MPP_FUNCTION(1, "wd_int", NULL
),
124 MPP_FUNCTION(2, "uart2", "txd"),
125 MPP_FUNCTION(3, "uartsd", "txd")),
127 MPP_FUNCTION(0, "gpio", NULL
),
128 MPP_FUNCTION(1, "int_out", NULL
),
129 MPP_FUNCTION(2, "uart2", "rxd"),
130 MPP_FUNCTION(3, "uartsd", "rxd")),
132 MPP_FUNCTION(0, "gpio", NULL
),
133 MPP_FUNCTION(1, "i2c0", "sck"),
134 MPP_FUNCTION(2, "ptp", "clk1"),
135 MPP_FUNCTION(3, "uart3", "txd")),
137 MPP_FUNCTION(0, "gpio", NULL
),
138 MPP_FUNCTION(1, "i2c0", "sda"),
139 MPP_FUNCTION(2, "ptp", "pulse"),
140 MPP_FUNCTION(3, "uart3", "rxd")),
142 MPP_FUNCTION(0, "gpio", NULL
),
143 MPP_FUNCTION(1, "xg", "mdio"),
144 MPP_FUNCTION(2, "ge", "mdio"),
145 MPP_FUNCTION(3, "uart3", "txd")),
147 MPP_FUNCTION(0, "gpio", NULL
),
148 MPP_FUNCTION(1, "xg", "mdio"),
149 MPP_FUNCTION(2, "ge", "mdio"),
150 MPP_FUNCTION(3, "uart3", "rxd")),
152 MPP_FUNCTION(0, "gpio", NULL
),
153 MPP_FUNCTION(1, "xg", "mdio"),
154 MPP_FUNCTION(2, "ge", "mdio"),
155 MPP_FUNCTION(3, "ge", "mdio")),
157 MPP_FUNCTION(0, "gpio", NULL
),
158 MPP_FUNCTION(1, "xg", "mdio"),
159 MPP_FUNCTION(2, "ge", "mdio"),
160 MPP_FUNCTION(3, "ge", "mdio")),
162 MPP_FUNCTION(0, "gpio", NULL
),
163 MPP_FUNCTION(1, "uart0", "txd")),
165 MPP_FUNCTION(0, "gpio", NULL
),
166 MPP_FUNCTION(1, "uart0", "rxd"),
167 MPP_FUNCTION(2, "ptp", "clk1"),
168 MPP_FUNCTION(3, "ptp", "pulse")),
170 MPP_FUNCTION(0, "gpio", NULL
),
171 MPP_FUNCTION(1, "ge", "mdio"),
172 MPP_FUNCTION(2, "uart3", "rxd")),
174 MPP_FUNCTION(0, "gpio", NULL
),
175 MPP_FUNCTION(1, "ge", "mdio"),
176 MPP_FUNCTION(2, "uart3", "txd"),
177 MPP_FUNCTION(3, "pcie", "rstoutn")),
179 MPP_FUNCTION(0, "gpio", NULL
),
180 MPP_FUNCTION(1, "ptp", "clk0_tp"),
181 MPP_FUNCTION(2, "ptp", "clk1_tp")),
183 MPP_FUNCTION(0, "gpio", NULL
),
184 MPP_FUNCTION(1, "ptp", "pulse_tp"),
185 MPP_FUNCTION(2, "wd_int", NULL
)),
187 MPP_FUNCTION(0, "gpio", NULL
),
188 MPP_FUNCTION(1, "synce", "clk_out0")),
190 MPP_FUNCTION(0, "gpio", NULL
),
191 MPP_FUNCTION(1, "synce", "clk_out1")),
193 MPP_FUNCTION(0, "gpio", NULL
),
194 MPP_FUNCTION(1, "ptp", "pclk_out0"),
195 MPP_FUNCTION(2, "ptp", "pclk_out1")),
197 MPP_FUNCTION(0, "gpio", NULL
),
198 MPP_FUNCTION(1, "ptp", "ref_clk"),
199 MPP_FUNCTION(2, "ptp", "clk1"),
200 MPP_FUNCTION(3, "ptp", "pulse"),
201 MPP_FUNCTION(4, "uart2", "txd"),
202 MPP_FUNCTION(5, "i2c1", "sck")),
204 MPP_FUNCTION(0, "gpio", NULL
),
205 MPP_FUNCTION(1, "ptp", "clk0"),
206 MPP_FUNCTION(2, "ptp", "clk1"),
207 MPP_FUNCTION(3, "ptp", "pulse"),
208 MPP_FUNCTION(4, "uart2", "rxd"),
209 MPP_FUNCTION(5, "i2c1", "sda")),
211 MPP_FUNCTION(0, "gpio", NULL
),
212 MPP_FUNCTION(1, "led", "clk")),
214 MPP_FUNCTION(0, "gpio", NULL
),
215 MPP_FUNCTION(1, "led", "stb")),
217 MPP_FUNCTION(0, "gpio", NULL
),
218 MPP_FUNCTION(1, "led", "data")),
221 static struct mvebu_pinctrl_soc_info ac5_pinctrl_info
;
223 static const struct of_device_id ac5_pinctrl_of_match
[] = {
225 .compatible
= "marvell,ac5-pinctrl",
230 static const struct mvebu_mpp_ctrl ac5_mpp_controls
[] = {
231 MPP_FUNC_CTRL(0, 45, NULL
, mvebu_mmio_mpp_ctrl
), };
233 static struct pinctrl_gpio_range ac5_mpp_gpio_ranges
[] = {
234 MPP_GPIO_RANGE(0, 0, 0, 46), };
236 static int ac5_pinctrl_probe(struct platform_device
*pdev
)
238 struct mvebu_pinctrl_soc_info
*soc
= &ac5_pinctrl_info
;
240 soc
->variant
= 0; /* no variants for ac5 */
241 soc
->controls
= ac5_mpp_controls
;
242 soc
->ncontrols
= ARRAY_SIZE(ac5_mpp_controls
);
243 soc
->gpioranges
= ac5_mpp_gpio_ranges
;
244 soc
->ngpioranges
= ARRAY_SIZE(ac5_mpp_gpio_ranges
);
245 soc
->modes
= ac5_mpp_modes
;
246 soc
->nmodes
= ac5_mpp_controls
[0].npins
;
248 pdev
->dev
.platform_data
= soc
;
250 return mvebu_pinctrl_simple_mmio_probe(pdev
);
253 static struct platform_driver ac5_pinctrl_driver
= {
255 .name
= "ac5-pinctrl",
256 .of_match_table
= of_match_ptr(ac5_pinctrl_of_match
),
258 .probe
= ac5_pinctrl_probe
,
260 builtin_platform_driver(ac5_pinctrl_driver
);