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