1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun //
3*4882a593Smuzhiyun // Copyright (c) 2006 Simtec Electronics
4*4882a593Smuzhiyun // Ben Dooks <ben@simtec.co.uk>
5*4882a593Smuzhiyun //
6*4882a593Smuzhiyun // http://armlinux.simtec.co.uk/.
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun #include <linux/kernel.h>
9*4882a593Smuzhiyun #include <linux/types.h>
10*4882a593Smuzhiyun #include <linux/interrupt.h>
11*4882a593Smuzhiyun #include <linux/list.h>
12*4882a593Smuzhiyun #include <linux/timer.h>
13*4882a593Smuzhiyun #include <linux/init.h>
14*4882a593Smuzhiyun #include <linux/clk.h>
15*4882a593Smuzhiyun #include <linux/delay.h>
16*4882a593Smuzhiyun #include <linux/device.h>
17*4882a593Smuzhiyun #include <linux/syscore_ops.h>
18*4882a593Smuzhiyun #include <linux/serial_core.h>
19*4882a593Smuzhiyun #include <linux/serial_s3c.h>
20*4882a593Smuzhiyun #include <linux/platform_device.h>
21*4882a593Smuzhiyun #include <linux/io.h>
22*4882a593Smuzhiyun #include <linux/reboot.h>
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun #include <asm/mach/arch.h>
25*4882a593Smuzhiyun #include <asm/mach/map.h>
26*4882a593Smuzhiyun #include <asm/mach/irq.h>
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun #include <asm/proc-fns.h>
29*4882a593Smuzhiyun #include <asm/irq.h>
30*4882a593Smuzhiyun #include <asm/system_misc.h>
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun #include "map.h"
33*4882a593Smuzhiyun #include "regs-clock.h"
34*4882a593Smuzhiyun #include "regs-gpio.h"
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun #include "cpu.h"
37*4882a593Smuzhiyun #include "devs.h"
38*4882a593Smuzhiyun #include "pm.h"
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun #include "s3c24xx.h"
41*4882a593Smuzhiyun #include "nand-core-s3c24xx.h"
42*4882a593Smuzhiyun #include "regs-dsc-s3c24xx.h"
43*4882a593Smuzhiyun #include "s3c2412-power.h"
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun #ifndef CONFIG_CPU_S3C2412_ONLY
46*4882a593Smuzhiyun void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO;
47*4882a593Smuzhiyun
s3c2412_init_gpio2(void)48*4882a593Smuzhiyun static inline void s3c2412_init_gpio2(void)
49*4882a593Smuzhiyun {
50*4882a593Smuzhiyun s3c24xx_va_gpio2 = S3C24XX_VA_GPIO + 0x10;
51*4882a593Smuzhiyun }
52*4882a593Smuzhiyun #else
53*4882a593Smuzhiyun #define s3c2412_init_gpio2() do { } while(0)
54*4882a593Smuzhiyun #endif
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun /* Initial IO mappings */
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun static struct map_desc s3c2412_iodesc[] __initdata __maybe_unused = {
59*4882a593Smuzhiyun IODESC_ENT(CLKPWR),
60*4882a593Smuzhiyun IODESC_ENT(TIMER),
61*4882a593Smuzhiyun IODESC_ENT(WATCHDOG),
62*4882a593Smuzhiyun {
63*4882a593Smuzhiyun .virtual = (unsigned long)S3C2412_VA_SSMC,
64*4882a593Smuzhiyun .pfn = __phys_to_pfn(S3C2412_PA_SSMC),
65*4882a593Smuzhiyun .length = SZ_1M,
66*4882a593Smuzhiyun .type = MT_DEVICE,
67*4882a593Smuzhiyun },
68*4882a593Smuzhiyun {
69*4882a593Smuzhiyun .virtual = (unsigned long)S3C2412_VA_EBI,
70*4882a593Smuzhiyun .pfn = __phys_to_pfn(S3C2412_PA_EBI),
71*4882a593Smuzhiyun .length = SZ_1M,
72*4882a593Smuzhiyun .type = MT_DEVICE,
73*4882a593Smuzhiyun },
74*4882a593Smuzhiyun };
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun /* uart registration process */
77*4882a593Smuzhiyun
s3c2412_init_uarts(struct s3c2410_uartcfg * cfg,int no)78*4882a593Smuzhiyun void __init s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no)
79*4882a593Smuzhiyun {
80*4882a593Smuzhiyun s3c24xx_init_uartdevs("s3c2412-uart", s3c2410_uart_resources, cfg, no);
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun /* rename devices that are s3c2412/s3c2413 specific */
83*4882a593Smuzhiyun s3c_device_sdi.name = "s3c2412-sdi";
84*4882a593Smuzhiyun s3c_device_lcd.name = "s3c2412-lcd";
85*4882a593Smuzhiyun s3c_nand_setname("s3c2412-nand");
86*4882a593Smuzhiyun
87*4882a593Smuzhiyun /* alter IRQ of SDI controller */
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun s3c_device_sdi.resource[1].start = IRQ_S3C2412_SDI;
90*4882a593Smuzhiyun s3c_device_sdi.resource[1].end = IRQ_S3C2412_SDI;
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun /* spi channel related changes, s3c2412/13 specific */
93*4882a593Smuzhiyun s3c_device_spi0.name = "s3c2412-spi";
94*4882a593Smuzhiyun s3c_device_spi0.resource[0].end = S3C24XX_PA_SPI + 0x24;
95*4882a593Smuzhiyun s3c_device_spi1.name = "s3c2412-spi";
96*4882a593Smuzhiyun s3c_device_spi1.resource[0].start = S3C24XX_PA_SPI + S3C2412_SPI1;
97*4882a593Smuzhiyun s3c_device_spi1.resource[0].end = S3C24XX_PA_SPI + S3C2412_SPI1 + 0x24;
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun }
100*4882a593Smuzhiyun
101*4882a593Smuzhiyun /* s3c2412_idle
102*4882a593Smuzhiyun *
103*4882a593Smuzhiyun * use the standard idle call by ensuring the idle mode
104*4882a593Smuzhiyun * in power config, then issuing the idle co-processor
105*4882a593Smuzhiyun * instruction
106*4882a593Smuzhiyun */
107*4882a593Smuzhiyun
s3c2412_idle(void)108*4882a593Smuzhiyun static void s3c2412_idle(void)
109*4882a593Smuzhiyun {
110*4882a593Smuzhiyun unsigned long tmp;
111*4882a593Smuzhiyun
112*4882a593Smuzhiyun /* ensure our idle mode is to go to idle */
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun tmp = __raw_readl(S3C2412_PWRCFG);
115*4882a593Smuzhiyun tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
116*4882a593Smuzhiyun tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
117*4882a593Smuzhiyun __raw_writel(tmp, S3C2412_PWRCFG);
118*4882a593Smuzhiyun
119*4882a593Smuzhiyun cpu_do_idle();
120*4882a593Smuzhiyun }
121*4882a593Smuzhiyun
122*4882a593Smuzhiyun /* s3c2412_map_io
123*4882a593Smuzhiyun *
124*4882a593Smuzhiyun * register the standard cpu IO areas, and any passed in from the
125*4882a593Smuzhiyun * machine specific initialisation.
126*4882a593Smuzhiyun */
127*4882a593Smuzhiyun
s3c2412_map_io(void)128*4882a593Smuzhiyun void __init s3c2412_map_io(void)
129*4882a593Smuzhiyun {
130*4882a593Smuzhiyun /* move base of IO */
131*4882a593Smuzhiyun
132*4882a593Smuzhiyun s3c2412_init_gpio2();
133*4882a593Smuzhiyun
134*4882a593Smuzhiyun /* set our idle function */
135*4882a593Smuzhiyun
136*4882a593Smuzhiyun arm_pm_idle = s3c2412_idle;
137*4882a593Smuzhiyun
138*4882a593Smuzhiyun /* register our io-tables */
139*4882a593Smuzhiyun
140*4882a593Smuzhiyun iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc));
141*4882a593Smuzhiyun }
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun /* need to register the subsystem before we actually register the device, and
144*4882a593Smuzhiyun * we also need to ensure that it has been initialised before any of the
145*4882a593Smuzhiyun * drivers even try to use it (even if not on an s3c2412 based system)
146*4882a593Smuzhiyun * as a driver which may support both 2410 and 2440 may try and use it.
147*4882a593Smuzhiyun */
148*4882a593Smuzhiyun
149*4882a593Smuzhiyun struct bus_type s3c2412_subsys = {
150*4882a593Smuzhiyun .name = "s3c2412-core",
151*4882a593Smuzhiyun .dev_name = "s3c2412-core",
152*4882a593Smuzhiyun };
153*4882a593Smuzhiyun
s3c2412_core_init(void)154*4882a593Smuzhiyun static int __init s3c2412_core_init(void)
155*4882a593Smuzhiyun {
156*4882a593Smuzhiyun return subsys_system_register(&s3c2412_subsys, NULL);
157*4882a593Smuzhiyun }
158*4882a593Smuzhiyun
159*4882a593Smuzhiyun core_initcall(s3c2412_core_init);
160*4882a593Smuzhiyun
161*4882a593Smuzhiyun static struct device s3c2412_dev = {
162*4882a593Smuzhiyun .bus = &s3c2412_subsys,
163*4882a593Smuzhiyun };
164*4882a593Smuzhiyun
s3c2412_init(void)165*4882a593Smuzhiyun int __init s3c2412_init(void)
166*4882a593Smuzhiyun {
167*4882a593Smuzhiyun printk("S3C2412: Initialising architecture\n");
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun #ifdef CONFIG_PM_SLEEP
170*4882a593Smuzhiyun register_syscore_ops(&s3c2412_pm_syscore_ops);
171*4882a593Smuzhiyun register_syscore_ops(&s3c24xx_irq_syscore_ops);
172*4882a593Smuzhiyun #endif
173*4882a593Smuzhiyun
174*4882a593Smuzhiyun return device_register(&s3c2412_dev);
175*4882a593Smuzhiyun }
176