xref: /linux/drivers/pinctrl/berlin/berlin-bg4ct.c (revision e9f0878c4b2004ac19581274c1ae4c61ae3ca70e)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Marvell berlin4ct pinctrl driver
4  *
5  * Copyright (C) 2015 Marvell Technology Group Ltd.
6  *
7  * Author: Jisheng Zhang <jszhang@marvell.com>
8  */
9 
10 #include <linux/init.h>
11 #include <linux/of_device.h>
12 #include <linux/platform_device.h>
13 #include <linux/regmap.h>
14 
15 #include "berlin.h"
16 
17 static const struct berlin_desc_group berlin4ct_soc_pinctrl_groups[] = {
18 	BERLIN_PINCTRL_GROUP("EMMC_RSTn", 0x0, 0x3, 0x00,
19 			BERLIN_PINCTRL_FUNCTION(0x0, "emmc"), /* RSTn */
20 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* GPIO47 */
21 	BERLIN_PINCTRL_GROUP("NAND_IO0", 0x0, 0x3, 0x03,
22 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO0 */
23 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXD0 */
24 			BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* CLK */
25 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO0 */
26 	BERLIN_PINCTRL_GROUP("NAND_IO1", 0x0, 0x3, 0x06,
27 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO1 */
28 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXD1 */
29 			BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* CDn */
30 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO1 */
31 	BERLIN_PINCTRL_GROUP("NAND_IO2", 0x0, 0x3, 0x09,
32 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO2 */
33 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXD2 */
34 			BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* DAT0 */
35 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO2 */
36 	BERLIN_PINCTRL_GROUP("NAND_IO3", 0x0, 0x3, 0x0c,
37 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO3 */
38 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXD3 */
39 			BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* DAT1 */
40 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO3 */
41 	BERLIN_PINCTRL_GROUP("NAND_IO4", 0x0, 0x3, 0x0f,
42 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO4 */
43 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXC */
44 			BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* DAT2 */
45 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO4 */
46 	BERLIN_PINCTRL_GROUP("NAND_IO5", 0x0, 0x3, 0x12,
47 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO5 */
48 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXCTL */
49 			BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* DAT3 */
50 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO5 */
51 	BERLIN_PINCTRL_GROUP("NAND_IO6", 0x0, 0x3, 0x15,
52 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO6 */
53 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* MDC */
54 			BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* CMD */
55 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO6 */
56 	BERLIN_PINCTRL_GROUP("NAND_IO7", 0x0, 0x3, 0x18,
57 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO7 */
58 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* MDIO */
59 			BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* WP */
60 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO7 */
61 	BERLIN_PINCTRL_GROUP("NAND_ALE", 0x0, 0x3, 0x1b,
62 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* ALE */
63 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXD0 */
64 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO8 */
65 	BERLIN_PINCTRL_GROUP("NAND_CLE", 0x4, 0x3, 0x00,
66 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* CLE */
67 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXD1 */
68 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO9 */
69 	BERLIN_PINCTRL_GROUP("NAND_WEn", 0x4, 0x3, 0x03,
70 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* WEn */
71 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXD2 */
72 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO10 */
73 	BERLIN_PINCTRL_GROUP("NAND_REn", 0x4, 0x3, 0x06,
74 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* REn */
75 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXD3 */
76 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO11 */
77 	BERLIN_PINCTRL_GROUP("NAND_WPn", 0x4, 0x3, 0x09,
78 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* WPn */
79 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO12 */
80 	BERLIN_PINCTRL_GROUP("NAND_CEn", 0x4, 0x3, 0x0c,
81 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* CEn */
82 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXC */
83 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO13 */
84 	BERLIN_PINCTRL_GROUP("NAND_RDY", 0x4, 0x3, 0x0f,
85 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* RDY */
86 			BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXCTL */
87 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO14 */
88 	BERLIN_PINCTRL_GROUP("SD0_CLK", 0x4, 0x3, 0x12,
89 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO29 */
90 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* CLK*/
91 			BERLIN_PINCTRL_FUNCTION(0x2, "sts4"), /* CLK */
92 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG8 */
93 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG8 */
94 	BERLIN_PINCTRL_GROUP("SD0_DAT0", 0x4, 0x3, 0x15,
95 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO30 */
96 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT0 */
97 			BERLIN_PINCTRL_FUNCTION(0x2, "sts4"), /* SOP */
98 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG9 */
99 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG9 */
100 	BERLIN_PINCTRL_GROUP("SD0_DAT1", 0x4, 0x3, 0x18,
101 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO31 */
102 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT1 */
103 			BERLIN_PINCTRL_FUNCTION(0x2, "sts4"), /* SD */
104 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG10 */
105 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG10 */
106 	BERLIN_PINCTRL_GROUP("SD0_DAT2", 0x4, 0x3, 0x1b,
107 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO32 */
108 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT2 */
109 			BERLIN_PINCTRL_FUNCTION(0x2, "sts4"), /* VALD */
110 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG11 */
111 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG11 */
112 	BERLIN_PINCTRL_GROUP("SD0_DAT3", 0x8, 0x3, 0x00,
113 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO33 */
114 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT3 */
115 			BERLIN_PINCTRL_FUNCTION(0x2, "sts5"), /* CLK */
116 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG12 */
117 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG12 */
118 	BERLIN_PINCTRL_GROUP("SD0_CDn", 0x8, 0x3, 0x03,
119 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO34 */
120 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* CDn */
121 			BERLIN_PINCTRL_FUNCTION(0x2, "sts5"), /* SOP */
122 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG13 */
123 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG13 */
124 	BERLIN_PINCTRL_GROUP("SD0_CMD", 0x8, 0x3, 0x06,
125 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO35 */
126 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* CMD */
127 			BERLIN_PINCTRL_FUNCTION(0x2, "sts5"), /* SD */
128 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG14 */
129 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG14 */
130 	BERLIN_PINCTRL_GROUP("SD0_WP", 0x8, 0x3, 0x09,
131 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO36 */
132 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* WP */
133 			BERLIN_PINCTRL_FUNCTION(0x2, "sts5"), /* VALD */
134 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG15 */
135 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG15 */
136 	BERLIN_PINCTRL_GROUP("STS0_CLK", 0x8, 0x3, 0x0c,
137 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO21 */
138 			BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), /* CLK */
139 			BERLIN_PINCTRL_FUNCTION(0x2, "cpupll"), /* CLKO */
140 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG0 */
141 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG0 */
142 	BERLIN_PINCTRL_GROUP("STS0_SOP", 0x8, 0x3, 0x0f,
143 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO22 */
144 			BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), /* SOP */
145 			BERLIN_PINCTRL_FUNCTION(0x2, "syspll"), /* CLKO */
146 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG1 */
147 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG1 */
148 	BERLIN_PINCTRL_GROUP("STS0_SD", 0x8, 0x3, 0x12,
149 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO23 */
150 			BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), /* SD */
151 			BERLIN_PINCTRL_FUNCTION(0x2, "mempll"), /* CLKO */
152 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG2 */
153 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG2 */
154 	BERLIN_PINCTRL_GROUP("STS0_VALD", 0x8, 0x3, 0x15,
155 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO24 */
156 			BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), /* VALD */
157 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG3 */
158 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG3 */
159 	BERLIN_PINCTRL_GROUP("STS1_CLK", 0x8, 0x3, 0x18,
160 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO25 */
161 			BERLIN_PINCTRL_FUNCTION(0x1, "sts1"), /* CLK */
162 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm0"),
163 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG4 */
164 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG4 */
165 	BERLIN_PINCTRL_GROUP("STS1_SOP", 0x8, 0x3, 0x1b,
166 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO26 */
167 			BERLIN_PINCTRL_FUNCTION(0x1, "sts1"), /* SOP */
168 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm1"),
169 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG5 */
170 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG5 */
171 	BERLIN_PINCTRL_GROUP("STS1_SD", 0xc, 0x3, 0x00,
172 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO27 */
173 			BERLIN_PINCTRL_FUNCTION(0x1, "sts1"), /* SD */
174 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm2"),
175 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG6 */
176 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG6 */
177 	BERLIN_PINCTRL_GROUP("STS1_VALD", 0xc, 0x3, 0x03,
178 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO28 */
179 			BERLIN_PINCTRL_FUNCTION(0x1, "sts1"), /* VALD */
180 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm3"),
181 			BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG7 */
182 			BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG7 */
183 	BERLIN_PINCTRL_GROUP("SCRD0_RST", 0xc, 0x3, 0x06,
184 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO15 */
185 			BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* RST */
186 			BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* CLK */
187 	BERLIN_PINCTRL_GROUP("SCRD0_DCLK", 0xc, 0x3, 0x09,
188 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO16 */
189 			BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* DCLK */
190 			BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* CMD */
191 	BERLIN_PINCTRL_GROUP("SCRD0_GPIO0", 0xc, 0x3, 0x0c,
192 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO17 */
193 			BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* SCRD0 GPIO0 */
194 			BERLIN_PINCTRL_FUNCTION(0x2, "sif"), /* DIO */
195 			BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* DAT0 */
196 	BERLIN_PINCTRL_GROUP("SCRD0_GPIO1", 0xc, 0x3, 0x0f,
197 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO18 */
198 			BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* SCRD0 GPIO1 */
199 			BERLIN_PINCTRL_FUNCTION(0x2, "sif"), /* CLK */
200 			BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* DAT1 */
201 	BERLIN_PINCTRL_GROUP("SCRD0_DIO", 0xc, 0x3, 0x12,
202 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO19 */
203 			BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* DIO */
204 			BERLIN_PINCTRL_FUNCTION(0x2, "sif"), /* DEN */
205 			BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* DAT2 */
206 	BERLIN_PINCTRL_GROUP("SCRD0_CRD_PRES", 0xc, 0x3, 0x15,
207 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO20 */
208 			BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* crd pres */
209 			BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* DAT3 */
210 	BERLIN_PINCTRL_GROUP("SPI1_SS0n", 0xc, 0x3, 0x18,
211 			BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS0n */
212 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO37 */
213 			BERLIN_PINCTRL_FUNCTION(0x2, "sts2")), /* CLK */
214 	BERLIN_PINCTRL_GROUP("SPI1_SS1n", 0xc, 0x3, 0x1b,
215 			BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS1n */
216 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO38 */
217 			BERLIN_PINCTRL_FUNCTION(0x2, "sts2"), /* SOP */
218 			BERLIN_PINCTRL_FUNCTION(0x4, "pwm1")),
219 	BERLIN_PINCTRL_GROUP("SPI1_SS2n", 0x10, 0x3, 0x00,
220 			BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS2n */
221 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO39 */
222 			BERLIN_PINCTRL_FUNCTION(0x2, "sts2"), /* SD */
223 			BERLIN_PINCTRL_FUNCTION(0x4, "pwm0")),
224 	BERLIN_PINCTRL_GROUP("SPI1_SS3n", 0x10, 0x3, 0x03,
225 			BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS3n */
226 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO40 */
227 			BERLIN_PINCTRL_FUNCTION(0x2, "sts2")), /* VALD */
228 	BERLIN_PINCTRL_GROUP("SPI1_SCLK", 0x10, 0x3, 0x06,
229 			BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SCLK */
230 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO41 */
231 			BERLIN_PINCTRL_FUNCTION(0x2, "sts3")), /* CLK */
232 	BERLIN_PINCTRL_GROUP("SPI1_SDO", 0x10, 0x3, 0x09,
233 			BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SDO */
234 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO42 */
235 			BERLIN_PINCTRL_FUNCTION(0x2, "sts3")), /* SOP */
236 	BERLIN_PINCTRL_GROUP("SPI1_SDI", 0x10, 0x3, 0x0c,
237 			BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SDI */
238 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO43 */
239 			BERLIN_PINCTRL_FUNCTION(0x2, "sts3")), /* SD */
240 	BERLIN_PINCTRL_GROUP("USB0_DRV_VBUS", 0x10, 0x3, 0x0f,
241 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO44 */
242 			BERLIN_PINCTRL_FUNCTION(0x1, "usb0"), /* VBUS */
243 			BERLIN_PINCTRL_FUNCTION(0x2, "sts3")), /* VALD */
244 	BERLIN_PINCTRL_GROUP("TW0_SCL", 0x10, 0x3, 0x12,
245 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO45 */
246 			BERLIN_PINCTRL_FUNCTION(0x1, "tw0")), /* SCL */
247 	BERLIN_PINCTRL_GROUP("TW0_SDA", 0x10, 0x3, 0x15,
248 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO46 */
249 			BERLIN_PINCTRL_FUNCTION(0x1, "tw0")), /* SDA */
250 };
251 
252 static const struct berlin_desc_group berlin4ct_avio_pinctrl_groups[] = {
253 	BERLIN_PINCTRL_GROUP("TX_EDDC_SCL", 0x0, 0x3, 0x00,
254 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO0 */
255 			BERLIN_PINCTRL_FUNCTION(0x1, "tx_eddc"), /* SCL */
256 			BERLIN_PINCTRL_FUNCTION(0x2, "tw1")), /* SCL */
257 	BERLIN_PINCTRL_GROUP("TX_EDDC_SDA", 0x0, 0x3, 0x03,
258 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO1 */
259 			BERLIN_PINCTRL_FUNCTION(0x1, "tx_eddc"), /* SDA */
260 			BERLIN_PINCTRL_FUNCTION(0x2, "tw1")), /* SDA */
261 	BERLIN_PINCTRL_GROUP("I2S1_LRCKO", 0x0, 0x3, 0x06,
262 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO2 */
263 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* LRCKO */
264 			BERLIN_PINCTRL_FUNCTION(0x3, "sts6"), /* CLK */
265 			BERLIN_PINCTRL_FUNCTION(0x4, "adac"), /* DBG0 */
266 			BERLIN_PINCTRL_FUNCTION(0x6, "sd1b"), /* CLK */
267 			BERLIN_PINCTRL_FUNCTION(0x7, "avio")), /* DBG0 */
268 	BERLIN_PINCTRL_GROUP("I2S1_BCLKO", 0x0, 0x3, 0x09,
269 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO3 */
270 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* BCLKO */
271 			BERLIN_PINCTRL_FUNCTION(0x3, "sts6"), /* SOP */
272 			BERLIN_PINCTRL_FUNCTION(0x4, "adac"), /* DBG1 */
273 			BERLIN_PINCTRL_FUNCTION(0x6, "sd1b"), /* CMD */
274 			BERLIN_PINCTRL_FUNCTION(0x7, "avio")), /* DBG1 */
275 	BERLIN_PINCTRL_GROUP("I2S1_DO", 0x0, 0x3, 0x0c,
276 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO4 */
277 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* DO */
278 			BERLIN_PINCTRL_FUNCTION(0x3, "sts6"), /* SD */
279 			BERLIN_PINCTRL_FUNCTION(0x4, "adac"), /* DBG2 */
280 			BERLIN_PINCTRL_FUNCTION(0x6, "sd1b"), /* DAT0 */
281 			BERLIN_PINCTRL_FUNCTION(0x7, "avio")), /* DBG2 */
282 	BERLIN_PINCTRL_GROUP("I2S1_MCLK", 0x0, 0x3, 0x0f,
283 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO5 */
284 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* MCLK */
285 			BERLIN_PINCTRL_FUNCTION(0x3, "sts6"), /* VALD */
286 			BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* MCLK */
287 			BERLIN_PINCTRL_FUNCTION(0x6, "sd1b"), /* DAT1 */
288 			BERLIN_PINCTRL_FUNCTION(0x7, "avio")), /* DBG3 */
289 	BERLIN_PINCTRL_GROUP("SPDIFO", 0x0, 0x3, 0x12,
290 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO6 */
291 			BERLIN_PINCTRL_FUNCTION(0x1, "spdifo"),
292 			BERLIN_PINCTRL_FUNCTION(0x2, "avpll"), /* CLKO */
293 			BERLIN_PINCTRL_FUNCTION(0x4, "adac")), /* DBG3 */
294 	BERLIN_PINCTRL_GROUP("I2S2_MCLK", 0x0, 0x3, 0x15,
295 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO7 */
296 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* MCLK */
297 			BERLIN_PINCTRL_FUNCTION(0x4, "hdmi"), /* FBCLK */
298 			BERLIN_PINCTRL_FUNCTION(0x5, "pdm")), /* CLKO */
299 	BERLIN_PINCTRL_GROUP("I2S2_LRCKI", 0x0, 0x3, 0x18,
300 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO8 */
301 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* LRCKI */
302 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm0"),
303 			BERLIN_PINCTRL_FUNCTION(0x3, "sts7"), /* CLK */
304 			BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* LRCK */
305 			BERLIN_PINCTRL_FUNCTION(0x6, "sd1b")), /* DAT2 */
306 	BERLIN_PINCTRL_GROUP("I2S2_BCLKI", 0x0, 0x3, 0x1b,
307 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO9 */
308 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* BCLKI */
309 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm1"),
310 			BERLIN_PINCTRL_FUNCTION(0x3, "sts7"), /* SOP */
311 			BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* BCLK */
312 			BERLIN_PINCTRL_FUNCTION(0x6, "sd1b")), /* DAT3 */
313 	BERLIN_PINCTRL_GROUP("I2S2_DI0", 0x4, 0x3, 0x00,
314 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO10 */
315 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* DI0 */
316 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm2"),
317 			BERLIN_PINCTRL_FUNCTION(0x3, "sts7"), /* SD */
318 			BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* SDIN */
319 			BERLIN_PINCTRL_FUNCTION(0x5, "pdm"), /* DI0 */
320 			BERLIN_PINCTRL_FUNCTION(0x6, "sd1b")), /* CDn */
321 	BERLIN_PINCTRL_GROUP("I2S2_DI1", 0x4, 0x3, 0x03,
322 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO11 */
323 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* DI1 */
324 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm3"),
325 			BERLIN_PINCTRL_FUNCTION(0x3, "sts7"), /* VALD */
326 			BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* PWMCLK */
327 			BERLIN_PINCTRL_FUNCTION(0x5, "pdm"), /* DI1 */
328 			BERLIN_PINCTRL_FUNCTION(0x6, "sd1b")), /* WP */
329 };
330 
331 static const struct berlin_desc_group berlin4ct_sysmgr_pinctrl_groups[] = {
332 	BERLIN_PINCTRL_GROUP("SM_TW2_SCL", 0x0, 0x3, 0x00,
333 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO19 */
334 			BERLIN_PINCTRL_FUNCTION(0x1, "tw2")), /* SCL */
335 	BERLIN_PINCTRL_GROUP("SM_TW2_SDA", 0x0, 0x3, 0x03,
336 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO20 */
337 			BERLIN_PINCTRL_FUNCTION(0x1, "tw2")), /* SDA */
338 	BERLIN_PINCTRL_GROUP("SM_TW3_SCL", 0x0, 0x3, 0x06,
339 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO21 */
340 			BERLIN_PINCTRL_FUNCTION(0x1, "tw3")), /* SCL */
341 	BERLIN_PINCTRL_GROUP("SM_TW3_SDA", 0x0, 0x3, 0x09,
342 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO22 */
343 			BERLIN_PINCTRL_FUNCTION(0x1, "tw3")), /* SDA */
344 	BERLIN_PINCTRL_GROUP("SM_TMS", 0x0, 0x3, 0x0c,
345 			BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), /* TMS */
346 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* SM GPIO0 */
347 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm0")),
348 	BERLIN_PINCTRL_GROUP("SM_TDI", 0x0, 0x3, 0x0f,
349 			BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), /* TDI */
350 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* SM GPIO1 */
351 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm1")),
352 	BERLIN_PINCTRL_GROUP("SM_TDO", 0x0, 0x3, 0x12,
353 			BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), /* TDO */
354 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO2 */
355 	BERLIN_PINCTRL_GROUP("SM_URT0_TXD", 0x0, 0x3, 0x15,
356 			BERLIN_PINCTRL_FUNCTION(0x0, "uart0"), /* TXD */
357 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO3 */
358 	BERLIN_PINCTRL_GROUP("SM_URT0_RXD", 0x0, 0x3, 0x18,
359 			BERLIN_PINCTRL_FUNCTION(0x0, "uart0"), /* RXD */
360 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO4 */
361 	BERLIN_PINCTRL_GROUP("SM_URT1_TXD", 0x0, 0x3, 0x1b,
362 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO5 */
363 			BERLIN_PINCTRL_FUNCTION(0x1, "uart1"), /* TXD */
364 			BERLIN_PINCTRL_FUNCTION(0x2, "eth1"), /* RXCLK */
365 			BERLIN_PINCTRL_FUNCTION(0x3, "pwm2"),
366 			BERLIN_PINCTRL_FUNCTION(0x4, "timer0"),
367 			BERLIN_PINCTRL_FUNCTION(0x5, "clk_25m")),
368 	BERLIN_PINCTRL_GROUP("SM_URT1_RXD", 0x4, 0x3, 0x00,
369 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO6 */
370 			BERLIN_PINCTRL_FUNCTION(0x1, "uart1"), /* RXD */
371 			BERLIN_PINCTRL_FUNCTION(0x3, "pwm3"),
372 			BERLIN_PINCTRL_FUNCTION(0x4, "timer1")),
373 	BERLIN_PINCTRL_GROUP("SM_SPI2_SS0n", 0x4, 0x3, 0x03,
374 			BERLIN_PINCTRL_FUNCTION(0x0, "spi2"), /* SS0 n*/
375 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO7 */
376 	BERLIN_PINCTRL_GROUP("SM_SPI2_SS1n", 0x4, 0x3, 0x06,
377 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO8 */
378 			BERLIN_PINCTRL_FUNCTION(0x1, "spi2")), /* SS1n */
379 	BERLIN_PINCTRL_GROUP("SM_SPI2_SS2n", 0x4, 0x3, 0x09,
380 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO9 */
381 			BERLIN_PINCTRL_FUNCTION(0x1, "spi2"), /* SS2n */
382 			BERLIN_PINCTRL_FUNCTION(0x2, "eth1"), /* MDC */
383 			BERLIN_PINCTRL_FUNCTION(0x3, "pwm0"),
384 			BERLIN_PINCTRL_FUNCTION(0x4, "timer0"),
385 			BERLIN_PINCTRL_FUNCTION(0x5, "clk_25m")),
386 	BERLIN_PINCTRL_GROUP("SM_SPI2_SS3n", 0x4, 0x3, 0x0c,
387 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO10 */
388 			BERLIN_PINCTRL_FUNCTION(0x1, "spi2"), /* SS3n */
389 			BERLIN_PINCTRL_FUNCTION(0x2, "eth1"), /* MDIO */
390 			BERLIN_PINCTRL_FUNCTION(0x3, "pwm1"),
391 			BERLIN_PINCTRL_FUNCTION(0x4, "timer1")),
392 	BERLIN_PINCTRL_GROUP("SM_SPI2_SDO", 0x4, 0x3, 0x0f,
393 			BERLIN_PINCTRL_FUNCTION(0x0, "spi2"), /* SDO */
394 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO11 */
395 	BERLIN_PINCTRL_GROUP("SM_SPI2_SDI", 0x4, 0x3, 0x12,
396 			BERLIN_PINCTRL_FUNCTION(0x0, "spi2"), /* SDI */
397 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO12 */
398 	BERLIN_PINCTRL_GROUP("SM_SPI2_SCLK", 0x4, 0x3, 0x15,
399 			BERLIN_PINCTRL_FUNCTION(0x0, "spi2"), /* SCLK */
400 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO13 */
401 	BERLIN_PINCTRL_GROUP("SM_FE_LED0", 0x4, 0x3, 0x18,
402 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO14 */
403 			BERLIN_PINCTRL_FUNCTION(0x2, "led")), /* LED0 */
404 	BERLIN_PINCTRL_GROUP("SM_FE_LED1", 0x4, 0x3, 0x1b,
405 			BERLIN_PINCTRL_FUNCTION(0x0, "pwr"),
406 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* SM GPIO 15 */
407 			BERLIN_PINCTRL_FUNCTION(0x2, "led")), /* LED1 */
408 	BERLIN_PINCTRL_GROUP("SM_FE_LED2", 0x8, 0x3, 0x00,
409 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO16 */
410 			BERLIN_PINCTRL_FUNCTION(0x2, "led")), /* LED2 */
411 	BERLIN_PINCTRL_GROUP("SM_HDMI_HPD", 0x8, 0x3, 0x03,
412 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO17 */
413 			BERLIN_PINCTRL_FUNCTION(0x1, "hdmi")), /* HPD */
414 	BERLIN_PINCTRL_GROUP("SM_HDMI_CEC", 0x8, 0x3, 0x06,
415 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO18 */
416 			BERLIN_PINCTRL_FUNCTION(0x1, "hdmi")), /* CEC */
417 };
418 
419 static const struct berlin_pinctrl_desc berlin4ct_soc_pinctrl_data = {
420 	.groups = berlin4ct_soc_pinctrl_groups,
421 	.ngroups = ARRAY_SIZE(berlin4ct_soc_pinctrl_groups),
422 };
423 
424 static const struct berlin_pinctrl_desc berlin4ct_avio_pinctrl_data = {
425 	.groups = berlin4ct_avio_pinctrl_groups,
426 	.ngroups = ARRAY_SIZE(berlin4ct_avio_pinctrl_groups),
427 };
428 
429 static const struct berlin_pinctrl_desc berlin4ct_sysmgr_pinctrl_data = {
430 	.groups = berlin4ct_sysmgr_pinctrl_groups,
431 	.ngroups = ARRAY_SIZE(berlin4ct_sysmgr_pinctrl_groups),
432 };
433 
434 static const struct of_device_id berlin4ct_pinctrl_match[] = {
435 	{
436 		.compatible = "marvell,berlin4ct-soc-pinctrl",
437 		.data = &berlin4ct_soc_pinctrl_data,
438 	},
439 	{
440 		.compatible = "marvell,berlin4ct-avio-pinctrl",
441 		.data = &berlin4ct_avio_pinctrl_data,
442 	},
443 	{
444 		.compatible = "marvell,berlin4ct-system-pinctrl",
445 		.data = &berlin4ct_sysmgr_pinctrl_data,
446 	},
447 	{}
448 };
449 
450 static int berlin4ct_pinctrl_probe(struct platform_device *pdev)
451 {
452 	const struct of_device_id *match =
453 		of_match_device(berlin4ct_pinctrl_match, &pdev->dev);
454 	struct regmap_config *rmconfig;
455 	struct regmap *regmap;
456 	struct resource *res;
457 	void __iomem *base;
458 
459 	rmconfig = devm_kzalloc(&pdev->dev, sizeof(*rmconfig), GFP_KERNEL);
460 	if (!rmconfig)
461 		return -ENOMEM;
462 
463 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
464 	base = devm_ioremap_resource(&pdev->dev, res);
465 	if (IS_ERR(base))
466 		return PTR_ERR(base);
467 
468 	rmconfig->reg_bits = 32,
469 	rmconfig->val_bits = 32,
470 	rmconfig->reg_stride = 4,
471 	rmconfig->max_register = resource_size(res);
472 
473 	regmap = devm_regmap_init_mmio(&pdev->dev, base, rmconfig);
474 	if (IS_ERR(regmap))
475 		return PTR_ERR(regmap);
476 
477 	return berlin_pinctrl_probe_regmap(pdev, match->data, regmap);
478 }
479 
480 static struct platform_driver berlin4ct_pinctrl_driver = {
481 	.probe	= berlin4ct_pinctrl_probe,
482 	.driver	= {
483 		.name = "berlin4ct-pinctrl",
484 		.of_match_table = berlin4ct_pinctrl_match,
485 	},
486 };
487 builtin_platform_driver(berlin4ct_pinctrl_driver);
488