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