sh: Use phyical addresses for MigoR smc91x resources
[linux-2.6-block.git] / arch / sh / boards / renesas / r7780rp / setup.c
CommitLineData
5283ecb5
PM
1/*
2 * arch/sh/boards/renesas/r7780rp/setup.c
3 *
32351a28
PM
4 * Renesas Solutions Highlander Support.
5 *
5283ecb5 6 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
71074d3a 7 * Copyright (C) 2005 - 2007 Paul Mundt
5283ecb5 8 *
32351a28
PM
9 * This contains support for the R7780RP-1, R7780MP, and R7785RP
10 * Highlander modules.
5283ecb5
PM
11 *
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>
0a87e3e9 18#include <linux/ata_platform.h>
b5751e2e 19#include <linux/types.h>
c6f93a34 20#include <net/ax88796.h>
5283ecb5 21#include <asm/machvec.h>
082c44d2 22#include <asm/r7780rp.h>
5283ecb5 23#include <asm/clock.h>
8786c952 24#include <asm/heartbeat.h>
5283ecb5 25#include <asm/io.h>
c1a34e4c 26#include <asm/io_trapped.h>
5283ecb5 27
e6c972f2
YS
28static struct resource r8a66597_usb_host_resources[] = {
29 [0] = {
30 .name = "r8a66597_hcd",
31 .start = 0xA4200000,
32 .end = 0xA42000FF,
33 .flags = IORESOURCE_MEM,
34 },
35 [1] = {
36 .name = "r8a66597_hcd",
897cfcd8
MD
37 .start = IRQ_EXT1, /* irq number */
38 .end = IRQ_EXT1,
e6c972f2
YS
39 .flags = IORESOURCE_IRQ,
40 },
41};
42
43static struct platform_device r8a66597_usb_host_device = {
44 .name = "r8a66597_hcd",
45 .id = -1,
46 .dev = {
47 .dma_mask = NULL, /* don't use dma */
48 .coherent_dma_mask = 0xffffffff,
49 },
50 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
51 .resource = r8a66597_usb_host_resources,
52};
53
54static struct resource m66592_usb_peripheral_resources[] = {
55 [0] = {
56 .name = "m66592_udc",
57 .start = 0xb0000000,
58 .end = 0xb00000FF,
59 .flags = IORESOURCE_MEM,
60 },
61 [1] = {
62 .name = "m66592_udc",
897cfcd8
MD
63 .start = IRQ_EXT4, /* irq number */
64 .end = IRQ_EXT4,
e6c972f2
YS
65 .flags = IORESOURCE_IRQ,
66 },
67};
68
69static struct platform_device m66592_usb_peripheral_device = {
70 .name = "m66592_udc",
71 .id = -1,
72 .dev = {
73 .dma_mask = NULL, /* don't use dma */
74 .coherent_dma_mask = 0xffffffff,
75 },
76 .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
77 .resource = m66592_usb_peripheral_resources,
78};
79
0c020e3d
PM
80static struct resource cf_ide_resources[] = {
81 [0] = {
71074d3a
PM
82 .start = PA_AREA5_IO + 0x1000,
83 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
84 .flags = IORESOURCE_MEM,
0c020e3d
PM
85 },
86 [1] = {
71074d3a
PM
87 .start = PA_AREA5_IO + 0x80c,
88 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
89 .flags = IORESOURCE_MEM,
0c020e3d
PM
90 },
91 [2] = {
897cfcd8 92 .start = IRQ_CF,
0c020e3d
PM
93 .flags = IORESOURCE_IRQ,
94 },
95};
96
71074d3a
PM
97static struct pata_platform_info pata_info = {
98 .ioport_shift = 1,
99};
100
0c020e3d
PM
101static struct platform_device cf_ide_device = {
102 .name = "pata_platform",
103 .id = -1,
104 .num_resources = ARRAY_SIZE(cf_ide_resources),
105 .resource = cf_ide_resources,
71074d3a
PM
106 .dev = {
107 .platform_data = &pata_info,
108 },
0c020e3d
PM
109};
110
3b4d9539
PM
111static struct resource heartbeat_resources[] = {
112 [0] = {
113 .start = PA_OBLED,
a1fd306b 114 .end = PA_OBLED,
3b4d9539
PM
115 .flags = IORESOURCE_MEM,
116 },
117};
118
8786c952
PM
119#ifndef CONFIG_SH_R7785RP
120static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
121
122static struct heartbeat_data heartbeat_data = {
123 .bit_pos = heartbeat_bit_pos,
124 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
125};
126#endif
127
3b4d9539
PM
128static struct platform_device heartbeat_device = {
129 .name = "heartbeat",
130 .id = -1,
32351a28
PM
131
132 /* R7785RP has a slightly more sensible FPGA.. */
133#ifndef CONFIG_SH_R7785RP
3b4d9539 134 .dev = {
a1fd306b 135 .platform_data = &heartbeat_data,
3b4d9539 136 },
32351a28 137#endif
3b4d9539
PM
138 .num_resources = ARRAY_SIZE(heartbeat_resources),
139 .resource = heartbeat_resources,
140};
141
c6f93a34
MD
142static struct ax_plat_data ax88796_platdata = {
143 .flags = AXFLG_HAS_93CX6,
144 .wordlength = 2,
145 .dcr_val = 0x1,
146 .rcr_val = 0x40,
147};
148
149static struct resource ax88796_resources[] = {
150 {
151#ifdef CONFIG_SH_R7780RP
152 .start = 0xa5800400,
153 .end = 0xa5800400 + (0x20 * 0x2) - 1,
154#else
155 .start = 0xa4100400,
156 .end = 0xa4100400 + (0x20 * 0x2) - 1,
157#endif
158 .flags = IORESOURCE_MEM,
159 },
160 {
161 .start = IRQ_AX88796,
162 .end = IRQ_AX88796,
163 .flags = IORESOURCE_IRQ,
164 },
165};
166
167static struct platform_device ax88796_device = {
168 .name = "ax88796",
169 .id = 0,
170
171 .dev = {
172 .platform_data = &ax88796_platdata,
173 },
174
175 .num_resources = ARRAY_SIZE(ax88796_resources),
176 .resource = ax88796_resources,
177};
178
179
5283ecb5 180static struct platform_device *r7780rp_devices[] __initdata = {
e6c972f2
YS
181 &r8a66597_usb_host_device,
182 &m66592_usb_peripheral_device,
3b4d9539 183 &heartbeat_device,
da2d7f4b 184#ifndef CONFIG_SH_R7780RP
c6f93a34 185 &ax88796_device,
da2d7f4b 186#endif
5283ecb5
PM
187};
188
c1a34e4c
MD
189/*
190 * The CF is connected using a 16-bit bus where 8-bit operations are
191 * unsupported. The linux ata driver is however using 8-bit operations, so
192 * insert a trapped io filter to convert 8-bit operations into 16-bit.
193 */
194static struct trapped_io cf_trapped_io = {
195 .resource = cf_ide_resources,
196 .num_resources = 2,
197 .minimum_bus_width = 16,
198};
199
5283ecb5
PM
200static int __init r7780rp_devices_setup(void)
201{
c1a34e4c
MD
202#ifndef CONFIG_SH_R7780RP
203 if (register_trapped_io(&cf_trapped_io) == 0)
204 platform_device_register(&cf_ide_device);
205#endif
5283ecb5
PM
206 return platform_add_devices(r7780rp_devices,
207 ARRAY_SIZE(r7780rp_devices));
208}
32351a28 209device_initcall(r7780rp_devices_setup);
5283ecb5
PM
210
211/*
212 * Platform specific clocks
213 */
214static void ivdr_clk_enable(struct clk *clk)
215{
39374aad 216 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
5283ecb5
PM
217}
218
219static void ivdr_clk_disable(struct clk *clk)
220{
39374aad 221 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
5283ecb5
PM
222}
223
224static struct clk_ops ivdr_clk_ops = {
225 .enable = ivdr_clk_enable,
226 .disable = ivdr_clk_disable,
227};
228
229static struct clk ivdr_clk = {
230 .name = "ivdr_clk",
231 .ops = &ivdr_clk_ops,
232};
233
234static struct clk *r7780rp_clocks[] = {
235 &ivdr_clk,
236};
237
5283ecb5
PM
238static void r7780rp_power_off(void)
239{
32351a28
PM
240 if (mach_is_r7780mp() || mach_is_r7785rp())
241 ctrl_outw(0x0001, PA_POFF);
5283ecb5
PM
242}
243
244/*
245 * Initialize the board
246 */
32351a28 247static void __init highlander_setup(char **cmdline_p)
5283ecb5
PM
248{
249 u16 ver = ctrl_inw(PA_VERREG);
250 int i;
251
32351a28
PM
252 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
253 mach_is_r7780rp() ? "R7780RP-1" :
254 mach_is_r7780mp() ? "R7780MP" :
255 "R7785RP");
5283ecb5
PM
256
257 printk(KERN_INFO "Board version: %d (revision %d), "
258 "FPGA version: %d (revision %d)\n",
259 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
260 (ver >> 4) & 0xf, ver & 0xf);
261
262 /*
263 * Enable the important clocks right away..
264 */
265 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
266 struct clk *clk = r7780rp_clocks[i];
267
268 clk_register(clk);
269 clk_enable(clk);
270 }
271
272 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
32351a28
PM
273
274 if (mach_is_r7780rp())
275 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
276
2c081e71 277 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
5283ecb5
PM
278
279 pm_power_off = r7780rp_power_off;
280}
2c7834a6 281
897cfcd8
MD
282static unsigned char irl2irq[HL_NR_IRL];
283
284int highlander_irq_demux(int irq)
285{
286 if (irq >= HL_NR_IRL || !irl2irq[irq])
287 return irq;
288
289 return irl2irq[irq];
290}
291
292void __init highlander_init_irq(void)
293{
294 unsigned char *ucp = NULL;
295
296 do {
297#ifdef CONFIG_SH_R7780MP
298 ucp = highlander_init_irq_r7780mp();
299 if (ucp)
300 break;
301#endif
302#ifdef CONFIG_SH_R7785RP
303 ucp = highlander_init_irq_r7785rp();
304 if (ucp)
305 break;
306#endif
307#ifdef CONFIG_SH_R7780RP
da2d7f4b
MD
308 ucp = highlander_init_irq_r7780rp();
309 if (ucp)
310 break;
897cfcd8
MD
311#endif
312 } while (0);
313
314 if (ucp) {
315 plat_irq_setup_pins(IRQ_MODE_IRL3210);
316 memcpy(irl2irq, ucp, HL_NR_IRL);
317 }
318}
319
2c7834a6
PM
320/*
321 * The Machine Vector
322 */
82f81f47 323static struct sh_machine_vector mv_highlander __initmv = {
32351a28 324 .mv_name = "Highlander",
32351a28
PM
325 .mv_setup = highlander_setup,
326 .mv_init_irq = highlander_init_irq,
897cfcd8 327 .mv_irq_demux = highlander_irq_demux,
2c7834a6 328};