2 * Copyright (C) 2009 Nokia
3 * Copyright (C) 2009-2010 Texas Instruments
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.
14 #define OMAP_MUX_TERMINATOR 0xffff
16 /* 34xx mux mode options for each pin. See TRM for options */
17 #define OMAP_MUX_MODE0 0
18 #define OMAP_MUX_MODE1 1
19 #define OMAP_MUX_MODE2 2
20 #define OMAP_MUX_MODE3 3
21 #define OMAP_MUX_MODE4 4
22 #define OMAP_MUX_MODE5 5
23 #define OMAP_MUX_MODE6 6
24 #define OMAP_MUX_MODE7 7
26 /* 24xx/34xx mux bit defines */
27 #define OMAP_PULL_ENA (1 << 3)
28 #define OMAP_PULL_UP (1 << 4)
29 #define OMAP_ALTELECTRICALSEL (1 << 5)
31 /* omap3/4/5 specific mux bit defines */
32 #define OMAP_INPUT_EN (1 << 8)
33 #define OMAP_OFF_EN (1 << 9)
34 #define OMAP_OFFOUT_EN (1 << 10)
35 #define OMAP_OFFOUT_VAL (1 << 11)
36 #define OMAP_OFF_PULL_EN (1 << 12)
37 #define OMAP_OFF_PULL_UP (1 << 13)
38 #define OMAP_WAKEUP_EN (1 << 14)
39 #define OMAP_WAKEUP_EVENT (1 << 15)
41 /* Active pin states */
42 #define OMAP_PIN_OUTPUT 0
43 #define OMAP_PIN_INPUT OMAP_INPUT_EN
44 #define OMAP_PIN_INPUT_PULLUP (OMAP_PULL_ENA | OMAP_INPUT_EN \
46 #define OMAP_PIN_INPUT_PULLDOWN (OMAP_PULL_ENA | OMAP_INPUT_EN)
49 #define OMAP_PIN_OFF_NONE 0
50 #define OMAP_PIN_OFF_OUTPUT_HIGH (OMAP_OFF_EN | OMAP_OFFOUT_EN \
52 #define OMAP_PIN_OFF_OUTPUT_LOW (OMAP_OFF_EN | OMAP_OFFOUT_EN)
53 #define OMAP_PIN_OFF_INPUT_PULLUP (OMAP_OFF_EN | OMAP_OFF_PULL_EN \
55 #define OMAP_PIN_OFF_INPUT_PULLDOWN (OMAP_OFF_EN | OMAP_OFF_PULL_EN)
56 #define OMAP_PIN_OFF_WAKEUPENABLE OMAP_WAKEUP_EN
58 #define OMAP_MODE_GPIO(partition, x) (((x) & OMAP_MUX_MODE7) == \
60 #define OMAP_MODE_UART(x) (((x) & OMAP_MUX_MODE7) == OMAP_MUX_MODE0)
62 /* Flags for omapX_mux_init */
63 #define OMAP_PACKAGE_MASK 0xffff
64 #define OMAP_PACKAGE_CBP 6 /* 515-pin 0.40 0.50 */
65 #define OMAP_PACKAGE_CUS 5 /* 423-pin 0.65 */
66 #define OMAP_PACKAGE_CBB 4 /* 515-pin 0.40 0.50 */
67 #define OMAP_PACKAGE_CBC 3 /* 515-pin 0.50 0.65 */
68 #define OMAP_PACKAGE_ZAC 2 /* 24xx 447-pin POP */
69 #define OMAP_PACKAGE_ZAF 1 /* 2420 447-pin SIP */
72 #define OMAP_MUX_NR_MODES 8 /* Available modes */
73 #define OMAP_MUX_NR_SIDES 2 /* Bottom & top */
76 * omap_mux_init flags definition:
78 * OMAP_GPIO_MUX_MODE, bits 0-2: gpio muxing mode, same like pad control
79 * register which includes values from 0-7.
80 * OMAP_MUX_REG_8BIT: Ensure that access to padconf is done in 8 bits.
81 * The default value is 16 bits.
83 #define OMAP_MUX_GPIO_IN_MODE0 OMAP_MUX_MODE0
84 #define OMAP_MUX_GPIO_IN_MODE1 OMAP_MUX_MODE1
85 #define OMAP_MUX_GPIO_IN_MODE2 OMAP_MUX_MODE2
86 #define OMAP_MUX_GPIO_IN_MODE3 OMAP_MUX_MODE3
87 #define OMAP_MUX_GPIO_IN_MODE4 OMAP_MUX_MODE4
88 #define OMAP_MUX_GPIO_IN_MODE5 OMAP_MUX_MODE5
89 #define OMAP_MUX_GPIO_IN_MODE6 OMAP_MUX_MODE6
90 #define OMAP_MUX_GPIO_IN_MODE7 OMAP_MUX_MODE7
91 #define OMAP_MUX_REG_8BIT (1 << 3)
94 * struct omap_board_data - board specific device data
96 * @flags: additional flags for platform init code
97 * @pads: array of device specific pads
98 * @pads_cnt: ARRAY_SIZE() of pads
100 struct omap_board_data
{
103 struct omap_device_pad
*pads
;
108 * struct mux_partition - contain partition related information
109 * @name: name of the current partition
110 * @flags: flags specific to this partition
111 * @gpio: gpio mux mode
112 * @phys: physical address
113 * @size: partition size
114 * @base: virtual address after ioremap
115 * @muxmodes: list of nodes that belong to a partition
116 * @node: list node for the partitions linked list
118 struct omap_mux_partition
{
125 struct list_head muxmodes
;
126 struct list_head node
;
130 * struct omap_mux - data for omap mux register offset and it's value
131 * @reg_offset: mux register offset from the mux base
133 * @muxnames: available signal modes for a ball
134 * @balls: available balls on the package
139 #ifdef CONFIG_OMAP_MUX
140 char *muxnames
[OMAP_MUX_NR_MODES
];
141 #ifdef CONFIG_DEBUG_FS
142 char *balls
[OMAP_MUX_NR_SIDES
];
148 * struct omap_ball - data for balls on omap package
149 * @reg_offset: mux register offset from the mux base
150 * @balls: available balls on the package
154 char *balls
[OMAP_MUX_NR_SIDES
];
158 * struct omap_board_mux - data for initializing mux registers
159 * @reg_offset: mux register offset from the mux base
160 * @mux_value: desired mux value to set
162 struct omap_board_mux
{
167 #define OMAP_DEVICE_PAD_REMUX BIT(1) /* Dynamically remux a pad,
168 needs enable, idle and off
170 #define OMAP_DEVICE_PAD_WAKEUP BIT(0) /* Pad is wake-up capable */
173 * struct omap_device_pad - device specific pad configuration
175 * @flags: pad specific runtime flags
176 * @enable: runtime value for a pad
177 * @idle: idle value for a pad
178 * @off: off value for a pad, defaults to safe mode
179 * @partition: mux partition
182 struct omap_device_pad
{
188 struct omap_mux_partition
*partition
;
189 struct omap_mux
*mux
;
192 struct omap_hwmod_mux_info
;
194 #define OMAP_MUX_STATIC(signal, mode) \
200 #if defined(CONFIG_OMAP_MUX)
203 * omap_mux_init_gpio - initialize a signal based on the GPIO number
205 * @val: Options for the mux register value
207 int omap_mux_init_gpio(int gpio
, int val
);
210 * omap_mux_init_signal - initialize a signal based on the signal name
211 * @muxname: Mux name in mode0_name.signal_name format
212 * @val: Options for the mux register value
214 int omap_mux_init_signal(const char *muxname
, int val
);
217 * omap_hwmod_mux_init - initialize hwmod specific mux data
218 * @bpads: Board specific device signal names
219 * @nr_pads: Number of signal names for the device
221 extern struct omap_hwmod_mux_info
*
222 omap_hwmod_mux_init(struct omap_device_pad
*bpads
, int nr_pads
);
225 * omap_hwmod_mux - omap hwmod specific pin muxing
226 * @hmux: Pads for a hwmod
227 * @state: Desired _HWMOD_STATE
229 * Called only from omap_hwmod.c, do not use.
231 void omap_hwmod_mux(struct omap_hwmod_mux_info
*hmux
, u8 state
);
233 int omap_mux_get_by_name(const char *muxname
,
234 struct omap_mux_partition
**found_partition
,
235 struct omap_mux
**found_mux
);
238 static inline int omap_mux_get_by_name(const char *muxname
,
239 struct omap_mux_partition
**found_partition
,
240 struct omap_mux
**found_mux
)
245 static inline int omap_mux_init_gpio(int gpio
, int val
)
249 static inline int omap_mux_init_signal(char *muxname
, int val
)
254 static inline struct omap_hwmod_mux_info
*
255 omap_hwmod_mux_init(struct omap_device_pad
*bpads
, int nr_pads
)
260 static inline void omap_hwmod_mux(struct omap_hwmod_mux_info
*hmux
, u8 state
)
264 static struct omap_board_mux
*board_mux __maybe_unused
;
269 * omap_mux_get_gpio() - get mux register value based on GPIO number
273 u16
omap_mux_get_gpio(int gpio
);
276 * omap_mux_set_gpio() - set mux register value based on GPIO number
277 * @val: New mux register value
281 void omap_mux_set_gpio(u16 val
, int gpio
);
284 * omap_mux_get() - get a mux partition by name
285 * @name: Name of the mux partition
288 struct omap_mux_partition
*omap_mux_get(const char *name
);
291 * omap_mux_read() - read mux register
292 * @partition: Mux partition
293 * @mux_offset: Offset of the mux register
296 u16
omap_mux_read(struct omap_mux_partition
*p
, u16 mux_offset
);
299 * omap_mux_write() - write mux register
300 * @partition: Mux partition
301 * @val: New mux register value
302 * @mux_offset: Offset of the mux register
304 * This should be only needed for dynamic remuxing of non-gpio signals.
306 void omap_mux_write(struct omap_mux_partition
*p
, u16 val
, u16 mux_offset
);
309 * omap_mux_write_array() - write an array of mux registers
310 * @partition: Mux partition
311 * @board_mux: Array of mux registers terminated by MAP_MUX_TERMINATOR
313 * This should be only needed for dynamic remuxing of non-gpio signals.
315 void omap_mux_write_array(struct omap_mux_partition
*p
,
316 struct omap_board_mux
*board_mux
);
319 * omap2420_mux_init() - initialize mux system with board specific set
320 * @board_mux: Board specific mux table
321 * @flags: OMAP package type used for the board
323 int omap2420_mux_init(struct omap_board_mux
*board_mux
, int flags
);
326 * omap2430_mux_init() - initialize mux system with board specific set
327 * @board_mux: Board specific mux table
328 * @flags: OMAP package type used for the board
330 int omap2430_mux_init(struct omap_board_mux
*board_mux
, int flags
);
333 * omap3_mux_init() - initialize mux system with board specific set
334 * @board_mux: Board specific mux table
335 * @flags: OMAP package type used for the board
337 int omap3_mux_init(struct omap_board_mux
*board_mux
, int flags
);
340 * omap4_mux_init() - initialize mux system with board specific set
341 * @board_subset: Board specific mux table
342 * @board_wkup_subset: Board specific mux table for wakeup instance
343 * @flags: OMAP package type used for the board
345 int omap4_mux_init(struct omap_board_mux
*board_subset
,
346 struct omap_board_mux
*board_wkup_subset
, int flags
);
349 * omap_mux_init - private mux init function, do not call
351 int omap_mux_init(const char *name
, u32 flags
,
352 u32 mux_pbase
, u32 mux_size
,
353 struct omap_mux
*superset
,
354 struct omap_mux
*package_subset
,
355 struct omap_board_mux
*board_mux
,
356 struct omap_ball
*package_balls
);