]> err.no Git - linux-2.6/blob - arch/sh/boards/renesas/r7780rp/setup.c
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzi...
[linux-2.6] / arch / sh / boards / renesas / r7780rp / setup.c
1 /*
2  * arch/sh/boards/renesas/r7780rp/setup.c
3  *
4  * Renesas Solutions Highlander Support.
5  *
6  * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
7  * Copyright (C) 2005 - 2007 Paul Mundt
8  *
9  * This contains support for the R7780RP-1, R7780MP, and R7785RP
10  * Highlander modules.
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>
18 #include <linux/ata_platform.h>
19 #include <linux/types.h>
20 #include <net/ax88796.h>
21 #include <asm/machvec.h>
22 #include <asm/r7780rp.h>
23 #include <asm/clock.h>
24 #include <asm/heartbeat.h>
25 #include <asm/io.h>
26 #include <asm/io_trapped.h>
27
28 static 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",
37                 .start  = IRQ_EXT1,             /* irq number */
38                 .end    = IRQ_EXT1,
39                 .flags  = IORESOURCE_IRQ,
40         },
41 };
42
43 static 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
54 static 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",
63                 .start  = IRQ_EXT4,             /* irq number */
64                 .end    = IRQ_EXT4,
65                 .flags  = IORESOURCE_IRQ,
66         },
67 };
68
69 static 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
80 static struct resource cf_ide_resources[] = {
81         [0] = {
82                 .start  = PA_AREA5_IO + 0x1000,
83                 .end    = PA_AREA5_IO + 0x1000 + 0x08 - 1,
84                 .flags  = IORESOURCE_MEM,
85         },
86         [1] = {
87                 .start  = PA_AREA5_IO + 0x80c,
88                 .end    = PA_AREA5_IO + 0x80c + 0x16 - 1,
89                 .flags  = IORESOURCE_MEM,
90         },
91         [2] = {
92                 .start  = IRQ_CF,
93                 .flags  = IORESOURCE_IRQ,
94         },
95 };
96
97 static struct pata_platform_info pata_info = {
98         .ioport_shift   = 1,
99 };
100
101 static 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,
106         .dev    = {
107                 .platform_data  = &pata_info,
108         },
109 };
110
111 static struct resource heartbeat_resources[] = {
112         [0] = {
113                 .start  = PA_OBLED,
114                 .end    = PA_OBLED,
115                 .flags  = IORESOURCE_MEM,
116         },
117 };
118
119 #ifndef CONFIG_SH_R7785RP
120 static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
121
122 static struct heartbeat_data heartbeat_data = {
123         .bit_pos        = heartbeat_bit_pos,
124         .nr_bits        = ARRAY_SIZE(heartbeat_bit_pos),
125 };
126 #endif
127
128 static struct platform_device heartbeat_device = {
129         .name           = "heartbeat",
130         .id             = -1,
131
132         /* R7785RP has a slightly more sensible FPGA.. */
133 #ifndef CONFIG_SH_R7785RP
134         .dev    = {
135                 .platform_data  = &heartbeat_data,
136         },
137 #endif
138         .num_resources  = ARRAY_SIZE(heartbeat_resources),
139         .resource       = heartbeat_resources,
140 };
141
142 static struct ax_plat_data ax88796_platdata = {
143         .flags          = AXFLG_HAS_93CX6,
144         .wordlength     = 2,
145         .dcr_val        = 0x1,
146         .rcr_val        = 0x40,
147 };
148
149 static 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
167 static 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
180 static struct platform_device *r7780rp_devices[] __initdata = {
181         &r8a66597_usb_host_device,
182         &m66592_usb_peripheral_device,
183         &heartbeat_device,
184 #ifndef CONFIG_SH_R7780RP
185         &ax88796_device,
186 #endif
187 };
188
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  */
194 static struct trapped_io cf_trapped_io = {
195         .resource               = cf_ide_resources,
196         .num_resources          = 2,
197         .minimum_bus_width      = 16,
198 };
199
200 static int __init r7780rp_devices_setup(void)
201 {
202 #ifndef CONFIG_SH_R7780RP
203         if (register_trapped_io(&cf_trapped_io) == 0)
204                 platform_device_register(&cf_ide_device);
205 #endif
206         return platform_add_devices(r7780rp_devices,
207                                     ARRAY_SIZE(r7780rp_devices));
208 }
209 device_initcall(r7780rp_devices_setup);
210
211 /*
212  * Platform specific clocks
213  */
214 static void ivdr_clk_enable(struct clk *clk)
215 {
216         ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
217 }
218
219 static void ivdr_clk_disable(struct clk *clk)
220 {
221         ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
222 }
223
224 static struct clk_ops ivdr_clk_ops = {
225         .enable         = ivdr_clk_enable,
226         .disable        = ivdr_clk_disable,
227 };
228
229 static struct clk ivdr_clk = {
230         .name           = "ivdr_clk",
231         .ops            = &ivdr_clk_ops,
232 };
233
234 static struct clk *r7780rp_clocks[] = {
235         &ivdr_clk,
236 };
237
238 static void r7780rp_power_off(void)
239 {
240         if (mach_is_r7780mp() || mach_is_r7785rp())
241                 ctrl_outw(0x0001, PA_POFF);
242 }
243
244 /*
245  * Initialize the board
246  */
247 static void __init highlander_setup(char **cmdline_p)
248 {
249         u16 ver = ctrl_inw(PA_VERREG);
250         int i;
251
252         printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
253                          mach_is_r7780rp() ? "R7780RP-1" :
254                          mach_is_r7780mp() ? "R7780MP"   :
255                                              "R7785RP");
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. */
273
274         if (mach_is_r7780rp())
275                 ctrl_outw(0x0001, PA_SDPOW);    /* SD Power ON */
276
277         ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL);     /* Si13112 */
278
279         pm_power_off = r7780rp_power_off;
280 }
281
282 static unsigned char irl2irq[HL_NR_IRL];
283
284 int highlander_irq_demux(int irq)
285 {
286         if (irq >= HL_NR_IRL || !irl2irq[irq])
287                 return irq;
288
289         return irl2irq[irq];
290 }
291
292 void __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
308                 ucp = highlander_init_irq_r7780rp();
309                 if (ucp)
310                         break;
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
320 /*
321  * The Machine Vector
322  */
323 static struct sh_machine_vector mv_highlander __initmv = {
324         .mv_name                = "Highlander",
325         .mv_setup               = highlander_setup,
326         .mv_init_irq            = highlander_init_irq,
327         .mv_irq_demux           = highlander_irq_demux,
328 };