1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Synaptics AS370 pinctrl driver
4  *
5  * Copyright (C) 2018 Synaptics Incorporated
6  *
7  * Author: Jisheng Zhang <jszhang@kernel.org>
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 as370_soc_pinctrl_groups[] = {
18 	BERLIN_PINCTRL_GROUP("I2S1_BCLKIO", 0x0, 0x3, 0x00,
19 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO0 */
20 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* BCLKIO */
21 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG0 */
22 	BERLIN_PINCTRL_GROUP("I2S1_LRCKIO", 0x0, 0x3, 0x03,
23 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO1 */
24 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* LRCKIO */
25 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG1 */
26 	BERLIN_PINCTRL_GROUP("I2S1_DO0", 0x0, 0x3, 0x06,
27 			BERLIN_PINCTRL_FUNCTION(0x0, "por"), /* 1P8V RSTB*/
28 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* DO0 */
29 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio"), /* GPIO2 */
30 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG2 */
31 	BERLIN_PINCTRL_GROUP("I2S1_DO1", 0x0, 0x3, 0x09,
32 			BERLIN_PINCTRL_FUNCTION(0x0, "por"), /* 3P3V RSTB */
33 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* DO1 */
34 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio"), /* GPIO3 */
35 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG3 */
36 	BERLIN_PINCTRL_GROUP("I2S1_DO2", 0x0, 0x3, 0x0c,
37 			BERLIN_PINCTRL_FUNCTION(0x0, "por"), /* CORE RSTB */
38 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* DO2 */
39 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm"), /* PWM4 */
40 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio"), /* GPIO4 */
41 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG4 */
42 	BERLIN_PINCTRL_GROUP("I2S1_DO3", 0x0, 0x3, 0x0f,
43 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO5 */
44 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* DO3 */
45 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm"), /* PWM5 */
46 			BERLIN_PINCTRL_FUNCTION(0x3, "spdifib"), /* SPDIFIB */
47 			BERLIN_PINCTRL_FUNCTION(0x4, "spdifo"), /* SPDIFO */
48 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG5 */
49 	BERLIN_PINCTRL_GROUP("I2S1_MCLK", 0x0, 0x3, 0x12,
50 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO6 */
51 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* MCLK */
52 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG6 */
53 	BERLIN_PINCTRL_GROUP("I2S2_BCLKIO", 0x0, 0x3, 0x15,
54 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO7 */
55 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* BCLKIO */
56 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG7 */
57 	BERLIN_PINCTRL_GROUP("I2S2_LRCKIO", 0x0, 0x3, 0x18,
58 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO8 */
59 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* LRCKIO */
60 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG8 */
61 	BERLIN_PINCTRL_GROUP("I2S2_DI0", 0x0, 0x3, 0x1b,
62 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO9 */
63 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* DI0 */
64 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm"), /* PWM2 */
65 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG9 */
66 	BERLIN_PINCTRL_GROUP("I2S2_DI1", 0x4, 0x3, 0x00,
67 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO10 */
68 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* DI1 */
69 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm"), /* PWM3 */
70 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG10 */
71 	BERLIN_PINCTRL_GROUP("I2S2_DI2", 0x4, 0x3, 0x03,
72 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO11 */
73 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* DI2 */
74 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm"), /* PWM6 */
75 			BERLIN_PINCTRL_FUNCTION(0x3, "spdific"), /* SPDIFIC */
76 			BERLIN_PINCTRL_FUNCTION(0x4, "spdifo"), /* SPDIFO */
77 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG11 */
78 	BERLIN_PINCTRL_GROUP("I2S2_DI3", 0x4, 0x3, 0x06,
79 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO12 */
80 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* DI3 */
81 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm"), /* PWM7 */
82 			BERLIN_PINCTRL_FUNCTION(0x3, "spdifia"), /* SPDIFIA */
83 			BERLIN_PINCTRL_FUNCTION(0x4, "spdifo"), /* SPDIFO */
84 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG12 */
85 	BERLIN_PINCTRL_GROUP("PDM_CLKO", 0x4, 0x3, 0x09,
86 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO13 */
87 			BERLIN_PINCTRL_FUNCTION(0x1, "pdm"), /* CLKO */
88 			BERLIN_PINCTRL_FUNCTION(0x2, "i2s2"), /* MCLK */
89 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG13 */
90 	BERLIN_PINCTRL_GROUP("PDM_DI0", 0x4, 0x3, 0x0c,
91 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO14 */
92 			BERLIN_PINCTRL_FUNCTION(0x1, "pdm"), /* DI0 */
93 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG14 */
94 	BERLIN_PINCTRL_GROUP("PDM_DI1", 0x4, 0x3, 0x0f,
95 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO15 */
96 			BERLIN_PINCTRL_FUNCTION(0x1, "pdm"), /* DI1 */
97 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG15 */
98 	BERLIN_PINCTRL_GROUP("PDM_DI2", 0x4, 0x3, 0x12,
99 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO16 */
100 			BERLIN_PINCTRL_FUNCTION(0x1, "pdm"), /* DI2 */
101 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm"), /* PWM4 */
102 			BERLIN_PINCTRL_FUNCTION(0x3, "spdifid"), /* SPDIFID */
103 			BERLIN_PINCTRL_FUNCTION(0x4, "spdifo"), /* SPDIFO */
104 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG16 */
105 	BERLIN_PINCTRL_GROUP("PDM_DI3", 0x4, 0x3, 0x15,
106 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO17 */
107 			BERLIN_PINCTRL_FUNCTION(0x1, "pdm"), /* DI3 */
108 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm"), /* PWM5 */
109 			BERLIN_PINCTRL_FUNCTION(0x3, "spdifi"), /* SPDIFI */
110 			BERLIN_PINCTRL_FUNCTION(0x4, "spdifo"), /* SPDIFO */
111 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG17 */
112 	BERLIN_PINCTRL_GROUP("NAND_IO0", 0x4, 0x3, 0x18,
113 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO0 */
114 			BERLIN_PINCTRL_FUNCTION(0x1, "emmc"), /* DATA0 */
115 			BERLIN_PINCTRL_FUNCTION(0x4, "pcie0")), /* MDIO */
116 	BERLIN_PINCTRL_GROUP("NAND_IO1", 0x4, 0x3, 0x1b,
117 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO1 */
118 			BERLIN_PINCTRL_FUNCTION(0x1, "emmc"), /* DATA1 */
119 			BERLIN_PINCTRL_FUNCTION(0x4, "pcie0")), /* MDC */
120 	BERLIN_PINCTRL_GROUP("NAND_IO2", 0x8, 0x3, 0x00,
121 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO2 */
122 			BERLIN_PINCTRL_FUNCTION(0x1, "emmc"), /* DATA2 */
123 			BERLIN_PINCTRL_FUNCTION(0x4, "pcie1")), /* MDIO */
124 	BERLIN_PINCTRL_GROUP("NAND_IO3", 0x8, 0x3, 0x03,
125 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO3 */
126 			BERLIN_PINCTRL_FUNCTION(0x1, "emmc"), /* DATA3 */
127 			BERLIN_PINCTRL_FUNCTION(0x4, "pcie1")), /* MDC */
128 	BERLIN_PINCTRL_GROUP("NAND_IO4", 0x8, 0x3, 0x06,
129 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO4 */
130 			BERLIN_PINCTRL_FUNCTION(0x1, "emmc")), /* DATA4 */
131 	BERLIN_PINCTRL_GROUP("NAND_IO5", 0x8, 0x3, 0x09,
132 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO5 */
133 			BERLIN_PINCTRL_FUNCTION(0x1, "emmc")), /* DATA5 */
134 	BERLIN_PINCTRL_GROUP("NAND_IO6", 0x8, 0x3, 0x0c,
135 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO6 */
136 			BERLIN_PINCTRL_FUNCTION(0x1, "emmc")), /* DATA6 */
137 	BERLIN_PINCTRL_GROUP("NAND_IO7", 0x8, 0x3, 0x0f,
138 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO7 */
139 			BERLIN_PINCTRL_FUNCTION(0x1, "emmc")), /* DATA7 */
140 	BERLIN_PINCTRL_GROUP("NAND_ALE", 0x8, 0x3, 0x12,
141 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* ALE */
142 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm"), /* PWM6 */
143 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO18 */
144 	BERLIN_PINCTRL_GROUP("NAND_CLE", 0x8, 0x3, 0x15,
145 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* CLE */
146 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm"), /* PWM7 */
147 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO19 */
148 	BERLIN_PINCTRL_GROUP("NAND_WEn", 0x8, 0x3, 0x18,
149 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* WEn */
150 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO20 */
151 	BERLIN_PINCTRL_GROUP("NAND_REn", 0x8, 0x3, 0x1b,
152 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* REn */
153 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO21 */
154 	BERLIN_PINCTRL_GROUP("NAND_WPn", 0xc, 0x3, 0x00,
155 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* WPn */
156 			BERLIN_PINCTRL_FUNCTION(0x1, "emmc"), /* CLK */
157 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO22 */
158 	BERLIN_PINCTRL_GROUP("NAND_CEn", 0xc, 0x3, 0x03,
159 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* CEn */
160 			BERLIN_PINCTRL_FUNCTION(0x1, "emmc"), /* RSTn */
161 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO23 */
162 	BERLIN_PINCTRL_GROUP("NAND_RDY", 0xc, 0x3, 0x06,
163 			BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* RDY */
164 			BERLIN_PINCTRL_FUNCTION(0x1, "emmc"), /* CMD */
165 			BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO24 */
166 	BERLIN_PINCTRL_GROUP("SPI1_SS0n", 0xc, 0x3, 0x09,
167 			BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS0n */
168 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* GPIO25 */
169 	BERLIN_PINCTRL_GROUP("SPI1_SS1n", 0xc, 0x3, 0x0c,
170 			BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS1n */
171 			BERLIN_PINCTRL_FUNCTION(0x2, "gpio"), /* GPIO26 */
172 			BERLIN_PINCTRL_FUNCTION(0x3, "pwm")), /* PWM2 */
173 	BERLIN_PINCTRL_GROUP("SPI1_SS2n", 0xc, 0x3, 0x0f,
174 			BERLIN_PINCTRL_FUNCTION(0x0, "uart0"), /* RXD */
175 			BERLIN_PINCTRL_FUNCTION(0x1, "spi1"), /* SS2n */
176 			BERLIN_PINCTRL_FUNCTION(0x2, "gpio"), /* GPIO27 */
177 			BERLIN_PINCTRL_FUNCTION(0x3, "pwm")), /* PWM3 */
178 	BERLIN_PINCTRL_GROUP("SPI1_SS3n", 0xc, 0x3, 0x12,
179 			BERLIN_PINCTRL_FUNCTION(0x0, "uart0"), /* TXD */
180 			BERLIN_PINCTRL_FUNCTION(0x1, "spi1"), /* SS3n */
181 			BERLIN_PINCTRL_FUNCTION(0x2, "gpio")), /* GPIO28 */
182 	BERLIN_PINCTRL_GROUP("SPI1_SCLK", 0xc, 0x3, 0x15,
183 			BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SCLK */
184 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO29 */
185 			BERLIN_PINCTRL_FUNCTION(0x3, "pwm")), /* PWM4 */
186 	BERLIN_PINCTRL_GROUP("SPI1_SDO", 0xc, 0x3, 0x18,
187 			BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SDO */
188 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO30 */
189 			BERLIN_PINCTRL_FUNCTION(0x3, "pwm")), /* PWM5 */
190 	BERLIN_PINCTRL_GROUP("SPI1_SDI", 0xc, 0x3, 0x1b,
191 			BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SDI */
192 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* GPIO31 */
193 	BERLIN_PINCTRL_GROUP("USB0_DRV_VBUS", 0x10, 0x3, 0x00,
194 			BERLIN_PINCTRL_FUNCTION(0x0, "usb0"), /* VBUS */
195 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO32 */
196 			BERLIN_PINCTRL_FUNCTION(0x3, "refclko")), /* 25M */
197 	BERLIN_PINCTRL_GROUP("TW1_SCL", 0x10, 0x3, 0x03,
198 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO33 */
199 			BERLIN_PINCTRL_FUNCTION(0x1, "tw1")), /* SCL */
200 	BERLIN_PINCTRL_GROUP("TW1_SDA", 0x10, 0x3, 0x06,
201 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO34 */
202 			BERLIN_PINCTRL_FUNCTION(0x1, "tw1")), /* SDA */
203 	BERLIN_PINCTRL_GROUP("TW0_SCL", 0x10, 0x3, 0x09,
204 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO35 */
205 			BERLIN_PINCTRL_FUNCTION(0x1, "tw0")), /* SCL */
206 	BERLIN_PINCTRL_GROUP("TW0_SDA", 0x10, 0x3, 0x0c,
207 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO36 */
208 			BERLIN_PINCTRL_FUNCTION(0x1, "tw0")), /* SDA */
209 	BERLIN_PINCTRL_GROUP("TMS", 0x10, 0x3, 0x0f,
210 			BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), /* TMS */
211 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO37 */
212 			BERLIN_PINCTRL_FUNCTION(0x4, "pwm")), /* PWM0 */
213 	BERLIN_PINCTRL_GROUP("TDI", 0x10, 0x3, 0x12,
214 			BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), /* TDI */
215 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO38 */
216 			BERLIN_PINCTRL_FUNCTION(0x4, "pwm")), /* PWM1 */
217 	BERLIN_PINCTRL_GROUP("TDO", 0x10, 0x3, 0x15,
218 			BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), /* TDO */
219 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO39 */
220 			BERLIN_PINCTRL_FUNCTION(0x4, "pwm")), /* PWM0 */
221 	BERLIN_PINCTRL_GROUP("PWM6", 0x10, 0x3, 0x18,
222 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO40 */
223 			BERLIN_PINCTRL_FUNCTION(0x1, "pwm")), /* PWM6 */
224 	BERLIN_PINCTRL_GROUP("PWM7", 0x10, 0x3, 0x1b,
225 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO41 */
226 			BERLIN_PINCTRL_FUNCTION(0x1, "pwm")), /* PWM7 */
227 	BERLIN_PINCTRL_GROUP("PWM0", 0x14, 0x3, 0x00,
228 			BERLIN_PINCTRL_FUNCTION(0x0, "por"), /* VDDCPUSOC RSTB */
229 			BERLIN_PINCTRL_FUNCTION(0x1, "pwm"), /* PWM0 */
230 			BERLIN_PINCTRL_FUNCTION(0x2, "gpio")), /* GPIO42 */
231 	BERLIN_PINCTRL_GROUP("PWM1", 0x14, 0x3, 0x03,
232 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO43 */
233 			BERLIN_PINCTRL_FUNCTION(0x1, "pwm")), /* PWM1 */
234 	BERLIN_PINCTRL_GROUP("PWM2", 0x14, 0x3, 0x06,
235 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO44 */
236 			BERLIN_PINCTRL_FUNCTION(0x1, "pwm")), /* PWM2 */
237 	BERLIN_PINCTRL_GROUP("PWM3", 0x14, 0x3, 0x09,
238 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO45 */
239 			BERLIN_PINCTRL_FUNCTION(0x1, "pwm")), /* PWM3 */
240 	BERLIN_PINCTRL_GROUP("PWM4", 0x14, 0x3, 0x0c,
241 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO46 */
242 			BERLIN_PINCTRL_FUNCTION(0x1, "pwm")), /* PWM4 */
243 	BERLIN_PINCTRL_GROUP("PWM5", 0x14, 0x3, 0x0f,
244 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO47 */
245 			BERLIN_PINCTRL_FUNCTION(0x1, "pwm")), /* PWM5 */
246 	BERLIN_PINCTRL_GROUP("URT1_RTSn", 0x14, 0x3, 0x12,
247 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO48 */
248 			BERLIN_PINCTRL_FUNCTION(0x1, "uart1"), /* RTSn */
249 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm"), /* PWM6 */
250 			BERLIN_PINCTRL_FUNCTION(0x3, "tw1a"), /* SCL */
251 			BERLIN_PINCTRL_FUNCTION(0x4, "aio"), /* DBG0 */
252 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG18 */
253 	BERLIN_PINCTRL_GROUP("URT1_CTSn", 0x14, 0x3, 0x15,
254 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO49 */
255 			BERLIN_PINCTRL_FUNCTION(0x1, "uart1"), /* CTSn */
256 			BERLIN_PINCTRL_FUNCTION(0x2, "pwm"), /* PWM7 */
257 			BERLIN_PINCTRL_FUNCTION(0x3, "tw1a"), /* SDA */
258 			BERLIN_PINCTRL_FUNCTION(0x4, "aio"), /* DBG1 */
259 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG19 */
260 	BERLIN_PINCTRL_GROUP("URT1_RXD", 0x14, 0x3, 0x18,
261 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO50 */
262 			BERLIN_PINCTRL_FUNCTION(0x1, "uart1"), /* RXD */
263 			BERLIN_PINCTRL_FUNCTION(0x4, "aio"), /* DBG2 */
264 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG20 */
265 	BERLIN_PINCTRL_GROUP("URT1_TXD", 0x14, 0x3, 0x1b,
266 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO51 */
267 			BERLIN_PINCTRL_FUNCTION(0x1, "uart1"), /* TXD */
268 			BERLIN_PINCTRL_FUNCTION(0x4, "aio"), /* DBG3 */
269 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG21 */
270 	BERLIN_PINCTRL_GROUP("I2S3_DI", 0x18, 0x3, 0x00,
271 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO52 */
272 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s3"), /* DI */
273 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG22 */
274 	BERLIN_PINCTRL_GROUP("I2S3_DO", 0x18, 0x3, 0x03,
275 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO53 */
276 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s3"), /* DO */
277 			BERLIN_PINCTRL_FUNCTION(0x5, "phy")), /* DBG23 */
278 	BERLIN_PINCTRL_GROUP("I2S3_BCLKIO", 0x18, 0x3, 0x06,
279 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO54 */
280 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s3"), /* BCLKIO */
281 			BERLIN_PINCTRL_FUNCTION(0x5, "clk")), /* DBG */
282 	BERLIN_PINCTRL_GROUP("I2S3_LRCKIO", 0x18, 0x3, 0x09,
283 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO55 */
284 			BERLIN_PINCTRL_FUNCTION(0x1, "i2s3")), /* LRCKIO */
285 	BERLIN_PINCTRL_GROUP("SD0_DAT0", 0x18, 0x3, 0x0c,
286 			BERLIN_PINCTRL_FUNCTION(0x0, "cpupll"), /* OUT */
287 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT0 */
288 			BERLIN_PINCTRL_FUNCTION(0x2, "gpio")), /* GPIO56 */
289 	BERLIN_PINCTRL_GROUP("SD0_DAT1", 0x18, 0x3, 0x0f,
290 			BERLIN_PINCTRL_FUNCTION(0x0, "syspll"), /* OUT */
291 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT1 */
292 			BERLIN_PINCTRL_FUNCTION(0x2, "gpio")), /* GPIO57 */
293 	BERLIN_PINCTRL_GROUP("SD0_CLK", 0x18, 0x3, 0x12,
294 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO58 */
295 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0")), /* CLK */
296 	BERLIN_PINCTRL_GROUP("SD0_DAT2", 0x18, 0x3, 0x15,
297 			BERLIN_PINCTRL_FUNCTION(0x0, "mempll"), /* OUT */
298 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT2 */
299 			BERLIN_PINCTRL_FUNCTION(0x2, "gpio")), /* GPIO59 */
300 	BERLIN_PINCTRL_GROUP("SD0_DAT3", 0x18, 0x3, 0x18,
301 			BERLIN_PINCTRL_FUNCTION(0x0, "apll0"), /* OUT */
302 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT3 */
303 			BERLIN_PINCTRL_FUNCTION(0x2, "gpio")), /* GPIO60 */
304 	BERLIN_PINCTRL_GROUP("SD0_CMD", 0x18, 0x3, 0x1b,
305 			BERLIN_PINCTRL_FUNCTION(0x0, "apll1"), /* OUT */
306 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* CMD */
307 			BERLIN_PINCTRL_FUNCTION(0x2, "gpio")), /* GPIO61 */
308 	BERLIN_PINCTRL_GROUP("SD0_CDn", 0x1c, 0x3, 0x00,
309 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO62 */
310 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* CDn */
311 			BERLIN_PINCTRL_FUNCTION(0x3, "pwm")), /* PWM2 */
312 	BERLIN_PINCTRL_GROUP("SD0_WP", 0x1c, 0x3, 0x03,
313 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO63 */
314 			BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* WP */
315 			BERLIN_PINCTRL_FUNCTION(0x3, "pwm")), /* PWM3 */
316 };
317 
318 static const struct berlin_pinctrl_desc as370_soc_pinctrl_data = {
319 	.groups = as370_soc_pinctrl_groups,
320 	.ngroups = ARRAY_SIZE(as370_soc_pinctrl_groups),
321 };
322 
323 static const struct of_device_id as370_pinctrl_match[] = {
324 	{
325 		.compatible = "syna,as370-soc-pinctrl",
326 		.data = &as370_soc_pinctrl_data,
327 	},
328 	{}
329 };
330 
331 static int as370_pinctrl_probe(struct platform_device *pdev)
332 {
333 	const struct of_device_id *match =
334 		of_match_device(as370_pinctrl_match, &pdev->dev);
335 	struct regmap_config *rmconfig;
336 	struct regmap *regmap;
337 	struct resource *res;
338 	void __iomem *base;
339 
340 	rmconfig = devm_kzalloc(&pdev->dev, sizeof(*rmconfig), GFP_KERNEL);
341 	if (!rmconfig)
342 		return -ENOMEM;
343 
344 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
345 	base = devm_ioremap_resource(&pdev->dev, res);
346 	if (IS_ERR(base))
347 		return PTR_ERR(base);
348 
349 	rmconfig->reg_bits = 32,
350 	rmconfig->val_bits = 32,
351 	rmconfig->reg_stride = 4,
352 	rmconfig->max_register = resource_size(res);
353 
354 	regmap = devm_regmap_init_mmio(&pdev->dev, base, rmconfig);
355 	if (IS_ERR(regmap))
356 		return PTR_ERR(regmap);
357 
358 	return berlin_pinctrl_probe_regmap(pdev, match->data, regmap);
359 }
360 
361 static struct platform_driver as370_pinctrl_driver = {
362 	.probe	= as370_pinctrl_probe,
363 	.driver	= {
364 		.name = "as370-pinctrl",
365 		.of_match_table = as370_pinctrl_match,
366 	},
367 };
368 builtin_platform_driver(as370_pinctrl_driver);
369