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
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/ata_platform.h>
14 #include <linux/serial_8250.h>
15 #include <linux/sm501.h>
16 #include <linux/sm501-regs.h>
19 #include <linux/spi/spi.h>
20 #include <linux/spi/spi_bitbang.h>
21 #include <asm/machvec.h>
22 #include <asm/rts7751r2d.h>
26 static struct resource cf_ide_resources[] = {
28 .start = PA_AREA5_IO + 0x1000,
29 .end = PA_AREA5_IO + 0x1000 + 0x10 - 0x2,
30 .flags = IORESOURCE_MEM,
33 .start = PA_AREA5_IO + 0x80c,
34 .end = PA_AREA5_IO + 0x80c,
35 .flags = IORESOURCE_MEM,
37 #ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */
40 .flags = IORESOURCE_IRQ,
45 static struct pata_platform_info pata_info = {
49 static struct platform_device cf_ide_device = {
50 .name = "pata_platform",
52 .num_resources = ARRAY_SIZE(cf_ide_resources),
53 .resource = cf_ide_resources,
55 .platform_data = &pata_info,
59 static struct spi_board_info spi_bus[] = {
61 .modalias = "rtc-r9701",
62 .max_speed_hz = 1000000,
67 static void r2d_chip_select(struct sh_spi_info *spi, int cs, int state)
69 BUG_ON(cs != 0); /* Single Epson RTC-9701JE attached on CS0 */
70 ctrl_outw(state == BITBANG_CS_ACTIVE, PA_RTCCE);
73 static struct sh_spi_info spi_info = {
75 .chip_select = r2d_chip_select,
78 static struct resource spi_sh_sci_resources[] = {
82 .flags = IORESOURCE_MEM,
86 static struct platform_device spi_sh_sci_device = {
89 .num_resources = ARRAY_SIZE(spi_sh_sci_resources),
90 .resource = spi_sh_sci_resources,
92 .platform_data = &spi_info,
96 static struct resource heartbeat_resources[] = {
100 .flags = IORESOURCE_MEM,
104 static struct platform_device heartbeat_device = {
107 .num_resources = ARRAY_SIZE(heartbeat_resources),
108 .resource = heartbeat_resources,
111 #ifdef CONFIG_MFD_SM501
112 static struct plat_serial8250_port uart_platform_data[] = {
114 .membase = (void __iomem *)0xb3e30000,
115 .mapbase = 0xb3e30000,
118 .flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ,
120 .uartclk = (9600 * 16),
125 static struct platform_device uart_device = {
126 .name = "serial8250",
127 .id = PLAT8250_DEV_PLATFORM,
129 .platform_data = uart_platform_data,
133 static struct resource sm501_resources[] = {
136 .end = 0x13e00000 - 1,
137 .flags = IORESOURCE_MEM,
142 .flags = IORESOURCE_MEM,
145 .start = IRQ_VOYAGER,
146 .flags = IORESOURCE_IRQ,
150 static struct fb_videomode sm501_default_mode = {
160 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
163 static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = {
165 .def_mode = &sm501_default_mode,
166 .flags = SM501FB_FLAG_USE_INIT_MODE |
167 SM501FB_FLAG_USE_HWCURSOR |
168 SM501FB_FLAG_USE_HWACCEL |
169 SM501FB_FLAG_DISABLE_AT_EXIT,
172 static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt = {
173 .flags = (SM501FB_FLAG_USE_INIT_MODE |
174 SM501FB_FLAG_USE_HWCURSOR |
175 SM501FB_FLAG_USE_HWACCEL |
176 SM501FB_FLAG_DISABLE_AT_EXIT),
180 static struct sm501_platdata_fb sm501_fb_pdata = {
181 .fb_route = SM501_FB_OWN,
182 .fb_crt = &sm501_pdata_fbsub_crt,
183 .fb_pnl = &sm501_pdata_fbsub_pnl,
184 .flags = SM501_FBPD_SWAP_FB_ENDIAN,
187 static struct sm501_initdata sm501_initdata = {
192 .devices = SM501_USE_USB_HOST,
195 static struct sm501_platdata sm501_platform_data = {
196 .init = &sm501_initdata,
197 .fb = &sm501_fb_pdata,
200 static struct platform_device sm501_device = {
204 .platform_data = &sm501_platform_data,
206 .num_resources = ARRAY_SIZE(sm501_resources),
207 .resource = sm501_resources,
210 #endif /* CONFIG_MFD_SM501 */
212 static struct platform_device *rts7751r2d_devices[] __initdata = {
213 #ifdef CONFIG_MFD_SM501
222 static int __init rts7751r2d_devices_setup(void)
224 spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
225 return platform_add_devices(rts7751r2d_devices,
226 ARRAY_SIZE(rts7751r2d_devices));
228 __initcall(rts7751r2d_devices_setup);
230 static void rts7751r2d_power_off(void)
232 ctrl_outw(0x0001, PA_POWOFF);
235 static inline unsigned char is_ide_ioaddr(unsigned long addr)
237 return ((cf_ide_resources[0].start <= addr &&
238 addr <= cf_ide_resources[0].end) ||
239 (cf_ide_resources[1].start <= addr &&
240 addr <= cf_ide_resources[1].end));
243 void rts7751r2d_writeb(u8 b, void __iomem *addr)
245 unsigned long tmp = (unsigned long __force)addr;
247 if (is_ide_ioaddr(tmp))
248 ctrl_outw((u16)b, tmp);
253 u8 rts7751r2d_readb(void __iomem *addr)
255 unsigned long tmp = (unsigned long __force)addr;
257 if (is_ide_ioaddr(tmp))
258 return ctrl_inw(tmp) & 0xff;
260 return ctrl_inb(tmp);
264 * Initialize the board
266 static void __init rts7751r2d_setup(char **cmdline_p)
268 void __iomem *sm501_reg;
269 u16 ver = ctrl_inw(PA_VERREG);
271 printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
273 printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
274 (ver >> 4) & 0xf, ver & 0xf);
276 ctrl_outw(0x0000, PA_OUTPORT);
277 pm_power_off = rts7751r2d_power_off;
279 /* sm501 dram configuration:
280 * ColSizeX = 11 - External Memory Column Size: 256 words.
281 * APX = 1 - External Memory Active to Pre-Charge Delay: 7 clocks.
282 * RstX = 1 - External Memory Reset: Normal.
283 * Rfsh = 1 - Local Memory Refresh to Command Delay: 12 clocks.
284 * BwC = 1 - Local Memory Block Write Cycle Time: 2 clocks.
285 * BwP = 1 - Local Memory Block Write to Pre-Charge Delay: 1 clock.
286 * AP = 1 - Internal Memory Active to Pre-Charge Delay: 7 clocks.
287 * Rst = 1 - Internal Memory Reset: Normal.
288 * RA = 1 - Internal Memory Remain in Active State: Do not remain.
291 sm501_reg = (void __iomem *)0xb3e00000 + SM501_DRAM_CONTROL;
292 writel(readl(sm501_reg) | 0x00f107c0, sm501_reg);
295 * Power Mode Gate - Enable UART0
298 sm501_reg = (void __iomem *)0xb3e00000 + SM501_POWER_MODE_0_GATE;
299 writel(readl(sm501_reg) | (1 << SM501_GATE_UART0), sm501_reg);
301 sm501_reg = (void __iomem *)0xb3e00000 + SM501_POWER_MODE_1_GATE;
302 writel(readl(sm501_reg) | (1 << SM501_GATE_UART0), sm501_reg);
308 static struct sh_machine_vector mv_rts7751r2d __initmv = {
309 .mv_name = "RTS7751R2D",
310 .mv_setup = rts7751r2d_setup,
311 .mv_init_irq = init_rts7751r2d_IRQ,
312 .mv_irq_demux = rts7751r2d_irq_demux,
313 .mv_writeb = rts7751r2d_writeb,
314 .mv_readb = rts7751r2d_readb,