mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration
@ 2011-07-18 12:54 Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 12:54 ` [PATCH 02/10] at91: switch to all resource declaration to "struct resource" Jean-Christophe PLAGNIOL-VILLARD
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-07-18 12:54 UTC (permalink / raw)
  To: barebox

and add multi resource per device support

for now we keep the old map_base and size temporary but will switch all of
the used step by step to them resource way

and mirror the first resource to the map_base and size if available

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
v2:

	update fixup

Best Regards,
J.
 include/driver.h       |    4 ++
 include/linux/ioport.h |  115 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/driver.c           |   19 ++++++++
 3 files changed, 138 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/ioport.h

diff --git a/include/driver.h b/include/driver.h
index 6a4d45e..ed3df16 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -24,6 +24,7 @@
 #define DRIVER_H
 
 #include <linux/list.h>
+#include <linux/ioport.h>
 
 #define MAX_DRIVER_NAME		32
 #define FORMAT_DRIVER_MANE_ID	"%s%d"
@@ -76,6 +77,9 @@ struct device_d {
 	 * Flash or SDRAM. */
 	resource_size_t map_base;
 
+	struct resource *resource;
+	int num_resources;
+
 	void *platform_data; /*! board specific information about this device */
 
 	/*! Devices of a particular class normaly need to store more
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
new file mode 100644
index 0000000..5143115
--- /dev/null
+++ b/include/linux/ioport.h
@@ -0,0 +1,115 @@
+/*
+ * ioport.h	Definitions of routines for detecting, reserving and
+ *		allocating system resources.
+ *
+ * Authors:	Linus Torvalds
+ */
+
+#ifndef _LINUX_IOPORT_H
+#define _LINUX_IOPORT_H
+
+#ifndef __ASSEMBLY__
+#include <linux/compiler.h>
+#include <linux/types.h>
+/*
+ * Resources are tree-like, allowing
+ * nesting etc..
+ */
+struct resource {
+	resource_size_t start;
+	resource_size_t size;
+	const char *name;
+	unsigned long flags;
+};
+
+/*
+ * IO resources have these defined flags.
+ */
+#define IORESOURCE_BITS		0x000000ff	/* Bus-specific bits */
+
+#define IORESOURCE_TYPE_BITS	0x00001f00	/* Resource type */
+#define IORESOURCE_IO		0x00000100
+#define IORESOURCE_MEM		0x00000200
+#define IORESOURCE_IRQ		0x00000400
+#define IORESOURCE_DMA		0x00000800
+#define IORESOURCE_BUS		0x00001000
+
+#define IORESOURCE_PREFETCH	0x00002000	/* No side effects */
+#define IORESOURCE_READONLY	0x00004000
+#define IORESOURCE_CACHEABLE	0x00008000
+#define IORESOURCE_RANGELENGTH	0x00010000
+#define IORESOURCE_SHADOWABLE	0x00020000
+
+#define IORESOURCE_SIZEALIGN	0x00040000	/* size indicates alignment */
+#define IORESOURCE_STARTALIGN	0x00080000	/* start field is alignment */
+
+#define IORESOURCE_MEM_64	0x00100000
+#define IORESOURCE_WINDOW	0x00200000	/* forwarded by bridge */
+#define IORESOURCE_MUXED	0x00400000	/* Resource is software muxed */
+
+#define IORESOURCE_EXCLUSIVE	0x08000000	/* Userland may not map this resource */
+#define IORESOURCE_DISABLED	0x10000000
+#define IORESOURCE_UNSET	0x20000000
+#define IORESOURCE_AUTO		0x40000000
+#define IORESOURCE_BUSY		0x80000000	/* Driver has marked this resource busy */
+
+/* PnP IRQ specific bits (IORESOURCE_BITS) */
+#define IORESOURCE_IRQ_HIGHEDGE		(1<<0)
+#define IORESOURCE_IRQ_LOWEDGE		(1<<1)
+#define IORESOURCE_IRQ_HIGHLEVEL	(1<<2)
+#define IORESOURCE_IRQ_LOWLEVEL		(1<<3)
+#define IORESOURCE_IRQ_SHAREABLE	(1<<4)
+#define IORESOURCE_IRQ_OPTIONAL		(1<<5)
+
+/* PnP DMA specific bits (IORESOURCE_BITS) */
+#define IORESOURCE_DMA_TYPE_MASK	(3<<0)
+#define IORESOURCE_DMA_8BIT		(0<<0)
+#define IORESOURCE_DMA_8AND16BIT	(1<<0)
+#define IORESOURCE_DMA_16BIT		(2<<0)
+
+#define IORESOURCE_DMA_MASTER		(1<<2)
+#define IORESOURCE_DMA_BYTE		(1<<3)
+#define IORESOURCE_DMA_WORD		(1<<4)
+
+#define IORESOURCE_DMA_SPEED_MASK	(3<<6)
+#define IORESOURCE_DMA_COMPATIBLE	(0<<6)
+#define IORESOURCE_DMA_TYPEA		(1<<6)
+#define IORESOURCE_DMA_TYPEB		(2<<6)
+#define IORESOURCE_DMA_TYPEF		(3<<6)
+
+/* PnP memory I/O specific bits (IORESOURCE_BITS) */
+#define IORESOURCE_MEM_WRITEABLE	(1<<0)	/* dup: IORESOURCE_READONLY */
+#define IORESOURCE_MEM_CACHEABLE	(1<<1)	/* dup: IORESOURCE_CACHEABLE */
+#define IORESOURCE_MEM_RANGELENGTH	(1<<2)	/* dup: IORESOURCE_RANGELENGTH */
+#define IORESOURCE_MEM_TYPE_MASK	(3<<3)
+#define IORESOURCE_MEM_8BIT		(0<<3)
+#define IORESOURCE_MEM_16BIT		(1<<3)
+#define IORESOURCE_MEM_8AND16BIT	(2<<3)
+#define IORESOURCE_MEM_32BIT		(3<<3)
+#define IORESOURCE_MEM_SHADOWABLE	(1<<5)	/* dup: IORESOURCE_SHADOWABLE */
+#define IORESOURCE_MEM_EXPANSIONROM	(1<<6)
+
+/* PnP I/O specific bits (IORESOURCE_BITS) */
+#define IORESOURCE_IO_16BIT_ADDR	(1<<0)
+#define IORESOURCE_IO_FIXED		(1<<1)
+
+/* PCI ROM control bits (IORESOURCE_BITS) */
+#define IORESOURCE_ROM_ENABLE		(1<<0)	/* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */
+#define IORESOURCE_ROM_SHADOW		(1<<1)	/* ROM is copy at C000:0 */
+#define IORESOURCE_ROM_COPY		(1<<2)	/* ROM is alloc'd copy, resource field overlaid */
+#define IORESOURCE_ROM_BIOS_COPY	(1<<3)	/* ROM is BIOS copy, resource field overlaid */
+
+/* PCI control bits.  Shares IORESOURCE_BITS with above PCI ROM.  */
+#define IORESOURCE_PCI_FIXED		(1<<4)	/* Do not move resource */
+
+static inline resource_size_t resource_size(const struct resource *res)
+{
+	return res->size;
+}
+static inline unsigned long resource_type(const struct resource *res)
+{
+	return res->flags & IORESOURCE_TYPE_BITS;
+}
+
+#endif /* __ASSEMBLY__ */
+#endif	/* _LINUX_IOPORT_H */
diff --git a/lib/driver.c b/lib/driver.c
index 4c10a49..7b381ab 100644
--- a/lib/driver.c
+++ b/lib/driver.c
@@ -103,6 +103,25 @@ int register_device(struct device_d *new_device)
 {
 	struct driver_d *drv;
 
+	/* if no map_base available use the first resource if available
+	 * so we do not need to duplicate it
+	 * Temporary fixup until we get rid of map_base and size
+	 */
+	if (new_device->map_base) {
+		if (new_device->resource) {
+			dev_err(new_device, "map_base and resource specifed\n");
+			return -EIO;
+		}
+		dev_warn(new_device, "uses map_base. Please convert to use resources\n");
+		new_device->resource = xzalloc(sizeof(struct resource));
+		new_device->resource[0].start = new_device->map_base;
+		new_device->resource[0].size = new_device->size;
+		new_device->num_resources = 1;
+	} else if (new_device->resource) {
+		new_device->map_base = new_device->resource[0].start;
+		new_device->size = new_device->resource[0].size;
+	}
+
 	if (new_device->id < 0) {
 		new_device->id = get_free_deviceid(new_device->name);
 	} else {
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 02/10] at91: switch to all resource declaration to "struct resource"
  2011-07-18 12:54 [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Jean-Christophe PLAGNIOL-VILLARD
@ 2011-07-18 12:54 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 12:54 ` [PATCH 03/10] at91/serial: switch " Jean-Christophe PLAGNIOL-VILLARD
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-07-18 12:54 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/at91rm9200ek/init.c      |    9 ++-
 arch/arm/boards/at91sam9261ek/init.c     |   11 ++-
 arch/arm/boards/at91sam9263ek/init.c     |   11 ++-
 arch/arm/boards/mmccpu/init.c            |   10 ++-
 arch/arm/boards/pm9261/init.c            |   11 ++-
 arch/arm/boards/pm9263/init.c            |   11 ++-
 arch/arm/mach-at91/at91rm9200_devices.c  |   88 ++++++++++++++++++----
 arch/arm/mach-at91/at91sam9260_devices.c |  121 ++++++++++++++++++++++++------
 arch/arm/mach-at91/at91sam9261_devices.c |   77 +++++++++++++++----
 arch/arm/mach-at91/at91sam9263_devices.c |  101 ++++++++++++++++++++-----
 arch/arm/mach-at91/at91sam9g45_devices.c |  110 ++++++++++++++++++++++-----
 11 files changed, 458 insertions(+), 102 deletions(-)

diff --git a/arch/arm/boards/at91rm9200ek/init.c b/arch/arm/boards/at91rm9200ek/init.c
index a449326..b21dc5f 100644
--- a/arch/arm/boards/at91rm9200ek/init.c
+++ b/arch/arm/boards/at91rm9200ek/init.c
@@ -34,10 +34,17 @@
 #include <mach/gpio.h>
 #include <mach/io.h>
 
+static struct resource cfi_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_0,
+	},
+};
+
 static struct device_d cfi_dev = {
 	.id		= 0,
 	.name		= "cfi_flash",
-	.map_base	= AT91_CHIPSELECT_0,
+	.num_resources	= ARRAY_SIZE(cfi_resources),
+	.resource	= cfi_resources,
 };
 
 static struct at91_ether_platform_data ether_pdata = {
diff --git a/arch/arm/boards/at91sam9261ek/init.c b/arch/arm/boards/at91sam9261ek/init.c
index b1388e1..3def38e 100644
--- a/arch/arm/boards/at91sam9261ek/init.c
+++ b/arch/arm/boards/at91sam9261ek/init.c
@@ -95,11 +95,18 @@ static struct dm9000_platform_data dm9000_data = {
 	.srom		= 0,
 };
 
+static struct resource dm9000_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_2,
+		.size	= 8,
+	},
+};
+
 static struct device_d dm9000_dev = {
 	.id		= 0,
 	.name		= "dm9000",
-	.map_base	= AT91_CHIPSELECT_2,
-	.size		= 8,
+	.num_resources	= ARRAY_SIZE(dm9000_resources),
+	.resource	= dm9000_resources,
 	.platform_data	= &dm9000_data,
 };
 
diff --git a/arch/arm/boards/at91sam9263ek/init.c b/arch/arm/boards/at91sam9263ek/init.c
index 9a763b3..fe69305 100644
--- a/arch/arm/boards/at91sam9263ek/init.c
+++ b/arch/arm/boards/at91sam9263ek/init.c
@@ -87,11 +87,18 @@ static void ek_add_device_nand(void)
 	at91_add_device_nand(&nand_pdata);
 }
 
+static struct resource cfi_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_0,
+		.size	= 8 * 1024 * 1024,
+	},
+};
+
 static struct device_d cfi_dev = {
 	.id		= -1,
 	.name		= "cfi_flash",
-	.map_base	= AT91_CHIPSELECT_0,
-	.size		= 8 * 1024 * 1024,
+	.num_resources	= ARRAY_SIZE(cfi_resources),
+	.resource	= cfi_resources,
 };
 
 static struct at91_ether_platform_data macb_pdata = {
diff --git a/arch/arm/boards/mmccpu/init.c b/arch/arm/boards/mmccpu/init.c
index 7cba01c..b79062e 100644
--- a/arch/arm/boards/mmccpu/init.c
+++ b/arch/arm/boards/mmccpu/init.c
@@ -37,11 +37,17 @@
 #include <mach/gpio.h>
 #include <mach/io.h>
 
+static struct resource cfi_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_0,
+	},
+};
+
 static struct device_d cfi_dev = {
 	.id		= -1,
 	.name		= "cfi_flash",
-	.map_base	= AT91_CHIPSELECT_0,
-	.size		= 0,	/* zero means autodetect size */
+	.num_resources	= ARRAY_SIZE(cfi_resources),
+	.resource	= cfi_resources,
 };
 
 static struct at91_ether_platform_data macb_pdata = {
diff --git a/arch/arm/boards/pm9261/init.c b/arch/arm/boards/pm9261/init.c
index 6fb14f7..af92835 100644
--- a/arch/arm/boards/pm9261/init.c
+++ b/arch/arm/boards/pm9261/init.c
@@ -95,11 +95,18 @@ static struct dm9000_platform_data dm9000_data = {
 	.srom		= 1,
 };
 
+static struct resource dm9000_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_2,
+		.size	= 8,
+	},
+};
+
 static struct device_d dm9000_dev = {
 	.id		= 0,
 	.name		= "dm9000",
-	.map_base	= AT91_CHIPSELECT_2,
-	.size		= 8,
+	.num_resources	= ARRAY_SIZE(dm9000_resources),
+	.resource	= dm9000_resources,
 	.platform_data	= &dm9000_data,
 };
 
diff --git a/arch/arm/boards/pm9263/init.c b/arch/arm/boards/pm9263/init.c
index abe8def..6544837 100644
--- a/arch/arm/boards/pm9263/init.c
+++ b/arch/arm/boards/pm9263/init.c
@@ -86,11 +86,18 @@ static void pm_add_device_nand(void)
 	at91_add_device_nand(&nand_pdata);
 }
 
+static struct resource cfi_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_0,
+		.size	= 4 * 1024 * 1024,
+	},
+};
+
 static struct device_d cfi_dev = {
 	.id	  = -1,
 	.name     = "cfi_flash",
-	.map_base = AT91_CHIPSELECT_0,
-	.size     = 4 * 1024 * 1024,
+	.num_resources	= ARRAY_SIZE(cfi_resources),
+	.resource	= cfi_resources,
 };
 
 static struct at91_ether_platform_data macb_pdata = {
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index f45008a..7585b27 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -20,6 +20,12 @@
 
 #include "generic.h"
 
+static struct resource sdram_dev_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_1,
+	},
+};
+
 static struct memory_platform_data ram_pdata = {
 	.name = "ram0",
 	.flags = DEVFS_RDWR,
@@ -28,13 +34,14 @@ static struct memory_platform_data ram_pdata = {
 static struct device_d sdram_dev = {
 	.id = -1,
 	.name = "mem",
-	.map_base = AT91_CHIPSELECT_1,
+	.num_resources	= ARRAY_SIZE(sdram_dev_resources),
+	.resource	= sdram_dev_resources,
 	.platform_data = &ram_pdata,
 };
 
 void at91_add_device_sdram(u32 size)
 {
-	sdram_dev.size = size;
+	sdram_dev_resources[0].size = size;
 	register_device(&sdram_dev);
 	armlinux_add_dram(&sdram_dev);
 }
@@ -44,11 +51,18 @@ void at91_add_device_sdram(u32 size)
  * -------------------------------------------------------------------- */
 
 #if defined(CONFIG_DRIVER_NET_AT91_ETHER)
+static struct resource eth_resources[] = {
+	[0] = {
+		.start	= AT91_VA_BASE_EMAC,
+		.size	= 0x1000,
+	},
+};
+
 static struct device_d at91rm9200_eth_device = {
 	.id		= 0,
 	.name		= "at91_ether",
-	.map_base	= AT91_VA_BASE_EMAC,
-	.size		= 0x1000,
+	.resource	= eth_resources,
+	.num_resources	= ARRAY_SIZE(eth_resources),
 };
 
 void __init at91_add_device_eth(struct at91_ether_platform_data *data)
@@ -91,11 +105,18 @@ void __init at91_add_device_eth(struct at91_ether_platform_data *data) {}
  * -------------------------------------------------------------------- */
 
 #if defined(CONFIG_NAND_ATMEL)
+static struct resource nand_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_3,
+		.size	= 0x10,
+	},
+};
+
 static struct device_d at91rm9200_nand_device = {
 	.id		= -1,
 	.name		= "atmel_nand",
-	.map_base	= AT91_CHIPSELECT_3,
-	.size		= 0x10,
+	.resource	= nand_resources,
+	.num_resources	= ARRAY_SIZE(nand_resources),
 };
 
 void __init at91_add_device_nand(struct atmel_nand_data *data)
@@ -143,11 +164,18 @@ void __init at91_add_device_nand(struct atmel_nand_data *data) {}
  *  UART
  * -------------------------------------------------------------------- */
 
+static struct resource dbgu_resources[] = {
+	[0] = {
+		.start	= AT91_BASE_SYS + AT91_DBGU,
+		.size	= 4096,
+	},
+};
+
 static struct device_d dbgu_serial_device = {
 	.id		= 0,
 	.name		= "atmel_serial",
-	.map_base	= (AT91_BASE_SYS + AT91_DBGU),
-	.size		= 4096,
+	.resource	= dbgu_resources,
+	.num_resources	= ARRAY_SIZE(dbgu_resources),
 };
 
 static inline void configure_dbgu_pins(void)
@@ -156,11 +184,18 @@ static inline void configure_dbgu_pins(void)
 	at91_set_A_periph(AT91_PIN_PA31, 1);		/* DTXD */
 }
 
+static struct resource uart0_resources[] = {
+	[0] = {
+		.start	= AT91RM9200_BASE_US0,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart0_serial_device = {
 	.id		= 1,
 	.name		= "atmel_serial",
-	.map_base	= AT91RM9200_BASE_US0,
-	.size		= 4096,
+	.resource	= uart0_resources,
+	.num_resources	= ARRAY_SIZE(uart0_resources),
 };
 
 static inline void configure_usart0_pins(unsigned pins)
@@ -180,11 +215,18 @@ static inline void configure_usart0_pins(unsigned pins)
 	}
 }
 
+static struct resource uart1_resources[] = {
+	[0] = {
+		.start	= AT91RM9200_BASE_US1,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart1_serial_device = {
 	.id		= 2,
 	.name		= "atmel_serial",
-	.map_base	= AT91RM9200_BASE_US1,
-	.size		= 4096,
+	.resource	= uart1_resources,
+	.num_resources	= ARRAY_SIZE(uart1_resources),
 };
 
 static inline void configure_usart1_pins(unsigned pins)
@@ -206,11 +248,18 @@ static inline void configure_usart1_pins(unsigned pins)
 		at91_set_A_periph(AT91_PIN_PB26, 0);	/* RTS1 */
 }
 
+static struct resource uart2_resources[] = {
+	[0] = {
+		.start	= AT91RM9200_BASE_US2,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart2_serial_device = {
 	.id		= 3,
 	.name		= "atmel_serial",
-	.map_base	= AT91RM9200_BASE_US2,
-	.size		= 4096,
+	.resource	= uart2_resources,
+	.num_resources	= ARRAY_SIZE(uart2_resources),
 };
 
 static inline void configure_usart2_pins(unsigned pins)
@@ -224,11 +273,18 @@ static inline void configure_usart2_pins(unsigned pins)
 		at91_set_B_periph(AT91_PIN_PA31, 0);	/* RTS2 */
 }
 
+static struct resource uart3_resources[] = {
+	[0] = {
+		.start	= AT91RM9200_BASE_US3,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart3_serial_device = {
 	.id		= 4,
 	.name		= "atmel_serial",
-	.map_base	= AT91RM9200_BASE_US3,
-	.size		= 4096,
+	.resource	= uart3_resources,
+	.num_resources	= ARRAY_SIZE(uart3_resources),
 };
 
 static inline void configure_usart3_pins(unsigned pins)
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index d44e280..85f7578 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -21,6 +21,12 @@
 
 #include "generic.h"
 
+static struct resource sdram_dev_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_1,
+	},
+};
+
 static struct memory_platform_data sram_pdata = {
 	.name = "sram0",
 	.flags = DEVFS_RDWR,
@@ -29,23 +35,31 @@ static struct memory_platform_data sram_pdata = {
 static struct device_d sdram_dev = {
 	.id	  = -1,
 	.name     = "mem",
-	.map_base = AT91_CHIPSELECT_1,
+	.num_resources	= ARRAY_SIZE(sdram_dev_resources),
+	.resource	= sdram_dev_resources,
 	.platform_data = &sram_pdata,
 };
 
 void at91_add_device_sdram(u32 size)
 {
-	sdram_dev.size = size;
+	sdram_dev_resources[0].size = size;
 	register_device(&sdram_dev);
 	armlinux_add_dram(&sdram_dev);
 }
 
 #if defined(CONFIG_DRIVER_NET_MACB)
+static struct resource eth_resources[] = {
+	[0] = {
+		.start	= AT91SAM9260_BASE_EMAC,
+		.size	= 0x1000,
+	},
+};
+
 static struct device_d macb_dev = {
 	.id	  = -1,
 	.name     = "macb",
-	.map_base = AT91SAM9260_BASE_EMAC,
-	.size     = 0x1000,
+	.resource	= eth_resources,
+	.num_resources	= ARRAY_SIZE(eth_resources),
 };
 
 void at91_add_device_eth(struct at91_ether_platform_data *data)
@@ -84,11 +98,18 @@ void at91_add_device_eth(struct at91_ether_platform_data *data) {}
 #endif
 
 #if defined(CONFIG_NAND_ATMEL)
+static struct resource nand_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_3,
+		.size	= 0x10,
+	},
+};
+
 static struct device_d nand_dev = {
 	.id	  = -1,
 	.name     = "atmel_nand",
-	.map_base = AT91_CHIPSELECT_3,
-	.size     = 0x10,
+	.resource	= nand_resources,
+	.num_resources	= ARRAY_SIZE(nand_resources),
 };
 
 void at91_add_device_nand(struct atmel_nand_data *data)
@@ -120,11 +141,18 @@ void at91_add_device_nand(struct atmel_nand_data *data)
 void at91_add_device_nand(struct atmel_nand_data *data) {}
 #endif
 
+static struct resource dbgu_resources[] = {
+	[0] = {
+		.start	= AT91_BASE_SYS + AT91_DBGU,
+		.size	= 4096,
+	},
+};
+
 static struct device_d dbgu_serial_device = {
 	.id	  = 0,
 	.name     = "atmel_serial",
-	.map_base = AT91_BASE_SYS + AT91_DBGU,
-	.size     = 4096,
+	.resource	= dbgu_resources,
+	.num_resources	= ARRAY_SIZE(dbgu_resources),
 };
 
 static inline void configure_dbgu_pins(void)
@@ -133,11 +161,18 @@ static inline void configure_dbgu_pins(void)
 	at91_set_A_periph(AT91_PIN_PB15, 1);		/* DTXD */
 }
 
+static struct resource uart0_resources[] = {
+	[0] = {
+		.start	= AT91SAM9260_BASE_US0,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart0_serial_device = {
 	.id	  = 1,
 	.name     = "atmel_serial",
-	.map_base = AT91SAM9260_BASE_US0,
-	.size     = 4096,
+	.resource	= uart0_resources,
+	.num_resources	= ARRAY_SIZE(uart0_resources),
 };
 
 static inline void configure_usart0_pins(unsigned pins)
@@ -159,11 +194,18 @@ static inline void configure_usart0_pins(unsigned pins)
 		at91_set_A_periph(AT91_PIN_PB25, 0);	/* RI0 */
 }
 
+static struct resource uart1_resources[] = {
+	[0] = {
+		.start	= AT91SAM9260_BASE_US1,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart1_serial_device = {
 	.id	  = 2,
 	.name     = "atmel_serial",
-	.map_base = AT91SAM9260_BASE_US1,
-	.size     = 4096,
+	.resource	= uart1_resources,
+	.num_resources	= ARRAY_SIZE(uart1_resources),
 };
 
 static inline void configure_usart1_pins(unsigned pins)
@@ -177,11 +219,18 @@ static inline void configure_usart1_pins(unsigned pins)
 		at91_set_A_periph(AT91_PIN_PB29, 0);	/* CTS1 */
 }
 
+static struct resource uart2_resources[] = {
+	[0] = {
+		.start	= AT91SAM9260_BASE_US2,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart2_serial_device = {
 	.id	  = 3,
 	.name     = "atmel_serial",
-	.map_base = AT91SAM9260_BASE_US2,
-	.size     = 4096,
+	.resource	= uart2_resources,
+	.num_resources	= ARRAY_SIZE(uart2_resources),
 };
 
 static inline void configure_usart2_pins(unsigned pins)
@@ -195,11 +244,18 @@ static inline void configure_usart2_pins(unsigned pins)
 		at91_set_A_periph(AT91_PIN_PA5, 0);	/* CTS2 */
 }
 
+static struct resource uart3_resources[] = {
+	[0] = {
+		.start	= AT91SAM9260_BASE_US3,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart3_serial_device = {
 	.id	  = 4,
 	.name     = "atmel_serial",
-	.map_base = AT91SAM9260_BASE_US3,
-	.size     = 4096,
+	.resource	= uart3_resources,
+	.num_resources	= ARRAY_SIZE(uart3_resources),
 };
 
 static inline void configure_usart3_pins(unsigned pins)
@@ -213,11 +269,18 @@ static inline void configure_usart3_pins(unsigned pins)
 		at91_set_B_periph(AT91_PIN_PC10, 0);	/* CTS3 */
 }
 
+static struct resource uart4_resources[] = {
+	[0] = {
+		.start	= AT91SAM9260_BASE_US4,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart4_serial_device = {
 	.id	  = 5,
 	.name     = "atmel_serial",
-	.map_base = AT91SAM9260_BASE_US4,
-	.size     = 4096,
+	.resource	= uart4_resources,
+	.num_resources	= ARRAY_SIZE(uart4_resources),
 };
 
 static inline void configure_usart4_pins(void)
@@ -226,11 +289,18 @@ static inline void configure_usart4_pins(void)
 	at91_set_B_periph(AT91_PIN_PA30, 0);		/* RXD4 */
 }
 
+static struct resource uart5_resources[] = {
+	[0] = {
+		.start	= AT91SAM9260_BASE_US5,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart5_serial_device = {
 	.id	  = 6,
 	.name     = "atmel_serial",
-	.map_base = AT91SAM9260_BASE_US5,
-	.size     = 4096,
+	.resource	= uart5_resources,
+	.num_resources	= ARRAY_SIZE(uart5_resources),
 };
 
 static inline void configure_usart5_pins(void)
@@ -283,11 +353,18 @@ void at91_register_uart(unsigned id, unsigned pins)
 }
 
 #if defined(CONFIG_MCI_ATMEL)
+static struct resource mci_resources[] = {
+	[0] = {
+		.start	= AT91SAM9260_BASE_MCI,
+		.size	= SZ_16K,
+	},
+};
+
 static struct device_d mci_device = {
 	.id		= -1,
 	.name		= "atmel_mci",
-	.map_base	= AT91SAM9260_BASE_MCI,
-	.size		= SZ_16K,
+	.num_resources	= ARRAY_SIZE(mci_resources),
+	.resource	= mci_resources,
 };
 
 /* Consider only one slot : slot 0 */
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index d8b70a3..bf726bc 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -21,6 +21,12 @@
 
 #include "generic.h"
 
+static struct resource sdram_dev_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_1,
+	},
+};
+
 static struct memory_platform_data ram_pdata = {
 	.name = "ram0",
 	.flags = DEVFS_RDWR,
@@ -29,23 +35,31 @@ static struct memory_platform_data ram_pdata = {
 static struct device_d sdram_dev = {
 	.id		= -1,
 	.name		= "mem",
-	.map_base	= AT91_CHIPSELECT_1,
+	.num_resources	= ARRAY_SIZE(sdram_dev_resources),
+	.resource	= sdram_dev_resources,
 	.platform_data	= &ram_pdata,
 };
 
 void at91_add_device_sdram(u32 size)
 {
-	sdram_dev.size = size;
+	sdram_dev_resources[0].size = size;
 	register_device(&sdram_dev);
 	armlinux_add_dram(&sdram_dev);
 }
 
 #if defined(CONFIG_NAND_ATMEL)
+static struct resource nand_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_3,
+		.size	= 0x10,
+	},
+};
+
 static struct device_d nand_dev = {
 	.id		= 0,
 	.name		= "atmel_nand",
-	.map_base	= AT91_CHIPSELECT_3,
-	.size		= 0x10,
+	.resource	= nand_resources,
+	.num_resources	= ARRAY_SIZE(nand_resources),
 };
 
 void at91_add_device_nand(struct atmel_nand_data *data)
@@ -80,11 +94,18 @@ void at91_add_device_nand(struct atmel_nand_data *data)
 void at91_add_device_nand(struct atmel_nand_data *data) {}
 #endif
 
+static struct resource dbgu_resources[] = {
+	[0] = {
+		.start	= (AT91_BASE_SYS + AT91_DBGU),
+		.size	= 4096,
+	},
+};
+
 static struct device_d dbgu_serial_device = {
 	.id		= 0,
 	.name		= "atmel_serial",
-	.map_base	= (AT91_BASE_SYS + AT91_DBGU),
-	.size		= 4096,
+	.resource	= dbgu_resources,
+	.num_resources	= ARRAY_SIZE(dbgu_resources),
 };
 
 static inline void configure_dbgu_pins(void)
@@ -93,11 +114,18 @@ static inline void configure_dbgu_pins(void)
 	at91_set_A_periph(AT91_PIN_PA10, 1);		/* DTXD */
 }
 
+static struct resource uart0_resources[] = {
+	[0] = {
+		.start	= AT91SAM9261_BASE_US0,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart0_serial_device = {
 	.id		= 1,
 	.name		= "atmel_serial",
-	.map_base	= AT91SAM9261_BASE_US0,
-	.size		= 4096,
+	.resource	= uart0_resources,
+	.num_resources	= ARRAY_SIZE(uart0_resources),
 };
 
 static inline void configure_usart0_pins(unsigned pins)
@@ -111,11 +139,18 @@ static inline void configure_usart0_pins(unsigned pins)
 		at91_set_A_periph(AT91_PIN_PC11, 0);	/* CTS0 */
 }
 
+static struct resource uart1_resources[] = {
+	[0] = {
+		.start	= AT91SAM9261_BASE_US1,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart1_serial_device = {
 	.id		= 2,
 	.name		= "atmel_serial",
-	.map_base	= AT91SAM9261_BASE_US1,
-	.size		= 4096,
+	.resource	= uart1_resources,
+	.num_resources	= ARRAY_SIZE(uart1_resources),
 };
 
 static inline void configure_usart1_pins(unsigned pins)
@@ -129,11 +164,18 @@ static inline void configure_usart1_pins(unsigned pins)
 		at91_set_B_periph(AT91_PIN_PA13, 0);	/* CTS1 */
 }
 
+static struct resource uart2_resources[] = {
+	[0] = {
+		.start	= AT91SAM9261_BASE_US2,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart2_serial_device = {
 	.id		= 3,
 	.name		= "atmel_serial",
-	.map_base	= AT91SAM9261_BASE_US2,
-	.size		= 4096,
+	.resource	= uart2_resources,
+	.num_resources	= ARRAY_SIZE(uart2_resources),
 };
 
 static inline void configure_usart2_pins(unsigned pins)
@@ -176,11 +218,18 @@ void at91_register_uart(unsigned id, unsigned pins)
 }
 
 #if defined(CONFIG_MCI_ATMEL)
+static struct resource mci_resources[] = {
+	[0] = {
+		.start	= AT91SAM9261_BASE_MCI,
+		.size	= SZ_16K,
+	},
+};
+
 static struct device_d mci_device = {
 	.id		= -1,
 	.name		= "atmel_mci",
-	.map_base	= AT91SAM9261_BASE_MCI,
-	.size		= SZ_16K,
+	.num_resources	= ARRAY_SIZE(mci_resources),
+	.resource	= mci_resources,
 };
 
 /* Consider only one slot : slot 0 */
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 04fb79e..9b87425 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -21,6 +21,12 @@
 
 #include "generic.h"
 
+static struct resource sdram_dev_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_1,
+	},
+};
+
 static struct memory_platform_data ram_pdata = {
 	.name = "ram0",
 	.flags = DEVFS_RDWR,
@@ -29,23 +35,31 @@ static struct memory_platform_data ram_pdata = {
 static struct device_d sdram_dev = {
 	.id	  = -1,
 	.name     = "mem",
-	.map_base = AT91_CHIPSELECT_1,
-	.platform_data = &ram_pdata,
+	.num_resources	= ARRAY_SIZE(sdram_dev_resources),
+	.resource	= sdram_dev_resources,
+	.platform_data	= &ram_pdata,
 };
 
 void at91_add_device_sdram(u32 size)
 {
-	sdram_dev.size = size;
+	sdram_dev_resources[0].size = size;
 	register_device(&sdram_dev);
 	armlinux_add_dram(&sdram_dev);
 }
 
 #if defined(CONFIG_DRIVER_NET_MACB)
+static struct resource eth_resources[] = {
+	[0] = {
+		.start	= AT91SAM9263_BASE_EMAC,
+		.size	= 0x1000,
+	},
+};
+
 static struct device_d macb_dev = {
 	.id	  = -1,
 	.name     = "macb",
-	.map_base = AT91SAM9263_BASE_EMAC,
-	.size     = 0x1000,
+	.resource	= eth_resources,
+	.num_resources	= ARRAY_SIZE(eth_resources),
 };
 
 void at91_add_device_eth(struct at91_ether_platform_data *data)
@@ -83,11 +97,18 @@ void at91_add_device_eth(struct at91_ether_platform_data *data) {}
 #endif
 
 #if defined(CONFIG_NAND_ATMEL)
+static struct resource nand_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_3,
+		.size	= 0x10,
+	},
+};
+
 static struct device_d nand_dev = {
 	.id	  = -1,
 	.name     = "atmel_nand",
-	.map_base = AT91_CHIPSELECT_3,
-	.size     = 0x10,
+	.resource	= nand_resources,
+	.num_resources	= ARRAY_SIZE(nand_resources),
 };
 
 void at91_add_device_nand(struct atmel_nand_data *data)
@@ -119,11 +140,18 @@ void at91_add_device_nand(struct atmel_nand_data *data)
 void at91_add_device_nand(struct atmel_nand_data *data) {}
 #endif
 
+static struct resource dbgu_resources[] = {
+	[0] = {
+		.start	= (AT91_BASE_SYS + AT91_DBGU),
+		.size	= 4096,
+	},
+};
+
 static struct device_d dbgu_serial_device = {
 	.id	  = 0,
 	.name     = "atmel_serial",
-	.map_base = (AT91_BASE_SYS + AT91_DBGU),
-	.size     = 4096,
+	.resource	= dbgu_resources,
+	.num_resources	= ARRAY_SIZE(dbgu_resources),
 };
 
 static inline void configure_dbgu_pins(void)
@@ -132,11 +160,18 @@ static inline void configure_dbgu_pins(void)
 	at91_set_A_periph(AT91_PIN_PC31, 1);		/* DTXD */
 }
 
+static struct resource uart0_resources[] = {
+	[0] = {
+		.start	= AT91SAM9263_BASE_US0,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart0_serial_device = {
 	.id	  = 1,
 	.name     = "atmel_serial",
-	.map_base = AT91SAM9263_BASE_US0,
-	.size     = 4096,
+	.resource	= uart0_resources,
+	.num_resources	= ARRAY_SIZE(uart0_resources),
 };
 
 static inline void configure_usart0_pins(unsigned pins)
@@ -150,11 +185,18 @@ static inline void configure_usart0_pins(unsigned pins)
 		at91_set_A_periph(AT91_PIN_PA29, 0);	/* CTS0 */
 }
 
+static struct resource uart1_resources[] = {
+	[0] = {
+		.start	= AT91SAM9263_BASE_US1,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart1_serial_device = {
 	.id	  = 2,
 	.name     = "atmel_serial",
-	.map_base = AT91SAM9263_BASE_US1,
-	.size     = 4096,
+	.resource	= uart1_resources,
+	.num_resources	= ARRAY_SIZE(uart1_resources),
 };
 
 static inline void configure_usart1_pins(unsigned pins)
@@ -168,11 +210,18 @@ static inline void configure_usart1_pins(unsigned pins)
 		at91_set_B_periph(AT91_PIN_PD8, 0);	/* CTS1 */
 }
 
+static struct resource uart2_resources[] = {
+	[0] = {
+		.start	= AT91SAM9263_BASE_US2,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart2_serial_device = {
 	.id	  = 3,
 	.name     = "atmel_serial",
-	.map_base = AT91SAM9263_BASE_US2,
-	.size     = 4096,
+	.resource	= uart2_resources,
+	.num_resources	= ARRAY_SIZE(uart2_resources),
 };
 
 static inline void configure_usart2_pins(unsigned pins)
@@ -216,18 +265,32 @@ void at91_register_uart(unsigned id, unsigned pins)
 }
 
 #if defined(CONFIG_MCI_ATMEL)
+static struct resource mci0_resources[] = {
+	[0] = {
+		.start	= AT91SAM9263_BASE_MCI0,
+		.size	= SZ_16K,
+	},
+};
+
 static struct device_d mci0_device = {
 	.id		= 0,
 	.name		= "atmel_mci",
-	.map_base	= AT91SAM9263_BASE_MCI0,
-	.size		= SZ_16K,
+	.num_resources	= ARRAY_SIZE(mci0_resources),
+	.resource	= mci0_resources,
+};
+
+static struct resource mci1_resources[] = {
+	[0] = {
+		.start	= AT91SAM9263_BASE_MCI1,
+		.size	= SZ_16K,
+	},
 };
 
 static struct device_d mci1_device = {
 	.id		= 1,
 	.name		= "atmel_mci",
-	.map_base	= AT91SAM9263_BASE_MCI1,
-	.size		= SZ_16K,
+	.num_resources	= ARRAY_SIZE(mci1_resources),
+	.resource	= mci1_resources,
 };
 
 /* Consider only one slot : slot 0 */
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index a474bd7..b2e633b 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -21,6 +21,12 @@
 
 #include "generic.h"
 
+static struct resource sdram_dev_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_6,
+	},
+};
+
 static struct memory_platform_data ram_pdata = {
 	.name = "ram0",
 	.flags = DEVFS_RDWR,
@@ -29,23 +35,31 @@ static struct memory_platform_data ram_pdata = {
 static struct device_d sdram_dev = {
 	.id		= -1,
 	.name		= "mem",
-	.map_base	= AT91_CHIPSELECT_6,
+	.num_resources	= ARRAY_SIZE(sdram_dev_resources),
+	.resource	= sdram_dev_resources,
 	.platform_data	= &ram_pdata,
 };
 
 void at91_add_device_sdram(u32 size)
 {
-	sdram_dev.size = size;
+	sdram_dev_resources[0].size = size;
 	register_device(&sdram_dev);
 	armlinux_add_dram(&sdram_dev);
 }
 
 #if defined(CONFIG_DRIVER_NET_MACB)
+static struct resource eth_resources[] = {
+	[0] = {
+		.start	= AT91SAM9G45_BASE_EMAC,
+		.size	= 0x1000,
+	},
+};
+
 static struct device_d macb_dev = {
 	.id		= 0,
 	.name		= "macb",
-	.map_base	= AT91SAM9G45_BASE_EMAC,
-	.size		= 0x1000,
+	.resource	= eth_resources,
+	.num_resources	= ARRAY_SIZE(eth_resources),
 };
 
 void at91_add_device_eth(struct at91_ether_platform_data *data)
@@ -84,11 +98,18 @@ void at91_add_device_eth(struct at91_ether_platform_data *data) {}
 #endif
 
 #if defined(CONFIG_NAND_ATMEL)
+static struct resource nand_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_3,
+		.size	= 0x10,
+	},
+};
+
 static struct device_d nand_dev = {
 	.id		= -1,
 	.name		= "atmel_nand",
-	.map_base	= AT91_CHIPSELECT_3,
-	.size		= 0x10,
+	.resource	= nand_resources,
+	.num_resources	= ARRAY_SIZE(nand_resources),
 };
 
 void at91_add_device_nand(struct atmel_nand_data *data)
@@ -123,11 +144,18 @@ void at91_add_device_nand(struct atmel_nand_data *data)
 void at91_add_device_nand(struct atmel_nand_data *data) {}
 #endif
 
+static struct resource dbgu_resources[] = {
+	[0] = {
+		.start	= (AT91_BASE_SYS + AT91_DBGU),
+		.size	= 4096,
+	},
+};
+
 static struct device_d dbgu_serial_device = {
 	.id	  = -1,
 	.name     = "atmel_serial",
-	.map_base = (AT91_BASE_SYS + AT91_DBGU),
-	.size     = 4096,
+	.resource	= dbgu_resources,
+	.num_resources	= ARRAY_SIZE(dbgu_resources),
 };
 
 static inline void configure_dbgu_pins(void)
@@ -136,11 +164,18 @@ static inline void configure_dbgu_pins(void)
 	at91_set_A_periph(AT91_PIN_PB13, 1);		/* DTXD */
 }
 
+static struct resource uart0_resources[] = {
+	[0] = {
+		.start	= AT91SAM9G45_BASE_US0,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart0_serial_device = {
 	.id	  = -1,
 	.name     = "atmel_serial",
-	.map_base = AT91SAM9G45_BASE_US0,
-	.size     = 4096,
+	.resource	= uart0_resources,
+	.num_resources	= ARRAY_SIZE(uart0_resources),
 };
 
 static inline void configure_usart0_pins(unsigned pins)
@@ -154,11 +189,18 @@ static inline void configure_usart0_pins(unsigned pins)
 		at91_set_B_periph(AT91_PIN_PB15, 0);	/* CTS0 */
 }
 
+static struct resource uart1_resources[] = {
+	[0] = {
+		.start	= AT91SAM9G45_BASE_US1,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart1_serial_device = {
 	.id	  = -1,
 	.name     = "atmel_serial",
-	.map_base = AT91SAM9G45_BASE_US1,
-	.size     = 4096,
+	.resource	= uart1_resources,
+	.num_resources	= ARRAY_SIZE(uart1_resources),
 };
 
 static inline void configure_usart1_pins(unsigned pins)
@@ -172,11 +214,18 @@ static inline void configure_usart1_pins(unsigned pins)
 		at91_set_A_periph(AT91_PIN_PD17, 0);	/* CTS1 */
 }
 
+static struct resource uart2_resources[] = {
+	[0] = {
+		.start	= AT91SAM9G45_BASE_US2,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart2_serial_device = {
 	.id	  = -1,
 	.name     = "atmel_serial",
-	.map_base = AT91SAM9G45_BASE_US2,
-	.size     = 4096,
+	.resource	= uart2_resources,
+	.num_resources	= ARRAY_SIZE(uart2_resources),
 };
 
 static inline void configure_usart2_pins(unsigned pins)
@@ -190,11 +239,18 @@ static inline void configure_usart2_pins(unsigned pins)
 		at91_set_B_periph(AT91_PIN_PC11, 0);	/* CTS2 */
 }
 
+static struct resource uart3_resources[] = {
+	[0] = {
+		.start	= AT91SAM9G45_BASE_US3,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart3_serial_device = {
 	.id	  = -1,
 	.name     = "atmel_serial",
-	.map_base = AT91SAM9G45_ID_US3,
-	.size     = 4096,
+	.resource	= uart3_resources,
+	.num_resources	= ARRAY_SIZE(uart3_resources),
 };
 
 static inline void configure_usart3_pins(unsigned pins)
@@ -243,18 +299,32 @@ void at91_register_uart(unsigned id, unsigned pins)
 }
 
 #if defined(CONFIG_MCI_ATMEL)
+static struct resource mci0_resources[] = {
+	[0] = {
+		.start	= AT91SAM9G45_BASE_MCI0,
+		.size	= SZ_16K,
+	},
+};
+
 static struct device_d mci0_device = {
 	.id		= 0,
 	.name		= "atmel_mci",
-	.map_base	= AT91SAM9G45_BASE_MCI0,
-	.size		= SZ_16K,
+	.num_resources	= ARRAY_SIZE(mci0_resources),
+	.resource	= mci0_resources,
+};
+
+static struct resource mci1_resources[] = {
+	[0] = {
+		.start	= AT91SAM9G45_BASE_MCI1,
+		.size	= SZ_16K,
+	},
 };
 
 static struct device_d mci1_device = {
 	.id		= 1,
 	.name		= "atmel_mci",
-	.map_base	= AT91SAM9G45_BASE_MCI1,
-	.size		= SZ_16K,
+	.num_resources	= ARRAY_SIZE(mci1_resources),
+	.resource	= mci1_resources,
 };
 
 /* Consider only one slot : slot 0 */
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 03/10] at91/serial: switch to "struct resource"
  2011-07-18 12:54 [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 12:54 ` [PATCH 02/10] at91: switch to all resource declaration to "struct resource" Jean-Christophe PLAGNIOL-VILLARD
@ 2011-07-18 12:54 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 12:54 ` [PATCH 04/10] macb: " Jean-Christophe PLAGNIOL-VILLARD
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-07-18 12:54 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/serial/atmel.c |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/serial/atmel.c b/drivers/serial/atmel.c
index 1098952..d8713b3 100644
--- a/drivers/serial/atmel.c
+++ b/drivers/serial/atmel.c
@@ -313,6 +313,7 @@
  * We wrap our port structure around the generic console_device.
  */
 struct atmel_uart_port {
+	void __iomem		*base;
 	struct console_device	uart;		/* uart */
 	struct clk		*clk;		/* uart clock */
 	u32			uartclk;
@@ -326,31 +327,30 @@ to_atmel_uart_port(struct console_device *uart)
 
 static void atmel_serial_putc(struct console_device *cdev, char c)
 {
-	struct device_d *dev = cdev->dev;
+	struct atmel_uart_port *uart = to_atmel_uart_port(cdev);
 
-	while (!(readl(dev->map_base + USART3_CSR) & USART3_BIT(TXRDY)));
+	while (!(readl(uart->base + USART3_CSR) & USART3_BIT(TXRDY)));
 
-	writel(c, dev->map_base + USART3_THR);
+	writel(c, uart->base + USART3_THR);
 }
 
 static int atmel_serial_tstc(struct console_device *cdev)
 {
-	struct device_d *dev = cdev->dev;
+	struct atmel_uart_port *uart = to_atmel_uart_port(cdev);
 
-	return (readl(dev->map_base + USART3_CSR) & USART3_BIT(RXRDY)) != 0;
+	return (readl(uart->base + USART3_CSR) & USART3_BIT(RXRDY)) != 0;
 }
 
 static int atmel_serial_getc(struct console_device *cdev)
 {
-	struct device_d *dev = cdev->dev;
+	struct atmel_uart_port *uart = to_atmel_uart_port(cdev);
 
-	while (!(readl(dev->map_base + USART3_CSR) & USART3_BIT(RXRDY))) ;
-	return readl(dev->map_base + USART3_RHR);
+	while (!(readl(uart->base + USART3_CSR) & USART3_BIT(RXRDY))) ;
+	return readl(uart->base + USART3_RHR);
 }
 
 static int atmel_serial_setbaudrate(struct console_device *cdev, int baudrate)
 {
-	struct device_d *dev = cdev->dev;
 	struct atmel_uart_port *uart = to_atmel_uart_port(cdev);
 	unsigned long divisor;
 
@@ -360,7 +360,7 @@ static int atmel_serial_setbaudrate(struct console_device *cdev, int baudrate)
 	 *                16 * CD
 	 */
 	divisor = (uart->uartclk / 16 + baudrate / 2) / baudrate;
-	writel(USART3_BF(CD, divisor), dev->map_base + USART3_BRGR);
+	writel(USART3_BF(CD, divisor), uart->base + USART3_BRGR);
 
 	return 0;
 }
@@ -375,20 +375,21 @@ static int atmel_serial_init_port(struct console_device *cdev)
 	struct device_d *dev = cdev->dev;
 	struct atmel_uart_port *uart = to_atmel_uart_port(cdev);
 
+	uart->base = (void __iomem *)dev->resource[0].start;
 	uart->clk = clk_get(dev, "usart");
 	clk_enable(uart->clk);
 	uart->uartclk = clk_get_rate(uart->clk);
 
-	writel(USART3_BIT(RSTRX) | USART3_BIT(RSTTX), dev->map_base + USART3_CR);
+	writel(USART3_BIT(RSTRX) | USART3_BIT(RSTTX), uart->base + USART3_CR);
 
 	atmel_serial_setbaudrate(cdev, 115200);
 
-	writel(USART3_BIT(RXEN) | USART3_BIT(TXEN), dev->map_base + USART3_CR);
+	writel(USART3_BIT(RXEN) | USART3_BIT(TXEN), uart->base + USART3_CR);
 	writel((USART3_BF(USART_MODE, USART3_USART_MODE_NORMAL)
 			   | USART3_BF(USCLKS, USART3_USCLKS_MCK)
 			   | USART3_BF(CHRL, USART3_CHRL_8)
 			   | USART3_BF(PAR, USART3_PAR_NONE)
-			   | USART3_BF(NBSTOP, USART3_NBSTOP_1)), dev->map_base + USART3_MR);
+			   | USART3_BF(NBSTOP, USART3_NBSTOP_1)), uart->base + USART3_MR);
 
 	return 0;
 }
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 04/10] macb: switch to "struct resource"
  2011-07-18 12:54 [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 12:54 ` [PATCH 02/10] at91: switch to all resource declaration to "struct resource" Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 12:54 ` [PATCH 03/10] at91/serial: switch " Jean-Christophe PLAGNIOL-VILLARD
@ 2011-07-18 12:54 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 12:54 ` [PATCH 05/10] atmel_mci: " Jean-Christophe PLAGNIOL-VILLARD
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-07-18 12:54 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/net/macb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index bc6618b..e030154 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -85,7 +85,7 @@ struct macb_dma_desc {
 #define TXBUF_USED		0x80000000
 
 struct macb_device {
-	void			*regs;
+	void			__iomem *regs;
 
 	unsigned int		rx_tail;
 	unsigned int		tx_tail;
@@ -446,7 +446,7 @@ static int macb_probe(struct device_d *dev)
 	macb->rx_ring = xmalloc(CFG_MACB_RX_RING_SIZE * sizeof(struct macb_dma_desc));
 	macb->tx_ring = xmalloc(sizeof(struct macb_dma_desc));
 
-	macb->regs = (void *)dev->map_base;
+	macb->regs = (void __iomem *)dev->resource[0].start;
 
 	/*
 	 * Do some basic initialization so that we at least can talk
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 05/10] atmel_mci: switch to "struct resource"
  2011-07-18 12:54 [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Jean-Christophe PLAGNIOL-VILLARD
                   ` (2 preceding siblings ...)
  2011-07-18 12:54 ` [PATCH 04/10] macb: " Jean-Christophe PLAGNIOL-VILLARD
@ 2011-07-18 12:54 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 12:54 ` [PATCH 06/10] atmel_nand: " Jean-Christophe PLAGNIOL-VILLARD
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-07-18 12:54 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/mci/atmel_mci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mci/atmel_mci.c b/drivers/mci/atmel_mci.c
index d8bcf81..70041ba 100644
--- a/drivers/mci/atmel_mci.c
+++ b/drivers/mci/atmel_mci.c
@@ -456,7 +456,7 @@ static int mci_probe(struct device_d *hw_dev)
 	if (pd->bus_width == 8)
 		host->mci.host_caps |= MMC_MODE_8BIT;
 
-	host->base = (void __iomem *)hw_dev->map_base;
+	host->base = (void __iomem *)hw_dev->resource[0].start;
 	host->hw_dev = hw_dev;
 	hw_dev->priv = host;
 	host->clk = clk_get(hw_dev, "mci_clk");
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 06/10] atmel_nand: switch to "struct resource"
  2011-07-18 12:54 [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Jean-Christophe PLAGNIOL-VILLARD
                   ` (3 preceding siblings ...)
  2011-07-18 12:54 ` [PATCH 05/10] atmel_mci: " Jean-Christophe PLAGNIOL-VILLARD
@ 2011-07-18 12:54 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 12:54 ` [PATCH 07/10 v2] dm9200: use "struct resource" instead of platform_data Jean-Christophe PLAGNIOL-VILLARD
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-07-18 12:54 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/mtd/nand/atmel_nand.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index e8f85fc..937bb70 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -381,7 +381,7 @@ static int __init atmel_nand_probe(struct device_d *dev)
 	if (!host)
 		return -ENOMEM;
 
-	host->io_base = (void __iomem *)dev->map_base;
+	host->io_base = (void __iomem *)dev->resource[0].start;
 
 	mtd = &host->mtd;
 	nand_chip = &host->nand_chip;
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 07/10 v2] dm9200: use "struct resource" instead of platform_data
  2011-07-18 12:54 [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Jean-Christophe PLAGNIOL-VILLARD
                   ` (4 preceding siblings ...)
  2011-07-18 12:54 ` [PATCH 06/10] atmel_nand: " Jean-Christophe PLAGNIOL-VILLARD
@ 2011-07-18 12:54 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 12:54 ` [PATCH 08/10] nomadik: switch to all resource declaration to "struct resource" Jean-Christophe PLAGNIOL-VILLARD
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-07-18 12:54 UTC (permalink / raw)
  To: barebox

drop iobase and iodata in favor of resources

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/at91sam9261ek/init.c |    8 +++++---
 arch/arm/boards/mini2440/mini2440.c  |   17 +++++++++++++----
 arch/arm/boards/pm9261/init.c        |    8 +++++---
 arch/arm/boards/scb9328/scb9328.c    |   23 ++++++++++++++++-------
 drivers/net/dm9000.c                 |   10 ++++++++--
 include/dm9000.h                     |    2 --
 6 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/arch/arm/boards/at91sam9261ek/init.c b/arch/arm/boards/at91sam9261ek/init.c
index 3def38e..4e52ab8 100644
--- a/arch/arm/boards/at91sam9261ek/init.c
+++ b/arch/arm/boards/at91sam9261ek/init.c
@@ -89,8 +89,6 @@ static void ek_add_device_nand(void)
  */
 #if defined(CONFIG_DRIVER_NET_DM9000)
 static struct dm9000_platform_data dm9000_data = {
-	.iobase		= AT91_CHIPSELECT_2,
-	.iodata		= AT91_CHIPSELECT_2 + 4,
 	.buswidth	= DM9000_WIDTH_16,
 	.srom		= 0,
 };
@@ -98,7 +96,11 @@ static struct dm9000_platform_data dm9000_data = {
 static struct resource dm9000_resources[] = {
 	[0] = {
 		.start	= AT91_CHIPSELECT_2,
-		.size	= 8,
+		.size	= 4,
+	},
+	[1] = {
+		.start	= AT91_CHIPSELECT_2 + 4,
+		.size	= 4,
 	},
 };
 
diff --git a/arch/arm/boards/mini2440/mini2440.c b/arch/arm/boards/mini2440/mini2440.c
index dcc7c3f..b487082 100644
--- a/arch/arm/boards/mini2440/mini2440.c
+++ b/arch/arm/boards/mini2440/mini2440.c
@@ -75,16 +75,25 @@ static struct device_d nand_dev = {
  * Area 2: Offset 0x304...0x307
  */
 static struct dm9000_platform_data dm9000_data = {
-	.iobase   = CS4_BASE + 0x300,
-	.iodata   = CS4_BASE + 0x304,
 	.buswidth = DM9000_WIDTH_16,
 	.srom     = 1,
 };
 
+static struct resource dm9000_resources[] = {
+	[0] = {
+		.start	= CS4_BASE + 0x300,
+		.size	= 4,
+	},
+	[1] = {
+		.start	= CS4_BASE + 0x304,
+		.size	= 4,
+	},
+};
+
 static struct device_d dm9000_dev = {
 	.name     = "dm9000",
-	.map_base = CS4_BASE + 0x300,
-	.size     = 8,
+	.num_resources	= ARRAY_SIZE(dm9000_resources),
+	.resource	= dm9000_resources,
 	.platform_data = &dm9000_data,
 };
 
diff --git a/arch/arm/boards/pm9261/init.c b/arch/arm/boards/pm9261/init.c
index af92835..4811c73 100644
--- a/arch/arm/boards/pm9261/init.c
+++ b/arch/arm/boards/pm9261/init.c
@@ -89,8 +89,6 @@ static void pm_add_device_nand(void)
  */
 #if defined(CONFIG_DRIVER_NET_DM9000)
 static struct dm9000_platform_data dm9000_data = {
-	.iobase		= AT91_CHIPSELECT_2,
-	.iodata		= AT91_CHIPSELECT_2 + 4,
 	.buswidth	= DM9000_WIDTH_16,
 	.srom		= 1,
 };
@@ -98,7 +96,11 @@ static struct dm9000_platform_data dm9000_data = {
 static struct resource dm9000_resources[] = {
 	[0] = {
 		.start	= AT91_CHIPSELECT_2,
-		.size	= 8,
+		.size	= 4,
+	},
+	[1] = {
+		.start	= AT91_CHIPSELECT_2 + 4,
+		.size	= 4,
 	},
 };
 
diff --git a/arch/arm/boards/scb9328/scb9328.c b/arch/arm/boards/scb9328/scb9328.c
index a98d9fe..69d0589 100644
--- a/arch/arm/boards/scb9328/scb9328.c
+++ b/arch/arm/boards/scb9328/scb9328.c
@@ -55,18 +55,27 @@ static struct device_d sdram_dev = {
 };
 
 static struct dm9000_platform_data dm9000_data = {
-	.iobase   = 0x16000000,
-	.iodata   = 0x16000004,
 	.buswidth = DM9000_WIDTH_16,
 	.srom     = 1,
 };
 
+static struct resource dm9000_resources[] = {
+	[0] = {
+		.start	= 0x16000000,
+		.size	= 4,
+	},
+	[1] = {
+		.start	= 0x16000004,
+		.size	= 4,
+	},
+};
+
 static struct device_d dm9000_dev = {
-	.id	  = -1,
-	.name     = "dm9000",
-	.map_base = 0x16000000,
-	.size     = 8,
-	.platform_data = &dm9000_data,
+	.id		= -1,
+	.name		= "dm9000",
+	.num_resources	= ARRAY_SIZE(dm9000_resources),
+	.resource	= dm9000_resources,
+	.platform_data	= &dm9000_data,
 };
 
 struct gpio_led leds[] = {
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index c8d8517..708801d 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -491,12 +491,18 @@ static int dm9000_probe(struct device_d *dev)
 		printf("dm9000: no platform_data\n");
 		return -ENODEV;
 	}
+
+	if (dev->num_resources < 2) {
+		printf("dm9000: need 2 resources base and data");
+		return -ENODEV;
+	}
+
 	pdata = dev->platform_data;
 
 	priv = edev->priv;
 	priv->buswidth = pdata->buswidth;
-	priv->iodata = (void *)pdata->iodata;
-	priv->iobase = (void *)pdata->iobase;
+	priv->iodata = (void __iomem *)dev->resource[1].start;
+	priv->iobase = (void __iomem *)dev->resource[0].start;
 	priv->srom = pdata->srom;
 
 	edev->init = dm9000_init_dev;
diff --git a/include/dm9000.h b/include/dm9000.h
index b4a04b1..0991ab5 100644
--- a/include/dm9000.h
+++ b/include/dm9000.h
@@ -7,8 +7,6 @@
 #define DM9000_WIDTH_32		3
 
 struct dm9000_platform_data {
-	unsigned long iobase;
-	unsigned long iodata;
 	int buswidth;
 	int srom;
 };
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 08/10] nomadik: switch to all resource declaration to "struct resource"
  2011-07-18 12:54 [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Jean-Christophe PLAGNIOL-VILLARD
                   ` (5 preceding siblings ...)
  2011-07-18 12:54 ` [PATCH 07/10 v2] dm9200: use "struct resource" instead of platform_data Jean-Christophe PLAGNIOL-VILLARD
@ 2011-07-18 12:54 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 12:54 ` [PATCH 09/10] nomadik_nand: use "struct resource" instead of platform_data Jean-Christophe PLAGNIOL-VILLARD
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-07-18 12:54 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/nhk8815/setup.c |   11 +++++++++--
 arch/arm/mach-nomadik/8815.c    |   33 +++++++++++++++++++++++++++------
 2 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/arch/arm/boards/nhk8815/setup.c b/arch/arm/boards/nhk8815/setup.c
index 9cb0fd0..3d08516 100644
--- a/arch/arm/boards/nhk8815/setup.c
+++ b/arch/arm/boards/nhk8815/setup.c
@@ -33,11 +33,18 @@
 #include <mach/nand.h>
 #include <mach/fsmc.h>
 
+static struct resource nhk8815_network_resources[] = {
+	[0] = {
+		.start	= 0x34000300,
+		.size	= 16,
+	},
+};
+
 static struct device_d nhk8815_network_dev = {
 	.id = -1,
 	.name = "smc91c111",
-	.map_base = 0x34000300,
-	.size = 16,
+	.num_resources	= ARRAY_SIZE(nhk8815_network_resources),
+	.resource	= nhk8815_network_resources,
 };
 
 static int nhk8815_nand_init(void)
diff --git a/arch/arm/mach-nomadik/8815.c b/arch/arm/mach-nomadik/8815.c
index 5844c68..3969193 100644
--- a/arch/arm/mach-nomadik/8815.c
+++ b/arch/arm/mach-nomadik/8815.c
@@ -36,32 +36,53 @@ static struct memory_platform_data ram_pdata = {
 	.flags = DEVFS_RDWR,
 };
 
+static struct resource sdram_dev_resources[] = {
+	[0] = {
+		.start	= 0x00000000,
+	},
+};
+
 static struct device_d sdram_dev = {
 	.id = -1,
 	.name = "mem",
-	.map_base = 0x00000000,
+	.num_resources	= ARRAY_SIZE(sdram_dev_resources),
+	.resource	= sdram_dev_resources,
 	.platform_data = &ram_pdata,
 };
 
 void st8815_add_device_sdram(u32 size)
 {
-	sdram_dev.size = size;
+	sdram_dev_resources[0].size = size;
 	register_device(&sdram_dev);
 	armlinux_add_dram(&sdram_dev);
 }
 
+static struct resource uart0_serial_resources[] = {
+	[0] = {
+		.start	= NOMADIK_UART0_BASE,
+		.size	= 4096,
+	},
+};
+
 static struct device_d uart0_serial_device = {
 	.id = 0,
 	.name = "uart-pl011",
-	.map_base = NOMADIK_UART0_BASE,
-	.size = 4096,
+	.num_resources	= ARRAY_SIZE(uart0_serial_resources),
+	.resource	= uart0_serial_resources,
+};
+
+static struct resource uart1_serial_resources[] = {
+	[0] = {
+		.start	= NOMADIK_UART1_BASE,
+		.size	= 4096,
+	},
 };
 
 static struct device_d uart1_serial_device = {
 	.id = 1,
 	.name = "uart-pl011",
-	.map_base = NOMADIK_UART1_BASE,
-	.size = 4096,
+	.num_resources	= ARRAY_SIZE(uart1_serial_resources),
+	.resource	= uart1_serial_resources,
 };
 
 void st8815_register_uart(unsigned id)
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 09/10] nomadik_nand: use "struct resource" instead of platform_data
  2011-07-18 12:54 [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Jean-Christophe PLAGNIOL-VILLARD
                   ` (6 preceding siblings ...)
  2011-07-18 12:54 ` [PATCH 08/10] nomadik: switch to all resource declaration to "struct resource" Jean-Christophe PLAGNIOL-VILLARD
@ 2011-07-18 12:54 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 12:54 ` [PATCH 10/10] amba-pl011: switch to "struct resource" Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 20:48 ` [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Sascha Hauer
  9 siblings, 0 replies; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-07-18 12:54 UTC (permalink / raw)
  To: barebox

drop data_va, cmd_va and addr_va in favor of resources

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/nhk8815/setup.c           |   18 +++++++++++++++---
 arch/arm/mach-nomadik/include/mach/nand.h |    3 ---
 drivers/mtd/nand/nomadik_nand.c           |    8 ++++----
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/arch/arm/boards/nhk8815/setup.c b/arch/arm/boards/nhk8815/setup.c
index 3d08516..3b67e44 100644
--- a/arch/arm/boards/nhk8815/setup.c
+++ b/arch/arm/boards/nhk8815/setup.c
@@ -61,17 +61,29 @@ static int nhk8815_nand_init(void)
 }
 
 static struct nomadik_nand_platform_data nhk8815_nand_data = {
-	.addr_va	= NAND_IO_ADDR,
-	.cmd_va		= NAND_IO_CMD,
-	.data_va	= NAND_IO_DATA,
 	.options	= NAND_COPYBACK | NAND_CACHEPRG | NAND_NO_PADDING \
 			| NAND_NO_READRDY | NAND_NO_AUTOINCR,
 	.init		= nhk8815_nand_init,
 };
 
+static struct resource nhk8815_nand_resources[] = {
+	{
+		.start	= NAND_IO_ADDR,
+		.size	= 0xfff,
+	}, {
+		.start	= NAND_IO_CMD,
+		.size	= 0xfff,
+	}, {
+		.start	= NAND_IO_DATA,
+		.size	= 0xfff,
+	}
+};
+
 static struct device_d nhk8815_nand_device = {
 	.id		= -1,
 	.name		= "nomadik_nand",
+	.num_resources	= ARRAY_SIZE(nhk8815_nand_resources),
+	.resource	= nhk8815_nand_resources,
 	.platform_data	= &nhk8815_nand_data,
 };
 
diff --git a/arch/arm/mach-nomadik/include/mach/nand.h b/arch/arm/mach-nomadik/include/mach/nand.h
index 265fe53..544f0e0 100644
--- a/arch/arm/mach-nomadik/include/mach/nand.h
+++ b/arch/arm/mach-nomadik/include/mach/nand.h
@@ -2,9 +2,6 @@
 #define __ASM_ARCH_NAND_H
 
 struct nomadik_nand_platform_data {
-	unsigned long data_va;
-	unsigned long cmd_va;
-	unsigned long addr_va;
 	int options;
 	int (*init) (void);
 };
diff --git a/drivers/mtd/nand/nomadik_nand.c b/drivers/mtd/nand/nomadik_nand.c
index 673fd88..058170f 100644
--- a/drivers/mtd/nand/nomadik_nand.c
+++ b/drivers/mtd/nand/nomadik_nand.c
@@ -189,8 +189,8 @@ static int nomadik_nand_probe(struct device_d *dev)
 		goto err;
 	}
 
-	host->cmd_va = (void __iomem*)pdata->cmd_va;
-	host->addr_va = (void __iomem*)pdata->addr_va;
+	host->cmd_va = (void __iomem*)dev->resource[1].start;
+	host->addr_va = (void __iomem*)dev->resource[0].start;
 
 	/* Link all private pointers */
 	mtd = &host->mtd;
@@ -198,8 +198,8 @@ static int nomadik_nand_probe(struct device_d *dev)
 	mtd->priv = nand;
 	nand->priv = host;
 
-	nand->IO_ADDR_R = (void __iomem*)pdata->data_va;
-	nand->IO_ADDR_W = (void __iomem*)pdata->data_va;
+	nand->IO_ADDR_R = (void __iomem *)dev->resource[2].start;
+	nand->IO_ADDR_W = (void __iomem *)dev->resource[2].start;
 	nand->cmd_ctrl = nomadik_cmd_ctrl;
 
 	nand->ecc.mode = NAND_ECC_HW;
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 10/10] amba-pl011: switch to "struct resource"
  2011-07-18 12:54 [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Jean-Christophe PLAGNIOL-VILLARD
                   ` (7 preceding siblings ...)
  2011-07-18 12:54 ` [PATCH 09/10] nomadik_nand: use "struct resource" instead of platform_data Jean-Christophe PLAGNIOL-VILLARD
@ 2011-07-18 12:54 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-07-18 20:48 ` [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Sascha Hauer
  9 siblings, 0 replies; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-07-18 12:54 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/serial/amba-pl011.c |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 442dbc4..c83983d 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -40,6 +40,7 @@
  * We wrap our port structure around the generic console_device.
  */
 struct amba_uart_port {
+	void __iomem		*base;
 	struct console_device	uart;		/* uart */
 	struct clk		*clk;		/* uart clock */
 	u32			uartclk;
@@ -53,7 +54,6 @@ to_amba_uart_port(struct console_device *uart)
 
 static int pl011_setbaudrate(struct console_device *cdev, int baudrate)
 {
-	struct device_d *dev = cdev->dev;
 	struct amba_uart_port *uart = to_amba_uart_port(cdev);
 	unsigned int temp;
 	unsigned int divider;
@@ -72,37 +72,37 @@ static int pl011_setbaudrate(struct console_device *cdev, int baudrate)
 	temp = (8 * remainder) / baudrate;
 	fraction = (temp >> 1) + (temp & 1);
 
-	writel(divider, dev->map_base + UART011_IBRD);
-	writel(fraction, dev->map_base + UART011_FBRD);
+	writel(divider, uart->base + UART011_IBRD);
+	writel(fraction, uart->base + UART011_FBRD);
 
 	return 0;
 }
 
 static void pl011_putc(struct console_device *cdev, char c)
 {
-	struct device_d *dev = cdev->dev;
+	struct amba_uart_port *uart = to_amba_uart_port(cdev);
 
 	/* Wait until there is space in the FIFO */
-	while (readl(dev->map_base + UART01x_FR) & UART01x_FR_TXFF);
+	while (readl(uart->base + UART01x_FR) & UART01x_FR_TXFF);
 
 	/* Send the character */
-	writel(c, dev->map_base + UART01x_DR);
+	writel(c, uart->base + UART01x_DR);
 }
 
 static int pl011_getc(struct console_device *cdev)
 {
-	struct device_d *dev = cdev->dev;
+	struct amba_uart_port *uart = to_amba_uart_port(cdev);
 	unsigned int data;
 
 	/* Wait until there is data in the FIFO */
-	while (readl(dev->map_base + UART01x_FR) & UART01x_FR_RXFE);
+	while (readl(uart->base + UART01x_FR) & UART01x_FR_RXFE);
 
-	data = readl(dev->map_base + UART01x_DR);
+	data = readl(uart->base + UART01x_DR);
 
 	/* Check for an error flag */
 	if (data & 0xffffff00) {
 		/* Clear the error */
-		writel(0xffffffff, dev->map_base + UART01x_ECR);
+		writel(0xffffffff, uart->base + UART01x_ECR);
 		return -1;
 	}
 
@@ -111,9 +111,9 @@ static int pl011_getc(struct console_device *cdev)
 
 static int pl011_tstc(struct console_device *cdev)
 {
-	struct device_d *dev = cdev->dev;
+	struct amba_uart_port *uart = to_amba_uart_port(cdev);
 
-	return !(readl(dev->map_base + UART01x_FR) & UART01x_FR_RXFE);
+	return !(readl(uart->base + UART01x_FR) & UART01x_FR_RXFE);
 }
 
 int pl011_init_port (struct console_device *cdev)
@@ -121,10 +121,12 @@ int pl011_init_port (struct console_device *cdev)
 	struct device_d *dev = cdev->dev;
 	struct amba_uart_port *uart = to_amba_uart_port(cdev);
 
+	uart->base = (void __iomem *)dev->resource[0].start;
+
 	/*
 	 ** First, disable everything.
 	 */
-	writel(0x0, dev->map_base + UART011_CR);
+	writel(0x0, uart->base + UART011_CR);
 
 	/*
 	 * Try to enable the clock producer.
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration
  2011-07-18 12:54 [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Jean-Christophe PLAGNIOL-VILLARD
                   ` (8 preceding siblings ...)
  2011-07-18 12:54 ` [PATCH 10/10] amba-pl011: switch to "struct resource" Jean-Christophe PLAGNIOL-VILLARD
@ 2011-07-18 20:48 ` Sascha Hauer
  9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2011-07-18 20:48 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Mon, Jul 18, 2011 at 02:54:29PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> and add multi resource per device support
> 
> for now we keep the old map_base and size temporary but will switch all of
> the used step by step to them resource way
> 
> and mirror the first resource to the map_base and size if available
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Let's give it a go. I applied these for next. I gave it a test on a i.MX
board and it seems to work. I already created some patches converting
several i.MX drivers to struct resource usage. Will post them tomorrow.

Sascha


> ---
> v2:
> 
> 	update fixup
> 
> Best Regards,
> J.
>  include/driver.h       |    4 ++
>  include/linux/ioport.h |  115 ++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/driver.c           |   19 ++++++++
>  3 files changed, 138 insertions(+), 0 deletions(-)
>  create mode 100644 include/linux/ioport.h
> 
> diff --git a/include/driver.h b/include/driver.h
> index 6a4d45e..ed3df16 100644
> --- a/include/driver.h
> +++ b/include/driver.h
> @@ -24,6 +24,7 @@
>  #define DRIVER_H
>  
>  #include <linux/list.h>
> +#include <linux/ioport.h>
>  
>  #define MAX_DRIVER_NAME		32
>  #define FORMAT_DRIVER_MANE_ID	"%s%d"
> @@ -76,6 +77,9 @@ struct device_d {
>  	 * Flash or SDRAM. */
>  	resource_size_t map_base;
>  
> +	struct resource *resource;
> +	int num_resources;
> +
>  	void *platform_data; /*! board specific information about this device */
>  
>  	/*! Devices of a particular class normaly need to store more
> diff --git a/include/linux/ioport.h b/include/linux/ioport.h
> new file mode 100644
> index 0000000..5143115
> --- /dev/null
> +++ b/include/linux/ioport.h
> @@ -0,0 +1,115 @@
> +/*
> + * ioport.h	Definitions of routines for detecting, reserving and
> + *		allocating system resources.
> + *
> + * Authors:	Linus Torvalds
> + */
> +
> +#ifndef _LINUX_IOPORT_H
> +#define _LINUX_IOPORT_H
> +
> +#ifndef __ASSEMBLY__
> +#include <linux/compiler.h>
> +#include <linux/types.h>
> +/*
> + * Resources are tree-like, allowing
> + * nesting etc..
> + */
> +struct resource {
> +	resource_size_t start;
> +	resource_size_t size;
> +	const char *name;
> +	unsigned long flags;
> +};
> +
> +/*
> + * IO resources have these defined flags.
> + */
> +#define IORESOURCE_BITS		0x000000ff	/* Bus-specific bits */
> +
> +#define IORESOURCE_TYPE_BITS	0x00001f00	/* Resource type */
> +#define IORESOURCE_IO		0x00000100
> +#define IORESOURCE_MEM		0x00000200
> +#define IORESOURCE_IRQ		0x00000400
> +#define IORESOURCE_DMA		0x00000800
> +#define IORESOURCE_BUS		0x00001000
> +
> +#define IORESOURCE_PREFETCH	0x00002000	/* No side effects */
> +#define IORESOURCE_READONLY	0x00004000
> +#define IORESOURCE_CACHEABLE	0x00008000
> +#define IORESOURCE_RANGELENGTH	0x00010000
> +#define IORESOURCE_SHADOWABLE	0x00020000
> +
> +#define IORESOURCE_SIZEALIGN	0x00040000	/* size indicates alignment */
> +#define IORESOURCE_STARTALIGN	0x00080000	/* start field is alignment */
> +
> +#define IORESOURCE_MEM_64	0x00100000
> +#define IORESOURCE_WINDOW	0x00200000	/* forwarded by bridge */
> +#define IORESOURCE_MUXED	0x00400000	/* Resource is software muxed */
> +
> +#define IORESOURCE_EXCLUSIVE	0x08000000	/* Userland may not map this resource */
> +#define IORESOURCE_DISABLED	0x10000000
> +#define IORESOURCE_UNSET	0x20000000
> +#define IORESOURCE_AUTO		0x40000000
> +#define IORESOURCE_BUSY		0x80000000	/* Driver has marked this resource busy */
> +
> +/* PnP IRQ specific bits (IORESOURCE_BITS) */
> +#define IORESOURCE_IRQ_HIGHEDGE		(1<<0)
> +#define IORESOURCE_IRQ_LOWEDGE		(1<<1)
> +#define IORESOURCE_IRQ_HIGHLEVEL	(1<<2)
> +#define IORESOURCE_IRQ_LOWLEVEL		(1<<3)
> +#define IORESOURCE_IRQ_SHAREABLE	(1<<4)
> +#define IORESOURCE_IRQ_OPTIONAL		(1<<5)
> +
> +/* PnP DMA specific bits (IORESOURCE_BITS) */
> +#define IORESOURCE_DMA_TYPE_MASK	(3<<0)
> +#define IORESOURCE_DMA_8BIT		(0<<0)
> +#define IORESOURCE_DMA_8AND16BIT	(1<<0)
> +#define IORESOURCE_DMA_16BIT		(2<<0)
> +
> +#define IORESOURCE_DMA_MASTER		(1<<2)
> +#define IORESOURCE_DMA_BYTE		(1<<3)
> +#define IORESOURCE_DMA_WORD		(1<<4)
> +
> +#define IORESOURCE_DMA_SPEED_MASK	(3<<6)
> +#define IORESOURCE_DMA_COMPATIBLE	(0<<6)
> +#define IORESOURCE_DMA_TYPEA		(1<<6)
> +#define IORESOURCE_DMA_TYPEB		(2<<6)
> +#define IORESOURCE_DMA_TYPEF		(3<<6)
> +
> +/* PnP memory I/O specific bits (IORESOURCE_BITS) */
> +#define IORESOURCE_MEM_WRITEABLE	(1<<0)	/* dup: IORESOURCE_READONLY */
> +#define IORESOURCE_MEM_CACHEABLE	(1<<1)	/* dup: IORESOURCE_CACHEABLE */
> +#define IORESOURCE_MEM_RANGELENGTH	(1<<2)	/* dup: IORESOURCE_RANGELENGTH */
> +#define IORESOURCE_MEM_TYPE_MASK	(3<<3)
> +#define IORESOURCE_MEM_8BIT		(0<<3)
> +#define IORESOURCE_MEM_16BIT		(1<<3)
> +#define IORESOURCE_MEM_8AND16BIT	(2<<3)
> +#define IORESOURCE_MEM_32BIT		(3<<3)
> +#define IORESOURCE_MEM_SHADOWABLE	(1<<5)	/* dup: IORESOURCE_SHADOWABLE */
> +#define IORESOURCE_MEM_EXPANSIONROM	(1<<6)
> +
> +/* PnP I/O specific bits (IORESOURCE_BITS) */
> +#define IORESOURCE_IO_16BIT_ADDR	(1<<0)
> +#define IORESOURCE_IO_FIXED		(1<<1)
> +
> +/* PCI ROM control bits (IORESOURCE_BITS) */
> +#define IORESOURCE_ROM_ENABLE		(1<<0)	/* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */
> +#define IORESOURCE_ROM_SHADOW		(1<<1)	/* ROM is copy at C000:0 */
> +#define IORESOURCE_ROM_COPY		(1<<2)	/* ROM is alloc'd copy, resource field overlaid */
> +#define IORESOURCE_ROM_BIOS_COPY	(1<<3)	/* ROM is BIOS copy, resource field overlaid */
> +
> +/* PCI control bits.  Shares IORESOURCE_BITS with above PCI ROM.  */
> +#define IORESOURCE_PCI_FIXED		(1<<4)	/* Do not move resource */
> +
> +static inline resource_size_t resource_size(const struct resource *res)
> +{
> +	return res->size;
> +}
> +static inline unsigned long resource_type(const struct resource *res)
> +{
> +	return res->flags & IORESOURCE_TYPE_BITS;
> +}
> +
> +#endif /* __ASSEMBLY__ */
> +#endif	/* _LINUX_IOPORT_H */
> diff --git a/lib/driver.c b/lib/driver.c
> index 4c10a49..7b381ab 100644
> --- a/lib/driver.c
> +++ b/lib/driver.c
> @@ -103,6 +103,25 @@ int register_device(struct device_d *new_device)
>  {
>  	struct driver_d *drv;
>  
> +	/* if no map_base available use the first resource if available
> +	 * so we do not need to duplicate it
> +	 * Temporary fixup until we get rid of map_base and size
> +	 */
> +	if (new_device->map_base) {
> +		if (new_device->resource) {
> +			dev_err(new_device, "map_base and resource specifed\n");
> +			return -EIO;
> +		}
> +		dev_warn(new_device, "uses map_base. Please convert to use resources\n");
> +		new_device->resource = xzalloc(sizeof(struct resource));
> +		new_device->resource[0].start = new_device->map_base;
> +		new_device->resource[0].size = new_device->size;
> +		new_device->num_resources = 1;
> +	} else if (new_device->resource) {
> +		new_device->map_base = new_device->resource[0].start;
> +		new_device->size = new_device->resource[0].size;
> +	}
> +
>  	if (new_device->id < 0) {
>  		new_device->id = get_free_deviceid(new_device->name);
>  	} else {
> -- 
> 1.7.5.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-07-18 20:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-18 12:54 [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Jean-Christophe PLAGNIOL-VILLARD
2011-07-18 12:54 ` [PATCH 02/10] at91: switch to all resource declaration to "struct resource" Jean-Christophe PLAGNIOL-VILLARD
2011-07-18 12:54 ` [PATCH 03/10] at91/serial: switch " Jean-Christophe PLAGNIOL-VILLARD
2011-07-18 12:54 ` [PATCH 04/10] macb: " Jean-Christophe PLAGNIOL-VILLARD
2011-07-18 12:54 ` [PATCH 05/10] atmel_mci: " Jean-Christophe PLAGNIOL-VILLARD
2011-07-18 12:54 ` [PATCH 06/10] atmel_nand: " Jean-Christophe PLAGNIOL-VILLARD
2011-07-18 12:54 ` [PATCH 07/10 v2] dm9200: use "struct resource" instead of platform_data Jean-Christophe PLAGNIOL-VILLARD
2011-07-18 12:54 ` [PATCH 08/10] nomadik: switch to all resource declaration to "struct resource" Jean-Christophe PLAGNIOL-VILLARD
2011-07-18 12:54 ` [PATCH 09/10] nomadik_nand: use "struct resource" instead of platform_data Jean-Christophe PLAGNIOL-VILLARD
2011-07-18 12:54 ` [PATCH 10/10] amba-pl011: switch to "struct resource" Jean-Christophe PLAGNIOL-VILLARD
2011-07-18 20:48 ` [PATCH 01/10 v2] device: introduce resource structure to simplify resource declaration Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox