blob: 2a9ac6bcd8d6715ffd2acc8cf5518ab34dde6ed9 [file] [log] [blame]
Paul Mundt5283ecb2006-09-27 15:59:17 +09001/*
2 * arch/sh/boards/renesas/r7780rp/setup.c
3 *
Paul Mundt32351a22007-03-12 14:38:59 +09004 * Renesas Solutions Highlander Support.
5 *
Paul Mundt5283ecb2006-09-27 15:59:17 +09006 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
Paul Mundt71074d32007-02-14 14:49:04 +09007 * Copyright (C) 2005 - 2007 Paul Mundt
Paul Mundt5283ecb2006-09-27 15:59:17 +09008 *
Paul Mundt32351a22007-03-12 14:38:59 +09009 * This contains support for the R7780RP-1, R7780MP, and R7785RP
10 * Highlander modules.
Paul Mundt5283ecb2006-09-27 15:59:17 +090011 *
12 * This file is subject to the terms and conditions of the GNU General Public
13 * License. See the file "COPYING" in the main directory of this archive
14 * for more details.
15 */
16#include <linux/init.h>
17#include <linux/platform_device.h>
Paul Mundt71074d32007-02-14 14:49:04 +090018#include <linux/pata_platform.h>
Magnus Dammc6f93a32007-10-15 10:36:45 +090019#include <net/ax88796.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090020#include <asm/machvec.h>
Paul Mundt082c44d2006-10-19 16:16:18 +090021#include <asm/r7780rp.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090022#include <asm/clock.h>
Paul Mundt8786c952007-08-20 13:03:41 +090023#include <asm/heartbeat.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090024#include <asm/io.h>
25
Yoshihiro Shimodae6c972f2007-07-17 13:38:54 +090026static struct resource r8a66597_usb_host_resources[] = {
27 [0] = {
28 .name = "r8a66597_hcd",
29 .start = 0xA4200000,
30 .end = 0xA42000FF,
31 .flags = IORESOURCE_MEM,
32 },
33 [1] = {
34 .name = "r8a66597_hcd",
Magnus Damm897cfcd2007-09-10 12:06:03 +090035 .start = IRQ_EXT1, /* irq number */
36 .end = IRQ_EXT1,
Yoshihiro Shimodae6c972f2007-07-17 13:38:54 +090037 .flags = IORESOURCE_IRQ,
38 },
39};
40
41static struct platform_device r8a66597_usb_host_device = {
42 .name = "r8a66597_hcd",
43 .id = -1,
44 .dev = {
45 .dma_mask = NULL, /* don't use dma */
46 .coherent_dma_mask = 0xffffffff,
47 },
48 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
49 .resource = r8a66597_usb_host_resources,
50};
51
52static struct resource m66592_usb_peripheral_resources[] = {
53 [0] = {
54 .name = "m66592_udc",
55 .start = 0xb0000000,
56 .end = 0xb00000FF,
57 .flags = IORESOURCE_MEM,
58 },
59 [1] = {
60 .name = "m66592_udc",
Magnus Damm897cfcd2007-09-10 12:06:03 +090061 .start = IRQ_EXT4, /* irq number */
62 .end = IRQ_EXT4,
Yoshihiro Shimodae6c972f2007-07-17 13:38:54 +090063 .flags = IORESOURCE_IRQ,
64 },
65};
66
67static struct platform_device m66592_usb_peripheral_device = {
68 .name = "m66592_udc",
69 .id = -1,
70 .dev = {
71 .dma_mask = NULL, /* don't use dma */
72 .coherent_dma_mask = 0xffffffff,
73 },
74 .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
75 .resource = m66592_usb_peripheral_resources,
76};
77
Paul Mundt0c020e32006-12-06 10:43:44 +090078static struct resource cf_ide_resources[] = {
79 [0] = {
Paul Mundt71074d32007-02-14 14:49:04 +090080 .start = PA_AREA5_IO + 0x1000,
81 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
82 .flags = IORESOURCE_MEM,
Paul Mundt0c020e32006-12-06 10:43:44 +090083 },
84 [1] = {
Paul Mundt71074d32007-02-14 14:49:04 +090085 .start = PA_AREA5_IO + 0x80c,
86 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
87 .flags = IORESOURCE_MEM,
Paul Mundt0c020e32006-12-06 10:43:44 +090088 },
89 [2] = {
Magnus Damm897cfcd2007-09-10 12:06:03 +090090 .start = IRQ_CF,
Paul Mundt0c020e32006-12-06 10:43:44 +090091 .flags = IORESOURCE_IRQ,
92 },
93};
94
Paul Mundt71074d32007-02-14 14:49:04 +090095static struct pata_platform_info pata_info = {
96 .ioport_shift = 1,
97};
98
Paul Mundt0c020e32006-12-06 10:43:44 +090099static struct platform_device cf_ide_device = {
100 .name = "pata_platform",
101 .id = -1,
102 .num_resources = ARRAY_SIZE(cf_ide_resources),
103 .resource = cf_ide_resources,
Paul Mundt71074d32007-02-14 14:49:04 +0900104 .dev = {
105 .platform_data = &pata_info,
106 },
Paul Mundt0c020e32006-12-06 10:43:44 +0900107};
108
Paul Mundt3b4d9532007-02-13 15:42:28 +0900109static struct resource heartbeat_resources[] = {
110 [0] = {
111 .start = PA_OBLED,
Paul Mundta1fd3062007-08-23 15:11:44 +0900112 .end = PA_OBLED,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900113 .flags = IORESOURCE_MEM,
114 },
115};
116
Paul Mundt8786c952007-08-20 13:03:41 +0900117#ifndef CONFIG_SH_R7785RP
118static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
119
120static struct heartbeat_data heartbeat_data = {
121 .bit_pos = heartbeat_bit_pos,
122 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
123};
124#endif
125
Paul Mundt3b4d9532007-02-13 15:42:28 +0900126static struct platform_device heartbeat_device = {
127 .name = "heartbeat",
128 .id = -1,
Paul Mundt32351a22007-03-12 14:38:59 +0900129
130 /* R7785RP has a slightly more sensible FPGA.. */
131#ifndef CONFIG_SH_R7785RP
Paul Mundt3b4d9532007-02-13 15:42:28 +0900132 .dev = {
Paul Mundta1fd3062007-08-23 15:11:44 +0900133 .platform_data = &heartbeat_data,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900134 },
Paul Mundt32351a22007-03-12 14:38:59 +0900135#endif
Paul Mundt3b4d9532007-02-13 15:42:28 +0900136 .num_resources = ARRAY_SIZE(heartbeat_resources),
137 .resource = heartbeat_resources,
138};
139
Magnus Dammc6f93a32007-10-15 10:36:45 +0900140static struct ax_plat_data ax88796_platdata = {
141 .flags = AXFLG_HAS_93CX6,
142 .wordlength = 2,
143 .dcr_val = 0x1,
144 .rcr_val = 0x40,
145};
146
147static struct resource ax88796_resources[] = {
148 {
149#ifdef CONFIG_SH_R7780RP
150 .start = 0xa5800400,
151 .end = 0xa5800400 + (0x20 * 0x2) - 1,
152#else
153 .start = 0xa4100400,
154 .end = 0xa4100400 + (0x20 * 0x2) - 1,
155#endif
156 .flags = IORESOURCE_MEM,
157 },
158 {
159 .start = IRQ_AX88796,
160 .end = IRQ_AX88796,
161 .flags = IORESOURCE_IRQ,
162 },
163};
164
165static struct platform_device ax88796_device = {
166 .name = "ax88796",
167 .id = 0,
168
169 .dev = {
170 .platform_data = &ax88796_platdata,
171 },
172
173 .num_resources = ARRAY_SIZE(ax88796_resources),
174 .resource = ax88796_resources,
175};
176
177
Paul Mundt5283ecb2006-09-27 15:59:17 +0900178static struct platform_device *r7780rp_devices[] __initdata = {
Yoshihiro Shimodae6c972f2007-07-17 13:38:54 +0900179 &r8a66597_usb_host_device,
180 &m66592_usb_peripheral_device,
Paul Mundt0c020e32006-12-06 10:43:44 +0900181 &cf_ide_device,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900182 &heartbeat_device,
Magnus Dammc6f93a32007-10-15 10:36:45 +0900183 &ax88796_device,
Paul Mundt5283ecb2006-09-27 15:59:17 +0900184};
185
186static int __init r7780rp_devices_setup(void)
187{
188 return platform_add_devices(r7780rp_devices,
189 ARRAY_SIZE(r7780rp_devices));
190}
Paul Mundt32351a22007-03-12 14:38:59 +0900191device_initcall(r7780rp_devices_setup);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900192
193/*
194 * Platform specific clocks
195 */
196static void ivdr_clk_enable(struct clk *clk)
197{
Ryusuke Sakato39374aa2007-05-07 10:48:56 +0900198 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900199}
200
201static void ivdr_clk_disable(struct clk *clk)
202{
Ryusuke Sakato39374aa2007-05-07 10:48:56 +0900203 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900204}
205
206static struct clk_ops ivdr_clk_ops = {
207 .enable = ivdr_clk_enable,
208 .disable = ivdr_clk_disable,
209};
210
211static struct clk ivdr_clk = {
212 .name = "ivdr_clk",
213 .ops = &ivdr_clk_ops,
214};
215
216static struct clk *r7780rp_clocks[] = {
217 &ivdr_clk,
218};
219
Paul Mundt5283ecb2006-09-27 15:59:17 +0900220static void r7780rp_power_off(void)
221{
Paul Mundt32351a22007-03-12 14:38:59 +0900222 if (mach_is_r7780mp() || mach_is_r7785rp())
223 ctrl_outw(0x0001, PA_POFF);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900224}
225
226/*
227 * Initialize the board
228 */
Paul Mundt32351a22007-03-12 14:38:59 +0900229static void __init highlander_setup(char **cmdline_p)
Paul Mundt5283ecb2006-09-27 15:59:17 +0900230{
231 u16 ver = ctrl_inw(PA_VERREG);
232 int i;
233
Paul Mundt32351a22007-03-12 14:38:59 +0900234 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
235 mach_is_r7780rp() ? "R7780RP-1" :
236 mach_is_r7780mp() ? "R7780MP" :
237 "R7785RP");
Paul Mundt5283ecb2006-09-27 15:59:17 +0900238
239 printk(KERN_INFO "Board version: %d (revision %d), "
240 "FPGA version: %d (revision %d)\n",
241 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
242 (ver >> 4) & 0xf, ver & 0xf);
243
244 /*
245 * Enable the important clocks right away..
246 */
247 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
248 struct clk *clk = r7780rp_clocks[i];
249
250 clk_register(clk);
251 clk_enable(clk);
252 }
253
254 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
Paul Mundt32351a22007-03-12 14:38:59 +0900255
256 if (mach_is_r7780rp())
257 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
258
Paul Mundt2c081e72006-12-25 18:28:33 +0900259 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
Paul Mundt5283ecb2006-09-27 15:59:17 +0900260
261 pm_power_off = r7780rp_power_off;
262}
Paul Mundt2c7834a2006-09-27 18:17:31 +0900263
Magnus Damm897cfcd2007-09-10 12:06:03 +0900264static unsigned char irl2irq[HL_NR_IRL];
265
266int highlander_irq_demux(int irq)
267{
268 if (irq >= HL_NR_IRL || !irl2irq[irq])
269 return irq;
270
271 return irl2irq[irq];
272}
273
274void __init highlander_init_irq(void)
275{
276 unsigned char *ucp = NULL;
277
278 do {
279#ifdef CONFIG_SH_R7780MP
280 ucp = highlander_init_irq_r7780mp();
281 if (ucp)
282 break;
283#endif
284#ifdef CONFIG_SH_R7785RP
285 ucp = highlander_init_irq_r7785rp();
286 if (ucp)
287 break;
288#endif
289#ifdef CONFIG_SH_R7780RP
290 highlander_init_irq_r7780rp();
291 ucp = irl2irq;
292 break;
293#endif
294 } while (0);
295
296 if (ucp) {
297 plat_irq_setup_pins(IRQ_MODE_IRL3210);
298 memcpy(irl2irq, ucp, HL_NR_IRL);
299 }
300}
301
Paul Mundt2c7834a2006-09-27 18:17:31 +0900302/*
303 * The Machine Vector
304 */
Paul Mundt82f81f42007-05-15 15:19:34 +0900305static struct sh_machine_vector mv_highlander __initmv = {
Paul Mundt32351a22007-03-12 14:38:59 +0900306 .mv_name = "Highlander",
Paul Mundt32351a22007-03-12 14:38:59 +0900307 .mv_setup = highlander_setup,
308 .mv_init_irq = highlander_init_irq,
Magnus Damm897cfcd2007-09-10 12:06:03 +0900309 .mv_irq_demux = highlander_irq_demux,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900310};