Commit ca2a7861 authored by Ben Dooks's avatar Ben Dooks Committed by Russell King

[ARM PATCH] 2147/1: S3C2410 - reorganise board support

Patch from Ben Dooks

this patch makes the following changes:

 - renames struct s3c2410_board to s3c24xx_board
 - moves board registration into cpu.c

Signed-off-by: Ben Dooks 
parent 37987151
...@@ -112,6 +112,17 @@ s3c_lookup_cpu(unsigned long idcode) ...@@ -112,6 +112,17 @@ s3c_lookup_cpu(unsigned long idcode)
return NULL; return NULL;
} }
/* board information */
static struct s3c24xx_board *board;
void s3c24xx_set_board(struct s3c24xx_board *b)
{
board = b;
}
/* cpu information */
static struct cpu_table *cpu; static struct cpu_table *cpu;
void __init s3c24xx_init_io(struct map_desc *mach_desc, int size) void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
...@@ -141,12 +152,29 @@ void __init s3c24xx_init_io(struct map_desc *mach_desc, int size) ...@@ -141,12 +152,29 @@ void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
static int __init s3c_arch_init(void) static int __init s3c_arch_init(void)
{ {
int ret;
// do the correct init for cpu // do the correct init for cpu
if (cpu == NULL) if (cpu == NULL)
panic("s3c_arch_init: NULL cpu\n"); panic("s3c_arch_init: NULL cpu\n");
return (cpu->init)(); ret = (cpu->init)();
if (ret != 0)
return ret;
if (board != NULL) {
ret = platform_add_devices(board->devices, board->devices_count);
if (ret) {
printk(KERN_ERR "s3c24xx: failed to add board devices (%d)\n", ret);
}
/* mask any error, we may not need all these board
* devices */
ret = 0;
}
return ret;
} }
arch_initcall(s3c_arch_init); arch_initcall(s3c_arch_init);
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
* *
* Modifications: * Modifications:
* 24-Aug-2004 BJD Start of generic S3C24XX support * 24-Aug-2004 BJD Start of generic S3C24XX support
* 18-Oct-2004 BJD Moved board struct into this file
*/ */
#define IODESC_ENT(x) { S3C2410_VA_##x, S3C2410_PA_##x, S3C2410_SZ_##x, MT_DEVICE } #define IODESC_ENT(x) { S3C2410_VA_##x, S3C2410_PA_##x, S3C2410_SZ_##x, MT_DEVICE }
...@@ -38,3 +39,18 @@ extern void s3c2440_map_io(struct map_desc *mach_desc, int size); ...@@ -38,3 +39,18 @@ extern void s3c2440_map_io(struct map_desc *mach_desc, int size);
#endif #endif
extern void s3c24xx_init_io(struct map_desc *mach_desc, int size); extern void s3c24xx_init_io(struct map_desc *mach_desc, int size);
/* the board structure is used at first initialsation time
* to get info such as the devices to register for this
* board. This is done because platfrom_add_devices() cannot
* be called from the map_io entry.
*/
struct s3c24xx_board {
struct platform_device **devices;
unsigned int devices_count;
};
extern void s3c24xx_set_board(struct s3c24xx_board *board);
...@@ -207,7 +207,7 @@ static struct platform_device *bast_devices[] __initdata = { ...@@ -207,7 +207,7 @@ static struct platform_device *bast_devices[] __initdata = {
&bast_device_nor &bast_device_nor
}; };
static struct s3c2410_board bast_board __initdata = { static struct s3c24xx_board bast_board __initdata = {
.devices = bast_devices, .devices = bast_devices,
.devices_count = ARRAY_SIZE(bast_devices) .devices_count = ARRAY_SIZE(bast_devices)
}; };
...@@ -216,7 +216,7 @@ void __init bast_map_io(void) ...@@ -216,7 +216,7 @@ void __init bast_map_io(void)
{ {
s3c24xx_init_io(bast_iodesc, ARRAY_SIZE(bast_iodesc)); s3c24xx_init_io(bast_iodesc, ARRAY_SIZE(bast_iodesc));
s3c2410_init_uarts(bast_uartcfgs, ARRAY_SIZE(bast_uartcfgs)); s3c2410_init_uarts(bast_uartcfgs, ARRAY_SIZE(bast_uartcfgs));
s3c2410_set_board(&bast_board); s3c24xx_set_board(&bast_board);
usb_simtec_init(); usb_simtec_init();
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
* 17-Feb-2003 BJD Copied to mach-ipaq.c * 17-Feb-2003 BJD Copied to mach-ipaq.c
* 21-Aug-2004 BJD Added struct s3c2410_board * 21-Aug-2004 BJD Added struct s3c2410_board
* 04-Sep-2004 BJD Changed uart init, renamed ipaq_ -> h1940_ * 04-Sep-2004 BJD Changed uart init, renamed ipaq_ -> h1940_
* 18-Oct-2004 BJD Updated new board structure name
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -92,7 +93,7 @@ static struct platform_device *h1940_devices[] __initdata = { ...@@ -92,7 +93,7 @@ static struct platform_device *h1940_devices[] __initdata = {
&s3c_device_iis, &s3c_device_iis,
}; };
static struct s3c2410_board h1940_board __initdata = { static struct s3c24xx_board h1940_board __initdata = {
.devices = h1940_devices, .devices = h1940_devices,
.devices_count = ARRAY_SIZE(h1940_devices) .devices_count = ARRAY_SIZE(h1940_devices)
}; };
...@@ -101,7 +102,7 @@ void __init h1940_map_io(void) ...@@ -101,7 +102,7 @@ void __init h1940_map_io(void)
{ {
s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc)); s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
s3c2410_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs)); s3c2410_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
s3c2410_set_board(&h1940_board); s3c24xx_set_board(&h1940_board);
} }
void __init h1940_init_irq(void) void __init h1940_init_irq(void)
......
...@@ -96,7 +96,7 @@ static struct platform_device *smdk2410_devices[] __initdata = { ...@@ -96,7 +96,7 @@ static struct platform_device *smdk2410_devices[] __initdata = {
&s3c_device_iis, &s3c_device_iis,
}; };
static struct s3c2410_board smdk2410_board __initdata = { static struct s3c24xx_board smdk2410_board __initdata = {
.devices = smdk2410_devices, .devices = smdk2410_devices,
.devices_count = ARRAY_SIZE(smdk2410_devices) .devices_count = ARRAY_SIZE(smdk2410_devices)
}; };
...@@ -105,7 +105,7 @@ void __init smdk2410_map_io(void) ...@@ -105,7 +105,7 @@ void __init smdk2410_map_io(void)
{ {
s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc)); s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
s3c2410_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs)); s3c2410_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
s3c2410_set_board(&smdk2410_board); s3c24xx_set_board(&smdk2410_board);
} }
void __init smdk2410_init_irq(void) void __init smdk2410_init_irq(void)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
* 21-Aug-2004 BJD Added struct s3c2410_board * 21-Aug-2004 BJD Added struct s3c2410_board
* 06-Aug-2004 BJD Fixed call to time initialisation * 06-Aug-2004 BJD Fixed call to time initialisation
* 05-Apr-2004 BJD Copied to make mach-vr1000.c * 05-Apr-2004 BJD Copied to make mach-vr1000.c
* 18-Oct-2004 BJD Updated board struct
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -151,7 +152,7 @@ static struct platform_device *vr1000_devices[] __initdata = { ...@@ -151,7 +152,7 @@ static struct platform_device *vr1000_devices[] __initdata = {
&s3c_device_iis, &s3c_device_iis,
}; };
static struct s3c2410_board vr1000_board __initdata = { static struct s3c24xx_board vr1000_board __initdata = {
.devices = vr1000_devices, .devices = vr1000_devices,
.devices_count = ARRAY_SIZE(vr1000_devices) .devices_count = ARRAY_SIZE(vr1000_devices)
}; };
...@@ -161,7 +162,7 @@ void __init vr1000_map_io(void) ...@@ -161,7 +162,7 @@ void __init vr1000_map_io(void)
{ {
s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc)); s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
s3c2410_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs)); s3c2410_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
s3c2410_set_board(&vr1000_board); s3c24xx_set_board(&vr1000_board);
usb_simtec_init(); usb_simtec_init();
} }
......
...@@ -191,13 +191,6 @@ void __init s3c2410_map_io(struct map_desc *mach_desc, int mach_size) ...@@ -191,13 +191,6 @@ void __init s3c2410_map_io(struct map_desc *mach_desc, int mach_size)
print_mhz(s3c24xx_pclk)); print_mhz(s3c24xx_pclk));
} }
static struct s3c2410_board *board;
void s3c2410_set_board(struct s3c2410_board *b)
{
board = b;
}
int __init s3c2410_init(void) int __init s3c2410_init(void)
{ {
int ret; int ret;
...@@ -205,22 +198,5 @@ int __init s3c2410_init(void) ...@@ -205,22 +198,5 @@ int __init s3c2410_init(void)
printk("S3C2410: Initialising architecture\n"); printk("S3C2410: Initialising architecture\n");
ret = platform_add_devices(uart_devices, ARRAY_SIZE(uart_devices)); ret = platform_add_devices(uart_devices, ARRAY_SIZE(uart_devices));
if (ret)
return ret;
if (board != NULL) {
if (board->devices != NULL) {
ret = platform_add_devices(board->devices,
board->devices_count);
if (ret) {
printk(KERN_ERR "s3c2410: failed to add board devices (%d)\n", ret);
}
}
/* not adding board devices may not be fatal */
ret = 0;
}
return ret; return ret;
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* 18-Aug-2004 BJD Created initial version * 18-Aug-2004 BJD Created initial version
* 20-Aug-2004 BJD Added s3c2410_board struct * 20-Aug-2004 BJD Added s3c2410_board struct
* 04-Sep-2004 BJD Added s3c2410_init_uarts() call * 04-Sep-2004 BJD Added s3c2410_init_uarts() call
* 17-Oct-2004 BJD Moved board out to cpu
*/ */
struct s3c2410_uartcfg; struct s3c2410_uartcfg;
...@@ -26,18 +27,4 @@ extern void s3c2410_init_irq(void); ...@@ -26,18 +27,4 @@ extern void s3c2410_init_irq(void);
struct sys_timer; struct sys_timer;
extern struct sys_timer s3c2410_timer; extern struct sys_timer s3c2410_timer;
/* the board structure is used at first initialsation time
* to get info such as the devices to register for this
* board. This is done because platfrom_add_devices() cannot
* be called from the map_io entry.
*
*/
struct s3c2410_board {
struct platform_device **devices;
unsigned int devices_count;
};
extern void s3c2410_set_board(struct s3c2410_board *board);
extern void s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no); extern void s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no);
...@@ -178,11 +178,6 @@ int __init s3c2440_init(void) ...@@ -178,11 +178,6 @@ int __init s3c2440_init(void)
printk("S3C2440: Initialising architecture\n"); printk("S3C2440: Initialising architecture\n");
ret = platform_add_devices(uart_devices, ARRAY_SIZE(uart_devices)); ret = platform_add_devices(uart_devices, ARRAY_SIZE(uart_devices));
if (ret)
return ret;
// todo: board specific inits?
return ret; return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment