blob: 9c1bcdcc12c3bfd8e479f21fe66b2d393be49616 [file] [log] [blame]
Kukjin Kim3fa754c2011-12-22 23:32:07 +01001/*
2 * Copyright (c) 2009-2011 Samsung Electronics Co., Ltd.
Kukjin Kim19a2c062010-08-31 16:30:51 +09003 * http://www.samsung.com
Kukjin Kim939d28a2010-02-24 16:40:29 +09004 *
Kukjin Kim3fa754c2011-12-22 23:32:07 +01005 * Common Codes for S5PV210
6 *
Kukjin Kim939d28a2010-02-24 16:40:29 +09007 * 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.
Kukjin Kim3fa754c2011-12-22 23:32:07 +010010 */
Kukjin Kim939d28a2010-02-24 16:40:29 +090011
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>
18#include <linux/module.h>
19#include <linux/clk.h>
20#include <linux/io.h>
Kay Sievers4a858cf2011-12-21 16:01:38 -080021#include <linux/device.h>
Kukjin Kim939d28a2010-02-24 16:40:29 +090022#include <linux/platform_device.h>
SeungChull Suh4341f9b2010-10-02 12:48:12 +090023#include <linux/sched.h>
Jon Medhursta06a58a2011-08-04 14:39:20 +010024#include <linux/dma-mapping.h>
Kukjin Kim3fa754c2011-12-22 23:32:07 +010025#include <linux/serial_core.h>
Kukjin Kim939d28a2010-02-24 16:40:29 +090026
Kukjin Kim3fa754c2011-12-22 23:32:07 +010027#include <asm/proc-fns.h>
Kukjin Kim939d28a2010-02-24 16:40:29 +090028#include <asm/mach/arch.h>
29#include <asm/mach/map.h>
30#include <asm/mach/irq.h>
31
Kukjin Kim939d28a2010-02-24 16:40:29 +090032#include <mach/map.h>
33#include <mach/regs-clock.h>
34
35#include <plat/cpu.h>
Kukjin Kim939d28a2010-02-24 16:40:29 +090036#include <plat/clock.h>
Kukjin Kim3fa754c2011-12-22 23:32:07 +010037#include <plat/devs.h>
Kukjin Kim3fa754c2011-12-22 23:32:07 +010038#include <plat/sdhci.h>
Naveen Krishna Ch50e97692010-06-09 15:25:19 +053039#include <plat/adc-core.h>
Abhilash Kesavan4b9a5ad2010-06-08 17:11:43 +090040#include <plat/ata-core.h>
Kukjin Kim3fa754c2011-12-22 23:32:07 +010041#include <plat/fb-core.h>
Sylwester Nawrocki33c14ff2010-08-05 18:16:31 +090042#include <plat/fimc-core.h>
Marek Szyprowskic8d833b2010-05-20 08:13:06 +020043#include <plat/iic-core.h>
Joonyoung Shime7d06282010-06-21 16:28:28 +090044#include <plat/keypad-core.h>
Tomasz Stanislawskifbf05562011-09-19 16:44:42 +090045#include <plat/tv-core.h>
Kukjin Kim3fa754c2011-12-22 23:32:07 +010046#include <plat/regs-serial.h>
47
48#include "common.h"
49
50static const char name_s5pv210[] = "S5PV210/S5PC110";
51
52static struct cpu_table cpu_ids[] __initdata = {
53 {
54 .idcode = S5PV210_CPU_ID,
55 .idmask = S5PV210_CPU_MASK,
56 .map_io = s5pv210_map_io,
57 .init_clocks = s5pv210_init_clocks,
58 .init_uarts = s5pv210_init_uarts,
59 .init = s5pv210_init,
60 .name = name_s5pv210,
61 },
62};
Kukjin Kim939d28a2010-02-24 16:40:29 +090063
64/* Initial IO mappings */
65
66static struct map_desc s5pv210_iodesc[] __initdata = {
67 {
Kukjin Kim3fa754c2011-12-22 23:32:07 +010068 .virtual = (unsigned long)S5P_VA_CHIPID,
69 .pfn = __phys_to_pfn(S5PV210_PA_CHIPID),
70 .length = SZ_4K,
71 .type = MT_DEVICE,
72 }, {
73 .virtual = (unsigned long)S3C_VA_SYS,
74 .pfn = __phys_to_pfn(S5PV210_PA_SYSCON),
75 .length = SZ_64K,
76 .type = MT_DEVICE,
77 }, {
78 .virtual = (unsigned long)S3C_VA_TIMER,
79 .pfn = __phys_to_pfn(S5PV210_PA_TIMER),
80 .length = SZ_16K,
81 .type = MT_DEVICE,
82 }, {
83 .virtual = (unsigned long)S3C_VA_WATCHDOG,
84 .pfn = __phys_to_pfn(S5PV210_PA_WATCHDOG),
85 .length = SZ_4K,
86 .type = MT_DEVICE,
87 }, {
88 .virtual = (unsigned long)S5P_VA_SROMC,
89 .pfn = __phys_to_pfn(S5PV210_PA_SROMC),
90 .length = SZ_4K,
91 .type = MT_DEVICE,
92 }, {
Kukjin Kim939d28a2010-02-24 16:40:29 +090093 .virtual = (unsigned long)S5P_VA_SYSTIMER,
94 .pfn = __phys_to_pfn(S5PV210_PA_SYSTIMER),
Kyungmin Parka203a132010-08-21 11:48:45 +090095 .length = SZ_4K,
Kukjin Kim939d28a2010-02-24 16:40:29 +090096 .type = MT_DEVICE,
97 }, {
Kukjin Kim19a2c062010-08-31 16:30:51 +090098 .virtual = (unsigned long)S5P_VA_GPIO,
99 .pfn = __phys_to_pfn(S5PV210_PA_GPIO),
100 .length = SZ_4K,
101 .type = MT_DEVICE,
102 }, {
103 .virtual = (unsigned long)VA_VIC0,
104 .pfn = __phys_to_pfn(S5PV210_PA_VIC0),
105 .length = SZ_16K,
106 .type = MT_DEVICE,
107 }, {
108 .virtual = (unsigned long)VA_VIC1,
109 .pfn = __phys_to_pfn(S5PV210_PA_VIC1),
110 .length = SZ_16K,
111 .type = MT_DEVICE,
112 }, {
Kukjin Kim939d28a2010-02-24 16:40:29 +0900113 .virtual = (unsigned long)VA_VIC2,
114 .pfn = __phys_to_pfn(S5PV210_PA_VIC2),
115 .length = SZ_16K,
116 .type = MT_DEVICE,
117 }, {
118 .virtual = (unsigned long)VA_VIC3,
119 .pfn = __phys_to_pfn(S5PV210_PA_VIC3),
120 .length = SZ_16K,
121 .type = MT_DEVICE,
122 }, {
Kukjin Kim19a2c062010-08-31 16:30:51 +0900123 .virtual = (unsigned long)S3C_VA_UART,
124 .pfn = __phys_to_pfn(S3C_PA_UART),
125 .length = SZ_512K,
126 .type = MT_DEVICE,
127 }, {
Jaecheol Lee1d826d12010-09-15 15:57:37 +0900128 .virtual = (unsigned long)S5P_VA_DMC0,
129 .pfn = __phys_to_pfn(S5PV210_PA_DMC0),
130 .length = SZ_4K,
131 .type = MT_DEVICE,
132 }, {
133 .virtual = (unsigned long)S5P_VA_DMC1,
134 .pfn = __phys_to_pfn(S5PV210_PA_DMC1),
135 .length = SZ_4K,
136 .type = MT_DEVICE,
Marek Szyprowskica1931c2010-09-29 22:10:51 +0900137 }, {
138 .virtual = (unsigned long)S3C_VA_USB_HSPHY,
139 .pfn =__phys_to_pfn(S5PV210_PA_HSPHY),
140 .length = SZ_4K,
141 .type = MT_DEVICE,
Kukjin Kim939d28a2010-02-24 16:40:29 +0900142 }
143};
144
145static void s5pv210_idle(void)
146{
147 if (!need_resched())
148 cpu_do_idle();
149
150 local_irq_enable();
151}
152
Russell King1f34f0e2011-12-22 23:36:02 +0100153void s5pv210_restart(char mode, const char *cmd)
Jongpill Lee4550ee22010-07-23 21:39:15 +0900154{
155 __raw_writel(0x1, S5P_SWRESET);
156}
157
Kukjin Kim3fa754c2011-12-22 23:32:07 +0100158/*
159 * s5pv210_map_io
Kukjin Kim939d28a2010-02-24 16:40:29 +0900160 *
161 * register the standard cpu IO areas
Kukjin Kim3fa754c2011-12-22 23:32:07 +0100162 */
163
164void __init s5pv210_init_io(struct map_desc *mach_desc, int size)
165{
166 /* initialize the io descriptors we need for initialization */
167 iotable_init(s5pv210_iodesc, ARRAY_SIZE(s5pv210_iodesc));
168 if (mach_desc)
169 iotable_init(mach_desc, size);
170
171 /* detect cpu id and rev. */
172 s5p_init_cpu(S5P_VA_CHIPID);
173
174 s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
175}
Kukjin Kim939d28a2010-02-24 16:40:29 +0900176
177void __init s5pv210_map_io(void)
178{
Jon Medhursta06a58a2011-08-04 14:39:20 +0100179 init_consistent_dma_size(14 << 20);
Marek Szyprowskic8d833b2010-05-20 08:13:06 +0200180
Marek Szyprowskie6f66a92010-05-20 08:13:07 +0200181 /* initialise device information early */
182 s5pv210_default_sdhci0();
183 s5pv210_default_sdhci1();
184 s5pv210_default_sdhci2();
Hyuk Lee976a62f2010-06-14 10:18:56 +0900185 s5pv210_default_sdhci3();
Marek Szyprowskie6f66a92010-05-20 08:13:07 +0200186
MyungJoo Hama0428f32011-07-20 21:08:18 +0900187 s3c_adc_setname("samsung-adc-v3");
Naveen Krishna Ch50e97692010-06-09 15:25:19 +0530188
Abhilash Kesavan4b9a5ad2010-06-08 17:11:43 +0900189 s3c_cfcon_setname("s5pv210-pata");
190
Kukjin Kimd61bd772010-08-06 21:49:18 +0900191 s3c_fimc_setname(0, "s5pv210-fimc");
192 s3c_fimc_setname(1, "s5pv210-fimc");
193 s3c_fimc_setname(2, "s5pv210-fimc");
Kukjin Kim939d28a2010-02-24 16:40:29 +0900194
195 /* the i2c devices are directly compatible with s3c2440 */
196 s3c_i2c0_setname("s3c2440-i2c");
197 s3c_i2c1_setname("s3c2440-i2c");
198 s3c_i2c2_setname("s3c2440-i2c");
Pawel Osciakeb42b042010-08-10 18:02:37 -0700199
200 s3c_fb_setname("s5pv210-fb");
Linus Torvalds636d1742010-08-11 09:13:19 -0700201
Joonyoung Shime7d06282010-06-21 16:28:28 +0900202 /* Use s5pv210-keypad instead of samsung-keypad */
203 samsung_keypad_setname("s5pv210-keypad");
Tomasz Stanislawskifbf05562011-09-19 16:44:42 +0900204
205 /* setup TV devices */
206 s5p_hdmi_setname("s5pv210-hdmi");
Kukjin Kim939d28a2010-02-24 16:40:29 +0900207}
208
209void __init s5pv210_init_clocks(int xtal)
210{
211 printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
212
213 s3c24xx_register_baseclocks(xtal);
214 s5p_register_clocks(xtal);
215 s5pv210_register_clocks();
216 s5pv210_setup_clocks();
217}
218
219void __init s5pv210_init_irq(void)
220{
221 u32 vic[4]; /* S5PV210 supports 4 VIC */
222
223 /* All the VICs are fully populated. */
224 vic[0] = ~0;
225 vic[1] = ~0;
226 vic[2] = ~0;
227 vic[3] = ~0;
228
229 s5p_init_irq(vic, ARRAY_SIZE(vic));
230}
231
Kay Sievers4a858cf2011-12-21 16:01:38 -0800232struct bus_type s5pv210_subsys = {
233 .name = "s5pv210-core",
234 .dev_name = "s5pv210-core",
Kukjin Kim939d28a2010-02-24 16:40:29 +0900235};
236
Kay Sievers4a858cf2011-12-21 16:01:38 -0800237static struct device s5pv210_dev = {
238 .bus = &s5pv210_subsys,
Kukjin Kim939d28a2010-02-24 16:40:29 +0900239};
240
241static int __init s5pv210_core_init(void)
242{
Kay Sievers4a858cf2011-12-21 16:01:38 -0800243 return subsys_system_register(&s5pv210_subsys, NULL);
Kukjin Kim939d28a2010-02-24 16:40:29 +0900244}
Kukjin Kim939d28a2010-02-24 16:40:29 +0900245core_initcall(s5pv210_core_init);
246
247int __init s5pv210_init(void)
248{
249 printk(KERN_INFO "S5PV210: Initializing architecture\n");
250
251 /* set idle function */
252 pm_idle = s5pv210_idle;
253
Kay Sievers4a858cf2011-12-21 16:01:38 -0800254 return device_register(&s5pv210_dev);
Kukjin Kim939d28a2010-02-24 16:40:29 +0900255}
Kukjin Kim3fa754c2011-12-22 23:32:07 +0100256
Kukjin Kim3fa754c2011-12-22 23:32:07 +0100257/* uart registration process */
258
259void __init s5pv210_init_uarts(struct s3c2410_uartcfg *cfg, int no)
260{
Kukjin Kim3fa754c2011-12-22 23:32:07 +0100261 s3c24xx_init_uartdevs("s5pv210-uart", s5p_uart_resources, cfg, no);
262}