blob: 8099b0b8a9346dcb76a17c2902dec2a1dba01c8b [file] [log] [blame]
Magnus Dammf2aaf662010-02-05 11:15:07 +00001/*
2 * sh7377 processor support
3 *
4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2008 Yoshihiro Shimoda
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/interrupt.h>
23#include <linux/irq.h>
24#include <linux/platform_device.h>
25#include <linux/delay.h>
26#include <linux/input.h>
27#include <linux/io.h>
28#include <linux/serial_sci.h>
29#include <linux/sh_intc.h>
30#include <linux/sh_timer.h>
31#include <mach/hardware.h>
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34
Magnus Damm043296d2010-05-20 14:39:21 +000035/* SCIFA0 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000036static struct plat_sci_port scif0_platform_data = {
37 .mapbase = 0xe6c40000,
38 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090039 .scscr = SCSCR_RE | SCSCR_TE,
40 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Dammf2aaf662010-02-05 11:15:07 +000041 .type = PORT_SCIF,
Magnus Damm043296d2010-05-20 14:39:21 +000042 .irqs = { evt2irq(0xc00), evt2irq(0xc00),
43 evt2irq(0xc00), evt2irq(0xc00) },
Magnus Dammf2aaf662010-02-05 11:15:07 +000044};
45
46static struct platform_device scif0_device = {
47 .name = "sh-sci",
48 .id = 0,
49 .dev = {
50 .platform_data = &scif0_platform_data,
51 },
52};
53
Magnus Damm043296d2010-05-20 14:39:21 +000054/* SCIFA1 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000055static struct plat_sci_port scif1_platform_data = {
56 .mapbase = 0xe6c50000,
57 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090058 .scscr = SCSCR_RE | SCSCR_TE,
59 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Dammf2aaf662010-02-05 11:15:07 +000060 .type = PORT_SCIF,
Magnus Damm043296d2010-05-20 14:39:21 +000061 .irqs = { evt2irq(0xc20), evt2irq(0xc20),
62 evt2irq(0xc20), evt2irq(0xc20) },
Magnus Dammf2aaf662010-02-05 11:15:07 +000063};
64
65static struct platform_device scif1_device = {
66 .name = "sh-sci",
67 .id = 1,
68 .dev = {
69 .platform_data = &scif1_platform_data,
70 },
71};
72
Magnus Damm043296d2010-05-20 14:39:21 +000073/* SCIFA2 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000074static struct plat_sci_port scif2_platform_data = {
75 .mapbase = 0xe6c60000,
76 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090077 .scscr = SCSCR_RE | SCSCR_TE,
78 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Dammf2aaf662010-02-05 11:15:07 +000079 .type = PORT_SCIF,
Magnus Damm043296d2010-05-20 14:39:21 +000080 .irqs = { evt2irq(0xc40), evt2irq(0xc40),
81 evt2irq(0xc40), evt2irq(0xc40) },
Magnus Dammf2aaf662010-02-05 11:15:07 +000082};
83
84static struct platform_device scif2_device = {
85 .name = "sh-sci",
86 .id = 2,
87 .dev = {
88 .platform_data = &scif2_platform_data,
89 },
90};
91
Magnus Damm043296d2010-05-20 14:39:21 +000092/* SCIFA3 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000093static struct plat_sci_port scif3_platform_data = {
94 .mapbase = 0xe6c70000,
95 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090096 .scscr = SCSCR_RE | SCSCR_TE,
97 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Dammf2aaf662010-02-05 11:15:07 +000098 .type = PORT_SCIF,
Magnus Damm043296d2010-05-20 14:39:21 +000099 .irqs = { evt2irq(0xc60), evt2irq(0xc60),
100 evt2irq(0xc60), evt2irq(0xc60) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000101};
102
103static struct platform_device scif3_device = {
104 .name = "sh-sci",
105 .id = 3,
106 .dev = {
107 .platform_data = &scif3_platform_data,
108 },
109};
110
Magnus Damm043296d2010-05-20 14:39:21 +0000111/* SCIFA4 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000112static struct plat_sci_port scif4_platform_data = {
113 .mapbase = 0xe6c80000,
114 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900115 .scscr = SCSCR_RE | SCSCR_TE,
116 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Dammf2aaf662010-02-05 11:15:07 +0000117 .type = PORT_SCIF,
Magnus Damm043296d2010-05-20 14:39:21 +0000118 .irqs = { evt2irq(0xd20), evt2irq(0xd20),
119 evt2irq(0xd20), evt2irq(0xd20) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000120};
121
122static struct platform_device scif4_device = {
123 .name = "sh-sci",
124 .id = 4,
125 .dev = {
126 .platform_data = &scif4_platform_data,
127 },
128};
129
Magnus Damm043296d2010-05-20 14:39:21 +0000130/* SCIFA5 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000131static struct plat_sci_port scif5_platform_data = {
132 .mapbase = 0xe6cb0000,
133 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900134 .scscr = SCSCR_RE | SCSCR_TE,
135 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Dammf2aaf662010-02-05 11:15:07 +0000136 .type = PORT_SCIF,
Magnus Damm043296d2010-05-20 14:39:21 +0000137 .irqs = { evt2irq(0xd40), evt2irq(0xd40),
138 evt2irq(0xd40), evt2irq(0xd40) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000139};
140
141static struct platform_device scif5_device = {
142 .name = "sh-sci",
143 .id = 5,
144 .dev = {
145 .platform_data = &scif5_platform_data,
146 },
147};
148
Magnus Damm043296d2010-05-20 14:39:21 +0000149/* SCIFA6 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000150static struct plat_sci_port scif6_platform_data = {
151 .mapbase = 0xe6cc0000,
152 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900153 .scscr = SCSCR_RE | SCSCR_TE,
154 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Dammf2aaf662010-02-05 11:15:07 +0000155 .type = PORT_SCIF,
Magnus Damm043296d2010-05-20 14:39:21 +0000156 .irqs = { intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80),
157 intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000158};
159
160static struct platform_device scif6_device = {
161 .name = "sh-sci",
162 .id = 6,
163 .dev = {
164 .platform_data = &scif6_platform_data,
165 },
166};
167
Magnus Damm043296d2010-05-20 14:39:21 +0000168/* SCIFB */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000169static struct plat_sci_port scif7_platform_data = {
170 .mapbase = 0xe6c30000,
171 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900172 .scscr = SCSCR_RE | SCSCR_TE,
173 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Dammf2aaf662010-02-05 11:15:07 +0000174 .type = PORT_SCIF,
Magnus Damm043296d2010-05-20 14:39:21 +0000175 .irqs = { evt2irq(0xd60), evt2irq(0xd60),
176 evt2irq(0xd60), evt2irq(0xd60) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000177};
178
179static struct platform_device scif7_device = {
180 .name = "sh-sci",
181 .id = 7,
182 .dev = {
183 .platform_data = &scif7_platform_data,
184 },
185};
186
187static struct sh_timer_config cmt10_platform_data = {
188 .name = "CMT10",
189 .channel_offset = 0x10,
190 .timer_bit = 0,
Magnus Dammf2aaf662010-02-05 11:15:07 +0000191 .clockevent_rating = 125,
192 .clocksource_rating = 125,
193};
194
195static struct resource cmt10_resources[] = {
196 [0] = {
197 .name = "CMT10",
198 .start = 0xe6138010,
199 .end = 0xe613801b,
200 .flags = IORESOURCE_MEM,
201 },
202 [1] = {
Magnus Damm043296d2010-05-20 14:39:21 +0000203 .start = evt2irq(0xb00), /* CMT1_CMT10 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000204 .flags = IORESOURCE_IRQ,
205 },
206};
207
208static struct platform_device cmt10_device = {
209 .name = "sh_cmt",
210 .id = 10,
211 .dev = {
212 .platform_data = &cmt10_platform_data,
213 },
214 .resource = cmt10_resources,
215 .num_resources = ARRAY_SIZE(cmt10_resources),
216};
217
218static struct platform_device *sh7377_early_devices[] __initdata = {
219 &scif0_device,
220 &scif1_device,
221 &scif2_device,
222 &scif3_device,
223 &scif4_device,
224 &scif5_device,
225 &scif6_device,
226 &scif7_device,
227 &cmt10_device,
228};
229
230void __init sh7377_add_standard_devices(void)
231{
232 platform_add_devices(sh7377_early_devices,
233 ARRAY_SIZE(sh7377_early_devices));
234}
235
236#define SMSTPCR3 0xe615013c
237#define SMSTPCR3_CMT1 (1 << 29)
238
239void __init sh7377_add_early_devices(void)
240{
241 /* enable clock to CMT1 */
242 __raw_writel(__raw_readl(SMSTPCR3) & ~SMSTPCR3_CMT1, SMSTPCR3);
243
244 early_platform_add_devices(sh7377_early_devices,
245 ARRAY_SIZE(sh7377_early_devices));
246}