sh: r2d - add lcd planel timings to sm501 platform data
[linux-2.6/linux-2.6-openrd.git] / arch / sh / boards / renesas / rts7751r2d / setup.c
blobdc143c10cd1886d7520b46e7bb19951304480618
1 /*
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
9 * for more details.
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>
16 #include <linux/pm.h>
17 #include <linux/fb.h>
18 #include <asm/machvec.h>
19 #include <asm/rts7751r2d.h>
20 #include <asm/voyagergx.h>
21 #include <asm/io.h>
23 static void __init voyagergx_serial_init(void)
25 unsigned long val;
28 * GPIO Control
30 val = readl((void __iomem *)GPIO_MUX_HIGH);
31 val |= 0x00001fe0;
32 writel(val, (void __iomem *)GPIO_MUX_HIGH);
35 * Power Mode Gate
37 val = readl((void __iomem *)POWER_MODE0_GATE);
38 val |= (POWER_MODE0_GATE_U0 | POWER_MODE0_GATE_U1);
39 writel(val, (void __iomem *)POWER_MODE0_GATE);
41 val = readl((void __iomem *)POWER_MODE1_GATE);
42 val |= (POWER_MODE1_GATE_U0 | POWER_MODE1_GATE_U1);
43 writel(val, (void __iomem *)POWER_MODE1_GATE);
46 static struct resource cf_ide_resources[] = {
47 [0] = {
48 .start = PA_AREA5_IO + 0x1000,
49 .end = PA_AREA5_IO + 0x1000 + 0x10 - 0x2,
50 .flags = IORESOURCE_MEM,
52 [1] = {
53 .start = PA_AREA5_IO + 0x80c,
54 .end = PA_AREA5_IO + 0x80c,
55 .flags = IORESOURCE_MEM,
57 #ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */
58 [2] = {
59 .start = IRQ_CF_IDE,
60 .flags = IORESOURCE_IRQ,
62 #endif
65 static struct pata_platform_info pata_info = {
66 .ioport_shift = 1,
69 static struct platform_device cf_ide_device = {
70 .name = "pata_platform",
71 .id = -1,
72 .num_resources = ARRAY_SIZE(cf_ide_resources),
73 .resource = cf_ide_resources,
74 .dev = {
75 .platform_data = &pata_info,
79 static struct resource heartbeat_resources[] = {
80 [0] = {
81 .start = PA_OUTPORT,
82 .end = PA_OUTPORT,
83 .flags = IORESOURCE_MEM,
87 static struct platform_device heartbeat_device = {
88 .name = "heartbeat",
89 .id = -1,
90 .num_resources = ARRAY_SIZE(heartbeat_resources),
91 .resource = heartbeat_resources,
94 #ifdef CONFIG_MFD_SM501
95 static struct plat_serial8250_port uart_platform_data[] = {
97 .membase = (void __iomem *)VOYAGER_UART_BASE,
98 .mapbase = VOYAGER_UART_BASE,
99 .iotype = UPIO_MEM,
100 .irq = IRQ_SM501_U0,
101 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
102 .regshift = 2,
103 .uartclk = (9600 * 16),
105 { 0 },
108 static struct platform_device uart_device = {
109 .name = "serial8250",
110 .id = PLAT8250_DEV_PLATFORM,
111 .dev = {
112 .platform_data = uart_platform_data,
116 static struct resource sm501_resources[] = {
117 [0] = {
118 .start = 0x10000000,
119 .end = 0x13e00000 - 1,
120 .flags = IORESOURCE_MEM,
122 [1] = {
123 .start = 0x13e00000,
124 .end = 0x13ffffff,
125 .flags = IORESOURCE_MEM,
127 [2] = {
128 .start = IRQ_SM501_CV,
129 .flags = IORESOURCE_IRQ,
133 static struct fb_videomode sm501_default_mode = {
134 .pixclock = 35714,
135 .xres = 640,
136 .yres = 480,
137 .left_margin = 105,
138 .right_margin = 50,
139 .upper_margin = 35,
140 .lower_margin = 0,
141 .hsync_len = 96,
142 .vsync_len = 2,
143 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
146 static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = {
147 .def_bpp = 16,
148 .def_mode = &sm501_default_mode,
149 .flags = SM501FB_FLAG_USE_INIT_MODE |
150 SM501FB_FLAG_USE_HWCURSOR |
151 SM501FB_FLAG_USE_HWACCEL |
152 SM501FB_FLAG_DISABLE_AT_EXIT,
155 static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt = {
156 .flags = (SM501FB_FLAG_USE_INIT_MODE |
157 SM501FB_FLAG_USE_HWCURSOR |
158 SM501FB_FLAG_USE_HWACCEL |
159 SM501FB_FLAG_DISABLE_AT_EXIT),
163 static struct sm501_platdata_fb sm501_fb_pdata = {
164 .fb_route = SM501_FB_OWN,
165 .fb_crt = &sm501_pdata_fbsub_crt,
166 .fb_pnl = &sm501_pdata_fbsub_pnl,
167 .flags = SM501_FBPD_SWAP_FB_ENDIAN,
170 static struct sm501_platdata sm501_platform_data = {
171 .fb = &sm501_fb_pdata,
174 static struct platform_device sm501_device = {
175 .name = "sm501",
176 .id = -1,
177 .dev = {
178 .platform_data = &sm501_platform_data,
180 .num_resources = ARRAY_SIZE(sm501_resources),
181 .resource = sm501_resources,
184 #endif /* CONFIG_MFD_SM501 */
186 static struct platform_device *rts7751r2d_devices[] __initdata = {
187 #ifdef CONFIG_MFD_SM501
188 &uart_device,
189 &sm501_device,
190 #endif
191 &cf_ide_device,
192 &heartbeat_device,
195 static int __init rts7751r2d_devices_setup(void)
197 return platform_add_devices(rts7751r2d_devices,
198 ARRAY_SIZE(rts7751r2d_devices));
200 __initcall(rts7751r2d_devices_setup);
202 static void rts7751r2d_power_off(void)
204 ctrl_outw(0x0001, PA_POWOFF);
207 static inline unsigned char is_ide_ioaddr(unsigned long addr)
209 return ((cf_ide_resources[0].start <= addr &&
210 addr <= cf_ide_resources[0].end) ||
211 (cf_ide_resources[1].start <= addr &&
212 addr <= cf_ide_resources[1].end));
215 void rts7751r2d_writeb(u8 b, void __iomem *addr)
217 unsigned long tmp = (unsigned long __force)addr;
219 if (is_ide_ioaddr(tmp))
220 ctrl_outw((u16)b, tmp);
221 else
222 ctrl_outb(b, tmp);
225 u8 rts7751r2d_readb(void __iomem *addr)
227 unsigned long tmp = (unsigned long __force)addr;
229 if (is_ide_ioaddr(tmp))
230 return ctrl_inw(tmp) & 0xff;
231 else
232 return ctrl_inb(tmp);
236 * Initialize the board
238 static void __init rts7751r2d_setup(char **cmdline_p)
240 u16 ver = ctrl_inw(PA_VERREG);
242 printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
244 printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
245 (ver >> 4) & 0xf, ver & 0xf);
247 ctrl_outw(0x0000, PA_OUTPORT);
248 pm_power_off = rts7751r2d_power_off;
250 voyagergx_serial_init();
254 * The Machine Vector
256 static struct sh_machine_vector mv_rts7751r2d __initmv = {
257 .mv_name = "RTS7751R2D",
258 .mv_setup = rts7751r2d_setup,
259 .mv_init_irq = init_rts7751r2d_IRQ,
260 .mv_irq_demux = rts7751r2d_irq_demux,
261 .mv_writeb = rts7751r2d_writeb,
262 .mv_readb = rts7751r2d_readb,
263 #if defined(CONFIG_MFD_SM501) && defined(CONFIG_USB_OHCI_HCD)
264 .mv_consistent_alloc = voyagergx_consistent_alloc,
265 .mv_consistent_free = voyagergx_consistent_free,
266 #endif