aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/mux.h
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2009-12-11 19:16:32 -0500
committerTony Lindgren <tony@atomide.com>2009-12-11 19:16:32 -0500
commit15ac7afe515631ec36966b1cf632a87276536f57 (patch)
tree68fae5c0154ccf441468569c0d763b32c3b90f21 /arch/arm/mach-omap2/mux.h
parent92c9f5018997dbc5f5e91eae2400d78ada2760b0 (diff)
omap: mux: Add new style pin multiplexing code for omap3
Initially only for 34xx. This code allows us to: - Make the code more generic as the omap internal signal names can stay the same across omap generations for some devices - Map mux registers to GPIO registers that is needed for dynamic muxing of pins during off-idle - Override bootloader mux values via kernel cmdline using omap_mux=some.signa1=0x1234,some.signal2=0x1234 - View and set the mux registers via debugfs if CONFIG_DEBUG_FS is enabled Cc: Mike Rapoport <mike@compulab.co.il> Cc: Benoit Cousson <b-cousson@ti.com> Signed-off-by: Paul Walmsley <paul@pwsan.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/mux.h')
-rw-r--r--arch/arm/mach-omap2/mux.h160
1 files changed, 160 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
new file mode 100644
index 000000000000..bebe9cc60858
--- /dev/null
+++ b/arch/arm/mach-omap2/mux.h
@@ -0,0 +1,160 @@
1/*
2 * Copyright (C) 2009 Nokia
3 * Copyright (C) 2009 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#define OMAP_MUX_TERMINATOR 0xffff
11
12/* 34xx mux mode options for each pin. See TRM for options */
13#define OMAP_MUX_MODE0 0
14#define OMAP_MUX_MODE1 1
15#define OMAP_MUX_MODE2 2
16#define OMAP_MUX_MODE3 3
17#define OMAP_MUX_MODE4 4
18#define OMAP_MUX_MODE5 5
19#define OMAP_MUX_MODE6 6
20#define OMAP_MUX_MODE7 7
21
22/* 24xx/34xx mux bit defines */
23#define OMAP_PULL_ENA (1 << 3)
24#define OMAP_PULL_UP (1 << 4)
25#define OMAP_ALTELECTRICALSEL (1 << 5)
26
27/* 34xx specific mux bit defines */
28#define OMAP_INPUT_EN (1 << 8)
29#define OMAP_OFF_EN (1 << 9)
30#define OMAP_OFFOUT_EN (1 << 10)
31#define OMAP_OFFOUT_VAL (1 << 11)
32#define OMAP_OFF_PULL_EN (1 << 12)
33#define OMAP_OFF_PULL_UP (1 << 13)
34#define OMAP_WAKEUP_EN (1 << 14)
35
36/* Active pin states */
37#define OMAP_PIN_OUTPUT 0
38#define OMAP_PIN_INPUT OMAP_INPUT_EN
39#define OMAP_PIN_INPUT_PULLUP (OMAP_PULL_ENA | OMAP_INPUT_EN \
40 | OMAP_PULL_UP)
41#define OMAP_PIN_INPUT_PULLDOWN (OMAP_PULL_ENA | OMAP_INPUT_EN)
42
43/* Off mode states */
44#define OMAP_PIN_OFF_NONE 0
45#define OMAP_PIN_OFF_OUTPUT_HIGH (OMAP_OFF_EN | OMAP_OFFOUT_EN \
46 | OMAP_OFFOUT_VAL)
47#define OMAP_PIN_OFF_OUTPUT_LOW (OMAP_OFF_EN | OMAP_OFFOUT_EN)
48#define OMAP_PIN_OFF_INPUT_PULLUP (OMAP_OFF_EN | OMAP_OFF_PULL_EN \
49 | OMAP_OFF_PULL_UP)
50#define OMAP_PIN_OFF_INPUT_PULLDOWN (OMAP_OFF_EN | OMAP_OFF_PULL_EN)
51#define OMAP_PIN_OFF_WAKEUPENABLE OMAP_WAKEUP_EN
52
53#define OMAP_MODE_GPIO(x) (((x) & OMAP_MUX_MODE7) == OMAP_MUX_MODE4)
54
55/* Flags for omap_mux_init */
56#define OMAP_PACKAGE_MASK 0xffff
57#define OMAP_PACKAGE_CUS 3 /* 423-pin 0.65 */
58#define OMAP_PACKAGE_CBB 2 /* 515-pin 0.40 0.50 */
59#define OMAP_PACKAGE_CBC 1 /* 515-pin 0.50 0.65 */
60
61
62#define OMAP_MUX_NR_MODES 8 /* Available modes */
63#define OMAP_MUX_NR_SIDES 2 /* Bottom & top */
64
65/**
66 * struct omap_mux - data for omap mux register offset and it's value
67 * @reg_offset: mux register offset from the mux base
68 * @gpio: GPIO number
69 * @muxnames: available signal modes for a ball
70 */
71struct omap_mux {
72 u16 reg_offset;
73 u16 gpio;
74#ifdef CONFIG_OMAP_MUX
75 char *muxnames[OMAP_MUX_NR_MODES];
76#ifdef CONFIG_DEBUG_FS
77 char *balls[OMAP_MUX_NR_SIDES];
78#endif
79#endif
80};
81
82/**
83 * struct omap_ball - data for balls on omap package
84 * @reg_offset: mux register offset from the mux base
85 * @balls: available balls on the package
86 */
87struct omap_ball {
88 u16 reg_offset;
89 char *balls[OMAP_MUX_NR_SIDES];
90};
91
92/**
93 * struct omap_board_mux - data for initializing mux registers
94 * @reg_offset: mux register offset from the mux base
95 * @mux_value: desired mux value to set
96 */
97struct omap_board_mux {
98 u16 reg_offset;
99 u16 value;
100};
101
102#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_ARCH_OMAP34XX)
103
104/**
105 * omap_mux_init_gpio - initialize a signal based on the GPIO number
106 * @gpio: GPIO number
107 * @val: Options for the mux register value
108 */
109int omap_mux_init_gpio(int gpio, int val);
110
111/**
112 * omap_mux_init_signal - initialize a signal based on the signal name
113 * @muxname: Mux name in mode0_name.signal_name format
114 * @val: Options for the mux register value
115 */
116int omap_mux_init_signal(char *muxname, int val);
117
118#else
119
120static inline int omap_mux_init_gpio(int gpio, int val)
121{
122 return 0;
123}
124static inline int omap_mux_init_signal(char *muxname, int val)
125{
126 return 0;
127}
128
129#endif
130
131/**
132 * omap_mux_get_gpio() - get mux register value based on GPIO number
133 * @gpio: GPIO number
134 *
135 */
136u16 omap_mux_get_gpio(int gpio);
137
138/**
139 * omap_mux_set_gpio() - set mux register value based on GPIO number
140 * @val: New mux register value
141 * @gpio: GPIO number
142 *
143 */
144void omap_mux_set_gpio(u16 val, int gpio);
145
146/**
147 * omap3_mux_init() - initialize mux system with board specific set
148 * @board_mux: Board specific mux table
149 * @flags: OMAP package type used for the board
150 */
151int omap3_mux_init(struct omap_board_mux *board_mux, int flags);
152
153/**
154 * omap_mux_init - private mux init function, do not call
155 */
156int omap_mux_init(u32 mux_pbase, u32 mux_size,
157 struct omap_mux *superset,
158 struct omap_mux *package_subset,
159 struct omap_board_mux *board_mux,
160 struct omap_ball *package_balls);