ARM: cpu topology: Add debugfs interface for cpu_power
[cmplus.git] / arch / arm / mach-omap2 / mux.h
blobe631b5e82b910839e918f3d8ace664659d729f67
1 /*
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.
8 */
10 #include "mux2420.h"
11 #include "mux2430.h"
12 #include "mux34xx.h"
13 #include "mux44xx.h"
15 #define OMAP_MUX_TERMINATOR 0xffff
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
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)
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)
41 /* 44xx specific mux bit defines */
42 #define OMAP_WAKEUP_EVENT (1 << 15)
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)
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
61 #define OMAP_MODE_GPIO(x) (((x) & OMAP_MUX_MODE7) == OMAP_MUX_MODE4)
63 /* Flags for omapX_mux_init */
64 #define OMAP_PACKAGE_MASK 0xffff
65 #define OMAP_PACKAGE_CBS 8 /* 547-pin 0.40 0.40 */
66 #define OMAP_PACKAGE_CBL 7 /* 547-pin 0.40 0.40 */
67 #define OMAP_PACKAGE_CBP 6 /* 515-pin 0.40 0.50 */
68 #define OMAP_PACKAGE_CUS 5 /* 423-pin 0.65 */
69 #define OMAP_PACKAGE_CBB 4 /* 515-pin 0.40 0.50 */
70 #define OMAP_PACKAGE_CBC 3 /* 515-pin 0.50 0.65 */
71 #define OMAP_PACKAGE_ZAC 2 /* 24xx 447-pin POP */
72 #define OMAP_PACKAGE_ZAF 1 /* 2420 447-pin SIP */
75 #define OMAP_MUX_NR_MODES 8 /* Available modes */
76 #define OMAP_MUX_NR_SIDES 2 /* Bottom & top */
79 * omap_mux_init flags definition:
81 * OMAP_MUX_REG_8BIT: Ensure that access to padconf is done in 8 bits.
82 * The default value is 16 bits.
83 * OMAP_MUX_GPIO_IN_MODE3: The GPIO is selected in mode3.
84 * The default is mode4.
86 #define OMAP_MUX_REG_8BIT (1 << 0)
87 #define OMAP_MUX_GPIO_IN_MODE3 (1 << 1)
89 /**
90 * struct omap_board_data - board specific device data
91 * @id: instance id
92 * @flags: additional flags for platform init code
93 * @pads: array of device specific pads
94 * @pads_cnt: ARRAY_SIZE() of pads
96 struct omap_board_data {
97 int id;
98 u32 flags;
99 struct omap_device_pad *pads;
100 int pads_cnt;
104 * struct mux_partition - contain partition related information
105 * @name: name of the current partition
106 * @flags: flags specific to this partition
107 * @phys: physical address
108 * @size: partition size
109 * @base: virtual address after ioremap
110 * @muxmodes: list of nodes that belong to a partition
111 * @node: list node for the partitions linked list
113 struct omap_mux_partition {
114 const char *name;
115 u32 flags;
116 u32 phys;
117 u32 size;
118 void __iomem *base;
119 struct list_head muxmodes;
120 struct list_head node;
124 * struct omap_mux - data for omap mux register offset and it's value
125 * @reg_offset: mux register offset from the mux base
126 * @gpio: GPIO number
127 * @muxnames: available signal modes for a ball
128 * @balls: available balls on the package
129 * @partition: mux partition
131 struct omap_mux {
132 u16 reg_offset;
133 u16 gpio;
134 struct omap_mux_partition *partition;
135 #ifdef CONFIG_OMAP_MUX
136 char *muxnames[OMAP_MUX_NR_MODES];
137 #ifdef CONFIG_DEBUG_FS
138 char *balls[OMAP_MUX_NR_SIDES];
139 #endif
140 #endif
144 * struct omap_ball - data for balls on omap package
145 * @reg_offset: mux register offset from the mux base
146 * @balls: available balls on the package
148 struct omap_ball {
149 u16 reg_offset;
150 char *balls[OMAP_MUX_NR_SIDES];
154 * struct omap_board_mux - data for initializing mux registers
155 * @reg_offset: mux register offset from the mux base
156 * @mux_value: desired mux value to set
158 struct omap_board_mux {
159 u16 reg_offset;
160 u16 value;
163 #define OMAP_DEVICE_PAD_REMUX BIT(1) /* Dynamically remux a pad,
164 needs enable, idle and off
165 values */
166 #define OMAP_DEVICE_PAD_WAKEUP BIT(0) /* Pad is wake-up capable */
169 * struct omap_device_pad - device specific pad configuration
170 * @name: signal name
171 * @flags: pad specific runtime flags
172 * @enable: runtime value for a pad
173 * @idle: idle value for a pad
174 * @off: off value for a pad, defaults to safe mode
175 * @partition: mux partition
176 * @mux: mux register
178 struct omap_device_pad {
179 char *name;
180 u8 flags;
181 u16 enable;
182 u16 idle;
183 u16 off;
184 struct omap_mux_partition *partition;
185 struct omap_mux *mux;
188 struct omap_hwmod_mux_info;
190 #define OMAP_MUX_STATIC(signal, mode) \
192 .name = (signal), \
193 .enable = (mode), \
196 #if defined(CONFIG_OMAP_MUX)
199 * omap_mux_init_gpio - initialize a signal based on the GPIO number
200 * @gpio: GPIO number
201 * @val: Options for the mux register value
203 int omap_mux_init_gpio(int gpio, int val);
206 * omap_mux_init_signal - initialize a signal based on the signal name
207 * @muxname: Mux name in mode0_name.signal_name format
208 * @val: Options for the mux register value
210 int omap_mux_init_signal(const char *muxname, int val);
213 * omap_hwmod_mux_init - initialize hwmod specific mux data
214 * @bpads: Board specific device signal names
215 * @nr_pads: Number of signal names for the device
217 extern struct omap_hwmod_mux_info *
218 omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads);
221 * omap_hwmod_mux - omap hwmod specific pin muxing
222 * @hmux: Pads for a hwmod
223 * @state: Desired _HWMOD_STATE
225 * Called only from omap_hwmod.c, do not use.
227 void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state);
230 * omap_hwmod_mux_get_wake_status - omap hwmod check pad wakeup
231 * @hmux: Pads for a hwmod
233 * Called only from omap_hwmod.c, do not use.
235 int omap_hwmod_mux_get_wake_status(struct omap_hwmod_mux_info *hmux);
236 #else
238 static inline int
239 omap_hwmod_mux_get_wake_status(struct omap_hwmod_mux_info *hmux)
241 return 0;
244 static inline int omap_mux_init_gpio(int gpio, int val)
246 return 0;
248 static inline int omap_mux_init_signal(char *muxname, int val)
250 return 0;
253 static inline struct omap_hwmod_mux_info *
254 omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)
256 return NULL;
259 static inline void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
263 static struct omap_board_mux *board_mux __initdata __maybe_unused;
265 #endif
268 * omap_mux_get_gpio() - get mux struct based on GPIO number
269 * @gpio: GPIO number
272 struct omap_mux *omap_mux_get_gpio(int gpio);
274 /** omap_mux_set_wakeupenable() - set the wakeupenable bit on a mux struct
275 * @m: mux struct
277 int omap_mux_set_wakeupenable(struct omap_mux *m);
279 /** omap_mux_clear_wakeupenable() - clear the wakeupenable bit on a mux struct
280 * @m: mux struct
282 int omap_mux_clear_wakeupenable(struct omap_mux *m);
284 /** omap_mux_get_wakeupenable() - get the wakeupenable bit from a mux struct
285 * @m: mux struct
287 bool omap_mux_get_wakeupenable(struct omap_mux *m);
289 /** omap_mux_get_wakeupevent() - get the wakeupevent bit from a mux struct
290 * @m: mux struct
292 bool omap_mux_get_wakeupevent(struct omap_mux *m);
295 * omap_mux_set_gpio() - set mux register value based on GPIO number
296 * @val: New mux register value
297 * @gpio: GPIO number
300 void omap_mux_set_gpio(u16 val, int gpio);
303 * omap_mux_get() - get a mux partition by name
304 * @name: Name of the mux partition
307 struct omap_mux_partition *omap_mux_get(const char *name);
310 * omap_mux_read() - read mux register
311 * @partition: Mux partition
312 * @mux_offset: Offset of the mux register
315 u16 omap_mux_read(struct omap_mux_partition *p, u16 mux_offset);
318 * omap_mux_write() - write mux register
319 * @partition: Mux partition
320 * @val: New mux register value
321 * @mux_offset: Offset of the mux register
323 * This should be only needed for dynamic remuxing of non-gpio signals.
325 void omap_mux_write(struct omap_mux_partition *p, u16 val, u16 mux_offset);
328 * omap_mux_write_array() - write an array of mux registers
329 * @partition: Mux partition
330 * @board_mux: Array of mux registers terminated by MAP_MUX_TERMINATOR
332 * This should be only needed for dynamic remuxing of non-gpio signals.
334 void omap_mux_write_array(struct omap_mux_partition *p,
335 struct omap_board_mux *board_mux);
338 * omap2420_mux_init() - initialize mux system with board specific set
339 * @board_mux: Board specific mux table
340 * @flags: OMAP package type used for the board
342 int omap2420_mux_init(struct omap_board_mux *board_mux, int flags);
345 * omap2430_mux_init() - initialize mux system with board specific set
346 * @board_mux: Board specific mux table
347 * @flags: OMAP package type used for the board
349 int omap2430_mux_init(struct omap_board_mux *board_mux, int flags);
352 * omap3_mux_init() - initialize mux system with board specific set
353 * @board_mux: Board specific mux table
354 * @flags: OMAP package type used for the board
356 int omap3_mux_init(struct omap_board_mux *board_mux, int flags);
359 * omap4_mux_init() - initialize mux system with board specific set
360 * @board_subset: Board specific mux table
361 * @board_wkup_subset: Board specific mux table for wakeup instance
362 * @flags: OMAP package type used for the board
364 int omap4_mux_init(struct omap_board_mux *board_subset,
365 struct omap_board_mux *board_wkup_subset, int flags);
368 * omap_mux_init - private mux init function, do not call
370 int omap_mux_init(const char *name, u32 flags,
371 u32 mux_pbase, u32 mux_size,
372 struct omap_mux *superset,
373 struct omap_mux *package_subset,
374 struct omap_board_mux *board_mux,
375 struct omap_ball *package_balls);