diff options
-rw-r--r-- | arch/arm/mach-omap2/mux.c | 65 | ||||
-rw-r--r-- | arch/arm/mach-omap2/mux.h | 40 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/plat/omap_hwmod.h | 13 |
3 files changed, 118 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c index 0fa3d74125bc..27eb51a224cb 100644 --- a/arch/arm/mach-omap2/mux.c +++ b/arch/arm/mach-omap2/mux.c | |||
@@ -35,6 +35,8 @@ | |||
35 | 35 | ||
36 | #include <asm/system.h> | 36 | #include <asm/system.h> |
37 | 37 | ||
38 | #include <plat/omap_hwmod.h> | ||
39 | |||
38 | #include "control.h" | 40 | #include "control.h" |
39 | #include "mux.h" | 41 | #include "mux.h" |
40 | 42 | ||
@@ -252,6 +254,69 @@ int __init omap_mux_init_signal(const char *muxname, int val) | |||
252 | return 0; | 254 | return 0; |
253 | } | 255 | } |
254 | 256 | ||
257 | struct omap_hwmod_mux_info * __init | ||
258 | omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads) | ||
259 | { | ||
260 | struct omap_hwmod_mux_info *hmux; | ||
261 | int i; | ||
262 | |||
263 | if (!bpads || nr_pads < 1) | ||
264 | return NULL; | ||
265 | |||
266 | hmux = kzalloc(sizeof(struct omap_hwmod_mux_info), GFP_KERNEL); | ||
267 | if (!hmux) | ||
268 | goto err1; | ||
269 | |||
270 | hmux->nr_pads = nr_pads; | ||
271 | |||
272 | hmux->pads = kzalloc(sizeof(struct omap_device_pad) * | ||
273 | nr_pads, GFP_KERNEL); | ||
274 | if (!hmux->pads) | ||
275 | goto err2; | ||
276 | |||
277 | for (i = 0; i < hmux->nr_pads; i++) { | ||
278 | struct omap_mux_partition *partition; | ||
279 | struct omap_device_pad *bpad = &bpads[i], *pad = &hmux->pads[i]; | ||
280 | struct omap_mux *mux; | ||
281 | int mux_mode; | ||
282 | |||
283 | mux_mode = omap_mux_get_by_name(bpad->name, &partition, &mux); | ||
284 | if (mux_mode < 0) | ||
285 | goto err3; | ||
286 | if (!pad->partition) | ||
287 | pad->partition = partition; | ||
288 | if (!pad->mux) | ||
289 | pad->mux = mux; | ||
290 | |||
291 | pad->name = kzalloc(strlen(bpad->name) + 1, GFP_KERNEL); | ||
292 | if (!pad->name) { | ||
293 | int j; | ||
294 | |||
295 | for (j = i - 1; j >= 0; j--) | ||
296 | kfree(hmux->pads[j].name); | ||
297 | goto err3; | ||
298 | } | ||
299 | strcpy(pad->name, bpad->name); | ||
300 | |||
301 | pad->flags = bpad->flags; | ||
302 | pad->enable = bpad->enable; | ||
303 | pad->idle = bpad->idle; | ||
304 | pad->off = bpad->off; | ||
305 | pr_debug("%s: Initialized %s\n", __func__, pad->name); | ||
306 | } | ||
307 | |||
308 | return hmux; | ||
309 | |||
310 | err3: | ||
311 | kfree(hmux->pads); | ||
312 | err2: | ||
313 | kfree(hmux); | ||
314 | err1: | ||
315 | pr_err("%s: Could not allocate device mux entry\n", __func__); | ||
316 | |||
317 | return NULL; | ||
318 | } | ||
319 | |||
255 | #ifdef CONFIG_DEBUG_FS | 320 | #ifdef CONFIG_DEBUG_FS |
256 | 321 | ||
257 | #define OMAP_MUX_MAX_NR_FLAGS 10 | 322 | #define OMAP_MUX_MAX_NR_FLAGS 10 |
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h index f5f7f4938057..9c48b9d3ec29 100644 --- a/arch/arm/mach-omap2/mux.h +++ b/arch/arm/mach-omap2/mux.h | |||
@@ -145,6 +145,32 @@ struct omap_board_mux { | |||
145 | u16 value; | 145 | u16 value; |
146 | }; | 146 | }; |
147 | 147 | ||
148 | #define OMAP_DEVICE_PAD_ENABLED BIT(7) /* Not needed for board-*.c */ | ||
149 | #define OMAP_DEVICE_PAD_REMUX BIT(1) /* Dynamically remux a pad, | ||
150 | needs enable, idle and off | ||
151 | values */ | ||
152 | #define OMAP_DEVICE_PAD_WAKEUP BIT(0) /* Pad is wake-up capable */ | ||
153 | |||
154 | /** | ||
155 | * struct omap_device_pad - device specific pad configuration | ||
156 | * @name: signal name | ||
157 | * @flags: pad specific runtime flags | ||
158 | * @enable: runtime value for a pad | ||
159 | * @idle: idle value for a pad | ||
160 | * @off: off value for a pad, defaults to safe mode | ||
161 | * @partition: mux partition | ||
162 | * @mux: mux register | ||
163 | */ | ||
164 | struct omap_device_pad { | ||
165 | char *name; | ||
166 | u8 flags; | ||
167 | u16 enable; | ||
168 | u16 idle; | ||
169 | u16 off; | ||
170 | struct omap_mux_partition *partition; | ||
171 | struct omap_mux *mux; | ||
172 | }; | ||
173 | |||
148 | #if defined(CONFIG_OMAP_MUX) | 174 | #if defined(CONFIG_OMAP_MUX) |
149 | 175 | ||
150 | /** | 176 | /** |
@@ -161,6 +187,14 @@ int omap_mux_init_gpio(int gpio, int val); | |||
161 | */ | 187 | */ |
162 | int omap_mux_init_signal(const char *muxname, int val); | 188 | int omap_mux_init_signal(const char *muxname, int val); |
163 | 189 | ||
190 | /** | ||
191 | * omap_hwmod_mux_init - initialize hwmod specific mux data | ||
192 | * @bpads: Board specific device signal names | ||
193 | * @nr_pads: Number of signal names for the device | ||
194 | */ | ||
195 | extern struct omap_hwmod_mux_info * | ||
196 | omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads); | ||
197 | |||
164 | #else | 198 | #else |
165 | 199 | ||
166 | static inline int omap_mux_init_gpio(int gpio, int val) | 200 | static inline int omap_mux_init_gpio(int gpio, int val) |
@@ -172,6 +206,12 @@ static inline int omap_mux_init_signal(char *muxname, int val) | |||
172 | return 0; | 206 | return 0; |
173 | } | 207 | } |
174 | 208 | ||
209 | static inline struct omap_hwmod_mux_info * | ||
210 | omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads) | ||
211 | { | ||
212 | return NULL; | ||
213 | } | ||
214 | |||
175 | static struct omap_board_mux *board_mux __initdata __maybe_unused; | 215 | static struct omap_board_mux *board_mux __initdata __maybe_unused; |
176 | 216 | ||
177 | #endif | 217 | #endif |
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h index b219a88cac2c..6864a997f2ca 100644 --- a/arch/arm/plat-omap/include/plat/omap_hwmod.h +++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h | |||
@@ -81,6 +81,18 @@ extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type2; | |||
81 | #define HWMOD_IDLEMODE_SMART_WKUP (1 << 3) | 81 | #define HWMOD_IDLEMODE_SMART_WKUP (1 << 3) |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * struct omap_hwmod_mux_info - hwmod specific mux configuration | ||
85 | * @pads: array of omap_device_pad entries | ||
86 | * @nr_pads: number of omap_device_pad entries | ||
87 | * | ||
88 | * Note that this is currently built during init as needed. | ||
89 | */ | ||
90 | struct omap_hwmod_mux_info { | ||
91 | int nr_pads; | ||
92 | struct omap_device_pad *pads; | ||
93 | }; | ||
94 | |||
95 | /** | ||
84 | * struct omap_hwmod_irq_info - MPU IRQs used by the hwmod | 96 | * struct omap_hwmod_irq_info - MPU IRQs used by the hwmod |
85 | * @name: name of the IRQ channel (module local name) | 97 | * @name: name of the IRQ channel (module local name) |
86 | * @irq_ch: IRQ channel ID | 98 | * @irq_ch: IRQ channel ID |
@@ -487,6 +499,7 @@ struct omap_hwmod { | |||
487 | const char *name; | 499 | const char *name; |
488 | struct omap_hwmod_class *class; | 500 | struct omap_hwmod_class *class; |
489 | struct omap_device *od; | 501 | struct omap_device *od; |
502 | struct omap_hwmod_mux_info *mux; | ||
490 | struct omap_hwmod_irq_info *mpu_irqs; | 503 | struct omap_hwmod_irq_info *mpu_irqs; |
491 | struct omap_hwmod_dma_info *sdma_reqs; | 504 | struct omap_hwmod_dma_info *sdma_reqs; |
492 | struct omap_hwmod_rst_info *rst_lines; | 505 | struct omap_hwmod_rst_info *rst_lines; |