Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Renesas Technology Sales RTS7751R2D Support. |
| 3 | * |
Paul Mundt | 9c57548 | 2007-02-15 18:20:52 +0900 | [diff] [blame] | 4 | * Copyright (C) 2002 - 2006 Atom Create Engineering Co., Ltd. |
| 5 | * Copyright (C) 2004 - 2007 Paul Mundt |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/init.h> |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 12 | #include <linux/platform_device.h> |
Jeff Garzik | 0a87e3e | 2008-02-01 18:02:30 -0500 | [diff] [blame] | 13 | #include <linux/ata_platform.h> |
Paul Mundt | c87a711 | 2007-03-01 18:47:08 +0900 | [diff] [blame] | 14 | #include <linux/sm501.h> |
Magnus Damm | 29ec677 | 2008-01-15 12:47:53 +0900 | [diff] [blame] | 15 | #include <linux/sm501-regs.h> |
Paul Mundt | a56d276 | 2006-09-27 11:43:24 +0900 | [diff] [blame] | 16 | #include <linux/pm.h> |
Magnus Damm | cbd10df | 2008-01-15 12:44:44 +0900 | [diff] [blame] | 17 | #include <linux/fb.h> |
Magnus Damm | 6582d7b | 2008-01-23 16:21:18 +0900 | [diff] [blame] | 18 | #include <linux/spi/spi.h> |
| 19 | #include <linux/spi/spi_bitbang.h> |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 20 | #include <asm/machvec.h> |
Paul Mundt | 7639a45 | 2008-10-20 13:02:48 +0900 | [diff] [blame^] | 21 | #include <mach/r2d.h> |
Paul Mundt | 9c57548 | 2007-02-15 18:20:52 +0900 | [diff] [blame] | 22 | #include <asm/io.h> |
Magnus Damm | 2d952b4 | 2008-02-07 20:21:10 +0900 | [diff] [blame] | 23 | #include <asm/io_trapped.h> |
Magnus Damm | 6582d7b | 2008-01-23 16:21:18 +0900 | [diff] [blame] | 24 | #include <asm/spi.h> |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 25 | |
Paul Mundt | 9c57548 | 2007-02-15 18:20:52 +0900 | [diff] [blame] | 26 | static struct resource cf_ide_resources[] = { |
| 27 | [0] = { |
| 28 | .start = PA_AREA5_IO + 0x1000, |
Aoi Shinkai | 43f4b8c | 2007-09-21 15:18:33 +0900 | [diff] [blame] | 29 | .end = PA_AREA5_IO + 0x1000 + 0x10 - 0x2, |
Paul Mundt | 9c57548 | 2007-02-15 18:20:52 +0900 | [diff] [blame] | 30 | .flags = IORESOURCE_MEM, |
| 31 | }, |
| 32 | [1] = { |
| 33 | .start = PA_AREA5_IO + 0x80c, |
Aoi Shinkai | 43f4b8c | 2007-09-21 15:18:33 +0900 | [diff] [blame] | 34 | .end = PA_AREA5_IO + 0x80c, |
Paul Mundt | 9c57548 | 2007-02-15 18:20:52 +0900 | [diff] [blame] | 35 | .flags = IORESOURCE_MEM, |
| 36 | }, |
Magnus Damm | abac3f7 | 2007-11-23 14:39:13 +0900 | [diff] [blame] | 37 | #ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */ |
Paul Mundt | 9c57548 | 2007-02-15 18:20:52 +0900 | [diff] [blame] | 38 | [2] = { |
Magnus Damm | 2eeec85 | 2007-08-12 15:29:16 +0900 | [diff] [blame] | 39 | .start = IRQ_CF_IDE, |
Paul Mundt | 9c57548 | 2007-02-15 18:20:52 +0900 | [diff] [blame] | 40 | .flags = IORESOURCE_IRQ, |
| 41 | }, |
Magnus Damm | abac3f7 | 2007-11-23 14:39:13 +0900 | [diff] [blame] | 42 | #endif |
Paul Mundt | 9c57548 | 2007-02-15 18:20:52 +0900 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | static struct pata_platform_info pata_info = { |
| 46 | .ioport_shift = 1, |
| 47 | }; |
| 48 | |
| 49 | static struct platform_device cf_ide_device = { |
| 50 | .name = "pata_platform", |
| 51 | .id = -1, |
| 52 | .num_resources = ARRAY_SIZE(cf_ide_resources), |
| 53 | .resource = cf_ide_resources, |
| 54 | .dev = { |
| 55 | .platform_data = &pata_info, |
| 56 | }, |
| 57 | }; |
| 58 | |
Magnus Damm | 6582d7b | 2008-01-23 16:21:18 +0900 | [diff] [blame] | 59 | static struct spi_board_info spi_bus[] = { |
| 60 | { |
| 61 | .modalias = "rtc-r9701", |
| 62 | .max_speed_hz = 1000000, |
| 63 | .mode = SPI_MODE_3, |
| 64 | }, |
| 65 | }; |
| 66 | |
| 67 | static void r2d_chip_select(struct sh_spi_info *spi, int cs, int state) |
| 68 | { |
| 69 | BUG_ON(cs != 0); /* Single Epson RTC-9701JE attached on CS0 */ |
| 70 | ctrl_outw(state == BITBANG_CS_ACTIVE, PA_RTCCE); |
| 71 | } |
| 72 | |
| 73 | static struct sh_spi_info spi_info = { |
| 74 | .num_chipselect = 1, |
| 75 | .chip_select = r2d_chip_select, |
| 76 | }; |
| 77 | |
| 78 | static struct resource spi_sh_sci_resources[] = { |
| 79 | { |
| 80 | .start = 0xffe00000, |
| 81 | .end = 0xffe0001f, |
| 82 | .flags = IORESOURCE_MEM, |
| 83 | }, |
| 84 | }; |
| 85 | |
| 86 | static struct platform_device spi_sh_sci_device = { |
| 87 | .name = "spi_sh_sci", |
| 88 | .id = -1, |
| 89 | .num_resources = ARRAY_SIZE(spi_sh_sci_resources), |
| 90 | .resource = spi_sh_sci_resources, |
| 91 | .dev = { |
| 92 | .platform_data = &spi_info, |
| 93 | }, |
| 94 | }; |
| 95 | |
Magnus Damm | f8b40d8 | 2007-08-12 15:30:40 +0900 | [diff] [blame] | 96 | static struct resource heartbeat_resources[] = { |
| 97 | [0] = { |
| 98 | .start = PA_OUTPORT, |
Paul Mundt | a1fd306 | 2007-08-23 15:11:44 +0900 | [diff] [blame] | 99 | .end = PA_OUTPORT, |
Magnus Damm | f8b40d8 | 2007-08-12 15:30:40 +0900 | [diff] [blame] | 100 | .flags = IORESOURCE_MEM, |
| 101 | }, |
| 102 | }; |
| 103 | |
| 104 | static struct platform_device heartbeat_device = { |
| 105 | .name = "heartbeat", |
| 106 | .id = -1, |
| 107 | .num_resources = ARRAY_SIZE(heartbeat_resources), |
| 108 | .resource = heartbeat_resources, |
| 109 | }; |
| 110 | |
Paul Mundt | c87a711 | 2007-03-01 18:47:08 +0900 | [diff] [blame] | 111 | static struct resource sm501_resources[] = { |
| 112 | [0] = { |
| 113 | .start = 0x10000000, |
| 114 | .end = 0x13e00000 - 1, |
| 115 | .flags = IORESOURCE_MEM, |
| 116 | }, |
| 117 | [1] = { |
| 118 | .start = 0x13e00000, |
| 119 | .end = 0x13ffffff, |
| 120 | .flags = IORESOURCE_MEM, |
| 121 | }, |
| 122 | [2] = { |
Magnus Damm | 29ec677 | 2008-01-15 12:47:53 +0900 | [diff] [blame] | 123 | .start = IRQ_VOYAGER, |
Paul Mundt | c87a711 | 2007-03-01 18:47:08 +0900 | [diff] [blame] | 124 | .flags = IORESOURCE_IRQ, |
| 125 | }, |
| 126 | }; |
| 127 | |
Magnus Damm | cbd10df | 2008-01-15 12:44:44 +0900 | [diff] [blame] | 128 | static struct fb_videomode sm501_default_mode = { |
| 129 | .pixclock = 35714, |
| 130 | .xres = 640, |
| 131 | .yres = 480, |
| 132 | .left_margin = 105, |
| 133 | .right_margin = 50, |
| 134 | .upper_margin = 35, |
| 135 | .lower_margin = 0, |
| 136 | .hsync_len = 96, |
| 137 | .vsync_len = 2, |
| 138 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 139 | }; |
| 140 | |
| 141 | static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = { |
| 142 | .def_bpp = 16, |
| 143 | .def_mode = &sm501_default_mode, |
| 144 | .flags = SM501FB_FLAG_USE_INIT_MODE | |
| 145 | SM501FB_FLAG_USE_HWCURSOR | |
| 146 | SM501FB_FLAG_USE_HWACCEL | |
| 147 | SM501FB_FLAG_DISABLE_AT_EXIT, |
| 148 | }; |
| 149 | |
| 150 | static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt = { |
| 151 | .flags = (SM501FB_FLAG_USE_INIT_MODE | |
| 152 | SM501FB_FLAG_USE_HWCURSOR | |
| 153 | SM501FB_FLAG_USE_HWACCEL | |
| 154 | SM501FB_FLAG_DISABLE_AT_EXIT), |
| 155 | |
| 156 | }; |
| 157 | |
| 158 | static struct sm501_platdata_fb sm501_fb_pdata = { |
| 159 | .fb_route = SM501_FB_OWN, |
| 160 | .fb_crt = &sm501_pdata_fbsub_crt, |
| 161 | .fb_pnl = &sm501_pdata_fbsub_pnl, |
| 162 | .flags = SM501_FBPD_SWAP_FB_ENDIAN, |
| 163 | }; |
| 164 | |
Magnus Damm | 29ec677 | 2008-01-15 12:47:53 +0900 | [diff] [blame] | 165 | static struct sm501_initdata sm501_initdata = { |
Magnus Damm | fa7ff08 | 2008-05-22 22:34:28 +0900 | [diff] [blame] | 166 | .devices = SM501_USE_USB_HOST | SM501_USE_UART0, |
Magnus Damm | 29ec677 | 2008-01-15 12:47:53 +0900 | [diff] [blame] | 167 | }; |
| 168 | |
Magnus Damm | cbd10df | 2008-01-15 12:44:44 +0900 | [diff] [blame] | 169 | static struct sm501_platdata sm501_platform_data = { |
Magnus Damm | 29ec677 | 2008-01-15 12:47:53 +0900 | [diff] [blame] | 170 | .init = &sm501_initdata, |
Magnus Damm | cbd10df | 2008-01-15 12:44:44 +0900 | [diff] [blame] | 171 | .fb = &sm501_fb_pdata, |
| 172 | }; |
| 173 | |
Paul Mundt | c87a711 | 2007-03-01 18:47:08 +0900 | [diff] [blame] | 174 | static struct platform_device sm501_device = { |
| 175 | .name = "sm501", |
| 176 | .id = -1, |
Magnus Damm | cbd10df | 2008-01-15 12:44:44 +0900 | [diff] [blame] | 177 | .dev = { |
| 178 | .platform_data = &sm501_platform_data, |
| 179 | }, |
Paul Mundt | c87a711 | 2007-03-01 18:47:08 +0900 | [diff] [blame] | 180 | .num_resources = ARRAY_SIZE(sm501_resources), |
| 181 | .resource = sm501_resources, |
| 182 | }; |
| 183 | |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 184 | static struct platform_device *rts7751r2d_devices[] __initdata = { |
Paul Mundt | c87a711 | 2007-03-01 18:47:08 +0900 | [diff] [blame] | 185 | &sm501_device, |
Magnus Damm | f8b40d8 | 2007-08-12 15:30:40 +0900 | [diff] [blame] | 186 | &heartbeat_device, |
Magnus Damm | 6582d7b | 2008-01-23 16:21:18 +0900 | [diff] [blame] | 187 | &spi_sh_sci_device, |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 188 | }; |
| 189 | |
Magnus Damm | 2d952b4 | 2008-02-07 20:21:10 +0900 | [diff] [blame] | 190 | /* |
| 191 | * The CF is connected with a 16-bit bus where 8-bit operations are |
| 192 | * unsupported. The linux ata driver is however using 8-bit operations, so |
| 193 | * insert a trapped io filter to convert 8-bit operations into 16-bit. |
| 194 | */ |
| 195 | static struct trapped_io cf_trapped_io = { |
| 196 | .resource = cf_ide_resources, |
| 197 | .num_resources = 2, |
| 198 | .minimum_bus_width = 16, |
| 199 | }; |
| 200 | |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 201 | static int __init rts7751r2d_devices_setup(void) |
| 202 | { |
Magnus Damm | 2d952b4 | 2008-02-07 20:21:10 +0900 | [diff] [blame] | 203 | if (register_trapped_io(&cf_trapped_io) == 0) |
| 204 | platform_device_register(&cf_ide_device); |
Paul Mundt | e305ec8 | 2008-04-25 16:10:53 +0900 | [diff] [blame] | 205 | |
Magnus Damm | 6582d7b | 2008-01-23 16:21:18 +0900 | [diff] [blame] | 206 | spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus)); |
Paul Mundt | e305ec8 | 2008-04-25 16:10:53 +0900 | [diff] [blame] | 207 | |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 208 | return platform_add_devices(rts7751r2d_devices, |
| 209 | ARRAY_SIZE(rts7751r2d_devices)); |
| 210 | } |
Paul Mundt | 9c57548 | 2007-02-15 18:20:52 +0900 | [diff] [blame] | 211 | __initcall(rts7751r2d_devices_setup); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | |
Paul Mundt | a56d276 | 2006-09-27 11:43:24 +0900 | [diff] [blame] | 213 | static void rts7751r2d_power_off(void) |
| 214 | { |
| 215 | ctrl_outw(0x0001, PA_POWOFF); |
| 216 | } |
| 217 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | /* |
| 219 | * Initialize the board |
| 220 | */ |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 221 | static void __init rts7751r2d_setup(char **cmdline_p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | { |
Magnus Damm | 29ec677 | 2008-01-15 12:47:53 +0900 | [diff] [blame] | 223 | void __iomem *sm501_reg; |
Paul Mundt | 9c57548 | 2007-02-15 18:20:52 +0900 | [diff] [blame] | 224 | u16 ver = ctrl_inw(PA_VERREG); |
| 225 | |
| 226 | printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n"); |
| 227 | |
| 228 | printk(KERN_INFO "FPGA version:%d (revision:%d)\n", |
| 229 | (ver >> 4) & 0xf, ver & 0xf); |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 230 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | ctrl_outw(0x0000, PA_OUTPORT); |
Paul Mundt | a56d276 | 2006-09-27 11:43:24 +0900 | [diff] [blame] | 232 | pm_power_off = rts7751r2d_power_off; |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 233 | |
Magnus Damm | 29ec677 | 2008-01-15 12:47:53 +0900 | [diff] [blame] | 234 | /* sm501 dram configuration: |
| 235 | * ColSizeX = 11 - External Memory Column Size: 256 words. |
| 236 | * APX = 1 - External Memory Active to Pre-Charge Delay: 7 clocks. |
| 237 | * RstX = 1 - External Memory Reset: Normal. |
| 238 | * Rfsh = 1 - Local Memory Refresh to Command Delay: 12 clocks. |
| 239 | * BwC = 1 - Local Memory Block Write Cycle Time: 2 clocks. |
| 240 | * BwP = 1 - Local Memory Block Write to Pre-Charge Delay: 1 clock. |
| 241 | * AP = 1 - Internal Memory Active to Pre-Charge Delay: 7 clocks. |
| 242 | * Rst = 1 - Internal Memory Reset: Normal. |
| 243 | * RA = 1 - Internal Memory Remain in Active State: Do not remain. |
| 244 | */ |
| 245 | |
| 246 | sm501_reg = (void __iomem *)0xb3e00000 + SM501_DRAM_CONTROL; |
| 247 | writel(readl(sm501_reg) | 0x00f107c0, sm501_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | } |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 249 | |
| 250 | /* |
| 251 | * The Machine Vector |
| 252 | */ |
Paul Mundt | 82f81f4 | 2007-05-15 15:19:34 +0900 | [diff] [blame] | 253 | static struct sh_machine_vector mv_rts7751r2d __initmv = { |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 254 | .mv_name = "RTS7751R2D", |
| 255 | .mv_setup = rts7751r2d_setup, |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 256 | .mv_init_irq = init_rts7751r2d_IRQ, |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 257 | .mv_irq_demux = rts7751r2d_irq_demux, |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 258 | }; |