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