diff options
author | Christian Krafft <krafft@de.ibm.com> | 2007-04-23 15:35:45 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@klappe.arndb.de> | 2007-04-23 15:44:40 -0400 |
commit | 6bf05fd776e38a0a9c17e17c2345b59b1b9aa2cb (patch) | |
tree | 2f7c2ecec6918614f6f407bec94299d79baf5b47 | |
parent | 4a065f9418274f2d73066f1638b3612341e4f030 (diff) |
[POWERPC] add of_iomap function
The of_iomap function maps memory for a given
device_node and returns a pointer to that memory.
This is used at some places, so it makes sense to
a seperate function.
Signed-off-by: Christian Krafft <krafft@de.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
-rw-r--r-- | arch/powerpc/sysdev/pmi.c | 19 | ||||
-rw-r--r-- | include/asm-powerpc/prom.h | 11 |
2 files changed, 13 insertions, 17 deletions
diff --git a/arch/powerpc/sysdev/pmi.c b/arch/powerpc/sysdev/pmi.c index 05db1f9f82d3..85a7c99c1003 100644 --- a/arch/powerpc/sysdev/pmi.c +++ b/arch/powerpc/sysdev/pmi.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <asm/of_platform.h> | 33 | #include <asm/of_platform.h> |
34 | #include <asm/io.h> | 34 | #include <asm/io.h> |
35 | #include <asm/pmi.h> | 35 | #include <asm/pmi.h> |
36 | 36 | #include <asm/prom.h> | |
37 | 37 | ||
38 | struct pmi_data { | 38 | struct pmi_data { |
39 | struct list_head handler; | 39 | struct list_head handler; |
@@ -49,21 +49,6 @@ struct pmi_data { | |||
49 | }; | 49 | }; |
50 | 50 | ||
51 | 51 | ||
52 | |||
53 | static void __iomem *of_iomap(struct device_node *np) | ||
54 | { | ||
55 | struct resource res; | ||
56 | |||
57 | if (of_address_to_resource(np, 0, &res)) | ||
58 | return NULL; | ||
59 | |||
60 | pr_debug("Resource start: 0x%lx\n", res.start); | ||
61 | pr_debug("Resource end: 0x%lx\n", res.end); | ||
62 | |||
63 | return ioremap(res.start, 1 + res.end - res.start); | ||
64 | } | ||
65 | |||
66 | |||
67 | static int pmi_irq_handler(int irq, void *dev_id) | 52 | static int pmi_irq_handler(int irq, void *dev_id) |
68 | { | 53 | { |
69 | struct pmi_data *data; | 54 | struct pmi_data *data; |
@@ -154,7 +139,7 @@ static int pmi_of_probe(struct of_device *dev, | |||
154 | goto out; | 139 | goto out; |
155 | } | 140 | } |
156 | 141 | ||
157 | data->pmi_reg = of_iomap(np); | 142 | data->pmi_reg = of_iomap(np, 0); |
158 | if (!data->pmi_reg) { | 143 | if (!data->pmi_reg) { |
159 | printk(KERN_ERR "pmi: invalid register address.\n"); | 144 | printk(KERN_ERR "pmi: invalid register address.\n"); |
160 | rc = -EFAULT; | 145 | rc = -EFAULT; |
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h index e73a2b482a15..f31af713e6a4 100644 --- a/include/asm-powerpc/prom.h +++ b/include/asm-powerpc/prom.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <asm/irq.h> | 21 | #include <asm/irq.h> |
22 | #include <asm/atomic.h> | 22 | #include <asm/atomic.h> |
23 | #include <asm/io.h> | ||
23 | 24 | ||
24 | /* Definitions used by the flattened device tree */ | 25 | /* Definitions used by the flattened device tree */ |
25 | #define OF_DT_HEADER 0xd00dfeed /* marker */ | 26 | #define OF_DT_HEADER 0xd00dfeed /* marker */ |
@@ -355,6 +356,16 @@ static inline int of_irq_to_resource(struct device_node *dev, int index, struct | |||
355 | return irq; | 356 | return irq; |
356 | } | 357 | } |
357 | 358 | ||
359 | static inline void __iomem *of_iomap(struct device_node *np, int index) | ||
360 | { | ||
361 | struct resource res; | ||
362 | |||
363 | if (of_address_to_resource(np, index, &res)) | ||
364 | return NULL; | ||
365 | |||
366 | return ioremap(res.start, 1 + res.end - res.start); | ||
367 | } | ||
368 | |||
358 | 369 | ||
359 | #endif /* __KERNEL__ */ | 370 | #endif /* __KERNEL__ */ |
360 | #endif /* _POWERPC_PROM_H */ | 371 | #endif /* _POWERPC_PROM_H */ |