]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[ARM] S3C24XX: Move initialisation code to arch/arm/plat-s3c
authorBen Dooks <ben-linux@fluff.org>
Tue, 21 Oct 2008 13:06:31 +0000 (14:06 +0100)
committerBen Dooks <ben-linux@fluff.org>
Mon, 15 Dec 2008 21:45:57 +0000 (21:45 +0000)
We need to add plat-s3c to the build to get the headers
that will go in here once moved from include/asm-arm so
we may as well put some useful common s3c code in here
to stop the errors generated form having nothing built.

The cpu setup is now passed the cpu idcode and the table
of supported cpus to s3c_init_cpu() to abstract the
cpu identification out of the initial io setup.

As well as moving the cpu initialisation code, we move the
map of the board specific items up to the calling code as
none of the map_io() functions actually do anything other
than pass this to iotable_init().

This patch does not rename any of the init functions that
will be common to s3c24xx and any other s3c architectures
as this can be done at a later date as it will touch all
the board support files which use functions such as
s3c24xx_init_clocks() and s3c24xx_init_uarts().

Note, the header arch/arm/plat-s3c24xx/include/plat/cpu.h
still has functions that are used by both the cpu and
board initialisation functions. This means that each board
has definitions specific to the cpu support included and
the vice-versa.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
13 files changed:
arch/arm/mach-s3c2410/s3c2410.c
arch/arm/mach-s3c2412/s3c2412.c
arch/arm/mach-s3c2443/s3c2443.c
arch/arm/plat-s3c/Makefile
arch/arm/plat-s3c/init.c [new file with mode: 0644]
arch/arm/plat-s3c24xx/cpu.c
arch/arm/plat-s3c24xx/include/plat/cpu.h
arch/arm/plat-s3c24xx/include/plat/s3c2400.h
arch/arm/plat-s3c24xx/include/plat/s3c2410.h
arch/arm/plat-s3c24xx/include/plat/s3c2412.h
arch/arm/plat-s3c24xx/include/plat/s3c2443.h
arch/arm/plat-s3c24xx/s3c244x.c
arch/arm/plat-s3c24xx/s3c244x.h

index ac79b536c4c3d5510f84e969e5cb4cfe5faecb9e..1db39c609d786be5009046e27a3776a28bda0e41 100644 (file)
@@ -59,12 +59,9 @@ void __init s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  * machine specific initialisation.
 */
 
-void __init s3c2410_map_io(struct map_desc *mach_desc, int mach_size)
+void __init s3c2410_map_io(void)
 {
-       /* register our io-tables */
-
        iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
-       iotable_init(mach_desc, mach_size);
 }
 
 void __init s3c2410_init_clocks(int xtal)
index a086818e117e80e585d184714f3f4cc0aeb81bcc..22d22a035782b4aacbca5ab340a0f1fda3897711 100644 (file)
@@ -136,7 +136,7 @@ static void s3c2412_hard_reset(void)
  * machine specific initialisation.
 */
 
-void __init s3c2412_map_io(struct map_desc *mach_desc, int mach_size)
+void __init s3c2412_map_io(void)
 {
        /* move base of IO */
 
@@ -153,7 +153,6 @@ void __init s3c2412_map_io(struct map_desc *mach_desc, int mach_size)
        /* register our io-tables */
 
        iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc));
-       iotable_init(mach_desc, mach_size);
 }
 
 void __init s3c2412_init_clocks(int xtal)
index bbeddf9ddcb1a68c99835f039f10a150c66f64f2..ce2ec32989304d6e6323639fa4c99dcf96578a00 100644 (file)
@@ -81,10 +81,9 @@ void __init s3c2443_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  * machine specific initialisation.
  */
 
-void __init s3c2443_map_io(struct map_desc *mach_desc, int mach_size)
+void __init s3c2443_map_io(void)
 {
        iotable_init(s3c2443_iodesc, ARRAY_SIZE(s3c2443_iodesc));
-       iotable_init(mach_desc, mach_size);
 }
 
 /* need to register class before we actually register the device, and
index f03d7b35ba3773c7699bc4fffafb8e2396b09945..f7c8824ef80546befdf6c3e182a4514972986156 100644 (file)
@@ -1,3 +1,14 @@
-# dummy makefile, currently just including asm/arm/plat-s3c/include/plat
+# arch/arm/plat-s3c/Makefile
+#
+# Copyright 2008 Simtec Electronics
+#
+# Licensed under GPLv2
 
-obj-n  := dummy.o
+obj-y                          :=
+obj-m                          :=
+obj-n                          :=
+obj-                           :=
+
+# Core support for all Samsung SoCs
+
+obj-y                          +=  init.o
diff --git a/arch/arm/plat-s3c/init.c b/arch/arm/plat-s3c/init.c
new file mode 100644 (file)
index 0000000..85f086e
--- /dev/null
@@ -0,0 +1,161 @@
+/* linux/arch/arm/plat-s3c/init.c
+ *
+ * Copyright (c) 2008 Simtec Electronics
+ *     Ben Dooks <ben@simtec.co.uk>
+ *     http://armlinux.simtec.co.uk/
+ *
+ * S3C series CPU initialisation
+ *
+ * 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 <mach/hardware.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+#include <plat/cpu.h>
+#include <plat/devs.h>
+#include <plat/clock.h>
+
+#include <plat/regs-serial.h>
+
+static struct cpu_table *cpu;
+
+static struct cpu_table * __init s3c_lookup_cpu(unsigned long idcode,
+                                               struct cpu_table *tab,
+                                               unsigned int count)
+{
+       for (; count != 0; count--, tab++) {
+               if ((idcode & tab->idmask) == tab->idcode)
+                       return tab;
+       }
+
+       return NULL;
+}
+
+void __init s3c_init_cpu(unsigned long idcode,
+                        struct cpu_table *cputab, unsigned int cputab_size)
+{
+       cpu = s3c_lookup_cpu(idcode, cputab, cputab_size);
+
+       if (cpu == NULL) {
+               printk(KERN_ERR "Unknown CPU type 0x%08lx\n", idcode);
+               panic("Unknown S3C24XX CPU");
+       }
+
+       printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
+
+       if (cpu->map_io == NULL || cpu->init == NULL) {
+               printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
+               panic("Unsupported Samsung CPU");
+       }
+
+       cpu->map_io();
+}
+
+/* s3c24xx_init_clocks
+ *
+ * Initialise the clock subsystem and associated information from the
+ * given master crystal value.
+ *
+ * xtal  = 0 -> use default PLL crystal value (normally 12MHz)
+ *      != 0 -> PLL crystal value in Hz
+*/
+
+void __init s3c24xx_init_clocks(int xtal)
+{
+       if (xtal == 0)
+               xtal = 12*1000*1000;
+
+       if (cpu == NULL)
+               panic("s3c24xx_init_clocks: no cpu setup?\n");
+
+       if (cpu->init_clocks == NULL)
+               panic("s3c24xx_init_clocks: cpu has no clock init\n");
+       else
+               (cpu->init_clocks)(xtal);
+}
+
+/* uart management */
+
+static int nr_uarts __initdata = 0;
+
+static struct s3c2410_uartcfg uart_cfgs[3];
+
+/* s3c24xx_init_uartdevs
+ *
+ * copy the specified platform data and configuration into our central
+ * set of devices, before the data is thrown away after the init process.
+ *
+ * This also fills in the array passed to the serial driver for the
+ * early initialisation of the console.
+*/
+
+void __init s3c24xx_init_uartdevs(char *name,
+                                 struct s3c24xx_uart_resources *res,
+                                 struct s3c2410_uartcfg *cfg, int no)
+{
+       struct platform_device *platdev;
+       struct s3c2410_uartcfg *cfgptr = uart_cfgs;
+       struct s3c24xx_uart_resources *resp;
+       int uart;
+
+       memcpy(cfgptr, cfg, sizeof(struct s3c2410_uartcfg) * no);
+
+       for (uart = 0; uart < no; uart++, cfg++, cfgptr++) {
+               platdev = s3c24xx_uart_src[cfgptr->hwport];
+
+               resp = res + cfgptr->hwport;
+
+               s3c24xx_uart_devs[uart] = platdev;
+
+               platdev->name = name;
+               platdev->resource = resp->resources;
+               platdev->num_resources = resp->nr_resources;
+
+               platdev->dev.platform_data = cfgptr;
+       }
+
+       nr_uarts = no;
+}
+
+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;
+
+       // do the correct init for cpu
+
+       if (cpu == NULL)
+               panic("s3c_arch_init: NULL cpu\n");
+
+       ret = (cpu->init)();
+       if (ret != 0)
+               return ret;
+
+       ret = platform_add_devices(s3c24xx_uart_devs, nr_uarts);
+       return ret;
+}
+
+arch_initcall(s3c_arch_init);
index 22a329513c0f3ff0149791066ae4d6a5c64515c1..7a0f494c93b6242051f4f9b8b1521ff386fbdf8d 100644 (file)
 #include <plat/s3c2442.h>
 #include <plat/s3c2443.h>
 
-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);
-       void            (*init_clocks)(int xtal);
-       int             (*init)(void);
-       const char      *name;
-};
-
 /* table of supported CPUs */
 
 static const char name_s3c2400[]  = "S3C2400";
@@ -169,23 +159,7 @@ static struct map_desc s3c_iodesc[] __initdata = {
        IODESC_ENT(UART)
 };
 
-static struct cpu_table * __init s3c_lookup_cpu(unsigned long idcode)
-{
-       struct cpu_table *tab;
-       int count;
-
-       tab = cpu_ids;
-       for (count = 0; count < ARRAY_SIZE(cpu_ids); count++, tab++) {
-               if ((idcode & tab->idmask) == tab->idcode)
-                       return tab;
-       }
-
-       return NULL;
-}
-
-/* cpu information */
-
-static struct cpu_table *cpu;
+/* read cpu identificaiton code */
 
 static unsigned long s3c24xx_read_idcode_v5(void)
 {
@@ -231,6 +205,7 @@ void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
        unsigned long idcode = 0x0;
 
        /* initialise the io descriptors we need for initialisation */
+       iotable_init(mach_desc, size);
        iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));
 
        if (cpu_architecture() >= CPU_ARCH_ARMv5) {
@@ -239,117 +214,7 @@ void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
                idcode = s3c24xx_read_idcode_v4();
        }
 
-       cpu = s3c_lookup_cpu(idcode);
-
-       if (cpu == NULL) {
-               printk(KERN_ERR "Unknown CPU type 0x%08lx\n", idcode);
-               panic("Unknown S3C24XX CPU");
-       }
-
-       printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
-
-       if (cpu->map_io == NULL || cpu->init == NULL) {
-               printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
-               panic("Unsupported S3C24XX CPU");
-       }
-
        arm_pm_restart = s3c24xx_pm_restart;
 
-       (cpu->map_io)(mach_desc, size);
-}
-
-/* s3c24xx_init_clocks
- *
- * Initialise the clock subsystem and associated information from the
- * given master crystal value.
- *
- * xtal  = 0 -> use default PLL crystal value (normally 12MHz)
- *      != 0 -> PLL crystal value in Hz
-*/
-
-void __init s3c24xx_init_clocks(int xtal)
-{
-       if (xtal == 0)
-               xtal = 12*1000*1000;
-
-       if (cpu == NULL)
-               panic("s3c24xx_init_clocks: no cpu setup?\n");
-
-       if (cpu->init_clocks == NULL)
-               panic("s3c24xx_init_clocks: cpu has no clock init\n");
-       else
-               (cpu->init_clocks)(xtal);
-}
-
-/* uart management */
-
-static int nr_uarts __initdata = 0;
-
-static struct s3c2410_uartcfg uart_cfgs[3];
-
-/* s3c24xx_init_uartdevs
- *
- * copy the specified platform data and configuration into our central
- * set of devices, before the data is thrown away after the init process.
- *
- * This also fills in the array passed to the serial driver for the
- * early initialisation of the console.
-*/
-
-void __init s3c24xx_init_uartdevs(char *name,
-                                 struct s3c24xx_uart_resources *res,
-                                 struct s3c2410_uartcfg *cfg, int no)
-{
-       struct platform_device *platdev;
-       struct s3c2410_uartcfg *cfgptr = uart_cfgs;
-       struct s3c24xx_uart_resources *resp;
-       int uart;
-
-       memcpy(cfgptr, cfg, sizeof(struct s3c2410_uartcfg) * no);
-
-       for (uart = 0; uart < no; uart++, cfg++, cfgptr++) {
-               platdev = s3c24xx_uart_src[cfgptr->hwport];
-
-               resp = res + cfgptr->hwport;
-
-               s3c24xx_uart_devs[uart] = platdev;
-
-               platdev->name = name;
-               platdev->resource = resp->resources;
-               platdev->num_resources = resp->nr_resources;
-
-               platdev->dev.platform_data = cfgptr;
-       }
-
-       nr_uarts = no;
+       s3c_init_cpu(idcode, cpu_ids, ARRAY_SIZE(cpu_ids));
 }
-
-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;
-
-       // do the correct init for cpu
-
-       if (cpu == NULL)
-               panic("s3c_arch_init: NULL cpu\n");
-
-       ret = (cpu->init)();
-       if (ret != 0)
-               return ret;
-
-       ret = platform_add_devices(s3c24xx_uart_devs, nr_uarts);
-       return ret;
-}
-
-arch_initcall(s3c_arch_init);
index 23e420e8bd5bcf1d1aee6fa562374fa6e273426a..bd0a02963b4684f5fa9561151d2815896c5babe1 100644 (file)
@@ -26,6 +26,21 @@ struct platform_device;
 struct s3c2410_uartcfg;
 struct map_desc;
 
+/* per-cpu initialisation function table. */
+
+struct cpu_table {
+       unsigned long   idcode;
+       unsigned long   idmask;
+       void            (*map_io)(void);
+       void            (*init_uarts)(struct s3c2410_uartcfg *cfg, int no);
+       void            (*init_clocks)(int xtal);
+       int             (*init)(void);
+       const char      *name;
+};
+
+extern void s3c_init_cpu(unsigned long idcode,
+                        struct cpu_table *cpus, unsigned int cputab_size);
+
 /* core initialisation functions */
 
 extern void s3c24xx_init_irq(void);
index 3a5a16821af8e5de6cbdcd3c3719847ff39d072a..b3feaea5c70ba20cc6e85bb89487de10837e6fe8 100644 (file)
@@ -17,7 +17,7 @@
 
 extern  int s3c2400_init(void);
 
-extern void s3c2400_map_io(struct map_desc *mach_desc, int size);
+extern void s3c2400_map_io(void);
 
 extern void s3c2400_init_uarts(struct s3c2410_uartcfg *cfg, int no);
 
index 3cd1ec677b3ffe00043ebe434016fbf90b1a9461..a9ac9e29759e0d0900594cf1c06b93ec4ad11d1e 100644 (file)
@@ -15,7 +15,7 @@
 
 extern  int s3c2410_init(void);
 
-extern void s3c2410_map_io(struct map_desc *mach_desc, int size);
+extern void s3c2410_map_io(void);
 
 extern void s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no);
 
index 3ec97685e7819029c342b0571a541db22c470cd1..bb15d3b68be5ec7c2beac2bee7272f0f9deb647b 100644 (file)
@@ -14,7 +14,7 @@
 
 extern  int s3c2412_init(void);
 
-extern void s3c2412_map_io(struct map_desc *mach_desc, int size);
+extern void s3c2412_map_io(void);
 
 extern void s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no);
 
index 11d83b5c84e60683a8e715e13550fd7206553d1f..815b107ed8904b6606fead4e12758ee715ea2709 100644 (file)
@@ -16,7 +16,7 @@ struct s3c2410_uartcfg;
 
 extern  int s3c2443_init(void);
 
-extern void s3c2443_map_io(struct map_desc *mach_desc, int size);
+extern void s3c2443_map_io(void);
 
 extern void s3c2443_init_uarts(struct s3c2410_uartcfg *cfg, int no);
 
index c0344fac4a9492706609ed7ef5a2a42a4b27c9b0..d1152d1f9ba0a109eb7117c44922a9e9c8b8a2c2 100644 (file)
@@ -56,12 +56,11 @@ void __init s3c244x_init_uarts(struct s3c2410_uartcfg *cfg, int no)
        s3c24xx_init_uartdevs("s3c2440-uart", s3c2410_uart_resources, cfg, no);
 }
 
-void __init s3c244x_map_io(struct map_desc *mach_desc, int size)
+void __init s3c244x_map_io(void)
 {
        /* register our io-tables */
 
        iotable_init(s3c244x_iodesc, ARRAY_SIZE(s3c244x_iodesc));
-       iotable_init(mach_desc, size);
 
        /* rename any peripherals used differing from the s3c2410 */
 
index f8ed17676a355c49a7f5af03818cdc826a85df10..6aab5eaae2b46cb6a7967d75f9235165bd2ac7ca 100644 (file)
@@ -12,7 +12,7 @@
 
 #if defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2442)
 
-extern void s3c244x_map_io(struct map_desc *mach_desc, int size);
+extern void s3c244x_map_io(void);
 
 extern void s3c244x_init_uarts(struct s3c2410_uartcfg *cfg, int no);