blob: 35f4addd110b556b4deec18f72b76d4b9685eae2 [file] [log] [blame]
Krzysztof Kozlowski84b21702017-12-25 20:54:32 +01001// SPDX-License-Identifier: GPL-2.0
2//
3// Copyright (c) 2006 Simtec Electronics
4// Ben Dooks <ben@simtec.co.uk>
5//
6// http://armlinux.simtec.co.uk/.
Ben Dooks68d9ab32006-06-24 21:21:27 +01007
8#include <linux/kernel.h>
9#include <linux/types.h>
10#include <linux/interrupt.h>
11#include <linux/list.h>
12#include <linux/timer.h>
13#include <linux/init.h>
Ben Dookse4253822008-10-21 14:06:38 +010014#include <linux/clk.h>
Ben Dookseca8c242007-05-28 18:19:16 +010015#include <linux/delay.h>
Kay Sievers4a858cf2011-12-21 16:01:38 -080016#include <linux/device.h>
Rafael J. Wysockibb072c32011-04-22 22:03:21 +020017#include <linux/syscore_ops.h>
Ben Dooksb6d1f542006-12-17 23:22:26 +010018#include <linux/serial_core.h>
Tushar Behera334a1c72014-02-14 10:32:45 +090019#include <linux/serial_s3c.h>
Ben Dooks68d9ab32006-06-24 21:21:27 +010020#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010021#include <linux/io.h>
Robin Holt7b6d8642013-07-08 16:01:40 -070022#include <linux/reboot.h>
Ben Dooks68d9ab32006-06-24 21:21:27 +010023
24#include <asm/mach/arch.h>
25#include <asm/mach/map.h>
26#include <asm/mach/irq.h>
27
Ben Dooksc84cbb22006-09-14 13:29:15 +010028#include <asm/proc-fns.h>
Ben Dooks68d9ab32006-06-24 21:21:27 +010029#include <asm/irq.h>
David Howells9f97da72012-03-28 18:30:01 +010030#include <asm/system_misc.h>
Ben Dooks68d9ab32006-06-24 21:21:27 +010031
Arnd Bergmannc6ff1322019-09-02 18:37:30 +020032#include "map.h"
33#include "regs-clock.h"
34#include "regs-gpio.h"
Ben Dooks68d9ab32006-06-24 21:21:27 +010035
Arnd Bergmannc6ff1322019-09-02 18:37:30 +020036#include "cpu.h"
37#include "devs.h"
38#include "pm.h"
Kukjin Kimfd4e5a52013-01-02 11:04:57 -080039
Arnd Bergmann71b91142019-09-02 17:47:55 +020040#include "s3c24xx.h"
41#include "nand-core-s3c24xx.h"
42#include "regs-dsc-s3c24xx.h"
Kukjin Kim14cce0e2013-02-01 21:49:35 -080043#include "s3c2412-power.h"
Kukjin Kimb4353782013-01-02 14:01:09 -080044
Ben Dooks68d9ab32006-06-24 21:21:27 +010045#ifndef CONFIG_CPU_S3C2412_ONLY
46void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO;
Ben Dooks50dedf12006-09-18 10:19:06 +010047
48static inline void s3c2412_init_gpio2(void)
49{
50 s3c24xx_va_gpio2 = S3C24XX_VA_GPIO + 0x10;
51}
52#else
53#define s3c2412_init_gpio2() do { } while(0)
Ben Dooks68d9ab32006-06-24 21:21:27 +010054#endif
55
56/* Initial IO mappings */
57
58static struct map_desc s3c2412_iodesc[] __initdata = {
59 IODESC_ENT(CLKPWR),
Ben Dooks68d9ab32006-06-24 21:21:27 +010060 IODESC_ENT(TIMER),
Ben Dooks68d9ab32006-06-24 21:21:27 +010061 IODESC_ENT(WATCHDOG),
Ben Dooks25400032009-07-30 23:23:36 +010062 {
63 .virtual = (unsigned long)S3C2412_VA_SSMC,
64 .pfn = __phys_to_pfn(S3C2412_PA_SSMC),
65 .length = SZ_1M,
66 .type = MT_DEVICE,
67 },
68 {
69 .virtual = (unsigned long)S3C2412_VA_EBI,
70 .pfn = __phys_to_pfn(S3C2412_PA_EBI),
71 .length = SZ_1M,
72 .type = MT_DEVICE,
73 },
Ben Dooks68d9ab32006-06-24 21:21:27 +010074};
75
76/* uart registration process */
77
78void __init s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no)
79{
80 s3c24xx_init_uartdevs("s3c2412-uart", s3c2410_uart_resources, cfg, no);
81
82 /* rename devices that are s3c2412/s3c2413 specific */
83 s3c_device_sdi.name = "s3c2412-sdi";
Ben Dooks72d70d02006-09-20 20:46:09 +010084 s3c_device_lcd.name = "s3c2412-lcd";
Atul Dahiyaef3f2dd2010-10-18 19:56:45 +090085 s3c_nand_setname("s3c2412-nand");
Sandeep Sanjay Patile9033822007-05-16 10:51:45 +010086
Ben Dooksf3fb5a52007-10-04 21:41:20 +010087 /* alter IRQ of SDI controller */
88
89 s3c_device_sdi.resource[1].start = IRQ_S3C2412_SDI;
90 s3c_device_sdi.resource[1].end = IRQ_S3C2412_SDI;
91
Sandeep Sanjay Patile9033822007-05-16 10:51:45 +010092 /* spi channel related changes, s3c2412/13 specific */
93 s3c_device_spi0.name = "s3c2412-spi";
94 s3c_device_spi0.resource[0].end = S3C24XX_PA_SPI + 0x24;
95 s3c_device_spi1.name = "s3c2412-spi";
96 s3c_device_spi1.resource[0].start = S3C24XX_PA_SPI + S3C2412_SPI1;
97 s3c_device_spi1.resource[0].end = S3C24XX_PA_SPI + S3C2412_SPI1 + 0x24;
98
Ben Dooks68d9ab32006-06-24 21:21:27 +010099}
100
Ben Dooksc84cbb22006-09-14 13:29:15 +0100101/* s3c2412_idle
102 *
103 * use the standard idle call by ensuring the idle mode
104 * in power config, then issuing the idle co-processor
105 * instruction
106*/
107
108static void s3c2412_idle(void)
109{
110 unsigned long tmp;
111
112 /* ensure our idle mode is to go to idle */
113
114 tmp = __raw_readl(S3C2412_PWRCFG);
115 tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
116 tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
117 __raw_writel(tmp, S3C2412_PWRCFG);
118
119 cpu_do_idle();
120}
121
Ben Dooks68d9ab32006-06-24 21:21:27 +0100122/* s3c2412_map_io
123 *
124 * register the standard cpu IO areas, and any passed in from the
125 * machine specific initialisation.
126*/
127
Ben Dooks74b265d2008-10-21 14:06:31 +0100128void __init s3c2412_map_io(void)
Ben Dooks68d9ab32006-06-24 21:21:27 +0100129{
130 /* move base of IO */
131
Ben Dooks50dedf12006-09-18 10:19:06 +0100132 s3c2412_init_gpio2();
Ben Dooks68d9ab32006-06-24 21:21:27 +0100133
Ben Dooksc84cbb22006-09-14 13:29:15 +0100134 /* set our idle function */
135
Nicolas Pitre92311272011-08-03 11:34:59 -0400136 arm_pm_idle = s3c2412_idle;
Ben Dooksc84cbb22006-09-14 13:29:15 +0100137
Ben Dooks68d9ab32006-06-24 21:21:27 +0100138 /* register our io-tables */
139
140 iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc));
Ben Dooks68d9ab32006-06-24 21:21:27 +0100141}
142
Kay Sievers4a858cf2011-12-21 16:01:38 -0800143/* need to register the subsystem before we actually register the device, and
Ben Dooks68d9ab32006-06-24 21:21:27 +0100144 * we also need to ensure that it has been initialised before any of the
145 * drivers even try to use it (even if not on an s3c2412 based system)
146 * as a driver which may support both 2410 and 2440 may try and use it.
147*/
148
Kay Sievers4a858cf2011-12-21 16:01:38 -0800149struct bus_type s3c2412_subsys = {
Kay Sieversaf5ca3f42007-12-20 02:09:39 +0100150 .name = "s3c2412-core",
Kay Sievers4a858cf2011-12-21 16:01:38 -0800151 .dev_name = "s3c2412-core",
Ben Dooks68d9ab32006-06-24 21:21:27 +0100152};
153
154static int __init s3c2412_core_init(void)
155{
Kay Sievers4a858cf2011-12-21 16:01:38 -0800156 return subsys_system_register(&s3c2412_subsys, NULL);
Ben Dooks68d9ab32006-06-24 21:21:27 +0100157}
158
159core_initcall(s3c2412_core_init);
160
Kay Sievers4a858cf2011-12-21 16:01:38 -0800161static struct device s3c2412_dev = {
162 .bus = &s3c2412_subsys,
Ben Dooks68d9ab32006-06-24 21:21:27 +0100163};
164
165int __init s3c2412_init(void)
166{
167 printk("S3C2412: Initialising architecture\n");
168
Arnd Bergmann4f506da2015-02-27 05:50:22 +0900169#ifdef CONFIG_PM_SLEEP
Rafael J. Wysockibb072c32011-04-22 22:03:21 +0200170 register_syscore_ops(&s3c2412_pm_syscore_ops);
171 register_syscore_ops(&s3c24xx_irq_syscore_ops);
Heiko Stuebnerd8fdec12013-01-29 10:25:22 -0800172#endif
Rafael J. Wysockibb072c32011-04-22 22:03:21 +0200173
Kay Sievers4a858cf2011-12-21 16:01:38 -0800174 return device_register(&s3c2412_dev);
Ben Dooks68d9ab32006-06-24 21:21:27 +0100175}