1 /* linux/arch/arm/plat-s3c/init.c
3 * Copyright (c) 2008 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 * http://armlinux.simtec.co.uk/
7 * S3C series CPU initialisation
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/init.h>
15 #include <linux/module.h>
16 #include <linux/interrupt.h>
17 #include <linux/ioport.h>
18 #include <linux/serial_core.h>
19 #include <linux/platform_device.h>
21 #include <mach/hardware.h>
23 #include <asm/mach/arch.h>
24 #include <asm/mach/map.h>
27 #include <plat/devs.h>
28 #include <plat/clock.h>
30 #include <plat/regs-serial.h>
32 static struct cpu_table *cpu;
34 static struct cpu_table * __init s3c_lookup_cpu(unsigned long idcode,
35 struct cpu_table *tab,
38 for (; count != 0; count--, tab++) {
39 if ((idcode & tab->idmask) == tab->idcode)
46 void __init s3c_init_cpu(unsigned long idcode,
47 struct cpu_table *cputab, unsigned int cputab_size)
49 cpu = s3c_lookup_cpu(idcode, cputab, cputab_size);
52 printk(KERN_ERR "Unknown CPU type 0x%08lx\n", idcode);
53 panic("Unknown S3C24XX CPU");
56 printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
58 if (cpu->map_io == NULL || cpu->init == NULL) {
59 printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
60 panic("Unsupported Samsung CPU");
66 /* s3c24xx_init_clocks
68 * Initialise the clock subsystem and associated information from the
69 * given master crystal value.
71 * xtal = 0 -> use default PLL crystal value (normally 12MHz)
72 * != 0 -> PLL crystal value in Hz
75 void __init s3c24xx_init_clocks(int xtal)
81 panic("s3c24xx_init_clocks: no cpu setup?\n");
83 if (cpu->init_clocks == NULL)
84 panic("s3c24xx_init_clocks: cpu has no clock init\n");
86 (cpu->init_clocks)(xtal);
91 static int nr_uarts __initdata = 0;
93 static struct s3c2410_uartcfg uart_cfgs[CONFIG_SERIAL_SAMSUNG_UARTS];
95 /* s3c24xx_init_uartdevs
97 * copy the specified platform data and configuration into our central
98 * set of devices, before the data is thrown away after the init process.
100 * This also fills in the array passed to the serial driver for the
101 * early initialisation of the console.
104 void __init s3c24xx_init_uartdevs(char *name,
105 struct s3c24xx_uart_resources *res,
106 struct s3c2410_uartcfg *cfg, int no)
108 struct platform_device *platdev;
109 struct s3c2410_uartcfg *cfgptr = uart_cfgs;
110 struct s3c24xx_uart_resources *resp;
113 memcpy(cfgptr, cfg, sizeof(struct s3c2410_uartcfg) * no);
115 for (uart = 0; uart < no; uart++, cfg++, cfgptr++) {
116 platdev = s3c24xx_uart_src[cfgptr->hwport];
118 resp = res + cfgptr->hwport;
120 s3c24xx_uart_devs[uart] = platdev;
122 platdev->name = name;
123 platdev->resource = resp->resources;
124 platdev->num_resources = resp->nr_resources;
126 platdev->dev.platform_data = cfgptr;
132 void __init s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no)
137 if (cpu->init_uarts == NULL) {
138 printk(KERN_ERR "s3c24xx_init_uarts: cpu has no uart init\n");
140 (cpu->init_uarts)(cfg, no);
143 static int __init s3c_arch_init(void)
147 // do the correct init for cpu
150 panic("s3c_arch_init: NULL cpu\n");
156 ret = platform_add_devices(s3c24xx_uart_devs, nr_uarts);
160 arch_initcall(s3c_arch_init);