Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc
[pandora-kernel.git] / arch / arm / mach-s5pv210 / cpu.c
1 /* linux/arch/arm/mach-s5pv210/cpu.c
2  *
3  * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4  *              http://www.samsung.com
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9 */
10
11 #include <linux/kernel.h>
12 #include <linux/types.h>
13 #include <linux/interrupt.h>
14 #include <linux/list.h>
15 #include <linux/timer.h>
16 #include <linux/init.h>
17 #include <linux/module.h>
18 #include <linux/clk.h>
19 #include <linux/io.h>
20 #include <linux/sysdev.h>
21 #include <linux/platform_device.h>
22 #include <linux/sched.h>
23 #include <linux/dma-mapping.h>
24
25 #include <asm/mach/arch.h>
26 #include <asm/mach/map.h>
27 #include <asm/mach/irq.h>
28
29 #include <asm/proc-fns.h>
30 #include <mach/map.h>
31 #include <mach/regs-clock.h>
32
33 #include <plat/cpu.h>
34 #include <plat/devs.h>
35 #include <plat/clock.h>
36 #include <plat/fb-core.h>
37 #include <plat/s5pv210.h>
38 #include <plat/adc-core.h>
39 #include <plat/ata-core.h>
40 #include <plat/fimc-core.h>
41 #include <plat/iic-core.h>
42 #include <plat/keypad-core.h>
43 #include <plat/sdhci.h>
44 #include <plat/reset.h>
45
46 /* Initial IO mappings */
47
48 static struct map_desc s5pv210_iodesc[] __initdata = {
49         {
50                 .virtual        = (unsigned long)S5P_VA_SYSTIMER,
51                 .pfn            = __phys_to_pfn(S5PV210_PA_SYSTIMER),
52                 .length         = SZ_4K,
53                 .type           = MT_DEVICE,
54         }, {
55                 .virtual        = (unsigned long)S5P_VA_GPIO,
56                 .pfn            = __phys_to_pfn(S5PV210_PA_GPIO),
57                 .length         = SZ_4K,
58                 .type           = MT_DEVICE,
59         }, {
60                 .virtual        = (unsigned long)VA_VIC0,
61                 .pfn            = __phys_to_pfn(S5PV210_PA_VIC0),
62                 .length         = SZ_16K,
63                 .type           = MT_DEVICE,
64         }, {
65                 .virtual        = (unsigned long)VA_VIC1,
66                 .pfn            = __phys_to_pfn(S5PV210_PA_VIC1),
67                 .length         = SZ_16K,
68                 .type           = MT_DEVICE,
69         }, {
70                 .virtual        = (unsigned long)VA_VIC2,
71                 .pfn            = __phys_to_pfn(S5PV210_PA_VIC2),
72                 .length         = SZ_16K,
73                 .type           = MT_DEVICE,
74         }, {
75                 .virtual        = (unsigned long)VA_VIC3,
76                 .pfn            = __phys_to_pfn(S5PV210_PA_VIC3),
77                 .length         = SZ_16K,
78                 .type           = MT_DEVICE,
79         }, {
80                 .virtual        = (unsigned long)S3C_VA_UART,
81                 .pfn            = __phys_to_pfn(S3C_PA_UART),
82                 .length         = SZ_512K,
83                 .type           = MT_DEVICE,
84         }, {
85                 .virtual        = (unsigned long)S5P_VA_DMC0,
86                 .pfn            = __phys_to_pfn(S5PV210_PA_DMC0),
87                 .length         = SZ_4K,
88                 .type           = MT_DEVICE,
89         }, {
90                 .virtual        = (unsigned long)S5P_VA_DMC1,
91                 .pfn            = __phys_to_pfn(S5PV210_PA_DMC1),
92                 .length         = SZ_4K,
93                 .type           = MT_DEVICE,
94         }, {
95                 .virtual        = (unsigned long)S3C_VA_USB_HSPHY,
96                 .pfn            =__phys_to_pfn(S5PV210_PA_HSPHY),
97                 .length         = SZ_4K,
98                 .type           = MT_DEVICE,
99         }
100 };
101
102 static void s5pv210_idle(void)
103 {
104         if (!need_resched())
105                 cpu_do_idle();
106
107         local_irq_enable();
108 }
109
110 static void s5pv210_sw_reset(void)
111 {
112         __raw_writel(0x1, S5P_SWRESET);
113 }
114
115 /* s5pv210_map_io
116  *
117  * register the standard cpu IO areas
118 */
119
120 void __init s5pv210_map_io(void)
121 {
122         iotable_init(s5pv210_iodesc, ARRAY_SIZE(s5pv210_iodesc));
123         init_consistent_dma_size(14 << 20);
124
125         /* initialise device information early */
126         s5pv210_default_sdhci0();
127         s5pv210_default_sdhci1();
128         s5pv210_default_sdhci2();
129         s5pv210_default_sdhci3();
130
131         s3c_adc_setname("samsung-adc-v3");
132
133         s3c_cfcon_setname("s5pv210-pata");
134
135         s3c_fimc_setname(0, "s5pv210-fimc");
136         s3c_fimc_setname(1, "s5pv210-fimc");
137         s3c_fimc_setname(2, "s5pv210-fimc");
138
139         /* the i2c devices are directly compatible with s3c2440 */
140         s3c_i2c0_setname("s3c2440-i2c");
141         s3c_i2c1_setname("s3c2440-i2c");
142         s3c_i2c2_setname("s3c2440-i2c");
143
144         s3c_fb_setname("s5pv210-fb");
145
146         /* Use s5pv210-keypad instead of samsung-keypad */
147         samsung_keypad_setname("s5pv210-keypad");
148 }
149
150 void __init s5pv210_init_clocks(int xtal)
151 {
152         printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
153
154         s3c24xx_register_baseclocks(xtal);
155         s5p_register_clocks(xtal);
156         s5pv210_register_clocks();
157         s5pv210_setup_clocks();
158 }
159
160 void __init s5pv210_init_irq(void)
161 {
162         u32 vic[4];     /* S5PV210 supports 4 VIC */
163
164         /* All the VICs are fully populated. */
165         vic[0] = ~0;
166         vic[1] = ~0;
167         vic[2] = ~0;
168         vic[3] = ~0;
169
170         s5p_init_irq(vic, ARRAY_SIZE(vic));
171 }
172
173 struct sysdev_class s5pv210_sysclass = {
174         .name   = "s5pv210-core",
175 };
176
177 static struct sys_device s5pv210_sysdev = {
178         .cls    = &s5pv210_sysclass,
179 };
180
181 static int __init s5pv210_core_init(void)
182 {
183         return sysdev_class_register(&s5pv210_sysclass);
184 }
185
186 core_initcall(s5pv210_core_init);
187
188 int __init s5pv210_init(void)
189 {
190         printk(KERN_INFO "S5PV210: Initializing architecture\n");
191
192         /* set idle function */
193         pm_idle = s5pv210_idle;
194
195         /* set sw_reset function */
196         s5p_reset_hook = s5pv210_sw_reset;
197
198         return sysdev_register(&s5pv210_sysdev);
199 }