]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - arch/arm/mach-omap2/mux.h
Merge branch 'akpm' (incoming from Andrew)
[mirror_ubuntu-zesty-kernel.git] / arch / arm / mach-omap2 / mux.h
CommitLineData
15ac7afe
TL
1/*
2 * Copyright (C) 2009 Nokia
112485e9 3 * Copyright (C) 2009-2010 Texas Instruments
15ac7afe
TL
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
ddaa912a
TL
10#include "mux34xx.h"
11
15ac7afe
TL
12#define OMAP_MUX_TERMINATOR 0xffff
13
14/* 34xx mux mode options for each pin. See TRM for options */
15#define OMAP_MUX_MODE0 0
16#define OMAP_MUX_MODE1 1
17#define OMAP_MUX_MODE2 2
18#define OMAP_MUX_MODE3 3
19#define OMAP_MUX_MODE4 4
20#define OMAP_MUX_MODE5 5
21#define OMAP_MUX_MODE6 6
22#define OMAP_MUX_MODE7 7
23
24/* 24xx/34xx mux bit defines */
25#define OMAP_PULL_ENA (1 << 3)
26#define OMAP_PULL_UP (1 << 4)
27#define OMAP_ALTELECTRICALSEL (1 << 5)
28
d623a0e1 29/* omap3/4/5 specific mux bit defines */
15ac7afe
TL
30#define OMAP_INPUT_EN (1 << 8)
31#define OMAP_OFF_EN (1 << 9)
32#define OMAP_OFFOUT_EN (1 << 10)
33#define OMAP_OFFOUT_VAL (1 << 11)
34#define OMAP_OFF_PULL_EN (1 << 12)
35#define OMAP_OFF_PULL_UP (1 << 13)
36#define OMAP_WAKEUP_EN (1 << 14)
a041a52c
BC
37#define OMAP_WAKEUP_EVENT (1 << 15)
38
15ac7afe
TL
39/* Active pin states */
40#define OMAP_PIN_OUTPUT 0
41#define OMAP_PIN_INPUT OMAP_INPUT_EN
42#define OMAP_PIN_INPUT_PULLUP (OMAP_PULL_ENA | OMAP_INPUT_EN \
43 | OMAP_PULL_UP)
44#define OMAP_PIN_INPUT_PULLDOWN (OMAP_PULL_ENA | OMAP_INPUT_EN)
45
46/* Off mode states */
47#define OMAP_PIN_OFF_NONE 0
48#define OMAP_PIN_OFF_OUTPUT_HIGH (OMAP_OFF_EN | OMAP_OFFOUT_EN \
49 | OMAP_OFFOUT_VAL)
50#define OMAP_PIN_OFF_OUTPUT_LOW (OMAP_OFF_EN | OMAP_OFFOUT_EN)
51#define OMAP_PIN_OFF_INPUT_PULLUP (OMAP_OFF_EN | OMAP_OFF_PULL_EN \
52 | OMAP_OFF_PULL_UP)
53#define OMAP_PIN_OFF_INPUT_PULLDOWN (OMAP_OFF_EN | OMAP_OFF_PULL_EN)
54#define OMAP_PIN_OFF_WAKEUPENABLE OMAP_WAKEUP_EN
55
421e8450
OM
56#define OMAP_MODE_GPIO(partition, x) (((x) & OMAP_MUX_MODE7) == \
57 partition->gpio)
91930652 58#define OMAP_MODE_UART(x) (((x) & OMAP_MUX_MODE7) == OMAP_MUX_MODE0)
15ac7afe 59
112485e9 60/* Flags for omapX_mux_init */
15ac7afe 61#define OMAP_PACKAGE_MASK 0xffff
6dd8a682
TL
62#define OMAP_PACKAGE_CBP 6 /* 515-pin 0.40 0.50 */
63#define OMAP_PACKAGE_CUS 5 /* 423-pin 0.65 */
64#define OMAP_PACKAGE_CBB 4 /* 515-pin 0.40 0.50 */
65#define OMAP_PACKAGE_CBC 3 /* 515-pin 0.50 0.65 */
66#define OMAP_PACKAGE_ZAC 2 /* 24xx 447-pin POP */
67#define OMAP_PACKAGE_ZAF 1 /* 2420 447-pin SIP */
15ac7afe
TL
68
69
112485e9
BC
70#define OMAP_MUX_NR_MODES 8 /* Available modes */
71#define OMAP_MUX_NR_SIDES 2 /* Bottom & top */
72
73/*
74 * omap_mux_init flags definition:
75 *
421e8450
OM
76 * OMAP_GPIO_MUX_MODE, bits 0-2: gpio muxing mode, same like pad control
77 * register which includes values from 0-7.
112485e9
BC
78 * OMAP_MUX_REG_8BIT: Ensure that access to padconf is done in 8 bits.
79 * The default value is 16 bits.
112485e9 80 */
421e8450
OM
81#define OMAP_MUX_GPIO_IN_MODE0 OMAP_MUX_MODE0
82#define OMAP_MUX_GPIO_IN_MODE1 OMAP_MUX_MODE1
83#define OMAP_MUX_GPIO_IN_MODE2 OMAP_MUX_MODE2
84#define OMAP_MUX_GPIO_IN_MODE3 OMAP_MUX_MODE3
85#define OMAP_MUX_GPIO_IN_MODE4 OMAP_MUX_MODE4
86#define OMAP_MUX_GPIO_IN_MODE5 OMAP_MUX_MODE5
87#define OMAP_MUX_GPIO_IN_MODE6 OMAP_MUX_MODE6
88#define OMAP_MUX_GPIO_IN_MODE7 OMAP_MUX_MODE7
89#define OMAP_MUX_REG_8BIT (1 << 3)
112485e9 90
40e44399
TL
91/**
92 * struct omap_board_data - board specific device data
93 * @id: instance id
94 * @flags: additional flags for platform init code
95 * @pads: array of device specific pads
96 * @pads_cnt: ARRAY_SIZE() of pads
97 */
98struct omap_board_data {
99 int id;
100 u32 flags;
101 struct omap_device_pad *pads;
102 int pads_cnt;
103};
104
112485e9
BC
105/**
106 * struct mux_partition - contain partition related information
107 * @name: name of the current partition
108 * @flags: flags specific to this partition
421e8450 109 * @gpio: gpio mux mode
112485e9
BC
110 * @phys: physical address
111 * @size: partition size
112 * @base: virtual address after ioremap
113 * @muxmodes: list of nodes that belong to a partition
114 * @node: list node for the partitions linked list
115 */
116struct omap_mux_partition {
117 const char *name;
118 u32 flags;
421e8450 119 u32 gpio;
112485e9
BC
120 u32 phys;
121 u32 size;
122 void __iomem *base;
123 struct list_head muxmodes;
124 struct list_head node;
125};
15ac7afe
TL
126
127/**
128 * struct omap_mux - data for omap mux register offset and it's value
129 * @reg_offset: mux register offset from the mux base
130 * @gpio: GPIO number
131 * @muxnames: available signal modes for a ball
112485e9 132 * @balls: available balls on the package
15ac7afe
TL
133 */
134struct omap_mux {
135 u16 reg_offset;
136 u16 gpio;
137#ifdef CONFIG_OMAP_MUX
138 char *muxnames[OMAP_MUX_NR_MODES];
139#ifdef CONFIG_DEBUG_FS
140 char *balls[OMAP_MUX_NR_SIDES];
141#endif
142#endif
143};
144
145/**
146 * struct omap_ball - data for balls on omap package
147 * @reg_offset: mux register offset from the mux base
148 * @balls: available balls on the package
149 */
150struct omap_ball {
151 u16 reg_offset;
152 char *balls[OMAP_MUX_NR_SIDES];
153};
154
155/**
156 * struct omap_board_mux - data for initializing mux registers
157 * @reg_offset: mux register offset from the mux base
158 * @mux_value: desired mux value to set
159 */
160struct omap_board_mux {
161 u16 reg_offset;
162 u16 value;
163};
164
9796b323
TL
165#define OMAP_DEVICE_PAD_REMUX BIT(1) /* Dynamically remux a pad,
166 needs enable, idle and off
167 values */
168#define OMAP_DEVICE_PAD_WAKEUP BIT(0) /* Pad is wake-up capable */
169
170/**
171 * struct omap_device_pad - device specific pad configuration
172 * @name: signal name
173 * @flags: pad specific runtime flags
174 * @enable: runtime value for a pad
175 * @idle: idle value for a pad
176 * @off: off value for a pad, defaults to safe mode
177 * @partition: mux partition
178 * @mux: mux register
179 */
180struct omap_device_pad {
181 char *name;
182 u8 flags;
183 u16 enable;
184 u16 idle;
185 u16 off;
186 struct omap_mux_partition *partition;
187 struct omap_mux *mux;
188};
189
8d9af88f
TL
190struct omap_hwmod_mux_info;
191
8aee6039
TL
192#define OMAP_MUX_STATIC(signal, mode) \
193{ \
194 .name = (signal), \
195 .enable = (mode), \
196}
197
ac3dbeef 198#if defined(CONFIG_OMAP_MUX)
15ac7afe
TL
199
200/**
201 * omap_mux_init_gpio - initialize a signal based on the GPIO number
202 * @gpio: GPIO number
203 * @val: Options for the mux register value
204 */
205int omap_mux_init_gpio(int gpio, int val);
206
207/**
208 * omap_mux_init_signal - initialize a signal based on the signal name
209 * @muxname: Mux name in mode0_name.signal_name format
210 * @val: Options for the mux register value
211 */
5a3b2f7a 212int omap_mux_init_signal(const char *muxname, int val);
15ac7afe 213
9796b323
TL
214/**
215 * omap_hwmod_mux_init - initialize hwmod specific mux data
216 * @bpads: Board specific device signal names
217 * @nr_pads: Number of signal names for the device
218 */
219extern struct omap_hwmod_mux_info *
220omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads);
221
8d9af88f
TL
222/**
223 * omap_hwmod_mux - omap hwmod specific pin muxing
224 * @hmux: Pads for a hwmod
225 * @state: Desired _HWMOD_STATE
226 *
227 * Called only from omap_hwmod.c, do not use.
228 */
229void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state);
230
91930652
G
231int omap_mux_get_by_name(const char *muxname,
232 struct omap_mux_partition **found_partition,
233 struct omap_mux **found_mux);
15ac7afe
TL
234#else
235
91930652
G
236static inline int omap_mux_get_by_name(const char *muxname,
237 struct omap_mux_partition **found_partition,
238 struct omap_mux **found_mux)
239{
240 return 0;
241}
242
15ac7afe
TL
243static inline int omap_mux_init_gpio(int gpio, int val)
244{
245 return 0;
246}
247static inline int omap_mux_init_signal(char *muxname, int val)
248{
249 return 0;
250}
251
9796b323
TL
252static inline struct omap_hwmod_mux_info *
253omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)
254{
255 return NULL;
256}
257
8d9af88f
TL
258static inline void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
259{
260}
261
cc4915d8 262static struct omap_board_mux *board_mux __maybe_unused;
7203f8a4 263
15ac7afe
TL
264#endif
265
266/**
267 * omap_mux_get_gpio() - get mux register value based on GPIO number
268 * @gpio: GPIO number
269 *
270 */
271u16 omap_mux_get_gpio(int gpio);
272
273/**
274 * omap_mux_set_gpio() - set mux register value based on GPIO number
275 * @val: New mux register value
276 * @gpio: GPIO number
277 *
278 */
279void omap_mux_set_gpio(u16 val, int gpio);
280
112485e9
BC
281/**
282 * omap_mux_get() - get a mux partition by name
283 * @name: Name of the mux partition
284 *
285 */
286struct omap_mux_partition *omap_mux_get(const char *name);
287
d4bb72e5
TL
288/**
289 * omap_mux_read() - read mux register
112485e9 290 * @partition: Mux partition
d4bb72e5
TL
291 * @mux_offset: Offset of the mux register
292 *
293 */
112485e9 294u16 omap_mux_read(struct omap_mux_partition *p, u16 mux_offset);
d4bb72e5
TL
295
296/**
297 * omap_mux_write() - write mux register
112485e9 298 * @partition: Mux partition
d4bb72e5
TL
299 * @val: New mux register value
300 * @mux_offset: Offset of the mux register
301 *
302 * This should be only needed for dynamic remuxing of non-gpio signals.
303 */
112485e9 304void omap_mux_write(struct omap_mux_partition *p, u16 val, u16 mux_offset);
d4bb72e5
TL
305
306/**
307 * omap_mux_write_array() - write an array of mux registers
112485e9 308 * @partition: Mux partition
d4bb72e5
TL
309 * @board_mux: Array of mux registers terminated by MAP_MUX_TERMINATOR
310 *
311 * This should be only needed for dynamic remuxing of non-gpio signals.
312 */
112485e9
BC
313void omap_mux_write_array(struct omap_mux_partition *p,
314 struct omap_board_mux *board_mux);
d4bb72e5 315
fc440461
TL
316/**
317 * omap2420_mux_init() - initialize mux system with board specific set
318 * @board_mux: Board specific mux table
319 * @flags: OMAP package type used for the board
320 */
321int omap2420_mux_init(struct omap_board_mux *board_mux, int flags);
322
89ba1092
TL
323/**
324 * omap2430_mux_init() - initialize mux system with board specific set
325 * @board_mux: Board specific mux table
326 * @flags: OMAP package type used for the board
327 */
328int omap2430_mux_init(struct omap_board_mux *board_mux, int flags);
329
15ac7afe
TL
330/**
331 * omap3_mux_init() - initialize mux system with board specific set
332 * @board_mux: Board specific mux table
333 * @flags: OMAP package type used for the board
334 */
335int omap3_mux_init(struct omap_board_mux *board_mux, int flags);
336
a041a52c
BC
337/**
338 * omap4_mux_init() - initialize mux system with board specific set
21a42c92
CC
339 * @board_subset: Board specific mux table
340 * @board_wkup_subset: Board specific mux table for wakeup instance
a041a52c
BC
341 * @flags: OMAP package type used for the board
342 */
21a42c92
CC
343int omap4_mux_init(struct omap_board_mux *board_subset,
344 struct omap_board_mux *board_wkup_subset, int flags);
a041a52c 345
15ac7afe
TL
346/**
347 * omap_mux_init - private mux init function, do not call
348 */
112485e9
BC
349int omap_mux_init(const char *name, u32 flags,
350 u32 mux_pbase, u32 mux_size,
351 struct omap_mux *superset,
352 struct omap_mux *package_subset,
353 struct omap_board_mux *board_mux,
354 struct omap_ball *package_balls);
355