]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/sh/boards/renesas/rts7751r2d/setup.c
452d0d6459a40ee0da3a1f1050d8525ac66367ee
[linux-2.6-omap-h63xx.git] / arch / sh / boards / renesas / rts7751r2d / setup.c
1 /*
2  * Renesas Technology Sales RTS7751R2D Support.
3  *
4  * Copyright (C) 2002 - 2006 Atom Create Engineering Co., Ltd.
5  * Copyright (C) 2004 - 2007 Paul Mundt
6  *
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.
10  */
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>
17 #include <linux/pm.h>
18 #include <linux/fb.h>
19 #include <linux/spi/spi.h>
20 #include <linux/spi/spi_bitbang.h>
21 #include <asm/machvec.h>
22 #include <asm/rts7751r2d.h>
23 #include <asm/io.h>
24 #include <asm/io_trapped.h>
25 #include <asm/spi.h>
26
27 static struct resource cf_ide_resources[] = {
28         [0] = {
29                 .start  = PA_AREA5_IO + 0x1000,
30                 .end    = PA_AREA5_IO + 0x1000 + 0x10 - 0x2,
31                 .flags  = IORESOURCE_MEM,
32         },
33         [1] = {
34                 .start  = PA_AREA5_IO + 0x80c,
35                 .end    = PA_AREA5_IO + 0x80c,
36                 .flags  = IORESOURCE_MEM,
37         },
38 #ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */
39         [2] = {
40                 .start  = IRQ_CF_IDE,
41                 .flags  = IORESOURCE_IRQ,
42         },
43 #endif
44 };
45
46 static struct pata_platform_info pata_info = {
47         .ioport_shift   = 1,
48 };
49
50 static struct platform_device cf_ide_device  = {
51         .name           = "pata_platform",
52         .id             = -1,
53         .num_resources  = ARRAY_SIZE(cf_ide_resources),
54         .resource       = cf_ide_resources,
55         .dev    = {
56                 .platform_data  = &pata_info,
57         },
58 };
59
60 static struct spi_board_info spi_bus[] = {
61         {
62                 .modalias       = "rtc-r9701",
63                 .max_speed_hz   = 1000000,
64                 .mode           = SPI_MODE_3,
65         },
66 };
67
68 static void r2d_chip_select(struct sh_spi_info *spi, int cs, int state)
69 {
70         BUG_ON(cs != 0);  /* Single Epson RTC-9701JE attached on CS0 */
71         ctrl_outw(state == BITBANG_CS_ACTIVE, PA_RTCCE);
72 }
73
74 static struct sh_spi_info spi_info = {
75         .num_chipselect = 1,
76         .chip_select = r2d_chip_select,
77 };
78
79 static struct resource spi_sh_sci_resources[] = {
80         {
81                 .start  = 0xffe00000,
82                 .end    = 0xffe0001f,
83                 .flags  = IORESOURCE_MEM,
84         },
85 };
86
87 static struct platform_device spi_sh_sci_device  = {
88         .name           = "spi_sh_sci",
89         .id             = -1,
90         .num_resources  = ARRAY_SIZE(spi_sh_sci_resources),
91         .resource       = spi_sh_sci_resources,
92         .dev    = {
93                 .platform_data  = &spi_info,
94         },
95 };
96
97 static struct resource heartbeat_resources[] = {
98         [0] = {
99                 .start  = PA_OUTPORT,
100                 .end    = PA_OUTPORT,
101                 .flags  = IORESOURCE_MEM,
102         },
103 };
104
105 static struct platform_device heartbeat_device = {
106         .name           = "heartbeat",
107         .id             = -1,
108         .num_resources  = ARRAY_SIZE(heartbeat_resources),
109         .resource       = heartbeat_resources,
110 };
111
112 static struct plat_serial8250_port uart_platform_data[] = {
113         {
114                 .membase        = (void __iomem *)0xb3e30000,
115                 .mapbase        = 0xb3e30000,
116                 .iotype         = UPIO_MEM,
117                 .irq            = IRQ_VOYAGER,
118                 .flags          = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ,
119                 .regshift       = 2,
120                 .uartclk        = (9600 * 16),
121         },
122         { 0 },
123 };
124
125 static struct platform_device uart_device = {
126         .name           = "serial8250",
127         .id             = PLAT8250_DEV_PLATFORM,
128         .dev            = {
129                 .platform_data  = uart_platform_data,
130         },
131 };
132
133 static struct resource sm501_resources[] = {
134         [0]     = {
135                 .start  = 0x10000000,
136                 .end    = 0x13e00000 - 1,
137                 .flags  = IORESOURCE_MEM,
138         },
139         [1]     = {
140                 .start  = 0x13e00000,
141                 .end    = 0x13ffffff,
142                 .flags  = IORESOURCE_MEM,
143         },
144         [2]     = {
145                 .start  = IRQ_VOYAGER,
146                 .flags  = IORESOURCE_IRQ,
147         },
148 };
149
150 static struct fb_videomode sm501_default_mode = {
151         .pixclock       = 35714,
152         .xres           = 640,
153         .yres           = 480,
154         .left_margin    = 105,
155         .right_margin   = 50,
156         .upper_margin   = 35,
157         .lower_margin   = 0,
158         .hsync_len      = 96,
159         .vsync_len      = 2,
160         .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
161 };
162
163 static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = {
164         .def_bpp        = 16,
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,
170 };
171
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),
177
178 };
179
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,
185 };
186
187 static struct sm501_initdata sm501_initdata = {
188         .gpio_high      = {
189                 .set    = 0x00001fe0,
190                 .mask   = 0x0,
191         },
192         .devices        = SM501_USE_USB_HOST,
193 };
194
195 static struct sm501_platdata sm501_platform_data = {
196         .init           = &sm501_initdata,
197         .fb             = &sm501_fb_pdata,
198 };
199
200 static struct platform_device sm501_device = {
201         .name           = "sm501",
202         .id             = -1,
203         .dev            = {
204                 .platform_data  = &sm501_platform_data,
205         },
206         .num_resources  = ARRAY_SIZE(sm501_resources),
207         .resource       = sm501_resources,
208 };
209
210 static struct platform_device *rts7751r2d_devices[] __initdata = {
211         &uart_device,
212         &sm501_device,
213         &heartbeat_device,
214         &spi_sh_sci_device,
215 };
216
217 /*
218  * The CF is connected with a 16-bit bus where 8-bit operations are
219  * unsupported. The linux ata driver is however using 8-bit operations, so
220  * insert a trapped io filter to convert 8-bit operations into 16-bit.
221  */
222 static struct trapped_io cf_trapped_io = {
223         .resource               = cf_ide_resources,
224         .num_resources          = 2,
225         .minimum_bus_width      = 16,
226 };
227
228 static int __init rts7751r2d_devices_setup(void)
229 {
230         if (register_trapped_io(&cf_trapped_io) == 0)
231                 platform_device_register(&cf_ide_device);
232
233         spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
234
235         return platform_add_devices(rts7751r2d_devices,
236                                     ARRAY_SIZE(rts7751r2d_devices));
237 }
238 __initcall(rts7751r2d_devices_setup);
239
240 static void rts7751r2d_power_off(void)
241 {
242         ctrl_outw(0x0001, PA_POWOFF);
243 }
244
245 /*
246  * Initialize the board
247  */
248 static void __init rts7751r2d_setup(char **cmdline_p)
249 {
250         void __iomem *sm501_reg;
251         u16 ver = ctrl_inw(PA_VERREG);
252
253         printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
254
255         printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
256                                         (ver >> 4) & 0xf, ver & 0xf);
257
258         ctrl_outw(0x0000, PA_OUTPORT);
259         pm_power_off = rts7751r2d_power_off;
260
261         /* sm501 dram configuration:
262          * ColSizeX = 11 - External Memory Column Size: 256 words.
263          * APX = 1 - External Memory Active to Pre-Charge Delay: 7 clocks.
264          * RstX = 1 - External Memory Reset: Normal.
265          * Rfsh = 1 - Local Memory Refresh to Command Delay: 12 clocks.
266          * BwC =  1 - Local Memory Block Write Cycle Time: 2 clocks.
267          * BwP =  1 - Local Memory Block Write to Pre-Charge Delay: 1 clock.
268          * AP = 1 - Internal Memory Active to Pre-Charge Delay: 7 clocks.
269          * Rst = 1 - Internal Memory Reset: Normal.
270          * RA = 1 - Internal Memory Remain in Active State: Do not remain.
271          */
272
273         sm501_reg = (void __iomem *)0xb3e00000 + SM501_DRAM_CONTROL;
274         writel(readl(sm501_reg) | 0x00f107c0, sm501_reg);
275
276         /*
277          * Power Mode Gate - Enable UART0
278          */
279
280         sm501_reg = (void __iomem *)0xb3e00000 + SM501_POWER_MODE_0_GATE;
281         writel(readl(sm501_reg) | (1 << SM501_GATE_UART0), sm501_reg);
282
283         sm501_reg = (void __iomem *)0xb3e00000 + SM501_POWER_MODE_1_GATE;
284         writel(readl(sm501_reg) | (1 << SM501_GATE_UART0), sm501_reg);
285 }
286
287 /*
288  * The Machine Vector
289  */
290 static struct sh_machine_vector mv_rts7751r2d __initmv = {
291         .mv_name                = "RTS7751R2D",
292         .mv_setup               = rts7751r2d_setup,
293         .mv_init_irq            = init_rts7751r2d_IRQ,
294         .mv_irq_demux           = rts7751r2d_irq_demux,
295 };