blob: 90703d5d12303bca2e5e0d1cd32166a09219d1ac [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] = {
Magnus Damm2eeec852007-08-12 15:29:16 +090057 .start = IRQ_CF_IDE,
Paul Mundt9c575482007-02-15 18:20:52 +090058 .flags = IORESOURCE_IRQ,
59 },
60};
61
62static struct pata_platform_info pata_info = {
63 .ioport_shift = 1,
64};
65
66static struct platform_device cf_ide_device = {
67 .name = "pata_platform",
68 .id = -1,
69 .num_resources = ARRAY_SIZE(cf_ide_resources),
70 .resource = cf_ide_resources,
71 .dev = {
72 .platform_data = &pata_info,
73 },
74};
75
76static struct plat_serial8250_port uart_platform_data[] = {
77 {
78 .membase = (void __iomem *)VOYAGER_UART_BASE,
79 .mapbase = VOYAGER_UART_BASE,
80 .iotype = UPIO_MEM,
Magnus Damm48180ca2007-08-03 14:27:20 +090081 .irq = IRQ_SM501_U0,
Paul Mundt9c575482007-02-15 18:20:52 +090082 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
83 .regshift = 2,
84 .uartclk = (9600 * 16),
Magnus Damm3a353822007-07-20 16:34:22 +090085 },
86 { 0 },
Paul Mundt9c575482007-02-15 18:20:52 +090087};
88
Paul Mundtade2b3f2006-09-27 16:48:46 +090089static struct platform_device uart_device = {
90 .name = "serial8250",
Paul Mundt9c575482007-02-15 18:20:52 +090091 .id = PLAT8250_DEV_PLATFORM,
Paul Mundtade2b3f2006-09-27 16:48:46 +090092 .dev = {
93 .platform_data = uart_platform_data,
94 },
95};
96
Paul Mundt3b4d9532007-02-13 15:42:28 +090097static struct resource heartbeat_resources[] = {
98 [0] = {
99 .start = PA_OUTPORT,
100 .end = PA_OUTPORT + 8 - 1,
101 .flags = IORESOURCE_MEM,
102 },
103};
104
105static struct platform_device heartbeat_device = {
106 .name = "heartbeat",
107 .id = -1,
108 .num_resources = ARRAY_SIZE(heartbeat_resources),
109 .resource = heartbeat_resources,
110};
111
Paul Mundtc87a7112007-03-01 18:47:08 +0900112static struct resource sm501_resources[] = {
113 [0] = {
114 .start = 0x10000000,
115 .end = 0x13e00000 - 1,
116 .flags = IORESOURCE_MEM,
117 },
118 [1] = {
119 .start = 0x13e00000,
120 .end = 0x13ffffff,
121 .flags = IORESOURCE_MEM,
122 },
123 [2] = {
Magnus Damm48180ca2007-08-03 14:27:20 +0900124 .start = IRQ_SM501_CV,
Paul Mundtc87a7112007-03-01 18:47:08 +0900125 .flags = IORESOURCE_IRQ,
126 },
127};
128
129static struct platform_device sm501_device = {
130 .name = "sm501",
131 .id = -1,
132 .num_resources = ARRAY_SIZE(sm501_resources),
133 .resource = sm501_resources,
134};
135
Paul Mundtade2b3f2006-09-27 16:48:46 +0900136static struct platform_device *rts7751r2d_devices[] __initdata = {
137 &uart_device,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900138 &heartbeat_device,
Paul Mundtc87a7112007-03-01 18:47:08 +0900139 &sm501_device,
Paul Mundtade2b3f2006-09-27 16:48:46 +0900140};
141
142static int __init rts7751r2d_devices_setup(void)
143{
Magnus Damm5ca95c42007-08-03 10:16:29 +0900144 int ret;
145
Magnus Damm2eeec852007-08-12 15:29:16 +0900146 if (ctrl_inw(PA_BVERREG) == 0x10) { /* R2D-PLUS */
Magnus Damm5ca95c42007-08-03 10:16:29 +0900147 ret = platform_device_register(&cf_ide_device);
148 if (ret)
149 return ret;
150 }
151
Paul Mundtade2b3f2006-09-27 16:48:46 +0900152 return platform_add_devices(rts7751r2d_devices,
153 ARRAY_SIZE(rts7751r2d_devices));
154}
Paul Mundt9c575482007-02-15 18:20:52 +0900155__initcall(rts7751r2d_devices_setup);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156
Paul Mundta56d2762006-09-27 11:43:24 +0900157static void rts7751r2d_power_off(void)
158{
159 ctrl_outw(0x0001, PA_POWOFF);
160}
161
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162/*
163 * Initialize the board
164 */
Paul Mundt2c7834a2006-09-27 18:17:31 +0900165static void __init rts7751r2d_setup(char **cmdline_p)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166{
Paul Mundt9c575482007-02-15 18:20:52 +0900167 u16 ver = ctrl_inw(PA_VERREG);
168
169 printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
170
171 printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
172 (ver >> 4) & 0xf, ver & 0xf);
Paul Mundt2c7834a2006-09-27 18:17:31 +0900173
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 ctrl_outw(0x0000, PA_OUTPORT);
Paul Mundta56d2762006-09-27 11:43:24 +0900175 pm_power_off = rts7751r2d_power_off;
Paul Mundtade2b3f2006-09-27 16:48:46 +0900176
177 voyagergx_serial_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178}
Paul Mundt2c7834a2006-09-27 18:17:31 +0900179
180/*
181 * The Machine Vector
182 */
Paul Mundt82f81f42007-05-15 15:19:34 +0900183static struct sh_machine_vector mv_rts7751r2d __initmv = {
Paul Mundt2c7834a2006-09-27 18:17:31 +0900184 .mv_name = "RTS7751R2D",
185 .mv_setup = rts7751r2d_setup,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900186
Paul Mundt2c7834a2006-09-27 18:17:31 +0900187 .mv_init_irq = init_rts7751r2d_IRQ,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900188 .mv_irq_demux = rts7751r2d_irq_demux,
189
190#ifdef CONFIG_USB_SM501
191 .mv_consistent_alloc = voyagergx_consistent_alloc,
192 .mv_consistent_free = voyagergx_consistent_free,
193#endif
194};