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/mtd/physmap.h>
21 #include <linux/i2c.h>
22 #include <linux/irq.h>
23 #include <net/ax88796.h>
24 #include <asm/machvec.h>
25 #include <mach/highlander.h>
26 #include <asm/clock.h>
27 #include <asm/heartbeat.h>
29 #include <asm/io_trapped.h>
31 static struct resource r8a66597_usb_host_resources[] = {
33 .name = "r8a66597_hcd",
36 .flags = IORESOURCE_MEM,
39 .name = "r8a66597_hcd",
40 .start = IRQ_EXT1, /* irq number */
42 .flags = IORESOURCE_IRQ,
46 static struct platform_device r8a66597_usb_host_device = {
47 .name = "r8a66597_hcd",
50 .dma_mask = NULL, /* don't use dma */
51 .coherent_dma_mask = 0xffffffff,
53 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
54 .resource = r8a66597_usb_host_resources,
57 static struct resource m66592_usb_peripheral_resources[] = {
62 .flags = IORESOURCE_MEM,
66 .start = IRQ_EXT4, /* irq number */
68 .flags = IORESOURCE_IRQ,
72 static struct platform_device m66592_usb_peripheral_device = {
76 .dma_mask = NULL, /* don't use dma */
77 .coherent_dma_mask = 0xffffffff,
79 .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
80 .resource = m66592_usb_peripheral_resources,
83 static struct resource cf_ide_resources[] = {
85 .start = PA_AREA5_IO + 0x1000,
86 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
87 .flags = IORESOURCE_MEM,
90 .start = PA_AREA5_IO + 0x80c,
91 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
92 .flags = IORESOURCE_MEM,
96 .flags = IORESOURCE_IRQ,
100 static struct pata_platform_info pata_info = {
104 static struct platform_device cf_ide_device = {
105 .name = "pata_platform",
107 .num_resources = ARRAY_SIZE(cf_ide_resources),
108 .resource = cf_ide_resources,
110 .platform_data = &pata_info,
114 static struct resource heartbeat_resources[] = {
118 .flags = IORESOURCE_MEM,
122 #ifndef CONFIG_SH_R7785RP
123 static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
125 static struct heartbeat_data heartbeat_data = {
126 .bit_pos = heartbeat_bit_pos,
127 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
131 static struct platform_device heartbeat_device = {
135 /* R7785RP has a slightly more sensible FPGA.. */
136 #ifndef CONFIG_SH_R7785RP
138 .platform_data = &heartbeat_data,
141 .num_resources = ARRAY_SIZE(heartbeat_resources),
142 .resource = heartbeat_resources,
145 static struct ax_plat_data ax88796_platdata = {
146 .flags = AXFLG_HAS_93CX6,
152 static struct resource ax88796_resources[] = {
154 #ifdef CONFIG_SH_R7780RP
156 .end = 0xa5800400 + (0x20 * 0x2) - 1,
159 .end = 0xa4100400 + (0x20 * 0x2) - 1,
161 .flags = IORESOURCE_MEM,
164 .start = IRQ_AX88796,
166 .flags = IORESOURCE_IRQ,
170 static struct platform_device ax88796_device = {
175 .platform_data = &ax88796_platdata,
178 .num_resources = ARRAY_SIZE(ax88796_resources),
179 .resource = ax88796_resources,
182 static struct mtd_partition nor_flash_partitions[] = {
185 .offset = 0x00000000,
190 .offset = MTDPART_OFS_APPEND,
195 .offset = MTDPART_OFS_APPEND,
196 .size = 4 * 1024 * 1024,
200 .offset = MTDPART_OFS_APPEND,
201 .size = MTDPART_SIZ_FULL,
205 static struct physmap_flash_data nor_flash_data = {
207 .parts = nor_flash_partitions,
208 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
211 /* This config is flash board for mass production. */
212 static struct resource nor_flash_resources[] = {
214 .start = PA_NORFLASH_ADDR,
215 .end = PA_NORFLASH_ADDR + PA_NORFLASH_SIZE - 1,
216 .flags = IORESOURCE_MEM,
220 static struct platform_device nor_flash_device = {
221 .name = "physmap-flash",
223 .platform_data = &nor_flash_data,
225 .num_resources = ARRAY_SIZE(nor_flash_resources),
226 .resource = nor_flash_resources,
229 static struct resource smbus_resources[] = {
232 .end = PA_SMCR + 0x100 - 1,
233 .flags = IORESOURCE_MEM,
238 .flags = IORESOURCE_IRQ,
242 static struct platform_device smbus_device = {
243 .name = "i2c-highlander",
245 .num_resources = ARRAY_SIZE(smbus_resources),
246 .resource = smbus_resources,
249 static struct i2c_board_info __initdata highlander_i2c_devices[] = {
251 I2C_BOARD_INFO("r2025sd", 0x32),
255 static struct platform_device *r7780rp_devices[] __initdata = {
256 &r8a66597_usb_host_device,
257 &m66592_usb_peripheral_device,
261 #ifndef CONFIG_SH_R7780RP
267 * The CF is connected using a 16-bit bus where 8-bit operations are
268 * unsupported. The linux ata driver is however using 8-bit operations, so
269 * insert a trapped io filter to convert 8-bit operations into 16-bit.
271 static struct trapped_io cf_trapped_io = {
272 .resource = cf_ide_resources,
274 .minimum_bus_width = 16,
277 static int __init r7780rp_devices_setup(void)
281 #ifndef CONFIG_SH_R7780RP
282 if (register_trapped_io(&cf_trapped_io) == 0)
283 ret |= platform_device_register(&cf_ide_device);
286 ret |= platform_add_devices(r7780rp_devices,
287 ARRAY_SIZE(r7780rp_devices));
289 ret |= i2c_register_board_info(0, highlander_i2c_devices,
290 ARRAY_SIZE(highlander_i2c_devices));
294 device_initcall(r7780rp_devices_setup);
297 * Platform specific clocks
299 static int ivdr_clk_enable(struct clk *clk)
301 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
305 static void ivdr_clk_disable(struct clk *clk)
307 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
310 static struct clk_ops ivdr_clk_ops = {
311 .enable = ivdr_clk_enable,
312 .disable = ivdr_clk_disable,
315 static struct clk ivdr_clk = {
317 .ops = &ivdr_clk_ops,
320 static struct clk *r7780rp_clocks[] = {
324 static void r7780rp_power_off(void)
326 if (mach_is_r7780mp() || mach_is_r7785rp())
327 ctrl_outw(0x0001, PA_POFF);
331 * Initialize the board
333 static void __init highlander_setup(char **cmdline_p)
335 u16 ver = ctrl_inw(PA_VERREG);
338 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
339 mach_is_r7780rp() ? "R7780RP-1" :
340 mach_is_r7780mp() ? "R7780MP" :
343 printk(KERN_INFO "Board version: %d (revision %d), "
344 "FPGA version: %d (revision %d)\n",
345 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
346 (ver >> 4) & 0xf, ver & 0xf);
348 highlander_plat_pinmux_setup();
351 * Enable the important clocks right away..
353 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
354 struct clk *clk = r7780rp_clocks[i];
360 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
362 if (mach_is_r7780rp())
363 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
365 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
367 pm_power_off = r7780rp_power_off;
370 static unsigned char irl2irq[HL_NR_IRL];
372 static int highlander_irq_demux(int irq)
374 if (irq >= HL_NR_IRL || !irl2irq[irq])
380 static void __init highlander_init_irq(void)
382 unsigned char *ucp = highlander_plat_irq_setup();
385 plat_irq_setup_pins(IRQ_MODE_IRL3210);
386 memcpy(irl2irq, ucp, HL_NR_IRL);
393 static struct sh_machine_vector mv_highlander __initmv = {
394 .mv_name = "Highlander",
395 .mv_setup = highlander_setup,
396 .mv_init_irq = highlander_init_irq,
397 .mv_irq_demux = highlander_irq_demux,