diff mbox

[7/8] ARM: OMAP: hwmod: extract module address space from DT blob

Message ID 1361374735-22018-8-git-send-email-santosh.shilimkar@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Santosh Shilimkar Feb. 20, 2013, 3:38 p.m. UTC
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.

Cc: Benoit Cousson <b-cousson@ti.com>

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |   31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

Comments

Felipe Balbi Feb. 20, 2013, 3:42 p.m. UTC | #1
Hi,

On Wed, Feb 20, 2013 at 09:08:54PM +0530, Santosh Shilimkar wrote:
> Patch adds the code for extracting the module ocp address space from device
> tree blob in case the hwmod address space look up fails.

IMHO you should lookup on DT first and if that fails try hwmod ;-)
Santosh Shilimkar Feb. 20, 2013, 3:46 p.m. UTC | #2
On Wednesday 20 February 2013 09:12 PM, Felipe Balbi wrote:
> Hi,
>
> On Wed, Feb 20, 2013 at 09:08:54PM +0530, Santosh Shilimkar wrote:
>> Patch adds the code for extracting the module ocp address space from device
>> tree blob in case the hwmod address space look up fails.
>
> IMHO you should lookup on DT first and if that fails try hwmod ;-)
>
I thought about that one. Since we have more devices rely on hwmod than
DT, I put the code that way. Eventually, we will need only the dt
version.

Regards,
Santosh
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 4653efb..5aad348 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -138,6 +138,7 @@ 
 #include <linux/spinlock.h>
 #include <linux/slab.h>
 #include <linux/bootmem.h>
+#include <linux/of.h>
 
 #include "clock.h"
 #include "omap_hwmod.h"
@@ -2336,6 +2337,11 @@  static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data)
 {
 	struct omap_hwmod_addr_space *mem;
 	void __iomem *va_start;
+	struct device_node *np;
+	const void *reg_prop;
+	const char *p;
+	unsigned long start = 0, size = 0;
+
 
 	if (!oh)
 		return;
@@ -2349,10 +2355,33 @@  static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data)
 	if (!mem) {
 		pr_debug("omap_hwmod: %s: no MPU register target found\n",
 			 oh->name);
+
+		/* Extract the IO space from device tree blob */
+		if (!of_have_populated_dt())
+			return;
+
+		for_each_child_of_node(of_find_node_by_name(NULL, "ocp"), np) {
+			if (of_find_property(np, "ti,hwmods", NULL)) {
+				p = of_get_property(np, "ti,hwmods", NULL);
+				if (!strcmp(p, oh->name)) {
+					reg_prop = of_get_property(np, "reg",
+									NULL);
+					start = of_read_number(reg_prop, 1);
+					size = of_read_number(reg_prop + 4, 1);
+				}
+			}
+		}
+	} else {
+		start = mem->pa_start;
+		size = mem->pa_end - mem->pa_start;
+	}
+
+	if (!start) {
+		pr_debug("omap_hwmod: %s: No address space found\n", oh->name);
 		return;
 	}
 
-	va_start = ioremap(mem->pa_start, mem->pa_end - mem->pa_start);
+	va_start = ioremap(start, size);
 	if (!va_start) {
 		pr_err("omap_hwmod: %s: Could not ioremap\n", oh->name);
 		return;