Commit 934ae6d8 authored by Ben Dooks's avatar Ben Dooks Committed by Russell King

[ARM PATCH] 2345/1: S3C24XX - serial init depending on cpu detected

Patch from Ben Dooks

Use the cpu-type detected in arch/arm/mach-s3c2410/cpu.c
to work out which uart initialisation routine to call,
instead of relying on the one called within mach-xxxx.c.

This allows one machine-type to run with either an 2410 or
2440 cpu installed.

Thanks to Dimitry Andric for the original patch.

Signed-off-by: Ben Dooks
Signed-off-by: Russell King
parent b1281d46
......@@ -46,6 +46,7 @@ struct cpu_table {
unsigned long idcode;
unsigned long idmask;
void (*map_io)(struct map_desc *mach_desc, int size);
void (*init_uarts)(struct s3c2410_uartcfg *cfg, int no);
int (*init)(void);
const char *name;
};
......@@ -59,32 +60,36 @@ static const char name_s3c2440a[] = "S3C2440A";
static struct cpu_table cpu_ids[] __initdata = {
{
.idcode = 0x32410000,
.idmask = 0xffffffff,
.map_io = s3c2410_map_io,
.init = s3c2410_init,
.name = name_s3c2410
.idcode = 0x32410000,
.idmask = 0xffffffff,
.map_io = s3c2410_map_io,
.init_uarts = s3c2410_init_uarts,
.init = s3c2410_init,
.name = name_s3c2410
},
{
.idcode = 0x32410002,
.idmask = 0xffffffff,
.map_io = s3c2410_map_io,
.init = s3c2410_init,
.name = name_s3c2410a
.idcode = 0x32410002,
.idmask = 0xffffffff,
.map_io = s3c2410_map_io,
.init_uarts = s3c2410_init_uarts,
.init = s3c2410_init,
.name = name_s3c2410a
},
{
.idcode = 0x32440000,
.idmask = 0xffffffff,
.map_io = s3c2440_map_io,
.init = s3c2440_init,
.name = name_s3c2440
.idcode = 0x32440000,
.idmask = 0xffffffff,
.map_io = s3c2440_map_io,
.init_uarts = s3c2440_init_uarts,
.init = s3c2440_init,
.name = name_s3c2440
},
{
.idcode = 0x32440001,
.idmask = 0xffffffff,
.map_io = s3c2440_map_io,
.init = s3c2440_init,
.name = name_s3c2440a
.idcode = 0x32440001,
.idmask = 0xffffffff,
.map_io = s3c2440_map_io,
.init_uarts = s3c2440_init_uarts,
.init = s3c2440_init,
.name = name_s3c2440a
}
};
......@@ -160,6 +165,16 @@ void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
(cpu->map_io)(mach_desc, size);
}
void __init s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no)
{
if (cpu == NULL)
return;
if (cpu->init_uarts == NULL) {
printk(KERN_ERR "s3c24xx_init_uarts: cpu has no uart init\n");
} else
(cpu->init_uarts)(cfg, no);
}
static int __init s3c_arch_init(void)
{
int ret;
......
/* arch/arm/mach-s3c2410/cpu.h
*
* Copyright (c) 2004 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
* Copyright (c) 2004-2005 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
*
* Header file for S3C24XX CPU support
*
......@@ -12,6 +12,7 @@
* Modifications:
* 24-Aug-2004 BJD Start of generic S3C24XX support
* 18-Oct-2004 BJD Moved board struct into this file
* 04-Jan-2005 BJD New uart initialisation
*/
#define IODESC_ENT(x) { S3C2410_VA_##x, S3C2410_PA_##x, S3C2410_SZ_##x, MT_DEVICE }
......@@ -22,10 +23,15 @@
#define print_mhz(m) ((m) / MHZ), ((m / 1000) % 1000)
/* forward declaration */
struct s3c2410_uartcfg;
#ifdef CONFIG_CPU_S3C2410
extern int s3c2410_init(void);
extern void s3c2410_map_io(struct map_desc *mach_desc, int size);
extern void s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no);
#else
#define s3c2410_init_uarts NULL
#define s3c2410_map_io NULL
#define s3c2410_init NULL
#endif
......@@ -33,13 +39,17 @@ extern void s3c2410_map_io(struct map_desc *mach_desc, int size);
#ifdef CONFIG_CPU_S3C2440
extern int s3c2440_init(void);
extern void s3c2440_map_io(struct map_desc *mach_desc, int size);
extern void s3c2440_init_uarts(struct s3c2410_uartcfg *cfg, int no);
#else
#define s3c2440_init_uarts NULL
#define s3c2440_map_io NULL
#define s3c2440_init NULL
#endif
extern void s3c24xx_init_io(struct map_desc *mach_desc, int size);
extern void s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no);
/* 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
......@@ -55,5 +65,3 @@ struct s3c24xx_board {
};
extern void s3c24xx_set_board(struct s3c24xx_board *board);
/* linux/arch/arm/mach-s3c2410/mach-bast.c
*
* Copyright (c) 2003,2004 Simtec Electronics
* Copyright (c) 2003-2005 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
*
* http://www.simtec.co.uk/products/EB2410ITX/
......@@ -20,6 +20,7 @@
* 18-Jan-2003 BJD Added serial port configuration
* 05-Oct-2004 BJD Power management code
* 04-Nov-2004 BJD Updated serial port clocks
* 04-Jan-2004 BJD New uart init call
*/
#include <linux/kernel.h>
......@@ -262,7 +263,7 @@ void __init bast_map_io(void)
s3c24xx_uclk.parent = &s3c24xx_clkout1;
s3c24xx_init_io(bast_iodesc, ARRAY_SIZE(bast_iodesc));
s3c2410_init_uarts(bast_uartcfgs, ARRAY_SIZE(bast_uartcfgs));
s3c24xx_init_uarts(bast_uartcfgs, ARRAY_SIZE(bast_uartcfgs));
s3c24xx_set_board(&bast_board);
usb_simtec_init();
}
......
/* linux/arch/arm/mach-s3c2410/mach-h1940.c
*
* Copyright (c) 2003,2004 Simtec Electronics
* Copyright (c) 2003-2005 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
*
* http://www.handhelds.org/projects/h1940.html
......@@ -20,6 +20,7 @@
* 04-Sep-2004 BJD Changed uart init, renamed ipaq_ -> h1940_
* 18-Oct-2004 BJD Updated new board structure name
* 04-Nov-2004 BJD Change for new serial clock
* 04-Jan-2005 BJD Updated uart init call
*/
#include <linux/kernel.h>
......@@ -102,7 +103,7 @@ static struct s3c24xx_board h1940_board __initdata = {
void __init h1940_map_io(void)
{
s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
s3c2410_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
s3c24xx_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
s3c24xx_set_board(&h1940_board);
}
......
......@@ -95,7 +95,7 @@ void __init rx3715_map_io(void)
s3c24xx_xtal = 16934000;
s3c24xx_init_io(rx3715_iodesc, ARRAY_SIZE(rx3715_iodesc));
s3c2440_init_uarts(rx3715_uartcfgs, ARRAY_SIZE(rx3715_uartcfgs));
s3c24xx_init_uarts(rx3715_uartcfgs, ARRAY_SIZE(rx3715_uartcfgs));
s3c24xx_set_board(&rx3715_board);
}
......
......@@ -98,7 +98,7 @@ static struct s3c24xx_board smdk2410_board __initdata = {
void __init smdk2410_map_io(void)
{
s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
s3c2410_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
s3c24xx_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
s3c24xx_set_board(&smdk2410_board);
}
......
......@@ -18,6 +18,7 @@
* 05-Apr-2004 BJD Copied to make mach-vr1000.c
* 18-Oct-2004 BJD Updated board struct
* 04-Nov-2004 BJD Clock and serial configuration update
* 04-Jan-2004 BJD Updated uart init call
*/
#include <linux/kernel.h>
......@@ -204,7 +205,7 @@ void __init vr1000_map_io(void)
s3c24xx_uclk.parent = &s3c24xx_clkout1;
s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
s3c2410_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
s3c24xx_set_board(&vr1000_board);
usb_simtec_init();
}
......
......@@ -14,17 +14,14 @@
* 20-Aug-2004 BJD Added s3c2410_board struct
* 04-Sep-2004 BJD Added s3c2410_init_uarts() call
* 17-Oct-2004 BJD Moved board out to cpu
* 04-Jan-2005 BJD Changed uart init
*/
struct s3c2410_uartcfg;
extern void s3c2410_map_io(struct map_desc *, int count);
extern void s3c2410_init_uarts(struct s3c2410_uartcfg *, int no);
extern void s3c2410_init_irq(void);
struct sys_timer;
extern struct sys_timer s3c2410_timer;
extern void s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no);
......@@ -12,12 +12,9 @@
* Modifications:
* 24-Aug-2004 BJD Start of S3C2440 CPU support
* 04-Nov-2004 BJD Added s3c2440_init_uarts()
* 04-Jan-2004 BJD Moved uart init to cpu code
*/
struct s3c2410_uartcfg;
extern void s3c2440_init_irq(void);
extern void s3c2440_init_time(void);
extern void s3c2440_init_uarts(struct s3c2410_uartcfg *cfg, int no);
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