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/pata_platform.h>
19 #include <asm/machvec.h>
20 #include <asm/r7780rp.h>
21 #include <asm/clock.h>
22 #include <asm/heartbeat.h>
25 static struct resource r8a66597_usb_host_resources[] = {
27 .name = "r8a66597_hcd",
30 .flags = IORESOURCE_MEM,
33 .name = "r8a66597_hcd",
34 .start = IRQ_EXT1, /* irq number */
36 .flags = IORESOURCE_IRQ,
40 static struct platform_device r8a66597_usb_host_device = {
41 .name = "r8a66597_hcd",
44 .dma_mask = NULL, /* don't use dma */
45 .coherent_dma_mask = 0xffffffff,
47 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
48 .resource = r8a66597_usb_host_resources,
51 static struct resource m66592_usb_peripheral_resources[] = {
56 .flags = IORESOURCE_MEM,
60 .start = IRQ_EXT4, /* irq number */
62 .flags = IORESOURCE_IRQ,
66 static struct platform_device m66592_usb_peripheral_device = {
70 .dma_mask = NULL, /* don't use dma */
71 .coherent_dma_mask = 0xffffffff,
73 .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
74 .resource = m66592_usb_peripheral_resources,
77 static struct resource cf_ide_resources[] = {
79 .start = PA_AREA5_IO + 0x1000,
80 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
81 .flags = IORESOURCE_MEM,
84 .start = PA_AREA5_IO + 0x80c,
85 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
86 .flags = IORESOURCE_MEM,
90 .flags = IORESOURCE_IRQ,
94 static struct pata_platform_info pata_info = {
98 static struct platform_device cf_ide_device = {
99 .name = "pata_platform",
101 .num_resources = ARRAY_SIZE(cf_ide_resources),
102 .resource = cf_ide_resources,
104 .platform_data = &pata_info,
108 static struct resource heartbeat_resources[] = {
112 .flags = IORESOURCE_MEM,
116 #ifndef CONFIG_SH_R7785RP
117 static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
119 static struct heartbeat_data heartbeat_data = {
120 .bit_pos = heartbeat_bit_pos,
121 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
125 static struct platform_device heartbeat_device = {
129 /* R7785RP has a slightly more sensible FPGA.. */
130 #ifndef CONFIG_SH_R7785RP
132 .platform_data = &heartbeat_data,
135 .num_resources = ARRAY_SIZE(heartbeat_resources),
136 .resource = heartbeat_resources,
139 static struct platform_device *r7780rp_devices[] __initdata = {
140 &r8a66597_usb_host_device,
141 &m66592_usb_peripheral_device,
146 static int __init r7780rp_devices_setup(void)
148 return platform_add_devices(r7780rp_devices,
149 ARRAY_SIZE(r7780rp_devices));
151 device_initcall(r7780rp_devices_setup);
154 * Platform specific clocks
156 static void ivdr_clk_enable(struct clk *clk)
158 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
161 static void ivdr_clk_disable(struct clk *clk)
163 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
166 static struct clk_ops ivdr_clk_ops = {
167 .enable = ivdr_clk_enable,
168 .disable = ivdr_clk_disable,
171 static struct clk ivdr_clk = {
173 .ops = &ivdr_clk_ops,
176 static struct clk *r7780rp_clocks[] = {
180 static void r7780rp_power_off(void)
182 if (mach_is_r7780mp() || mach_is_r7785rp())
183 ctrl_outw(0x0001, PA_POFF);
187 * Initialize the board
189 static void __init highlander_setup(char **cmdline_p)
191 u16 ver = ctrl_inw(PA_VERREG);
194 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
195 mach_is_r7780rp() ? "R7780RP-1" :
196 mach_is_r7780mp() ? "R7780MP" :
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);
205 * Enable the important clocks right away..
207 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
208 struct clk *clk = r7780rp_clocks[i];
214 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
216 if (mach_is_r7780rp())
217 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
219 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
221 pm_power_off = r7780rp_power_off;
224 static unsigned char irl2irq[HL_NR_IRL];
226 int highlander_irq_demux(int irq)
228 if (irq >= HL_NR_IRL || !irl2irq[irq])
234 void __init highlander_init_irq(void)
236 unsigned char *ucp = NULL;
239 #ifdef CONFIG_SH_R7780MP
240 ucp = highlander_init_irq_r7780mp();
244 #ifdef CONFIG_SH_R7785RP
245 ucp = highlander_init_irq_r7785rp();
249 #ifdef CONFIG_SH_R7780RP
250 highlander_init_irq_r7780rp();
257 plat_irq_setup_pins(IRQ_MODE_IRL3210);
258 memcpy(irl2irq, ucp, HL_NR_IRL);
265 static struct sh_machine_vector mv_highlander __initmv = {
266 .mv_name = "Highlander",
267 .mv_setup = highlander_setup,
268 .mv_init_irq = highlander_init_irq,
269 .mv_irq_demux = highlander_irq_demux,