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