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

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

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

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 96 97 98
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,
	},
};

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

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

114 115 116 117 118 119 120 121 122 123 124 125
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 已提交
126
		.start	= IRQ_VOYAGER,
127 128 129 130
		.flags	= IORESOURCE_IRQ,
	},
};

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 165 166 167
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 已提交
168
static struct sm501_initdata sm501_initdata = {
169
	.devices	= SM501_USE_USB_HOST | SM501_USE_UART0,
M
Magnus Damm 已提交
170 171
};

172
static struct sm501_platdata sm501_platform_data = {
M
Magnus Damm 已提交
173
	.init		= &sm501_initdata,
174 175 176
	.fb		= &sm501_fb_pdata,
};

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

187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
static struct mtd_partition r2d_partitions[] = {
	{
		.name		= "U-Boot",
		.offset		= 0x00000000,
		.size		= 0x00040000,
		.mask_flags	= MTD_WRITEABLE,
	}, {
		.name		= "Environment",
		.offset		= MTDPART_OFS_NXTBLK,
		.size		= 0x00040000,
		.mask_flags	= MTD_WRITEABLE,
	}, {
		.name		= "Kernel",
		.offset		= MTDPART_OFS_NXTBLK,
		.size		= 0x001c0000,
	}, {
		.name		= "Flash_FS",
		.offset		= MTDPART_OFS_NXTBLK,
		.size		= MTDPART_SIZ_FULL,
	}
};

static struct physmap_flash_data flash_data = {
	.width		= 2,
	.nr_parts	= ARRAY_SIZE(r2d_partitions),
	.parts		= r2d_partitions,
};

static struct resource flash_resource = {
	.start		= 0x00000000,
	.end		= 0x02000000,
	.flags		= IORESOURCE_MEM,
};

static struct platform_device flash_device = {
	.name		= "physmap-flash",
	.id		= -1,
	.resource	= &flash_resource,
	.num_resources	= 1,
	.dev		= {
		.platform_data = &flash_data,
	},
};

231
static struct platform_device *rts7751r2d_devices[] __initdata = {
232
	&sm501_device,
233
	&heartbeat_device,
234
	&spi_sh_sci_device,
235 236
};

M
Magnus Damm 已提交
237 238 239 240 241 242 243 244 245 246 247
/*
 * 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,
};

248 249
static int __init rts7751r2d_devices_setup(void)
{
M
Magnus Damm 已提交
250 251
	if (register_trapped_io(&cf_trapped_io) == 0)
		platform_device_register(&cf_ide_device);
252

253 254 255
	if (mach_is_r2d_plus())
		platform_device_register(&flash_device);

256
	spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
257

258 259 260
	return platform_add_devices(rts7751r2d_devices,
				    ARRAY_SIZE(rts7751r2d_devices));
}
P
Paul Mundt 已提交
261
__initcall(rts7751r2d_devices_setup);
L
Linus Torvalds 已提交
262

263 264 265 266 267
static void rts7751r2d_power_off(void)
{
	ctrl_outw(0x0001, PA_POWOFF);
}

L
Linus Torvalds 已提交
268 269 270
/*
 * Initialize the board
 */
P
Paul Mundt 已提交
271
static void __init rts7751r2d_setup(char **cmdline_p)
L
Linus Torvalds 已提交
272
{
M
Magnus Damm 已提交
273
	void __iomem *sm501_reg;
P
Paul Mundt 已提交
274 275 276 277 278 279
	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 已提交
280

L
Linus Torvalds 已提交
281
	ctrl_outw(0x0000, PA_OUTPORT);
282
	pm_power_off = rts7751r2d_power_off;
283

M
Magnus Damm 已提交
284 285 286 287 288 289 290 291 292 293 294 295 296 297
	/* 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 已提交
298
}
P
Paul Mundt 已提交
299 300 301 302

/*
 * The Machine Vector
 */
P
Paul Mundt 已提交
303
static struct sh_machine_vector mv_rts7751r2d __initmv = {
P
Paul Mundt 已提交
304 305 306 307 308
	.mv_name		= "RTS7751R2D",
	.mv_setup		= rts7751r2d_setup,
	.mv_init_irq		= init_rts7751r2d_IRQ,
	.mv_irq_demux		= rts7751r2d_irq_demux,
};