Merge branch 'for-linus' of git://gitorious.org/linux-omap-dss2/linux
[pandora-kernel.git] / arch / arm / mach-s5pv310 / cpu.c
1 /* linux/arch/arm/mach-s5pv310/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/sched.h>
12 #include <linux/sysdev.h>
13
14 #include <asm/mach/map.h>
15 #include <asm/mach/irq.h>
16
17 #include <asm/proc-fns.h>
18
19 #include <plat/cpu.h>
20 #include <plat/clock.h>
21 #include <plat/s5pv310.h>
22
23 #include <mach/regs-irq.h>
24
25 void __iomem *gic_cpu_base_addr;
26
27 extern int combiner_init(unsigned int combiner_nr, void __iomem *base,
28                          unsigned int irq_start);
29 extern void combiner_cascade_irq(unsigned int combiner_nr, unsigned int irq);
30
31 /* Initial IO mappings */
32 static struct map_desc s5pv310_iodesc[] __initdata = {
33         {
34                 .virtual        = (unsigned long)S5P_VA_SYSRAM,
35                 .pfn            = __phys_to_pfn(S5PV310_PA_SYSRAM),
36                 .length         = SZ_4K,
37                 .type           = MT_DEVICE,
38         }, {
39                 .virtual        = (unsigned long)S5P_VA_CMU,
40                 .pfn            = __phys_to_pfn(S5PV310_PA_CMU),
41                 .length         = SZ_128K,
42                 .type           = MT_DEVICE,
43         }, {
44                 .virtual        = (unsigned long)S5P_VA_COMBINER_BASE,
45                 .pfn            = __phys_to_pfn(S5PV310_PA_COMBINER),
46                 .length         = SZ_4K,
47                 .type           = MT_DEVICE,
48         }, {
49                 .virtual        = (unsigned long)S5P_VA_COREPERI_BASE,
50                 .pfn            = __phys_to_pfn(S5PV310_PA_COREPERI),
51                 .length         = SZ_8K,
52                 .type           = MT_DEVICE,
53         }, {
54                 .virtual        = (unsigned long)S5P_VA_L2CC,
55                 .pfn            = __phys_to_pfn(S5PV310_PA_L2CC),
56                 .length         = SZ_4K,
57                 .type           = MT_DEVICE,
58         }, {
59                 .virtual        = (unsigned long)S5P_VA_GPIO,
60                 .pfn            = __phys_to_pfn(S5PV310_PA_GPIO1),
61                 .length         = SZ_4K,
62                 .type           = MT_DEVICE,
63         }, {
64                 .virtual        = (unsigned long)S3C_VA_UART,
65                 .pfn            = __phys_to_pfn(S3C_PA_UART),
66                 .length         = SZ_512K,
67                 .type           = MT_DEVICE,
68         },
69 };
70
71 static void s5pv310_idle(void)
72 {
73         if (!need_resched())
74                 cpu_do_idle();
75
76         local_irq_enable();
77 }
78
79 /* s5pv310_map_io
80  *
81  * register the standard cpu IO areas
82 */
83 void __init s5pv310_map_io(void)
84 {
85         iotable_init(s5pv310_iodesc, ARRAY_SIZE(s5pv310_iodesc));
86 }
87
88 void __init s5pv310_init_clocks(int xtal)
89 {
90         printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
91
92         s3c24xx_register_baseclocks(xtal);
93         s5p_register_clocks(xtal);
94         s5pv310_register_clocks();
95         s5pv310_setup_clocks();
96 }
97
98 void __init s5pv310_init_irq(void)
99 {
100         int irq;
101
102         gic_cpu_base_addr = S5P_VA_GIC_CPU;
103         gic_dist_init(0, S5P_VA_GIC_DIST, IRQ_LOCALTIMER);
104         gic_cpu_init(0, S5P_VA_GIC_CPU);
105
106         for (irq = 0; irq < MAX_COMBINER_NR; irq++) {
107                 combiner_init(irq, (void __iomem *)S5P_VA_COMBINER(irq),
108                                 COMBINER_IRQ(irq, 0));
109                 combiner_cascade_irq(irq, IRQ_SPI(irq));
110         }
111
112         /* The parameters of s5p_init_irq() are for VIC init.
113          * Theses parameters should be NULL and 0 because S5PV310
114          * uses GIC instead of VIC.
115          */
116         s5p_init_irq(NULL, 0);
117 }
118
119 struct sysdev_class s5pv310_sysclass = {
120         .name   = "s5pv310-core",
121 };
122
123 static struct sys_device s5pv310_sysdev = {
124         .cls    = &s5pv310_sysclass,
125 };
126
127 static int __init s5pv310_core_init(void)
128 {
129         return sysdev_class_register(&s5pv310_sysclass);
130 }
131
132 core_initcall(s5pv310_core_init);
133
134 int __init s5pv310_init(void)
135 {
136         printk(KERN_INFO "S5PV310: Initializing architecture\n");
137
138         /* set idle function */
139         pm_idle = s5pv310_idle;
140
141         return sysdev_register(&s5pv310_sysdev);
142 }