@@ -21,6 +21,7 @@
#ifdef CONFIG_IRAM_ALLOC
int __init iram_init(unsigned long base, unsigned long size);
+int __init of_iram_init(void);
void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr);
void iram_free(unsigned long dma_addr, unsigned int size);
@@ -31,6 +32,11 @@ static inline int __init iram_init(unsigned long base, unsigned long size)
return -ENOMEM;
}
+static inline int __init of_iram_init(void)
+{
+ return -EINVAL;
+}
+
static inline void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
{
return NULL;
@@ -22,6 +22,8 @@
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/genalloc.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
#include <mach/iram.h>
static unsigned long iram_phys_base;
@@ -71,3 +73,17 @@ int __init iram_init(unsigned long base, unsigned long size)
pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
return 0;
}
+
+int __init of_iram_init(void)
+{
+ struct device_node *np;
+ struct resource res;
+
+ np = of_find_compatible_node(NULL, NULL, "fsl,imx-iram");
+ if (of_address_to_resource(np, 0, &res))
+ return -EINVAL;
+ if (res.start && (res.end > res.start))
+ return iram_init(res.start, res.end - res.start + 1);
+ else
+ return -EINVAL;
+}