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