Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
1da177e4 LT |
2 | * Renesas Technology Sales RTS7751R2D Support. |
3 | * | |
9c57548f PM |
4 | * Copyright (C) 2002 - 2006 Atom Create Engineering Co., Ltd. |
5 | * Copyright (C) 2004 - 2007 Paul Mundt | |
ade2b3f6 PM |
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. | |
1da177e4 | 10 | */ |
1da177e4 | 11 | #include <linux/init.h> |
ade2b3f6 | 12 | #include <linux/platform_device.h> |
c2e0090c JCPV |
13 | #include <linux/mtd/mtd.h> |
14 | #include <linux/mtd/partitions.h> | |
15 | #include <linux/mtd/physmap.h> | |
0a87e3e9 | 16 | #include <linux/ata_platform.h> |
c87a7111 | 17 | #include <linux/sm501.h> |
29ec6778 | 18 | #include <linux/sm501-regs.h> |
a56d276c | 19 | #include <linux/pm.h> |
cbd10dfb | 20 | #include <linux/fb.h> |
6582d7b7 MD |
21 | #include <linux/spi/spi.h> |
22 | #include <linux/spi/spi_bitbang.h> | |
2c7834a6 | 23 | #include <asm/machvec.h> |
7639a454 | 24 | #include <mach/r2d.h> |
9c57548f | 25 | #include <asm/io.h> |
2d952b4b | 26 | #include <asm/io_trapped.h> |
6582d7b7 | 27 | #include <asm/spi.h> |
ade2b3f6 | 28 | |
9c57548f PM |
29 | static struct resource cf_ide_resources[] = { |
30 | [0] = { | |
31 | .start = PA_AREA5_IO + 0x1000, | |
43f4b8c7 | 32 | .end = PA_AREA5_IO + 0x1000 + 0x10 - 0x2, |
9c57548f PM |
33 | .flags = IORESOURCE_MEM, |
34 | }, | |
35 | [1] = { | |
36 | .start = PA_AREA5_IO + 0x80c, | |
43f4b8c7 | 37 | .end = PA_AREA5_IO + 0x80c, |
9c57548f PM |
38 | .flags = IORESOURCE_MEM, |
39 | }, | |
abac3f78 | 40 | #ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */ |
9c57548f | 41 | [2] = { |
2eeec856 | 42 | .start = IRQ_CF_IDE, |
9c57548f PM |
43 | .flags = IORESOURCE_IRQ, |
44 | }, | |
abac3f78 | 45 | #endif |
9c57548f PM |
46 | }; |
47 | ||
48 | static struct pata_platform_info pata_info = { | |
49 | .ioport_shift = 1, | |
50 | }; | |
51 | ||
52 | static struct platform_device cf_ide_device = { | |
53 | .name = "pata_platform", | |
54 | .id = -1, | |
55 | .num_resources = ARRAY_SIZE(cf_ide_resources), | |
56 | .resource = cf_ide_resources, | |
57 | .dev = { | |
58 | .platform_data = &pata_info, | |
59 | }, | |
60 | }; | |
61 | ||
6582d7b7 MD |
62 | static struct spi_board_info spi_bus[] = { |
63 | { | |
64 | .modalias = "rtc-r9701", | |
65 | .max_speed_hz = 1000000, | |
66 | .mode = SPI_MODE_3, | |
67 | }, | |
68 | }; | |
69 | ||
70 | static void r2d_chip_select(struct sh_spi_info *spi, int cs, int state) | |
71 | { | |
72 | BUG_ON(cs != 0); /* Single Epson RTC-9701JE attached on CS0 */ | |
9d56dd3b | 73 | __raw_writew(state == BITBANG_CS_ACTIVE, PA_RTCCE); |
6582d7b7 MD |
74 | } |
75 | ||
76 | static struct sh_spi_info spi_info = { | |
77 | .num_chipselect = 1, | |
78 | .chip_select = r2d_chip_select, | |
79 | }; | |
80 | ||
81 | static struct resource spi_sh_sci_resources[] = { | |
82 | { | |
83 | .start = 0xffe00000, | |
84 | .end = 0xffe0001f, | |
85 | .flags = IORESOURCE_MEM, | |
86 | }, | |
87 | }; | |
88 | ||
89 | static struct platform_device spi_sh_sci_device = { | |
90 | .name = "spi_sh_sci", | |
91 | .id = -1, | |
92 | .num_resources = ARRAY_SIZE(spi_sh_sci_resources), | |
93 | .resource = spi_sh_sci_resources, | |
94 | .dev = { | |
95 | .platform_data = &spi_info, | |
96 | }, | |
97 | }; | |
98 | ||
f8b40d8c MD |
99 | static struct resource heartbeat_resources[] = { |
100 | [0] = { | |
101 | .start = PA_OUTPORT, | |
a1fd306b | 102 | .end = PA_OUTPORT, |
f8b40d8c MD |
103 | .flags = IORESOURCE_MEM, |
104 | }, | |
105 | }; | |
106 | ||
107 | static struct platform_device heartbeat_device = { | |
108 | .name = "heartbeat", | |
109 | .id = -1, | |
110 | .num_resources = ARRAY_SIZE(heartbeat_resources), | |
111 | .resource = heartbeat_resources, | |
112 | }; | |
113 | ||
c87a7111 PM |
114 | static struct resource sm501_resources[] = { |
115 | [0] = { | |
116 | .start = 0x10000000, | |
117 | .end = 0x13e00000 - 1, | |
118 | .flags = IORESOURCE_MEM, | |
119 | }, | |
120 | [1] = { | |
121 | .start = 0x13e00000, | |
122 | .end = 0x13ffffff, | |
123 | .flags = IORESOURCE_MEM, | |
124 | }, | |
125 | [2] = { | |
29ec6778 | 126 | .start = IRQ_VOYAGER, |
c87a7111 PM |
127 | .flags = IORESOURCE_IRQ, |
128 | }, | |
129 | }; | |
130 | ||
cbd10dfb MD |
131 | static struct fb_videomode sm501_default_mode = { |
132 | .pixclock = 35714, | |
133 | .xres = 640, | |
134 | .yres = 480, | |
135 | .left_margin = 105, | |
136 | .right_margin = 50, | |
137 | .upper_margin = 35, | |
138 | .lower_margin = 0, | |
139 | .hsync_len = 96, | |
140 | .vsync_len = 2, | |
141 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, | |
142 | }; | |
143 | ||
144 | static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = { | |
145 | .def_bpp = 16, | |
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, | |
151 | }; | |
152 | ||
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), | |
158 | ||
159 | }; | |
160 | ||
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, | |
166 | }; | |
167 | ||
29ec6778 | 168 | static struct sm501_initdata sm501_initdata = { |
fa7ff086 | 169 | .devices = SM501_USE_USB_HOST | SM501_USE_UART0, |
29ec6778 MD |
170 | }; |
171 | ||
cbd10dfb | 172 | static struct sm501_platdata sm501_platform_data = { |
29ec6778 | 173 | .init = &sm501_initdata, |
cbd10dfb MD |
174 | .fb = &sm501_fb_pdata, |
175 | }; | |
176 | ||
c87a7111 PM |
177 | static struct platform_device sm501_device = { |
178 | .name = "sm501", | |
179 | .id = -1, | |
cbd10dfb MD |
180 | .dev = { |
181 | .platform_data = &sm501_platform_data, | |
182 | }, | |
c87a7111 PM |
183 | .num_resources = ARRAY_SIZE(sm501_resources), |
184 | .resource = sm501_resources, | |
185 | }; | |
186 | ||
c2e0090c JCPV |
187 | static struct mtd_partition r2d_partitions[] = { |
188 | { | |
189 | .name = "U-Boot", | |
190 | .offset = 0x00000000, | |
191 | .size = 0x00040000, | |
192 | .mask_flags = MTD_WRITEABLE, | |
193 | }, { | |
194 | .name = "Environment", | |
195 | .offset = MTDPART_OFS_NXTBLK, | |
196 | .size = 0x00040000, | |
197 | .mask_flags = MTD_WRITEABLE, | |
198 | }, { | |
199 | .name = "Kernel", | |
200 | .offset = MTDPART_OFS_NXTBLK, | |
201 | .size = 0x001c0000, | |
202 | }, { | |
203 | .name = "Flash_FS", | |
204 | .offset = MTDPART_OFS_NXTBLK, | |
205 | .size = MTDPART_SIZ_FULL, | |
206 | } | |
207 | }; | |
208 | ||
209 | static struct physmap_flash_data flash_data = { | |
210 | .width = 2, | |
211 | .nr_parts = ARRAY_SIZE(r2d_partitions), | |
212 | .parts = r2d_partitions, | |
213 | }; | |
214 | ||
215 | static struct resource flash_resource = { | |
216 | .start = 0x00000000, | |
217 | .end = 0x02000000, | |
218 | .flags = IORESOURCE_MEM, | |
219 | }; | |
220 | ||
221 | static struct platform_device flash_device = { | |
222 | .name = "physmap-flash", | |
223 | .id = -1, | |
224 | .resource = &flash_resource, | |
225 | .num_resources = 1, | |
226 | .dev = { | |
227 | .platform_data = &flash_data, | |
228 | }, | |
229 | }; | |
230 | ||
ade2b3f6 | 231 | static struct platform_device *rts7751r2d_devices[] __initdata = { |
c87a7111 | 232 | &sm501_device, |
f8b40d8c | 233 | &heartbeat_device, |
6582d7b7 | 234 | &spi_sh_sci_device, |
ade2b3f6 PM |
235 | }; |
236 | ||
2d952b4b MD |
237 | /* |
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. | |
241 | */ | |
242 | static struct trapped_io cf_trapped_io = { | |
243 | .resource = cf_ide_resources, | |
244 | .num_resources = 2, | |
245 | .minimum_bus_width = 16, | |
246 | }; | |
247 | ||
ade2b3f6 PM |
248 | static int __init rts7751r2d_devices_setup(void) |
249 | { | |
2d952b4b MD |
250 | if (register_trapped_io(&cf_trapped_io) == 0) |
251 | platform_device_register(&cf_ide_device); | |
e305ec80 | 252 | |
c2e0090c JCPV |
253 | if (mach_is_r2d_plus()) |
254 | platform_device_register(&flash_device); | |
255 | ||
6582d7b7 | 256 | spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus)); |
e305ec80 | 257 | |
ade2b3f6 PM |
258 | return platform_add_devices(rts7751r2d_devices, |
259 | ARRAY_SIZE(rts7751r2d_devices)); | |
260 | } | |
9c57548f | 261 | __initcall(rts7751r2d_devices_setup); |
1da177e4 | 262 | |
a56d276c PM |
263 | static void rts7751r2d_power_off(void) |
264 | { | |
9d56dd3b | 265 | __raw_writew(0x0001, PA_POWOFF); |
a56d276c PM |
266 | } |
267 | ||
1da177e4 LT |
268 | /* |
269 | * Initialize the board | |
270 | */ | |
2c7834a6 | 271 | static void __init rts7751r2d_setup(char **cmdline_p) |
1da177e4 | 272 | { |
29ec6778 | 273 | void __iomem *sm501_reg; |
9d56dd3b | 274 | u16 ver = __raw_readw(PA_VERREG); |
9c57548f PM |
275 | |
276 | printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n"); | |
277 | ||
278 | printk(KERN_INFO "FPGA version:%d (revision:%d)\n", | |
279 | (ver >> 4) & 0xf, ver & 0xf); | |
2c7834a6 | 280 | |
9d56dd3b | 281 | __raw_writew(0x0000, PA_OUTPORT); |
a56d276c | 282 | pm_power_off = rts7751r2d_power_off; |
ade2b3f6 | 283 | |
29ec6778 MD |
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. | |
294 | */ | |
295 | ||
296 | sm501_reg = (void __iomem *)0xb3e00000 + SM501_DRAM_CONTROL; | |
297 | writel(readl(sm501_reg) | 0x00f107c0, sm501_reg); | |
1da177e4 | 298 | } |
2c7834a6 PM |
299 | |
300 | /* | |
301 | * The Machine Vector | |
302 | */ | |
82f81f47 | 303 | static struct sh_machine_vector mv_rts7751r2d __initmv = { |
2c7834a6 PM |
304 | .mv_name = "RTS7751R2D", |
305 | .mv_setup = rts7751r2d_setup, | |
2c7834a6 | 306 | .mv_init_irq = init_rts7751r2d_IRQ, |
2c7834a6 | 307 | .mv_irq_demux = rts7751r2d_irq_demux, |
2c7834a6 | 308 | }; |