Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[deliverable/linux.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>
71074d3a 18#include <linux/pata_platform.h>
5283ecb5 19#include <asm/machvec.h>
082c44d2 20#include <asm/r7780rp.h>
5283ecb5 21#include <asm/clock.h>
8786c952 22#include <asm/heartbeat.h>
5283ecb5
PM
23#include <asm/io.h>
24
e6c972f2
YS
25static struct resource r8a66597_usb_host_resources[] = {
26 [0] = {
27 .name = "r8a66597_hcd",
28 .start = 0xA4200000,
29 .end = 0xA42000FF,
30 .flags = IORESOURCE_MEM,
31 },
32 [1] = {
33 .name = "r8a66597_hcd",
897cfcd8
MD
34 .start = IRQ_EXT1, /* irq number */
35 .end = IRQ_EXT1,
e6c972f2
YS
36 .flags = IORESOURCE_IRQ,
37 },
38};
39
40static struct platform_device r8a66597_usb_host_device = {
41 .name = "r8a66597_hcd",
42 .id = -1,
43 .dev = {
44 .dma_mask = NULL, /* don't use dma */
45 .coherent_dma_mask = 0xffffffff,
46 },
47 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
48 .resource = r8a66597_usb_host_resources,
49};
50
51static struct resource m66592_usb_peripheral_resources[] = {
52 [0] = {
53 .name = "m66592_udc",
54 .start = 0xb0000000,
55 .end = 0xb00000FF,
56 .flags = IORESOURCE_MEM,
57 },
58 [1] = {
59 .name = "m66592_udc",
897cfcd8
MD
60 .start = IRQ_EXT4, /* irq number */
61 .end = IRQ_EXT4,
e6c972f2
YS
62 .flags = IORESOURCE_IRQ,
63 },
64};
65
66static struct platform_device m66592_usb_peripheral_device = {
67 .name = "m66592_udc",
68 .id = -1,
69 .dev = {
70 .dma_mask = NULL, /* don't use dma */
71 .coherent_dma_mask = 0xffffffff,
72 },
73 .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
74 .resource = m66592_usb_peripheral_resources,
75};
76
0c020e3d
PM
77static struct resource cf_ide_resources[] = {
78 [0] = {
71074d3a
PM
79 .start = PA_AREA5_IO + 0x1000,
80 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
81 .flags = IORESOURCE_MEM,
0c020e3d
PM
82 },
83 [1] = {
71074d3a
PM
84 .start = PA_AREA5_IO + 0x80c,
85 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
86 .flags = IORESOURCE_MEM,
0c020e3d
PM
87 },
88 [2] = {
897cfcd8 89 .start = IRQ_CF,
0c020e3d
PM
90 .flags = IORESOURCE_IRQ,
91 },
92};
93
71074d3a
PM
94static struct pata_platform_info pata_info = {
95 .ioport_shift = 1,
96};
97
0c020e3d
PM
98static struct platform_device cf_ide_device = {
99 .name = "pata_platform",
100 .id = -1,
101 .num_resources = ARRAY_SIZE(cf_ide_resources),
102 .resource = cf_ide_resources,
71074d3a
PM
103 .dev = {
104 .platform_data = &pata_info,
105 },
0c020e3d
PM
106};
107
3b4d9539
PM
108static struct resource heartbeat_resources[] = {
109 [0] = {
110 .start = PA_OBLED,
a1fd306b 111 .end = PA_OBLED,
3b4d9539
PM
112 .flags = IORESOURCE_MEM,
113 },
114};
115
8786c952
PM
116#ifndef CONFIG_SH_R7785RP
117static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
118
119static struct heartbeat_data heartbeat_data = {
120 .bit_pos = heartbeat_bit_pos,
121 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
122};
123#endif
124
3b4d9539
PM
125static struct platform_device heartbeat_device = {
126 .name = "heartbeat",
127 .id = -1,
32351a28
PM
128
129 /* R7785RP has a slightly more sensible FPGA.. */
130#ifndef CONFIG_SH_R7785RP
3b4d9539 131 .dev = {
a1fd306b 132 .platform_data = &heartbeat_data,
3b4d9539 133 },
32351a28 134#endif
3b4d9539
PM
135 .num_resources = ARRAY_SIZE(heartbeat_resources),
136 .resource = heartbeat_resources,
137};
138
5283ecb5 139static struct platform_device *r7780rp_devices[] __initdata = {
e6c972f2
YS
140 &r8a66597_usb_host_device,
141 &m66592_usb_peripheral_device,
0c020e3d 142 &cf_ide_device,
3b4d9539 143 &heartbeat_device,
5283ecb5
PM
144};
145
146static int __init r7780rp_devices_setup(void)
147{
148 return platform_add_devices(r7780rp_devices,
149 ARRAY_SIZE(r7780rp_devices));
150}
32351a28 151device_initcall(r7780rp_devices_setup);
5283ecb5
PM
152
153/*
154 * Platform specific clocks
155 */
156static void ivdr_clk_enable(struct clk *clk)
157{
39374aad 158 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
5283ecb5
PM
159}
160
161static void ivdr_clk_disable(struct clk *clk)
162{
39374aad 163 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
5283ecb5
PM
164}
165
166static struct clk_ops ivdr_clk_ops = {
167 .enable = ivdr_clk_enable,
168 .disable = ivdr_clk_disable,
169};
170
171static struct clk ivdr_clk = {
172 .name = "ivdr_clk",
173 .ops = &ivdr_clk_ops,
174};
175
176static struct clk *r7780rp_clocks[] = {
177 &ivdr_clk,
178};
179
5283ecb5
PM
180static void r7780rp_power_off(void)
181{
32351a28
PM
182 if (mach_is_r7780mp() || mach_is_r7785rp())
183 ctrl_outw(0x0001, PA_POFF);
5283ecb5
PM
184}
185
186/*
187 * Initialize the board
188 */
32351a28 189static void __init highlander_setup(char **cmdline_p)
5283ecb5
PM
190{
191 u16 ver = ctrl_inw(PA_VERREG);
192 int i;
193
32351a28
PM
194 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
195 mach_is_r7780rp() ? "R7780RP-1" :
196 mach_is_r7780mp() ? "R7780MP" :
197 "R7785RP");
5283ecb5
PM
198
199 printk(KERN_INFO "Board version: %d (revision %d), "
200 "FPGA version: %d (revision %d)\n",
201 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
202 (ver >> 4) & 0xf, ver & 0xf);
203
204 /*
205 * Enable the important clocks right away..
206 */
207 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
208 struct clk *clk = r7780rp_clocks[i];
209
210 clk_register(clk);
211 clk_enable(clk);
212 }
213
214 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
32351a28
PM
215
216 if (mach_is_r7780rp())
217 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
218
2c081e71 219 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
5283ecb5
PM
220
221 pm_power_off = r7780rp_power_off;
222}
2c7834a6 223
897cfcd8
MD
224static unsigned char irl2irq[HL_NR_IRL];
225
226int highlander_irq_demux(int irq)
227{
228 if (irq >= HL_NR_IRL || !irl2irq[irq])
229 return irq;
230
231 return irl2irq[irq];
232}
233
234void __init highlander_init_irq(void)
235{
236 unsigned char *ucp = NULL;
237
238 do {
239#ifdef CONFIG_SH_R7780MP
240 ucp = highlander_init_irq_r7780mp();
241 if (ucp)
242 break;
243#endif
244#ifdef CONFIG_SH_R7785RP
245 ucp = highlander_init_irq_r7785rp();
246 if (ucp)
247 break;
248#endif
249#ifdef CONFIG_SH_R7780RP
250 highlander_init_irq_r7780rp();
251 ucp = irl2irq;
252 break;
253#endif
254 } while (0);
255
256 if (ucp) {
257 plat_irq_setup_pins(IRQ_MODE_IRL3210);
258 memcpy(irl2irq, ucp, HL_NR_IRL);
259 }
260}
261
2c7834a6
PM
262/*
263 * The Machine Vector
264 */
82f81f47 265static struct sh_machine_vector mv_highlander __initmv = {
32351a28 266 .mv_name = "Highlander",
32351a28
PM
267 .mv_setup = highlander_setup,
268 .mv_init_irq = highlander_init_irq,
897cfcd8 269 .mv_irq_demux = highlander_irq_demux,
2c7834a6 270};
This page took 0.237785 seconds and 5 git commands to generate.