blob: c9095730a7f58ec31f4cf34ee3863f32a848dd6a [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>
25#include <linux/platform_device.h>
SeungChull Suh4341f9b2010-10-02 12:48:12 +090026#include <linux/sched.h>
Byungho Min8acd1ad2009-06-23 21:40:15 +090027
Kukjin Kimdd4153d2011-12-22 23:31:28 +010028#include <asm/irq.h>
29#include <asm/proc-fns.h>
Byungho Min8acd1ad2009-06-23 21:40:15 +090030#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32#include <asm/mach/irq.h>
33
Byungho Min8acd1ad2009-06-23 21:40:15 +090034#include <mach/map.h>
Kukjin Kimdd4153d2011-12-22 23:31:28 +010035#include <mach/hardware.h>
Marek Szyprowskiacc84702010-05-20 07:51:08 +020036#include <mach/regs-clock.h>
Byungho Min8acd1ad2009-06-23 21:40:15 +090037
38#include <plat/cpu.h>
39#include <plat/devs.h>
40#include <plat/clock.h>
Marek Szyprowskiacc84702010-05-20 07:51:08 +020041#include <plat/sdhci.h>
Naveen Krishna Ch327b9032010-06-30 21:50:24 +090042#include <plat/adc-core.h>
Kukjin Kimdd4153d2011-12-22 23:31:28 +010043#include <plat/ata-core.h>
Pawel Osciakeb42b042010-08-10 18:02:37 -070044#include <plat/fb-core.h>
Kukjin Kimdd4153d2011-12-22 23:31:28 +010045#include <plat/iic-core.h>
46#include <plat/onenand-core.h>
47#include <plat/regs-serial.h>
Kukjin Kim5497d2e2011-12-22 23:35:21 +010048#include <plat/watchdog-reset.h>
Marek Szyprowski999304b2010-05-20 08:59:05 +020049
Kukjin Kimdd4153d2011-12-22 23:31:28 +010050#include "common.h"
51
52static const char name_s5pc100[] = "S5PC100";
53
54static struct cpu_table cpu_ids[] __initdata = {
55 {
56 .idcode = S5PC100_CPU_ID,
57 .idmask = S5PC100_CPU_MASK,
58 .map_io = s5pc100_map_io,
59 .init_clocks = s5pc100_init_clocks,
60 .init_uarts = s5pc100_init_uarts,
61 .init = s5pc100_init,
62 .name = name_s5pc100,
63 },
64};
Byungho Min8acd1ad2009-06-23 21:40:15 +090065
66/* Initial IO mappings */
67
68static struct map_desc s5pc100_iodesc[] __initdata = {
Marek Szyprowskiacc84702010-05-20 07:51:08 +020069 {
Kukjin Kimdd4153d2011-12-22 23:31:28 +010070 .virtual = (unsigned long)S5P_VA_CHIPID,
71 .pfn = __phys_to_pfn(S5PC100_PA_CHIPID),
72 .length = SZ_4K,
73 .type = MT_DEVICE,
74 }, {
75 .virtual = (unsigned long)S3C_VA_SYS,
76 .pfn = __phys_to_pfn(S5PC100_PA_SYSCON),
77 .length = SZ_64K,
78 .type = MT_DEVICE,
79 }, {
80 .virtual = (unsigned long)S3C_VA_TIMER,
81 .pfn = __phys_to_pfn(S5PC100_PA_TIMER),
82 .length = SZ_16K,
83 .type = MT_DEVICE,
84 }, {
85 .virtual = (unsigned long)S3C_VA_WATCHDOG,
86 .pfn = __phys_to_pfn(S5PC100_PA_WATCHDOG),
87 .length = SZ_4K,
88 .type = MT_DEVICE,
89 }, {
90 .virtual = (unsigned long)S5P_VA_SROMC,
91 .pfn = __phys_to_pfn(S5PC100_PA_SROMC),
92 .length = SZ_4K,
93 .type = MT_DEVICE,
94 }, {
Marek Szyprowskiacc84702010-05-20 07:51:08 +020095 .virtual = (unsigned long)S5P_VA_SYSTIMER,
96 .pfn = __phys_to_pfn(S5PC100_PA_SYSTIMER),
97 .length = SZ_16K,
98 .type = MT_DEVICE,
99 }, {
Kukjin Kim19a2c062010-08-31 16:30:51 +0900100 .virtual = (unsigned long)S5P_VA_GPIO,
101 .pfn = __phys_to_pfn(S5PC100_PA_GPIO),
102 .length = SZ_4K,
103 .type = MT_DEVICE,
104 }, {
105 .virtual = (unsigned long)VA_VIC0,
106 .pfn = __phys_to_pfn(S5PC100_PA_VIC0),
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200107 .length = SZ_16K,
108 .type = MT_DEVICE,
109 }, {
Kukjin Kim19a2c062010-08-31 16:30:51 +0900110 .virtual = (unsigned long)VA_VIC1,
111 .pfn = __phys_to_pfn(S5PC100_PA_VIC1),
112 .length = SZ_16K,
113 .type = MT_DEVICE,
114 }, {
115 .virtual = (unsigned long)VA_VIC2,
116 .pfn = __phys_to_pfn(S5PC100_PA_VIC2),
117 .length = SZ_16K,
118 .type = MT_DEVICE,
119 }, {
120 .virtual = (unsigned long)S3C_VA_UART,
121 .pfn = __phys_to_pfn(S3C_PA_UART),
122 .length = SZ_512K,
123 .type = MT_DEVICE,
124 }, {
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200125 .virtual = (unsigned long)S5PC100_VA_OTHERS,
126 .pfn = __phys_to_pfn(S5PC100_PA_OTHERS),
127 .length = SZ_4K,
128 .type = MT_DEVICE,
129 }
Byungho Min8acd1ad2009-06-23 21:40:15 +0900130};
131
Kyungmin Parkc3fcf5d2009-11-17 08:41:17 +0100132static void s5pc100_idle(void)
133{
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200134 if (!need_resched())
135 cpu_do_idle();
Kyungmin Parkc3fcf5d2009-11-17 08:41:17 +0100136
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200137 local_irq_enable();
Kyungmin Parkc3fcf5d2009-11-17 08:41:17 +0100138}
139
Kukjin Kimdd4153d2011-12-22 23:31:28 +0100140/*
141 * s5pc100_map_io
Byungho Min8acd1ad2009-06-23 21:40:15 +0900142 *
Kukjin Kimdd4153d2011-12-22 23:31:28 +0100143 * register the standard CPU IO areas
144 */
145
146void __init s5pc100_init_io(struct map_desc *mach_desc, int size)
147{
148 /* initialize the io descriptors we need for initialization */
149 iotable_init(s5pc100_iodesc, ARRAY_SIZE(s5pc100_iodesc));
150 if (mach_desc)
151 iotable_init(mach_desc, size);
152
153 /* detect cpu id and rev. */
154 s5p_init_cpu(S5P_VA_CHIPID);
155
156 s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
157}
Byungho Min8acd1ad2009-06-23 21:40:15 +0900158
159void __init s5pc100_map_io(void)
160{
Byungho Min8acd1ad2009-06-23 21:40:15 +0900161 /* initialise device information early */
Kyungmin Park86cd4f52009-11-17 08:41:23 +0100162 s5pc100_default_sdhci0();
163 s5pc100_default_sdhci1();
164 s5pc100_default_sdhci2();
Kyungmin Park5eda2882009-11-17 08:41:21 +0100165
Naveen Krishna Ch327b9032010-06-30 21:50:24 +0900166 s3c_adc_setname("s3c64xx-adc");
167
Kyungmin Park5eda2882009-11-17 08:41:21 +0100168 /* the i2c devices are directly compatible with s3c2440 */
169 s3c_i2c0_setname("s3c2440-i2c");
170 s3c_i2c1_setname("s3c2440-i2c");
Marek Szyprowski999304b2010-05-20 08:59:05 +0200171
172 s3c_onenand_setname("s5pc100-onenand");
Pawel Osciakeb42b042010-08-10 18:02:37 -0700173 s3c_fb_setname("s5pc100-fb");
Abhilash Kesavan66194a72010-06-08 17:02:08 +0900174 s3c_cfcon_setname("s5pc100-pata");
Byungho Min8acd1ad2009-06-23 21:40:15 +0900175}
176
177void __init s5pc100_init_clocks(int xtal)
178{
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200179 printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
180
Byungho Min8acd1ad2009-06-23 21:40:15 +0900181 s3c24xx_register_baseclocks(xtal);
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200182 s5p_register_clocks(xtal);
Byungho Min8acd1ad2009-06-23 21:40:15 +0900183 s5pc100_register_clocks();
184 s5pc100_setup_clocks();
185}
186
187void __init s5pc100_init_irq(void)
188{
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200189 u32 vic[] = {~0, ~0, ~0};
Byungho Min8acd1ad2009-06-23 21:40:15 +0900190
191 /* VIC0, VIC1, and VIC2 are fully populated. */
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200192 s5p_init_irq(vic, ARRAY_SIZE(vic));
Byungho Min8acd1ad2009-06-23 21:40:15 +0900193}
194
Kay Sievers4a858cf2011-12-21 16:01:38 -0800195static struct bus_type s5pc100_subsys = {
196 .name = "s5pc100-core",
197 .dev_name = "s5pc100-core",
Byungho Min8acd1ad2009-06-23 21:40:15 +0900198};
199
Kay Sievers4a858cf2011-12-21 16:01:38 -0800200static struct device s5pc100_dev = {
201 .bus = &s5pc100_subsys,
Byungho Min8acd1ad2009-06-23 21:40:15 +0900202};
203
204static int __init s5pc100_core_init(void)
205{
Kay Sievers4a858cf2011-12-21 16:01:38 -0800206 return subsys_system_register(&s5pc100_subsys, NULL);
Byungho Min8acd1ad2009-06-23 21:40:15 +0900207}
Byungho Min8acd1ad2009-06-23 21:40:15 +0900208core_initcall(s5pc100_core_init);
209
210int __init s5pc100_init(void)
211{
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200212 printk(KERN_INFO "S5PC100: Initializing architecture\n");
Byungho Min8acd1ad2009-06-23 21:40:15 +0900213
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200214 /* set idle function */
215 pm_idle = s5pc100_idle;
Kyungmin Parkc3fcf5d2009-11-17 08:41:17 +0100216
Kukjin Kimea040182012-01-06 16:08:09 +0900217 return device_register(&s5pc100_dev);
Byungho Min8acd1ad2009-06-23 21:40:15 +0900218}
Kukjin Kimdd4153d2011-12-22 23:31:28 +0100219
220/* uart registration process */
221
222void __init s5pc100_init_uarts(struct s3c2410_uartcfg *cfg, int no)
223{
224 s3c24xx_init_uartdevs("s3c6400-uart", s5p_uart_resources, cfg, no);
225}
Kukjin Kim5497d2e2011-12-22 23:35:21 +0100226
227void s5pc100_restart(char mode, const char *cmd)
228{
229 if (mode != 's')
230 arch_wdt_reset();
231
232 soft_restart(0);
233}