+
#
# Makefile for the linux kernel.
#
# 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-n :=
obj- :=
+# S3C2410 support files
+
+obj-$(CONFIG_CPU_S3C2410) += s3c2410.o
obj-$(CONFIG_S3C2410_DMA) += dma.o
-obj-$(CONFIG_ARCH_BAST) += mach-bast.o
-obj-$(CONFIG_MACH_H1940) += mach-h1940.o
-obj-$(CONFIG_ARCH_H1940) += mach-h1940.o
-obj-$(CONFIG_ARCH_SMDK2410) += mach-smdk2410.o
-obj-$(CONFIG_MACH_VR1000) += mach-vr1000.o
+# S3C2440 support
+
+obj-$(CONFIG_CPU_S3C2440) += s3c2440.o s3c2440-dsc.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)
--- /dev/null
+/* 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);
--- /dev/null
+/* 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);
+
#include "s3c2410.h"
#include "devs.h"
+#include "cpu.h"
/* macros for virtual address mods for the io space entries */
#define VA_C5(item) ((item) + BAST_VAM_CS5)
}
};
+/* 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 = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c,
&s3c_device_iis,
+ &s3c_device_rtc,
+ &bast_device_nor
};
static struct s3c2410_board bast_board __initdata = {
void __init bast_map_io(void)
{
- s3c2410_map_io(bast_iodesc, ARRAY_SIZE(bast_iodesc));
- s3c2410_uartcfgs = bast_uartcfgs;
-
+ s3c24xx_init_io(bast_iodesc, ARRAY_SIZE(bast_iodesc));
+ s3c2410_init_uarts(bast_uartcfgs, ARRAY_SIZE(bast_uartcfgs));
s3c2410_set_board(&bast_board);
}
* 18-Jan-2003 BJD Added serial port configuration
* 17-Feb-2003 BJD Copied to mach-ipaq.c
* 21-Aug-2004 BJD Added struct s3c2410_board
+ * 04-Sep-2004 BJD Changed uart init, renamed ipaq_ -> h1940_
*/
#include <linux/kernel.h>
#include "s3c2410.h"
#include "devs.h"
+#include "cpu.h"
-static struct map_desc ipaq_iodesc[] __initdata = {
+static struct map_desc h1940_iodesc[] __initdata = {
/* nothing here yet */
};
#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
-static struct s3c2410_uartcfg ipaq_uartcfgs[] = {
+static struct s3c2410_uartcfg h1940_uartcfgs[] = {
[0] = {
.hwport = 0,
.flags = 0,
.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));
- s3c2410_uartcfgs = ipaq_uartcfgs;
-
+ s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
+ s3c2410_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
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();
}
-void __init ipaq_init_time(void)
+void __init h1940_init_time(void)
{
s3c2410_init_time();
}
MAINTAINER("Ben Dooks <ben@fluff.org>")
BOOT_MEM(S3C2410_SDRAM_PA, S3C2410_PA_UART, S3C2410_VA_UART)
BOOT_PARAMS(S3C2410_SDRAM_PA + 0x100)
- MAPIO(ipaq_map_io)
- INITIRQ(ipaq_init_irq)
- INITTIME(ipaq_init_time)
+ MAPIO(h1940_map_io)
+ INITIRQ(h1940_init_irq)
+ INITTIME(h1940_init_time)
MACHINE_END
#include "s3c2410.h"
#include "devs.h"
+#include "cpu.h"
static struct map_desc smdk2410_iodesc[] __initdata = {
/* nothing here yet */
void __init smdk2410_map_io(void)
{
- s3c2410_map_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
- s3c2410_uartcfgs = smdk2410_uartcfgs;
-
+ s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
+ s3c2410_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
s3c2410_set_board(&smdk2410_board);
}
INITIRQ(smdk2410_init_irq)
INITTIME(smdk2410_init_time)
MACHINE_END
+
+
* published by the Free Software Foundation.
*
* Modifications:
+ * 04-Sep-2004 BJD Added new uart init, and io init
* 21-Aug-2004 BJD Added struct s3c2410_board
* 06-Aug-2004 BJD Fixed call to time initialisation
* 05-Apr-2004 BJD Copied to make mach-vr1000.c
#include "s3c2410.h"
#include "devs.h"
+#include "cpu.h"
/* macros for virtual address mods for the io space entries */
#define VA_C5(item) ((item) + BAST_VAM_CS5)
void __init vr1000_map_io(void)
{
- s3c2410_map_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
- s3c2410_uartcfgs = vr1000_uartcfgs;
-
+ s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
+ s3c2410_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
s3c2410_set_board(&vr1000_board);
}
void __init vr1000_init_irq(void)
{
- //llprintk("vr1000init_irq:\n");
-
s3c2410_init_irq();
-
}
void __init vr1000_init_time(void)
#include <asm/arch/regs-serial.h>
#include "s3c2410.h"
+#include "cpu.h"
int s3c2410_clock_tick_rate = 12*1000*1000; /* current timers at 12MHz */
unsigned long s3c2410_hclk;
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 = {
- IODESC_ENT(IRQ),
- IODESC_ENT(MEMCTRL),
IODESC_ENT(USBHOST),
IODESC_ENT(CLKPWR),
IODESC_ENT(LCD),
IODESC_ENT(UART),
IODESC_ENT(TIMER),
- IODESC_ENT(GPIO),
IODESC_ENT(ADC),
IODESC_ENT(WATCHDOG)
};
&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;
/* register our io-tables */
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
* clocks we've got */
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;
return ret;
}
-
-arch_initcall(s3c2410_init);
* Modifications:
* 18-Aug-2004 BJD Created initial version
* 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_set_board(struct s3c2410_board *board);
+
+extern void s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no);