2 * Driver for the ST Microelectronics SPEAr310 pinmux
4 * Copyright (C) 2012 ST Microelectronics
5 * Viresh Kumar <vireshk@kernel.org>
7 * This file is licensed under the terms of the GNU General Public
8 * License version 2. This program is licensed "as is" without any
9 * warranty of any kind, whether express or implied.
12 #include <linux/err.h>
13 #include <linux/init.h>
14 #include <linux/of_device.h>
15 #include <linux/platform_device.h>
16 #include "pinctrl-spear3xx.h"
18 #define DRIVER_NAME "spear310-pinmux"
21 #define PMX_CONFIG_REG 0x08
23 /* emi_cs_0_to_5_pins */
24 static const unsigned emi_cs_0_to_5_pins
[] = { 45, 46, 47, 48, 49, 50 };
25 static struct spear_muxreg emi_cs_0_to_5_muxreg
[] = {
27 .reg
= PMX_CONFIG_REG
,
28 .mask
= PMX_TIMER_0_1_MASK
| PMX_TIMER_2_3_MASK
,
33 static struct spear_modemux emi_cs_0_to_5_modemux
[] = {
35 .muxregs
= emi_cs_0_to_5_muxreg
,
36 .nmuxregs
= ARRAY_SIZE(emi_cs_0_to_5_muxreg
),
40 static struct spear_pingroup emi_cs_0_to_5_pingroup
= {
41 .name
= "emi_cs_0_to_5_grp",
42 .pins
= emi_cs_0_to_5_pins
,
43 .npins
= ARRAY_SIZE(emi_cs_0_to_5_pins
),
44 .modemuxs
= emi_cs_0_to_5_modemux
,
45 .nmodemuxs
= ARRAY_SIZE(emi_cs_0_to_5_modemux
),
48 static const char *const emi_cs_0_to_5_grps
[] = { "emi_cs_0_to_5_grp" };
49 static struct spear_function emi_cs_0_to_5_function
= {
51 .groups
= emi_cs_0_to_5_grps
,
52 .ngroups
= ARRAY_SIZE(emi_cs_0_to_5_grps
),
56 static const unsigned uart1_pins
[] = { 0, 1 };
57 static struct spear_muxreg uart1_muxreg
[] = {
59 .reg
= PMX_CONFIG_REG
,
60 .mask
= PMX_FIRDA_MASK
,
65 static struct spear_modemux uart1_modemux
[] = {
67 .muxregs
= uart1_muxreg
,
68 .nmuxregs
= ARRAY_SIZE(uart1_muxreg
),
72 static struct spear_pingroup uart1_pingroup
= {
75 .npins
= ARRAY_SIZE(uart1_pins
),
76 .modemuxs
= uart1_modemux
,
77 .nmodemuxs
= ARRAY_SIZE(uart1_modemux
),
80 static const char *const uart1_grps
[] = { "uart1_grp" };
81 static struct spear_function uart1_function
= {
84 .ngroups
= ARRAY_SIZE(uart1_grps
),
88 static const unsigned uart2_pins
[] = { 43, 44 };
89 static struct spear_muxreg uart2_muxreg
[] = {
91 .reg
= PMX_CONFIG_REG
,
92 .mask
= PMX_TIMER_0_1_MASK
,
97 static struct spear_modemux uart2_modemux
[] = {
99 .muxregs
= uart2_muxreg
,
100 .nmuxregs
= ARRAY_SIZE(uart2_muxreg
),
104 static struct spear_pingroup uart2_pingroup
= {
107 .npins
= ARRAY_SIZE(uart2_pins
),
108 .modemuxs
= uart2_modemux
,
109 .nmodemuxs
= ARRAY_SIZE(uart2_modemux
),
112 static const char *const uart2_grps
[] = { "uart2_grp" };
113 static struct spear_function uart2_function
= {
115 .groups
= uart2_grps
,
116 .ngroups
= ARRAY_SIZE(uart2_grps
),
120 static const unsigned uart3_pins
[] = { 37, 38 };
121 static struct spear_muxreg uart3_muxreg
[] = {
123 .reg
= PMX_CONFIG_REG
,
124 .mask
= PMX_UART0_MODEM_MASK
,
129 static struct spear_modemux uart3_modemux
[] = {
131 .muxregs
= uart3_muxreg
,
132 .nmuxregs
= ARRAY_SIZE(uart3_muxreg
),
136 static struct spear_pingroup uart3_pingroup
= {
139 .npins
= ARRAY_SIZE(uart3_pins
),
140 .modemuxs
= uart3_modemux
,
141 .nmodemuxs
= ARRAY_SIZE(uart3_modemux
),
144 static const char *const uart3_grps
[] = { "uart3_grp" };
145 static struct spear_function uart3_function
= {
147 .groups
= uart3_grps
,
148 .ngroups
= ARRAY_SIZE(uart3_grps
),
152 static const unsigned uart4_pins
[] = { 39, 40 };
153 static struct spear_muxreg uart4_muxreg
[] = {
155 .reg
= PMX_CONFIG_REG
,
156 .mask
= PMX_UART0_MODEM_MASK
,
161 static struct spear_modemux uart4_modemux
[] = {
163 .muxregs
= uart4_muxreg
,
164 .nmuxregs
= ARRAY_SIZE(uart4_muxreg
),
168 static struct spear_pingroup uart4_pingroup
= {
171 .npins
= ARRAY_SIZE(uart4_pins
),
172 .modemuxs
= uart4_modemux
,
173 .nmodemuxs
= ARRAY_SIZE(uart4_modemux
),
176 static const char *const uart4_grps
[] = { "uart4_grp" };
177 static struct spear_function uart4_function
= {
179 .groups
= uart4_grps
,
180 .ngroups
= ARRAY_SIZE(uart4_grps
),
184 static const unsigned uart5_pins
[] = { 41, 42 };
185 static struct spear_muxreg uart5_muxreg
[] = {
187 .reg
= PMX_CONFIG_REG
,
188 .mask
= PMX_UART0_MODEM_MASK
,
193 static struct spear_modemux uart5_modemux
[] = {
195 .muxregs
= uart5_muxreg
,
196 .nmuxregs
= ARRAY_SIZE(uart5_muxreg
),
200 static struct spear_pingroup uart5_pingroup
= {
203 .npins
= ARRAY_SIZE(uart5_pins
),
204 .modemuxs
= uart5_modemux
,
205 .nmodemuxs
= ARRAY_SIZE(uart5_modemux
),
208 static const char *const uart5_grps
[] = { "uart5_grp" };
209 static struct spear_function uart5_function
= {
211 .groups
= uart5_grps
,
212 .ngroups
= ARRAY_SIZE(uart5_grps
),
216 static const unsigned fsmc_pins
[] = { 34, 35, 36 };
217 static struct spear_muxreg fsmc_muxreg
[] = {
219 .reg
= PMX_CONFIG_REG
,
220 .mask
= PMX_SSP_CS_MASK
,
225 static struct spear_modemux fsmc_modemux
[] = {
227 .muxregs
= fsmc_muxreg
,
228 .nmuxregs
= ARRAY_SIZE(fsmc_muxreg
),
232 static struct spear_pingroup fsmc_pingroup
= {
235 .npins
= ARRAY_SIZE(fsmc_pins
),
236 .modemuxs
= fsmc_modemux
,
237 .nmodemuxs
= ARRAY_SIZE(fsmc_modemux
),
240 static const char *const fsmc_grps
[] = { "fsmc_grp" };
241 static struct spear_function fsmc_function
= {
244 .ngroups
= ARRAY_SIZE(fsmc_grps
),
248 static const unsigned rs485_0_pins
[] = { 19, 20, 21, 22, 23 };
249 static struct spear_muxreg rs485_0_muxreg
[] = {
251 .reg
= PMX_CONFIG_REG
,
252 .mask
= PMX_MII_MASK
,
257 static struct spear_modemux rs485_0_modemux
[] = {
259 .muxregs
= rs485_0_muxreg
,
260 .nmuxregs
= ARRAY_SIZE(rs485_0_muxreg
),
264 static struct spear_pingroup rs485_0_pingroup
= {
265 .name
= "rs485_0_grp",
266 .pins
= rs485_0_pins
,
267 .npins
= ARRAY_SIZE(rs485_0_pins
),
268 .modemuxs
= rs485_0_modemux
,
269 .nmodemuxs
= ARRAY_SIZE(rs485_0_modemux
),
272 static const char *const rs485_0_grps
[] = { "rs485_0" };
273 static struct spear_function rs485_0_function
= {
275 .groups
= rs485_0_grps
,
276 .ngroups
= ARRAY_SIZE(rs485_0_grps
),
280 static const unsigned rs485_1_pins
[] = { 14, 15, 16, 17, 18 };
281 static struct spear_muxreg rs485_1_muxreg
[] = {
283 .reg
= PMX_CONFIG_REG
,
284 .mask
= PMX_MII_MASK
,
289 static struct spear_modemux rs485_1_modemux
[] = {
291 .muxregs
= rs485_1_muxreg
,
292 .nmuxregs
= ARRAY_SIZE(rs485_1_muxreg
),
296 static struct spear_pingroup rs485_1_pingroup
= {
297 .name
= "rs485_1_grp",
298 .pins
= rs485_1_pins
,
299 .npins
= ARRAY_SIZE(rs485_1_pins
),
300 .modemuxs
= rs485_1_modemux
,
301 .nmodemuxs
= ARRAY_SIZE(rs485_1_modemux
),
304 static const char *const rs485_1_grps
[] = { "rs485_1" };
305 static struct spear_function rs485_1_function
= {
307 .groups
= rs485_1_grps
,
308 .ngroups
= ARRAY_SIZE(rs485_1_grps
),
312 static const unsigned tdm_pins
[] = { 10, 11, 12, 13 };
313 static struct spear_muxreg tdm_muxreg
[] = {
315 .reg
= PMX_CONFIG_REG
,
316 .mask
= PMX_MII_MASK
,
321 static struct spear_modemux tdm_modemux
[] = {
323 .muxregs
= tdm_muxreg
,
324 .nmuxregs
= ARRAY_SIZE(tdm_muxreg
),
328 static struct spear_pingroup tdm_pingroup
= {
331 .npins
= ARRAY_SIZE(tdm_pins
),
332 .modemuxs
= tdm_modemux
,
333 .nmodemuxs
= ARRAY_SIZE(tdm_modemux
),
336 static const char *const tdm_grps
[] = { "tdm_grp" };
337 static struct spear_function tdm_function
= {
340 .ngroups
= ARRAY_SIZE(tdm_grps
),
344 static struct spear_pingroup
*spear310_pingroups
[] = {
345 SPEAR3XX_COMMON_PINGROUPS
,
346 &emi_cs_0_to_5_pingroup
,
359 static struct spear_function
*spear310_functions
[] = {
360 SPEAR3XX_COMMON_FUNCTIONS
,
361 &emi_cs_0_to_5_function
,
373 static const struct of_device_id spear310_pinctrl_of_match
[] = {
375 .compatible
= "st,spear310-pinmux",
380 static int spear310_pinctrl_probe(struct platform_device
*pdev
)
384 spear3xx_machdata
.groups
= spear310_pingroups
;
385 spear3xx_machdata
.ngroups
= ARRAY_SIZE(spear310_pingroups
);
386 spear3xx_machdata
.functions
= spear310_functions
;
387 spear3xx_machdata
.nfunctions
= ARRAY_SIZE(spear310_functions
);
389 pmx_init_addr(&spear3xx_machdata
, PMX_CONFIG_REG
);
390 pmx_init_gpio_pingroup_addr(spear3xx_machdata
.gpio_pingroups
,
391 spear3xx_machdata
.ngpio_pingroups
, PMX_CONFIG_REG
);
393 spear3xx_machdata
.modes_supported
= false;
395 ret
= spear_pinctrl_probe(pdev
, &spear3xx_machdata
);
402 static struct platform_driver spear310_pinctrl_driver
= {
405 .of_match_table
= spear310_pinctrl_of_match
,
407 .probe
= spear310_pinctrl_probe
,
410 static int __init
spear310_pinctrl_init(void)
412 return platform_driver_register(&spear310_pinctrl_driver
);
414 arch_initcall(spear310_pinctrl_init
);