setup.c 4.1 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3
/*
 * Renesas Technology Sales RTS7751R2D Support.
 *
P
Paul Mundt 已提交
4 5
 * Copyright (C) 2002 - 2006 Atom Create Engineering Co., Ltd.
 * Copyright (C) 2004 - 2007 Paul Mundt
6 7 8 9
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
L
Linus Torvalds 已提交
10 11
 */
#include <linux/init.h>
12
#include <linux/platform_device.h>
P
Paul Mundt 已提交
13
#include <linux/pata_platform.h>
14
#include <linux/serial_8250.h>
15
#include <linux/sm501.h>
16
#include <linux/pm.h>
P
Paul Mundt 已提交
17
#include <asm/machvec.h>
P
Paul Mundt 已提交
18
#include <asm/rts7751r2d.h>
19
#include <asm/voyagergx.h>
P
Paul Mundt 已提交
20
#include <asm/io.h>
21 22 23 24 25 26 27 28

static void __init voyagergx_serial_init(void)
{
	unsigned long val;

	/*
	 * GPIO Control
	 */
P
Paul Mundt 已提交
29
	val = readl((void __iomem *)GPIO_MUX_HIGH);
30
	val |= 0x00001fe0;
P
Paul Mundt 已提交
31
	writel(val, (void __iomem *)GPIO_MUX_HIGH);
32 33 34 35

	/*
	 * Power Mode Gate
	 */
P
Paul Mundt 已提交
36
	val = readl((void __iomem *)POWER_MODE0_GATE);
37
	val |= (POWER_MODE0_GATE_U0 | POWER_MODE0_GATE_U1);
P
Paul Mundt 已提交
38
	writel(val, (void __iomem *)POWER_MODE0_GATE);
39

P
Paul Mundt 已提交
40
	val = readl((void __iomem *)POWER_MODE1_GATE);
41
	val |= (POWER_MODE1_GATE_U0 | POWER_MODE1_GATE_U1);
P
Paul Mundt 已提交
42
	writel(val, (void __iomem *)POWER_MODE1_GATE);
43 44
}

P
Paul Mundt 已提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
static struct resource cf_ide_resources[] = {
	[0] = {
		.start	= PA_AREA5_IO + 0x1000,
		.end	= PA_AREA5_IO + 0x1000 + 0x08 - 1,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= PA_AREA5_IO + 0x80c,
		.end	= PA_AREA5_IO + 0x80c + 0x16 - 1,
		.flags	= IORESOURCE_MEM,
	},
	[2] = {
#ifdef CONFIG_RTS7751R2D_REV11
		.start	= 1,
#else
		.start	= 2,
#endif
		.flags	= IORESOURCE_IRQ,
	},
};

static struct pata_platform_info pata_info = {
	.ioport_shift	= 1,
};

static struct platform_device cf_ide_device  = {
	.name		= "pata_platform",
	.id		= -1,
	.num_resources	= ARRAY_SIZE(cf_ide_resources),
	.resource	= cf_ide_resources,
	.dev	= {
		.platform_data	= &pata_info,
	},
};

static struct plat_serial8250_port uart_platform_data[] = {
	{
		.membase	= (void __iomem *)VOYAGER_UART_BASE,
		.mapbase	= VOYAGER_UART_BASE,
		.iotype		= UPIO_MEM,
		.irq		= VOYAGER_UART0_IRQ,
		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
		.regshift	= 2,
		.uartclk	= (9600 * 16),
89 90
	},
	{ 0 },
P
Paul Mundt 已提交
91 92
};

93 94
static struct platform_device uart_device = {
	.name		= "serial8250",
P
Paul Mundt 已提交
95
	.id		= PLAT8250_DEV_PLATFORM,
96 97 98 99 100
	.dev		= {
		.platform_data	= uart_platform_data,
	},
};

101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
static struct resource heartbeat_resources[] = {
	[0] = {
		.start	= PA_OUTPORT,
		.end	= PA_OUTPORT + 8 - 1,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device heartbeat_device = {
	.name		= "heartbeat",
	.id		= -1,
	.num_resources	= ARRAY_SIZE(heartbeat_resources),
	.resource	= heartbeat_resources,
};

116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
static struct resource sm501_resources[] = {
	[0]	= {
		.start	= 0x10000000,
		.end	= 0x13e00000 - 1,
		.flags	= IORESOURCE_MEM,
	},
	[1]	= {
		.start	= 0x13e00000,
		.end	= 0x13ffffff,
		.flags	= IORESOURCE_MEM,
	},
	[2]	= {
		.start	= 32,
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device sm501_device = {
	.name		= "sm501",
	.id		= -1,
	.num_resources	= ARRAY_SIZE(sm501_resources),
	.resource	= sm501_resources,
};

140 141
static struct platform_device *rts7751r2d_devices[] __initdata = {
	&uart_device,
142
	&heartbeat_device,
P
Paul Mundt 已提交
143
	&cf_ide_device,
144
	&sm501_device,
145 146 147 148 149 150 151
};

static int __init rts7751r2d_devices_setup(void)
{
	return platform_add_devices(rts7751r2d_devices,
				    ARRAY_SIZE(rts7751r2d_devices));
}
P
Paul Mundt 已提交
152
__initcall(rts7751r2d_devices_setup);
L
Linus Torvalds 已提交
153

154 155 156 157 158
static void rts7751r2d_power_off(void)
{
	ctrl_outw(0x0001, PA_POWOFF);
}

L
Linus Torvalds 已提交
159 160 161
/*
 * Initialize the board
 */
P
Paul Mundt 已提交
162
static void __init rts7751r2d_setup(char **cmdline_p)
L
Linus Torvalds 已提交
163
{
P
Paul Mundt 已提交
164 165 166 167 168 169
	u16 ver = ctrl_inw(PA_VERREG);

	printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");

	printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
					(ver >> 4) & 0xf, ver & 0xf);
P
Paul Mundt 已提交
170

L
Linus Torvalds 已提交
171
	ctrl_outw(0x0000, PA_OUTPORT);
172
	pm_power_off = rts7751r2d_power_off;
173 174

	voyagergx_serial_init();
L
Linus Torvalds 已提交
175
}
P
Paul Mundt 已提交
176 177 178 179

/*
 * The Machine Vector
 */
P
Paul Mundt 已提交
180
static struct sh_machine_vector mv_rts7751r2d __initmv = {
P
Paul Mundt 已提交
181 182 183 184 185 186 187 188 189 190 191 192
	.mv_name		= "RTS7751R2D",
	.mv_setup		= rts7751r2d_setup,
	.mv_nr_irqs		= 72,

	.mv_init_irq		= init_rts7751r2d_IRQ,
	.mv_irq_demux		= rts7751r2d_irq_demux,

#ifdef CONFIG_USB_SM501
	.mv_consistent_alloc	= voyagergx_consistent_alloc,
	.mv_consistent_free	= voyagergx_consistent_free,
#endif
};