[ARM] S3C64XX: Basic CPU detection and map initialisation
authorBen Dooks <ben-linux@fluff.org>
Tue, 21 Oct 2008 13:06:49 +0000 (14:06 +0100)
committerBen Dooks <ben-linux@fluff.org>
Mon, 15 Dec 2008 21:50:31 +0000 (21:50 +0000)
Initialise the basic physical to virtual mappings and
then detect the CPU that the system is being run on so
that the cpu code code can call the correct initialisation
code.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
arch/arm/mach-s3c6400/include/mach/map.h
arch/arm/plat-s3c64xx/Makefile
arch/arm/plat-s3c64xx/cpu.c [new file with mode: 0644]
arch/arm/plat-s3c64xx/include/plat/s3c6400.h [new file with mode: 0644]
arch/arm/plat-s3c64xx/include/plat/s3c6410.h [new file with mode: 0644]

index 0ee6be08e748d9589d3f2ad425b1c4e527543ec6..de6cdd518cea3b4110cffa7e18703a613a77c981 100644 (file)
@@ -24,6 +24,7 @@
 #define S3C_PA_UART3           (S3C_PA_UART + 0xC00)
 #define S3C_UART_OFFSET                (0x400)
 
+#define S3C64XX_PA_SYSCON      (0x7E00F000)
 #define S3C64XX_PA_TIMER       (0x7F006000)
 
 #define S3C64XX_PA_SDRAM       (0x50000000)
index 178c968bb8da1265d6b551e0cc03e81d784ea7fc..5d9a1d86ab8ec519b0f20c6b3e6a3ba00d6f9ae6 100644 (file)
@@ -13,3 +13,4 @@ obj-                          :=
 # Core files
 
 obj-y                          += dev-uart.o
+obj-y                          += cpu.o
diff --git a/arch/arm/plat-s3c64xx/cpu.c b/arch/arm/plat-s3c64xx/cpu.c
new file mode 100644 (file)
index 0000000..dc7bf11
--- /dev/null
@@ -0,0 +1,106 @@
+/* linux/arch/arm/plat-s3c64xx/cpu.c
+ *
+ * Copyright 2008 Openmoko, Inc.
+ * Copyright 2008 Simtec Electronics
+ *     Ben Dooks <ben@simtec.co.uk>
+ *     http://armlinux.simtec.co.uk/
+ *
+ * S3C64XX 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.
+*/
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/serial_core.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+
+#include <mach/hardware.h>
+#include <mach/map.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+#include <plat/regs-serial.h>
+
+#include <plat/cpu.h>
+#include <plat/devs.h>
+#include <plat/clock.h>
+
+#include <plat/s3c6400.h>
+#include <plat/s3c6410.h>
+
+/* table of supported CPUs */
+
+static const char name_s3c6400[] = "S3C6400";
+static const char name_s3c6410[] = "S3C6410";
+
+static struct cpu_table cpu_ids[] __initdata = {
+       {
+               .idcode         = 0x36400000,
+               .idmask         = 0xfffff000,
+               .map_io         = s3c6400_map_io,
+               .init_clocks    = s3c6400_init_clocks,
+               .init_uarts     = s3c6400_init_uarts,
+               .init           = s3c6400_init,
+               .name           = name_s3c6400,
+       }, {
+               .idcode         = 0x36410100,
+               .idmask         = 0xffffff00,
+               .map_io         = s3c6410_map_io,
+               .init_clocks    = s3c6410_init_clocks,
+               .init_uarts     = s3c6410_init_uarts,
+               .init           = s3c6410_init,
+               .name           = name_s3c6410,
+       },
+};
+
+/* minimal IO mapping */
+
+/* see notes on uart map in arch/arm/mach-s3c6400/include/mach/debug-macro.S */
+#define UART_OFFS (S3C_PA_UART & 0xfffff)
+
+static struct map_desc s3c_iodesc[] __initdata = {
+       {
+               .virtual        = S3C_VA_SYS,
+               .pfn            = __phys_to_pfn(S3C64XX_PA_SYSCON),
+               .length         = SZ_4K,
+               .type           = MT_DEVICE,
+       }, {
+               .virtual        = (unsigned long)(S3C_VA_UART + UART_OFFS),
+               .pfn            = __phys_to_pfn(S3C_PA_UART),
+               .length         = SZ_4K,
+               .type           = MT_DEVICE,
+       }, {
+               .virtual        = S3C_VA_VIC0,
+               .pfn            = __phys_to_pfn(S3C64XX_PA_VIC0),
+               .length         = SZ_16K,
+               .type           = MT_DEVICE,
+       }, {
+               .virtual        = S3C_VA_VIC1,
+               .pfn            = __phys_to_pfn(S3C64XX_PA_VIC1),
+               .length         = SZ_16K,
+               .type           = MT_DEVICE,
+       },
+};
+
+/* read cpu identification code */
+
+
+void __init s3c64xx_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));
+       iotable_init(mach_desc, size);
+
+       idcode = __raw_readl(S3C_VA_SYS + 0x118);
+       s3c_init_cpu(idcode, cpu_ids, ARRAY_SIZE(cpu_ids));
+}
diff --git a/arch/arm/plat-s3c64xx/include/plat/s3c6400.h b/arch/arm/plat-s3c64xx/include/plat/s3c6400.h
new file mode 100644 (file)
index 0000000..142bb3d
--- /dev/null
@@ -0,0 +1,33 @@
+/* arch/arm/plat-s3c64xx/include/plat/s3c6400.h
+ *
+ * Copyright 2008 Openmoko, Inc.
+ * Copyright 2008 Simtec Electronics
+ *     Ben Dooks <ben@simtec.co.uk>
+ *     http://armlinux.simtec.co.uk/
+ *
+ * Header file for s3c6400 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.
+*/
+
+/* Common init code for S3C6400 related SoCs */
+
+extern void s3c6400_common_init_uarts(struct s3c2410_uartcfg *cfg, int no);
+
+#ifdef CONFIG_CPU_S3C6400
+
+extern  int s3c6400_init(void);
+extern void s3c6400_map_io(void);
+extern void s3c6400_init_clocks(int xtal);
+
+#define s3c6400_init_uarts s3c6400_common_init_uarts
+
+#else
+#define s3c6400_init_clocks NULL
+#define s3c6400_init_uarts NULL
+#define s3c6400_map_io NULL
+#define s3c6400_init NULL
+#endif
+
diff --git a/arch/arm/plat-s3c64xx/include/plat/s3c6410.h b/arch/arm/plat-s3c64xx/include/plat/s3c6410.h
new file mode 100644 (file)
index 0000000..56f14b5
--- /dev/null
@@ -0,0 +1,28 @@
+/* arch/arm/plat-s3c64xx/include/plat/s3c6410.h
+ *
+ * Copyright 2008 Openmoko,  Inc.
+ * Copyright 2008 Simtec Electronics
+ *     Ben Dooks <ben@simtec.co.uk>
+ *     http://armlinux.simtec.co.uk/
+ *
+ * Header file for s3c6410 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.
+*/
+
+#ifdef CONFIG_CPU_S3C6410
+
+extern  int s3c6410_init(void);
+extern void s3c6410_map_io(void);
+extern void s3c6410_init_clocks(int xtal);
+
+#define s3c6410_init_uarts s3c6400_common_init_uarts
+
+#else
+#define s3c6410_init_clocks NULL
+#define s3c6410_init_uarts NULL
+#define s3c6410_map_io NULL
+#define s3c6410_init NULL
+#endif