blob: 6a41bf7dacf6b8f7de9f491d1858ad590ae27264 [file] [log] [blame]
Kukjin Kimdd4153d2011-12-22 23:31:28 +01001/*
2 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
Kukjin Kim19a2c062010-08-31 16:30:51 +09003 * http://www.samsung.com
4 *
Byungho Min8acd1ad2009-06-23 21:40:15 +09005 * Copyright 2009 Samsung Electronics Co.
6 * Byungho Min <bhmin@samsung.com>
7 *
Kukjin Kimdd4153d2011-12-22 23:31:28 +01008 * Common Codes for S5PC100
Byungho Min8acd1ad2009-06-23 21:40:15 +09009 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
Kukjin Kimdd4153d2011-12-22 23:31:28 +010013 */
Byungho Min8acd1ad2009-06-23 21:40:15 +090014
15#include <linux/kernel.h>
16#include <linux/types.h>
17#include <linux/interrupt.h>
18#include <linux/list.h>
19#include <linux/timer.h>
20#include <linux/init.h>
21#include <linux/clk.h>
22#include <linux/io.h>
Kay Sievers4a858cf2011-12-21 16:01:38 -080023#include <linux/device.h>
Byungho Min8acd1ad2009-06-23 21:40:15 +090024#include <linux/serial_core.h>
Tushar Behera334a1c72014-02-14 10:32:45 +090025#include <linux/serial_s3c.h>
Tomasz Figa1c161fd2013-04-12 21:17:22 +020026#include <clocksource/samsung_pwm.h>
Byungho Min8acd1ad2009-06-23 21:40:15 +090027#include <linux/platform_device.h>
SeungChull Suh4341f9b2010-10-02 12:48:12 +090028#include <linux/sched.h>
Robin Holt7b6d8642013-07-08 16:01:40 -070029#include <linux/reboot.h>
Byungho Min8acd1ad2009-06-23 21:40:15 +090030
Kukjin Kimdd4153d2011-12-22 23:31:28 +010031#include <asm/irq.h>
32#include <asm/proc-fns.h>
David Howells9f97da72012-03-28 18:30:01 +010033#include <asm/system_misc.h>
Byungho Min8acd1ad2009-06-23 21:40:15 +090034#include <asm/mach/arch.h>
35#include <asm/mach/map.h>
36#include <asm/mach/irq.h>
37
Byungho Min8acd1ad2009-06-23 21:40:15 +090038#include <mach/map.h>
Kukjin Kimdd4153d2011-12-22 23:31:28 +010039#include <mach/hardware.h>
Marek Szyprowskiacc84702010-05-20 07:51:08 +020040#include <mach/regs-clock.h>
Byungho Min8acd1ad2009-06-23 21:40:15 +090041
42#include <plat/cpu.h>
43#include <plat/devs.h>
44#include <plat/clock.h>
Marek Szyprowskiacc84702010-05-20 07:51:08 +020045#include <plat/sdhci.h>
Naveen Krishna Ch327b9032010-06-30 21:50:24 +090046#include <plat/adc-core.h>
Kukjin Kimdd4153d2011-12-22 23:31:28 +010047#include <plat/ata-core.h>
Pawel Osciakeb42b042010-08-10 18:02:37 -070048#include <plat/fb-core.h>
Kukjin Kimdd4153d2011-12-22 23:31:28 +010049#include <plat/iic-core.h>
50#include <plat/onenand-core.h>
Tomasz Figa1c161fd2013-04-12 21:17:22 +020051#include <plat/pwm-core.h>
Heiko Stuebner308b3af2012-10-17 16:47:11 +090052#include <plat/spi-core.h>
Kukjin Kim5497d2e2011-12-22 23:35:21 +010053#include <plat/watchdog-reset.h>
Marek Szyprowski999304b2010-05-20 08:59:05 +020054
Kukjin Kimdd4153d2011-12-22 23:31:28 +010055#include "common.h"
56
57static const char name_s5pc100[] = "S5PC100";
58
59static struct cpu_table cpu_ids[] __initdata = {
60 {
61 .idcode = S5PC100_CPU_ID,
62 .idmask = S5PC100_CPU_MASK,
63 .map_io = s5pc100_map_io,
64 .init_clocks = s5pc100_init_clocks,
65 .init_uarts = s5pc100_init_uarts,
66 .init = s5pc100_init,
67 .name = name_s5pc100,
68 },
69};
Byungho Min8acd1ad2009-06-23 21:40:15 +090070
71/* Initial IO mappings */
72
73static struct map_desc s5pc100_iodesc[] __initdata = {
Marek Szyprowskiacc84702010-05-20 07:51:08 +020074 {
Kukjin Kimdd4153d2011-12-22 23:31:28 +010075 .virtual = (unsigned long)S5P_VA_CHIPID,
76 .pfn = __phys_to_pfn(S5PC100_PA_CHIPID),
77 .length = SZ_4K,
78 .type = MT_DEVICE,
79 }, {
80 .virtual = (unsigned long)S3C_VA_SYS,
81 .pfn = __phys_to_pfn(S5PC100_PA_SYSCON),
82 .length = SZ_64K,
83 .type = MT_DEVICE,
84 }, {
85 .virtual = (unsigned long)S3C_VA_TIMER,
86 .pfn = __phys_to_pfn(S5PC100_PA_TIMER),
87 .length = SZ_16K,
88 .type = MT_DEVICE,
89 }, {
90 .virtual = (unsigned long)S3C_VA_WATCHDOG,
91 .pfn = __phys_to_pfn(S5PC100_PA_WATCHDOG),
92 .length = SZ_4K,
93 .type = MT_DEVICE,
94 }, {
95 .virtual = (unsigned long)S5P_VA_SROMC,
96 .pfn = __phys_to_pfn(S5PC100_PA_SROMC),
97 .length = SZ_4K,
98 .type = MT_DEVICE,
99 }, {
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200100 .virtual = (unsigned long)S5P_VA_SYSTIMER,
101 .pfn = __phys_to_pfn(S5PC100_PA_SYSTIMER),
102 .length = SZ_16K,
103 .type = MT_DEVICE,
104 }, {
Kukjin Kim19a2c062010-08-31 16:30:51 +0900105 .virtual = (unsigned long)S5P_VA_GPIO,
106 .pfn = __phys_to_pfn(S5PC100_PA_GPIO),
107 .length = SZ_4K,
108 .type = MT_DEVICE,
109 }, {
110 .virtual = (unsigned long)VA_VIC0,
111 .pfn = __phys_to_pfn(S5PC100_PA_VIC0),
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200112 .length = SZ_16K,
113 .type = MT_DEVICE,
114 }, {
Kukjin Kim19a2c062010-08-31 16:30:51 +0900115 .virtual = (unsigned long)VA_VIC1,
116 .pfn = __phys_to_pfn(S5PC100_PA_VIC1),
117 .length = SZ_16K,
118 .type = MT_DEVICE,
119 }, {
120 .virtual = (unsigned long)VA_VIC2,
121 .pfn = __phys_to_pfn(S5PC100_PA_VIC2),
122 .length = SZ_16K,
123 .type = MT_DEVICE,
124 }, {
125 .virtual = (unsigned long)S3C_VA_UART,
126 .pfn = __phys_to_pfn(S3C_PA_UART),
127 .length = SZ_512K,
128 .type = MT_DEVICE,
129 }, {
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200130 .virtual = (unsigned long)S5PC100_VA_OTHERS,
131 .pfn = __phys_to_pfn(S5PC100_PA_OTHERS),
132 .length = SZ_4K,
133 .type = MT_DEVICE,
134 }
Byungho Min8acd1ad2009-06-23 21:40:15 +0900135};
136
Tomasz Figa1c161fd2013-04-12 21:17:22 +0200137static struct samsung_pwm_variant s5pc100_pwm_variant = {
138 .bits = 32,
139 .div_base = 0,
140 .has_tint_cstat = true,
141 .tclk_mask = (1 << 5),
142};
143
Tomasz Figa42805062013-04-28 02:25:01 +0200144void __init samsung_set_timer_source(unsigned int event, unsigned int source)
145{
146 s5pc100_pwm_variant.output_mask = BIT(SAMSUNG_PWM_NUM) - 1;
147 s5pc100_pwm_variant.output_mask &= ~(BIT(event) | BIT(source));
148}
149
150void __init samsung_timer_init(void)
151{
152 unsigned int timer_irqs[SAMSUNG_PWM_NUM] = {
153 IRQ_TIMER0_VIC, IRQ_TIMER1_VIC, IRQ_TIMER2_VIC,
154 IRQ_TIMER3_VIC, IRQ_TIMER4_VIC,
155 };
156
157 samsung_pwm_clocksource_init(S3C_VA_TIMER,
158 timer_irqs, &s5pc100_pwm_variant);
159}
160
Kukjin Kimdd4153d2011-12-22 23:31:28 +0100161/*
162 * s5pc100_map_io
Byungho Min8acd1ad2009-06-23 21:40:15 +0900163 *
Kukjin Kimdd4153d2011-12-22 23:31:28 +0100164 * register the standard CPU IO areas
165 */
166
167void __init s5pc100_init_io(struct map_desc *mach_desc, int size)
168{
169 /* initialize the io descriptors we need for initialization */
170 iotable_init(s5pc100_iodesc, ARRAY_SIZE(s5pc100_iodesc));
171 if (mach_desc)
172 iotable_init(mach_desc, size);
173
174 /* detect cpu id and rev. */
175 s5p_init_cpu(S5P_VA_CHIPID);
176
177 s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
Tomasz Figa1c161fd2013-04-12 21:17:22 +0200178
179 samsung_pwm_set_platdata(&s5pc100_pwm_variant);
Kukjin Kimdd4153d2011-12-22 23:31:28 +0100180}
Byungho Min8acd1ad2009-06-23 21:40:15 +0900181
182void __init s5pc100_map_io(void)
183{
Byungho Min8acd1ad2009-06-23 21:40:15 +0900184 /* initialise device information early */
Kyungmin Park86cd4f52009-11-17 08:41:23 +0100185 s5pc100_default_sdhci0();
186 s5pc100_default_sdhci1();
187 s5pc100_default_sdhci2();
Kyungmin Park5eda2882009-11-17 08:41:21 +0100188
Naveen Krishna Ch327b9032010-06-30 21:50:24 +0900189 s3c_adc_setname("s3c64xx-adc");
190
Kyungmin Park5eda2882009-11-17 08:41:21 +0100191 /* the i2c devices are directly compatible with s3c2440 */
192 s3c_i2c0_setname("s3c2440-i2c");
193 s3c_i2c1_setname("s3c2440-i2c");
Marek Szyprowski999304b2010-05-20 08:59:05 +0200194
195 s3c_onenand_setname("s5pc100-onenand");
Pawel Osciakeb42b042010-08-10 18:02:37 -0700196 s3c_fb_setname("s5pc100-fb");
Abhilash Kesavan66194a72010-06-08 17:02:08 +0900197 s3c_cfcon_setname("s5pc100-pata");
Heiko Stuebner308b3af2012-10-17 16:47:11 +0900198
199 s3c64xx_spi_setname("s5pc100-spi");
Byungho Min8acd1ad2009-06-23 21:40:15 +0900200}
201
202void __init s5pc100_init_clocks(int xtal)
203{
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200204 printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
205
Byungho Min8acd1ad2009-06-23 21:40:15 +0900206 s3c24xx_register_baseclocks(xtal);
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200207 s5p_register_clocks(xtal);
Byungho Min8acd1ad2009-06-23 21:40:15 +0900208 s5pc100_register_clocks();
209 s5pc100_setup_clocks();
Tomasz Figa88f59732013-06-17 23:45:37 +0900210 samsung_wdt_reset_init(S3C_VA_WATCHDOG);
Byungho Min8acd1ad2009-06-23 21:40:15 +0900211}
212
213void __init s5pc100_init_irq(void)
214{
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200215 u32 vic[] = {~0, ~0, ~0};
Byungho Min8acd1ad2009-06-23 21:40:15 +0900216
217 /* VIC0, VIC1, and VIC2 are fully populated. */
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200218 s5p_init_irq(vic, ARRAY_SIZE(vic));
Byungho Min8acd1ad2009-06-23 21:40:15 +0900219}
220
Kay Sievers4a858cf2011-12-21 16:01:38 -0800221static struct bus_type s5pc100_subsys = {
222 .name = "s5pc100-core",
223 .dev_name = "s5pc100-core",
Byungho Min8acd1ad2009-06-23 21:40:15 +0900224};
225
Kay Sievers4a858cf2011-12-21 16:01:38 -0800226static struct device s5pc100_dev = {
227 .bus = &s5pc100_subsys,
Byungho Min8acd1ad2009-06-23 21:40:15 +0900228};
229
230static int __init s5pc100_core_init(void)
231{
Kay Sievers4a858cf2011-12-21 16:01:38 -0800232 return subsys_system_register(&s5pc100_subsys, NULL);
Byungho Min8acd1ad2009-06-23 21:40:15 +0900233}
Byungho Min8acd1ad2009-06-23 21:40:15 +0900234core_initcall(s5pc100_core_init);
235
236int __init s5pc100_init(void)
237{
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200238 printk(KERN_INFO "S5PC100: Initializing architecture\n");
Kukjin Kimea040182012-01-06 16:08:09 +0900239 return device_register(&s5pc100_dev);
Byungho Min8acd1ad2009-06-23 21:40:15 +0900240}
Kukjin Kimdd4153d2011-12-22 23:31:28 +0100241
242/* uart registration process */
243
244void __init s5pc100_init_uarts(struct s3c2410_uartcfg *cfg, int no)
245{
246 s3c24xx_init_uartdevs("s3c6400-uart", s5p_uart_resources, cfg, no);
247}
Kukjin Kim5497d2e2011-12-22 23:35:21 +0100248
Robin Holt7b6d8642013-07-08 16:01:40 -0700249void s5pc100_restart(enum reboot_mode mode, const char *cmd)
Kukjin Kim5497d2e2011-12-22 23:35:21 +0100250{
Robin Holt7b6d8642013-07-08 16:01:40 -0700251 if (mode != REBOOT_SOFT)
Tomasz Figa88f59732013-06-17 23:45:37 +0900252 samsung_wdt_reset();
Kukjin Kim5497d2e2011-12-22 23:35:21 +0100253
254 soft_restart(0);
255}