blob: e165d85c03b5543050d721bd98ef2b5c7b4f9166 [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 Mundtc87a7112007-03-01 18:47:08 +090015#include <linux/sm501.h>
Paul Mundta56d2762006-09-27 11:43:24 +090016#include <linux/pm.h>
Paul Mundt2c7834a2006-09-27 18:17:31 +090017#include <asm/machvec.h>
Paul Mundt9c575482007-02-15 18:20:52 +090018#include <asm/rts7751r2d.h>
Paul Mundtadf18902006-09-27 17:17:27 +090019#include <asm/voyagergx.h>
Paul Mundt9c575482007-02-15 18:20:52 +090020#include <asm/io.h>
Paul Mundtade2b3f2006-09-27 16:48:46 +090021
22static void __init voyagergx_serial_init(void)
23{
24 unsigned long val;
25
26 /*
27 * GPIO Control
28 */
Paul Mundt9c575482007-02-15 18:20:52 +090029 val = readl((void __iomem *)GPIO_MUX_HIGH);
Paul Mundtade2b3f2006-09-27 16:48:46 +090030 val |= 0x00001fe0;
Paul Mundt9c575482007-02-15 18:20:52 +090031 writel(val, (void __iomem *)GPIO_MUX_HIGH);
Paul Mundtade2b3f2006-09-27 16:48:46 +090032
33 /*
34 * Power Mode Gate
35 */
Paul Mundt9c575482007-02-15 18:20:52 +090036 val = readl((void __iomem *)POWER_MODE0_GATE);
Paul Mundtade2b3f2006-09-27 16:48:46 +090037 val |= (POWER_MODE0_GATE_U0 | POWER_MODE0_GATE_U1);
Paul Mundt9c575482007-02-15 18:20:52 +090038 writel(val, (void __iomem *)POWER_MODE0_GATE);
Paul Mundtade2b3f2006-09-27 16:48:46 +090039
Paul Mundt9c575482007-02-15 18:20:52 +090040 val = readl((void __iomem *)POWER_MODE1_GATE);
Paul Mundtade2b3f2006-09-27 16:48:46 +090041 val |= (POWER_MODE1_GATE_U0 | POWER_MODE1_GATE_U1);
Paul Mundt9c575482007-02-15 18:20:52 +090042 writel(val, (void __iomem *)POWER_MODE1_GATE);
Paul Mundtade2b3f2006-09-27 16:48:46 +090043}
44
Paul Mundt9c575482007-02-15 18:20:52 +090045static struct resource cf_ide_resources[] = {
46 [0] = {
47 .start = PA_AREA5_IO + 0x1000,
48 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
49 .flags = IORESOURCE_MEM,
50 },
51 [1] = {
52 .start = PA_AREA5_IO + 0x80c,
53 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
54 .flags = IORESOURCE_MEM,
55 },
56 [2] = {
57#ifdef CONFIG_RTS7751R2D_REV11
58 .start = 1,
59#else
60 .start = 2,
61#endif
62 .flags = IORESOURCE_IRQ,
63 },
64};
65
66static struct pata_platform_info pata_info = {
67 .ioport_shift = 1,
68};
69
70static struct platform_device cf_ide_device = {
71 .name = "pata_platform",
72 .id = -1,
73 .num_resources = ARRAY_SIZE(cf_ide_resources),
74 .resource = cf_ide_resources,
75 .dev = {
76 .platform_data = &pata_info,
77 },
78};
79
80static struct plat_serial8250_port uart_platform_data[] = {
81 {
82 .membase = (void __iomem *)VOYAGER_UART_BASE,
83 .mapbase = VOYAGER_UART_BASE,
84 .iotype = UPIO_MEM,
85 .irq = VOYAGER_UART0_IRQ,
86 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
87 .regshift = 2,
88 .uartclk = (9600 * 16),
Magnus Damm3a353822007-07-20 16:34:22 +090089 },
90 { 0 },
Paul Mundt9c575482007-02-15 18:20:52 +090091};
92
Paul Mundtade2b3f2006-09-27 16:48:46 +090093static struct platform_device uart_device = {
94 .name = "serial8250",
Paul Mundt9c575482007-02-15 18:20:52 +090095 .id = PLAT8250_DEV_PLATFORM,
Paul Mundtade2b3f2006-09-27 16:48:46 +090096 .dev = {
97 .platform_data = uart_platform_data,
98 },
99};
100
Paul Mundt3b4d9532007-02-13 15:42:28 +0900101static struct resource heartbeat_resources[] = {
102 [0] = {
103 .start = PA_OUTPORT,
104 .end = PA_OUTPORT + 8 - 1,
105 .flags = IORESOURCE_MEM,
106 },
107};
108
109static struct platform_device heartbeat_device = {
110 .name = "heartbeat",
111 .id = -1,
112 .num_resources = ARRAY_SIZE(heartbeat_resources),
113 .resource = heartbeat_resources,
114};
115
Paul Mundtc87a7112007-03-01 18:47:08 +0900116static struct resource sm501_resources[] = {
117 [0] = {
118 .start = 0x10000000,
119 .end = 0x13e00000 - 1,
120 .flags = IORESOURCE_MEM,
121 },
122 [1] = {
123 .start = 0x13e00000,
124 .end = 0x13ffffff,
125 .flags = IORESOURCE_MEM,
126 },
127 [2] = {
128 .start = 32,
129 .flags = IORESOURCE_IRQ,
130 },
131};
132
133static struct platform_device sm501_device = {
134 .name = "sm501",
135 .id = -1,
136 .num_resources = ARRAY_SIZE(sm501_resources),
137 .resource = sm501_resources,
138};
139
Paul Mundtade2b3f2006-09-27 16:48:46 +0900140static struct platform_device *rts7751r2d_devices[] __initdata = {
141 &uart_device,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900142 &heartbeat_device,
Paul Mundt9c575482007-02-15 18:20:52 +0900143 &cf_ide_device,
Paul Mundtc87a7112007-03-01 18:47:08 +0900144 &sm501_device,
Paul Mundtade2b3f2006-09-27 16:48:46 +0900145};
146
147static int __init rts7751r2d_devices_setup(void)
148{
149 return platform_add_devices(rts7751r2d_devices,
150 ARRAY_SIZE(rts7751r2d_devices));
151}
Paul Mundt9c575482007-02-15 18:20:52 +0900152__initcall(rts7751r2d_devices_setup);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
Paul Mundta56d2762006-09-27 11:43:24 +0900154static void rts7751r2d_power_off(void)
155{
156 ctrl_outw(0x0001, PA_POWOFF);
157}
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159/*
160 * Initialize the board
161 */
Paul Mundt2c7834a2006-09-27 18:17:31 +0900162static void __init rts7751r2d_setup(char **cmdline_p)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163{
Paul Mundt9c575482007-02-15 18:20:52 +0900164 u16 ver = ctrl_inw(PA_VERREG);
165
166 printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
167
168 printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
169 (ver >> 4) & 0xf, ver & 0xf);
Paul Mundt2c7834a2006-09-27 18:17:31 +0900170
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 ctrl_outw(0x0000, PA_OUTPORT);
Paul Mundta56d2762006-09-27 11:43:24 +0900172 pm_power_off = rts7751r2d_power_off;
Paul Mundtade2b3f2006-09-27 16:48:46 +0900173
174 voyagergx_serial_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175}
Paul Mundt2c7834a2006-09-27 18:17:31 +0900176
177/*
178 * The Machine Vector
179 */
Paul Mundt82f81f42007-05-15 15:19:34 +0900180static struct sh_machine_vector mv_rts7751r2d __initmv = {
Paul Mundt2c7834a2006-09-27 18:17:31 +0900181 .mv_name = "RTS7751R2D",
182 .mv_setup = rts7751r2d_setup,
183 .mv_nr_irqs = 72,
184
Paul Mundt2c7834a2006-09-27 18:17:31 +0900185 .mv_init_irq = init_rts7751r2d_IRQ,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900186 .mv_irq_demux = rts7751r2d_irq_demux,
187
188#ifdef CONFIG_USB_SM501
189 .mv_consistent_alloc = voyagergx_consistent_alloc,
190 .mv_consistent_free = voyagergx_consistent_free,
191#endif
192};