crypto: omap - OMAP macros corrected
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-omap2 / mux.h
blob480abc56e605b2140590c7556c46ff15bb31892f
1 /*
2 * Copyright (C) 2009 Nokia
3 * Copyright (C) 2009 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.
8 */
10 #include "mux34xx.h"
12 #define OMAP_MUX_TERMINATOR 0xffff
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
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)
29 /* 34xx specific mux bit defines */
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)
38 /* Active pin states */
39 #define OMAP_PIN_OUTPUT 0
40 #define OMAP_PIN_INPUT OMAP_INPUT_EN
41 #define OMAP_PIN_INPUT_PULLUP (OMAP_PULL_ENA | OMAP_INPUT_EN \
42 | OMAP_PULL_UP)
43 #define OMAP_PIN_INPUT_PULLDOWN (OMAP_PULL_ENA | OMAP_INPUT_EN)
45 /* Off mode states */
46 #define OMAP_PIN_OFF_NONE 0
47 #define OMAP_PIN_OFF_OUTPUT_HIGH (OMAP_OFF_EN | OMAP_OFFOUT_EN \
48 | OMAP_OFFOUT_VAL)
49 #define OMAP_PIN_OFF_OUTPUT_LOW (OMAP_OFF_EN | OMAP_OFFOUT_EN)
50 #define OMAP_PIN_OFF_INPUT_PULLUP (OMAP_OFF_EN | OMAP_OFF_PULL_EN \
51 | OMAP_OFF_PULL_UP)
52 #define OMAP_PIN_OFF_INPUT_PULLDOWN (OMAP_OFF_EN | OMAP_OFF_PULL_EN)
53 #define OMAP_PIN_OFF_WAKEUPENABLE OMAP_WAKEUP_EN
55 #define OMAP_MODE_GPIO(x) (((x) & OMAP_MUX_MODE7) == OMAP_MUX_MODE4)
57 /* Flags for omap_mux_init */
58 #define OMAP_PACKAGE_MASK 0xffff
59 #define OMAP_PACKAGE_CBP 4 /* 515-pin 0.40 0.50 */
60 #define OMAP_PACKAGE_CUS 3 /* 423-pin 0.65 */
61 #define OMAP_PACKAGE_CBB 2 /* 515-pin 0.40 0.50 */
62 #define OMAP_PACKAGE_CBC 1 /* 515-pin 0.50 0.65 */
65 #define OMAP_MUX_NR_MODES 8 /* Available modes */
66 #define OMAP_MUX_NR_SIDES 2 /* Bottom & top */
68 /**
69 * struct omap_mux - data for omap mux register offset and it's value
70 * @reg_offset: mux register offset from the mux base
71 * @gpio: GPIO number
72 * @muxnames: available signal modes for a ball
74 struct omap_mux {
75 u16 reg_offset;
76 u16 gpio;
77 #ifdef CONFIG_OMAP_MUX
78 char *muxnames[OMAP_MUX_NR_MODES];
79 #ifdef CONFIG_DEBUG_FS
80 char *balls[OMAP_MUX_NR_SIDES];
81 #endif
82 #endif
85 /**
86 * struct omap_ball - data for balls on omap package
87 * @reg_offset: mux register offset from the mux base
88 * @balls: available balls on the package
90 struct omap_ball {
91 u16 reg_offset;
92 char *balls[OMAP_MUX_NR_SIDES];
95 /**
96 * struct omap_board_mux - data for initializing mux registers
97 * @reg_offset: mux register offset from the mux base
98 * @mux_value: desired mux value to set
100 struct omap_board_mux {
101 u16 reg_offset;
102 u16 value;
105 #if defined(CONFIG_OMAP_MUX) && defined(CONFIG_ARCH_OMAP3)
108 * omap_mux_init_gpio - initialize a signal based on the GPIO number
109 * @gpio: GPIO number
110 * @val: Options for the mux register value
112 int omap_mux_init_gpio(int gpio, int val);
115 * omap_mux_init_signal - initialize a signal based on the signal name
116 * @muxname: Mux name in mode0_name.signal_name format
117 * @val: Options for the mux register value
119 int omap_mux_init_signal(char *muxname, int val);
121 #else
123 static inline int omap_mux_init_gpio(int gpio, int val)
125 return 0;
127 static inline int omap_mux_init_signal(char *muxname, int val)
129 return 0;
132 #endif
135 * omap_mux_get_gpio() - get mux register value based on GPIO number
136 * @gpio: GPIO number
139 u16 omap_mux_get_gpio(int gpio);
142 * omap_mux_set_gpio() - set mux register value based on GPIO number
143 * @val: New mux register value
144 * @gpio: GPIO number
147 void omap_mux_set_gpio(u16 val, int gpio);
150 * omap_mux_read() - read mux register
151 * @mux_offset: Offset of the mux register
154 u16 omap_mux_read(u16 mux_offset);
157 * omap_mux_write() - write mux register
158 * @val: New mux register value
159 * @mux_offset: Offset of the mux register
161 * This should be only needed for dynamic remuxing of non-gpio signals.
163 void omap_mux_write(u16 val, u16 mux_offset);
166 * omap_mux_write_array() - write an array of mux registers
167 * @board_mux: Array of mux registers terminated by MAP_MUX_TERMINATOR
169 * This should be only needed for dynamic remuxing of non-gpio signals.
171 void omap_mux_write_array(struct omap_board_mux *board_mux);
174 * omap3_mux_init() - initialize mux system with board specific set
175 * @board_mux: Board specific mux table
176 * @flags: OMAP package type used for the board
178 int omap3_mux_init(struct omap_board_mux *board_mux, int flags);
181 * omap_mux_init - private mux init function, do not call
183 int omap_mux_init(u32 mux_pbase, u32 mux_size,
184 struct omap_mux *superset,
185 struct omap_mux *package_subset,
186 struct omap_board_mux *board_mux,
187 struct omap_ball *package_balls);