2 * Renesas Technology Sales RTS7751R2D Support.
4 * Copyright (C) 2002 - 2006 Atom Create Engineering Co., Ltd.
5 * Copyright (C) 2004 - 2007 Paul Mundt
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
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/pata_platform.h>
14 #include <linux/serial_8250.h>
15 #include <linux/sm501.h>
17 #include <asm/machvec.h>
18 #include <asm/rts7751r2d.h>
19 #include <asm/voyagergx.h>
22 static void __init voyagergx_serial_init(void)
29 val = readl((void __iomem *)GPIO_MUX_HIGH);
31 writel(val, (void __iomem *)GPIO_MUX_HIGH);
36 val = readl((void __iomem *)POWER_MODE0_GATE);
37 val |= (POWER_MODE0_GATE_U0 | POWER_MODE0_GATE_U1);
38 writel(val, (void __iomem *)POWER_MODE0_GATE);
40 val = readl((void __iomem *)POWER_MODE1_GATE);
41 val |= (POWER_MODE1_GATE_U0 | POWER_MODE1_GATE_U1);
42 writel(val, (void __iomem *)POWER_MODE1_GATE);
45 static struct resource cf_ide_resources[] = {
47 .start = PA_AREA5_IO + 0x1000,
48 .end = PA_AREA5_IO + 0x1000 + 0x10 - 0x2,
49 .flags = IORESOURCE_MEM,
52 .start = PA_AREA5_IO + 0x80c,
53 .end = PA_AREA5_IO + 0x80c,
54 .flags = IORESOURCE_MEM,
56 #ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */
59 .flags = IORESOURCE_IRQ,
64 static struct pata_platform_info pata_info = {
68 static struct platform_device cf_ide_device = {
69 .name = "pata_platform",
71 .num_resources = ARRAY_SIZE(cf_ide_resources),
72 .resource = cf_ide_resources,
74 .platform_data = &pata_info,
78 static struct resource heartbeat_resources[] = {
82 .flags = IORESOURCE_MEM,
86 static struct platform_device heartbeat_device = {
89 .num_resources = ARRAY_SIZE(heartbeat_resources),
90 .resource = heartbeat_resources,
93 #ifdef CONFIG_MFD_SM501
94 static struct plat_serial8250_port uart_platform_data[] = {
96 .membase = (void __iomem *)VOYAGER_UART_BASE,
97 .mapbase = VOYAGER_UART_BASE,
100 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
102 .uartclk = (9600 * 16),
107 static struct platform_device uart_device = {
108 .name = "serial8250",
109 .id = PLAT8250_DEV_PLATFORM,
111 .platform_data = uart_platform_data,
115 static struct resource sm501_resources[] = {
118 .end = 0x13e00000 - 1,
119 .flags = IORESOURCE_MEM,
124 .flags = IORESOURCE_MEM,
127 .start = IRQ_SM501_CV,
128 .flags = IORESOURCE_IRQ,
132 static struct platform_device sm501_device = {
135 .num_resources = ARRAY_SIZE(sm501_resources),
136 .resource = sm501_resources,
139 #endif /* CONFIG_MFD_SM501 */
141 static struct platform_device *rts7751r2d_devices[] __initdata = {
142 #ifdef CONFIG_MFD_SM501
150 static int __init rts7751r2d_devices_setup(void)
152 return platform_add_devices(rts7751r2d_devices,
153 ARRAY_SIZE(rts7751r2d_devices));
155 __initcall(rts7751r2d_devices_setup);
157 static void rts7751r2d_power_off(void)
159 ctrl_outw(0x0001, PA_POWOFF);
162 static inline unsigned char is_ide_ioaddr(unsigned long addr)
164 return ((cf_ide_resources[0].start <= addr &&
165 addr <= cf_ide_resources[0].end) ||
166 (cf_ide_resources[1].start <= addr &&
167 addr <= cf_ide_resources[1].end));
170 void rts7751r2d_writeb(u8 b, void __iomem *addr)
172 unsigned long tmp = (unsigned long __force)addr;
174 if (is_ide_ioaddr(tmp))
175 ctrl_outw((u16)b, tmp);
180 u8 rts7751r2d_readb(void __iomem *addr)
182 unsigned long tmp = (unsigned long __force)addr;
184 if (is_ide_ioaddr(tmp))
185 return ctrl_inw(tmp) & 0xff;
187 return ctrl_inb(tmp);
191 * Initialize the board
193 static void __init rts7751r2d_setup(char **cmdline_p)
195 u16 ver = ctrl_inw(PA_VERREG);
197 printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
199 printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
200 (ver >> 4) & 0xf, ver & 0xf);
202 ctrl_outw(0x0000, PA_OUTPORT);
203 pm_power_off = rts7751r2d_power_off;
205 voyagergx_serial_init();
211 static struct sh_machine_vector mv_rts7751r2d __initmv = {
212 .mv_name = "RTS7751R2D",
213 .mv_setup = rts7751r2d_setup,
214 .mv_init_irq = init_rts7751r2d_IRQ,
215 .mv_irq_demux = rts7751r2d_irq_demux,
216 .mv_writeb = rts7751r2d_writeb,
217 .mv_readb = rts7751r2d_readb,
218 #if defined(CONFIG_MFD_SM501) && defined(CONFIG_USB_OHCI_HCD)
219 .mv_consistent_alloc = voyagergx_consistent_alloc,
220 .mv_consistent_free = voyagergx_consistent_free,