blob: fb5ee8d389136dc4d5bfc5a52b86509211472569 [file] [log] [blame]
Kukjin Kimfd4e5a52013-01-02 11:04:57 -08001/*
Ben Dooks68d9ab32006-06-24 21:21:27 +01002 * Copyright (c) 2006 Simtec Electronics
3 * Ben Dooks <ben@simtec.co.uk>
4 *
5 * http://armlinux.simtec.co.uk/.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
Ben Dooks68d9ab32006-06-24 21:21:27 +010010*/
11
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/interrupt.h>
15#include <linux/list.h>
16#include <linux/timer.h>
17#include <linux/init.h>
Ben Dookse4253822008-10-21 14:06:38 +010018#include <linux/clk.h>
Ben Dookseca8c242007-05-28 18:19:16 +010019#include <linux/delay.h>
Kay Sievers4a858cf2011-12-21 16:01:38 -080020#include <linux/device.h>
Rafael J. Wysockibb072c32011-04-22 22:03:21 +020021#include <linux/syscore_ops.h>
Ben Dooksb6d1f542006-12-17 23:22:26 +010022#include <linux/serial_core.h>
Tushar Behera334a1c72014-02-14 10:32:45 +090023#include <linux/serial_s3c.h>
Ben Dooks68d9ab32006-06-24 21:21:27 +010024#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010025#include <linux/io.h>
Robin Holt7b6d8642013-07-08 16:01:40 -070026#include <linux/reboot.h>
Ben Dooks68d9ab32006-06-24 21:21:27 +010027
28#include <asm/mach/arch.h>
29#include <asm/mach/map.h>
30#include <asm/mach/irq.h>
31
Ben Dooksc84cbb22006-09-14 13:29:15 +010032#include <asm/proc-fns.h>
Ben Dooks68d9ab32006-06-24 21:21:27 +010033#include <asm/irq.h>
David Howells9f97da72012-03-28 18:30:01 +010034#include <asm/system_misc.h>
Ben Dooks68d9ab32006-06-24 21:21:27 +010035
Kukjin Kimfd4e5a52013-01-02 11:04:57 -080036#include <mach/hardware.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010037#include <mach/regs-clock.h>
Kukjin Kimfd4e5a52013-01-02 11:04:57 -080038#include <mach/regs-gpio.h>
Ben Dooks68d9ab32006-06-24 21:21:27 +010039
Kukjin Kimfd4e5a52013-01-02 11:04:57 -080040#include <plat/cpu.h>
41#include <plat/cpu-freq.h>
42#include <plat/devs.h>
Kukjin Kimfd4e5a52013-01-02 11:04:57 -080043#include <plat/pm.h>
Kukjin Kimfd4e5a52013-01-02 11:04:57 -080044#include <plat/regs-spi.h>
Kukjin Kimfd4e5a52013-01-02 11:04:57 -080045
Heiko Stuebnerd8fdec12013-01-29 10:25:22 -080046#include "common.h"
Kukjin Kimf8eed6c2015-07-30 02:00:35 +090047#include "nand-core.h"
Kukjin Kimb4353782013-01-02 14:01:09 -080048#include "regs-dsc.h"
Kukjin Kim14cce0e2013-02-01 21:49:35 -080049#include "s3c2412-power.h"
Kukjin Kimb4353782013-01-02 14:01:09 -080050
Ben Dooks68d9ab32006-06-24 21:21:27 +010051#ifndef CONFIG_CPU_S3C2412_ONLY
52void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO;
Ben Dooks50dedf12006-09-18 10:19:06 +010053
54static inline void s3c2412_init_gpio2(void)
55{
56 s3c24xx_va_gpio2 = S3C24XX_VA_GPIO + 0x10;
57}
58#else
59#define s3c2412_init_gpio2() do { } while(0)
Ben Dooks68d9ab32006-06-24 21:21:27 +010060#endif
61
62/* Initial IO mappings */
63
64static struct map_desc s3c2412_iodesc[] __initdata = {
65 IODESC_ENT(CLKPWR),
Ben Dooks68d9ab32006-06-24 21:21:27 +010066 IODESC_ENT(TIMER),
Ben Dooks68d9ab32006-06-24 21:21:27 +010067 IODESC_ENT(WATCHDOG),
Ben Dooks25400032009-07-30 23:23:36 +010068 {
69 .virtual = (unsigned long)S3C2412_VA_SSMC,
70 .pfn = __phys_to_pfn(S3C2412_PA_SSMC),
71 .length = SZ_1M,
72 .type = MT_DEVICE,
73 },
74 {
75 .virtual = (unsigned long)S3C2412_VA_EBI,
76 .pfn = __phys_to_pfn(S3C2412_PA_EBI),
77 .length = SZ_1M,
78 .type = MT_DEVICE,
79 },
Ben Dooks68d9ab32006-06-24 21:21:27 +010080};
81
82/* uart registration process */
83
84void __init s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no)
85{
86 s3c24xx_init_uartdevs("s3c2412-uart", s3c2410_uart_resources, cfg, no);
87
88 /* rename devices that are s3c2412/s3c2413 specific */
89 s3c_device_sdi.name = "s3c2412-sdi";
Ben Dooks72d70d02006-09-20 20:46:09 +010090 s3c_device_lcd.name = "s3c2412-lcd";
Atul Dahiyaef3f2dd2010-10-18 19:56:45 +090091 s3c_nand_setname("s3c2412-nand");
Sandeep Sanjay Patile9033822007-05-16 10:51:45 +010092
Ben Dooksf3fb5a52007-10-04 21:41:20 +010093 /* alter IRQ of SDI controller */
94
95 s3c_device_sdi.resource[1].start = IRQ_S3C2412_SDI;
96 s3c_device_sdi.resource[1].end = IRQ_S3C2412_SDI;
97
Sandeep Sanjay Patile9033822007-05-16 10:51:45 +010098 /* spi channel related changes, s3c2412/13 specific */
99 s3c_device_spi0.name = "s3c2412-spi";
100 s3c_device_spi0.resource[0].end = S3C24XX_PA_SPI + 0x24;
101 s3c_device_spi1.name = "s3c2412-spi";
102 s3c_device_spi1.resource[0].start = S3C24XX_PA_SPI + S3C2412_SPI1;
103 s3c_device_spi1.resource[0].end = S3C24XX_PA_SPI + S3C2412_SPI1 + 0x24;
104
Ben Dooks68d9ab32006-06-24 21:21:27 +0100105}
106
Ben Dooksc84cbb22006-09-14 13:29:15 +0100107/* s3c2412_idle
108 *
109 * use the standard idle call by ensuring the idle mode
110 * in power config, then issuing the idle co-processor
111 * instruction
112*/
113
114static void s3c2412_idle(void)
115{
116 unsigned long tmp;
117
118 /* ensure our idle mode is to go to idle */
119
120 tmp = __raw_readl(S3C2412_PWRCFG);
121 tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
122 tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
123 __raw_writel(tmp, S3C2412_PWRCFG);
124
125 cpu_do_idle();
126}
127
Ben Dooks68d9ab32006-06-24 21:21:27 +0100128/* s3c2412_map_io
129 *
130 * register the standard cpu IO areas, and any passed in from the
131 * machine specific initialisation.
132*/
133
Ben Dooks74b265d2008-10-21 14:06:31 +0100134void __init s3c2412_map_io(void)
Ben Dooks68d9ab32006-06-24 21:21:27 +0100135{
136 /* move base of IO */
137
Ben Dooks50dedf12006-09-18 10:19:06 +0100138 s3c2412_init_gpio2();
Ben Dooks68d9ab32006-06-24 21:21:27 +0100139
Ben Dooksc84cbb22006-09-14 13:29:15 +0100140 /* set our idle function */
141
Nicolas Pitre92311272011-08-03 11:34:59 -0400142 arm_pm_idle = s3c2412_idle;
Ben Dooksc84cbb22006-09-14 13:29:15 +0100143
Ben Dooks68d9ab32006-06-24 21:21:27 +0100144 /* register our io-tables */
145
146 iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc));
Ben Dooks68d9ab32006-06-24 21:21:27 +0100147}
148
Kay Sievers4a858cf2011-12-21 16:01:38 -0800149/* need to register the subsystem before we actually register the device, and
Ben Dooks68d9ab32006-06-24 21:21:27 +0100150 * we also need to ensure that it has been initialised before any of the
151 * drivers even try to use it (even if not on an s3c2412 based system)
152 * as a driver which may support both 2410 and 2440 may try and use it.
153*/
154
Kay Sievers4a858cf2011-12-21 16:01:38 -0800155struct bus_type s3c2412_subsys = {
Kay Sieversaf5ca3f2007-12-20 02:09:39 +0100156 .name = "s3c2412-core",
Kay Sievers4a858cf2011-12-21 16:01:38 -0800157 .dev_name = "s3c2412-core",
Ben Dooks68d9ab32006-06-24 21:21:27 +0100158};
159
160static int __init s3c2412_core_init(void)
161{
Kay Sievers4a858cf2011-12-21 16:01:38 -0800162 return subsys_system_register(&s3c2412_subsys, NULL);
Ben Dooks68d9ab32006-06-24 21:21:27 +0100163}
164
165core_initcall(s3c2412_core_init);
166
Kay Sievers4a858cf2011-12-21 16:01:38 -0800167static struct device s3c2412_dev = {
168 .bus = &s3c2412_subsys,
Ben Dooks68d9ab32006-06-24 21:21:27 +0100169};
170
171int __init s3c2412_init(void)
172{
173 printk("S3C2412: Initialising architecture\n");
174
Arnd Bergmann4f506da2015-02-27 05:50:22 +0900175#ifdef CONFIG_PM_SLEEP
Rafael J. Wysockibb072c32011-04-22 22:03:21 +0200176 register_syscore_ops(&s3c2412_pm_syscore_ops);
177 register_syscore_ops(&s3c24xx_irq_syscore_ops);
Heiko Stuebnerd8fdec12013-01-29 10:25:22 -0800178#endif
Rafael J. Wysockibb072c32011-04-22 22:03:21 +0200179
Kay Sievers4a858cf2011-12-21 16:01:38 -0800180 return device_register(&s3c2412_dev);
Ben Dooks68d9ab32006-06-24 21:21:27 +0100181}