blob: 94f142c10c198f712f3cd4ef5e19484739eddf91 [file] [log] [blame]
Viresh Kumardeda8282012-03-28 22:27:07 +05301/*
2 * Driver header file for the ST Microelectronics SPEAr pinmux
3 *
4 * Copyright (C) 2012 ST Microelectronics
Viresh Kumar10d89352012-06-20 12:53:02 -07005 * Viresh Kumar <viresh.linux@gmail.com>
Viresh Kumardeda8282012-03-28 22:27:07 +05306 *
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.
10 */
11
12#ifndef __PINMUX_SPEAR_H__
13#define __PINMUX_SPEAR_H__
14
Viresh Kumarf4f8e562012-10-27 15:21:38 +053015#include <linux/gpio.h>
Viresh Kumardeda8282012-03-28 22:27:07 +053016#include <linux/pinctrl/pinctrl.h>
17#include <linux/types.h>
18
19struct platform_device;
20struct device;
21
22/**
23 * struct spear_pmx_mode - SPEAr pmx mode
24 * @name: name of pmx mode
25 * @mode: mode id
26 * @reg: register for configuring this mode
27 * @mask: mask of this mode in reg
28 * @val: val to be configured at reg after doing (val & mask)
29 */
30struct spear_pmx_mode {
31 const char *const name;
32 u16 mode;
33 u16 reg;
34 u16 mask;
35 u32 val;
36};
37
38/**
39 * struct spear_muxreg - SPEAr mux reg configuration
40 * @reg: register offset
41 * @mask: mask bits
42 * @val: val to be written on mask bits
43 */
44struct spear_muxreg {
45 u16 reg;
46 u32 mask;
47 u32 val;
48};
49
Viresh Kumarf4f8e562012-10-27 15:21:38 +053050struct spear_gpio_pingroup {
51 const unsigned *pins;
52 unsigned npins;
53 struct spear_muxreg *muxregs;
54 u8 nmuxregs;
55};
56
57/* ste: set to enable */
58#define DEFINE_MUXREG(__pins, __muxreg, __mask, __ste) \
59static struct spear_muxreg __pins##_muxregs[] = { \
60 { \
61 .reg = __muxreg, \
62 .mask = __mask, \
63 .val = __ste ? __mask : 0, \
64 }, \
65}
66
67#define DEFINE_2_MUXREG(__pins, __muxreg1, __muxreg2, __mask, __ste1, __ste2) \
68static struct spear_muxreg __pins##_muxregs[] = { \
69 { \
70 .reg = __muxreg1, \
71 .mask = __mask, \
72 .val = __ste1 ? __mask : 0, \
73 }, { \
74 .reg = __muxreg2, \
75 .mask = __mask, \
76 .val = __ste2 ? __mask : 0, \
77 }, \
78}
79
80#define GPIO_PINGROUP(__pins) \
81 { \
82 .pins = __pins, \
83 .npins = ARRAY_SIZE(__pins), \
84 .muxregs = __pins##_muxregs, \
85 .nmuxregs = ARRAY_SIZE(__pins##_muxregs), \
86 }
87
Viresh Kumardeda8282012-03-28 22:27:07 +053088/**
89 * struct spear_modemux - SPEAr mode mux configuration
90 * @modes: mode ids supported by this group of muxregs
91 * @nmuxregs: number of muxreg configurations to be done for modes
92 * @muxregs: array of muxreg configurations to be done for modes
93 */
94struct spear_modemux {
95 u16 modes;
96 u8 nmuxregs;
97 struct spear_muxreg *muxregs;
98};
99
100/**
101 * struct spear_pingroup - SPEAr pin group configurations
102 * @name: name of pin group
103 * @pins: array containing pin numbers
104 * @npins: size of pins array
105 * @modemuxs: array of modemux configurations for this pin group
106 * @nmodemuxs: size of array modemuxs
107 *
108 * A representation of a group of pins in the SPEAr pin controller. Each group
109 * allows some parameter or parameters to be configured.
110 */
111struct spear_pingroup {
112 const char *name;
113 const unsigned *pins;
114 unsigned npins;
115 struct spear_modemux *modemuxs;
116 unsigned nmodemuxs;
117};
118
119/**
120 * struct spear_function - SPEAr pinctrl mux function
121 * @name: The name of the function, exported to pinctrl core.
122 * @groups: An array of pin groups that may select this function.
123 * @ngroups: The number of entries in @groups.
124 */
125struct spear_function {
126 const char *name;
127 const char *const *groups;
128 unsigned ngroups;
129};
130
131/**
132 * struct spear_pinctrl_machdata - SPEAr pin controller machine driver
133 * configuration
134 * @pins: An array describing all pins the pin controller affects.
135 * All pins which are also GPIOs must be listed first within the *array,
136 * and be numbered identically to the GPIO controller's *numbering.
137 * @npins: The numbmer of entries in @pins.
138 * @functions: An array describing all mux functions the SoC supports.
139 * @nfunctions: The numbmer of entries in @functions.
140 * @groups: An array describing all pin groups the pin SoC supports.
141 * @ngroups: The numbmer of entries in @groups.
Viresh Kumarf4f8e562012-10-27 15:21:38 +0530142 * @gpio_pingroups: gpio pingroups
143 * @ngpio_pingroups: gpio pingroups count
Viresh Kumardeda8282012-03-28 22:27:07 +0530144 *
145 * @modes_supported: Does SoC support modes
146 * @mode: mode configured from probe
147 * @pmx_modes: array of modes supported by SoC
148 * @npmx_modes: number of entries in pmx_modes.
149 */
150struct spear_pinctrl_machdata {
151 const struct pinctrl_pin_desc *pins;
152 unsigned npins;
153 struct spear_function **functions;
154 unsigned nfunctions;
155 struct spear_pingroup **groups;
156 unsigned ngroups;
Viresh Kumarf4f8e562012-10-27 15:21:38 +0530157 struct spear_gpio_pingroup *gpio_pingroups;
158 unsigned ngpio_pingroups;
Viresh Kumardeda8282012-03-28 22:27:07 +0530159
160 bool modes_supported;
161 u16 mode;
162 struct spear_pmx_mode **pmx_modes;
163 unsigned npmx_modes;
164};
165
166/**
167 * struct spear_pmx - SPEAr pinctrl mux
168 * @dev: pointer to struct dev of platform_device registered
169 * @pctl: pointer to struct pinctrl_dev
170 * @machdata: pointer to SoC or machine specific structure
171 * @vbase: virtual base address of pinmux controller
172 */
173struct spear_pmx {
174 struct device *dev;
175 struct pinctrl_dev *pctl;
176 struct spear_pinctrl_machdata *machdata;
177 void __iomem *vbase;
178};
179
180/* exported routines */
181void __devinit pmx_init_addr(struct spear_pinctrl_machdata *machdata, u16 reg);
Viresh Kumarf4f8e562012-10-27 15:21:38 +0530182void __devinit
183pmx_init_gpio_pingroup_addr(struct spear_gpio_pingroup *gpio_pingroup,
184 unsigned count, u16 reg);
Viresh Kumardeda8282012-03-28 22:27:07 +0530185int __devinit spear_pinctrl_probe(struct platform_device *pdev,
186 struct spear_pinctrl_machdata *machdata);
187int __devexit spear_pinctrl_remove(struct platform_device *pdev);
Viresh Kumard1e77af2012-04-05 18:59:23 +0530188
189#define SPEAR_PIN_0_TO_101 \
190 PINCTRL_PIN(0, "PLGPIO0"), \
191 PINCTRL_PIN(1, "PLGPIO1"), \
192 PINCTRL_PIN(2, "PLGPIO2"), \
193 PINCTRL_PIN(3, "PLGPIO3"), \
194 PINCTRL_PIN(4, "PLGPIO4"), \
195 PINCTRL_PIN(5, "PLGPIO5"), \
196 PINCTRL_PIN(6, "PLGPIO6"), \
197 PINCTRL_PIN(7, "PLGPIO7"), \
198 PINCTRL_PIN(8, "PLGPIO8"), \
199 PINCTRL_PIN(9, "PLGPIO9"), \
200 PINCTRL_PIN(10, "PLGPIO10"), \
201 PINCTRL_PIN(11, "PLGPIO11"), \
202 PINCTRL_PIN(12, "PLGPIO12"), \
203 PINCTRL_PIN(13, "PLGPIO13"), \
204 PINCTRL_PIN(14, "PLGPIO14"), \
205 PINCTRL_PIN(15, "PLGPIO15"), \
206 PINCTRL_PIN(16, "PLGPIO16"), \
207 PINCTRL_PIN(17, "PLGPIO17"), \
208 PINCTRL_PIN(18, "PLGPIO18"), \
209 PINCTRL_PIN(19, "PLGPIO19"), \
210 PINCTRL_PIN(20, "PLGPIO20"), \
211 PINCTRL_PIN(21, "PLGPIO21"), \
212 PINCTRL_PIN(22, "PLGPIO22"), \
213 PINCTRL_PIN(23, "PLGPIO23"), \
214 PINCTRL_PIN(24, "PLGPIO24"), \
215 PINCTRL_PIN(25, "PLGPIO25"), \
216 PINCTRL_PIN(26, "PLGPIO26"), \
217 PINCTRL_PIN(27, "PLGPIO27"), \
218 PINCTRL_PIN(28, "PLGPIO28"), \
219 PINCTRL_PIN(29, "PLGPIO29"), \
220 PINCTRL_PIN(30, "PLGPIO30"), \
221 PINCTRL_PIN(31, "PLGPIO31"), \
222 PINCTRL_PIN(32, "PLGPIO32"), \
223 PINCTRL_PIN(33, "PLGPIO33"), \
224 PINCTRL_PIN(34, "PLGPIO34"), \
225 PINCTRL_PIN(35, "PLGPIO35"), \
226 PINCTRL_PIN(36, "PLGPIO36"), \
227 PINCTRL_PIN(37, "PLGPIO37"), \
228 PINCTRL_PIN(38, "PLGPIO38"), \
229 PINCTRL_PIN(39, "PLGPIO39"), \
230 PINCTRL_PIN(40, "PLGPIO40"), \
231 PINCTRL_PIN(41, "PLGPIO41"), \
232 PINCTRL_PIN(42, "PLGPIO42"), \
233 PINCTRL_PIN(43, "PLGPIO43"), \
234 PINCTRL_PIN(44, "PLGPIO44"), \
235 PINCTRL_PIN(45, "PLGPIO45"), \
236 PINCTRL_PIN(46, "PLGPIO46"), \
237 PINCTRL_PIN(47, "PLGPIO47"), \
238 PINCTRL_PIN(48, "PLGPIO48"), \
239 PINCTRL_PIN(49, "PLGPIO49"), \
240 PINCTRL_PIN(50, "PLGPIO50"), \
241 PINCTRL_PIN(51, "PLGPIO51"), \
242 PINCTRL_PIN(52, "PLGPIO52"), \
243 PINCTRL_PIN(53, "PLGPIO53"), \
244 PINCTRL_PIN(54, "PLGPIO54"), \
245 PINCTRL_PIN(55, "PLGPIO55"), \
246 PINCTRL_PIN(56, "PLGPIO56"), \
247 PINCTRL_PIN(57, "PLGPIO57"), \
248 PINCTRL_PIN(58, "PLGPIO58"), \
249 PINCTRL_PIN(59, "PLGPIO59"), \
250 PINCTRL_PIN(60, "PLGPIO60"), \
251 PINCTRL_PIN(61, "PLGPIO61"), \
252 PINCTRL_PIN(62, "PLGPIO62"), \
253 PINCTRL_PIN(63, "PLGPIO63"), \
254 PINCTRL_PIN(64, "PLGPIO64"), \
255 PINCTRL_PIN(65, "PLGPIO65"), \
256 PINCTRL_PIN(66, "PLGPIO66"), \
257 PINCTRL_PIN(67, "PLGPIO67"), \
258 PINCTRL_PIN(68, "PLGPIO68"), \
259 PINCTRL_PIN(69, "PLGPIO69"), \
260 PINCTRL_PIN(70, "PLGPIO70"), \
261 PINCTRL_PIN(71, "PLGPIO71"), \
262 PINCTRL_PIN(72, "PLGPIO72"), \
263 PINCTRL_PIN(73, "PLGPIO73"), \
264 PINCTRL_PIN(74, "PLGPIO74"), \
265 PINCTRL_PIN(75, "PLGPIO75"), \
266 PINCTRL_PIN(76, "PLGPIO76"), \
267 PINCTRL_PIN(77, "PLGPIO77"), \
268 PINCTRL_PIN(78, "PLGPIO78"), \
269 PINCTRL_PIN(79, "PLGPIO79"), \
270 PINCTRL_PIN(80, "PLGPIO80"), \
271 PINCTRL_PIN(81, "PLGPIO81"), \
272 PINCTRL_PIN(82, "PLGPIO82"), \
273 PINCTRL_PIN(83, "PLGPIO83"), \
274 PINCTRL_PIN(84, "PLGPIO84"), \
275 PINCTRL_PIN(85, "PLGPIO85"), \
276 PINCTRL_PIN(86, "PLGPIO86"), \
277 PINCTRL_PIN(87, "PLGPIO87"), \
278 PINCTRL_PIN(88, "PLGPIO88"), \
279 PINCTRL_PIN(89, "PLGPIO89"), \
280 PINCTRL_PIN(90, "PLGPIO90"), \
281 PINCTRL_PIN(91, "PLGPIO91"), \
282 PINCTRL_PIN(92, "PLGPIO92"), \
283 PINCTRL_PIN(93, "PLGPIO93"), \
284 PINCTRL_PIN(94, "PLGPIO94"), \
285 PINCTRL_PIN(95, "PLGPIO95"), \
286 PINCTRL_PIN(96, "PLGPIO96"), \
287 PINCTRL_PIN(97, "PLGPIO97"), \
288 PINCTRL_PIN(98, "PLGPIO98"), \
289 PINCTRL_PIN(99, "PLGPIO99"), \
290 PINCTRL_PIN(100, "PLGPIO100"), \
291 PINCTRL_PIN(101, "PLGPIO101")
292
Viresh Kumar85ed41a2012-03-28 22:27:07 +0530293#define SPEAR_PIN_102_TO_245 \
294 PINCTRL_PIN(102, "PLGPIO102"), \
295 PINCTRL_PIN(103, "PLGPIO103"), \
296 PINCTRL_PIN(104, "PLGPIO104"), \
297 PINCTRL_PIN(105, "PLGPIO105"), \
298 PINCTRL_PIN(106, "PLGPIO106"), \
299 PINCTRL_PIN(107, "PLGPIO107"), \
300 PINCTRL_PIN(108, "PLGPIO108"), \
301 PINCTRL_PIN(109, "PLGPIO109"), \
302 PINCTRL_PIN(110, "PLGPIO110"), \
303 PINCTRL_PIN(111, "PLGPIO111"), \
304 PINCTRL_PIN(112, "PLGPIO112"), \
305 PINCTRL_PIN(113, "PLGPIO113"), \
306 PINCTRL_PIN(114, "PLGPIO114"), \
307 PINCTRL_PIN(115, "PLGPIO115"), \
308 PINCTRL_PIN(116, "PLGPIO116"), \
309 PINCTRL_PIN(117, "PLGPIO117"), \
310 PINCTRL_PIN(118, "PLGPIO118"), \
311 PINCTRL_PIN(119, "PLGPIO119"), \
312 PINCTRL_PIN(120, "PLGPIO120"), \
313 PINCTRL_PIN(121, "PLGPIO121"), \
314 PINCTRL_PIN(122, "PLGPIO122"), \
315 PINCTRL_PIN(123, "PLGPIO123"), \
316 PINCTRL_PIN(124, "PLGPIO124"), \
317 PINCTRL_PIN(125, "PLGPIO125"), \
318 PINCTRL_PIN(126, "PLGPIO126"), \
319 PINCTRL_PIN(127, "PLGPIO127"), \
320 PINCTRL_PIN(128, "PLGPIO128"), \
321 PINCTRL_PIN(129, "PLGPIO129"), \
322 PINCTRL_PIN(130, "PLGPIO130"), \
323 PINCTRL_PIN(131, "PLGPIO131"), \
324 PINCTRL_PIN(132, "PLGPIO132"), \
325 PINCTRL_PIN(133, "PLGPIO133"), \
326 PINCTRL_PIN(134, "PLGPIO134"), \
327 PINCTRL_PIN(135, "PLGPIO135"), \
328 PINCTRL_PIN(136, "PLGPIO136"), \
329 PINCTRL_PIN(137, "PLGPIO137"), \
330 PINCTRL_PIN(138, "PLGPIO138"), \
331 PINCTRL_PIN(139, "PLGPIO139"), \
332 PINCTRL_PIN(140, "PLGPIO140"), \
333 PINCTRL_PIN(141, "PLGPIO141"), \
334 PINCTRL_PIN(142, "PLGPIO142"), \
335 PINCTRL_PIN(143, "PLGPIO143"), \
336 PINCTRL_PIN(144, "PLGPIO144"), \
337 PINCTRL_PIN(145, "PLGPIO145"), \
338 PINCTRL_PIN(146, "PLGPIO146"), \
339 PINCTRL_PIN(147, "PLGPIO147"), \
340 PINCTRL_PIN(148, "PLGPIO148"), \
341 PINCTRL_PIN(149, "PLGPIO149"), \
342 PINCTRL_PIN(150, "PLGPIO150"), \
343 PINCTRL_PIN(151, "PLGPIO151"), \
344 PINCTRL_PIN(152, "PLGPIO152"), \
345 PINCTRL_PIN(153, "PLGPIO153"), \
346 PINCTRL_PIN(154, "PLGPIO154"), \
347 PINCTRL_PIN(155, "PLGPIO155"), \
348 PINCTRL_PIN(156, "PLGPIO156"), \
349 PINCTRL_PIN(157, "PLGPIO157"), \
350 PINCTRL_PIN(158, "PLGPIO158"), \
351 PINCTRL_PIN(159, "PLGPIO159"), \
352 PINCTRL_PIN(160, "PLGPIO160"), \
353 PINCTRL_PIN(161, "PLGPIO161"), \
354 PINCTRL_PIN(162, "PLGPIO162"), \
355 PINCTRL_PIN(163, "PLGPIO163"), \
356 PINCTRL_PIN(164, "PLGPIO164"), \
357 PINCTRL_PIN(165, "PLGPIO165"), \
358 PINCTRL_PIN(166, "PLGPIO166"), \
359 PINCTRL_PIN(167, "PLGPIO167"), \
360 PINCTRL_PIN(168, "PLGPIO168"), \
361 PINCTRL_PIN(169, "PLGPIO169"), \
362 PINCTRL_PIN(170, "PLGPIO170"), \
363 PINCTRL_PIN(171, "PLGPIO171"), \
364 PINCTRL_PIN(172, "PLGPIO172"), \
365 PINCTRL_PIN(173, "PLGPIO173"), \
366 PINCTRL_PIN(174, "PLGPIO174"), \
367 PINCTRL_PIN(175, "PLGPIO175"), \
368 PINCTRL_PIN(176, "PLGPIO176"), \
369 PINCTRL_PIN(177, "PLGPIO177"), \
370 PINCTRL_PIN(178, "PLGPIO178"), \
371 PINCTRL_PIN(179, "PLGPIO179"), \
372 PINCTRL_PIN(180, "PLGPIO180"), \
373 PINCTRL_PIN(181, "PLGPIO181"), \
374 PINCTRL_PIN(182, "PLGPIO182"), \
375 PINCTRL_PIN(183, "PLGPIO183"), \
376 PINCTRL_PIN(184, "PLGPIO184"), \
377 PINCTRL_PIN(185, "PLGPIO185"), \
378 PINCTRL_PIN(186, "PLGPIO186"), \
379 PINCTRL_PIN(187, "PLGPIO187"), \
380 PINCTRL_PIN(188, "PLGPIO188"), \
381 PINCTRL_PIN(189, "PLGPIO189"), \
382 PINCTRL_PIN(190, "PLGPIO190"), \
383 PINCTRL_PIN(191, "PLGPIO191"), \
384 PINCTRL_PIN(192, "PLGPIO192"), \
385 PINCTRL_PIN(193, "PLGPIO193"), \
386 PINCTRL_PIN(194, "PLGPIO194"), \
387 PINCTRL_PIN(195, "PLGPIO195"), \
388 PINCTRL_PIN(196, "PLGPIO196"), \
389 PINCTRL_PIN(197, "PLGPIO197"), \
390 PINCTRL_PIN(198, "PLGPIO198"), \
391 PINCTRL_PIN(199, "PLGPIO199"), \
392 PINCTRL_PIN(200, "PLGPIO200"), \
393 PINCTRL_PIN(201, "PLGPIO201"), \
394 PINCTRL_PIN(202, "PLGPIO202"), \
395 PINCTRL_PIN(203, "PLGPIO203"), \
396 PINCTRL_PIN(204, "PLGPIO204"), \
397 PINCTRL_PIN(205, "PLGPIO205"), \
398 PINCTRL_PIN(206, "PLGPIO206"), \
399 PINCTRL_PIN(207, "PLGPIO207"), \
400 PINCTRL_PIN(208, "PLGPIO208"), \
401 PINCTRL_PIN(209, "PLGPIO209"), \
402 PINCTRL_PIN(210, "PLGPIO210"), \
403 PINCTRL_PIN(211, "PLGPIO211"), \
404 PINCTRL_PIN(212, "PLGPIO212"), \
405 PINCTRL_PIN(213, "PLGPIO213"), \
406 PINCTRL_PIN(214, "PLGPIO214"), \
407 PINCTRL_PIN(215, "PLGPIO215"), \
408 PINCTRL_PIN(216, "PLGPIO216"), \
409 PINCTRL_PIN(217, "PLGPIO217"), \
410 PINCTRL_PIN(218, "PLGPIO218"), \
411 PINCTRL_PIN(219, "PLGPIO219"), \
412 PINCTRL_PIN(220, "PLGPIO220"), \
413 PINCTRL_PIN(221, "PLGPIO221"), \
414 PINCTRL_PIN(222, "PLGPIO222"), \
415 PINCTRL_PIN(223, "PLGPIO223"), \
416 PINCTRL_PIN(224, "PLGPIO224"), \
417 PINCTRL_PIN(225, "PLGPIO225"), \
418 PINCTRL_PIN(226, "PLGPIO226"), \
419 PINCTRL_PIN(227, "PLGPIO227"), \
420 PINCTRL_PIN(228, "PLGPIO228"), \
421 PINCTRL_PIN(229, "PLGPIO229"), \
422 PINCTRL_PIN(230, "PLGPIO230"), \
423 PINCTRL_PIN(231, "PLGPIO231"), \
424 PINCTRL_PIN(232, "PLGPIO232"), \
425 PINCTRL_PIN(233, "PLGPIO233"), \
426 PINCTRL_PIN(234, "PLGPIO234"), \
427 PINCTRL_PIN(235, "PLGPIO235"), \
428 PINCTRL_PIN(236, "PLGPIO236"), \
429 PINCTRL_PIN(237, "PLGPIO237"), \
430 PINCTRL_PIN(238, "PLGPIO238"), \
431 PINCTRL_PIN(239, "PLGPIO239"), \
432 PINCTRL_PIN(240, "PLGPIO240"), \
433 PINCTRL_PIN(241, "PLGPIO241"), \
434 PINCTRL_PIN(242, "PLGPIO242"), \
435 PINCTRL_PIN(243, "PLGPIO243"), \
436 PINCTRL_PIN(244, "PLGPIO244"), \
437 PINCTRL_PIN(245, "PLGPIO245")
438
Viresh Kumardeda8282012-03-28 22:27:07 +0530439#endif /* __PINMUX_SPEAR_H__ */