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 <[email protected]>
Acked-by: Benjamin Herrenschmidt <[email protected]>
CC: Michal Simek <[email protected]>
CC: Stephen Rothwell <[email protected]>
This commit is contained in:
Grant Likely 2010-06-08 07:48:09 -06:00
commit 6b884a8d50
8 changed files with 38 additions and 40 deletions

View 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

View 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

22
drivers/of/address.c Normal file
View file

@ -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);