1
2
3
4
5
6
7
8
9
10
11
12
13
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
26
27
28
29
30
31
32static const struct wmt_pinctrl_bank_registers wm8750_banks[] = {
33 WMT_PINCTRL_BANK(0x40, 0x80, 0xC0, 0x00, 0x480, 0x4C0),
34 WMT_PINCTRL_BANK(0x44, 0x84, 0xC4, 0x04, 0x484, 0x4C4),
35 WMT_PINCTRL_BANK(0x48, 0x88, 0xC8, 0x08, 0x488, 0x4C8),
36 WMT_PINCTRL_BANK(0x4C, 0x8C, 0xCC, 0x0C, 0x48C, 0x4CC),
37 WMT_PINCTRL_BANK(0x50, 0x90, 0xD0, 0x10, 0x490, 0x4D0),
38 WMT_PINCTRL_BANK(0x54, 0x94, 0xD4, 0x14, 0x494, 0x4D4),
39 WMT_PINCTRL_BANK(0x58, 0x98, 0xD8, 0x18, 0x498, 0x4D8),
40 WMT_PINCTRL_BANK(0x5C, 0x9C, 0xDC, 0x1C, 0x49C, 0x4DC),
41 WMT_PINCTRL_BANK(0x60, 0xA0, 0xE0, 0x20, 0x4A0, 0x4E0),
42 WMT_PINCTRL_BANK(0x70, 0xB0, 0xF0, 0x30, 0x4B0, 0x4F0),
43 WMT_PINCTRL_BANK(0x7C, 0xBC, 0xDC, 0x3C, 0x4BC, 0x4FC),
44};
45
46
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_SD0CD WMT_PIN(0, 28)
58#define WMT_PIN_VDOUT0 WMT_PIN(1, 0)
59#define WMT_PIN_VDOUT1 WMT_PIN(1, 1)
60#define WMT_PIN_VDOUT2 WMT_PIN(1, 2)
61#define WMT_PIN_VDOUT3 WMT_PIN(1, 3)
62#define WMT_PIN_VDOUT4 WMT_PIN(1, 4)
63#define WMT_PIN_VDOUT5 WMT_PIN(1, 5)
64#define WMT_PIN_VDOUT6 WMT_PIN(1, 6)
65#define WMT_PIN_VDOUT7 WMT_PIN(1, 7)
66#define WMT_PIN_VDOUT8 WMT_PIN(1, 8)
67#define WMT_PIN_VDOUT9 WMT_PIN(1, 9)
68#define WMT_PIN_VDOUT10 WMT_PIN(1, 10)
69#define WMT_PIN_VDOUT11 WMT_PIN(1, 11)
70#define WMT_PIN_VDOUT12 WMT_PIN(1, 12)
71#define WMT_PIN_VDOUT13 WMT_PIN(1, 13)
72#define WMT_PIN_VDOUT14 WMT_PIN(1, 14)
73#define WMT_PIN_VDOUT15 WMT_PIN(1, 15)
74#define WMT_PIN_VDOUT16 WMT_PIN(1, 16)
75#define WMT_PIN_VDOUT17 WMT_PIN(1, 17)
76#define WMT_PIN_VDOUT18 WMT_PIN(1, 18)
77#define WMT_PIN_VDOUT19 WMT_PIN(1, 19)
78#define WMT_PIN_VDOUT20 WMT_PIN(1, 20)
79#define WMT_PIN_VDOUT21 WMT_PIN(1, 21)
80#define WMT_PIN_VDOUT22 WMT_PIN(1, 22)
81#define WMT_PIN_VDOUT23 WMT_PIN(1, 23)
82#define WMT_PIN_VDIN0 WMT_PIN(2, 0)
83#define WMT_PIN_VDIN1 WMT_PIN(2, 1)
84#define WMT_PIN_VDIN2 WMT_PIN(2, 2)
85#define WMT_PIN_VDIN3 WMT_PIN(2, 3)
86#define WMT_PIN_VDIN4 WMT_PIN(2, 4)
87#define WMT_PIN_VDIN5 WMT_PIN(2, 5)
88#define WMT_PIN_VDIN6 WMT_PIN(2, 6)
89#define WMT_PIN_VDIN7 WMT_PIN(2, 7)
90#define WMT_PIN_SPI0_MOSI WMT_PIN(2, 24)
91#define WMT_PIN_SPI0_MISO WMT_PIN(2, 25)
92#define WMT_PIN_SPI0_SS WMT_PIN(2, 26)
93#define WMT_PIN_SPI0_CLK WMT_PIN(2, 27)
94#define WMT_PIN_SPI0_SSB WMT_PIN(2, 28)
95#define WMT_PIN_SD0CLK WMT_PIN(3, 17)
96#define WMT_PIN_SD0CMD WMT_PIN(3, 18)
97#define WMT_PIN_SD0WP WMT_PIN(3, 19)
98#define WMT_PIN_SD0DATA0 WMT_PIN(3, 20)
99#define WMT_PIN_SD0DATA1 WMT_PIN(3, 21)
100#define WMT_PIN_SD0DATA2 WMT_PIN(3, 22)
101#define WMT_PIN_SD0DATA3 WMT_PIN(3, 23)
102#define WMT_PIN_SD1DATA0 WMT_PIN(3, 24)
103#define WMT_PIN_SD1DATA1 WMT_PIN(3, 25)
104#define WMT_PIN_SD1DATA2 WMT_PIN(3, 26)
105#define WMT_PIN_SD1DATA3 WMT_PIN(3, 27)
106#define WMT_PIN_SD1DATA4 WMT_PIN(3, 28)
107#define WMT_PIN_SD1DATA5 WMT_PIN(3, 29)
108#define WMT_PIN_SD1DATA6 WMT_PIN(3, 30)
109#define WMT_PIN_SD1DATA7 WMT_PIN(3, 31)
110#define WMT_PIN_I2C0_SCL WMT_PIN(5, 8)
111#define WMT_PIN_I2C0_SDA WMT_PIN(5, 9)
112#define WMT_PIN_I2C1_SCL WMT_PIN(5, 10)
113#define WMT_PIN_I2C1_SDA WMT_PIN(5, 11)
114#define WMT_PIN_I2C2_SCL WMT_PIN(5, 12)
115#define WMT_PIN_I2C2_SDA WMT_PIN(5, 13)
116#define WMT_PIN_UART0_RTS WMT_PIN(5, 16)
117#define WMT_PIN_UART0_TXD WMT_PIN(5, 17)
118#define WMT_PIN_UART0_CTS WMT_PIN(5, 18)
119#define WMT_PIN_UART0_RXD WMT_PIN(5, 19)
120#define WMT_PIN_UART1_RTS WMT_PIN(5, 20)
121#define WMT_PIN_UART1_TXD WMT_PIN(5, 21)
122#define WMT_PIN_UART1_CTS WMT_PIN(5, 22)
123#define WMT_PIN_UART1_RXD WMT_PIN(5, 23)
124#define WMT_PIN_UART2_RTS WMT_PIN(5, 24)
125#define WMT_PIN_UART2_TXD WMT_PIN(5, 25)
126#define WMT_PIN_UART2_CTS WMT_PIN(5, 26)
127#define WMT_PIN_UART2_RXD WMT_PIN(5, 27)
128#define WMT_PIN_UART3_RTS WMT_PIN(5, 28)
129#define WMT_PIN_UART3_TXD WMT_PIN(5, 29)
130#define WMT_PIN_UART3_CTS WMT_PIN(5, 30)
131#define WMT_PIN_UART3_RXD WMT_PIN(5, 31)
132#define WMT_PIN_SD2CD WMT_PIN(6, 0)
133#define WMT_PIN_SD2DATA3 WMT_PIN(6, 1)
134#define WMT_PIN_SD2DATA0 WMT_PIN(6, 2)
135#define WMT_PIN_SD2WP WMT_PIN(6, 3)
136#define WMT_PIN_SD2DATA1 WMT_PIN(6, 4)
137#define WMT_PIN_SD2DATA2 WMT_PIN(6, 5)
138#define WMT_PIN_SD2CMD WMT_PIN(6, 6)
139#define WMT_PIN_SD2CLK WMT_PIN(6, 7)
140#define WMT_PIN_SD2PWR WMT_PIN(6, 9)
141#define WMT_PIN_SD1CLK WMT_PIN(7, 0)
142#define WMT_PIN_SD1CMD WMT_PIN(7, 1)
143#define WMT_PIN_SD1PWR WMT_PIN(7, 10)
144#define WMT_PIN_SD1WP WMT_PIN(7, 11)
145#define WMT_PIN_SD1CD WMT_PIN(7, 12)
146#define WMT_PIN_SPI0SS3 WMT_PIN(7, 24)
147#define WMT_PIN_SPI0SS2 WMT_PIN(7, 25)
148#define WMT_PIN_PWMOUT1 WMT_PIN(7, 26)
149#define WMT_PIN_PWMOUT0 WMT_PIN(7, 27)
150
151static const struct pinctrl_pin_desc wm8750_pins[] = {
152 PINCTRL_PIN(WMT_PIN_EXTGPIO0, "extgpio0"),
153 PINCTRL_PIN(WMT_PIN_EXTGPIO1, "extgpio1"),
154 PINCTRL_PIN(WMT_PIN_EXTGPIO2, "extgpio2"),
155 PINCTRL_PIN(WMT_PIN_EXTGPIO3, "extgpio3"),
156 PINCTRL_PIN(WMT_PIN_EXTGPIO4, "extgpio4"),
157 PINCTRL_PIN(WMT_PIN_EXTGPIO5, "extgpio5"),
158 PINCTRL_PIN(WMT_PIN_EXTGPIO6, "extgpio6"),
159 PINCTRL_PIN(WMT_PIN_EXTGPIO7, "extgpio7"),
160 PINCTRL_PIN(WMT_PIN_WAKEUP0, "wakeup0"),
161 PINCTRL_PIN(WMT_PIN_WAKEUP1, "wakeup1"),
162 PINCTRL_PIN(WMT_PIN_SD0CD, "sd0_cd"),
163 PINCTRL_PIN(WMT_PIN_VDOUT0, "vdout0"),
164 PINCTRL_PIN(WMT_PIN_VDOUT1, "vdout1"),
165 PINCTRL_PIN(WMT_PIN_VDOUT2, "vdout2"),
166 PINCTRL_PIN(WMT_PIN_VDOUT3, "vdout3"),
167 PINCTRL_PIN(WMT_PIN_VDOUT4, "vdout4"),
168 PINCTRL_PIN(WMT_PIN_VDOUT5, "vdout5"),
169 PINCTRL_PIN(WMT_PIN_VDOUT6, "vdout6"),
170 PINCTRL_PIN(WMT_PIN_VDOUT7, "vdout7"),
171 PINCTRL_PIN(WMT_PIN_VDOUT8, "vdout8"),
172 PINCTRL_PIN(WMT_PIN_VDOUT9, "vdout9"),
173 PINCTRL_PIN(WMT_PIN_VDOUT10, "vdout10"),
174 PINCTRL_PIN(WMT_PIN_VDOUT11, "vdout11"),
175 PINCTRL_PIN(WMT_PIN_VDOUT12, "vdout12"),
176 PINCTRL_PIN(WMT_PIN_VDOUT13, "vdout13"),
177 PINCTRL_PIN(WMT_PIN_VDOUT14, "vdout14"),
178 PINCTRL_PIN(WMT_PIN_VDOUT15, "vdout15"),
179 PINCTRL_PIN(WMT_PIN_VDOUT16, "vdout16"),
180 PINCTRL_PIN(WMT_PIN_VDOUT17, "vdout17"),
181 PINCTRL_PIN(WMT_PIN_VDOUT18, "vdout18"),
182 PINCTRL_PIN(WMT_PIN_VDOUT19, "vdout19"),
183 PINCTRL_PIN(WMT_PIN_VDOUT20, "vdout20"),
184 PINCTRL_PIN(WMT_PIN_VDOUT21, "vdout21"),
185 PINCTRL_PIN(WMT_PIN_VDOUT22, "vdout22"),
186 PINCTRL_PIN(WMT_PIN_VDOUT23, "vdout23"),
187 PINCTRL_PIN(WMT_PIN_VDIN0, "vdin0"),
188 PINCTRL_PIN(WMT_PIN_VDIN1, "vdin1"),
189 PINCTRL_PIN(WMT_PIN_VDIN2, "vdin2"),
190 PINCTRL_PIN(WMT_PIN_VDIN3, "vdin3"),
191 PINCTRL_PIN(WMT_PIN_VDIN4, "vdin4"),
192 PINCTRL_PIN(WMT_PIN_VDIN5, "vdin5"),
193 PINCTRL_PIN(WMT_PIN_VDIN6, "vdin6"),
194 PINCTRL_PIN(WMT_PIN_VDIN7, "vdin7"),
195 PINCTRL_PIN(WMT_PIN_SPI0_MOSI, "spi0_mosi"),
196 PINCTRL_PIN(WMT_PIN_SPI0_MISO, "spi0_miso"),
197 PINCTRL_PIN(WMT_PIN_SPI0_SS, "spi0_ss"),
198 PINCTRL_PIN(WMT_PIN_SPI0_CLK, "spi0_clk"),
199 PINCTRL_PIN(WMT_PIN_SPI0_SSB, "spi0_ssb"),
200 PINCTRL_PIN(WMT_PIN_SD0CLK, "sd0_clk"),
201 PINCTRL_PIN(WMT_PIN_SD0CMD, "sd0_cmd"),
202 PINCTRL_PIN(WMT_PIN_SD0WP, "sd0_wp"),
203 PINCTRL_PIN(WMT_PIN_SD0DATA0, "sd0_data0"),
204 PINCTRL_PIN(WMT_PIN_SD0DATA1, "sd0_data1"),
205 PINCTRL_PIN(WMT_PIN_SD0DATA2, "sd0_data2"),
206 PINCTRL_PIN(WMT_PIN_SD0DATA3, "sd0_data3"),
207 PINCTRL_PIN(WMT_PIN_SD1DATA0, "sd1_data0"),
208 PINCTRL_PIN(WMT_PIN_SD1DATA1, "sd1_data1"),
209 PINCTRL_PIN(WMT_PIN_SD1DATA2, "sd1_data2"),
210 PINCTRL_PIN(WMT_PIN_SD1DATA3, "sd1_data3"),
211 PINCTRL_PIN(WMT_PIN_SD1DATA4, "sd1_data4"),
212 PINCTRL_PIN(WMT_PIN_SD1DATA5, "sd1_data5"),
213 PINCTRL_PIN(WMT_PIN_SD1DATA6, "sd1_data6"),
214 PINCTRL_PIN(WMT_PIN_SD1DATA7, "sd1_data7"),
215 PINCTRL_PIN(WMT_PIN_I2C0_SCL, "i2c0_scl"),
216 PINCTRL_PIN(WMT_PIN_I2C0_SDA, "i2c0_sda"),
217 PINCTRL_PIN(WMT_PIN_I2C1_SCL, "i2c1_scl"),
218 PINCTRL_PIN(WMT_PIN_I2C1_SDA, "i2c1_sda"),
219 PINCTRL_PIN(WMT_PIN_I2C2_SCL, "i2c2_scl"),
220 PINCTRL_PIN(WMT_PIN_I2C2_SDA, "i2c2_sda"),
221 PINCTRL_PIN(WMT_PIN_UART0_RTS, "uart0_rts"),
222 PINCTRL_PIN(WMT_PIN_UART0_TXD, "uart0_txd"),
223 PINCTRL_PIN(WMT_PIN_UART0_CTS, "uart0_cts"),
224 PINCTRL_PIN(WMT_PIN_UART0_RXD, "uart0_rxd"),
225 PINCTRL_PIN(WMT_PIN_UART1_RTS, "uart1_rts"),
226 PINCTRL_PIN(WMT_PIN_UART1_TXD, "uart1_txd"),
227 PINCTRL_PIN(WMT_PIN_UART1_CTS, "uart1_cts"),
228 PINCTRL_PIN(WMT_PIN_UART1_RXD, "uart1_rxd"),
229 PINCTRL_PIN(WMT_PIN_UART2_RTS, "uart2_rts"),
230 PINCTRL_PIN(WMT_PIN_UART2_TXD, "uart2_txd"),
231 PINCTRL_PIN(WMT_PIN_UART2_CTS, "uart2_cts"),
232 PINCTRL_PIN(WMT_PIN_UART2_RXD, "uart2_rxd"),
233 PINCTRL_PIN(WMT_PIN_UART3_RTS, "uart3_rts"),
234 PINCTRL_PIN(WMT_PIN_UART3_TXD, "uart3_txd"),
235 PINCTRL_PIN(WMT_PIN_UART3_CTS, "uart3_cts"),
236 PINCTRL_PIN(WMT_PIN_UART3_RXD, "uart3_rxd"),
237 PINCTRL_PIN(WMT_PIN_SD2CD, "sd2_cd"),
238 PINCTRL_PIN(WMT_PIN_SD2DATA3, "sd2_data3"),
239 PINCTRL_PIN(WMT_PIN_SD2DATA0, "sd2_data0"),
240 PINCTRL_PIN(WMT_PIN_SD2WP, "sd2_wp"),
241 PINCTRL_PIN(WMT_PIN_SD2DATA1, "sd2_data1"),
242 PINCTRL_PIN(WMT_PIN_SD2DATA2, "sd2_data2"),
243 PINCTRL_PIN(WMT_PIN_SD2CMD, "sd2_cmd"),
244 PINCTRL_PIN(WMT_PIN_SD2CLK, "sd2_clk"),
245 PINCTRL_PIN(WMT_PIN_SD2PWR, "sd2_pwr"),
246 PINCTRL_PIN(WMT_PIN_SD1CLK, "sd1_clk"),
247 PINCTRL_PIN(WMT_PIN_SD1CMD, "sd1_cmd"),
248 PINCTRL_PIN(WMT_PIN_SD1PWR, "sd1_pwr"),
249 PINCTRL_PIN(WMT_PIN_SD1WP, "sd1_wp"),
250 PINCTRL_PIN(WMT_PIN_SD1CD, "sd1_cd"),
251 PINCTRL_PIN(WMT_PIN_SPI0SS3, "spi0_ss3"),
252 PINCTRL_PIN(WMT_PIN_SPI0SS2, "spi0_ss2"),
253 PINCTRL_PIN(WMT_PIN_PWMOUT1, "pwmout1"),
254 PINCTRL_PIN(WMT_PIN_PWMOUT0, "pwmout0"),
255};
256
257
258static const char * const wm8750_groups[] = {
259 "extgpio0",
260 "extgpio1",
261 "extgpio2",
262 "extgpio3",
263 "extgpio4",
264 "extgpio5",
265 "extgpio6",
266 "extgpio7",
267 "wakeup0",
268 "wakeup1",
269 "sd0_cd",
270 "vdout0",
271 "vdout1",
272 "vdout2",
273 "vdout3",
274 "vdout4",
275 "vdout5",
276 "vdout6",
277 "vdout7",
278 "vdout8",
279 "vdout9",
280 "vdout10",
281 "vdout11",
282 "vdout12",
283 "vdout13",
284 "vdout14",
285 "vdout15",
286 "vdout16",
287 "vdout17",
288 "vdout18",
289 "vdout19",
290 "vdout20",
291 "vdout21",
292 "vdout22",
293 "vdout23",
294 "vdin0",
295 "vdin1",
296 "vdin2",
297 "vdin3",
298 "vdin4",
299 "vdin5",
300 "vdin6",
301 "vdin7",
302 "spi0_mosi",
303 "spi0_miso",
304 "spi0_ss",
305 "spi0_clk",
306 "spi0_ssb",
307 "sd0_clk",
308 "sd0_cmd",
309 "sd0_wp",
310 "sd0_data0",
311 "sd0_data1",
312 "sd0_data2",
313 "sd0_data3",
314 "sd1_data0",
315 "sd1_data1",
316 "sd1_data2",
317 "sd1_data3",
318 "sd1_data4",
319 "sd1_data5",
320 "sd1_data6",
321 "sd1_data7",
322 "i2c0_scl",
323 "i2c0_sda",
324 "i2c1_scl",
325 "i2c1_sda",
326 "i2c2_scl",
327 "i2c2_sda",
328 "uart0_rts",
329 "uart0_txd",
330 "uart0_cts",
331 "uart0_rxd",
332 "uart1_rts",
333 "uart1_txd",
334 "uart1_cts",
335 "uart1_rxd",
336 "uart2_rts",
337 "uart2_txd",
338 "uart2_cts",
339 "uart2_rxd",
340 "uart3_rts",
341 "uart3_txd",
342 "uart3_cts",
343 "uart3_rxd",
344 "sd2_cd",
345 "sd2_data3",
346 "sd2_data0",
347 "sd2_wp",
348 "sd2_data1",
349 "sd2_data2",
350 "sd2_cmd",
351 "sd2_clk",
352 "sd2_pwr",
353 "sd1_clk",
354 "sd1_cmd",
355 "sd1_pwr",
356 "sd1_wp",
357 "sd1_cd",
358 "spi0_ss3",
359 "spi0_ss2",
360 "pwmout1",
361 "pwmout0",
362};
363
364static int wm8750_pinctrl_probe(struct platform_device *pdev)
365{
366 struct wmt_pinctrl_data *data;
367
368 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
369 if (!data) {
370 dev_err(&pdev->dev, "failed to allocate data\n");
371 return -ENOMEM;
372 }
373
374 data->banks = wm8750_banks;
375 data->nbanks = ARRAY_SIZE(wm8750_banks);
376 data->pins = wm8750_pins;
377 data->npins = ARRAY_SIZE(wm8750_pins);
378 data->groups = wm8750_groups;
379 data->ngroups = ARRAY_SIZE(wm8750_groups);
380
381 return wmt_pinctrl_probe(pdev, data);
382}
383
384static int wm8750_pinctrl_remove(struct platform_device *pdev)
385{
386 return wmt_pinctrl_remove(pdev);
387}
388
389static struct of_device_id wmt_pinctrl_of_match[] = {
390 { .compatible = "wm,wm8750-pinctrl" },
391 { },
392};
393
394static struct platform_driver wmt_pinctrl_driver = {
395 .probe = wm8750_pinctrl_probe,
396 .remove = wm8750_pinctrl_remove,
397 .driver = {
398 .name = "pinctrl-wm8750",
399 .owner = THIS_MODULE,
400 .of_match_table = wmt_pinctrl_of_match,
401 },
402};
403
404module_platform_driver(wmt_pinctrl_driver);
405
406MODULE_AUTHOR("Tony Prisk <linux@prisktech.co.nz>");
407MODULE_DESCRIPTION("Wondermedia WM8750 Pincontrol driver");
408MODULE_LICENSE("GPL v2");
409MODULE_DEVICE_TABLE(of, wmt_pinctrl_of_match);
410