2 * arch/sh/boards/renesas/r7780rp/setup.c
4 * Renesas Solutions Highlander Support.
6 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
7 * Copyright (C) 2005 - 2007 Paul Mundt
9 * This contains support for the R7780RP-1, R7780MP, and R7785RP
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
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>
26 #include <asm/io_trapped.h>
28 static struct resource r8a66597_usb_host_resources[] = {
30 .name = "r8a66597_hcd",
33 .flags = IORESOURCE_MEM,
36 .name = "r8a66597_hcd",
37 .start = IRQ_EXT1, /* irq number */
39 .flags = IORESOURCE_IRQ,
43 static struct platform_device r8a66597_usb_host_device = {
44 .name = "r8a66597_hcd",
47 .dma_mask = NULL, /* don't use dma */
48 .coherent_dma_mask = 0xffffffff,
50 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
51 .resource = r8a66597_usb_host_resources,
54 static struct resource m66592_usb_peripheral_resources[] = {
59 .flags = IORESOURCE_MEM,
63 .start = IRQ_EXT4, /* irq number */
65 .flags = IORESOURCE_IRQ,
69 static struct platform_device m66592_usb_peripheral_device = {
73 .dma_mask = NULL, /* don't use dma */
74 .coherent_dma_mask = 0xffffffff,
76 .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
77 .resource = m66592_usb_peripheral_resources,
80 static struct resource cf_ide_resources[] = {
82 .start = PA_AREA5_IO + 0x1000,
83 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
84 .flags = IORESOURCE_MEM,
87 .start = PA_AREA5_IO + 0x80c,
88 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
89 .flags = IORESOURCE_MEM,
93 .flags = IORESOURCE_IRQ,
97 static struct pata_platform_info pata_info = {
101 static struct platform_device cf_ide_device = {
102 .name = "pata_platform",
104 .num_resources = ARRAY_SIZE(cf_ide_resources),
105 .resource = cf_ide_resources,
107 .platform_data = &pata_info,
111 static struct resource heartbeat_resources[] = {
115 .flags = IORESOURCE_MEM,
119 #ifndef CONFIG_SH_R7785RP
120 static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
122 static struct heartbeat_data heartbeat_data = {
123 .bit_pos = heartbeat_bit_pos,
124 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
128 static struct platform_device heartbeat_device = {
132 /* R7785RP has a slightly more sensible FPGA.. */
133 #ifndef CONFIG_SH_R7785RP
135 .platform_data = &heartbeat_data,
138 .num_resources = ARRAY_SIZE(heartbeat_resources),
139 .resource = heartbeat_resources,
142 static struct ax_plat_data ax88796_platdata = {
143 .flags = AXFLG_HAS_93CX6,
149 static struct resource ax88796_resources[] = {
151 #ifdef CONFIG_SH_R7780RP
153 .end = 0xa5800400 + (0x20 * 0x2) - 1,
156 .end = 0xa4100400 + (0x20 * 0x2) - 1,
158 .flags = IORESOURCE_MEM,
161 .start = IRQ_AX88796,
163 .flags = IORESOURCE_IRQ,
167 static struct platform_device ax88796_device = {
172 .platform_data = &ax88796_platdata,
175 .num_resources = ARRAY_SIZE(ax88796_resources),
176 .resource = ax88796_resources,
180 static struct platform_device *r7780rp_devices[] __initdata = {
181 &r8a66597_usb_host_device,
182 &m66592_usb_peripheral_device,
184 #ifndef CONFIG_SH_R7780RP
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.
194 static struct trapped_io cf_trapped_io = {
195 .resource = cf_ide_resources,
197 .minimum_bus_width = 16,
200 static int __init r7780rp_devices_setup(void)
202 #ifndef CONFIG_SH_R7780RP
203 if (register_trapped_io(&cf_trapped_io) == 0)
204 platform_device_register(&cf_ide_device);
206 return platform_add_devices(r7780rp_devices,
207 ARRAY_SIZE(r7780rp_devices));
209 device_initcall(r7780rp_devices_setup);
212 * Platform specific clocks
214 static void ivdr_clk_enable(struct clk *clk)
216 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
219 static void ivdr_clk_disable(struct clk *clk)
221 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
224 static struct clk_ops ivdr_clk_ops = {
225 .enable = ivdr_clk_enable,
226 .disable = ivdr_clk_disable,
229 static struct clk ivdr_clk = {
231 .ops = &ivdr_clk_ops,
234 static struct clk *r7780rp_clocks[] = {
238 static void r7780rp_power_off(void)
240 if (mach_is_r7780mp() || mach_is_r7785rp())
241 ctrl_outw(0x0001, PA_POFF);
245 * Initialize the board
247 static void __init highlander_setup(char **cmdline_p)
249 u16 ver = ctrl_inw(PA_VERREG);
252 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
253 mach_is_r7780rp() ? "R7780RP-1" :
254 mach_is_r7780mp() ? "R7780MP" :
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);
263 * Enable the important clocks right away..
265 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
266 struct clk *clk = r7780rp_clocks[i];
272 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
274 if (mach_is_r7780rp())
275 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
277 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
279 pm_power_off = r7780rp_power_off;
282 static unsigned char irl2irq[HL_NR_IRL];
284 int highlander_irq_demux(int irq)
286 if (irq >= HL_NR_IRL || !irl2irq[irq])
292 void __init highlander_init_irq(void)
294 unsigned char *ucp = NULL;
297 #ifdef CONFIG_SH_R7780MP
298 ucp = highlander_init_irq_r7780mp();
302 #ifdef CONFIG_SH_R7785RP
303 ucp = highlander_init_irq_r7785rp();
307 #ifdef CONFIG_SH_R7780RP
308 ucp = highlander_init_irq_r7780rp();
315 plat_irq_setup_pins(IRQ_MODE_IRL3210);
316 memcpy(irl2irq, ucp, HL_NR_IRL);
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,