diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-06-08 09:48:09 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-07-05 18:14:26 -0400 |
commit | 6b884a8d50a6eea2fb3dad7befe748f67193073b (patch) | |
tree | 85756fbd09ebaebdeb9a7ab56806bcbc5e793532 | |
parent | a7c194b007ec40a130207e9ace9cecf598fc6ac5 (diff) |
of/address: merge of_iomap()
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>
-rw-r--r-- | arch/microblaze/include/asm/prom.h | 10 | ||||
-rw-r--r-- | arch/microblaze/kernel/prom_parse.c | 11 | ||||
-rw-r--r-- | arch/powerpc/include/asm/prom.h | 10 | ||||
-rw-r--r-- | arch/powerpc/kernel/prom_parse.c | 11 | ||||
-rw-r--r-- | drivers/of/Kconfig | 4 | ||||
-rw-r--r-- | drivers/of/Makefile | 1 | ||||
-rw-r--r-- | drivers/of/address.c | 22 | ||||
-rw-r--r-- | include/linux/of_address.h | 9 |
8 files changed, 38 insertions, 40 deletions
diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h index 5fbdfe76fe76..6411c3b3a80f 100644 --- a/arch/microblaze/include/asm/prom.h +++ b/arch/microblaze/include/asm/prom.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #ifndef __ASSEMBLY__ | 20 | #ifndef __ASSEMBLY__ |
21 | 21 | ||
22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
23 | #include <linux/of_address.h> | ||
23 | #include <linux/of_irq.h> | 24 | #include <linux/of_irq.h> |
24 | #include <linux/of_fdt.h> | 25 | #include <linux/of_fdt.h> |
25 | #include <linux/proc_fs.h> | 26 | #include <linux/proc_fs.h> |
@@ -103,15 +104,6 @@ extern const void *of_get_mac_address(struct device_node *np); | |||
103 | struct pci_dev; | 104 | struct pci_dev; |
104 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); | 105 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); |
105 | 106 | ||
106 | /** | ||
107 | * of_iomap - Maps the memory mapped IO for a given device_node | ||
108 | * @device: the device whose io range will be mapped | ||
109 | * @index: index of the io range | ||
110 | * | ||
111 | * Returns a pointer to the mapped memory | ||
112 | */ | ||
113 | extern void __iomem *of_iomap(struct device_node *device, int index); | ||
114 | |||
115 | #endif /* __ASSEMBLY__ */ | 107 | #endif /* __ASSEMBLY__ */ |
116 | #endif /* __KERNEL__ */ | 108 | #endif /* __KERNEL__ */ |
117 | #endif /* _ASM_MICROBLAZE_PROM_H */ | 109 | #endif /* _ASM_MICROBLAZE_PROM_H */ |
diff --git a/arch/microblaze/kernel/prom_parse.c b/arch/microblaze/kernel/prom_parse.c index e28968fa34c1..1159ba52ad4a 100644 --- a/arch/microblaze/kernel/prom_parse.c +++ b/arch/microblaze/kernel/prom_parse.c | |||
@@ -681,14 +681,3 @@ const void *of_get_mac_address(struct device_node *np) | |||
681 | return NULL; | 681 | return NULL; |
682 | } | 682 | } |
683 | EXPORT_SYMBOL(of_get_mac_address); | 683 | EXPORT_SYMBOL(of_get_mac_address); |
684 | |||
685 | void __iomem *of_iomap(struct device_node *np, int index) | ||
686 | { | ||
687 | struct resource res; | ||
688 | |||
689 | if (of_address_to_resource(np, index, &res)) | ||
690 | return NULL; | ||
691 | |||
692 | return ioremap(res.start, 1 + res.end - res.start); | ||
693 | } | ||
694 | EXPORT_SYMBOL(of_iomap); | ||
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h index 10d5ee556702..0abe379c6f33 100644 --- a/arch/powerpc/include/asm/prom.h +++ b/arch/powerpc/include/asm/prom.h | |||
@@ -18,6 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
20 | #include <linux/of_fdt.h> | 20 | #include <linux/of_fdt.h> |
21 | #include <linux/of_address.h> | ||
21 | #include <linux/of_irq.h> | 22 | #include <linux/of_irq.h> |
22 | #include <linux/proc_fs.h> | 23 | #include <linux/proc_fs.h> |
23 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
@@ -119,14 +120,5 @@ extern const void *of_get_mac_address(struct device_node *np); | |||
119 | struct pci_dev; | 120 | struct pci_dev; |
120 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); | 121 | extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); |
121 | 122 | ||
122 | /** | ||
123 | * of_iomap - Maps the memory mapped IO for a given device_node | ||
124 | * @device: the device whose io range will be mapped | ||
125 | * @index: index of the io range | ||
126 | * | ||
127 | * Returns a pointer to the mapped memory | ||
128 | */ | ||
129 | extern void __iomem *of_iomap(struct device_node *device, int index); | ||
130 | |||
131 | #endif /* __KERNEL__ */ | 123 | #endif /* __KERNEL__ */ |
132 | #endif /* _POWERPC_PROM_H */ | 124 | #endif /* _POWERPC_PROM_H */ |
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c index d61a5c5fe690..1d5d4f6dfef5 100644 --- a/arch/powerpc/kernel/prom_parse.c +++ b/arch/powerpc/kernel/prom_parse.c | |||
@@ -715,14 +715,3 @@ const void *of_get_mac_address(struct device_node *np) | |||
715 | return NULL; | 715 | return NULL; |
716 | } | 716 | } |
717 | EXPORT_SYMBOL(of_get_mac_address); | 717 | EXPORT_SYMBOL(of_get_mac_address); |
718 | |||
719 | void __iomem *of_iomap(struct device_node *np, int index) | ||
720 | { | ||
721 | struct resource res; | ||
722 | |||
723 | if (of_address_to_resource(np, index, &res)) | ||
724 | return NULL; | ||
725 | |||
726 | return ioremap(res.start, 1 + res.end - res.start); | ||
727 | } | ||
728 | EXPORT_SYMBOL(of_iomap); | ||
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index b87495efa16e..097f42aebe90 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig | |||
@@ -6,6 +6,10 @@ config OF_DYNAMIC | |||
6 | def_bool y | 6 | def_bool y |
7 | depends on OF && PPC_OF | 7 | depends on OF && PPC_OF |
8 | 8 | ||
9 | config OF_ADDRESS | ||
10 | def_bool y | ||
11 | depends on OF && !SPARC | ||
12 | |||
9 | config OF_IRQ | 13 | config OF_IRQ |
10 | def_bool y | 14 | def_bool y |
11 | depends on OF && !SPARC | 15 | depends on OF && !SPARC |
diff --git a/drivers/of/Makefile b/drivers/of/Makefile index 3631a5ea0b47..0052c405463a 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile | |||
@@ -1,5 +1,6 @@ | |||
1 | obj-y = base.o | 1 | obj-y = base.o |
2 | obj-$(CONFIG_OF_FLATTREE) += fdt.o | 2 | obj-$(CONFIG_OF_FLATTREE) += fdt.o |
3 | obj-$(CONFIG_OF_ADDRESS) += address.o | ||
3 | obj-$(CONFIG_OF_IRQ) += irq.o | 4 | obj-$(CONFIG_OF_IRQ) += irq.o |
4 | obj-$(CONFIG_OF_DEVICE) += device.o platform.o | 5 | obj-$(CONFIG_OF_DEVICE) += device.o platform.o |
5 | obj-$(CONFIG_OF_GPIO) += gpio.o | 6 | obj-$(CONFIG_OF_GPIO) += gpio.o |
diff --git a/drivers/of/address.c b/drivers/of/address.c new file mode 100644 index 000000000000..258528d6c4fe --- /dev/null +++ b/drivers/of/address.c | |||
@@ -0,0 +1,22 @@ | |||
1 | |||
2 | #include <linux/io.h> | ||
3 | #include <linux/ioport.h> | ||
4 | #include <linux/of_address.h> | ||
5 | |||
6 | /** | ||
7 | * of_iomap - Maps the memory mapped IO for a given device_node | ||
8 | * @device: the device whose io range will be mapped | ||
9 | * @index: index of the io range | ||
10 | * | ||
11 | * Returns a pointer to the mapped memory | ||
12 | */ | ||
13 | void __iomem *of_iomap(struct device_node *np, int index) | ||
14 | { | ||
15 | struct resource res; | ||
16 | |||
17 | if (of_address_to_resource(np, index, &res)) | ||
18 | return NULL; | ||
19 | |||
20 | return ioremap(res.start, 1 + res.end - res.start); | ||
21 | } | ||
22 | EXPORT_SYMBOL(of_iomap); | ||
diff --git a/include/linux/of_address.h b/include/linux/of_address.h new file mode 100644 index 000000000000..570831d7e795 --- /dev/null +++ b/include/linux/of_address.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef __OF_ADDRESS_H | ||
2 | #define __OF_ADDRESS_H | ||
3 | #include <linux/ioport.h> | ||
4 | #include <linux/of.h> | ||
5 | |||
6 | extern void __iomem *of_iomap(struct device_node *device, int index); | ||
7 | |||
8 | #endif /* __OF_ADDRESS_H */ | ||
9 | |||