blob: 3148c11a550e2fa6e28641920aab5a4930b0fe04 [file] [log] [blame]
Magnus Dammc793c1b2010-02-05 11:14:49 +00001/*
2 * sh7367 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>
Magnus Dammc793c1b2010-02-05 11:14:49 +000029#include <linux/sh_timer.h>
30#include <mach/hardware.h>
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33
Magnus Damm74905092010-05-20 14:35:30 +000034/* SCIFA0 */
Magnus Dammc793c1b2010-02-05 11:14:49 +000035static struct plat_sci_port scif0_platform_data = {
36 .mapbase = 0xe6c40000,
37 .flags = UPF_BOOT_AUTOCONF,
38 .type = PORT_SCIF,
Magnus Damm74905092010-05-20 14:35:30 +000039 .irqs = { evt2irq(0xc00), evt2irq(0xc00),
40 evt2irq(0xc00), evt2irq(0xc00) },
Magnus Dammc793c1b2010-02-05 11:14:49 +000041};
42
43static struct platform_device scif0_device = {
44 .name = "sh-sci",
45 .id = 0,
46 .dev = {
47 .platform_data = &scif0_platform_data,
48 },
49};
50
Magnus Damm74905092010-05-20 14:35:30 +000051/* SCIFA1 */
Magnus Dammc793c1b2010-02-05 11:14:49 +000052static struct plat_sci_port scif1_platform_data = {
53 .mapbase = 0xe6c50000,
54 .flags = UPF_BOOT_AUTOCONF,
55 .type = PORT_SCIF,
Magnus Damm74905092010-05-20 14:35:30 +000056 .irqs = { evt2irq(0xc20), evt2irq(0xc20),
57 evt2irq(0xc20), evt2irq(0xc20) },
Magnus Dammc793c1b2010-02-05 11:14:49 +000058};
59
60static struct platform_device scif1_device = {
61 .name = "sh-sci",
62 .id = 1,
63 .dev = {
64 .platform_data = &scif1_platform_data,
65 },
66};
67
Magnus Damm74905092010-05-20 14:35:30 +000068/* SCIFA2 */
Magnus Dammc793c1b2010-02-05 11:14:49 +000069static struct plat_sci_port scif2_platform_data = {
70 .mapbase = 0xe6c60000,
71 .flags = UPF_BOOT_AUTOCONF,
72 .type = PORT_SCIF,
Magnus Damm74905092010-05-20 14:35:30 +000073 .irqs = { evt2irq(0xc40), evt2irq(0xc40),
74 evt2irq(0xc40), evt2irq(0xc40) },
Magnus Dammc793c1b2010-02-05 11:14:49 +000075};
76
77static struct platform_device scif2_device = {
78 .name = "sh-sci",
79 .id = 2,
80 .dev = {
81 .platform_data = &scif2_platform_data,
82 },
83};
84
Magnus Damm74905092010-05-20 14:35:30 +000085/* SCIFA3 */
Magnus Dammc793c1b2010-02-05 11:14:49 +000086static struct plat_sci_port scif3_platform_data = {
87 .mapbase = 0xe6c70000,
88 .flags = UPF_BOOT_AUTOCONF,
89 .type = PORT_SCIF,
Magnus Damm74905092010-05-20 14:35:30 +000090 .irqs = { evt2irq(0xc60), evt2irq(0xc60),
91 evt2irq(0xc60), evt2irq(0xc60) },
Magnus Dammc793c1b2010-02-05 11:14:49 +000092};
93
94static struct platform_device scif3_device = {
95 .name = "sh-sci",
96 .id = 3,
97 .dev = {
98 .platform_data = &scif3_platform_data,
99 },
100};
101
Magnus Damm74905092010-05-20 14:35:30 +0000102/* SCIFA4 */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000103static struct plat_sci_port scif4_platform_data = {
104 .mapbase = 0xe6c80000,
105 .flags = UPF_BOOT_AUTOCONF,
106 .type = PORT_SCIF,
Magnus Damm74905092010-05-20 14:35:30 +0000107 .irqs = { evt2irq(0xd20), evt2irq(0xd20),
108 evt2irq(0xd20), evt2irq(0xd20) },
Magnus Dammc793c1b2010-02-05 11:14:49 +0000109};
110
111static struct platform_device scif4_device = {
112 .name = "sh-sci",
113 .id = 4,
114 .dev = {
115 .platform_data = &scif4_platform_data,
116 },
117};
118
Magnus Damm74905092010-05-20 14:35:30 +0000119/* SCIFA5 */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000120static struct plat_sci_port scif5_platform_data = {
121 .mapbase = 0xe6cb0000,
122 .flags = UPF_BOOT_AUTOCONF,
123 .type = PORT_SCIF,
Magnus Damm74905092010-05-20 14:35:30 +0000124 .irqs = { evt2irq(0xd40), evt2irq(0xd40),
125 evt2irq(0xd40), evt2irq(0xd40) },
Magnus Dammc793c1b2010-02-05 11:14:49 +0000126};
127
128static struct platform_device scif5_device = {
129 .name = "sh-sci",
130 .id = 5,
131 .dev = {
132 .platform_data = &scif5_platform_data,
133 },
134};
135
Magnus Damm74905092010-05-20 14:35:30 +0000136/* SCIFB */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000137static struct plat_sci_port scif6_platform_data = {
138 .mapbase = 0xe6c30000,
139 .flags = UPF_BOOT_AUTOCONF,
140 .type = PORT_SCIF,
Magnus Damm74905092010-05-20 14:35:30 +0000141 .irqs = { evt2irq(0xd60), evt2irq(0xd60),
142 evt2irq(0xd60), evt2irq(0xd60) },
Magnus Dammc793c1b2010-02-05 11:14:49 +0000143};
144
145static struct platform_device scif6_device = {
146 .name = "sh-sci",
147 .id = 6,
148 .dev = {
149 .platform_data = &scif6_platform_data,
150 },
151};
152
153static struct sh_timer_config cmt10_platform_data = {
154 .name = "CMT10",
155 .channel_offset = 0x10,
156 .timer_bit = 0,
157 .clk = "r_clk",
158 .clockevent_rating = 125,
159 .clocksource_rating = 125,
160};
161
162static struct resource cmt10_resources[] = {
163 [0] = {
164 .name = "CMT10",
165 .start = 0xe6138010,
166 .end = 0xe613801b,
167 .flags = IORESOURCE_MEM,
168 },
169 [1] = {
Magnus Damm74905092010-05-20 14:35:30 +0000170 .start = evt2irq(0xb00), /* CMT1_CMT10 */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000171 .flags = IORESOURCE_IRQ,
172 },
173};
174
175static struct platform_device cmt10_device = {
176 .name = "sh_cmt",
177 .id = 10,
178 .dev = {
179 .platform_data = &cmt10_platform_data,
180 },
181 .resource = cmt10_resources,
182 .num_resources = ARRAY_SIZE(cmt10_resources),
183};
184
185static struct platform_device *sh7367_early_devices[] __initdata = {
186 &scif0_device,
187 &scif1_device,
188 &scif2_device,
189 &scif3_device,
190 &scif4_device,
191 &scif5_device,
192 &scif6_device,
193 &cmt10_device,
194};
195
196void __init sh7367_add_standard_devices(void)
197{
198 platform_add_devices(sh7367_early_devices,
199 ARRAY_SIZE(sh7367_early_devices));
200}
201
202#define SYMSTPCR2 0xe6158048
203#define SYMSTPCR2_CMT1 (1 << 29)
204
205void __init sh7367_add_early_devices(void)
206{
207 /* enable clock to CMT1 */
208 __raw_writel(__raw_readl(SYMSTPCR2) & ~SYMSTPCR2_CMT1, SYMSTPCR2);
209
210 early_platform_add_devices(sh7367_early_devices,
211 ARRAY_SIZE(sh7367_early_devices));
212}