xref: /openbmc/linux/arch/sh/kernel/cpu/sh3/setup-sh7705.c (revision b6dcefde)
1 /*
2  * SH7705 Setup
3  *
4  *  Copyright (C) 2006 - 2009  Paul Mundt
5  *  Copyright (C) 2007  Nobuhiro Iwamatsu
6  *
7  * This file is subject to the terms and conditions of the GNU General Public
8  * License.  See the file "COPYING" in the main directory of this archive
9  * for more details.
10  */
11 #include <linux/platform_device.h>
12 #include <linux/init.h>
13 #include <linux/irq.h>
14 #include <linux/serial.h>
15 #include <linux/serial_sci.h>
16 #include <linux/sh_timer.h>
17 #include <asm/rtc.h>
18 
19 enum {
20 	UNUSED = 0,
21 
22 	/* interrupt sources */
23 	IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
24 	PINT07, PINT815,
25 
26 	DMAC, SCIF0, SCIF2, ADC_ADI, USB,
27 
28 	TPU0, TPU1, TPU2, TPU3,
29 	TMU0, TMU1, TMU2,
30 
31 	RTC, WDT, REF_RCMI,
32 };
33 
34 static struct intc_vect vectors[] __initdata = {
35 	/* IRQ0->5 are handled in setup-sh3.c */
36 	INTC_VECT(PINT07, 0x700), INTC_VECT(PINT815, 0x720),
37 	INTC_VECT(DMAC, 0x800), INTC_VECT(DMAC, 0x820),
38 	INTC_VECT(DMAC, 0x840), INTC_VECT(DMAC, 0x860),
39 	INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0),
40 	INTC_VECT(SCIF0, 0x8e0),
41 	INTC_VECT(SCIF2, 0x900), INTC_VECT(SCIF2, 0x920),
42 	INTC_VECT(SCIF2, 0x960),
43 	INTC_VECT(ADC_ADI, 0x980),
44 	INTC_VECT(USB, 0xa20), INTC_VECT(USB, 0xa40),
45 	INTC_VECT(TPU0, 0xc00), INTC_VECT(TPU1, 0xc20),
46 	INTC_VECT(TPU2, 0xc80), INTC_VECT(TPU3, 0xca0),
47 	INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
48 	INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
49 	INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
50 	INTC_VECT(RTC, 0x4c0),
51 	INTC_VECT(WDT, 0x560),
52 	INTC_VECT(REF_RCMI, 0x580),
53 };
54 
55 static struct intc_prio_reg prio_registers[] __initdata = {
56 	{ 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
57 	{ 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF_RCMI, 0, 0 } },
58 	{ 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
59 	{ 0xa4000018, 0, 16, 4, /* IPRD */ { PINT07, PINT815, IRQ5, IRQ4 } },
60 	{ 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC, SCIF0, SCIF2, ADC_ADI } },
61 	{ 0xa4080000, 0, 16, 4, /* IPRF */ { 0, 0, USB } },
62 	{ 0xa4080002, 0, 16, 4, /* IPRG */ { TPU0, TPU1 } },
63 	{ 0xa4080004, 0, 16, 4, /* IPRH */ { TPU2, TPU3 } },
64 
65 };
66 
67 static DECLARE_INTC_DESC(intc_desc, "sh7705", vectors, NULL,
68 			 NULL, prio_registers, NULL);
69 
70 static struct plat_sci_port scif0_platform_data = {
71 	.mapbase	= 0xa4410000,
72 	.flags		= UPF_BOOT_AUTOCONF,
73 	.type		= PORT_SCIF,
74 	.irqs		= { 56, 56, 56 },
75 };
76 
77 static struct platform_device scif0_device = {
78 	.name		= "sh-sci",
79 	.id		= 0,
80 	.dev		= {
81 		.platform_data	= &scif0_platform_data,
82 	},
83 };
84 
85 static struct plat_sci_port scif1_platform_data = {
86 	.mapbase	= 0xa4400000,
87 	.flags		= UPF_BOOT_AUTOCONF,
88 	.type		= PORT_SCIF,
89 	.irqs		= { 52, 52, 52 },
90 };
91 
92 static struct platform_device scif1_device = {
93 	.name		= "sh-sci",
94 	.id		= 1,
95 	.dev		= {
96 		.platform_data	= &scif1_platform_data,
97 	},
98 };
99 
100 static struct resource rtc_resources[] = {
101 	[0] =	{
102 		.start	= 0xfffffec0,
103 		.end	= 0xfffffec0 + 0x1e,
104 		.flags  = IORESOURCE_IO,
105 	},
106 	[1] =	{
107 		.start  = 20,
108 		.flags	= IORESOURCE_IRQ,
109 	},
110 };
111 
112 static struct sh_rtc_platform_info rtc_info = {
113 	.capabilities	= RTC_CAP_4_DIGIT_YEAR,
114 };
115 
116 static struct platform_device rtc_device = {
117 	.name		= "sh-rtc",
118 	.id		= -1,
119 	.num_resources	= ARRAY_SIZE(rtc_resources),
120 	.resource	= rtc_resources,
121 	.dev		= {
122 		.platform_data = &rtc_info,
123 	},
124 };
125 
126 static struct sh_timer_config tmu0_platform_data = {
127 	.name = "TMU0",
128 	.channel_offset = 0x02,
129 	.timer_bit = 0,
130 	.clk = "peripheral_clk",
131 	.clockevent_rating = 200,
132 };
133 
134 static struct resource tmu0_resources[] = {
135 	[0] = {
136 		.name	= "TMU0",
137 		.start	= 0xfffffe94,
138 		.end	= 0xfffffe9f,
139 		.flags	= IORESOURCE_MEM,
140 	},
141 	[1] = {
142 		.start	= 16,
143 		.flags	= IORESOURCE_IRQ,
144 	},
145 };
146 
147 static struct platform_device tmu0_device = {
148 	.name		= "sh_tmu",
149 	.id		= 0,
150 	.dev = {
151 		.platform_data	= &tmu0_platform_data,
152 	},
153 	.resource	= tmu0_resources,
154 	.num_resources	= ARRAY_SIZE(tmu0_resources),
155 };
156 
157 static struct sh_timer_config tmu1_platform_data = {
158 	.name = "TMU1",
159 	.channel_offset = 0xe,
160 	.timer_bit = 1,
161 	.clk = "peripheral_clk",
162 	.clocksource_rating = 200,
163 };
164 
165 static struct resource tmu1_resources[] = {
166 	[0] = {
167 		.name	= "TMU1",
168 		.start	= 0xfffffea0,
169 		.end	= 0xfffffeab,
170 		.flags	= IORESOURCE_MEM,
171 	},
172 	[1] = {
173 		.start	= 17,
174 		.flags	= IORESOURCE_IRQ,
175 	},
176 };
177 
178 static struct platform_device tmu1_device = {
179 	.name		= "sh_tmu",
180 	.id		= 1,
181 	.dev = {
182 		.platform_data	= &tmu1_platform_data,
183 	},
184 	.resource	= tmu1_resources,
185 	.num_resources	= ARRAY_SIZE(tmu1_resources),
186 };
187 
188 static struct sh_timer_config tmu2_platform_data = {
189 	.name = "TMU2",
190 	.channel_offset = 0x1a,
191 	.timer_bit = 2,
192 	.clk = "peripheral_clk",
193 };
194 
195 static struct resource tmu2_resources[] = {
196 	[0] = {
197 		.name	= "TMU2",
198 		.start	= 0xfffffeac,
199 		.end	= 0xfffffebb,
200 		.flags	= IORESOURCE_MEM,
201 	},
202 	[1] = {
203 		.start	= 18,
204 		.flags	= IORESOURCE_IRQ,
205 	},
206 };
207 
208 static struct platform_device tmu2_device = {
209 	.name		= "sh_tmu",
210 	.id		= 2,
211 	.dev = {
212 		.platform_data	= &tmu2_platform_data,
213 	},
214 	.resource	= tmu2_resources,
215 	.num_resources	= ARRAY_SIZE(tmu2_resources),
216 };
217 
218 static struct platform_device *sh7705_devices[] __initdata = {
219 	&scif0_device,
220 	&scif1_device,
221 	&tmu0_device,
222 	&tmu1_device,
223 	&tmu2_device,
224 	&rtc_device,
225 };
226 
227 static int __init sh7705_devices_setup(void)
228 {
229 	return platform_add_devices(sh7705_devices,
230 				    ARRAY_SIZE(sh7705_devices));
231 }
232 arch_initcall(sh7705_devices_setup);
233 
234 static struct platform_device *sh7705_early_devices[] __initdata = {
235 	&scif0_device,
236 	&scif1_device,
237 	&tmu0_device,
238 	&tmu1_device,
239 	&tmu2_device,
240 };
241 
242 void __init plat_early_device_setup(void)
243 {
244 	early_platform_add_devices(sh7705_early_devices,
245 				   ARRAY_SIZE(sh7705_early_devices));
246 }
247 
248 void __init plat_irq_setup(void)
249 {
250 	register_intc_controller(&intc_desc);
251 	plat_irq_setup_sh3();
252 }
253