setup.c 6.2 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>
13
#include <linux/ata_platform.h>
14
#include <linux/sm501.h>
M
Magnus Damm 已提交
15
#include <linux/sm501-regs.h>
16
#include <linux/pm.h>
17
#include <linux/fb.h>
18 19
#include <linux/spi/spi.h>
#include <linux/spi/spi_bitbang.h>
P
Paul Mundt 已提交
20
#include <asm/machvec.h>
21
#include <mach/r2d.h>
P
Paul Mundt 已提交
22
#include <asm/io.h>
M
Magnus Damm 已提交
23
#include <asm/io_trapped.h>
24
#include <asm/spi.h>
25

P
Paul Mundt 已提交
26 27 28
static struct resource cf_ide_resources[] = {
	[0] = {
		.start	= PA_AREA5_IO + 0x1000,
A
Aoi Shinkai 已提交
29
		.end	= PA_AREA5_IO + 0x1000 + 0x10 - 0x2,
P
Paul Mundt 已提交
30 31 32 33
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= PA_AREA5_IO + 0x80c,
A
Aoi Shinkai 已提交
34
		.end	= PA_AREA5_IO + 0x80c,
P
Paul Mundt 已提交
35 36
		.flags	= IORESOURCE_MEM,
	},
M
Magnus Damm 已提交
37
#ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */
P
Paul Mundt 已提交
38
	[2] = {
39
		.start	= IRQ_CF_IDE,
P
Paul Mundt 已提交
40 41
		.flags	= IORESOURCE_IRQ,
	},
M
Magnus Damm 已提交
42
#endif
P
Paul Mundt 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
};

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,
	},
};

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 89 90 91 92 93 94 95
static struct spi_board_info spi_bus[] = {
	{
		.modalias	= "rtc-r9701",
		.max_speed_hz	= 1000000,
		.mode		= SPI_MODE_3,
	},
};

static void r2d_chip_select(struct sh_spi_info *spi, int cs, int state)
{
	BUG_ON(cs != 0);  /* Single Epson RTC-9701JE attached on CS0 */
	ctrl_outw(state == BITBANG_CS_ACTIVE, PA_RTCCE);
}

static struct sh_spi_info spi_info = {
	.num_chipselect = 1,
	.chip_select = r2d_chip_select,
};

static struct resource spi_sh_sci_resources[] = {
	{
		.start	= 0xffe00000,
		.end	= 0xffe0001f,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device spi_sh_sci_device  = {
	.name		= "spi_sh_sci",
	.id		= -1,
	.num_resources	= ARRAY_SIZE(spi_sh_sci_resources),
	.resource	= spi_sh_sci_resources,
	.dev	= {
		.platform_data	= &spi_info,
	},
};

96 97 98
static struct resource heartbeat_resources[] = {
	[0] = {
		.start	= PA_OUTPORT,
99
		.end	= PA_OUTPORT,
100 101 102 103 104 105 106 107 108 109 110
		.flags	= IORESOURCE_MEM,
	},
};

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

111 112 113 114 115 116 117 118 119 120 121 122
static struct resource sm501_resources[] = {
	[0]	= {
		.start	= 0x10000000,
		.end	= 0x13e00000 - 1,
		.flags	= IORESOURCE_MEM,
	},
	[1]	= {
		.start	= 0x13e00000,
		.end	= 0x13ffffff,
		.flags	= IORESOURCE_MEM,
	},
	[2]	= {
M
Magnus Damm 已提交
123
		.start	= IRQ_VOYAGER,
124 125 126 127
		.flags	= IORESOURCE_IRQ,
	},
};

128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
static struct fb_videomode sm501_default_mode = {
	.pixclock	= 35714,
	.xres		= 640,
	.yres		= 480,
	.left_margin	= 105,
	.right_margin	= 50,
	.upper_margin	= 35,
	.lower_margin	= 0,
	.hsync_len	= 96,
	.vsync_len	= 2,
	.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
};

static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = {
	.def_bpp	= 16,
	.def_mode	= &sm501_default_mode,
	.flags		= SM501FB_FLAG_USE_INIT_MODE |
			  SM501FB_FLAG_USE_HWCURSOR |
			  SM501FB_FLAG_USE_HWACCEL |
			  SM501FB_FLAG_DISABLE_AT_EXIT,
};

static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt = {
	.flags		= (SM501FB_FLAG_USE_INIT_MODE |
			   SM501FB_FLAG_USE_HWCURSOR |
			   SM501FB_FLAG_USE_HWACCEL |
			   SM501FB_FLAG_DISABLE_AT_EXIT),

};

static struct sm501_platdata_fb sm501_fb_pdata = {
	.fb_route	= SM501_FB_OWN,
	.fb_crt		= &sm501_pdata_fbsub_crt,
	.fb_pnl		= &sm501_pdata_fbsub_pnl,
	.flags		= SM501_FBPD_SWAP_FB_ENDIAN,
};

M
Magnus Damm 已提交
165
static struct sm501_initdata sm501_initdata = {
166
	.devices	= SM501_USE_USB_HOST | SM501_USE_UART0,
M
Magnus Damm 已提交
167 168
};

169
static struct sm501_platdata sm501_platform_data = {
M
Magnus Damm 已提交
170
	.init		= &sm501_initdata,
171 172 173
	.fb		= &sm501_fb_pdata,
};

174 175 176
static struct platform_device sm501_device = {
	.name		= "sm501",
	.id		= -1,
177 178 179
	.dev		= {
		.platform_data	= &sm501_platform_data,
	},
180 181 182 183
	.num_resources	= ARRAY_SIZE(sm501_resources),
	.resource	= sm501_resources,
};

184
static struct platform_device *rts7751r2d_devices[] __initdata = {
185
	&sm501_device,
186
	&heartbeat_device,
187
	&spi_sh_sci_device,
188 189
};

M
Magnus Damm 已提交
190 191 192 193 194 195 196 197 198 199 200
/*
 * The CF is connected with a 16-bit bus where 8-bit operations are
 * unsupported. The linux ata driver is however using 8-bit operations, so
 * insert a trapped io filter to convert 8-bit operations into 16-bit.
 */
static struct trapped_io cf_trapped_io = {
	.resource		= cf_ide_resources,
	.num_resources		= 2,
	.minimum_bus_width	= 16,
};

201 202
static int __init rts7751r2d_devices_setup(void)
{
M
Magnus Damm 已提交
203 204
	if (register_trapped_io(&cf_trapped_io) == 0)
		platform_device_register(&cf_ide_device);
205

206
	spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
207

208 209 210
	return platform_add_devices(rts7751r2d_devices,
				    ARRAY_SIZE(rts7751r2d_devices));
}
P
Paul Mundt 已提交
211
__initcall(rts7751r2d_devices_setup);
L
Linus Torvalds 已提交
212

213 214 215 216 217
static void rts7751r2d_power_off(void)
{
	ctrl_outw(0x0001, PA_POWOFF);
}

L
Linus Torvalds 已提交
218 219 220
/*
 * Initialize the board
 */
P
Paul Mundt 已提交
221
static void __init rts7751r2d_setup(char **cmdline_p)
L
Linus Torvalds 已提交
222
{
M
Magnus Damm 已提交
223
	void __iomem *sm501_reg;
P
Paul Mundt 已提交
224 225 226 227 228 229
	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 已提交
230

L
Linus Torvalds 已提交
231
	ctrl_outw(0x0000, PA_OUTPORT);
232
	pm_power_off = rts7751r2d_power_off;
233

M
Magnus Damm 已提交
234 235 236 237 238 239 240 241 242 243 244 245 246 247
	/* sm501 dram configuration:
	 * ColSizeX = 11 - External Memory Column Size: 256 words.
	 * APX = 1 - External Memory Active to Pre-Charge Delay: 7 clocks.
	 * RstX = 1 - External Memory Reset: Normal.
	 * Rfsh = 1 - Local Memory Refresh to Command Delay: 12 clocks.
	 * BwC =  1 - Local Memory Block Write Cycle Time: 2 clocks.
	 * BwP =  1 - Local Memory Block Write to Pre-Charge Delay: 1 clock.
	 * AP = 1 - Internal Memory Active to Pre-Charge Delay: 7 clocks.
	 * Rst = 1 - Internal Memory Reset: Normal.
	 * RA = 1 - Internal Memory Remain in Active State: Do not remain.
	 */

	sm501_reg = (void __iomem *)0xb3e00000 + SM501_DRAM_CONTROL;
	writel(readl(sm501_reg) | 0x00f107c0, sm501_reg);
L
Linus Torvalds 已提交
248
}
P
Paul Mundt 已提交
249 250 251 252

/*
 * The Machine Vector
 */
P
Paul Mundt 已提交
253
static struct sh_machine_vector mv_rts7751r2d __initmv = {
P
Paul Mundt 已提交
254 255 256 257 258
	.mv_name		= "RTS7751R2D",
	.mv_setup		= rts7751r2d_setup,
	.mv_init_irq		= init_rts7751r2d_IRQ,
	.mv_irq_demux		= rts7751r2d_irq_demux,
};