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 - 2008 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 <linux/i2c.h>
21 #include <net/ax88796.h>
22 #include <asm/machvec.h>
23 #include <mach/highlander.h>
24 #include <asm/clock.h>
25 #include <asm/heartbeat.h>
27 #include <asm/io_trapped.h>
29 static struct resource r8a66597_usb_host_resources[] = {
31 .name = "r8a66597_hcd",
34 .flags = IORESOURCE_MEM,
37 .name = "r8a66597_hcd",
38 .start = IRQ_EXT1, /* irq number */
40 .flags = IORESOURCE_IRQ,
44 static struct platform_device r8a66597_usb_host_device = {
45 .name = "r8a66597_hcd",
48 .dma_mask = NULL, /* don't use dma */
49 .coherent_dma_mask = 0xffffffff,
51 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
52 .resource = r8a66597_usb_host_resources,
55 static struct resource m66592_usb_peripheral_resources[] = {
60 .flags = IORESOURCE_MEM,
64 .start = IRQ_EXT4, /* irq number */
66 .flags = IORESOURCE_IRQ,
70 static struct platform_device m66592_usb_peripheral_device = {
74 .dma_mask = NULL, /* don't use dma */
75 .coherent_dma_mask = 0xffffffff,
77 .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
78 .resource = m66592_usb_peripheral_resources,
81 static struct resource cf_ide_resources[] = {
83 .start = PA_AREA5_IO + 0x1000,
84 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
85 .flags = IORESOURCE_MEM,
88 .start = PA_AREA5_IO + 0x80c,
89 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
90 .flags = IORESOURCE_MEM,
94 .flags = IORESOURCE_IRQ,
98 static struct pata_platform_info pata_info = {
102 static struct platform_device cf_ide_device = {
103 .name = "pata_platform",
105 .num_resources = ARRAY_SIZE(cf_ide_resources),
106 .resource = cf_ide_resources,
108 .platform_data = &pata_info,
112 static struct resource heartbeat_resources[] = {
116 .flags = IORESOURCE_MEM,
120 #ifndef CONFIG_SH_R7785RP
121 static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
123 static struct heartbeat_data heartbeat_data = {
124 .bit_pos = heartbeat_bit_pos,
125 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
129 static struct platform_device heartbeat_device = {
133 /* R7785RP has a slightly more sensible FPGA.. */
134 #ifndef CONFIG_SH_R7785RP
136 .platform_data = &heartbeat_data,
139 .num_resources = ARRAY_SIZE(heartbeat_resources),
140 .resource = heartbeat_resources,
143 static struct ax_plat_data ax88796_platdata = {
144 .flags = AXFLG_HAS_93CX6,
150 static struct resource ax88796_resources[] = {
152 #ifdef CONFIG_SH_R7780RP
154 .end = 0xa5800400 + (0x20 * 0x2) - 1,
157 .end = 0xa4100400 + (0x20 * 0x2) - 1,
159 .flags = IORESOURCE_MEM,
162 .start = IRQ_AX88796,
164 .flags = IORESOURCE_IRQ,
168 static struct platform_device ax88796_device = {
173 .platform_data = &ax88796_platdata,
176 .num_resources = ARRAY_SIZE(ax88796_resources),
177 .resource = ax88796_resources,
180 static struct resource smbus_resources[] = {
183 .end = PA_SMCR + 0x100 - 1,
184 .flags = IORESOURCE_MEM,
189 .flags = IORESOURCE_IRQ,
193 static struct platform_device smbus_device = {
194 .name = "i2c-highlander",
196 .num_resources = ARRAY_SIZE(smbus_resources),
197 .resource = smbus_resources,
200 static struct i2c_board_info __initdata highlander_i2c_devices[] = {
202 I2C_BOARD_INFO("r2025sd", 0x32),
206 static struct platform_device *r7780rp_devices[] __initdata = {
207 &r8a66597_usb_host_device,
208 &m66592_usb_peripheral_device,
211 #ifndef CONFIG_SH_R7780RP
217 * The CF is connected using a 16-bit bus where 8-bit operations are
218 * unsupported. The linux ata driver is however using 8-bit operations, so
219 * insert a trapped io filter to convert 8-bit operations into 16-bit.
221 static struct trapped_io cf_trapped_io = {
222 .resource = cf_ide_resources,
224 .minimum_bus_width = 16,
227 static int __init r7780rp_devices_setup(void)
231 #ifndef CONFIG_SH_R7780RP
232 if (register_trapped_io(&cf_trapped_io) == 0)
233 ret |= platform_device_register(&cf_ide_device);
236 ret |= platform_add_devices(r7780rp_devices,
237 ARRAY_SIZE(r7780rp_devices));
239 ret |= i2c_register_board_info(0, highlander_i2c_devices,
240 ARRAY_SIZE(highlander_i2c_devices));
244 device_initcall(r7780rp_devices_setup);
247 * Platform specific clocks
249 static void ivdr_clk_enable(struct clk *clk)
251 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
254 static void ivdr_clk_disable(struct clk *clk)
256 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
259 static struct clk_ops ivdr_clk_ops = {
260 .enable = ivdr_clk_enable,
261 .disable = ivdr_clk_disable,
264 static struct clk ivdr_clk = {
266 .ops = &ivdr_clk_ops,
269 static struct clk *r7780rp_clocks[] = {
273 static void r7780rp_power_off(void)
275 if (mach_is_r7780mp() || mach_is_r7785rp())
276 ctrl_outw(0x0001, PA_POFF);
280 * Initialize the board
282 static void __init highlander_setup(char **cmdline_p)
284 u16 ver = ctrl_inw(PA_VERREG);
287 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
288 mach_is_r7780rp() ? "R7780RP-1" :
289 mach_is_r7780mp() ? "R7780MP" :
292 printk(KERN_INFO "Board version: %d (revision %d), "
293 "FPGA version: %d (revision %d)\n",
294 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
295 (ver >> 4) & 0xf, ver & 0xf);
298 * Enable the important clocks right away..
300 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
301 struct clk *clk = r7780rp_clocks[i];
307 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
309 if (mach_is_r7780rp())
310 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
312 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
314 pm_power_off = r7780rp_power_off;
317 static unsigned char irl2irq[HL_NR_IRL];
319 static int highlander_irq_demux(int irq)
321 if (irq >= HL_NR_IRL || !irl2irq[irq])
327 static void __init highlander_init_irq(void)
329 unsigned char *ucp = highlander_plat_irq_setup();
332 plat_irq_setup_pins(IRQ_MODE_IRL3210);
333 memcpy(irl2irq, ucp, HL_NR_IRL);
340 static struct sh_machine_vector mv_highlander __initmv = {
341 .mv_name = "Highlander",
342 .mv_setup = highlander_setup,
343 .mv_init_irq = highlander_init_irq,
344 .mv_irq_demux = highlander_irq_demux,