aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/mux.c
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2010-12-22 21:42:35 -0500
committerTony Lindgren <tony@atomide.com>2010-12-22 21:42:35 -0500
commit9796b323b5a1940f9ec62c3a6cf7e442bf540d53 (patch)
tree8fb2b57e5cbc7cfdfc5a26c4f5daf6f8c884353e /arch/arm/mach-omap2/mux.c
parent8419fdbaf2118a0a169441be82f09f7be93a5ca1 (diff)
omap2+: Add support for hwmod specific muxing of devices
This allows adding hwmod specific pads dynamically during the platform device init. Note that we don't currently have the hwmod specific signals listed in the hwmod data, but struct omap_hwmod_mux_info will make that possible if necessary. Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/mux.c')
-rw-r--r--arch/arm/mach-omap2/mux.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 0fa3d74125b..27eb51a224c 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
257struct omap_hwmod_mux_info * __init
258omap_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
310err3:
311 kfree(hmux->pads);
312err2:
313 kfree(hmux);
314err1:
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