Commit | Line | Data |
---|---|---|
15ac7afe TL |
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 | ||
ddaa912a TL |
10 | #include "mux34xx.h" |
11 | ||
15ac7afe TL |
12 | #define OMAP_MUX_TERMINATOR 0xffff |
13 | ||
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 | |
23 | ||
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) | |
28 | ||
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) | |
37 | ||
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) | |
44 | ||
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 | |
54 | ||
55 | #define OMAP_MODE_GPIO(x) (((x) & OMAP_MUX_MODE7) == OMAP_MUX_MODE4) | |
56 | ||
57 | /* Flags for omap_mux_init */ | |
58 | #define OMAP_PACKAGE_MASK 0xffff | |
662c8b55 | 59 | #define OMAP_PACKAGE_CBP 4 /* 515-pin 0.40 0.50 */ |
15ac7afe TL |
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 */ | |
63 | ||
64 | ||
65 | #define OMAP_MUX_NR_MODES 8 /* Available modes */ | |
66 | #define OMAP_MUX_NR_SIDES 2 /* Bottom & top */ | |
67 | ||
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 | |
73 | */ | |
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 | |
83 | }; | |
84 | ||
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 | |
89 | */ | |
90 | struct omap_ball { | |
91 | u16 reg_offset; | |
92 | char *balls[OMAP_MUX_NR_SIDES]; | |
93 | }; | |
94 | ||
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 | |
99 | */ | |
100 | struct omap_board_mux { | |
101 | u16 reg_offset; | |
102 | u16 value; | |
103 | }; | |
104 | ||
105 | #if defined(CONFIG_OMAP_MUX) && defined(CONFIG_ARCH_OMAP34XX) | |
106 | ||
107 | /** | |
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 | |
111 | */ | |
112 | int omap_mux_init_gpio(int gpio, int val); | |
113 | ||
114 | /** | |
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 | |
118 | */ | |
119 | int omap_mux_init_signal(char *muxname, int val); | |
120 | ||
121 | #else | |
122 | ||
123 | static inline int omap_mux_init_gpio(int gpio, int val) | |
124 | { | |
125 | return 0; | |
126 | } | |
127 | static inline int omap_mux_init_signal(char *muxname, int val) | |
128 | { | |
129 | return 0; | |
130 | } | |
131 | ||
132 | #endif | |
133 | ||
134 | /** | |
135 | * omap_mux_get_gpio() - get mux register value based on GPIO number | |
136 | * @gpio: GPIO number | |
137 | * | |
138 | */ | |
139 | u16 omap_mux_get_gpio(int gpio); | |
140 | ||
141 | /** | |
142 | * omap_mux_set_gpio() - set mux register value based on GPIO number | |
143 | * @val: New mux register value | |
144 | * @gpio: GPIO number | |
145 | * | |
146 | */ | |
147 | void omap_mux_set_gpio(u16 val, int gpio); | |
148 | ||
149 | /** | |
150 | * omap3_mux_init() - initialize mux system with board specific set | |
151 | * @board_mux: Board specific mux table | |
152 | * @flags: OMAP package type used for the board | |
153 | */ | |
154 | int omap3_mux_init(struct omap_board_mux *board_mux, int flags); | |
155 | ||
156 | /** | |
157 | * omap_mux_init - private mux init function, do not call | |
158 | */ | |
159 | int omap_mux_init(u32 mux_pbase, u32 mux_size, | |
160 | struct omap_mux *superset, | |
161 | struct omap_mux *package_subset, | |
162 | struct omap_board_mux *board_mux, | |
163 | struct omap_ball *package_balls); |