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/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/mtd/physmap.h>
16 #include <linux/ata_platform.h>
17 #include <linux/sm501.h>
18 #include <linux/sm501-regs.h>
21 #include <linux/spi/spi.h>
22 #include <linux/spi/spi_bitbang.h>
23 #include <asm/machvec.h>
26 #include <asm/io_trapped.h>
29 static struct resource cf_ide_resources
[] = {
31 .start
= PA_AREA5_IO
+ 0x1000,
32 .end
= PA_AREA5_IO
+ 0x1000 + 0x10 - 0x2,
33 .flags
= IORESOURCE_MEM
,
36 .start
= PA_AREA5_IO
+ 0x80c,
37 .end
= PA_AREA5_IO
+ 0x80c,
38 .flags
= IORESOURCE_MEM
,
40 #ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */
43 .flags
= IORESOURCE_IRQ
,
48 static struct pata_platform_info pata_info
= {
52 static struct platform_device cf_ide_device
= {
53 .name
= "pata_platform",
55 .num_resources
= ARRAY_SIZE(cf_ide_resources
),
56 .resource
= cf_ide_resources
,
58 .platform_data
= &pata_info
,
62 static struct spi_board_info spi_bus
[] = {
64 .modalias
= "rtc-r9701",
65 .max_speed_hz
= 1000000,
70 static void r2d_chip_select(struct sh_spi_info
*spi
, int cs
, int state
)
72 BUG_ON(cs
!= 0); /* Single Epson RTC-9701JE attached on CS0 */
73 __raw_writew(state
== BITBANG_CS_ACTIVE
, PA_RTCCE
);
76 static struct sh_spi_info spi_info
= {
78 .chip_select
= r2d_chip_select
,
81 static struct resource spi_sh_sci_resources
[] = {
85 .flags
= IORESOURCE_MEM
,
89 static struct platform_device spi_sh_sci_device
= {
92 .num_resources
= ARRAY_SIZE(spi_sh_sci_resources
),
93 .resource
= spi_sh_sci_resources
,
95 .platform_data
= &spi_info
,
99 static struct resource heartbeat_resources
[] = {
103 .flags
= IORESOURCE_MEM
,
107 static struct platform_device heartbeat_device
= {
110 .num_resources
= ARRAY_SIZE(heartbeat_resources
),
111 .resource
= heartbeat_resources
,
114 static struct resource sm501_resources
[] = {
117 .end
= 0x13e00000 - 1,
118 .flags
= IORESOURCE_MEM
,
123 .flags
= IORESOURCE_MEM
,
126 .start
= IRQ_VOYAGER
,
127 .flags
= IORESOURCE_IRQ
,
131 static struct fb_videomode sm501_default_mode
= {
141 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
144 static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl
= {
146 .def_mode
= &sm501_default_mode
,
147 .flags
= SM501FB_FLAG_USE_INIT_MODE
|
148 SM501FB_FLAG_USE_HWCURSOR
|
149 SM501FB_FLAG_USE_HWACCEL
|
150 SM501FB_FLAG_DISABLE_AT_EXIT
,
153 static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt
= {
154 .flags
= (SM501FB_FLAG_USE_INIT_MODE
|
155 SM501FB_FLAG_USE_HWCURSOR
|
156 SM501FB_FLAG_USE_HWACCEL
|
157 SM501FB_FLAG_DISABLE_AT_EXIT
),
161 static struct sm501_platdata_fb sm501_fb_pdata
= {
162 .fb_route
= SM501_FB_OWN
,
163 .fb_crt
= &sm501_pdata_fbsub_crt
,
164 .fb_pnl
= &sm501_pdata_fbsub_pnl
,
165 .flags
= SM501_FBPD_SWAP_FB_ENDIAN
,
168 static struct sm501_initdata sm501_initdata
= {
169 .devices
= SM501_USE_USB_HOST
| SM501_USE_UART0
,
172 static struct sm501_platdata sm501_platform_data
= {
173 .init
= &sm501_initdata
,
174 .fb
= &sm501_fb_pdata
,
177 static struct platform_device sm501_device
= {
181 .platform_data
= &sm501_platform_data
,
183 .num_resources
= ARRAY_SIZE(sm501_resources
),
184 .resource
= sm501_resources
,
187 static struct mtd_partition r2d_partitions
[] = {
190 .offset
= 0x00000000,
192 .mask_flags
= MTD_WRITEABLE
,
194 .name
= "Environment",
195 .offset
= MTDPART_OFS_NXTBLK
,
197 .mask_flags
= MTD_WRITEABLE
,
200 .offset
= MTDPART_OFS_NXTBLK
,
204 .offset
= MTDPART_OFS_NXTBLK
,
205 .size
= MTDPART_SIZ_FULL
,
209 static struct physmap_flash_data flash_data
= {
211 .nr_parts
= ARRAY_SIZE(r2d_partitions
),
212 .parts
= r2d_partitions
,
215 static struct resource flash_resource
= {
218 .flags
= IORESOURCE_MEM
,
221 static struct platform_device flash_device
= {
222 .name
= "physmap-flash",
224 .resource
= &flash_resource
,
227 .platform_data
= &flash_data
,
231 static struct platform_device
*rts7751r2d_devices
[] __initdata
= {
238 * The CF is connected with a 16-bit bus where 8-bit operations are
239 * unsupported. The linux ata driver is however using 8-bit operations, so
240 * insert a trapped io filter to convert 8-bit operations into 16-bit.
242 static struct trapped_io cf_trapped_io
= {
243 .resource
= cf_ide_resources
,
245 .minimum_bus_width
= 16,
248 static int __init
rts7751r2d_devices_setup(void)
250 if (register_trapped_io(&cf_trapped_io
) == 0)
251 platform_device_register(&cf_ide_device
);
253 if (mach_is_r2d_plus())
254 platform_device_register(&flash_device
);
256 spi_register_board_info(spi_bus
, ARRAY_SIZE(spi_bus
));
258 return platform_add_devices(rts7751r2d_devices
,
259 ARRAY_SIZE(rts7751r2d_devices
));
261 device_initcall(rts7751r2d_devices_setup
);
263 static void rts7751r2d_power_off(void)
265 __raw_writew(0x0001, PA_POWOFF
);
269 * Initialize the board
271 static void __init
rts7751r2d_setup(char **cmdline_p
)
273 void __iomem
*sm501_reg
;
274 u16 ver
= __raw_readw(PA_VERREG
);
276 printk(KERN_INFO
"Renesas Technology Sales RTS7751R2D support.\n");
278 printk(KERN_INFO
"FPGA version:%d (revision:%d)\n",
279 (ver
>> 4) & 0xf, ver
& 0xf);
281 __raw_writew(0x0000, PA_OUTPORT
);
282 pm_power_off
= rts7751r2d_power_off
;
284 /* sm501 dram configuration:
285 * ColSizeX = 11 - External Memory Column Size: 256 words.
286 * APX = 1 - External Memory Active to Pre-Charge Delay: 7 clocks.
287 * RstX = 1 - External Memory Reset: Normal.
288 * Rfsh = 1 - Local Memory Refresh to Command Delay: 12 clocks.
289 * BwC = 1 - Local Memory Block Write Cycle Time: 2 clocks.
290 * BwP = 1 - Local Memory Block Write to Pre-Charge Delay: 1 clock.
291 * AP = 1 - Internal Memory Active to Pre-Charge Delay: 7 clocks.
292 * Rst = 1 - Internal Memory Reset: Normal.
293 * RA = 1 - Internal Memory Remain in Active State: Do not remain.
296 sm501_reg
= (void __iomem
*)0xb3e00000 + SM501_DRAM_CONTROL
;
297 writel(readl(sm501_reg
) | 0x00f107c0, sm501_reg
);
303 static struct sh_machine_vector mv_rts7751r2d __initmv
= {
304 .mv_name
= "RTS7751R2D",
305 .mv_setup
= rts7751r2d_setup
,
306 .mv_init_irq
= init_rts7751r2d_IRQ
,
307 .mv_irq_demux
= rts7751r2d_irq_demux
,