sh: Kill off all timer name clobbering.
[pandora-kernel.git] / arch / sh / kernel / cpu / sh5 / setup-sh5.c
1 /*
2  * SH5-101/SH5-103 CPU Setup
3  *
4  *  Copyright (C) 2009  Paul Mundt
5  *
6  * This file is subject to the terms and conditions of the GNU General Public
7  * License.  See the file "COPYING" in the main directory of this archive
8  * for more details.
9  */
10 #include <linux/platform_device.h>
11 #include <linux/init.h>
12 #include <linux/serial.h>
13 #include <linux/serial_sci.h>
14 #include <linux/io.h>
15 #include <linux/mm.h>
16 #include <linux/sh_timer.h>
17 #include <asm/addrspace.h>
18
19 static struct plat_sci_port scif0_platform_data = {
20         .mapbase        = PHYS_PERIPHERAL_BLOCK + 0x01030000,
21         .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
22         .type           = PORT_SCIF,
23         .irqs           = { 39, 40, 42, 0 },
24 };
25
26 static struct platform_device scif0_device = {
27         .name           = "sh-sci",
28         .id             = 0,
29         .dev            = {
30                 .platform_data  = &scif0_platform_data,
31         },
32 };
33
34 static struct resource rtc_resources[] = {
35         [0] = {
36                 .start  = PHYS_PERIPHERAL_BLOCK + 0x01040000,
37                 .end    = PHYS_PERIPHERAL_BLOCK + 0x01040000 + 0x58 - 1,
38                 .flags  = IORESOURCE_IO,
39         },
40         [1] = {
41                 /* Period IRQ */
42                 .start  = IRQ_PRI,
43                 .flags  = IORESOURCE_IRQ,
44         },
45         [2] = {
46                 /* Carry IRQ */
47                 .start  = IRQ_CUI,
48                 .flags  = IORESOURCE_IRQ,
49         },
50         [3] = {
51                 /* Alarm IRQ */
52                 .start  = IRQ_ATI,
53                 .flags  = IORESOURCE_IRQ,
54         },
55 };
56
57 static struct platform_device rtc_device = {
58         .name           = "sh-rtc",
59         .id             = -1,
60         .num_resources  = ARRAY_SIZE(rtc_resources),
61         .resource       = rtc_resources,
62 };
63
64 #define TMU_BLOCK_OFF   0x01020000
65 #define TMU_BASE        PHYS_PERIPHERAL_BLOCK + TMU_BLOCK_OFF
66 #define TMU0_BASE       (TMU_BASE + 0x8 + (0xc * 0x0))
67 #define TMU1_BASE       (TMU_BASE + 0x8 + (0xc * 0x1))
68 #define TMU2_BASE       (TMU_BASE + 0x8 + (0xc * 0x2))
69
70 static struct sh_timer_config tmu0_platform_data = {
71         .channel_offset = 0x04,
72         .timer_bit = 0,
73         .clk = "peripheral_clk",
74         .clockevent_rating = 200,
75 };
76
77 static struct resource tmu0_resources[] = {
78         [0] = {
79                 .start  = TMU0_BASE,
80                 .end    = TMU0_BASE + 0xc - 1,
81                 .flags  = IORESOURCE_MEM,
82         },
83         [1] = {
84                 .start  = IRQ_TUNI0,
85                 .flags  = IORESOURCE_IRQ,
86         },
87 };
88
89 static struct platform_device tmu0_device = {
90         .name           = "sh_tmu",
91         .id             = 0,
92         .dev = {
93                 .platform_data  = &tmu0_platform_data,
94         },
95         .resource       = tmu0_resources,
96         .num_resources  = ARRAY_SIZE(tmu0_resources),
97 };
98
99 static struct sh_timer_config tmu1_platform_data = {
100         .channel_offset = 0x10,
101         .timer_bit = 1,
102         .clk = "peripheral_clk",
103         .clocksource_rating = 200,
104 };
105
106 static struct resource tmu1_resources[] = {
107         [0] = {
108                 .start  = TMU1_BASE,
109                 .end    = TMU1_BASE + 0xc - 1,
110                 .flags  = IORESOURCE_MEM,
111         },
112         [1] = {
113                 .start  = IRQ_TUNI1,
114                 .flags  = IORESOURCE_IRQ,
115         },
116 };
117
118 static struct platform_device tmu1_device = {
119         .name           = "sh_tmu",
120         .id             = 1,
121         .dev = {
122                 .platform_data  = &tmu1_platform_data,
123         },
124         .resource       = tmu1_resources,
125         .num_resources  = ARRAY_SIZE(tmu1_resources),
126 };
127
128 static struct sh_timer_config tmu2_platform_data = {
129         .channel_offset = 0x1c,
130         .timer_bit = 2,
131         .clk = "peripheral_clk",
132 };
133
134 static struct resource tmu2_resources[] = {
135         [0] = {
136                 .start  = TMU2_BASE,
137                 .end    = TMU2_BASE + 0xc - 1,
138                 .flags  = IORESOURCE_MEM,
139         },
140         [1] = {
141                 .start  = IRQ_TUNI2,
142                 .flags  = IORESOURCE_IRQ,
143         },
144 };
145
146 static struct platform_device tmu2_device = {
147         .name           = "sh_tmu",
148         .id             = 2,
149         .dev = {
150                 .platform_data  = &tmu2_platform_data,
151         },
152         .resource       = tmu2_resources,
153         .num_resources  = ARRAY_SIZE(tmu2_resources),
154 };
155
156 static struct platform_device *sh5_early_devices[] __initdata = {
157         &scif0_device,
158         &tmu0_device,
159         &tmu1_device,
160         &tmu2_device,
161 };
162
163 static struct platform_device *sh5_devices[] __initdata = {
164         &rtc_device,
165 };
166
167 static int __init sh5_devices_setup(void)
168 {
169         int ret;
170
171         ret = platform_add_devices(sh5_early_devices,
172                                    ARRAY_SIZE(sh5_early_devices));
173         if (unlikely(ret != 0))
174                 return ret;
175
176         return platform_add_devices(sh5_devices,
177                                     ARRAY_SIZE(sh5_devices));
178 }
179 arch_initcall(sh5_devices_setup);
180
181 void __init plat_early_device_setup(void)
182 {
183         early_platform_add_devices(sh5_early_devices,
184                                    ARRAY_SIZE(sh5_early_devices));
185 }