Magnus Damm | 70f784e | 2008-02-07 00:38:24 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Renesas System Solutions Asia Pte. Ltd - Migo-R |
| 3 | * |
| 4 | * Copyright (C) 2008 Magnus Damm |
| 5 | * |
| 6 | * This file is subject to the terms and conditions of the GNU General Public |
| 7 | * License. See the file "COPYING" in the main directory of this archive |
| 8 | * for more details. |
| 9 | */ |
| 10 | #include <linux/init.h> |
| 11 | #include <linux/platform_device.h> |
| 12 | #include <linux/interrupt.h> |
Magnus Damm | 92cfeb6 | 2008-03-04 15:23:45 -0800 | [diff] [blame] | 13 | #include <linux/input.h> |
Magnus Damm | b880878 | 2008-03-21 18:43:55 +0900 | [diff] [blame] | 14 | #include <linux/mtd/physmap.h> |
Magnus Damm | 3c803a9 | 2008-03-21 18:44:04 +0900 | [diff] [blame] | 15 | #include <linux/mtd/nand.h> |
Magnus Damm | 0c6111e | 2008-03-25 17:20:24 +0900 | [diff] [blame] | 16 | #include <linux/i2c.h> |
Magnus Damm | 8a3ee0f | 2008-04-23 20:13:59 +0900 | [diff] [blame] | 17 | #include <linux/smc91x.h> |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 18 | #include <linux/delay.h> |
| 19 | #include <linux/clk.h> |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 20 | #include <linux/gpio.h> |
Magnus Damm | 70e5c4f | 2009-01-07 20:36:10 +0900 | [diff] [blame] | 21 | #include <video/sh_mobile_lcdc.h> |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 22 | #include <media/sh_mobile_ceu.h> |
Kuninori Morimoto | ff04ea4 | 2008-12-02 16:38:34 +0900 | [diff] [blame] | 23 | #include <media/ov772x.h> |
Kuninori Morimoto | deae7b8 | 2009-01-05 16:25:16 +0900 | [diff] [blame] | 24 | #include <media/tw9910.h> |
Magnus Damm | 6c7d826 | 2008-07-17 19:16:11 +0900 | [diff] [blame] | 25 | #include <asm/clock.h> |
Magnus Damm | 70f784e | 2008-02-07 00:38:24 +0900 | [diff] [blame] | 26 | #include <asm/machvec.h> |
| 27 | #include <asm/io.h> |
Magnus Damm | 92cfeb6 | 2008-03-04 15:23:45 -0800 | [diff] [blame] | 28 | #include <asm/sh_keysc.h> |
Paul Mundt | 7639a45 | 2008-10-20 13:02:48 +0900 | [diff] [blame] | 29 | #include <mach/migor.h> |
Paul Mundt | f727565 | 2008-10-20 12:04:53 +0900 | [diff] [blame] | 30 | #include <cpu/sh7722.h> |
Magnus Damm | 70f784e | 2008-02-07 00:38:24 +0900 | [diff] [blame] | 31 | |
| 32 | /* Address IRQ Size Bus Description |
| 33 | * 0x00000000 64MB 16 NOR Flash (SP29PL256N) |
| 34 | * 0x0c000000 64MB 64 SDRAM (2xK4M563233G) |
| 35 | * 0x10000000 IRQ0 16 Ethernet (SMC91C111) |
| 36 | * 0x14000000 IRQ4 16 USB 2.0 Host Controller (M66596) |
| 37 | * 0x18000000 8GB 8 NAND Flash (K9K8G08U0A) |
| 38 | */ |
| 39 | |
Magnus Damm | 8a3ee0f | 2008-04-23 20:13:59 +0900 | [diff] [blame] | 40 | static struct smc91x_platdata smc91x_info = { |
Magnus Damm | a30c89a | 2008-10-09 18:41:34 +0900 | [diff] [blame] | 41 | .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT, |
Magnus Damm | 8a3ee0f | 2008-04-23 20:13:59 +0900 | [diff] [blame] | 42 | }; |
| 43 | |
Magnus Damm | 70f784e | 2008-02-07 00:38:24 +0900 | [diff] [blame] | 44 | static struct resource smc91x_eth_resources[] = { |
| 45 | [0] = { |
Magnus Damm | b026a23 | 2008-03-21 18:43:46 +0900 | [diff] [blame] | 46 | .name = "SMC91C111" , |
| 47 | .start = 0x10000300, |
| 48 | .end = 0x1000030f, |
Magnus Damm | 70f784e | 2008-02-07 00:38:24 +0900 | [diff] [blame] | 49 | .flags = IORESOURCE_MEM, |
| 50 | }, |
| 51 | [1] = { |
| 52 | .start = 32, /* IRQ0 */ |
Eric Miao | d280ead | 2008-06-06 17:13:02 +0800 | [diff] [blame] | 53 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, |
Magnus Damm | 70f784e | 2008-02-07 00:38:24 +0900 | [diff] [blame] | 54 | }, |
| 55 | }; |
| 56 | |
| 57 | static struct platform_device smc91x_eth_device = { |
| 58 | .name = "smc91x", |
| 59 | .num_resources = ARRAY_SIZE(smc91x_eth_resources), |
| 60 | .resource = smc91x_eth_resources, |
Magnus Damm | 8a3ee0f | 2008-04-23 20:13:59 +0900 | [diff] [blame] | 61 | .dev = { |
| 62 | .platform_data = &smc91x_info, |
| 63 | }, |
Magnus Damm | 70f784e | 2008-02-07 00:38:24 +0900 | [diff] [blame] | 64 | }; |
| 65 | |
Magnus Damm | 92cfeb6 | 2008-03-04 15:23:45 -0800 | [diff] [blame] | 66 | static struct sh_keysc_info sh_keysc_info = { |
| 67 | .mode = SH_KEYSC_MODE_2, /* KEYOUT0->4, KEYIN1->5 */ |
| 68 | .scan_timing = 3, |
| 69 | .delay = 5, |
| 70 | .keycodes = { |
| 71 | 0, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_ENTER, |
| 72 | 0, KEY_F, KEY_C, KEY_D, KEY_H, KEY_1, |
| 73 | 0, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, |
| 74 | 0, KEY_7, KEY_8, KEY_9, KEY_S, KEY_0, |
| 75 | 0, KEY_P, KEY_STOP, KEY_REWIND, KEY_PLAY, KEY_FASTFORWARD, |
| 76 | }, |
| 77 | }; |
| 78 | |
| 79 | static struct resource sh_keysc_resources[] = { |
| 80 | [0] = { |
| 81 | .start = 0x044b0000, |
| 82 | .end = 0x044b000f, |
| 83 | .flags = IORESOURCE_MEM, |
| 84 | }, |
| 85 | [1] = { |
| 86 | .start = 79, |
| 87 | .flags = IORESOURCE_IRQ, |
| 88 | }, |
| 89 | }; |
| 90 | |
| 91 | static struct platform_device sh_keysc_device = { |
| 92 | .name = "sh_keysc", |
Magnus Damm | 090d951 | 2008-10-31 20:21:23 +0900 | [diff] [blame] | 93 | .id = 0, /* "keysc0" clock */ |
Magnus Damm | 92cfeb6 | 2008-03-04 15:23:45 -0800 | [diff] [blame] | 94 | .num_resources = ARRAY_SIZE(sh_keysc_resources), |
| 95 | .resource = sh_keysc_resources, |
| 96 | .dev = { |
| 97 | .platform_data = &sh_keysc_info, |
| 98 | }, |
Magnus Damm | 2de63cf | 2009-07-31 07:47:35 +0000 | [diff] [blame] | 99 | .archdata = { |
| 100 | .hwblk_id = HWBLK_KEYSC, |
| 101 | }, |
Magnus Damm | 92cfeb6 | 2008-03-04 15:23:45 -0800 | [diff] [blame] | 102 | }; |
| 103 | |
Magnus Damm | b880878 | 2008-03-21 18:43:55 +0900 | [diff] [blame] | 104 | static struct mtd_partition migor_nor_flash_partitions[] = |
| 105 | { |
| 106 | { |
| 107 | .name = "uboot", |
| 108 | .offset = 0, |
| 109 | .size = (1 * 1024 * 1024), |
| 110 | .mask_flags = MTD_WRITEABLE, /* Read-only */ |
| 111 | }, |
| 112 | { |
| 113 | .name = "rootfs", |
| 114 | .offset = MTDPART_OFS_APPEND, |
| 115 | .size = (15 * 1024 * 1024), |
| 116 | }, |
| 117 | { |
| 118 | .name = "other", |
| 119 | .offset = MTDPART_OFS_APPEND, |
| 120 | .size = MTDPART_SIZ_FULL, |
| 121 | }, |
| 122 | }; |
| 123 | |
| 124 | static struct physmap_flash_data migor_nor_flash_data = { |
| 125 | .width = 2, |
| 126 | .parts = migor_nor_flash_partitions, |
| 127 | .nr_parts = ARRAY_SIZE(migor_nor_flash_partitions), |
| 128 | }; |
| 129 | |
| 130 | static struct resource migor_nor_flash_resources[] = { |
| 131 | [0] = { |
| 132 | .name = "NOR Flash", |
| 133 | .start = 0x00000000, |
| 134 | .end = 0x03ffffff, |
| 135 | .flags = IORESOURCE_MEM, |
| 136 | } |
| 137 | }; |
| 138 | |
| 139 | static struct platform_device migor_nor_flash_device = { |
| 140 | .name = "physmap-flash", |
| 141 | .resource = migor_nor_flash_resources, |
| 142 | .num_resources = ARRAY_SIZE(migor_nor_flash_resources), |
| 143 | .dev = { |
| 144 | .platform_data = &migor_nor_flash_data, |
| 145 | }, |
| 146 | }; |
| 147 | |
Magnus Damm | 3c803a9 | 2008-03-21 18:44:04 +0900 | [diff] [blame] | 148 | static struct mtd_partition migor_nand_flash_partitions[] = { |
| 149 | { |
| 150 | .name = "nanddata1", |
| 151 | .offset = 0x0, |
| 152 | .size = 512 * 1024 * 1024, |
| 153 | }, |
| 154 | { |
| 155 | .name = "nanddata2", |
| 156 | .offset = MTDPART_OFS_APPEND, |
| 157 | .size = 512 * 1024 * 1024, |
| 158 | }, |
| 159 | }; |
| 160 | |
| 161 | static void migor_nand_flash_cmd_ctl(struct mtd_info *mtd, int cmd, |
| 162 | unsigned int ctrl) |
| 163 | { |
| 164 | struct nand_chip *chip = mtd->priv; |
| 165 | |
| 166 | if (cmd == NAND_CMD_NONE) |
| 167 | return; |
| 168 | |
| 169 | if (ctrl & NAND_CLE) |
| 170 | writeb(cmd, chip->IO_ADDR_W + 0x00400000); |
| 171 | else if (ctrl & NAND_ALE) |
| 172 | writeb(cmd, chip->IO_ADDR_W + 0x00800000); |
| 173 | else |
| 174 | writeb(cmd, chip->IO_ADDR_W); |
| 175 | } |
| 176 | |
| 177 | static int migor_nand_flash_ready(struct mtd_info *mtd) |
| 178 | { |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 179 | return gpio_get_value(GPIO_PTA1); /* NAND_RBn */ |
Magnus Damm | 3c803a9 | 2008-03-21 18:44:04 +0900 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | struct platform_nand_data migor_nand_flash_data = { |
| 183 | .chip = { |
| 184 | .nr_chips = 1, |
| 185 | .partitions = migor_nand_flash_partitions, |
| 186 | .nr_partitions = ARRAY_SIZE(migor_nand_flash_partitions), |
| 187 | .chip_delay = 20, |
| 188 | .part_probe_types = (const char *[]) { "cmdlinepart", NULL }, |
| 189 | }, |
| 190 | .ctrl = { |
| 191 | .dev_ready = migor_nand_flash_ready, |
| 192 | .cmd_ctrl = migor_nand_flash_cmd_ctl, |
| 193 | }, |
| 194 | }; |
| 195 | |
| 196 | static struct resource migor_nand_flash_resources[] = { |
| 197 | [0] = { |
| 198 | .name = "NAND Flash", |
| 199 | .start = 0x18000000, |
| 200 | .end = 0x18ffffff, |
| 201 | .flags = IORESOURCE_MEM, |
| 202 | }, |
| 203 | }; |
| 204 | |
| 205 | static struct platform_device migor_nand_flash_device = { |
| 206 | .name = "gen_nand", |
| 207 | .resource = migor_nand_flash_resources, |
| 208 | .num_resources = ARRAY_SIZE(migor_nand_flash_resources), |
| 209 | .dev = { |
| 210 | .platform_data = &migor_nand_flash_data, |
| 211 | } |
| 212 | }; |
| 213 | |
Magnus Damm | 8b1285f | 2008-07-28 18:47:30 +0900 | [diff] [blame] | 214 | static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = { |
| 215 | #ifdef CONFIG_SH_MIGOR_RTA_WVGA |
| 216 | .clock_source = LCDC_CLK_BUS, |
| 217 | .ch[0] = { |
| 218 | .chan = LCDC_CHAN_MAINLCD, |
| 219 | .bpp = 16, |
| 220 | .interface_type = RGB16, |
| 221 | .clock_divider = 2, |
| 222 | .lcd_cfg = { |
| 223 | .name = "LB070WV1", |
| 224 | .xres = 800, |
| 225 | .yres = 480, |
| 226 | .left_margin = 64, |
| 227 | .right_margin = 16, |
| 228 | .hsync_len = 120, |
| 229 | .upper_margin = 1, |
| 230 | .lower_margin = 17, |
| 231 | .vsync_len = 2, |
| 232 | .sync = 0, |
| 233 | }, |
Magnus Damm | ce9c008 | 2008-08-11 15:26:00 +0900 | [diff] [blame] | 234 | .lcd_size_cfg = { /* 7.0 inch */ |
| 235 | .width = 152, |
| 236 | .height = 91, |
| 237 | }, |
Magnus Damm | 8b1285f | 2008-07-28 18:47:30 +0900 | [diff] [blame] | 238 | } |
| 239 | #endif |
| 240 | #ifdef CONFIG_SH_MIGOR_QVGA |
| 241 | .clock_source = LCDC_CLK_PERIPHERAL, |
| 242 | .ch[0] = { |
| 243 | .chan = LCDC_CHAN_MAINLCD, |
| 244 | .bpp = 16, |
| 245 | .interface_type = SYS16A, |
| 246 | .clock_divider = 10, |
| 247 | .lcd_cfg = { |
| 248 | .name = "PH240320T", |
| 249 | .xres = 320, |
| 250 | .yres = 240, |
| 251 | .left_margin = 0, |
| 252 | .right_margin = 16, |
| 253 | .hsync_len = 8, |
| 254 | .upper_margin = 1, |
| 255 | .lower_margin = 17, |
| 256 | .vsync_len = 2, |
| 257 | .sync = FB_SYNC_HOR_HIGH_ACT, |
| 258 | }, |
Magnus Damm | ce9c008 | 2008-08-11 15:26:00 +0900 | [diff] [blame] | 259 | .lcd_size_cfg = { /* 2.4 inch */ |
| 260 | .width = 49, |
| 261 | .height = 37, |
| 262 | }, |
Magnus Damm | 8b1285f | 2008-07-28 18:47:30 +0900 | [diff] [blame] | 263 | .board_cfg = { |
| 264 | .setup_sys = migor_lcd_qvga_setup, |
| 265 | }, |
| 266 | .sys_bus_cfg = { |
| 267 | .ldmt2r = 0x06000a09, |
| 268 | .ldmt3r = 0x180e3418, |
Magnus Damm | b5868e8 | 2008-12-19 15:34:50 +0900 | [diff] [blame] | 269 | /* set 1s delay to encourage fsync() */ |
| 270 | .deferred_io_msec = 1000, |
Magnus Damm | 8b1285f | 2008-07-28 18:47:30 +0900 | [diff] [blame] | 271 | }, |
| 272 | } |
| 273 | #endif |
| 274 | }; |
| 275 | |
| 276 | static struct resource migor_lcdc_resources[] = { |
| 277 | [0] = { |
| 278 | .name = "LCDC", |
| 279 | .start = 0xfe940000, /* P4-only space */ |
Phil Edworthy | a6f15ad | 2009-09-15 12:00:30 +0000 | [diff] [blame] | 280 | .end = 0xfe942fff, |
Magnus Damm | 8b1285f | 2008-07-28 18:47:30 +0900 | [diff] [blame] | 281 | .flags = IORESOURCE_MEM, |
| 282 | }, |
Magnus Damm | 0790555 | 2008-12-19 12:02:16 +0900 | [diff] [blame] | 283 | [1] = { |
| 284 | .start = 28, |
| 285 | .flags = IORESOURCE_IRQ, |
| 286 | }, |
Magnus Damm | 8b1285f | 2008-07-28 18:47:30 +0900 | [diff] [blame] | 287 | }; |
| 288 | |
| 289 | static struct platform_device migor_lcdc_device = { |
| 290 | .name = "sh_mobile_lcdc_fb", |
| 291 | .num_resources = ARRAY_SIZE(migor_lcdc_resources), |
| 292 | .resource = migor_lcdc_resources, |
| 293 | .dev = { |
| 294 | .platform_data = &sh_mobile_lcdc_info, |
| 295 | }, |
Magnus Damm | 2de63cf | 2009-07-31 07:47:35 +0000 | [diff] [blame] | 296 | .archdata = { |
| 297 | .hwblk_id = HWBLK_LCDC, |
| 298 | }, |
Magnus Damm | 8b1285f | 2008-07-28 18:47:30 +0900 | [diff] [blame] | 299 | }; |
| 300 | |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 301 | static struct clk *camera_clk; |
Kuninori Morimoto | deae7b8 | 2009-01-05 16:25:16 +0900 | [diff] [blame] | 302 | static DEFINE_MUTEX(camera_lock); |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 303 | |
Kuninori Morimoto | deae7b8 | 2009-01-05 16:25:16 +0900 | [diff] [blame] | 304 | static void camera_power_on(int is_tw) |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 305 | { |
Kuninori Morimoto | deae7b8 | 2009-01-05 16:25:16 +0900 | [diff] [blame] | 306 | mutex_lock(&camera_lock); |
| 307 | |
Magnus Damm | 22ee3ba | 2008-10-22 18:25:39 +0900 | [diff] [blame] | 308 | /* Use 10 MHz VIO_CKO instead of 24 MHz to work |
| 309 | * around signal quality issues on Panel Board V2.1. |
| 310 | */ |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 311 | camera_clk = clk_get(NULL, "video_clk"); |
Magnus Damm | 22ee3ba | 2008-10-22 18:25:39 +0900 | [diff] [blame] | 312 | clk_set_rate(camera_clk, 10000000); |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 313 | clk_enable(camera_clk); /* start VIO_CKO */ |
| 314 | |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 315 | /* use VIO_RST to take camera out of reset */ |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 316 | mdelay(10); |
Kuninori Morimoto | deae7b8 | 2009-01-05 16:25:16 +0900 | [diff] [blame] | 317 | if (is_tw) { |
| 318 | gpio_set_value(GPIO_PTT2, 0); |
| 319 | gpio_set_value(GPIO_PTT0, 0); |
| 320 | } else { |
| 321 | gpio_set_value(GPIO_PTT0, 1); |
| 322 | } |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 323 | gpio_set_value(GPIO_PTT3, 0); |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 324 | mdelay(10); |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 325 | gpio_set_value(GPIO_PTT3, 1); |
Magnus Damm | 4545bfa | 2008-12-10 17:02:13 +0900 | [diff] [blame] | 326 | mdelay(10); /* wait to let chip come out of reset */ |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | static void camera_power_off(void) |
| 330 | { |
| 331 | clk_disable(camera_clk); /* stop VIO_CKO */ |
| 332 | clk_put(camera_clk); |
| 333 | |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 334 | gpio_set_value(GPIO_PTT3, 0); |
Kuninori Morimoto | deae7b8 | 2009-01-05 16:25:16 +0900 | [diff] [blame] | 335 | mutex_unlock(&camera_lock); |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 336 | } |
| 337 | |
Kuninori Morimoto | ff04ea4 | 2008-12-02 16:38:34 +0900 | [diff] [blame] | 338 | static int ov7725_power(struct device *dev, int mode) |
| 339 | { |
| 340 | if (mode) |
Kuninori Morimoto | deae7b8 | 2009-01-05 16:25:16 +0900 | [diff] [blame] | 341 | camera_power_on(0); |
| 342 | else |
| 343 | camera_power_off(); |
| 344 | |
| 345 | return 0; |
| 346 | } |
| 347 | |
| 348 | static int tw9910_power(struct device *dev, int mode) |
| 349 | { |
| 350 | if (mode) |
| 351 | camera_power_on(1); |
Kuninori Morimoto | ff04ea4 | 2008-12-02 16:38:34 +0900 | [diff] [blame] | 352 | else |
| 353 | camera_power_off(); |
| 354 | |
| 355 | return 0; |
| 356 | } |
| 357 | |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 358 | static struct sh_mobile_ceu_info sh_mobile_ceu_info = { |
Paul Mundt | 6493505 | 2009-04-02 11:25:12 +0900 | [diff] [blame] | 359 | .flags = SH_CEU_FLAG_USE_8BIT_BUS, |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 360 | }; |
| 361 | |
| 362 | static struct resource migor_ceu_resources[] = { |
| 363 | [0] = { |
| 364 | .name = "CEU", |
| 365 | .start = 0xfe910000, |
| 366 | .end = 0xfe91009f, |
| 367 | .flags = IORESOURCE_MEM, |
| 368 | }, |
| 369 | [1] = { |
| 370 | .start = 52, |
| 371 | .flags = IORESOURCE_IRQ, |
| 372 | }, |
| 373 | [2] = { |
| 374 | /* place holder for contiguous memory */ |
| 375 | }, |
| 376 | }; |
| 377 | |
| 378 | static struct platform_device migor_ceu_device = { |
| 379 | .name = "sh_mobile_ceu", |
Magnus Damm | a42b6dd | 2008-10-31 20:21:44 +0900 | [diff] [blame] | 380 | .id = 0, /* "ceu0" clock */ |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 381 | .num_resources = ARRAY_SIZE(migor_ceu_resources), |
| 382 | .resource = migor_ceu_resources, |
| 383 | .dev = { |
| 384 | .platform_data = &sh_mobile_ceu_info, |
| 385 | }, |
Magnus Damm | 2de63cf | 2009-07-31 07:47:35 +0000 | [diff] [blame] | 386 | .archdata = { |
| 387 | .hwblk_id = HWBLK_CEU, |
| 388 | }, |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 389 | }; |
| 390 | |
Magnus Damm | 2e3fc56 | 2009-10-02 02:22:43 +0000 | [diff] [blame] | 391 | static struct resource sdhi_cn9_resources[] = { |
| 392 | [0] = { |
| 393 | .name = "SDHI", |
| 394 | .start = 0x04ce0000, |
| 395 | .end = 0x04ce01ff, |
| 396 | .flags = IORESOURCE_MEM, |
| 397 | }, |
| 398 | [1] = { |
| 399 | .start = 101, |
| 400 | .flags = IORESOURCE_IRQ, |
| 401 | }, |
Magnus Damm | 70e5c4f | 2009-01-07 20:36:10 +0900 | [diff] [blame] | 402 | }; |
| 403 | |
Magnus Damm | 2e3fc56 | 2009-10-02 02:22:43 +0000 | [diff] [blame] | 404 | static struct platform_device sdhi_cn9_device = { |
| 405 | .name = "sh_mobile_sdhi", |
| 406 | .num_resources = ARRAY_SIZE(sdhi_cn9_resources), |
| 407 | .resource = sdhi_cn9_resources, |
| 408 | .archdata = { |
| 409 | .hwblk_id = HWBLK_SDHI, |
Magnus Damm | 70e5c4f | 2009-01-07 20:36:10 +0900 | [diff] [blame] | 410 | }, |
| 411 | }; |
| 412 | |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 413 | static struct i2c_board_info migor_i2c_devices[] = { |
Magnus Damm | 5779586 | 2008-03-25 17:24:31 +0900 | [diff] [blame] | 414 | { |
Jean Delvare | 3760f73 | 2008-04-29 23:11:40 +0200 | [diff] [blame] | 415 | I2C_BOARD_INFO("rs5c372b", 0x32), |
Magnus Damm | 5779586 | 2008-03-25 17:24:31 +0900 | [diff] [blame] | 416 | }, |
Magnus Damm | 67908ab | 2008-03-25 17:30:45 +0900 | [diff] [blame] | 417 | { |
| 418 | I2C_BOARD_INFO("migor_ts", 0x51), |
| 419 | .irq = 38, /* IRQ6 */ |
| 420 | }, |
Guennadi Liakhovetski | 2cb582c | 2009-05-12 15:13:40 +0000 | [diff] [blame] | 421 | }; |
| 422 | |
| 423 | static struct i2c_board_info migor_i2c_camera[] = { |
Kuninori Morimoto | ff04ea4 | 2008-12-02 16:38:34 +0900 | [diff] [blame] | 424 | { |
| 425 | I2C_BOARD_INFO("ov772x", 0x21), |
Kuninori Morimoto | ff04ea4 | 2008-12-02 16:38:34 +0900 | [diff] [blame] | 426 | }, |
Kuninori Morimoto | deae7b8 | 2009-01-05 16:25:16 +0900 | [diff] [blame] | 427 | { |
| 428 | I2C_BOARD_INFO("tw9910", 0x45), |
Kuninori Morimoto | deae7b8 | 2009-01-05 16:25:16 +0900 | [diff] [blame] | 429 | }, |
Magnus Damm | 0c6111e | 2008-03-25 17:20:24 +0900 | [diff] [blame] | 430 | }; |
| 431 | |
Guennadi Liakhovetski | 2cb582c | 2009-05-12 15:13:40 +0000 | [diff] [blame] | 432 | static struct ov772x_camera_info ov7725_info = { |
| 433 | .buswidth = SOCAM_DATAWIDTH_8, |
| 434 | .link = { |
| 435 | .power = ov7725_power, |
| 436 | .board_info = &migor_i2c_camera[0], |
| 437 | .i2c_adapter_id = 0, |
| 438 | .module_name = "ov772x", |
| 439 | }, |
| 440 | }; |
| 441 | |
| 442 | static struct tw9910_video_info tw9910_info = { |
| 443 | .buswidth = SOCAM_DATAWIDTH_8, |
| 444 | .mpout = TW9910_MPO_FIELD, |
| 445 | .link = { |
| 446 | .power = tw9910_power, |
| 447 | .board_info = &migor_i2c_camera[1], |
| 448 | .i2c_adapter_id = 0, |
| 449 | .module_name = "tw9910", |
| 450 | } |
| 451 | }; |
| 452 | |
| 453 | static struct platform_device migor_camera[] = { |
| 454 | { |
| 455 | .name = "soc-camera-pdrv", |
| 456 | .id = 0, |
| 457 | .dev = { |
| 458 | .platform_data = &ov7725_info.link, |
| 459 | }, |
| 460 | }, { |
| 461 | .name = "soc-camera-pdrv", |
| 462 | .id = 1, |
| 463 | .dev = { |
| 464 | .platform_data = &tw9910_info.link, |
| 465 | }, |
| 466 | }, |
| 467 | }; |
| 468 | |
| 469 | static struct platform_device *migor_devices[] __initdata = { |
| 470 | &smc91x_eth_device, |
| 471 | &sh_keysc_device, |
| 472 | &migor_lcdc_device, |
| 473 | &migor_ceu_device, |
| 474 | &migor_nor_flash_device, |
| 475 | &migor_nand_flash_device, |
Magnus Damm | 2e3fc56 | 2009-10-02 02:22:43 +0000 | [diff] [blame] | 476 | &sdhi_cn9_device, |
Guennadi Liakhovetski | 2cb582c | 2009-05-12 15:13:40 +0000 | [diff] [blame] | 477 | &migor_camera[0], |
| 478 | &migor_camera[1], |
| 479 | }; |
| 480 | |
Magnus Damm | 70f784e | 2008-02-07 00:38:24 +0900 | [diff] [blame] | 481 | static int __init migor_devices_setup(void) |
| 482 | { |
Magnus Damm | 5084071 | 2009-03-10 06:13:22 +0000 | [diff] [blame] | 483 | |
| 484 | #ifdef CONFIG_PM |
| 485 | /* Let D11 LED show STATUS0 */ |
| 486 | gpio_request(GPIO_FN_STATUS0, NULL); |
| 487 | |
| 488 | /* Lit D12 LED show PDSTATUS */ |
| 489 | gpio_request(GPIO_FN_PDSTATUS, NULL); |
| 490 | #else |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 491 | /* Lit D11 LED */ |
| 492 | gpio_request(GPIO_PTJ7, NULL); |
| 493 | gpio_direction_output(GPIO_PTJ7, 1); |
| 494 | gpio_export(GPIO_PTJ7, 0); |
| 495 | |
| 496 | /* Lit D12 LED */ |
| 497 | gpio_request(GPIO_PTJ5, NULL); |
| 498 | gpio_direction_output(GPIO_PTJ5, 1); |
| 499 | gpio_export(GPIO_PTJ5, 0); |
Magnus Damm | 5084071 | 2009-03-10 06:13:22 +0000 | [diff] [blame] | 500 | #endif |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 501 | |
Magnus Damm | a30c89a | 2008-10-09 18:41:34 +0900 | [diff] [blame] | 502 | /* SMC91C111 - Enable IRQ0, Setup CS4 for 16-bit fast access */ |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 503 | gpio_request(GPIO_FN_IRQ0, NULL); |
Magnus Damm | a30c89a | 2008-10-09 18:41:34 +0900 | [diff] [blame] | 504 | ctrl_outl(0x00003400, BSC_CS4BCR); |
| 505 | ctrl_outl(0x00110080, BSC_CS4WCR); |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 506 | |
| 507 | /* KEYSC */ |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 508 | gpio_request(GPIO_FN_KEYOUT0, NULL); |
| 509 | gpio_request(GPIO_FN_KEYOUT1, NULL); |
| 510 | gpio_request(GPIO_FN_KEYOUT2, NULL); |
| 511 | gpio_request(GPIO_FN_KEYOUT3, NULL); |
| 512 | gpio_request(GPIO_FN_KEYOUT4_IN6, NULL); |
| 513 | gpio_request(GPIO_FN_KEYIN1, NULL); |
| 514 | gpio_request(GPIO_FN_KEYIN2, NULL); |
| 515 | gpio_request(GPIO_FN_KEYIN3, NULL); |
| 516 | gpio_request(GPIO_FN_KEYIN4, NULL); |
| 517 | gpio_request(GPIO_FN_KEYOUT5_IN5, NULL); |
| 518 | |
| 519 | /* NAND Flash */ |
| 520 | gpio_request(GPIO_FN_CS6A_CE2B, NULL); |
| 521 | ctrl_outl((ctrl_inl(BSC_CS6ABCR) & ~0x0600) | 0x0200, BSC_CS6ABCR); |
| 522 | gpio_request(GPIO_PTA1, NULL); |
| 523 | gpio_direction_input(GPIO_PTA1); |
| 524 | |
Magnus Damm | 2e3fc56 | 2009-10-02 02:22:43 +0000 | [diff] [blame] | 525 | /* SDHI */ |
| 526 | gpio_request(GPIO_FN_SDHICD, NULL); |
| 527 | gpio_request(GPIO_FN_SDHIWP, NULL); |
| 528 | gpio_request(GPIO_FN_SDHID3, NULL); |
| 529 | gpio_request(GPIO_FN_SDHID2, NULL); |
| 530 | gpio_request(GPIO_FN_SDHID1, NULL); |
| 531 | gpio_request(GPIO_FN_SDHID0, NULL); |
| 532 | gpio_request(GPIO_FN_SDHICMD, NULL); |
| 533 | gpio_request(GPIO_FN_SDHICLK, NULL); |
| 534 | |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 535 | /* Touch Panel */ |
| 536 | gpio_request(GPIO_FN_IRQ6, NULL); |
| 537 | |
| 538 | /* LCD Panel */ |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 539 | #ifdef CONFIG_SH_MIGOR_QVGA /* LCDC - QVGA - Enable SYS Interface signals */ |
| 540 | gpio_request(GPIO_FN_LCDD17, NULL); |
| 541 | gpio_request(GPIO_FN_LCDD16, NULL); |
| 542 | gpio_request(GPIO_FN_LCDD15, NULL); |
| 543 | gpio_request(GPIO_FN_LCDD14, NULL); |
| 544 | gpio_request(GPIO_FN_LCDD13, NULL); |
| 545 | gpio_request(GPIO_FN_LCDD12, NULL); |
| 546 | gpio_request(GPIO_FN_LCDD11, NULL); |
| 547 | gpio_request(GPIO_FN_LCDD10, NULL); |
| 548 | gpio_request(GPIO_FN_LCDD8, NULL); |
| 549 | gpio_request(GPIO_FN_LCDD7, NULL); |
| 550 | gpio_request(GPIO_FN_LCDD6, NULL); |
| 551 | gpio_request(GPIO_FN_LCDD5, NULL); |
| 552 | gpio_request(GPIO_FN_LCDD4, NULL); |
| 553 | gpio_request(GPIO_FN_LCDD3, NULL); |
| 554 | gpio_request(GPIO_FN_LCDD2, NULL); |
| 555 | gpio_request(GPIO_FN_LCDD1, NULL); |
| 556 | gpio_request(GPIO_FN_LCDRS, NULL); |
| 557 | gpio_request(GPIO_FN_LCDCS, NULL); |
| 558 | gpio_request(GPIO_FN_LCDRD, NULL); |
| 559 | gpio_request(GPIO_FN_LCDWR, NULL); |
| 560 | gpio_request(GPIO_PTH2, NULL); /* LCD_DON */ |
| 561 | gpio_direction_output(GPIO_PTH2, 1); |
| 562 | #endif |
| 563 | #ifdef CONFIG_SH_MIGOR_RTA_WVGA /* LCDC - WVGA - Enable RGB Interface signals */ |
| 564 | gpio_request(GPIO_FN_LCDD15, NULL); |
| 565 | gpio_request(GPIO_FN_LCDD14, NULL); |
| 566 | gpio_request(GPIO_FN_LCDD13, NULL); |
| 567 | gpio_request(GPIO_FN_LCDD12, NULL); |
| 568 | gpio_request(GPIO_FN_LCDD11, NULL); |
| 569 | gpio_request(GPIO_FN_LCDD10, NULL); |
| 570 | gpio_request(GPIO_FN_LCDD9, NULL); |
| 571 | gpio_request(GPIO_FN_LCDD8, NULL); |
| 572 | gpio_request(GPIO_FN_LCDD7, NULL); |
| 573 | gpio_request(GPIO_FN_LCDD6, NULL); |
| 574 | gpio_request(GPIO_FN_LCDD5, NULL); |
| 575 | gpio_request(GPIO_FN_LCDD4, NULL); |
| 576 | gpio_request(GPIO_FN_LCDD3, NULL); |
| 577 | gpio_request(GPIO_FN_LCDD2, NULL); |
| 578 | gpio_request(GPIO_FN_LCDD1, NULL); |
| 579 | gpio_request(GPIO_FN_LCDD0, NULL); |
| 580 | gpio_request(GPIO_FN_LCDLCLK, NULL); |
| 581 | gpio_request(GPIO_FN_LCDDCK, NULL); |
| 582 | gpio_request(GPIO_FN_LCDVEPWC, NULL); |
| 583 | gpio_request(GPIO_FN_LCDVCPWC, NULL); |
| 584 | gpio_request(GPIO_FN_LCDVSYN, NULL); |
| 585 | gpio_request(GPIO_FN_LCDHSYN, NULL); |
| 586 | gpio_request(GPIO_FN_LCDDISP, NULL); |
| 587 | gpio_request(GPIO_FN_LCDDON, NULL); |
| 588 | #endif |
| 589 | |
| 590 | /* CEU */ |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 591 | gpio_request(GPIO_FN_VIO_CLK2, NULL); |
| 592 | gpio_request(GPIO_FN_VIO_VD2, NULL); |
| 593 | gpio_request(GPIO_FN_VIO_HD2, NULL); |
| 594 | gpio_request(GPIO_FN_VIO_FLD, NULL); |
| 595 | gpio_request(GPIO_FN_VIO_CKO, NULL); |
| 596 | gpio_request(GPIO_FN_VIO_D15, NULL); |
| 597 | gpio_request(GPIO_FN_VIO_D14, NULL); |
| 598 | gpio_request(GPIO_FN_VIO_D13, NULL); |
| 599 | gpio_request(GPIO_FN_VIO_D12, NULL); |
| 600 | gpio_request(GPIO_FN_VIO_D11, NULL); |
| 601 | gpio_request(GPIO_FN_VIO_D10, NULL); |
| 602 | gpio_request(GPIO_FN_VIO_D9, NULL); |
| 603 | gpio_request(GPIO_FN_VIO_D8, NULL); |
| 604 | |
| 605 | gpio_request(GPIO_PTT3, NULL); /* VIO_RST */ |
| 606 | gpio_direction_output(GPIO_PTT3, 0); |
| 607 | gpio_request(GPIO_PTT2, NULL); /* TV_IN_EN */ |
| 608 | gpio_direction_output(GPIO_PTT2, 1); |
| 609 | gpio_request(GPIO_PTT0, NULL); /* CAM_EN */ |
| 610 | #ifdef CONFIG_SH_MIGOR_RTA_WVGA |
| 611 | gpio_direction_output(GPIO_PTT0, 0); |
| 612 | #else |
| 613 | gpio_direction_output(GPIO_PTT0, 1); |
| 614 | #endif |
| 615 | ctrl_outw(ctrl_inw(PORT_MSELCRB) | 0x2000, PORT_MSELCRB); /* D15->D8 */ |
Magnus Damm | 1765534 | 2008-07-28 18:51:01 +0900 | [diff] [blame] | 616 | |
| 617 | platform_resource_setup_memory(&migor_ceu_device, "ceu", 4 << 20); |
Magnus Damm | 6c7d826 | 2008-07-17 19:16:11 +0900 | [diff] [blame] | 618 | |
Magnus Damm | 0c6111e | 2008-03-25 17:20:24 +0900 | [diff] [blame] | 619 | i2c_register_board_info(0, migor_i2c_devices, |
| 620 | ARRAY_SIZE(migor_i2c_devices)); |
Magnus Damm | 91b6f3c | 2008-10-08 20:42:01 +0900 | [diff] [blame] | 621 | |
Magnus Damm | 70f784e | 2008-02-07 00:38:24 +0900 | [diff] [blame] | 622 | return platform_add_devices(migor_devices, ARRAY_SIZE(migor_devices)); |
| 623 | } |
Magnus Damm | ba3a170 | 2009-08-13 11:39:02 +0900 | [diff] [blame] | 624 | arch_initcall(migor_devices_setup); |
Magnus Damm | 0ec80fdd | 2009-06-03 08:22:50 +0000 | [diff] [blame] | 625 | |
| 626 | /* Return the board specific boot mode pin configuration */ |
| 627 | static int migor_mode_pins(void) |
| 628 | { |
| 629 | /* MD0=1, MD1=1, MD2=0: Clock Mode 3 |
| 630 | * MD3=0: 16-bit Area0 Bus Width |
| 631 | * MD5=1: Little Endian |
| 632 | * TSTMD=1, MD8=0: Test Mode Disabled |
| 633 | */ |
| 634 | return MODE_PIN0 | MODE_PIN1 | MODE_PIN5; |
| 635 | } |
| 636 | |
| 637 | /* |
| 638 | * The Machine Vector |
| 639 | */ |
| 640 | static struct sh_machine_vector mv_migor __initmv = { |
| 641 | .mv_name = "Migo-R", |
| 642 | .mv_mode_pins = migor_mode_pins, |
| 643 | }; |