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>
18 #include <linux/platform_device.h>
19 #include <linux/ata_platform.h>
20 #include <linux/types.h>
21 #include <linux/mtd/physmap.h>
22 #include <linux/i2c.h>
23 #include <linux/irq.h>
24 #include <linux/interrupt.h>
25 #include <linux/usb/r8a66597.h>
26 #include <linux/usb/m66592.h>
27 #include <net/ax88796.h>
28 #include <asm/machvec.h>
29 #include <mach/highlander.h>
30 #include <asm/clkdev.h>
31 #include <asm/clock.h>
32 #include <asm/heartbeat.h>
34 #include <asm/io_trapped.h>
36 static struct r8a66597_platdata r8a66597_data = {
37 .xtal = R8A66597_PLATDATA_XTAL_12MHZ,
41 static struct resource r8a66597_usb_host_resources[] = {
45 .flags = IORESOURCE_MEM,
48 .start = IRQ_EXT1, /* irq number */
50 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
54 static struct platform_device r8a66597_usb_host_device = {
55 .name = "r8a66597_hcd",
58 .dma_mask = NULL, /* don't use dma */
59 .coherent_dma_mask = 0xffffffff,
60 .platform_data = &r8a66597_data,
62 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
63 .resource = r8a66597_usb_host_resources,
66 static struct m66592_platdata usbf_platdata = {
67 .xtal = M66592_PLATDATA_XTAL_24MHZ,
71 static struct resource m66592_usb_peripheral_resources[] = {
76 .flags = IORESOURCE_MEM,
80 .start = IRQ_EXT4, /* irq number */
82 .flags = IORESOURCE_IRQ,
86 static struct platform_device m66592_usb_peripheral_device = {
90 .dma_mask = NULL, /* don't use dma */
91 .coherent_dma_mask = 0xffffffff,
92 .platform_data = &usbf_platdata,
94 .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
95 .resource = m66592_usb_peripheral_resources,
98 static struct resource cf_ide_resources[] = {
100 .start = PA_AREA5_IO + 0x1000,
101 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
102 .flags = IORESOURCE_MEM,
105 .start = PA_AREA5_IO + 0x80c,
106 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
107 .flags = IORESOURCE_MEM,
111 .flags = IORESOURCE_IRQ,
115 static struct pata_platform_info pata_info = {
119 static struct platform_device cf_ide_device = {
120 .name = "pata_platform",
122 .num_resources = ARRAY_SIZE(cf_ide_resources),
123 .resource = cf_ide_resources,
125 .platform_data = &pata_info,
129 static struct resource heartbeat_resources[] = {
133 .flags = IORESOURCE_MEM,
137 #ifndef CONFIG_SH_R7785RP
138 static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
140 static struct heartbeat_data heartbeat_data = {
141 .bit_pos = heartbeat_bit_pos,
142 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
146 static struct platform_device heartbeat_device = {
150 /* R7785RP has a slightly more sensible FPGA.. */
151 #ifndef CONFIG_SH_R7785RP
153 .platform_data = &heartbeat_data,
156 .num_resources = ARRAY_SIZE(heartbeat_resources),
157 .resource = heartbeat_resources,
160 static struct ax_plat_data ax88796_platdata = {
161 .flags = AXFLG_HAS_93CX6,
167 static struct resource ax88796_resources[] = {
169 #ifdef CONFIG_SH_R7780RP
171 .end = 0xa5800400 + (0x20 * 0x2) - 1,
174 .end = 0xa4100400 + (0x20 * 0x2) - 1,
176 .flags = IORESOURCE_MEM,
179 .start = IRQ_AX88796,
181 .flags = IORESOURCE_IRQ,
185 static struct platform_device ax88796_device = {
190 .platform_data = &ax88796_platdata,
193 .num_resources = ARRAY_SIZE(ax88796_resources),
194 .resource = ax88796_resources,
197 static struct mtd_partition nor_flash_partitions[] = {
200 .offset = 0x00000000,
205 .offset = MTDPART_OFS_APPEND,
210 .offset = MTDPART_OFS_APPEND,
211 .size = 4 * 1024 * 1024,
215 .offset = MTDPART_OFS_APPEND,
216 .size = MTDPART_SIZ_FULL,
220 static struct physmap_flash_data nor_flash_data = {
222 .parts = nor_flash_partitions,
223 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
226 /* This config is flash board for mass production. */
227 static struct resource nor_flash_resources[] = {
229 .start = PA_NORFLASH_ADDR,
230 .end = PA_NORFLASH_ADDR + PA_NORFLASH_SIZE - 1,
231 .flags = IORESOURCE_MEM,
235 static struct platform_device nor_flash_device = {
236 .name = "physmap-flash",
238 .platform_data = &nor_flash_data,
240 .num_resources = ARRAY_SIZE(nor_flash_resources),
241 .resource = nor_flash_resources,
244 static struct resource smbus_resources[] = {
247 .end = PA_SMCR + 0x100 - 1,
248 .flags = IORESOURCE_MEM,
253 .flags = IORESOURCE_IRQ,
257 static struct platform_device smbus_device = {
258 .name = "i2c-highlander",
260 .num_resources = ARRAY_SIZE(smbus_resources),
261 .resource = smbus_resources,
264 static struct i2c_board_info __initdata highlander_i2c_devices[] = {
266 I2C_BOARD_INFO("r2025sd", 0x32),
270 static struct platform_device *r7780rp_devices[] __initdata = {
271 &r8a66597_usb_host_device,
272 &m66592_usb_peripheral_device,
276 #ifndef CONFIG_SH_R7780RP
282 * The CF is connected using a 16-bit bus where 8-bit operations are
283 * unsupported. The linux ata driver is however using 8-bit operations, so
284 * insert a trapped io filter to convert 8-bit operations into 16-bit.
286 static struct trapped_io cf_trapped_io = {
287 .resource = cf_ide_resources,
289 .minimum_bus_width = 16,
292 static int __init r7780rp_devices_setup(void)
296 #ifndef CONFIG_SH_R7780RP
297 if (register_trapped_io(&cf_trapped_io) == 0)
298 ret |= platform_device_register(&cf_ide_device);
301 ret |= platform_add_devices(r7780rp_devices,
302 ARRAY_SIZE(r7780rp_devices));
304 ret |= i2c_register_board_info(0, highlander_i2c_devices,
305 ARRAY_SIZE(highlander_i2c_devices));
309 device_initcall(r7780rp_devices_setup);
312 * Platform specific clocks
314 static int ivdr_clk_enable(struct clk *clk)
316 __raw_writew(__raw_readw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
320 static void ivdr_clk_disable(struct clk *clk)
322 __raw_writew(__raw_readw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
325 static struct clk_ops ivdr_clk_ops = {
326 .enable = ivdr_clk_enable,
327 .disable = ivdr_clk_disable,
330 static struct clk ivdr_clk = {
331 .ops = &ivdr_clk_ops,
334 static struct clk *r7780rp_clocks[] = {
338 #define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk }
340 static struct clk_lookup lookups[] = {
342 CLKDEV_CON_ID("ivdr_clk", &ivdr_clk),
345 static void r7780rp_power_off(void)
347 if (mach_is_r7780mp() || mach_is_r7785rp())
348 __raw_writew(0x0001, PA_POFF);
352 * Initialize the board
354 static void __init highlander_setup(char **cmdline_p)
356 u16 ver = __raw_readw(PA_VERREG);
359 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
360 mach_is_r7780rp() ? "R7780RP-1" :
361 mach_is_r7780mp() ? "R7780MP" :
364 printk(KERN_INFO "Board version: %d (revision %d), "
365 "FPGA version: %d (revision %d)\n",
366 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
367 (ver >> 4) & 0xf, ver & 0xf);
369 highlander_plat_pinmux_setup();
372 * Enable the important clocks right away..
374 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
375 struct clk *clk = r7780rp_clocks[i];
381 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
383 __raw_writew(0x0000, PA_OBLED); /* Clear LED. */
385 if (mach_is_r7780rp())
386 __raw_writew(0x0001, PA_SDPOW); /* SD Power ON */
388 __raw_writew(__raw_readw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
390 pm_power_off = r7780rp_power_off;
393 static unsigned char irl2irq[HL_NR_IRL];
395 static int highlander_irq_demux(int irq)
397 if (irq >= HL_NR_IRL || irq < 0 || !irl2irq[irq])
403 static void __init highlander_init_irq(void)
405 unsigned char *ucp = highlander_plat_irq_setup();
408 plat_irq_setup_pins(IRQ_MODE_IRL3210);
409 memcpy(irl2irq, ucp, HL_NR_IRL);
416 static struct sh_machine_vector mv_highlander __initmv = {
417 .mv_name = "Highlander",
418 .mv_setup = highlander_setup,
419 .mv_init_irq = highlander_init_irq,
420 .mv_irq_demux = highlander_irq_demux,