aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/omap_hwmod.c
diff options
context:
space:
mode:
authorSantosh Shilimkar <santosh.shilimkar@ti.com>2013-01-21 08:10:57 -0500
committerBenoit Cousson <benoit.cousson@linaro.org>2013-04-08 18:21:21 -0400
commit079abade857e7ba7877a84536fbf5da5fa665d70 (patch)
tree897b9af9f1b143738f9605b80da4284198bcc938 /arch/arm/mach-omap2/omap_hwmod.c
parent55452197ce43a8de500507e88eeae2f0c3520649 (diff)
ARM: OMAP2+: hwmod: extract module address space from DT blob
Patch adds the code for extracting the module ocp address space from device tree blob in case the hwmod address space look up fails. The idea is to remove the address space data from hwmod and extract it from DT blob. Signed-off-by: Rajendra Nayak <rnayak@ti.com> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Signed-off-by: Benoit Cousson <benoit.cousson@linaro.org>
Diffstat (limited to 'arch/arm/mach-omap2/omap_hwmod.c')
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index e5cafed8ef25..ff729706c5a1 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -138,6 +138,8 @@
138#include <linux/spinlock.h> 138#include <linux/spinlock.h>
139#include <linux/slab.h> 139#include <linux/slab.h>
140#include <linux/bootmem.h> 140#include <linux/bootmem.h>
141#include <linux/of.h>
142#include <linux/of_address.h>
141 143
142#include <asm/system_misc.h> 144#include <asm/system_misc.h>
143 145
@@ -2346,6 +2348,34 @@ static int _shutdown(struct omap_hwmod *oh)
2346} 2348}
2347 2349
2348/** 2350/**
2351 * of_dev_hwmod_lookup - look up needed hwmod from dt blob
2352 * @np: struct device_node *
2353 * @oh: struct omap_hwmod *
2354 *
2355 * Parse the dt blob and find out needed hwmod. Recursive function is
2356 * implemented to take care hierarchical dt blob parsing.
2357 * Return: The device node on success or NULL on failure.
2358 */
2359static struct device_node *of_dev_hwmod_lookup(struct device_node *np,
2360 struct omap_hwmod *oh)
2361{
2362 struct device_node *np0 = NULL, *np1 = NULL;
2363 const char *p;
2364
2365 for_each_child_of_node(np, np0) {
2366 if (of_find_property(np0, "ti,hwmods", NULL)) {
2367 p = of_get_property(np0, "ti,hwmods", NULL);
2368 if (!strcmp(p, oh->name))
2369 return np0;
2370 np1 = of_dev_hwmod_lookup(np0, oh);
2371 if (np1)
2372 return np1;
2373 }
2374 }
2375 return NULL;
2376}
2377
2378/**
2349 * _init_mpu_rt_base - populate the virtual address for a hwmod 2379 * _init_mpu_rt_base - populate the virtual address for a hwmod
2350 * @oh: struct omap_hwmod * to locate the virtual address 2380 * @oh: struct omap_hwmod * to locate the virtual address
2351 * 2381 *
@@ -2357,7 +2387,8 @@ static int _shutdown(struct omap_hwmod *oh)
2357static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data) 2387static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data)
2358{ 2388{
2359 struct omap_hwmod_addr_space *mem; 2389 struct omap_hwmod_addr_space *mem;
2360 void __iomem *va_start; 2390 void __iomem *va_start = NULL;
2391 struct device_node *np;
2361 2392
2362 if (!oh) 2393 if (!oh)
2363 return; 2394 return;
@@ -2371,10 +2402,18 @@ static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data)
2371 if (!mem) { 2402 if (!mem) {
2372 pr_debug("omap_hwmod: %s: no MPU register target found\n", 2403 pr_debug("omap_hwmod: %s: no MPU register target found\n",
2373 oh->name); 2404 oh->name);
2374 return; 2405
2406 /* Extract the IO space from device tree blob */
2407 if (!of_have_populated_dt())
2408 return;
2409
2410 np = of_dev_hwmod_lookup(of_find_node_by_name(NULL, "ocp"), oh);
2411 if (np)
2412 va_start = of_iomap(np, 0);
2413 } else {
2414 va_start = ioremap(mem->pa_start, mem->pa_end - mem->pa_start);
2375 } 2415 }
2376 2416
2377 va_start = ioremap(mem->pa_start, mem->pa_end - mem->pa_start);
2378 if (!va_start) { 2417 if (!va_start) {
2379 pr_err("omap_hwmod: %s: Could not ioremap\n", oh->name); 2418 pr_err("omap_hwmod: %s: Could not ioremap\n", oh->name);
2380 return; 2419 return;