blob: 44b42082a0afe721a7f9776e80c327652734c15f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Renesas Technology Sales RTS7751R2D Support.
3 *
Paul Mundt9c575482007-02-15 18:20:52 +09004 * Copyright (C) 2002 - 2006 Atom Create Engineering Co., Ltd.
5 * Copyright (C) 2004 - 2007 Paul Mundt
Paul Mundtade2b3f2006-09-27 16:48:46 +09006 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/init.h>
Paul Mundtade2b3f2006-09-27 16:48:46 +090012#include <linux/platform_device.h>
Paul Mundt9c575482007-02-15 18:20:52 +090013#include <linux/pata_platform.h>
Paul Mundtade2b3f2006-09-27 16:48:46 +090014#include <linux/serial_8250.h>
Paul Mundta56d2762006-09-27 11:43:24 +090015#include <linux/pm.h>
Paul Mundt2c7834a2006-09-27 18:17:31 +090016#include <asm/machvec.h>
Paul Mundt9c575482007-02-15 18:20:52 +090017#include <asm/rts7751r2d.h>
Paul Mundtadf18902006-09-27 17:17:27 +090018#include <asm/voyagergx.h>
Paul Mundt9c575482007-02-15 18:20:52 +090019#include <asm/io.h>
Paul Mundtade2b3f2006-09-27 16:48:46 +090020
21static void __init voyagergx_serial_init(void)
22{
23 unsigned long val;
24
25 /*
26 * GPIO Control
27 */
Paul Mundt9c575482007-02-15 18:20:52 +090028 val = readl((void __iomem *)GPIO_MUX_HIGH);
Paul Mundtade2b3f2006-09-27 16:48:46 +090029 val |= 0x00001fe0;
Paul Mundt9c575482007-02-15 18:20:52 +090030 writel(val, (void __iomem *)GPIO_MUX_HIGH);
Paul Mundtade2b3f2006-09-27 16:48:46 +090031
32 /*
33 * Power Mode Gate
34 */
Paul Mundt9c575482007-02-15 18:20:52 +090035 val = readl((void __iomem *)POWER_MODE0_GATE);
Paul Mundtade2b3f2006-09-27 16:48:46 +090036 val |= (POWER_MODE0_GATE_U0 | POWER_MODE0_GATE_U1);
Paul Mundt9c575482007-02-15 18:20:52 +090037 writel(val, (void __iomem *)POWER_MODE0_GATE);
Paul Mundtade2b3f2006-09-27 16:48:46 +090038
Paul Mundt9c575482007-02-15 18:20:52 +090039 val = readl((void __iomem *)POWER_MODE1_GATE);
Paul Mundtade2b3f2006-09-27 16:48:46 +090040 val |= (POWER_MODE1_GATE_U0 | POWER_MODE1_GATE_U1);
Paul Mundt9c575482007-02-15 18:20:52 +090041 writel(val, (void __iomem *)POWER_MODE1_GATE);
Paul Mundtade2b3f2006-09-27 16:48:46 +090042}
43
Paul Mundt9c575482007-02-15 18:20:52 +090044static struct resource cf_ide_resources[] = {
45 [0] = {
46 .start = PA_AREA5_IO + 0x1000,
47 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
48 .flags = IORESOURCE_MEM,
49 },
50 [1] = {
51 .start = PA_AREA5_IO + 0x80c,
52 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
53 .flags = IORESOURCE_MEM,
54 },
55 [2] = {
56#ifdef CONFIG_RTS7751R2D_REV11
57 .start = 1,
58#else
59 .start = 2,
60#endif
61 .flags = IORESOURCE_IRQ,
62 },
63};
64
65static struct pata_platform_info pata_info = {
66 .ioport_shift = 1,
67};
68
69static struct platform_device cf_ide_device = {
70 .name = "pata_platform",
71 .id = -1,
72 .num_resources = ARRAY_SIZE(cf_ide_resources),
73 .resource = cf_ide_resources,
74 .dev = {
75 .platform_data = &pata_info,
76 },
77};
78
79static struct plat_serial8250_port uart_platform_data[] = {
80 {
81 .membase = (void __iomem *)VOYAGER_UART_BASE,
82 .mapbase = VOYAGER_UART_BASE,
83 .iotype = UPIO_MEM,
84 .irq = VOYAGER_UART0_IRQ,
85 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
86 .regshift = 2,
87 .uartclk = (9600 * 16),
88 }
89};
90
Paul Mundtade2b3f2006-09-27 16:48:46 +090091static struct platform_device uart_device = {
92 .name = "serial8250",
Paul Mundt9c575482007-02-15 18:20:52 +090093 .id = PLAT8250_DEV_PLATFORM,
Paul Mundtade2b3f2006-09-27 16:48:46 +090094 .dev = {
95 .platform_data = uart_platform_data,
96 },
97};
98
Paul Mundt3b4d9532007-02-13 15:42:28 +090099static struct resource heartbeat_resources[] = {
100 [0] = {
101 .start = PA_OUTPORT,
102 .end = PA_OUTPORT + 8 - 1,
103 .flags = IORESOURCE_MEM,
104 },
105};
106
107static struct platform_device heartbeat_device = {
108 .name = "heartbeat",
109 .id = -1,
110 .num_resources = ARRAY_SIZE(heartbeat_resources),
111 .resource = heartbeat_resources,
112};
113
Paul Mundtade2b3f2006-09-27 16:48:46 +0900114static struct platform_device *rts7751r2d_devices[] __initdata = {
115 &uart_device,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900116 &heartbeat_device,
Paul Mundt9c575482007-02-15 18:20:52 +0900117 &cf_ide_device,
Paul Mundtade2b3f2006-09-27 16:48:46 +0900118};
119
120static int __init rts7751r2d_devices_setup(void)
121{
122 return platform_add_devices(rts7751r2d_devices,
123 ARRAY_SIZE(rts7751r2d_devices));
124}
Paul Mundt9c575482007-02-15 18:20:52 +0900125__initcall(rts7751r2d_devices_setup);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
Paul Mundta56d2762006-09-27 11:43:24 +0900127static void rts7751r2d_power_off(void)
128{
129 ctrl_outw(0x0001, PA_POWOFF);
130}
131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132/*
133 * Initialize the board
134 */
Paul Mundt2c7834a2006-09-27 18:17:31 +0900135static void __init rts7751r2d_setup(char **cmdline_p)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136{
Paul Mundt9c575482007-02-15 18:20:52 +0900137 u16 ver = ctrl_inw(PA_VERREG);
138
139 printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
140
141 printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
142 (ver >> 4) & 0xf, ver & 0xf);
Paul Mundt2c7834a2006-09-27 18:17:31 +0900143
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 ctrl_outw(0x0000, PA_OUTPORT);
Paul Mundta56d2762006-09-27 11:43:24 +0900145 pm_power_off = rts7751r2d_power_off;
Paul Mundtade2b3f2006-09-27 16:48:46 +0900146
147 voyagergx_serial_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148}
Paul Mundt2c7834a2006-09-27 18:17:31 +0900149
150/*
151 * The Machine Vector
152 */
153struct sh_machine_vector mv_rts7751r2d __initmv = {
154 .mv_name = "RTS7751R2D",
155 .mv_setup = rts7751r2d_setup,
156 .mv_nr_irqs = 72,
157
Paul Mundt2c7834a2006-09-27 18:17:31 +0900158 .mv_init_irq = init_rts7751r2d_IRQ,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900159 .mv_irq_demux = rts7751r2d_irq_demux,
160
161#ifdef CONFIG_USB_SM501
162 .mv_consistent_alloc = voyagergx_consistent_alloc,
163 .mv_consistent_free = voyagergx_consistent_free,
164#endif
165};
166ALIAS_MV(rts7751r2d)