1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright (c) 2008 Simtec Electronics
4 // Ben Dooks <ben@simtec.co.uk>
5 // http://armlinux.simtec.co.uk/
7 // S3C series CPU initialisation
10 * NOTE: Code in this file is not used on S3C64xx when booting with
11 * Device Tree support.
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/serial_s3c.h>
20 #include <linux/platform_device.h>
23 #include <asm/mach/arch.h>
24 #include <asm/mach/map.h>
29 static struct cpu_table *cpu;
31 static struct cpu_table * __init s3c_lookup_cpu(unsigned long idcode,
32 struct cpu_table *tab,
35 for (; count != 0; count--, tab++) {
36 if ((idcode & tab->idmask) == (tab->idcode & tab->idmask))
43 void __init s3c_init_cpu(unsigned long idcode,
44 struct cpu_table *cputab, unsigned int cputab_size)
46 cpu = s3c_lookup_cpu(idcode, cputab, cputab_size);
49 printk(KERN_ERR "Unknown CPU type 0x%08lx\n", idcode);
50 panic("Unknown S3C24XX CPU");
53 printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
55 if (cpu->init == NULL) {
56 printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
57 panic("Unsupported Samsung CPU");
63 pr_err("The platform is deprecated and scheduled for removal. Please reach to the maintainers of the platform and linux-samsung-soc@vger.kernel.org if you still use it. Without such feedback, the platform will be removed after 2022.\n");
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);
90 #if IS_ENABLED(CONFIG_SAMSUNG_ATAGS)
91 static int nr_uarts __initdata = 0;
93 #ifdef CONFIG_SERIAL_SAMSUNG_UARTS
94 static struct s3c2410_uartcfg uart_cfgs[CONFIG_SERIAL_SAMSUNG_UARTS];
97 /* s3c24xx_init_uartdevs
99 * copy the specified platform data and configuration into our central
100 * set of devices, before the data is thrown away after the init process.
102 * This also fills in the array passed to the serial driver for the
103 * early initialisation of the console.
106 void __init s3c24xx_init_uartdevs(char *name,
107 struct s3c24xx_uart_resources *res,
108 struct s3c2410_uartcfg *cfg, int no)
110 #ifdef CONFIG_SERIAL_SAMSUNG_UARTS
111 struct platform_device *platdev;
112 struct s3c2410_uartcfg *cfgptr = uart_cfgs;
113 struct s3c24xx_uart_resources *resp;
116 memcpy(cfgptr, cfg, sizeof(struct s3c2410_uartcfg) * no);
118 for (uart = 0; uart < no; uart++, cfg++, cfgptr++) {
119 platdev = s3c24xx_uart_src[cfgptr->hwport];
121 resp = res + cfgptr->hwport;
123 s3c24xx_uart_devs[uart] = platdev;
125 platdev->name = name;
126 platdev->resource = resp->resources;
127 platdev->num_resources = resp->nr_resources;
129 platdev->dev.platform_data = cfgptr;
136 void __init s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no)
141 if (cpu->init_uarts == NULL && IS_ENABLED(CONFIG_SAMSUNG_ATAGS)) {
142 printk(KERN_ERR "s3c24xx_init_uarts: cpu has no uart init\n");
144 (cpu->init_uarts)(cfg, no);
148 static int __init s3c_arch_init(void)
152 /* init is only needed for ATAGS based platforms */
153 if (!IS_ENABLED(CONFIG_ATAGS) ||
154 (!soc_is_s3c24xx() && !soc_is_s3c64xx()))
157 // do the correct init for cpu
160 /* Not needed when booting with device tree. */
161 if (of_have_populated_dt())
163 panic("s3c_arch_init: NULL cpu\n");
169 #if IS_ENABLED(CONFIG_SAMSUNG_ATAGS)
170 ret = platform_add_devices(s3c24xx_uart_devs, nr_uarts);
175 arch_initcall(s3c_arch_init);