xref: /linux/drivers/pinctrl/vt8500/pinctrl-wm8505.c (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Pinctrl data for Wondermedia WM8505 SoC
4  *
5  * Copyright (c) 2013 Tony Prisk <linux@prisktech.co.nz>
6  */
7 
8 #include <linux/io.h>
9 #include <linux/init.h>
10 #include <linux/pinctrl/pinctrl.h>
11 #include <linux/platform_device.h>
12 #include <linux/slab.h>
13 
14 #include "pinctrl-wmt.h"
15 
16 /*
17  * Describe the register offsets within the GPIO memory space
18  * The dedicated external GPIO's should always be listed in bank 0
19  * so they are exported in the 0..31 range which is what users
20  * expect.
21  *
22  * Do not reorder these banks as it will change the pin numbering
23  */
24 static const struct wmt_pinctrl_bank_registers wm8505_banks[] = {
25 	WMT_PINCTRL_BANK(0x64, 0x8C, 0xB4, 0xDC, NO_REG, NO_REG),	/* 0 */
26 	WMT_PINCTRL_BANK(0x40, 0x68, 0x90, 0xB8, NO_REG, NO_REG),	/* 1 */
27 	WMT_PINCTRL_BANK(0x44, 0x6C, 0x94, 0xBC, NO_REG, NO_REG),	/* 2 */
28 	WMT_PINCTRL_BANK(0x48, 0x70, 0x98, 0xC0, NO_REG, NO_REG),	/* 3 */
29 	WMT_PINCTRL_BANK(0x4C, 0x74, 0x9C, 0xC4, NO_REG, NO_REG),	/* 4 */
30 	WMT_PINCTRL_BANK(0x50, 0x78, 0xA0, 0xC8, NO_REG, NO_REG),	/* 5 */
31 	WMT_PINCTRL_BANK(0x54, 0x7C, 0xA4, 0xD0, NO_REG, NO_REG),	/* 6 */
32 	WMT_PINCTRL_BANK(0x58, 0x80, 0xA8, 0xD4, NO_REG, NO_REG),	/* 7 */
33 	WMT_PINCTRL_BANK(0x5C, 0x84, 0xAC, 0xD8, NO_REG, NO_REG),	/* 8 */
34 	WMT_PINCTRL_BANK(0x60, 0x88, 0xB0, 0xDC, NO_REG, NO_REG),	/* 9 */
35 	WMT_PINCTRL_BANK(0x500, 0x504, 0x508, 0x50C, NO_REG, NO_REG),	/* 10 */
36 };
37 
38 /* Please keep sorted by bank/bit */
39 #define WMT_PIN_EXTGPIO0	WMT_PIN(0, 0)
40 #define WMT_PIN_EXTGPIO1	WMT_PIN(0, 1)
41 #define WMT_PIN_EXTGPIO2	WMT_PIN(0, 2)
42 #define WMT_PIN_EXTGPIO3	WMT_PIN(0, 3)
43 #define WMT_PIN_EXTGPIO4	WMT_PIN(0, 4)
44 #define WMT_PIN_EXTGPIO5	WMT_PIN(0, 5)
45 #define WMT_PIN_EXTGPIO6	WMT_PIN(0, 6)
46 #define WMT_PIN_EXTGPIO7	WMT_PIN(0, 7)
47 #define WMT_PIN_WAKEUP0		WMT_PIN(0, 16)
48 #define WMT_PIN_WAKEUP1		WMT_PIN(0, 17)
49 #define WMT_PIN_WAKEUP2		WMT_PIN(0, 18)
50 #define WMT_PIN_WAKEUP3		WMT_PIN(0, 19)
51 #define WMT_PIN_SUSGPIO0	WMT_PIN(0, 21)
52 #define WMT_PIN_SDDATA0		WMT_PIN(1, 0)
53 #define WMT_PIN_SDDATA1		WMT_PIN(1, 1)
54 #define WMT_PIN_SDDATA2		WMT_PIN(1, 2)
55 #define WMT_PIN_SDDATA3		WMT_PIN(1, 3)
56 #define WMT_PIN_MMCDATA0	WMT_PIN(1, 4)
57 #define WMT_PIN_MMCDATA1	WMT_PIN(1, 5)
58 #define WMT_PIN_MMCDATA2	WMT_PIN(1, 6)
59 #define WMT_PIN_MMCDATA3	WMT_PIN(1, 7)
60 #define WMT_PIN_VDIN0		WMT_PIN(2, 0)
61 #define WMT_PIN_VDIN1		WMT_PIN(2, 1)
62 #define WMT_PIN_VDIN2		WMT_PIN(2, 2)
63 #define WMT_PIN_VDIN3		WMT_PIN(2, 3)
64 #define WMT_PIN_VDIN4		WMT_PIN(2, 4)
65 #define WMT_PIN_VDIN5		WMT_PIN(2, 5)
66 #define WMT_PIN_VDIN6		WMT_PIN(2, 6)
67 #define WMT_PIN_VDIN7		WMT_PIN(2, 7)
68 #define WMT_PIN_VDOUT0		WMT_PIN(2, 8)
69 #define WMT_PIN_VDOUT1		WMT_PIN(2, 9)
70 #define WMT_PIN_VDOUT2		WMT_PIN(2, 10)
71 #define WMT_PIN_VDOUT3		WMT_PIN(2, 11)
72 #define WMT_PIN_VDOUT4		WMT_PIN(2, 12)
73 #define WMT_PIN_VDOUT5		WMT_PIN(2, 13)
74 #define WMT_PIN_VDOUT6		WMT_PIN(2, 14)
75 #define WMT_PIN_VDOUT7		WMT_PIN(2, 15)
76 #define WMT_PIN_VDOUT8		WMT_PIN(2, 16)
77 #define WMT_PIN_VDOUT9		WMT_PIN(2, 17)
78 #define WMT_PIN_VDOUT10		WMT_PIN(2, 18)
79 #define WMT_PIN_VDOUT11		WMT_PIN(2, 19)
80 #define WMT_PIN_VDOUT12		WMT_PIN(2, 20)
81 #define WMT_PIN_VDOUT13		WMT_PIN(2, 21)
82 #define WMT_PIN_VDOUT14		WMT_PIN(2, 22)
83 #define WMT_PIN_VDOUT15		WMT_PIN(2, 23)
84 #define WMT_PIN_VDOUT16		WMT_PIN(2, 24)
85 #define WMT_PIN_VDOUT17		WMT_PIN(2, 25)
86 #define WMT_PIN_VDOUT18		WMT_PIN(2, 26)
87 #define WMT_PIN_VDOUT19		WMT_PIN(2, 27)
88 #define WMT_PIN_VDOUT20		WMT_PIN(2, 28)
89 #define WMT_PIN_VDOUT21		WMT_PIN(2, 29)
90 #define WMT_PIN_VDOUT22		WMT_PIN(2, 30)
91 #define WMT_PIN_VDOUT23		WMT_PIN(2, 31)
92 #define WMT_PIN_VHSYNC		WMT_PIN(3, 0)
93 #define WMT_PIN_VVSYNC		WMT_PIN(3, 1)
94 #define WMT_PIN_VGAHSYNC	WMT_PIN(3, 2)
95 #define WMT_PIN_VGAVSYNC	WMT_PIN(3, 3)
96 #define WMT_PIN_VDHSYNC		WMT_PIN(3, 4)
97 #define WMT_PIN_VDVSYNC		WMT_PIN(3, 5)
98 #define WMT_PIN_NORD0		WMT_PIN(4, 0)
99 #define WMT_PIN_NORD1		WMT_PIN(4, 1)
100 #define WMT_PIN_NORD2		WMT_PIN(4, 2)
101 #define WMT_PIN_NORD3		WMT_PIN(4, 3)
102 #define WMT_PIN_NORD4		WMT_PIN(4, 4)
103 #define WMT_PIN_NORD5		WMT_PIN(4, 5)
104 #define WMT_PIN_NORD6		WMT_PIN(4, 6)
105 #define WMT_PIN_NORD7		WMT_PIN(4, 7)
106 #define WMT_PIN_NORD8		WMT_PIN(4, 8)
107 #define WMT_PIN_NORD9		WMT_PIN(4, 9)
108 #define WMT_PIN_NORD10		WMT_PIN(4, 10)
109 #define WMT_PIN_NORD11		WMT_PIN(4, 11)
110 #define WMT_PIN_NORD12		WMT_PIN(4, 12)
111 #define WMT_PIN_NORD13		WMT_PIN(4, 13)
112 #define WMT_PIN_NORD14		WMT_PIN(4, 14)
113 #define WMT_PIN_NORD15		WMT_PIN(4, 15)
114 #define WMT_PIN_NORA0		WMT_PIN(5, 0)
115 #define WMT_PIN_NORA1		WMT_PIN(5, 1)
116 #define WMT_PIN_NORA2		WMT_PIN(5, 2)
117 #define WMT_PIN_NORA3		WMT_PIN(5, 3)
118 #define WMT_PIN_NORA4		WMT_PIN(5, 4)
119 #define WMT_PIN_NORA5		WMT_PIN(5, 5)
120 #define WMT_PIN_NORA6		WMT_PIN(5, 6)
121 #define WMT_PIN_NORA7		WMT_PIN(5, 7)
122 #define WMT_PIN_NORA8		WMT_PIN(5, 8)
123 #define WMT_PIN_NORA9		WMT_PIN(5, 9)
124 #define WMT_PIN_NORA10		WMT_PIN(5, 10)
125 #define WMT_PIN_NORA11		WMT_PIN(5, 11)
126 #define WMT_PIN_NORA12		WMT_PIN(5, 12)
127 #define WMT_PIN_NORA13		WMT_PIN(5, 13)
128 #define WMT_PIN_NORA14		WMT_PIN(5, 14)
129 #define WMT_PIN_NORA15		WMT_PIN(5, 15)
130 #define WMT_PIN_NORA16		WMT_PIN(5, 16)
131 #define WMT_PIN_NORA17		WMT_PIN(5, 17)
132 #define WMT_PIN_NORA18		WMT_PIN(5, 18)
133 #define WMT_PIN_NORA19		WMT_PIN(5, 19)
134 #define WMT_PIN_NORA20		WMT_PIN(5, 20)
135 #define WMT_PIN_NORA21		WMT_PIN(5, 21)
136 #define WMT_PIN_NORA22		WMT_PIN(5, 22)
137 #define WMT_PIN_NORA23		WMT_PIN(5, 23)
138 #define WMT_PIN_NORA24		WMT_PIN(5, 24)
139 #define WMT_PIN_AC97SDI		WMT_PIN(6, 0)
140 #define WMT_PIN_AC97SYNC	WMT_PIN(6, 1)
141 #define WMT_PIN_AC97SDO		WMT_PIN(6, 2)
142 #define WMT_PIN_AC97BCLK	WMT_PIN(6, 3)
143 #define WMT_PIN_AC97RST		WMT_PIN(6, 4)
144 #define WMT_PIN_SFDO		WMT_PIN(7, 0)
145 #define WMT_PIN_SFCS0		WMT_PIN(7, 1)
146 #define WMT_PIN_SFCS1		WMT_PIN(7, 2)
147 #define WMT_PIN_SFCLK		WMT_PIN(7, 3)
148 #define WMT_PIN_SFDI		WMT_PIN(7, 4)
149 #define WMT_PIN_SPI0CLK		WMT_PIN(8, 0)
150 #define WMT_PIN_SPI0MISO	WMT_PIN(8, 1)
151 #define WMT_PIN_SPI0MOSI	WMT_PIN(8, 2)
152 #define WMT_PIN_SPI0SS		WMT_PIN(8, 3)
153 #define WMT_PIN_SPI1CLK		WMT_PIN(8, 4)
154 #define WMT_PIN_SPI1MISO	WMT_PIN(8, 5)
155 #define WMT_PIN_SPI1MOSI	WMT_PIN(8, 6)
156 #define WMT_PIN_SPI1SS		WMT_PIN(8, 7)
157 #define WMT_PIN_SPI2CLK		WMT_PIN(8, 8)
158 #define WMT_PIN_SPI2MISO	WMT_PIN(8, 9)
159 #define WMT_PIN_SPI2MOSI	WMT_PIN(8, 10)
160 #define WMT_PIN_SPI2SS		WMT_PIN(8, 11)
161 #define WMT_PIN_UART0_RTS	WMT_PIN(9, 0)
162 #define WMT_PIN_UART0_TXD	WMT_PIN(9, 1)
163 #define WMT_PIN_UART0_CTS	WMT_PIN(9, 2)
164 #define WMT_PIN_UART0_RXD	WMT_PIN(9, 3)
165 #define WMT_PIN_UART1_RTS	WMT_PIN(9, 4)
166 #define WMT_PIN_UART1_TXD	WMT_PIN(9, 5)
167 #define WMT_PIN_UART1_CTS	WMT_PIN(9, 6)
168 #define WMT_PIN_UART1_RXD	WMT_PIN(9, 7)
169 #define WMT_PIN_UART2_RTS	WMT_PIN(9, 8)
170 #define WMT_PIN_UART2_TXD	WMT_PIN(9, 9)
171 #define WMT_PIN_UART2_CTS	WMT_PIN(9, 10)
172 #define WMT_PIN_UART2_RXD	WMT_PIN(9, 11)
173 #define WMT_PIN_UART3_RTS	WMT_PIN(9, 12)
174 #define WMT_PIN_UART3_TXD	WMT_PIN(9, 13)
175 #define WMT_PIN_UART3_CTS	WMT_PIN(9, 14)
176 #define WMT_PIN_UART3_RXD	WMT_PIN(9, 15)
177 #define WMT_PIN_I2C0SCL		WMT_PIN(10, 0)
178 #define WMT_PIN_I2C0SDA		WMT_PIN(10, 1)
179 #define WMT_PIN_I2C1SCL		WMT_PIN(10, 2)
180 #define WMT_PIN_I2C1SDA		WMT_PIN(10, 3)
181 #define WMT_PIN_I2C2SCL		WMT_PIN(10, 4)
182 #define WMT_PIN_I2C2SDA		WMT_PIN(10, 5)
183 
184 static const struct pinctrl_pin_desc wm8505_pins[] = {
185 	PINCTRL_PIN(WMT_PIN_EXTGPIO0, "extgpio0"),
186 	PINCTRL_PIN(WMT_PIN_EXTGPIO1, "extgpio1"),
187 	PINCTRL_PIN(WMT_PIN_EXTGPIO2, "extgpio2"),
188 	PINCTRL_PIN(WMT_PIN_EXTGPIO3, "extgpio3"),
189 	PINCTRL_PIN(WMT_PIN_EXTGPIO4, "extgpio4"),
190 	PINCTRL_PIN(WMT_PIN_EXTGPIO5, "extgpio5"),
191 	PINCTRL_PIN(WMT_PIN_EXTGPIO6, "extgpio6"),
192 	PINCTRL_PIN(WMT_PIN_EXTGPIO7, "extgpio7"),
193 	PINCTRL_PIN(WMT_PIN_WAKEUP0, "wakeup0"),
194 	PINCTRL_PIN(WMT_PIN_WAKEUP1, "wakeup1"),
195 	PINCTRL_PIN(WMT_PIN_WAKEUP2, "wakeup2"),
196 	PINCTRL_PIN(WMT_PIN_WAKEUP3, "wakeup3"),
197 	PINCTRL_PIN(WMT_PIN_SUSGPIO0, "susgpio0"),
198 	PINCTRL_PIN(WMT_PIN_SDDATA0, "sd_data0"),
199 	PINCTRL_PIN(WMT_PIN_SDDATA1, "sd_data1"),
200 	PINCTRL_PIN(WMT_PIN_SDDATA2, "sd_data2"),
201 	PINCTRL_PIN(WMT_PIN_SDDATA3, "sd_data3"),
202 	PINCTRL_PIN(WMT_PIN_MMCDATA0, "mmc_data0"),
203 	PINCTRL_PIN(WMT_PIN_MMCDATA1, "mmc_data1"),
204 	PINCTRL_PIN(WMT_PIN_MMCDATA2, "mmc_data2"),
205 	PINCTRL_PIN(WMT_PIN_MMCDATA3, "mmc_data3"),
206 	PINCTRL_PIN(WMT_PIN_VDIN0, "vdin0"),
207 	PINCTRL_PIN(WMT_PIN_VDIN1, "vdin1"),
208 	PINCTRL_PIN(WMT_PIN_VDIN2, "vdin2"),
209 	PINCTRL_PIN(WMT_PIN_VDIN3, "vdin3"),
210 	PINCTRL_PIN(WMT_PIN_VDIN4, "vdin4"),
211 	PINCTRL_PIN(WMT_PIN_VDIN5, "vdin5"),
212 	PINCTRL_PIN(WMT_PIN_VDIN6, "vdin6"),
213 	PINCTRL_PIN(WMT_PIN_VDIN7, "vdin7"),
214 	PINCTRL_PIN(WMT_PIN_VDOUT0, "vdout0"),
215 	PINCTRL_PIN(WMT_PIN_VDOUT1, "vdout1"),
216 	PINCTRL_PIN(WMT_PIN_VDOUT2, "vdout2"),
217 	PINCTRL_PIN(WMT_PIN_VDOUT3, "vdout3"),
218 	PINCTRL_PIN(WMT_PIN_VDOUT4, "vdout4"),
219 	PINCTRL_PIN(WMT_PIN_VDOUT5, "vdout5"),
220 	PINCTRL_PIN(WMT_PIN_VDOUT6, "vdout6"),
221 	PINCTRL_PIN(WMT_PIN_VDOUT7, "vdout7"),
222 	PINCTRL_PIN(WMT_PIN_VDOUT8, "vdout8"),
223 	PINCTRL_PIN(WMT_PIN_VDOUT9, "vdout9"),
224 	PINCTRL_PIN(WMT_PIN_VDOUT10, "vdout10"),
225 	PINCTRL_PIN(WMT_PIN_VDOUT11, "vdout11"),
226 	PINCTRL_PIN(WMT_PIN_VDOUT12, "vdout12"),
227 	PINCTRL_PIN(WMT_PIN_VDOUT13, "vdout13"),
228 	PINCTRL_PIN(WMT_PIN_VDOUT14, "vdout14"),
229 	PINCTRL_PIN(WMT_PIN_VDOUT15, "vdout15"),
230 	PINCTRL_PIN(WMT_PIN_VDOUT16, "vdout16"),
231 	PINCTRL_PIN(WMT_PIN_VDOUT17, "vdout17"),
232 	PINCTRL_PIN(WMT_PIN_VDOUT18, "vdout18"),
233 	PINCTRL_PIN(WMT_PIN_VDOUT19, "vdout19"),
234 	PINCTRL_PIN(WMT_PIN_VDOUT20, "vdout20"),
235 	PINCTRL_PIN(WMT_PIN_VDOUT21, "vdout21"),
236 	PINCTRL_PIN(WMT_PIN_VDOUT22, "vdout22"),
237 	PINCTRL_PIN(WMT_PIN_VDOUT23, "vdout23"),
238 	PINCTRL_PIN(WMT_PIN_VHSYNC, "v_hsync"),
239 	PINCTRL_PIN(WMT_PIN_VVSYNC, "v_vsync"),
240 	PINCTRL_PIN(WMT_PIN_VGAHSYNC, "vga_hsync"),
241 	PINCTRL_PIN(WMT_PIN_VGAVSYNC, "vga_vsync"),
242 	PINCTRL_PIN(WMT_PIN_VDHSYNC, "vd_hsync"),
243 	PINCTRL_PIN(WMT_PIN_VDVSYNC, "vd_vsync"),
244 	PINCTRL_PIN(WMT_PIN_NORD0, "nor_d0"),
245 	PINCTRL_PIN(WMT_PIN_NORD1, "nor_d1"),
246 	PINCTRL_PIN(WMT_PIN_NORD2, "nor_d2"),
247 	PINCTRL_PIN(WMT_PIN_NORD3, "nor_d3"),
248 	PINCTRL_PIN(WMT_PIN_NORD4, "nor_d4"),
249 	PINCTRL_PIN(WMT_PIN_NORD5, "nor_d5"),
250 	PINCTRL_PIN(WMT_PIN_NORD6, "nor_d6"),
251 	PINCTRL_PIN(WMT_PIN_NORD7, "nor_d7"),
252 	PINCTRL_PIN(WMT_PIN_NORD8, "nor_d8"),
253 	PINCTRL_PIN(WMT_PIN_NORD9, "nor_d9"),
254 	PINCTRL_PIN(WMT_PIN_NORD10, "nor_d10"),
255 	PINCTRL_PIN(WMT_PIN_NORD11, "nor_d11"),
256 	PINCTRL_PIN(WMT_PIN_NORD12, "nor_d12"),
257 	PINCTRL_PIN(WMT_PIN_NORD13, "nor_d13"),
258 	PINCTRL_PIN(WMT_PIN_NORD14, "nor_d14"),
259 	PINCTRL_PIN(WMT_PIN_NORD15, "nor_d15"),
260 	PINCTRL_PIN(WMT_PIN_NORA0, "nor_a0"),
261 	PINCTRL_PIN(WMT_PIN_NORA1, "nor_a1"),
262 	PINCTRL_PIN(WMT_PIN_NORA2, "nor_a2"),
263 	PINCTRL_PIN(WMT_PIN_NORA3, "nor_a3"),
264 	PINCTRL_PIN(WMT_PIN_NORA4, "nor_a4"),
265 	PINCTRL_PIN(WMT_PIN_NORA5, "nor_a5"),
266 	PINCTRL_PIN(WMT_PIN_NORA6, "nor_a6"),
267 	PINCTRL_PIN(WMT_PIN_NORA7, "nor_a7"),
268 	PINCTRL_PIN(WMT_PIN_NORA8, "nor_a8"),
269 	PINCTRL_PIN(WMT_PIN_NORA9, "nor_a9"),
270 	PINCTRL_PIN(WMT_PIN_NORA10, "nor_a10"),
271 	PINCTRL_PIN(WMT_PIN_NORA11, "nor_a11"),
272 	PINCTRL_PIN(WMT_PIN_NORA12, "nor_a12"),
273 	PINCTRL_PIN(WMT_PIN_NORA13, "nor_a13"),
274 	PINCTRL_PIN(WMT_PIN_NORA14, "nor_a14"),
275 	PINCTRL_PIN(WMT_PIN_NORA15, "nor_a15"),
276 	PINCTRL_PIN(WMT_PIN_NORA16, "nor_a16"),
277 	PINCTRL_PIN(WMT_PIN_NORA17, "nor_a17"),
278 	PINCTRL_PIN(WMT_PIN_NORA18, "nor_a18"),
279 	PINCTRL_PIN(WMT_PIN_NORA19, "nor_a19"),
280 	PINCTRL_PIN(WMT_PIN_NORA20, "nor_a20"),
281 	PINCTRL_PIN(WMT_PIN_NORA21, "nor_a21"),
282 	PINCTRL_PIN(WMT_PIN_NORA22, "nor_a22"),
283 	PINCTRL_PIN(WMT_PIN_NORA23, "nor_a23"),
284 	PINCTRL_PIN(WMT_PIN_NORA24, "nor_a24"),
285 	PINCTRL_PIN(WMT_PIN_AC97SDI, "ac97_sdi"),
286 	PINCTRL_PIN(WMT_PIN_AC97SYNC, "ac97_sync"),
287 	PINCTRL_PIN(WMT_PIN_AC97SDO, "ac97_sdo"),
288 	PINCTRL_PIN(WMT_PIN_AC97BCLK, "ac97_bclk"),
289 	PINCTRL_PIN(WMT_PIN_AC97RST, "ac97_rst"),
290 	PINCTRL_PIN(WMT_PIN_SFDO, "sf_do"),
291 	PINCTRL_PIN(WMT_PIN_SFCS0, "sf_cs0"),
292 	PINCTRL_PIN(WMT_PIN_SFCS1, "sf_cs1"),
293 	PINCTRL_PIN(WMT_PIN_SFCLK, "sf_clk"),
294 	PINCTRL_PIN(WMT_PIN_SFDI, "sf_di"),
295 	PINCTRL_PIN(WMT_PIN_SPI0CLK, "spi0_clk"),
296 	PINCTRL_PIN(WMT_PIN_SPI0MISO, "spi0_miso"),
297 	PINCTRL_PIN(WMT_PIN_SPI0MOSI, "spi0_mosi"),
298 	PINCTRL_PIN(WMT_PIN_SPI0SS, "spi0_ss"),
299 	PINCTRL_PIN(WMT_PIN_SPI1CLK, "spi1_clk"),
300 	PINCTRL_PIN(WMT_PIN_SPI1MISO, "spi1_miso"),
301 	PINCTRL_PIN(WMT_PIN_SPI1MOSI, "spi1_mosi"),
302 	PINCTRL_PIN(WMT_PIN_SPI1SS, "spi1_ss"),
303 	PINCTRL_PIN(WMT_PIN_SPI2CLK, "spi2_clk"),
304 	PINCTRL_PIN(WMT_PIN_SPI2MISO, "spi2_miso"),
305 	PINCTRL_PIN(WMT_PIN_SPI2MOSI, "spi2_mosi"),
306 	PINCTRL_PIN(WMT_PIN_SPI2SS, "spi2_ss"),
307 	PINCTRL_PIN(WMT_PIN_UART0_RTS, "uart0_rts"),
308 	PINCTRL_PIN(WMT_PIN_UART0_TXD, "uart0_txd"),
309 	PINCTRL_PIN(WMT_PIN_UART0_CTS, "uart0_cts"),
310 	PINCTRL_PIN(WMT_PIN_UART0_RXD, "uart0_rxd"),
311 	PINCTRL_PIN(WMT_PIN_UART1_RTS, "uart1_rts"),
312 	PINCTRL_PIN(WMT_PIN_UART1_TXD, "uart1_txd"),
313 	PINCTRL_PIN(WMT_PIN_UART1_CTS, "uart1_cts"),
314 	PINCTRL_PIN(WMT_PIN_UART1_RXD, "uart1_rxd"),
315 	PINCTRL_PIN(WMT_PIN_UART2_RTS, "uart2_rts"),
316 	PINCTRL_PIN(WMT_PIN_UART2_TXD, "uart2_txd"),
317 	PINCTRL_PIN(WMT_PIN_UART2_CTS, "uart2_cts"),
318 	PINCTRL_PIN(WMT_PIN_UART2_RXD, "uart2_rxd"),
319 	PINCTRL_PIN(WMT_PIN_UART3_RTS, "uart3_rts"),
320 	PINCTRL_PIN(WMT_PIN_UART3_TXD, "uart3_txd"),
321 	PINCTRL_PIN(WMT_PIN_UART3_CTS, "uart3_cts"),
322 	PINCTRL_PIN(WMT_PIN_UART3_RXD, "uart3_rxd"),
323 	PINCTRL_PIN(WMT_PIN_I2C0SCL, "i2c0_scl"),
324 	PINCTRL_PIN(WMT_PIN_I2C0SDA, "i2c0_sda"),
325 	PINCTRL_PIN(WMT_PIN_I2C1SCL, "i2c1_scl"),
326 	PINCTRL_PIN(WMT_PIN_I2C1SDA, "i2c1_sda"),
327 	PINCTRL_PIN(WMT_PIN_I2C2SCL, "i2c2_scl"),
328 	PINCTRL_PIN(WMT_PIN_I2C2SDA, "i2c2_sda"),
329 };
330 
331 /* Order of these names must match the above list */
332 static const char * const wm8505_groups[] = {
333 	"extgpio0",
334 	"extgpio1",
335 	"extgpio2",
336 	"extgpio3",
337 	"extgpio4",
338 	"extgpio5",
339 	"extgpio6",
340 	"extgpio7",
341 	"wakeup0",
342 	"wakeup1",
343 	"wakeup2",
344 	"wakeup3",
345 	"susgpio0",
346 	"sd_data0",
347 	"sd_data1",
348 	"sd_data2",
349 	"sd_data3",
350 	"mmc_data0",
351 	"mmc_data1",
352 	"mmc_data2",
353 	"mmc_data3",
354 	"vdin0",
355 	"vdin1",
356 	"vdin2",
357 	"vdin3",
358 	"vdin4",
359 	"vdin5",
360 	"vdin6",
361 	"vdin7",
362 	"vdout0",
363 	"vdout1",
364 	"vdout2",
365 	"vdout3",
366 	"vdout4",
367 	"vdout5",
368 	"vdout6",
369 	"vdout7",
370 	"vdout8",
371 	"vdout9",
372 	"vdout10",
373 	"vdout11",
374 	"vdout12",
375 	"vdout13",
376 	"vdout14",
377 	"vdout15",
378 	"vdout16",
379 	"vdout17",
380 	"vdout18",
381 	"vdout19",
382 	"vdout20",
383 	"vdout21",
384 	"vdout22",
385 	"vdout23",
386 	"v_hsync",
387 	"v_vsync",
388 	"vga_hsync",
389 	"vga_vsync",
390 	"vd_hsync",
391 	"vd_vsync",
392 	"nor_d0",
393 	"nor_d1",
394 	"nor_d2",
395 	"nor_d3",
396 	"nor_d4",
397 	"nor_d5",
398 	"nor_d6",
399 	"nor_d7",
400 	"nor_d8",
401 	"nor_d9",
402 	"nor_d10",
403 	"nor_d11",
404 	"nor_d12",
405 	"nor_d13",
406 	"nor_d14",
407 	"nor_d15",
408 	"nor_a0",
409 	"nor_a1",
410 	"nor_a2",
411 	"nor_a3",
412 	"nor_a4",
413 	"nor_a5",
414 	"nor_a6",
415 	"nor_a7",
416 	"nor_a8",
417 	"nor_a9",
418 	"nor_a10",
419 	"nor_a11",
420 	"nor_a12",
421 	"nor_a13",
422 	"nor_a14",
423 	"nor_a15",
424 	"nor_a16",
425 	"nor_a17",
426 	"nor_a18",
427 	"nor_a19",
428 	"nor_a20",
429 	"nor_a21",
430 	"nor_a22",
431 	"nor_a23",
432 	"nor_a24",
433 	"ac97_sdi",
434 	"ac97_sync",
435 	"ac97_sdo",
436 	"ac97_bclk",
437 	"ac97_rst",
438 	"sf_do",
439 	"sf_cs0",
440 	"sf_cs1",
441 	"sf_clk",
442 	"sf_di",
443 	"spi0_clk",
444 	"spi0_miso",
445 	"spi0_mosi",
446 	"spi0_ss",
447 	"spi1_clk",
448 	"spi1_miso",
449 	"spi1_mosi",
450 	"spi1_ss",
451 	"spi2_clk",
452 	"spi2_miso",
453 	"spi2_mosi",
454 	"spi2_ss",
455 	"uart0_rts",
456 	"uart0_txd",
457 	"uart0_cts",
458 	"uart0_rxd",
459 	"uart1_rts",
460 	"uart1_txd",
461 	"uart1_cts",
462 	"uart1_rxd",
463 	"uart2_rts",
464 	"uart2_txd",
465 	"uart2_cts",
466 	"uart2_rxd",
467 	"uart3_rts",
468 	"uart3_txd",
469 	"uart3_cts",
470 	"uart3_rxd",
471 	"i2c0_scl",
472 	"i2c0_sda",
473 	"i2c1_scl",
474 	"i2c1_sda",
475 	"i2c2_scl",
476 	"i2c2_sda",
477 };
478 
wm8505_pinctrl_probe(struct platform_device * pdev)479 static int wm8505_pinctrl_probe(struct platform_device *pdev)
480 {
481 	struct wmt_pinctrl_data *data;
482 
483 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
484 	if (!data)
485 		return -ENOMEM;
486 
487 	data->banks = wm8505_banks;
488 	data->nbanks = ARRAY_SIZE(wm8505_banks);
489 	data->pins = wm8505_pins;
490 	data->npins = ARRAY_SIZE(wm8505_pins);
491 	data->groups = wm8505_groups;
492 	data->ngroups = ARRAY_SIZE(wm8505_groups);
493 
494 	return wmt_pinctrl_probe(pdev, data);
495 }
496 
497 static const struct of_device_id wmt_pinctrl_of_match[] = {
498 	{ .compatible = "wm,wm8505-pinctrl" },
499 	{ /* sentinel */ },
500 };
501 
502 static struct platform_driver wmt_pinctrl_driver = {
503 	.probe	= wm8505_pinctrl_probe,
504 	.driver = {
505 		.name	= "pinctrl-wm8505",
506 		.of_match_table	= wmt_pinctrl_of_match,
507 		.suppress_bind_attrs = true,
508 	},
509 };
510 builtin_platform_driver(wmt_pinctrl_driver);
511