Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 Renesas Solutions Corp. |
| 3 | * |
| 4 | * Kuninori Morimoto <morimoto.kuninori@renesas.com> |
| 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 | |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/device.h> |
| 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/mtd/physmap.h> |
| 15 | #include <linux/gpio.h> |
| 16 | #include <linux/interrupt.h> |
Kuninori Morimoto | 35a3540 | 2009-08-26 11:04:26 +0000 | [diff] [blame] | 17 | #include <linux/io.h> |
| 18 | #include <linux/delay.h> |
Kuninori Morimoto | 907050a | 2009-08-26 11:04:31 +0000 | [diff] [blame] | 19 | #include <linux/usb/r8a66597.h> |
Kuninori Morimoto | 4907d57 | 2009-09-10 01:39:58 +0000 | [diff] [blame] | 20 | #include <linux/i2c.h> |
Kuninori Morimoto | e9103e7 | 2009-09-14 11:23:00 +0000 | [diff] [blame] | 21 | #include <linux/input.h> |
Kuninori Morimoto | fa3ba51 | 2009-08-26 11:04:34 +0000 | [diff] [blame] | 22 | #include <video/sh_mobile_lcdc.h> |
Kuninori Morimoto | 2153ad3 | 2009-08-26 11:04:36 +0000 | [diff] [blame] | 23 | #include <media/sh_mobile_ceu.h> |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 24 | #include <asm/heartbeat.h> |
Kuninori Morimoto | 35a3540 | 2009-08-26 11:04:26 +0000 | [diff] [blame] | 25 | #include <asm/sh_eth.h> |
Kuninori Morimoto | e9103e7 | 2009-09-14 11:23:00 +0000 | [diff] [blame] | 26 | #include <asm/sh_keysc.h> |
Kuninori Morimoto | a991801 | 2009-09-14 11:23:16 +0000 | [diff] [blame] | 27 | #include <asm/clock.h> |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 28 | #include <cpu/sh7724.h> |
| 29 | |
| 30 | /* |
Kuninori Morimoto | b7056bc | 2009-08-26 11:04:22 +0000 | [diff] [blame] | 31 | * Address Interface BusWidth |
| 32 | *----------------------------------------- |
| 33 | * 0x0000_0000 uboot 16bit |
| 34 | * 0x0004_0000 Linux romImage 16bit |
| 35 | * 0x0014_0000 MTD for Linux 16bit |
| 36 | * 0x0400_0000 Internal I/O 16/32bit |
| 37 | * 0x0800_0000 DRAM 32bit |
| 38 | * 0x1800_0000 MFI 16bit |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 39 | */ |
| 40 | |
| 41 | /* Heartbeat */ |
| 42 | static unsigned char led_pos[] = { 0, 1, 2, 3 }; |
| 43 | static struct heartbeat_data heartbeat_data = { |
| 44 | .regsize = 8, |
| 45 | .nr_bits = 4, |
| 46 | .bit_pos = led_pos, |
| 47 | }; |
| 48 | |
| 49 | static struct resource heartbeat_resources[] = { |
| 50 | [0] = { |
| 51 | .start = 0xA405012C, /* PTG */ |
| 52 | .end = 0xA405012E - 1, |
| 53 | .flags = IORESOURCE_MEM, |
| 54 | }, |
| 55 | }; |
| 56 | |
| 57 | static struct platform_device heartbeat_device = { |
| 58 | .name = "heartbeat", |
| 59 | .id = -1, |
| 60 | .dev = { |
| 61 | .platform_data = &heartbeat_data, |
| 62 | }, |
| 63 | .num_resources = ARRAY_SIZE(heartbeat_resources), |
| 64 | .resource = heartbeat_resources, |
| 65 | }; |
| 66 | |
| 67 | /* MTD */ |
| 68 | static struct mtd_partition nor_flash_partitions[] = { |
| 69 | { |
Kuninori Morimoto | b7056bc | 2009-08-26 11:04:22 +0000 | [diff] [blame] | 70 | .name = "boot loader", |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 71 | .offset = 0, |
Kuninori Morimoto | b7056bc | 2009-08-26 11:04:22 +0000 | [diff] [blame] | 72 | .size = (5 * 1024 * 1024), |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 73 | .mask_flags = MTD_CAP_ROM, |
| 74 | }, { |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 75 | .name = "free-area", |
| 76 | .offset = MTDPART_OFS_APPEND, |
| 77 | .size = MTDPART_SIZ_FULL, |
| 78 | }, |
| 79 | }; |
| 80 | |
| 81 | static struct physmap_flash_data nor_flash_data = { |
| 82 | .width = 2, |
| 83 | .parts = nor_flash_partitions, |
| 84 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), |
| 85 | }; |
| 86 | |
| 87 | static struct resource nor_flash_resources[] = { |
| 88 | [0] = { |
| 89 | .name = "NOR Flash", |
| 90 | .start = 0x00000000, |
| 91 | .end = 0x03ffffff, |
| 92 | .flags = IORESOURCE_MEM, |
| 93 | } |
| 94 | }; |
| 95 | |
| 96 | static struct platform_device nor_flash_device = { |
| 97 | .name = "physmap-flash", |
| 98 | .resource = nor_flash_resources, |
| 99 | .num_resources = ARRAY_SIZE(nor_flash_resources), |
| 100 | .dev = { |
| 101 | .platform_data = &nor_flash_data, |
| 102 | }, |
| 103 | }; |
| 104 | |
Kuninori Morimoto | 35a3540 | 2009-08-26 11:04:26 +0000 | [diff] [blame] | 105 | /* SH Eth */ |
| 106 | #define SH_ETH_ADDR (0xA4600000) |
| 107 | #define SH_ETH_MAHR (SH_ETH_ADDR + 0x1C0) |
| 108 | #define SH_ETH_MALR (SH_ETH_ADDR + 0x1C8) |
| 109 | static struct resource sh_eth_resources[] = { |
| 110 | [0] = { |
| 111 | .start = SH_ETH_ADDR, |
| 112 | .end = SH_ETH_ADDR + 0x1FC, |
| 113 | .flags = IORESOURCE_MEM, |
| 114 | }, |
| 115 | [1] = { |
| 116 | .start = 91, |
| 117 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, |
| 118 | }, |
| 119 | }; |
| 120 | |
| 121 | struct sh_eth_plat_data sh_eth_plat = { |
| 122 | .phy = 0x1f, /* SMSC LAN8700 */ |
| 123 | .edmac_endian = EDMAC_LITTLE_ENDIAN, |
Kuninori Morimoto | acf3cc2 | 2009-09-24 06:28:27 +0000 | [diff] [blame] | 124 | .ether_link_active_low = 1 |
Kuninori Morimoto | 35a3540 | 2009-08-26 11:04:26 +0000 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | static struct platform_device sh_eth_device = { |
| 128 | .name = "sh-eth", |
| 129 | .id = 0, |
| 130 | .dev = { |
| 131 | .platform_data = &sh_eth_plat, |
| 132 | }, |
| 133 | .num_resources = ARRAY_SIZE(sh_eth_resources), |
| 134 | .resource = sh_eth_resources, |
| 135 | }; |
| 136 | |
Kuninori Morimoto | 907050a | 2009-08-26 11:04:31 +0000 | [diff] [blame] | 137 | /* USB0 host */ |
| 138 | void usb0_port_power(int port, int power) |
| 139 | { |
| 140 | gpio_set_value(GPIO_PTB4, power); |
| 141 | } |
| 142 | |
| 143 | static struct r8a66597_platdata usb0_host_data = { |
| 144 | .on_chip = 1, |
| 145 | .port_power = usb0_port_power, |
| 146 | }; |
| 147 | |
| 148 | static struct resource usb0_host_resources[] = { |
| 149 | [0] = { |
| 150 | .start = 0xa4d80000, |
| 151 | .end = 0xa4d80124 - 1, |
| 152 | .flags = IORESOURCE_MEM, |
| 153 | }, |
| 154 | [1] = { |
| 155 | .start = 65, |
| 156 | .end = 65, |
| 157 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW, |
| 158 | }, |
| 159 | }; |
| 160 | |
| 161 | static struct platform_device usb0_host_device = { |
| 162 | .name = "r8a66597_hcd", |
| 163 | .id = 0, |
| 164 | .dev = { |
| 165 | .dma_mask = NULL, /* not use dma */ |
| 166 | .coherent_dma_mask = 0xffffffff, |
| 167 | .platform_data = &usb0_host_data, |
| 168 | }, |
| 169 | .num_resources = ARRAY_SIZE(usb0_host_resources), |
| 170 | .resource = usb0_host_resources, |
| 171 | }; |
| 172 | |
| 173 | /* |
| 174 | * USB1 |
| 175 | * |
| 176 | * CN5 can use both host/function, |
| 177 | * and we can determine it by checking PTB[3] |
| 178 | * |
| 179 | * This time only USB1 host is supported. |
| 180 | */ |
| 181 | void usb1_port_power(int port, int power) |
| 182 | { |
| 183 | if (!gpio_get_value(GPIO_PTB3)) { |
| 184 | printk(KERN_ERR "USB1 function is not supported\n"); |
| 185 | return; |
| 186 | } |
| 187 | |
| 188 | gpio_set_value(GPIO_PTB5, power); |
| 189 | } |
| 190 | |
| 191 | static struct r8a66597_platdata usb1_host_data = { |
| 192 | .on_chip = 1, |
| 193 | .port_power = usb1_port_power, |
| 194 | }; |
| 195 | |
| 196 | static struct resource usb1_host_resources[] = { |
| 197 | [0] = { |
| 198 | .start = 0xa4d90000, |
| 199 | .end = 0xa4d90124 - 1, |
| 200 | .flags = IORESOURCE_MEM, |
| 201 | }, |
| 202 | [1] = { |
| 203 | .start = 66, |
| 204 | .end = 66, |
| 205 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW, |
| 206 | }, |
| 207 | }; |
| 208 | |
| 209 | static struct platform_device usb1_host_device = { |
| 210 | .name = "r8a66597_hcd", |
| 211 | .id = 1, |
| 212 | .dev = { |
| 213 | .dma_mask = NULL, /* not use dma */ |
| 214 | .coherent_dma_mask = 0xffffffff, |
| 215 | .platform_data = &usb1_host_data, |
| 216 | }, |
| 217 | .num_resources = ARRAY_SIZE(usb1_host_resources), |
| 218 | .resource = usb1_host_resources, |
| 219 | }; |
| 220 | |
Kuninori Morimoto | fa3ba51 | 2009-08-26 11:04:34 +0000 | [diff] [blame] | 221 | /* LCDC */ |
| 222 | static struct sh_mobile_lcdc_info lcdc_info = { |
| 223 | .ch[0] = { |
| 224 | .interface_type = RGB18, |
| 225 | .chan = LCDC_CHAN_MAINLCD, |
| 226 | .bpp = 16, |
Kuninori Morimoto | fa3ba51 | 2009-08-26 11:04:34 +0000 | [diff] [blame] | 227 | .lcd_cfg = { |
| 228 | .sync = 0, /* hsync and vsync are active low */ |
| 229 | }, |
| 230 | .lcd_size_cfg = { /* 7.0 inch */ |
| 231 | .width = 152, |
| 232 | .height = 91, |
| 233 | }, |
| 234 | .board_cfg = { |
| 235 | }, |
| 236 | } |
| 237 | }; |
| 238 | |
| 239 | static struct resource lcdc_resources[] = { |
| 240 | [0] = { |
| 241 | .name = "LCDC", |
| 242 | .start = 0xfe940000, |
Phil Edworthy | a6f15ad | 2009-09-15 12:00:30 +0000 | [diff] [blame] | 243 | .end = 0xfe942fff, |
Kuninori Morimoto | fa3ba51 | 2009-08-26 11:04:34 +0000 | [diff] [blame] | 244 | .flags = IORESOURCE_MEM, |
| 245 | }, |
| 246 | [1] = { |
| 247 | .start = 106, |
| 248 | .flags = IORESOURCE_IRQ, |
| 249 | }, |
| 250 | }; |
| 251 | |
| 252 | static struct platform_device lcdc_device = { |
| 253 | .name = "sh_mobile_lcdc_fb", |
| 254 | .num_resources = ARRAY_SIZE(lcdc_resources), |
| 255 | .resource = lcdc_resources, |
| 256 | .dev = { |
| 257 | .platform_data = &lcdc_info, |
| 258 | }, |
| 259 | .archdata = { |
| 260 | .hwblk_id = HWBLK_LCDC, |
| 261 | }, |
| 262 | }; |
| 263 | |
Kuninori Morimoto | 2153ad3 | 2009-08-26 11:04:36 +0000 | [diff] [blame] | 264 | /* CEU0 */ |
| 265 | static struct sh_mobile_ceu_info sh_mobile_ceu0_info = { |
| 266 | .flags = SH_CEU_FLAG_USE_8BIT_BUS, |
| 267 | }; |
| 268 | |
| 269 | static struct resource ceu0_resources[] = { |
| 270 | [0] = { |
| 271 | .name = "CEU0", |
| 272 | .start = 0xfe910000, |
| 273 | .end = 0xfe91009f, |
| 274 | .flags = IORESOURCE_MEM, |
| 275 | }, |
| 276 | [1] = { |
| 277 | .start = 52, |
| 278 | .flags = IORESOURCE_IRQ, |
| 279 | }, |
| 280 | [2] = { |
| 281 | /* place holder for contiguous memory */ |
| 282 | }, |
| 283 | }; |
| 284 | |
| 285 | static struct platform_device ceu0_device = { |
| 286 | .name = "sh_mobile_ceu", |
| 287 | .id = 0, /* "ceu0" clock */ |
| 288 | .num_resources = ARRAY_SIZE(ceu0_resources), |
| 289 | .resource = ceu0_resources, |
| 290 | .dev = { |
| 291 | .platform_data = &sh_mobile_ceu0_info, |
| 292 | }, |
| 293 | .archdata = { |
| 294 | .hwblk_id = HWBLK_CEU0, |
| 295 | }, |
| 296 | }; |
| 297 | |
| 298 | /* CEU1 */ |
| 299 | static struct sh_mobile_ceu_info sh_mobile_ceu1_info = { |
| 300 | .flags = SH_CEU_FLAG_USE_8BIT_BUS, |
| 301 | }; |
| 302 | |
| 303 | static struct resource ceu1_resources[] = { |
| 304 | [0] = { |
| 305 | .name = "CEU1", |
| 306 | .start = 0xfe914000, |
| 307 | .end = 0xfe91409f, |
| 308 | .flags = IORESOURCE_MEM, |
| 309 | }, |
| 310 | [1] = { |
| 311 | .start = 63, |
| 312 | .flags = IORESOURCE_IRQ, |
| 313 | }, |
| 314 | [2] = { |
| 315 | /* place holder for contiguous memory */ |
| 316 | }, |
| 317 | }; |
| 318 | |
| 319 | static struct platform_device ceu1_device = { |
| 320 | .name = "sh_mobile_ceu", |
| 321 | .id = 1, /* "ceu1" clock */ |
| 322 | .num_resources = ARRAY_SIZE(ceu1_resources), |
| 323 | .resource = ceu1_resources, |
| 324 | .dev = { |
| 325 | .platform_data = &sh_mobile_ceu1_info, |
| 326 | }, |
| 327 | .archdata = { |
| 328 | .hwblk_id = HWBLK_CEU1, |
| 329 | }, |
| 330 | }; |
| 331 | |
Kuninori Morimoto | 125ecce | 2009-09-10 01:39:37 +0000 | [diff] [blame] | 332 | /* I2C device */ |
| 333 | static struct i2c_board_info i2c1_devices[] = { |
| 334 | { |
| 335 | I2C_BOARD_INFO("r2025sd", 0x32), |
| 336 | }, |
| 337 | }; |
| 338 | |
Kuninori Morimoto | e9103e7 | 2009-09-14 11:23:00 +0000 | [diff] [blame] | 339 | /* KEYSC */ |
| 340 | static struct sh_keysc_info keysc_info = { |
| 341 | .mode = SH_KEYSC_MODE_1, |
| 342 | .scan_timing = 3, |
| 343 | .delay = 50, |
| 344 | .kycr2_delay = 100, |
| 345 | .keycodes = { KEY_1, 0, 0, 0, 0, |
| 346 | KEY_2, 0, 0, 0, 0, |
| 347 | KEY_3, 0, 0, 0, 0, |
| 348 | KEY_4, 0, 0, 0, 0, |
| 349 | KEY_5, 0, 0, 0, 0, |
| 350 | KEY_6, 0, 0, 0, 0, }, |
| 351 | }; |
| 352 | |
| 353 | static struct resource keysc_resources[] = { |
| 354 | [0] = { |
| 355 | .name = "KEYSC", |
| 356 | .start = 0x044b0000, |
| 357 | .end = 0x044b000f, |
| 358 | .flags = IORESOURCE_MEM, |
| 359 | }, |
| 360 | [1] = { |
| 361 | .start = 79, |
| 362 | .flags = IORESOURCE_IRQ, |
| 363 | }, |
| 364 | }; |
| 365 | |
| 366 | static struct platform_device keysc_device = { |
| 367 | .name = "sh_keysc", |
| 368 | .id = 0, /* keysc0 clock */ |
| 369 | .num_resources = ARRAY_SIZE(keysc_resources), |
| 370 | .resource = keysc_resources, |
| 371 | .dev = { |
| 372 | .platform_data = &keysc_info, |
| 373 | }, |
| 374 | .archdata = { |
| 375 | .hwblk_id = HWBLK_KEYSC, |
| 376 | }, |
| 377 | }; |
| 378 | |
Kuninori Morimoto | 96987d9 | 2009-10-02 07:54:42 +0000 | [diff] [blame^] | 379 | /* SHDI0 */ |
| 380 | static struct resource sdhi0_resources[] = { |
| 381 | [0] = { |
| 382 | .name = "SDHI0", |
| 383 | .start = 0x04ce0000, |
| 384 | .end = 0x04ce01ff, |
| 385 | .flags = IORESOURCE_MEM, |
| 386 | }, |
| 387 | [1] = { |
| 388 | .start = 101, |
| 389 | .flags = IORESOURCE_IRQ, |
| 390 | }, |
| 391 | }; |
| 392 | |
| 393 | static struct platform_device sdhi0_device = { |
| 394 | .name = "sh_mobile_sdhi", |
| 395 | .num_resources = ARRAY_SIZE(sdhi0_resources), |
| 396 | .resource = sdhi0_resources, |
| 397 | .id = 0, |
| 398 | .archdata = { |
| 399 | .hwblk_id = HWBLK_SDHI0, |
| 400 | }, |
| 401 | }; |
| 402 | |
| 403 | /* SHDI1 */ |
| 404 | static struct resource sdhi1_resources[] = { |
| 405 | [0] = { |
| 406 | .name = "SDHI1", |
| 407 | .start = 0x04cf0000, |
| 408 | .end = 0x04cf01ff, |
| 409 | .flags = IORESOURCE_MEM, |
| 410 | }, |
| 411 | [1] = { |
| 412 | .start = 24, |
| 413 | .flags = IORESOURCE_IRQ, |
| 414 | }, |
| 415 | }; |
| 416 | |
| 417 | static struct platform_device sdhi1_device = { |
| 418 | .name = "sh_mobile_sdhi", |
| 419 | .num_resources = ARRAY_SIZE(sdhi1_resources), |
| 420 | .resource = sdhi1_resources, |
| 421 | .id = 1, |
| 422 | .archdata = { |
| 423 | .hwblk_id = HWBLK_SDHI1, |
| 424 | }, |
| 425 | }; |
| 426 | |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 427 | static struct platform_device *ecovec_devices[] __initdata = { |
| 428 | &heartbeat_device, |
| 429 | &nor_flash_device, |
Kuninori Morimoto | 35a3540 | 2009-08-26 11:04:26 +0000 | [diff] [blame] | 430 | &sh_eth_device, |
Kuninori Morimoto | 907050a | 2009-08-26 11:04:31 +0000 | [diff] [blame] | 431 | &usb0_host_device, |
| 432 | &usb1_host_device, /* USB1 host support */ |
Kuninori Morimoto | fa3ba51 | 2009-08-26 11:04:34 +0000 | [diff] [blame] | 433 | &lcdc_device, |
Kuninori Morimoto | 2153ad3 | 2009-08-26 11:04:36 +0000 | [diff] [blame] | 434 | &ceu0_device, |
| 435 | &ceu1_device, |
Kuninori Morimoto | e9103e7 | 2009-09-14 11:23:00 +0000 | [diff] [blame] | 436 | &keysc_device, |
Kuninori Morimoto | 96987d9 | 2009-10-02 07:54:42 +0000 | [diff] [blame^] | 437 | &sdhi0_device, |
| 438 | &sdhi1_device, |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 439 | }; |
| 440 | |
Kuninori Morimoto | 4907d57 | 2009-09-10 01:39:58 +0000 | [diff] [blame] | 441 | #define EEPROM_ADDR 0x50 |
| 442 | static u8 mac_read(struct i2c_adapter *a, u8 command) |
| 443 | { |
| 444 | struct i2c_msg msg[2]; |
| 445 | u8 buf; |
| 446 | int ret; |
| 447 | |
| 448 | msg[0].addr = EEPROM_ADDR; |
| 449 | msg[0].flags = 0; |
| 450 | msg[0].len = 1; |
| 451 | msg[0].buf = &command; |
| 452 | |
| 453 | msg[1].addr = EEPROM_ADDR; |
| 454 | msg[1].flags = I2C_M_RD; |
| 455 | msg[1].len = 1; |
| 456 | msg[1].buf = &buf; |
| 457 | |
| 458 | ret = i2c_transfer(a, msg, 2); |
| 459 | if (ret < 0) { |
| 460 | printk(KERN_ERR "error %d\n", ret); |
| 461 | buf = 0xff; |
| 462 | } |
| 463 | |
| 464 | return buf; |
| 465 | } |
| 466 | |
| 467 | #define MAC_LEN 6 |
| 468 | static void __init sh_eth_init(void) |
| 469 | { |
| 470 | struct i2c_adapter *a = i2c_get_adapter(1); |
| 471 | struct clk *eth_clk; |
| 472 | u8 mac[MAC_LEN]; |
| 473 | int i; |
| 474 | |
| 475 | if (!a) { |
| 476 | pr_err("can not get I2C 1\n"); |
| 477 | return; |
| 478 | } |
| 479 | |
| 480 | eth_clk = clk_get(NULL, "eth0"); |
| 481 | if (!eth_clk) { |
| 482 | pr_err("can not get eth0 clk\n"); |
| 483 | return; |
| 484 | } |
| 485 | |
| 486 | /* read MAC address frome EEPROM */ |
| 487 | for (i = 0; i < MAC_LEN; i++) { |
| 488 | mac[i] = mac_read(a, 0x10 + i); |
| 489 | msleep(10); |
| 490 | } |
| 491 | |
| 492 | /* clock enable */ |
| 493 | clk_enable(eth_clk); |
| 494 | |
| 495 | /* reset sh-eth */ |
| 496 | ctrl_outl(0x1, SH_ETH_ADDR + 0x0); |
| 497 | |
| 498 | /* set MAC addr */ |
| 499 | ctrl_outl((mac[0] << 24) | |
| 500 | (mac[1] << 16) | |
| 501 | (mac[2] << 8) | |
| 502 | (mac[3] << 0), SH_ETH_MAHR); |
| 503 | ctrl_outl((mac[4] << 8) | |
| 504 | (mac[5] << 0), SH_ETH_MALR); |
| 505 | |
| 506 | clk_put(eth_clk); |
| 507 | } |
| 508 | |
Kuninori Morimoto | fa3ba51 | 2009-08-26 11:04:34 +0000 | [diff] [blame] | 509 | #define PORT_HIZA 0xA4050158 |
Kuninori Morimoto | ea15edb | 2009-08-26 11:04:39 +0000 | [diff] [blame] | 510 | #define IODRIVEA 0xA405018A |
Kuninori Morimoto | 4907d57 | 2009-09-10 01:39:58 +0000 | [diff] [blame] | 511 | static int __init arch_setup(void) |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 512 | { |
| 513 | /* enable SCIFA0 */ |
| 514 | gpio_request(GPIO_FN_SCIF0_TXD, NULL); |
| 515 | gpio_request(GPIO_FN_SCIF0_RXD, NULL); |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 516 | |
| 517 | /* enable debug LED */ |
| 518 | gpio_request(GPIO_PTG0, NULL); |
| 519 | gpio_request(GPIO_PTG1, NULL); |
| 520 | gpio_request(GPIO_PTG2, NULL); |
| 521 | gpio_request(GPIO_PTG3, NULL); |
Kuninori Morimoto | b7056bc | 2009-08-26 11:04:22 +0000 | [diff] [blame] | 522 | gpio_direction_output(GPIO_PTG0, 0); |
| 523 | gpio_direction_output(GPIO_PTG1, 0); |
| 524 | gpio_direction_output(GPIO_PTG2, 0); |
| 525 | gpio_direction_output(GPIO_PTG3, 0); |
Kuninori Morimoto | 643e9d1 | 2009-09-10 01:40:00 +0000 | [diff] [blame] | 526 | ctrl_outw((ctrl_inw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA); |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 527 | |
Kuninori Morimoto | 35a3540 | 2009-08-26 11:04:26 +0000 | [diff] [blame] | 528 | /* enable SH-Eth */ |
| 529 | gpio_request(GPIO_PTA1, NULL); |
| 530 | gpio_direction_output(GPIO_PTA1, 1); |
| 531 | mdelay(20); |
| 532 | |
| 533 | gpio_request(GPIO_FN_RMII_RXD0, NULL); |
| 534 | gpio_request(GPIO_FN_RMII_RXD1, NULL); |
| 535 | gpio_request(GPIO_FN_RMII_TXD0, NULL); |
| 536 | gpio_request(GPIO_FN_RMII_TXD1, NULL); |
| 537 | gpio_request(GPIO_FN_RMII_REF_CLK, NULL); |
| 538 | gpio_request(GPIO_FN_RMII_TX_EN, NULL); |
| 539 | gpio_request(GPIO_FN_RMII_RX_ER, NULL); |
| 540 | gpio_request(GPIO_FN_RMII_CRS_DV, NULL); |
| 541 | gpio_request(GPIO_FN_MDIO, NULL); |
| 542 | gpio_request(GPIO_FN_MDC, NULL); |
| 543 | gpio_request(GPIO_FN_LNKSTA, NULL); |
| 544 | |
Kuninori Morimoto | 907050a | 2009-08-26 11:04:31 +0000 | [diff] [blame] | 545 | /* enable USB */ |
Kuninori Morimoto | be4ebf9 | 2009-09-10 01:39:55 +0000 | [diff] [blame] | 546 | ctrl_outw(0x0000, 0xA4D80000); |
Kuninori Morimoto | 147df2d | 2009-09-14 11:22:31 +0000 | [diff] [blame] | 547 | ctrl_outw(0x0000, 0xA4D90000); |
Kuninori Morimoto | 907050a | 2009-08-26 11:04:31 +0000 | [diff] [blame] | 548 | gpio_request(GPIO_PTB3, NULL); |
| 549 | gpio_request(GPIO_PTB4, NULL); |
| 550 | gpio_request(GPIO_PTB5, NULL); |
| 551 | gpio_direction_input(GPIO_PTB3); |
| 552 | gpio_direction_output(GPIO_PTB4, 0); |
| 553 | gpio_direction_output(GPIO_PTB5, 0); |
| 554 | ctrl_outw(0x0600, 0xa40501d4); |
| 555 | ctrl_outw(0x0600, 0xa4050192); |
| 556 | |
Kuninori Morimoto | fa3ba51 | 2009-08-26 11:04:34 +0000 | [diff] [blame] | 557 | /* enable LCDC */ |
| 558 | gpio_request(GPIO_FN_LCDD23, NULL); |
| 559 | gpio_request(GPIO_FN_LCDD22, NULL); |
| 560 | gpio_request(GPIO_FN_LCDD21, NULL); |
| 561 | gpio_request(GPIO_FN_LCDD20, NULL); |
| 562 | gpio_request(GPIO_FN_LCDD19, NULL); |
| 563 | gpio_request(GPIO_FN_LCDD18, NULL); |
| 564 | gpio_request(GPIO_FN_LCDD17, NULL); |
| 565 | gpio_request(GPIO_FN_LCDD16, NULL); |
| 566 | gpio_request(GPIO_FN_LCDD15, NULL); |
| 567 | gpio_request(GPIO_FN_LCDD14, NULL); |
| 568 | gpio_request(GPIO_FN_LCDD13, NULL); |
| 569 | gpio_request(GPIO_FN_LCDD12, NULL); |
| 570 | gpio_request(GPIO_FN_LCDD11, NULL); |
| 571 | gpio_request(GPIO_FN_LCDD10, NULL); |
| 572 | gpio_request(GPIO_FN_LCDD9, NULL); |
| 573 | gpio_request(GPIO_FN_LCDD8, NULL); |
| 574 | gpio_request(GPIO_FN_LCDD7, NULL); |
| 575 | gpio_request(GPIO_FN_LCDD6, NULL); |
| 576 | gpio_request(GPIO_FN_LCDD5, NULL); |
| 577 | gpio_request(GPIO_FN_LCDD4, NULL); |
| 578 | gpio_request(GPIO_FN_LCDD3, NULL); |
| 579 | gpio_request(GPIO_FN_LCDD2, NULL); |
| 580 | gpio_request(GPIO_FN_LCDD1, NULL); |
| 581 | gpio_request(GPIO_FN_LCDD0, NULL); |
| 582 | gpio_request(GPIO_FN_LCDDISP, NULL); |
| 583 | gpio_request(GPIO_FN_LCDHSYN, NULL); |
| 584 | gpio_request(GPIO_FN_LCDDCK, NULL); |
| 585 | gpio_request(GPIO_FN_LCDVSYN, NULL); |
| 586 | gpio_request(GPIO_FN_LCDDON, NULL); |
| 587 | gpio_request(GPIO_FN_LCDLCLK, NULL); |
| 588 | ctrl_outw((ctrl_inw(PORT_HIZA) & ~0x0001), PORT_HIZA); |
| 589 | |
| 590 | gpio_request(GPIO_PTE6, NULL); |
| 591 | gpio_request(GPIO_PTU1, NULL); |
| 592 | gpio_request(GPIO_PTR1, NULL); |
| 593 | gpio_request(GPIO_PTA2, NULL); |
| 594 | gpio_direction_input(GPIO_PTE6); |
| 595 | gpio_direction_output(GPIO_PTU1, 0); |
| 596 | gpio_direction_output(GPIO_PTR1, 0); |
| 597 | gpio_direction_output(GPIO_PTA2, 0); |
| 598 | |
Kuninori Morimoto | ea15edb | 2009-08-26 11:04:39 +0000 | [diff] [blame] | 599 | /* I/O buffer drive ability is low */ |
| 600 | ctrl_outw((ctrl_inw(IODRIVEA) & ~0x00c0) | 0x0040 , IODRIVEA); |
| 601 | |
Kuninori Morimoto | fa3ba51 | 2009-08-26 11:04:34 +0000 | [diff] [blame] | 602 | if (gpio_get_value(GPIO_PTE6)) { |
| 603 | /* DVI */ |
| 604 | lcdc_info.clock_source = LCDC_CLK_EXTERNAL; |
Kuninori Morimoto | ea15edb | 2009-08-26 11:04:39 +0000 | [diff] [blame] | 605 | lcdc_info.ch[0].clock_divider = 1, |
Kuninori Morimoto | fa3ba51 | 2009-08-26 11:04:34 +0000 | [diff] [blame] | 606 | lcdc_info.ch[0].lcd_cfg.name = "DVI"; |
| 607 | lcdc_info.ch[0].lcd_cfg.xres = 1280; |
| 608 | lcdc_info.ch[0].lcd_cfg.yres = 720; |
| 609 | lcdc_info.ch[0].lcd_cfg.left_margin = 220; |
| 610 | lcdc_info.ch[0].lcd_cfg.right_margin = 110; |
| 611 | lcdc_info.ch[0].lcd_cfg.hsync_len = 40; |
| 612 | lcdc_info.ch[0].lcd_cfg.upper_margin = 20; |
| 613 | lcdc_info.ch[0].lcd_cfg.lower_margin = 5; |
| 614 | lcdc_info.ch[0].lcd_cfg.vsync_len = 5; |
| 615 | |
| 616 | gpio_set_value(GPIO_PTA2, 1); |
| 617 | gpio_set_value(GPIO_PTU1, 1); |
| 618 | } else { |
| 619 | /* Panel */ |
Kuninori Morimoto | ea15edb | 2009-08-26 11:04:39 +0000 | [diff] [blame] | 620 | |
| 621 | lcdc_info.clock_source = LCDC_CLK_PERIPHERAL; |
| 622 | lcdc_info.ch[0].clock_divider = 2, |
| 623 | lcdc_info.ch[0].lcd_cfg.name = "Panel"; |
| 624 | lcdc_info.ch[0].lcd_cfg.xres = 800; |
| 625 | lcdc_info.ch[0].lcd_cfg.yres = 480; |
| 626 | lcdc_info.ch[0].lcd_cfg.left_margin = 220; |
| 627 | lcdc_info.ch[0].lcd_cfg.right_margin = 110; |
| 628 | lcdc_info.ch[0].lcd_cfg.hsync_len = 70; |
| 629 | lcdc_info.ch[0].lcd_cfg.upper_margin = 20; |
| 630 | lcdc_info.ch[0].lcd_cfg.lower_margin = 5; |
| 631 | lcdc_info.ch[0].lcd_cfg.vsync_len = 5; |
| 632 | |
| 633 | gpio_set_value(GPIO_PTR1, 1); |
| 634 | |
| 635 | /* FIXME |
| 636 | * |
| 637 | * LCDDON control is needed for Panel, |
| 638 | * but current sh_mobile_lcdc driver doesn't control it. |
| 639 | * It is temporary correspondence |
| 640 | */ |
| 641 | gpio_request(GPIO_PTF4, NULL); |
| 642 | gpio_direction_output(GPIO_PTF4, 1); |
Kuninori Morimoto | fa3ba51 | 2009-08-26 11:04:34 +0000 | [diff] [blame] | 643 | } |
| 644 | |
Kuninori Morimoto | 2153ad3 | 2009-08-26 11:04:36 +0000 | [diff] [blame] | 645 | /* enable CEU0 */ |
| 646 | gpio_request(GPIO_FN_VIO0_D15, NULL); |
| 647 | gpio_request(GPIO_FN_VIO0_D14, NULL); |
| 648 | gpio_request(GPIO_FN_VIO0_D13, NULL); |
| 649 | gpio_request(GPIO_FN_VIO0_D12, NULL); |
| 650 | gpio_request(GPIO_FN_VIO0_D11, NULL); |
| 651 | gpio_request(GPIO_FN_VIO0_D10, NULL); |
| 652 | gpio_request(GPIO_FN_VIO0_D9, NULL); |
| 653 | gpio_request(GPIO_FN_VIO0_D8, NULL); |
| 654 | gpio_request(GPIO_FN_VIO0_D7, NULL); |
| 655 | gpio_request(GPIO_FN_VIO0_D6, NULL); |
| 656 | gpio_request(GPIO_FN_VIO0_D5, NULL); |
| 657 | gpio_request(GPIO_FN_VIO0_D4, NULL); |
| 658 | gpio_request(GPIO_FN_VIO0_D3, NULL); |
| 659 | gpio_request(GPIO_FN_VIO0_D2, NULL); |
| 660 | gpio_request(GPIO_FN_VIO0_D1, NULL); |
| 661 | gpio_request(GPIO_FN_VIO0_D0, NULL); |
| 662 | gpio_request(GPIO_FN_VIO0_VD, NULL); |
| 663 | gpio_request(GPIO_FN_VIO0_CLK, NULL); |
| 664 | gpio_request(GPIO_FN_VIO0_FLD, NULL); |
| 665 | gpio_request(GPIO_FN_VIO0_HD, NULL); |
| 666 | platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20); |
| 667 | |
| 668 | /* enable CEU1 */ |
| 669 | gpio_request(GPIO_FN_VIO1_D7, NULL); |
| 670 | gpio_request(GPIO_FN_VIO1_D6, NULL); |
| 671 | gpio_request(GPIO_FN_VIO1_D5, NULL); |
| 672 | gpio_request(GPIO_FN_VIO1_D4, NULL); |
| 673 | gpio_request(GPIO_FN_VIO1_D3, NULL); |
| 674 | gpio_request(GPIO_FN_VIO1_D2, NULL); |
| 675 | gpio_request(GPIO_FN_VIO1_D1, NULL); |
| 676 | gpio_request(GPIO_FN_VIO1_D0, NULL); |
| 677 | gpio_request(GPIO_FN_VIO1_FLD, NULL); |
| 678 | gpio_request(GPIO_FN_VIO1_HD, NULL); |
| 679 | gpio_request(GPIO_FN_VIO1_VD, NULL); |
| 680 | gpio_request(GPIO_FN_VIO1_CLK, NULL); |
| 681 | platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20); |
| 682 | |
Kuninori Morimoto | e9103e7 | 2009-09-14 11:23:00 +0000 | [diff] [blame] | 683 | /* enable KEYSC */ |
| 684 | gpio_request(GPIO_FN_KEYOUT5_IN5, NULL); |
| 685 | gpio_request(GPIO_FN_KEYOUT4_IN6, NULL); |
| 686 | gpio_request(GPIO_FN_KEYOUT3, NULL); |
| 687 | gpio_request(GPIO_FN_KEYOUT2, NULL); |
| 688 | gpio_request(GPIO_FN_KEYOUT1, NULL); |
| 689 | gpio_request(GPIO_FN_KEYOUT0, NULL); |
| 690 | gpio_request(GPIO_FN_KEYIN0, NULL); |
| 691 | |
Kuninori Morimoto | 064a16d | 2009-09-16 11:34:34 +0000 | [diff] [blame] | 692 | /* enable user debug switch */ |
| 693 | gpio_request(GPIO_PTR0, NULL); |
| 694 | gpio_request(GPIO_PTR4, NULL); |
| 695 | gpio_request(GPIO_PTR5, NULL); |
| 696 | gpio_request(GPIO_PTR6, NULL); |
| 697 | gpio_direction_input(GPIO_PTR0); |
| 698 | gpio_direction_input(GPIO_PTR4); |
| 699 | gpio_direction_input(GPIO_PTR5); |
| 700 | gpio_direction_input(GPIO_PTR6); |
| 701 | |
Kuninori Morimoto | 96987d9 | 2009-10-02 07:54:42 +0000 | [diff] [blame^] | 702 | /* enable SDHI0 */ |
| 703 | gpio_request(GPIO_FN_SDHI0CD, NULL); |
| 704 | gpio_request(GPIO_FN_SDHI0WP, NULL); |
| 705 | gpio_request(GPIO_FN_SDHI0CMD, NULL); |
| 706 | gpio_request(GPIO_FN_SDHI0CLK, NULL); |
| 707 | gpio_request(GPIO_FN_SDHI0D3, NULL); |
| 708 | gpio_request(GPIO_FN_SDHI0D2, NULL); |
| 709 | gpio_request(GPIO_FN_SDHI0D1, NULL); |
| 710 | gpio_request(GPIO_FN_SDHI0D0, NULL); |
| 711 | |
| 712 | /* enable SDHI1 */ |
| 713 | gpio_request(GPIO_FN_SDHI1CD, NULL); |
| 714 | gpio_request(GPIO_FN_SDHI1WP, NULL); |
| 715 | gpio_request(GPIO_FN_SDHI1CMD, NULL); |
| 716 | gpio_request(GPIO_FN_SDHI1CLK, NULL); |
| 717 | gpio_request(GPIO_FN_SDHI1D3, NULL); |
| 718 | gpio_request(GPIO_FN_SDHI1D2, NULL); |
| 719 | gpio_request(GPIO_FN_SDHI1D1, NULL); |
| 720 | gpio_request(GPIO_FN_SDHI1D0, NULL); |
| 721 | |
| 722 | gpio_request(GPIO_PTB6, NULL); |
| 723 | gpio_request(GPIO_PTB7, NULL); |
| 724 | gpio_direction_output(GPIO_PTB6, 1); |
| 725 | gpio_direction_output(GPIO_PTB7, 1); |
| 726 | |
| 727 | /* I/O buffer drive ability is high for SDHI1 */ |
| 728 | ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA); |
| 729 | |
Kuninori Morimoto | 125ecce | 2009-09-10 01:39:37 +0000 | [diff] [blame] | 730 | /* enable I2C device */ |
| 731 | i2c_register_board_info(1, i2c1_devices, |
| 732 | ARRAY_SIZE(i2c1_devices)); |
| 733 | |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 734 | return platform_add_devices(ecovec_devices, |
| 735 | ARRAY_SIZE(ecovec_devices)); |
| 736 | } |
Kuninori Morimoto | 4907d57 | 2009-09-10 01:39:58 +0000 | [diff] [blame] | 737 | arch_initcall(arch_setup); |
| 738 | |
| 739 | static int __init devices_setup(void) |
| 740 | { |
| 741 | sh_eth_init(); |
| 742 | return 0; |
| 743 | } |
| 744 | device_initcall(devices_setup); |
| 745 | |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 746 | |
| 747 | static struct sh_machine_vector mv_ecovec __initmv = { |
| 748 | .mv_name = "R0P7724 (EcoVec)", |
| 749 | }; |