of/address: merge of_iomap()
authorGrant Likely <grant.likely@secretlab.ca>
Tue, 8 Jun 2010 13:48:09 +0000 (07:48 -0600)
committerGrant Likely <grant.likely@secretlab.ca>
Mon, 5 Jul 2010 22:14:26 +0000 (16:14 -0600)
Merge common code between Microblaze and PowerPC.  This patch creates
new of_address.h and address.c files to containing address translation
and mapping routines.  First routine to be moved it of_iomap()

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Michal Simek <monstr@monstr.eu>
CC: Stephen Rothwell <sfr@canb.auug.org.au>
arch/microblaze/include/asm/prom.h
arch/microblaze/kernel/prom_parse.c
arch/powerpc/include/asm/prom.h
arch/powerpc/kernel/prom_parse.c
drivers/of/Kconfig
drivers/of/Makefile
drivers/of/address.c [new file with mode: 0644]
include/linux/of_address.h [new file with mode: 0644]

index 5fbdfe7..6411c3b 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef __ASSEMBLY__
 
 #include <linux/types.h>
+#include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/of_fdt.h>
 #include <linux/proc_fs.h>
@@ -103,15 +104,6 @@ extern const void *of_get_mac_address(struct device_node *np);
 struct pci_dev;
 extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
 
-/**
- * of_iomap - Maps the memory mapped IO for a given device_node
- * @device:    the device whose io range will be mapped
- * @index:     index of the io range
- *
- * Returns a pointer to the mapped memory
- */
-extern void __iomem *of_iomap(struct device_node *device, int index);
-
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL__ */
 #endif /* _ASM_MICROBLAZE_PROM_H */
index e28968f..1159ba5 100644 (file)
@@ -681,14 +681,3 @@ const void *of_get_mac_address(struct device_node *np)
        return NULL;
 }
 EXPORT_SYMBOL(of_get_mac_address);
-
-void __iomem *of_iomap(struct device_node *np, int index)
-{
-       struct resource res;
-
-       if (of_address_to_resource(np, index, &res))
-               return NULL;
-
-       return ioremap(res.start, 1 + res.end - res.start);
-}
-EXPORT_SYMBOL(of_iomap);
index 10d5ee5..0abe379 100644 (file)
@@ -18,6 +18,7 @@
  */
 #include <linux/types.h>
 #include <linux/of_fdt.h>
+#include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/proc_fs.h>
 #include <linux/platform_device.h>
@@ -119,14 +120,5 @@ extern const void *of_get_mac_address(struct device_node *np);
 struct pci_dev;
 extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
 
-/**
- * of_iomap - Maps the memory mapped IO for a given device_node
- * @device:    the device whose io range will be mapped
- * @index:     index of the io range
- *
- * Returns a pointer to the mapped memory
- */
-extern void __iomem *of_iomap(struct device_node *device, int index);
-
 #endif /* __KERNEL__ */
 #endif /* _POWERPC_PROM_H */
index d61a5c5..1d5d4f6 100644 (file)
@@ -715,14 +715,3 @@ const void *of_get_mac_address(struct device_node *np)
        return NULL;
 }
 EXPORT_SYMBOL(of_get_mac_address);
-
-void __iomem *of_iomap(struct device_node *np, int index)
-{
-       struct resource res;
-
-       if (of_address_to_resource(np, index, &res))
-               return NULL;
-
-       return ioremap(res.start, 1 + res.end - res.start);
-}
-EXPORT_SYMBOL(of_iomap);
index b87495e..097f42a 100644 (file)
@@ -6,6 +6,10 @@ config OF_DYNAMIC
        def_bool y
        depends on OF && PPC_OF
 
+config OF_ADDRESS
+       def_bool y
+       depends on OF && !SPARC
+
 config OF_IRQ
        def_bool y
        depends on OF && !SPARC
index 3631a5e..0052c40 100644 (file)
@@ -1,5 +1,6 @@
 obj-y = base.o
 obj-$(CONFIG_OF_FLATTREE) += fdt.o
+obj-$(CONFIG_OF_ADDRESS)  += address.o
 obj-$(CONFIG_OF_IRQ)    += irq.o
 obj-$(CONFIG_OF_DEVICE) += device.o platform.o
 obj-$(CONFIG_OF_GPIO)   += gpio.o
diff --git a/drivers/of/address.c b/drivers/of/address.c
new file mode 100644 (file)
index 0000000..258528d
--- /dev/null
@@ -0,0 +1,22 @@
+
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/of_address.h>
+
+/**
+ * of_iomap - Maps the memory mapped IO for a given device_node
+ * @device:    the device whose io range will be mapped
+ * @index:     index of the io range
+ *
+ * Returns a pointer to the mapped memory
+ */
+void __iomem *of_iomap(struct device_node *np, int index)
+{
+       struct resource res;
+
+       if (of_address_to_resource(np, index, &res))
+               return NULL;
+
+       return ioremap(res.start, 1 + res.end - res.start);
+}
+EXPORT_SYMBOL(of_iomap);
diff --git a/include/linux/of_address.h b/include/linux/of_address.h
new file mode 100644 (file)
index 0000000..570831d
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __OF_ADDRESS_H
+#define __OF_ADDRESS_H
+#include <linux/ioport.h>
+#include <linux/of.h>
+
+extern void __iomem *of_iomap(struct device_node *device, int index);
+
+#endif /* __OF_ADDRESS_H */
+