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

[ARM PATCH] 2076/1: S3C2410 - s3c2440 support and machine updates

Patch from Ben Dooks

Include the central code for detecting the cpu in use,
and initialising it's IO. Updated all mach-XXX.c files to
use this new init.

Added the first stage of the new serial port code by
calling s3c2410_init_uarts() instead of just setting
a variable.

Updates mach-h1940.c to prefix with h1940_ instead of ipaq_

Small fixes for redundant code

Signed-off-by: Ben Dooks 
parent f35ece20
# #
# Makefile for the linux kernel. # Makefile for the linux kernel.
# #
# Object file lists. # Object file lists.
obj-y := s3c2410.o irq.o time.o gpio.o clock.o devs.o obj-y := cpu.o irq.o time.o gpio.o clock.o devs.o
obj-m := obj-m :=
obj-n := obj-n :=
obj- := obj- :=
# S3C2410 support files
obj-$(CONFIG_CPU_S3C2410) += s3c2410.o
obj-$(CONFIG_S3C2410_DMA) += dma.o obj-$(CONFIG_S3C2410_DMA) += dma.o
obj-$(CONFIG_ARCH_BAST) += mach-bast.o # S3C2440 support
obj-$(CONFIG_MACH_H1940) += mach-h1940.o
obj-$(CONFIG_ARCH_H1940) += mach-h1940.o obj-$(CONFIG_CPU_S3C2440) += s3c2440.o s3c2440-dsc.o
obj-$(CONFIG_ARCH_SMDK2410) += mach-smdk2410.o
obj-$(CONFIG_MACH_VR1000) += mach-vr1000.o # machine specific support
obj-$(CONFIG_ARCH_BAST) += mach-bast.o
obj-$(CONFIG_ARCH_H1940) += mach-h1940.o
obj-$(CONFIG_ARCH_SMDK2410) += mach-smdk2410.o
obj-$(CONFIG_MACH_VR1000) += mach-vr1000.o
#obj-$(CONFIG_PCI) +=$(pci-y)
#obj-$(CONFIG_LEDS) +=$(leds-y)
/* linux/arch/arm/mach-s3c2410/cpu.c
*
* Copyright (c) 2004 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
*
* S3C24XX CPU Support
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/device.h>
#include <asm/hardware.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <asm/delay.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/arch/regs-gpio.h>
#include "cpu.h"
#include "s3c2410.h"
#include "s3c2440.h"
struct cpu_table {
unsigned long idcode;
unsigned long idmask;
void (*map_io)(struct map_desc *mach_desc, int size);
int (*init)(void);
const char *name;
};
/* table of supported CPUs */
static const char name_s3c2410[] = "S3C2410";
static const char name_s3c2440[] = "S3C2440";
static const char name_s3c2410a[] = "S3C2410A";
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 = 0x3241002,
.idmask = 0xffffffff,
.map_io = s3c2410_map_io,
.init = s3c2410_init,
.name = name_s3c2410a
},
{
.idcode = 0x32440000,
.idmask = 0xffffffff,
.map_io = s3c2440_map_io,
.init = s3c2440_init,
.name = name_s3c2440
},
{
.idcode = 0x32440001,
.idmask = 0xffffffff,
.map_io = s3c2440_map_io,
.init = s3c2440_init,
.name = name_s3c2440a
}
};
/* minimal IO mapping */
static struct map_desc s3c_iodesc[] __initdata = {
IODESC_ENT(GPIO),
IODESC_ENT(IRQ),
IODESC_ENT(MEMCTRL),
IODESC_ENT(UART)
};
static struct cpu_table *
s3c_lookup_cpu(unsigned long idcode)
{
struct cpu_table *tab;
int count;
tab = cpu_ids;
for (count = 0; count < ARRAY_SIZE(cpu_ids); count++) {
if ((idcode & tab->idmask) == tab->idcode)
return tab;
}
return NULL;
}
static struct cpu_table *cpu;
void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
{
unsigned long idcode;
/* initialise the io descriptors we need for initialisation */
iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));
idcode = __raw_readl(S3C2410_GSTATUS1);
cpu = s3c_lookup_cpu(idcode);
if (cpu == NULL) {
printk(KERN_ERR "Unknown CPU type 0x%08lx\n", idcode);
panic("Unknown S3C24XX CPU");
}
if (cpu->map_io == NULL || cpu->init == NULL) {
printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
panic("Unsupported S3C24XX CPU");
}
printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
(cpu->map_io)(mach_desc, size);
}
static int __init s3c_arch_init(void)
{
// do the correct init for cpu
if (cpu == NULL)
panic("s3c_arch_init: NULL cpu\n");
return (cpu->init)();
}
arch_initcall(s3c_arch_init);
/* arch/arm/mach-s3c2410/cpu.h
*
* Copyright (c) 2004 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
*
* Header file for S3C24XX CPU support
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Modifications:
* 24-Aug-2004 BJD Start of generic S3C24XX support
*/
#define IODESC_ENT(x) { S3C2410_VA_##x, S3C2410_PA_##x, S3C2410_SZ_##x, MT_DEVICE }
#ifndef MHZ
#define MHZ (1000*1000)
#endif
#define print_mhz(m) ((m) / MHZ), ((m / 1000) % 1000)
#ifdef CONFIG_CPU_S3C2410
extern int s3c2410_init(void);
extern void s3c2410_map_io(struct map_desc *mach_desc, int size);
#else
#define s3c2410_map_io NULL
#define s3c2410_init NULL
#endif
#ifdef CONFIG_CPU_S3C2440
extern int s3c2440_init(void);
extern void s3c2440_map_io(struct map_desc *mach_desc, int size);
#else
#define s3c2440_map_io NULL
#define s3c2440_init NULL
#endif
extern void s3c24xx_init_io(struct map_desc *mach_desc, int size);
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "s3c2410.h" #include "s3c2410.h"
#include "devs.h" #include "devs.h"
#include "cpu.h"
/* macros for virtual address mods for the io space entries */ /* macros for virtual address mods for the io space entries */
#define VA_C5(item) ((item) + BAST_VAM_CS5) #define VA_C5(item) ((item) + BAST_VAM_CS5)
...@@ -175,12 +176,33 @@ static struct s3c2410_uartcfg bast_uartcfgs[] = { ...@@ -175,12 +176,33 @@ static struct s3c2410_uartcfg bast_uartcfgs[] = {
} }
}; };
/* NOR Flash on BAST board */
static struct resource bast_nor_resource[] = {
[0] = {
.start = S3C2410_CS1 + 0x4000000,
.end = S3C2410_CS1 + 0x4000000 + (32*1024*1024) - 1,
.flags = IORESOURCE_MEM,
}
};
static struct platform_device bast_device_nor = {
.name = "bast-nor",
.id = -1,
.num_resources = ARRAY_SIZE(bast_nor_resource),
.resource = bast_nor_resource,
};
/* Standard BAST devices */
static struct platform_device *bast_devices[] __initdata = { static struct platform_device *bast_devices[] __initdata = {
&s3c_device_usb, &s3c_device_usb,
&s3c_device_lcd, &s3c_device_lcd,
&s3c_device_wdt, &s3c_device_wdt,
&s3c_device_i2c, &s3c_device_i2c,
&s3c_device_iis, &s3c_device_iis,
&s3c_device_rtc,
&bast_device_nor
}; };
static struct s3c2410_board bast_board __initdata = { static struct s3c2410_board bast_board __initdata = {
...@@ -190,9 +212,8 @@ static struct s3c2410_board bast_board __initdata = { ...@@ -190,9 +212,8 @@ static struct s3c2410_board bast_board __initdata = {
void __init bast_map_io(void) void __init bast_map_io(void)
{ {
s3c2410_map_io(bast_iodesc, ARRAY_SIZE(bast_iodesc)); s3c24xx_init_io(bast_iodesc, ARRAY_SIZE(bast_iodesc));
s3c2410_uartcfgs = bast_uartcfgs; s3c2410_init_uarts(bast_uartcfgs, ARRAY_SIZE(bast_uartcfgs));
s3c2410_set_board(&bast_board); s3c2410_set_board(&bast_board);
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* 18-Jan-2003 BJD Added serial port configuration * 18-Jan-2003 BJD Added serial port configuration
* 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_
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -41,8 +42,9 @@ ...@@ -41,8 +42,9 @@
#include "s3c2410.h" #include "s3c2410.h"
#include "devs.h" #include "devs.h"
#include "cpu.h"
static struct map_desc ipaq_iodesc[] __initdata = { static struct map_desc h1940_iodesc[] __initdata = {
/* nothing here yet */ /* nothing here yet */
}; };
...@@ -50,7 +52,7 @@ static struct map_desc ipaq_iodesc[] __initdata = { ...@@ -50,7 +52,7 @@ static struct map_desc ipaq_iodesc[] __initdata = {
#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
static struct s3c2410_uartcfg ipaq_uartcfgs[] = { static struct s3c2410_uartcfg h1940_uartcfgs[] = {
[0] = { [0] = {
.hwport = 0, .hwport = 0,
.flags = 0, .flags = 0,
...@@ -94,23 +96,20 @@ static struct s3c2410_board h1940_board __initdata = { ...@@ -94,23 +96,20 @@ static struct s3c2410_board h1940_board __initdata = {
.devices_count = ARRAY_SIZE(h1940_devices) .devices_count = ARRAY_SIZE(h1940_devices)
}; };
void __init ipaq_map_io(void) void __init h1940_map_io(void)
{ {
s3c2410_map_io(ipaq_iodesc, ARRAY_SIZE(ipaq_iodesc)); s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
s3c2410_uartcfgs = ipaq_uartcfgs; s3c2410_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
s3c2410_set_board(&h1940_board); s3c2410_set_board(&h1940_board);
} }
void __init ipaq_init_irq(void) void __init h1940_init_irq(void)
{ {
//llprintk("ipaq_init_irq:\n");
s3c2410_init_irq(); s3c2410_init_irq();
} }
void __init ipaq_init_time(void) void __init h1940_init_time(void)
{ {
s3c2410_init_time(); s3c2410_init_time();
} }
...@@ -119,7 +118,7 @@ MACHINE_START(H1940, "IPAQ-H1940") ...@@ -119,7 +118,7 @@ MACHINE_START(H1940, "IPAQ-H1940")
MAINTAINER("Ben Dooks <ben@fluff.org>") MAINTAINER("Ben Dooks <ben@fluff.org>")
BOOT_MEM(S3C2410_SDRAM_PA, S3C2410_PA_UART, S3C2410_VA_UART) BOOT_MEM(S3C2410_SDRAM_PA, S3C2410_PA_UART, S3C2410_VA_UART)
BOOT_PARAMS(S3C2410_SDRAM_PA + 0x100) BOOT_PARAMS(S3C2410_SDRAM_PA + 0x100)
MAPIO(ipaq_map_io) MAPIO(h1940_map_io)
INITIRQ(ipaq_init_irq) INITIRQ(h1940_init_irq)
INITTIME(ipaq_init_time) INITTIME(h1940_init_time)
MACHINE_END MACHINE_END
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "s3c2410.h" #include "s3c2410.h"
#include "devs.h" #include "devs.h"
#include "cpu.h"
static struct map_desc smdk2410_iodesc[] __initdata = { static struct map_desc smdk2410_iodesc[] __initdata = {
/* nothing here yet */ /* nothing here yet */
...@@ -102,9 +103,8 @@ static struct s3c2410_board smdk2410_board __initdata = { ...@@ -102,9 +103,8 @@ static struct s3c2410_board smdk2410_board __initdata = {
void __init smdk2410_map_io(void) void __init smdk2410_map_io(void)
{ {
s3c2410_map_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc)); s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
s3c2410_uartcfgs = smdk2410_uartcfgs; s3c2410_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
s3c2410_set_board(&smdk2410_board); s3c2410_set_board(&smdk2410_board);
} }
...@@ -127,3 +127,5 @@ MACHINE_START(SMDK2410, "SMDK2410") /* @TODO: request a new identifier and switc ...@@ -127,3 +127,5 @@ MACHINE_START(SMDK2410, "SMDK2410") /* @TODO: request a new identifier and switc
INITIRQ(smdk2410_init_irq) INITIRQ(smdk2410_init_irq)
INITTIME(smdk2410_init_time) INITTIME(smdk2410_init_time)
MACHINE_END MACHINE_END
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* Modifications: * Modifications:
* 04-Sep-2004 BJD Added new uart init, and io init
* 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
...@@ -40,6 +41,7 @@ ...@@ -40,6 +41,7 @@
#include "s3c2410.h" #include "s3c2410.h"
#include "devs.h" #include "devs.h"
#include "cpu.h"
/* macros for virtual address mods for the io space entries */ /* macros for virtual address mods for the io space entries */
#define VA_C5(item) ((item) + BAST_VAM_CS5) #define VA_C5(item) ((item) + BAST_VAM_CS5)
...@@ -155,18 +157,14 @@ static struct s3c2410_board vr1000_board __initdata = { ...@@ -155,18 +157,14 @@ static struct s3c2410_board vr1000_board __initdata = {
void __init vr1000_map_io(void) void __init vr1000_map_io(void)
{ {
s3c2410_map_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc)); s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
s3c2410_uartcfgs = vr1000_uartcfgs; s3c2410_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
s3c2410_set_board(&vr1000_board); s3c2410_set_board(&vr1000_board);
} }
void __init vr1000_init_irq(void) void __init vr1000_init_irq(void)
{ {
//llprintk("vr1000init_irq:\n");
s3c2410_init_irq(); s3c2410_init_irq();
} }
void __init vr1000_init_time(void) void __init vr1000_init_time(void)
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <asm/arch/regs-serial.h> #include <asm/arch/regs-serial.h>
#include "s3c2410.h" #include "s3c2410.h"
#include "cpu.h"
int s3c2410_clock_tick_rate = 12*1000*1000; /* current timers at 12MHz */ int s3c2410_clock_tick_rate = 12*1000*1000; /* current timers at 12MHz */
...@@ -50,23 +51,12 @@ unsigned long s3c2410_fclk; ...@@ -50,23 +51,12 @@ unsigned long s3c2410_fclk;
unsigned long s3c2410_hclk; unsigned long s3c2410_hclk;
unsigned long s3c2410_pclk; unsigned long s3c2410_pclk;
#ifndef MHZ
#define MHZ (1000*1000)
#endif
#define print_mhz(m) ((m) / MHZ), ((m / 1000) % 1000)
#define IODESC_ENT(x) { S3C2410_VA_##x, S3C2410_PA_##x, S3C2410_SZ_##x, MT_DEVICE }
static struct map_desc s3c2410_iodesc[] __initdata = { static struct map_desc s3c2410_iodesc[] __initdata = {
IODESC_ENT(IRQ),
IODESC_ENT(MEMCTRL),
IODESC_ENT(USBHOST), IODESC_ENT(USBHOST),
IODESC_ENT(CLKPWR), IODESC_ENT(CLKPWR),
IODESC_ENT(LCD), IODESC_ENT(LCD),
IODESC_ENT(UART), IODESC_ENT(UART),
IODESC_ENT(TIMER), IODESC_ENT(TIMER),
IODESC_ENT(GPIO),
IODESC_ENT(ADC), IODESC_ENT(ADC),
IODESC_ENT(WATCHDOG) IODESC_ENT(WATCHDOG)
}; };
...@@ -141,14 +131,16 @@ static struct platform_device *uart_devices[] __initdata = { ...@@ -141,14 +131,16 @@ static struct platform_device *uart_devices[] __initdata = {
&s3c_uart2 &s3c_uart2
}; };
void __init s3c2410_map_io(struct map_desc *mach_desc, int size) void __init s3c2410_map_io(struct map_desc *mach_desc, int mach_size)
{ {
unsigned long tmp; unsigned long tmp;
/* register our io-tables */ /* register our io-tables */
iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc)); iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
iotable_init(mach_desc, size); iotable_init(mach_desc, mach_size);
printk("machine_initted %p,%d\n", mach_desc, mach_size);
/* now we've got our machine bits initialised, work out what /* now we've got our machine bits initialised, work out what
* clocks we've got */ * clocks we've got */
...@@ -177,7 +169,12 @@ void s3c2410_set_board(struct s3c2410_board *b) ...@@ -177,7 +169,12 @@ void s3c2410_set_board(struct s3c2410_board *b)
board = b; board = b;
} }
static int __init s3c2410_init(void) void s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
{
s3c2410_uartcfgs = cfg;
}
int __init s3c2410_init(void)
{ {
int ret; int ret;
...@@ -203,5 +200,3 @@ static int __init s3c2410_init(void) ...@@ -203,5 +200,3 @@ static int __init s3c2410_init(void)
return ret; return ret;
} }
arch_initcall(s3c2410_init);
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* Modifications: * Modifications:
* 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
*/ */
extern void s3c2410_map_io(struct map_desc *, int count); extern void s3c2410_map_io(struct map_desc *, int count);
...@@ -33,3 +34,5 @@ struct s3c2410_board { ...@@ -33,3 +34,5 @@ struct s3c2410_board {
}; };
extern void s3c2410_set_board(struct s3c2410_board *board); extern void s3c2410_set_board(struct s3c2410_board *board);
extern void s3c2410_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