blob: dc143c10cd1886d7520b46e7bb19951304480618 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Renesas Technology Sales RTS7751R2D Support.
3 *
Paul Mundt9c575482007-02-15 18:20:52 +09004 * Copyright (C) 2002 - 2006 Atom Create Engineering Co., Ltd.
5 * Copyright (C) 2004 - 2007 Paul Mundt
Paul Mundtade2b3f2006-09-27 16:48:46 +09006 *
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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/init.h>
Paul Mundtade2b3f2006-09-27 16:48:46 +090012#include <linux/platform_device.h>
Paul Mundt9c575482007-02-15 18:20:52 +090013#include <linux/pata_platform.h>
Paul Mundtade2b3f2006-09-27 16:48:46 +090014#include <linux/serial_8250.h>
Paul Mundtc87a7112007-03-01 18:47:08 +090015#include <linux/sm501.h>
Paul Mundta56d2762006-09-27 11:43:24 +090016#include <linux/pm.h>
Magnus Dammcbd10df2008-01-15 12:44:44 +090017#include <linux/fb.h>
Paul Mundt2c7834a2006-09-27 18:17:31 +090018#include <asm/machvec.h>
Paul Mundt9c575482007-02-15 18:20:52 +090019#include <asm/rts7751r2d.h>
Paul Mundtadf18902006-09-27 17:17:27 +090020#include <asm/voyagergx.h>
Paul Mundt9c575482007-02-15 18:20:52 +090021#include <asm/io.h>
Paul Mundtade2b3f2006-09-27 16:48:46 +090022
23static void __init voyagergx_serial_init(void)
24{
25 unsigned long val;
26
27 /*
28 * GPIO Control
29 */
Paul Mundt9c575482007-02-15 18:20:52 +090030 val = readl((void __iomem *)GPIO_MUX_HIGH);
Paul Mundtade2b3f2006-09-27 16:48:46 +090031 val |= 0x00001fe0;
Paul Mundt9c575482007-02-15 18:20:52 +090032 writel(val, (void __iomem *)GPIO_MUX_HIGH);
Paul Mundtade2b3f2006-09-27 16:48:46 +090033
34 /*
35 * Power Mode Gate
36 */
Paul Mundt9c575482007-02-15 18:20:52 +090037 val = readl((void __iomem *)POWER_MODE0_GATE);
Paul Mundtade2b3f2006-09-27 16:48:46 +090038 val |= (POWER_MODE0_GATE_U0 | POWER_MODE0_GATE_U1);
Paul Mundt9c575482007-02-15 18:20:52 +090039 writel(val, (void __iomem *)POWER_MODE0_GATE);
Paul Mundtade2b3f2006-09-27 16:48:46 +090040
Paul Mundt9c575482007-02-15 18:20:52 +090041 val = readl((void __iomem *)POWER_MODE1_GATE);
Paul Mundtade2b3f2006-09-27 16:48:46 +090042 val |= (POWER_MODE1_GATE_U0 | POWER_MODE1_GATE_U1);
Paul Mundt9c575482007-02-15 18:20:52 +090043 writel(val, (void __iomem *)POWER_MODE1_GATE);
Paul Mundtade2b3f2006-09-27 16:48:46 +090044}
45
Paul Mundt9c575482007-02-15 18:20:52 +090046static struct resource cf_ide_resources[] = {
47 [0] = {
48 .start = PA_AREA5_IO + 0x1000,
Aoi Shinkai43f4b8c2007-09-21 15:18:33 +090049 .end = PA_AREA5_IO + 0x1000 + 0x10 - 0x2,
Paul Mundt9c575482007-02-15 18:20:52 +090050 .flags = IORESOURCE_MEM,
51 },
52 [1] = {
53 .start = PA_AREA5_IO + 0x80c,
Aoi Shinkai43f4b8c2007-09-21 15:18:33 +090054 .end = PA_AREA5_IO + 0x80c,
Paul Mundt9c575482007-02-15 18:20:52 +090055 .flags = IORESOURCE_MEM,
56 },
Magnus Dammabac3f72007-11-23 14:39:13 +090057#ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */
Paul Mundt9c575482007-02-15 18:20:52 +090058 [2] = {
Magnus Damm2eeec852007-08-12 15:29:16 +090059 .start = IRQ_CF_IDE,
Paul Mundt9c575482007-02-15 18:20:52 +090060 .flags = IORESOURCE_IRQ,
61 },
Magnus Dammabac3f72007-11-23 14:39:13 +090062#endif
Paul Mundt9c575482007-02-15 18:20:52 +090063};
64
65static struct pata_platform_info pata_info = {
66 .ioport_shift = 1,
67};
68
69static 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,
76 },
77};
78
Magnus Dammf8b40d82007-08-12 15:30:40 +090079static struct resource heartbeat_resources[] = {
80 [0] = {
81 .start = PA_OUTPORT,
Paul Mundta1fd3062007-08-23 15:11:44 +090082 .end = PA_OUTPORT,
Magnus Dammf8b40d82007-08-12 15:30:40 +090083 .flags = IORESOURCE_MEM,
84 },
85};
86
87static struct platform_device heartbeat_device = {
88 .name = "heartbeat",
89 .id = -1,
90 .num_resources = ARRAY_SIZE(heartbeat_resources),
91 .resource = heartbeat_resources,
92};
93
94#ifdef CONFIG_MFD_SM501
Paul Mundt9c575482007-02-15 18:20:52 +090095static struct plat_serial8250_port uart_platform_data[] = {
96 {
97 .membase = (void __iomem *)VOYAGER_UART_BASE,
98 .mapbase = VOYAGER_UART_BASE,
99 .iotype = UPIO_MEM,
Magnus Damm48180ca2007-08-03 14:27:20 +0900100 .irq = IRQ_SM501_U0,
Paul Mundt9c575482007-02-15 18:20:52 +0900101 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
102 .regshift = 2,
103 .uartclk = (9600 * 16),
Magnus Damm3a353822007-07-20 16:34:22 +0900104 },
105 { 0 },
Paul Mundt9c575482007-02-15 18:20:52 +0900106};
107
Paul Mundtade2b3f2006-09-27 16:48:46 +0900108static struct platform_device uart_device = {
109 .name = "serial8250",
Paul Mundt9c575482007-02-15 18:20:52 +0900110 .id = PLAT8250_DEV_PLATFORM,
Paul Mundtade2b3f2006-09-27 16:48:46 +0900111 .dev = {
112 .platform_data = uart_platform_data,
113 },
114};
115
Paul Mundtc87a7112007-03-01 18:47:08 +0900116static struct resource sm501_resources[] = {
117 [0] = {
118 .start = 0x10000000,
119 .end = 0x13e00000 - 1,
120 .flags = IORESOURCE_MEM,
121 },
122 [1] = {
123 .start = 0x13e00000,
124 .end = 0x13ffffff,
125 .flags = IORESOURCE_MEM,
126 },
127 [2] = {
Magnus Damm48180ca2007-08-03 14:27:20 +0900128 .start = IRQ_SM501_CV,
Paul Mundtc87a7112007-03-01 18:47:08 +0900129 .flags = IORESOURCE_IRQ,
130 },
131};
132
Magnus Dammcbd10df2008-01-15 12:44:44 +0900133static 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,
144};
145
146static 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,
153};
154
155static 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),
160
161};
162
163static 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,
168};
169
170static struct sm501_platdata sm501_platform_data = {
171 .fb = &sm501_fb_pdata,
172};
173
Paul Mundtc87a7112007-03-01 18:47:08 +0900174static struct platform_device sm501_device = {
175 .name = "sm501",
176 .id = -1,
Magnus Dammcbd10df2008-01-15 12:44:44 +0900177 .dev = {
178 .platform_data = &sm501_platform_data,
179 },
Paul Mundtc87a7112007-03-01 18:47:08 +0900180 .num_resources = ARRAY_SIZE(sm501_resources),
181 .resource = sm501_resources,
182};
183
Magnus Dammf8b40d82007-08-12 15:30:40 +0900184#endif /* CONFIG_MFD_SM501 */
185
Paul Mundtade2b3f2006-09-27 16:48:46 +0900186static struct platform_device *rts7751r2d_devices[] __initdata = {
Magnus Dammf8b40d82007-08-12 15:30:40 +0900187#ifdef CONFIG_MFD_SM501
Paul Mundtade2b3f2006-09-27 16:48:46 +0900188 &uart_device,
Paul Mundtc87a7112007-03-01 18:47:08 +0900189 &sm501_device,
Magnus Dammf8b40d82007-08-12 15:30:40 +0900190#endif
Aoi Shinkai43f4b8c2007-09-21 15:18:33 +0900191 &cf_ide_device,
Magnus Dammf8b40d82007-08-12 15:30:40 +0900192 &heartbeat_device,
Paul Mundtade2b3f2006-09-27 16:48:46 +0900193};
194
195static int __init rts7751r2d_devices_setup(void)
196{
197 return platform_add_devices(rts7751r2d_devices,
198 ARRAY_SIZE(rts7751r2d_devices));
199}
Paul Mundt9c575482007-02-15 18:20:52 +0900200__initcall(rts7751r2d_devices_setup);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Paul Mundta56d2762006-09-27 11:43:24 +0900202static void rts7751r2d_power_off(void)
203{
204 ctrl_outw(0x0001, PA_POWOFF);
205}
206
Aoi Shinkai43f4b8c2007-09-21 15:18:33 +0900207static inline unsigned char is_ide_ioaddr(unsigned long addr)
208{
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));
213}
214
Paul Mundt02353f52007-09-21 15:21:55 +0900215void rts7751r2d_writeb(u8 b, void __iomem *addr)
Aoi Shinkai43f4b8c2007-09-21 15:18:33 +0900216{
217 unsigned long tmp = (unsigned long __force)addr;
218
219 if (is_ide_ioaddr(tmp))
220 ctrl_outw((u16)b, tmp);
221 else
222 ctrl_outb(b, tmp);
223}
224
Paul Mundt02353f52007-09-21 15:21:55 +0900225u8 rts7751r2d_readb(void __iomem *addr)
Aoi Shinkai43f4b8c2007-09-21 15:18:33 +0900226{
227 unsigned long tmp = (unsigned long __force)addr;
228
229 if (is_ide_ioaddr(tmp))
230 return ctrl_inw(tmp) & 0xff;
231 else
232 return ctrl_inb(tmp);
233}
234
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235/*
236 * Initialize the board
237 */
Paul Mundt2c7834a2006-09-27 18:17:31 +0900238static void __init rts7751r2d_setup(char **cmdline_p)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239{
Paul Mundt9c575482007-02-15 18:20:52 +0900240 u16 ver = ctrl_inw(PA_VERREG);
241
242 printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
243
244 printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
245 (ver >> 4) & 0xf, ver & 0xf);
Paul Mundt2c7834a2006-09-27 18:17:31 +0900246
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 ctrl_outw(0x0000, PA_OUTPORT);
Paul Mundta56d2762006-09-27 11:43:24 +0900248 pm_power_off = rts7751r2d_power_off;
Paul Mundtade2b3f2006-09-27 16:48:46 +0900249
250 voyagergx_serial_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251}
Paul Mundt2c7834a2006-09-27 18:17:31 +0900252
253/*
254 * The Machine Vector
255 */
Paul Mundt82f81f42007-05-15 15:19:34 +0900256static struct sh_machine_vector mv_rts7751r2d __initmv = {
Paul Mundt2c7834a2006-09-27 18:17:31 +0900257 .mv_name = "RTS7751R2D",
258 .mv_setup = rts7751r2d_setup,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900259 .mv_init_irq = init_rts7751r2d_IRQ,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900260 .mv_irq_demux = rts7751r2d_irq_demux,
Aoi Shinkai43f4b8c2007-09-21 15:18:33 +0900261 .mv_writeb = rts7751r2d_writeb,
262 .mv_readb = rts7751r2d_readb,
Magnus Dammf8b40d82007-08-12 15:30:40 +0900263#if defined(CONFIG_MFD_SM501) && defined(CONFIG_USB_OHCI_HCD)
Paul Mundt2c7834a2006-09-27 18:17:31 +0900264 .mv_consistent_alloc = voyagergx_consistent_alloc,
265 .mv_consistent_free = voyagergx_consistent_free,
266#endif
267};