Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mux.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Nokia
3  * Copyright (C) 2009-2010 Texas Instruments
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 
10 #include "mux2420.h"
11 #include "mux2430.h"
12 #include "mux34xx.h"
13 #include "mux44xx.h"
14 
15 #define OMAP_MUX_TERMINATOR 0xffff
16 
17 /* 34xx mux mode options for each pin. See TRM for options */
18 #define OMAP_MUX_MODE0 0
19 #define OMAP_MUX_MODE1 1
20 #define OMAP_MUX_MODE2 2
21 #define OMAP_MUX_MODE3 3
22 #define OMAP_MUX_MODE4 4
23 #define OMAP_MUX_MODE5 5
24 #define OMAP_MUX_MODE6 6
25 #define OMAP_MUX_MODE7 7
26 
27 /* 24xx/34xx mux bit defines */
28 #define OMAP_PULL_ENA (1 << 3)
29 #define OMAP_PULL_UP (1 << 4)
30 #define OMAP_ALTELECTRICALSEL (1 << 5)
31 
32 /* 34xx specific mux bit defines */
33 #define OMAP_INPUT_EN (1 << 8)
34 #define OMAP_OFF_EN (1 << 9)
35 #define OMAP_OFFOUT_EN (1 << 10)
36 #define OMAP_OFFOUT_VAL (1 << 11)
37 #define OMAP_OFF_PULL_EN (1 << 12)
38 #define OMAP_OFF_PULL_UP (1 << 13)
39 #define OMAP_WAKEUP_EN (1 << 14)
40 
41 /* 44xx specific mux bit defines */
42 #define OMAP_WAKEUP_EVENT (1 << 15)
43 
44 /* Active pin states */
45 #define OMAP_PIN_OUTPUT 0
46 #define OMAP_PIN_INPUT OMAP_INPUT_EN
47 #define OMAP_PIN_INPUT_PULLUP (OMAP_PULL_ENA | OMAP_INPUT_EN \
48  | OMAP_PULL_UP)
49 #define OMAP_PIN_INPUT_PULLDOWN (OMAP_PULL_ENA | OMAP_INPUT_EN)
50 
51 /* Off mode states */
52 #define OMAP_PIN_OFF_NONE 0
53 #define OMAP_PIN_OFF_OUTPUT_HIGH (OMAP_OFF_EN | OMAP_OFFOUT_EN \
54  | OMAP_OFFOUT_VAL)
55 #define OMAP_PIN_OFF_OUTPUT_LOW (OMAP_OFF_EN | OMAP_OFFOUT_EN)
56 #define OMAP_PIN_OFF_INPUT_PULLUP (OMAP_OFF_EN | OMAP_OFF_PULL_EN \
57  | OMAP_OFF_PULL_UP)
58 #define OMAP_PIN_OFF_INPUT_PULLDOWN (OMAP_OFF_EN | OMAP_OFF_PULL_EN)
59 #define OMAP_PIN_OFF_WAKEUPENABLE OMAP_WAKEUP_EN
60 
61 #define OMAP_MODE_GPIO(x) (((x) & OMAP_MUX_MODE7) == OMAP_MUX_MODE4)
62 #define OMAP_MODE_UART(x) (((x) & OMAP_MUX_MODE7) == OMAP_MUX_MODE0)
63 
64 /* Flags for omapX_mux_init */
65 #define OMAP_PACKAGE_MASK 0xffff
66 #define OMAP_PACKAGE_CBS 8 /* 547-pin 0.40 0.40 */
67 #define OMAP_PACKAGE_CBL 7 /* 547-pin 0.40 0.40 */
68 #define OMAP_PACKAGE_CBP 6 /* 515-pin 0.40 0.50 */
69 #define OMAP_PACKAGE_CUS 5 /* 423-pin 0.65 */
70 #define OMAP_PACKAGE_CBB 4 /* 515-pin 0.40 0.50 */
71 #define OMAP_PACKAGE_CBC 3 /* 515-pin 0.50 0.65 */
72 #define OMAP_PACKAGE_ZAC 2 /* 24xx 447-pin POP */
73 #define OMAP_PACKAGE_ZAF 1 /* 2420 447-pin SIP */
74 
75 
76 #define OMAP_MUX_NR_MODES 8 /* Available modes */
77 #define OMAP_MUX_NR_SIDES 2 /* Bottom & top */
78 
79 /*
80  * omap_mux_init flags definition:
81  *
82  * OMAP_MUX_REG_8BIT: Ensure that access to padconf is done in 8 bits.
83  * The default value is 16 bits.
84  * OMAP_MUX_GPIO_IN_MODE3: The GPIO is selected in mode3.
85  * The default is mode4.
86  */
87 #define OMAP_MUX_REG_8BIT (1 << 0)
88 #define OMAP_MUX_GPIO_IN_MODE3 (1 << 1)
89 
98  int id;
101  int pads_cnt;
102 };
103 
115  const char *name;
119  void __iomem *base;
121  struct list_head node;
122 };
123 
131 struct omap_mux {
134 #ifdef CONFIG_OMAP_MUX
135  char *muxnames[OMAP_MUX_NR_MODES];
136 #ifdef CONFIG_DEBUG_FS
137  char *balls[OMAP_MUX_NR_SIDES];
138 #endif
139 #endif
140 };
141 
147 struct omap_ball {
150 };
151 
160 };
161 
162 #define OMAP_DEVICE_PAD_REMUX BIT(1) /* Dynamically remux a pad,
163  needs enable, idle and off
164  values */
165 #define OMAP_DEVICE_PAD_WAKEUP BIT(0) /* Pad is wake-up capable */
166 
178  char *name;
184  struct omap_mux *mux;
185 };
186 
188 
189 #define OMAP_MUX_STATIC(signal, mode) \
190 { \
191  .name = (signal), \
192  .enable = (mode), \
193 }
194 
195 #if defined(CONFIG_OMAP_MUX)
196 
202 int omap_mux_init_gpio(int gpio, int val);
203 
209 int omap_mux_init_signal(const char *muxname, int val);
210 
216 extern struct omap_hwmod_mux_info *
217 omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads);
218 
226 void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state);
227 
228 int omap_mux_get_by_name(const char *muxname,
229  struct omap_mux_partition **found_partition,
230  struct omap_mux **found_mux);
231 #else
232 
233 static inline int omap_mux_get_by_name(const char *muxname,
234  struct omap_mux_partition **found_partition,
235  struct omap_mux **found_mux)
236 {
237  return 0;
238 }
239 
240 static inline int omap_mux_init_gpio(int gpio, int val)
241 {
242  return 0;
243 }
244 static inline int omap_mux_init_signal(char *muxname, int val)
245 {
246  return 0;
247 }
248 
249 static inline struct omap_hwmod_mux_info *
250 omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)
251 {
252  return NULL;
253 }
254 
255 static inline void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
256 {
257 }
258 
260 
261 #endif
262 
269 
276 void omap_mux_set_gpio(u16 val, int gpio);
277 
283 struct omap_mux_partition *omap_mux_get(const char *name);
284 
291 u16 omap_mux_read(struct omap_mux_partition *p, u16 mux_offset);
292 
301 void omap_mux_write(struct omap_mux_partition *p, u16 val, u16 mux_offset);
302 
311  struct omap_board_mux *board_mux);
312 
319 
326 
332 int omap3_mux_init(struct omap_board_mux *board_mux, int flags);
333 
340 int omap4_mux_init(struct omap_board_mux *board_subset,
341  struct omap_board_mux *board_wkup_subset, int flags);
342 
346 int omap_mux_init(const char *name, u32 flags,
347  u32 mux_pbase, u32 mux_size,
348  struct omap_mux *superset,
349  struct omap_mux *package_subset,
350  struct omap_board_mux *board_mux,
351  struct omap_ball *package_balls);
352