14138b740SKuninori Morimoto /* 24138b740SKuninori Morimoto * Copyright (C) 2009 Renesas Solutions Corp. 34138b740SKuninori Morimoto * 44138b740SKuninori Morimoto * Kuninori Morimoto <morimoto.kuninori@renesas.com> 54138b740SKuninori Morimoto * 64138b740SKuninori Morimoto * This file is subject to the terms and conditions of the GNU General Public 74138b740SKuninori Morimoto * License. See the file "COPYING" in the main directory of this archive 84138b740SKuninori Morimoto * for more details. 94138b740SKuninori Morimoto */ 104138b740SKuninori Morimoto 114138b740SKuninori Morimoto #include <linux/init.h> 124138b740SKuninori Morimoto #include <linux/device.h> 134138b740SKuninori Morimoto #include <linux/platform_device.h> 144138b740SKuninori Morimoto #include <linux/mtd/physmap.h> 154138b740SKuninori Morimoto #include <linux/gpio.h> 164138b740SKuninori Morimoto #include <linux/interrupt.h> 1735a35408SKuninori Morimoto #include <linux/io.h> 1835a35408SKuninori Morimoto #include <linux/delay.h> 19907050a3SKuninori Morimoto #include <linux/usb/r8a66597.h> 20*4907d57fSKuninori Morimoto #include <linux/i2c.h> 21fa3ba51bSKuninori Morimoto #include <video/sh_mobile_lcdc.h> 222153ad32SKuninori Morimoto #include <media/sh_mobile_ceu.h> 234138b740SKuninori Morimoto #include <asm/heartbeat.h> 2435a35408SKuninori Morimoto #include <asm/sh_eth.h> 254138b740SKuninori Morimoto #include <cpu/sh7724.h> 264138b740SKuninori Morimoto 274138b740SKuninori Morimoto /* 28b7056bc1SKuninori Morimoto * Address Interface BusWidth 29b7056bc1SKuninori Morimoto *----------------------------------------- 30b7056bc1SKuninori Morimoto * 0x0000_0000 uboot 16bit 31b7056bc1SKuninori Morimoto * 0x0004_0000 Linux romImage 16bit 32b7056bc1SKuninori Morimoto * 0x0014_0000 MTD for Linux 16bit 33b7056bc1SKuninori Morimoto * 0x0400_0000 Internal I/O 16/32bit 34b7056bc1SKuninori Morimoto * 0x0800_0000 DRAM 32bit 35b7056bc1SKuninori Morimoto * 0x1800_0000 MFI 16bit 364138b740SKuninori Morimoto */ 374138b740SKuninori Morimoto 384138b740SKuninori Morimoto /* Heartbeat */ 394138b740SKuninori Morimoto static unsigned char led_pos[] = { 0, 1, 2, 3 }; 404138b740SKuninori Morimoto static struct heartbeat_data heartbeat_data = { 414138b740SKuninori Morimoto .regsize = 8, 424138b740SKuninori Morimoto .nr_bits = 4, 434138b740SKuninori Morimoto .bit_pos = led_pos, 444138b740SKuninori Morimoto }; 454138b740SKuninori Morimoto 464138b740SKuninori Morimoto static struct resource heartbeat_resources[] = { 474138b740SKuninori Morimoto [0] = { 484138b740SKuninori Morimoto .start = 0xA405012C, /* PTG */ 494138b740SKuninori Morimoto .end = 0xA405012E - 1, 504138b740SKuninori Morimoto .flags = IORESOURCE_MEM, 514138b740SKuninori Morimoto }, 524138b740SKuninori Morimoto }; 534138b740SKuninori Morimoto 544138b740SKuninori Morimoto static struct platform_device heartbeat_device = { 554138b740SKuninori Morimoto .name = "heartbeat", 564138b740SKuninori Morimoto .id = -1, 574138b740SKuninori Morimoto .dev = { 584138b740SKuninori Morimoto .platform_data = &heartbeat_data, 594138b740SKuninori Morimoto }, 604138b740SKuninori Morimoto .num_resources = ARRAY_SIZE(heartbeat_resources), 614138b740SKuninori Morimoto .resource = heartbeat_resources, 624138b740SKuninori Morimoto }; 634138b740SKuninori Morimoto 644138b740SKuninori Morimoto /* MTD */ 654138b740SKuninori Morimoto static struct mtd_partition nor_flash_partitions[] = { 664138b740SKuninori Morimoto { 67b7056bc1SKuninori Morimoto .name = "boot loader", 684138b740SKuninori Morimoto .offset = 0, 69b7056bc1SKuninori Morimoto .size = (5 * 1024 * 1024), 704138b740SKuninori Morimoto .mask_flags = MTD_CAP_ROM, 714138b740SKuninori Morimoto }, { 724138b740SKuninori Morimoto .name = "free-area", 734138b740SKuninori Morimoto .offset = MTDPART_OFS_APPEND, 744138b740SKuninori Morimoto .size = MTDPART_SIZ_FULL, 754138b740SKuninori Morimoto }, 764138b740SKuninori Morimoto }; 774138b740SKuninori Morimoto 784138b740SKuninori Morimoto static struct physmap_flash_data nor_flash_data = { 794138b740SKuninori Morimoto .width = 2, 804138b740SKuninori Morimoto .parts = nor_flash_partitions, 814138b740SKuninori Morimoto .nr_parts = ARRAY_SIZE(nor_flash_partitions), 824138b740SKuninori Morimoto }; 834138b740SKuninori Morimoto 844138b740SKuninori Morimoto static struct resource nor_flash_resources[] = { 854138b740SKuninori Morimoto [0] = { 864138b740SKuninori Morimoto .name = "NOR Flash", 874138b740SKuninori Morimoto .start = 0x00000000, 884138b740SKuninori Morimoto .end = 0x03ffffff, 894138b740SKuninori Morimoto .flags = IORESOURCE_MEM, 904138b740SKuninori Morimoto } 914138b740SKuninori Morimoto }; 924138b740SKuninori Morimoto 934138b740SKuninori Morimoto static struct platform_device nor_flash_device = { 944138b740SKuninori Morimoto .name = "physmap-flash", 954138b740SKuninori Morimoto .resource = nor_flash_resources, 964138b740SKuninori Morimoto .num_resources = ARRAY_SIZE(nor_flash_resources), 974138b740SKuninori Morimoto .dev = { 984138b740SKuninori Morimoto .platform_data = &nor_flash_data, 994138b740SKuninori Morimoto }, 1004138b740SKuninori Morimoto }; 1014138b740SKuninori Morimoto 10235a35408SKuninori Morimoto /* SH Eth */ 10335a35408SKuninori Morimoto #define SH_ETH_ADDR (0xA4600000) 10435a35408SKuninori Morimoto #define SH_ETH_MAHR (SH_ETH_ADDR + 0x1C0) 10535a35408SKuninori Morimoto #define SH_ETH_MALR (SH_ETH_ADDR + 0x1C8) 10635a35408SKuninori Morimoto static struct resource sh_eth_resources[] = { 10735a35408SKuninori Morimoto [0] = { 10835a35408SKuninori Morimoto .start = SH_ETH_ADDR, 10935a35408SKuninori Morimoto .end = SH_ETH_ADDR + 0x1FC, 11035a35408SKuninori Morimoto .flags = IORESOURCE_MEM, 11135a35408SKuninori Morimoto }, 11235a35408SKuninori Morimoto [1] = { 11335a35408SKuninori Morimoto .start = 91, 11435a35408SKuninori Morimoto .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, 11535a35408SKuninori Morimoto }, 11635a35408SKuninori Morimoto }; 11735a35408SKuninori Morimoto 11835a35408SKuninori Morimoto struct sh_eth_plat_data sh_eth_plat = { 11935a35408SKuninori Morimoto .phy = 0x1f, /* SMSC LAN8700 */ 12035a35408SKuninori Morimoto .edmac_endian = EDMAC_LITTLE_ENDIAN, 12135a35408SKuninori Morimoto }; 12235a35408SKuninori Morimoto 12335a35408SKuninori Morimoto static struct platform_device sh_eth_device = { 12435a35408SKuninori Morimoto .name = "sh-eth", 12535a35408SKuninori Morimoto .id = 0, 12635a35408SKuninori Morimoto .dev = { 12735a35408SKuninori Morimoto .platform_data = &sh_eth_plat, 12835a35408SKuninori Morimoto }, 12935a35408SKuninori Morimoto .num_resources = ARRAY_SIZE(sh_eth_resources), 13035a35408SKuninori Morimoto .resource = sh_eth_resources, 13135a35408SKuninori Morimoto }; 13235a35408SKuninori Morimoto 133907050a3SKuninori Morimoto /* USB0 host */ 134907050a3SKuninori Morimoto void usb0_port_power(int port, int power) 135907050a3SKuninori Morimoto { 136907050a3SKuninori Morimoto gpio_set_value(GPIO_PTB4, power); 137907050a3SKuninori Morimoto } 138907050a3SKuninori Morimoto 139907050a3SKuninori Morimoto static struct r8a66597_platdata usb0_host_data = { 140907050a3SKuninori Morimoto .on_chip = 1, 141907050a3SKuninori Morimoto .port_power = usb0_port_power, 142907050a3SKuninori Morimoto }; 143907050a3SKuninori Morimoto 144907050a3SKuninori Morimoto static struct resource usb0_host_resources[] = { 145907050a3SKuninori Morimoto [0] = { 146907050a3SKuninori Morimoto .start = 0xa4d80000, 147907050a3SKuninori Morimoto .end = 0xa4d80124 - 1, 148907050a3SKuninori Morimoto .flags = IORESOURCE_MEM, 149907050a3SKuninori Morimoto }, 150907050a3SKuninori Morimoto [1] = { 151907050a3SKuninori Morimoto .start = 65, 152907050a3SKuninori Morimoto .end = 65, 153907050a3SKuninori Morimoto .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW, 154907050a3SKuninori Morimoto }, 155907050a3SKuninori Morimoto }; 156907050a3SKuninori Morimoto 157907050a3SKuninori Morimoto static struct platform_device usb0_host_device = { 158907050a3SKuninori Morimoto .name = "r8a66597_hcd", 159907050a3SKuninori Morimoto .id = 0, 160907050a3SKuninori Morimoto .dev = { 161907050a3SKuninori Morimoto .dma_mask = NULL, /* not use dma */ 162907050a3SKuninori Morimoto .coherent_dma_mask = 0xffffffff, 163907050a3SKuninori Morimoto .platform_data = &usb0_host_data, 164907050a3SKuninori Morimoto }, 165907050a3SKuninori Morimoto .num_resources = ARRAY_SIZE(usb0_host_resources), 166907050a3SKuninori Morimoto .resource = usb0_host_resources, 167907050a3SKuninori Morimoto }; 168907050a3SKuninori Morimoto 169907050a3SKuninori Morimoto /* 170907050a3SKuninori Morimoto * USB1 171907050a3SKuninori Morimoto * 172907050a3SKuninori Morimoto * CN5 can use both host/function, 173907050a3SKuninori Morimoto * and we can determine it by checking PTB[3] 174907050a3SKuninori Morimoto * 175907050a3SKuninori Morimoto * This time only USB1 host is supported. 176907050a3SKuninori Morimoto */ 177907050a3SKuninori Morimoto void usb1_port_power(int port, int power) 178907050a3SKuninori Morimoto { 179907050a3SKuninori Morimoto if (!gpio_get_value(GPIO_PTB3)) { 180907050a3SKuninori Morimoto printk(KERN_ERR "USB1 function is not supported\n"); 181907050a3SKuninori Morimoto return; 182907050a3SKuninori Morimoto } 183907050a3SKuninori Morimoto 184907050a3SKuninori Morimoto gpio_set_value(GPIO_PTB5, power); 185907050a3SKuninori Morimoto } 186907050a3SKuninori Morimoto 187907050a3SKuninori Morimoto static struct r8a66597_platdata usb1_host_data = { 188907050a3SKuninori Morimoto .on_chip = 1, 189907050a3SKuninori Morimoto .port_power = usb1_port_power, 190907050a3SKuninori Morimoto }; 191907050a3SKuninori Morimoto 192907050a3SKuninori Morimoto static struct resource usb1_host_resources[] = { 193907050a3SKuninori Morimoto [0] = { 194907050a3SKuninori Morimoto .start = 0xa4d90000, 195907050a3SKuninori Morimoto .end = 0xa4d90124 - 1, 196907050a3SKuninori Morimoto .flags = IORESOURCE_MEM, 197907050a3SKuninori Morimoto }, 198907050a3SKuninori Morimoto [1] = { 199907050a3SKuninori Morimoto .start = 66, 200907050a3SKuninori Morimoto .end = 66, 201907050a3SKuninori Morimoto .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW, 202907050a3SKuninori Morimoto }, 203907050a3SKuninori Morimoto }; 204907050a3SKuninori Morimoto 205907050a3SKuninori Morimoto static struct platform_device usb1_host_device = { 206907050a3SKuninori Morimoto .name = "r8a66597_hcd", 207907050a3SKuninori Morimoto .id = 1, 208907050a3SKuninori Morimoto .dev = { 209907050a3SKuninori Morimoto .dma_mask = NULL, /* not use dma */ 210907050a3SKuninori Morimoto .coherent_dma_mask = 0xffffffff, 211907050a3SKuninori Morimoto .platform_data = &usb1_host_data, 212907050a3SKuninori Morimoto }, 213907050a3SKuninori Morimoto .num_resources = ARRAY_SIZE(usb1_host_resources), 214907050a3SKuninori Morimoto .resource = usb1_host_resources, 215907050a3SKuninori Morimoto }; 216907050a3SKuninori Morimoto 217fa3ba51bSKuninori Morimoto /* LCDC */ 218fa3ba51bSKuninori Morimoto static struct sh_mobile_lcdc_info lcdc_info = { 219fa3ba51bSKuninori Morimoto .ch[0] = { 220fa3ba51bSKuninori Morimoto .interface_type = RGB18, 221fa3ba51bSKuninori Morimoto .chan = LCDC_CHAN_MAINLCD, 222fa3ba51bSKuninori Morimoto .bpp = 16, 223fa3ba51bSKuninori Morimoto .lcd_cfg = { 224fa3ba51bSKuninori Morimoto .sync = 0, /* hsync and vsync are active low */ 225fa3ba51bSKuninori Morimoto }, 226fa3ba51bSKuninori Morimoto .lcd_size_cfg = { /* 7.0 inch */ 227fa3ba51bSKuninori Morimoto .width = 152, 228fa3ba51bSKuninori Morimoto .height = 91, 229fa3ba51bSKuninori Morimoto }, 230fa3ba51bSKuninori Morimoto .board_cfg = { 231fa3ba51bSKuninori Morimoto }, 232fa3ba51bSKuninori Morimoto } 233fa3ba51bSKuninori Morimoto }; 234fa3ba51bSKuninori Morimoto 235fa3ba51bSKuninori Morimoto static struct resource lcdc_resources[] = { 236fa3ba51bSKuninori Morimoto [0] = { 237fa3ba51bSKuninori Morimoto .name = "LCDC", 238fa3ba51bSKuninori Morimoto .start = 0xfe940000, 239fa3ba51bSKuninori Morimoto .end = 0xfe941fff, 240fa3ba51bSKuninori Morimoto .flags = IORESOURCE_MEM, 241fa3ba51bSKuninori Morimoto }, 242fa3ba51bSKuninori Morimoto [1] = { 243fa3ba51bSKuninori Morimoto .start = 106, 244fa3ba51bSKuninori Morimoto .flags = IORESOURCE_IRQ, 245fa3ba51bSKuninori Morimoto }, 246fa3ba51bSKuninori Morimoto }; 247fa3ba51bSKuninori Morimoto 248fa3ba51bSKuninori Morimoto static struct platform_device lcdc_device = { 249fa3ba51bSKuninori Morimoto .name = "sh_mobile_lcdc_fb", 250fa3ba51bSKuninori Morimoto .num_resources = ARRAY_SIZE(lcdc_resources), 251fa3ba51bSKuninori Morimoto .resource = lcdc_resources, 252fa3ba51bSKuninori Morimoto .dev = { 253fa3ba51bSKuninori Morimoto .platform_data = &lcdc_info, 254fa3ba51bSKuninori Morimoto }, 255fa3ba51bSKuninori Morimoto .archdata = { 256fa3ba51bSKuninori Morimoto .hwblk_id = HWBLK_LCDC, 257fa3ba51bSKuninori Morimoto }, 258fa3ba51bSKuninori Morimoto }; 259fa3ba51bSKuninori Morimoto 2602153ad32SKuninori Morimoto /* CEU0 */ 2612153ad32SKuninori Morimoto static struct sh_mobile_ceu_info sh_mobile_ceu0_info = { 2622153ad32SKuninori Morimoto .flags = SH_CEU_FLAG_USE_8BIT_BUS, 2632153ad32SKuninori Morimoto }; 2642153ad32SKuninori Morimoto 2652153ad32SKuninori Morimoto static struct resource ceu0_resources[] = { 2662153ad32SKuninori Morimoto [0] = { 2672153ad32SKuninori Morimoto .name = "CEU0", 2682153ad32SKuninori Morimoto .start = 0xfe910000, 2692153ad32SKuninori Morimoto .end = 0xfe91009f, 2702153ad32SKuninori Morimoto .flags = IORESOURCE_MEM, 2712153ad32SKuninori Morimoto }, 2722153ad32SKuninori Morimoto [1] = { 2732153ad32SKuninori Morimoto .start = 52, 2742153ad32SKuninori Morimoto .flags = IORESOURCE_IRQ, 2752153ad32SKuninori Morimoto }, 2762153ad32SKuninori Morimoto [2] = { 2772153ad32SKuninori Morimoto /* place holder for contiguous memory */ 2782153ad32SKuninori Morimoto }, 2792153ad32SKuninori Morimoto }; 2802153ad32SKuninori Morimoto 2812153ad32SKuninori Morimoto static struct platform_device ceu0_device = { 2822153ad32SKuninori Morimoto .name = "sh_mobile_ceu", 2832153ad32SKuninori Morimoto .id = 0, /* "ceu0" clock */ 2842153ad32SKuninori Morimoto .num_resources = ARRAY_SIZE(ceu0_resources), 2852153ad32SKuninori Morimoto .resource = ceu0_resources, 2862153ad32SKuninori Morimoto .dev = { 2872153ad32SKuninori Morimoto .platform_data = &sh_mobile_ceu0_info, 2882153ad32SKuninori Morimoto }, 2892153ad32SKuninori Morimoto .archdata = { 2902153ad32SKuninori Morimoto .hwblk_id = HWBLK_CEU0, 2912153ad32SKuninori Morimoto }, 2922153ad32SKuninori Morimoto }; 2932153ad32SKuninori Morimoto 2942153ad32SKuninori Morimoto /* CEU1 */ 2952153ad32SKuninori Morimoto static struct sh_mobile_ceu_info sh_mobile_ceu1_info = { 2962153ad32SKuninori Morimoto .flags = SH_CEU_FLAG_USE_8BIT_BUS, 2972153ad32SKuninori Morimoto }; 2982153ad32SKuninori Morimoto 2992153ad32SKuninori Morimoto static struct resource ceu1_resources[] = { 3002153ad32SKuninori Morimoto [0] = { 3012153ad32SKuninori Morimoto .name = "CEU1", 3022153ad32SKuninori Morimoto .start = 0xfe914000, 3032153ad32SKuninori Morimoto .end = 0xfe91409f, 3042153ad32SKuninori Morimoto .flags = IORESOURCE_MEM, 3052153ad32SKuninori Morimoto }, 3062153ad32SKuninori Morimoto [1] = { 3072153ad32SKuninori Morimoto .start = 63, 3082153ad32SKuninori Morimoto .flags = IORESOURCE_IRQ, 3092153ad32SKuninori Morimoto }, 3102153ad32SKuninori Morimoto [2] = { 3112153ad32SKuninori Morimoto /* place holder for contiguous memory */ 3122153ad32SKuninori Morimoto }, 3132153ad32SKuninori Morimoto }; 3142153ad32SKuninori Morimoto 3152153ad32SKuninori Morimoto static struct platform_device ceu1_device = { 3162153ad32SKuninori Morimoto .name = "sh_mobile_ceu", 3172153ad32SKuninori Morimoto .id = 1, /* "ceu1" clock */ 3182153ad32SKuninori Morimoto .num_resources = ARRAY_SIZE(ceu1_resources), 3192153ad32SKuninori Morimoto .resource = ceu1_resources, 3202153ad32SKuninori Morimoto .dev = { 3212153ad32SKuninori Morimoto .platform_data = &sh_mobile_ceu1_info, 3222153ad32SKuninori Morimoto }, 3232153ad32SKuninori Morimoto .archdata = { 3242153ad32SKuninori Morimoto .hwblk_id = HWBLK_CEU1, 3252153ad32SKuninori Morimoto }, 3262153ad32SKuninori Morimoto }; 3272153ad32SKuninori Morimoto 328125ecce6SKuninori Morimoto /* I2C device */ 329125ecce6SKuninori Morimoto static struct i2c_board_info i2c1_devices[] = { 330125ecce6SKuninori Morimoto { 331125ecce6SKuninori Morimoto I2C_BOARD_INFO("r2025sd", 0x32), 332125ecce6SKuninori Morimoto }, 333125ecce6SKuninori Morimoto }; 334125ecce6SKuninori Morimoto 3354138b740SKuninori Morimoto static struct platform_device *ecovec_devices[] __initdata = { 3364138b740SKuninori Morimoto &heartbeat_device, 3374138b740SKuninori Morimoto &nor_flash_device, 33835a35408SKuninori Morimoto &sh_eth_device, 339907050a3SKuninori Morimoto &usb0_host_device, 340907050a3SKuninori Morimoto &usb1_host_device, /* USB1 host support */ 341fa3ba51bSKuninori Morimoto &lcdc_device, 3422153ad32SKuninori Morimoto &ceu0_device, 3432153ad32SKuninori Morimoto &ceu1_device, 3444138b740SKuninori Morimoto }; 3454138b740SKuninori Morimoto 346*4907d57fSKuninori Morimoto #define EEPROM_ADDR 0x50 347*4907d57fSKuninori Morimoto static u8 mac_read(struct i2c_adapter *a, u8 command) 348*4907d57fSKuninori Morimoto { 349*4907d57fSKuninori Morimoto struct i2c_msg msg[2]; 350*4907d57fSKuninori Morimoto u8 buf; 351*4907d57fSKuninori Morimoto int ret; 352*4907d57fSKuninori Morimoto 353*4907d57fSKuninori Morimoto msg[0].addr = EEPROM_ADDR; 354*4907d57fSKuninori Morimoto msg[0].flags = 0; 355*4907d57fSKuninori Morimoto msg[0].len = 1; 356*4907d57fSKuninori Morimoto msg[0].buf = &command; 357*4907d57fSKuninori Morimoto 358*4907d57fSKuninori Morimoto msg[1].addr = EEPROM_ADDR; 359*4907d57fSKuninori Morimoto msg[1].flags = I2C_M_RD; 360*4907d57fSKuninori Morimoto msg[1].len = 1; 361*4907d57fSKuninori Morimoto msg[1].buf = &buf; 362*4907d57fSKuninori Morimoto 363*4907d57fSKuninori Morimoto ret = i2c_transfer(a, msg, 2); 364*4907d57fSKuninori Morimoto if (ret < 0) { 365*4907d57fSKuninori Morimoto printk(KERN_ERR "error %d\n", ret); 366*4907d57fSKuninori Morimoto buf = 0xff; 367*4907d57fSKuninori Morimoto } 368*4907d57fSKuninori Morimoto 369*4907d57fSKuninori Morimoto return buf; 370*4907d57fSKuninori Morimoto } 371*4907d57fSKuninori Morimoto 372*4907d57fSKuninori Morimoto #define MAC_LEN 6 373*4907d57fSKuninori Morimoto static void __init sh_eth_init(void) 374*4907d57fSKuninori Morimoto { 375*4907d57fSKuninori Morimoto struct i2c_adapter *a = i2c_get_adapter(1); 376*4907d57fSKuninori Morimoto struct clk *eth_clk; 377*4907d57fSKuninori Morimoto u8 mac[MAC_LEN]; 378*4907d57fSKuninori Morimoto int i; 379*4907d57fSKuninori Morimoto 380*4907d57fSKuninori Morimoto if (!a) { 381*4907d57fSKuninori Morimoto pr_err("can not get I2C 1\n"); 382*4907d57fSKuninori Morimoto return; 383*4907d57fSKuninori Morimoto } 384*4907d57fSKuninori Morimoto 385*4907d57fSKuninori Morimoto eth_clk = clk_get(NULL, "eth0"); 386*4907d57fSKuninori Morimoto if (!eth_clk) { 387*4907d57fSKuninori Morimoto pr_err("can not get eth0 clk\n"); 388*4907d57fSKuninori Morimoto return; 389*4907d57fSKuninori Morimoto } 390*4907d57fSKuninori Morimoto 391*4907d57fSKuninori Morimoto /* read MAC address frome EEPROM */ 392*4907d57fSKuninori Morimoto for (i = 0; i < MAC_LEN; i++) { 393*4907d57fSKuninori Morimoto mac[i] = mac_read(a, 0x10 + i); 394*4907d57fSKuninori Morimoto msleep(10); 395*4907d57fSKuninori Morimoto } 396*4907d57fSKuninori Morimoto 397*4907d57fSKuninori Morimoto /* clock enable */ 398*4907d57fSKuninori Morimoto clk_enable(eth_clk); 399*4907d57fSKuninori Morimoto 400*4907d57fSKuninori Morimoto /* reset sh-eth */ 401*4907d57fSKuninori Morimoto ctrl_outl(0x1, SH_ETH_ADDR + 0x0); 402*4907d57fSKuninori Morimoto 403*4907d57fSKuninori Morimoto /* set MAC addr */ 404*4907d57fSKuninori Morimoto ctrl_outl((mac[0] << 24) | 405*4907d57fSKuninori Morimoto (mac[1] << 16) | 406*4907d57fSKuninori Morimoto (mac[2] << 8) | 407*4907d57fSKuninori Morimoto (mac[3] << 0), SH_ETH_MAHR); 408*4907d57fSKuninori Morimoto ctrl_outl((mac[4] << 8) | 409*4907d57fSKuninori Morimoto (mac[5] << 0), SH_ETH_MALR); 410*4907d57fSKuninori Morimoto 411*4907d57fSKuninori Morimoto clk_put(eth_clk); 412*4907d57fSKuninori Morimoto } 413*4907d57fSKuninori Morimoto 414fa3ba51bSKuninori Morimoto #define PORT_HIZA 0xA4050158 415ea15edb2SKuninori Morimoto #define IODRIVEA 0xA405018A 416*4907d57fSKuninori Morimoto static int __init arch_setup(void) 4174138b740SKuninori Morimoto { 4184138b740SKuninori Morimoto /* enable SCIFA0 */ 4194138b740SKuninori Morimoto gpio_request(GPIO_FN_SCIF0_TXD, NULL); 4204138b740SKuninori Morimoto gpio_request(GPIO_FN_SCIF0_RXD, NULL); 4214138b740SKuninori Morimoto 4224138b740SKuninori Morimoto /* enable debug LED */ 4234138b740SKuninori Morimoto gpio_request(GPIO_PTG0, NULL); 4244138b740SKuninori Morimoto gpio_request(GPIO_PTG1, NULL); 4254138b740SKuninori Morimoto gpio_request(GPIO_PTG2, NULL); 4264138b740SKuninori Morimoto gpio_request(GPIO_PTG3, NULL); 427b7056bc1SKuninori Morimoto gpio_direction_output(GPIO_PTG0, 0); 428b7056bc1SKuninori Morimoto gpio_direction_output(GPIO_PTG1, 0); 429b7056bc1SKuninori Morimoto gpio_direction_output(GPIO_PTG2, 0); 430b7056bc1SKuninori Morimoto gpio_direction_output(GPIO_PTG3, 0); 4314138b740SKuninori Morimoto 43235a35408SKuninori Morimoto /* enable SH-Eth */ 43335a35408SKuninori Morimoto gpio_request(GPIO_PTA1, NULL); 43435a35408SKuninori Morimoto gpio_direction_output(GPIO_PTA1, 1); 43535a35408SKuninori Morimoto mdelay(20); 43635a35408SKuninori Morimoto 43735a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_RXD0, NULL); 43835a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_RXD1, NULL); 43935a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_TXD0, NULL); 44035a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_TXD1, NULL); 44135a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_REF_CLK, NULL); 44235a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_TX_EN, NULL); 44335a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_RX_ER, NULL); 44435a35408SKuninori Morimoto gpio_request(GPIO_FN_RMII_CRS_DV, NULL); 44535a35408SKuninori Morimoto gpio_request(GPIO_FN_MDIO, NULL); 44635a35408SKuninori Morimoto gpio_request(GPIO_FN_MDC, NULL); 44735a35408SKuninori Morimoto gpio_request(GPIO_FN_LNKSTA, NULL); 44835a35408SKuninori Morimoto 449907050a3SKuninori Morimoto /* enable USB */ 450be4ebf99SKuninori Morimoto ctrl_outw(0x0000, 0xA4D80000); 451907050a3SKuninori Morimoto gpio_request(GPIO_PTB3, NULL); 452907050a3SKuninori Morimoto gpio_request(GPIO_PTB4, NULL); 453907050a3SKuninori Morimoto gpio_request(GPIO_PTB5, NULL); 454907050a3SKuninori Morimoto gpio_direction_input(GPIO_PTB3); 455907050a3SKuninori Morimoto gpio_direction_output(GPIO_PTB4, 0); 456907050a3SKuninori Morimoto gpio_direction_output(GPIO_PTB5, 0); 457907050a3SKuninori Morimoto ctrl_outw(0x0600, 0xa40501d4); 458907050a3SKuninori Morimoto ctrl_outw(0x0600, 0xa4050192); 459907050a3SKuninori Morimoto 460fa3ba51bSKuninori Morimoto /* enable LCDC */ 461fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD23, NULL); 462fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD22, NULL); 463fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD21, NULL); 464fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD20, NULL); 465fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD19, NULL); 466fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD18, NULL); 467fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD17, NULL); 468fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD16, NULL); 469fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD15, NULL); 470fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD14, NULL); 471fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD13, NULL); 472fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD12, NULL); 473fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD11, NULL); 474fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD10, NULL); 475fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD9, NULL); 476fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD8, NULL); 477fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD7, NULL); 478fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD6, NULL); 479fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD5, NULL); 480fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD4, NULL); 481fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD3, NULL); 482fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD2, NULL); 483fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD1, NULL); 484fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDD0, NULL); 485fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDDISP, NULL); 486fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDHSYN, NULL); 487fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDDCK, NULL); 488fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDVSYN, NULL); 489fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDDON, NULL); 490fa3ba51bSKuninori Morimoto gpio_request(GPIO_FN_LCDLCLK, NULL); 491fa3ba51bSKuninori Morimoto ctrl_outw((ctrl_inw(PORT_HIZA) & ~0x0001), PORT_HIZA); 492fa3ba51bSKuninori Morimoto 493fa3ba51bSKuninori Morimoto gpio_request(GPIO_PTE6, NULL); 494fa3ba51bSKuninori Morimoto gpio_request(GPIO_PTU1, NULL); 495fa3ba51bSKuninori Morimoto gpio_request(GPIO_PTR1, NULL); 496fa3ba51bSKuninori Morimoto gpio_request(GPIO_PTA2, NULL); 497fa3ba51bSKuninori Morimoto gpio_direction_input(GPIO_PTE6); 498fa3ba51bSKuninori Morimoto gpio_direction_output(GPIO_PTU1, 0); 499fa3ba51bSKuninori Morimoto gpio_direction_output(GPIO_PTR1, 0); 500fa3ba51bSKuninori Morimoto gpio_direction_output(GPIO_PTA2, 0); 501fa3ba51bSKuninori Morimoto 502ea15edb2SKuninori Morimoto /* I/O buffer drive ability is low */ 503ea15edb2SKuninori Morimoto ctrl_outw((ctrl_inw(IODRIVEA) & ~0x00c0) | 0x0040 , IODRIVEA); 504ea15edb2SKuninori Morimoto 505fa3ba51bSKuninori Morimoto if (gpio_get_value(GPIO_PTE6)) { 506fa3ba51bSKuninori Morimoto /* DVI */ 507fa3ba51bSKuninori Morimoto lcdc_info.clock_source = LCDC_CLK_EXTERNAL; 508ea15edb2SKuninori Morimoto lcdc_info.ch[0].clock_divider = 1, 509fa3ba51bSKuninori Morimoto lcdc_info.ch[0].lcd_cfg.name = "DVI"; 510fa3ba51bSKuninori Morimoto lcdc_info.ch[0].lcd_cfg.xres = 1280; 511fa3ba51bSKuninori Morimoto lcdc_info.ch[0].lcd_cfg.yres = 720; 512fa3ba51bSKuninori Morimoto lcdc_info.ch[0].lcd_cfg.left_margin = 220; 513fa3ba51bSKuninori Morimoto lcdc_info.ch[0].lcd_cfg.right_margin = 110; 514fa3ba51bSKuninori Morimoto lcdc_info.ch[0].lcd_cfg.hsync_len = 40; 515fa3ba51bSKuninori Morimoto lcdc_info.ch[0].lcd_cfg.upper_margin = 20; 516fa3ba51bSKuninori Morimoto lcdc_info.ch[0].lcd_cfg.lower_margin = 5; 517fa3ba51bSKuninori Morimoto lcdc_info.ch[0].lcd_cfg.vsync_len = 5; 518fa3ba51bSKuninori Morimoto 519fa3ba51bSKuninori Morimoto gpio_set_value(GPIO_PTA2, 1); 520fa3ba51bSKuninori Morimoto gpio_set_value(GPIO_PTU1, 1); 521fa3ba51bSKuninori Morimoto } else { 522fa3ba51bSKuninori Morimoto /* Panel */ 523ea15edb2SKuninori Morimoto 524ea15edb2SKuninori Morimoto lcdc_info.clock_source = LCDC_CLK_PERIPHERAL; 525ea15edb2SKuninori Morimoto lcdc_info.ch[0].clock_divider = 2, 526ea15edb2SKuninori Morimoto lcdc_info.ch[0].lcd_cfg.name = "Panel"; 527ea15edb2SKuninori Morimoto lcdc_info.ch[0].lcd_cfg.xres = 800; 528ea15edb2SKuninori Morimoto lcdc_info.ch[0].lcd_cfg.yres = 480; 529ea15edb2SKuninori Morimoto lcdc_info.ch[0].lcd_cfg.left_margin = 220; 530ea15edb2SKuninori Morimoto lcdc_info.ch[0].lcd_cfg.right_margin = 110; 531ea15edb2SKuninori Morimoto lcdc_info.ch[0].lcd_cfg.hsync_len = 70; 532ea15edb2SKuninori Morimoto lcdc_info.ch[0].lcd_cfg.upper_margin = 20; 533ea15edb2SKuninori Morimoto lcdc_info.ch[0].lcd_cfg.lower_margin = 5; 534ea15edb2SKuninori Morimoto lcdc_info.ch[0].lcd_cfg.vsync_len = 5; 535ea15edb2SKuninori Morimoto 536ea15edb2SKuninori Morimoto gpio_set_value(GPIO_PTR1, 1); 537ea15edb2SKuninori Morimoto 538ea15edb2SKuninori Morimoto /* FIXME 539ea15edb2SKuninori Morimoto * 540ea15edb2SKuninori Morimoto * LCDDON control is needed for Panel, 541ea15edb2SKuninori Morimoto * but current sh_mobile_lcdc driver doesn't control it. 542ea15edb2SKuninori Morimoto * It is temporary correspondence 543ea15edb2SKuninori Morimoto */ 544ea15edb2SKuninori Morimoto gpio_request(GPIO_PTF4, NULL); 545ea15edb2SKuninori Morimoto gpio_direction_output(GPIO_PTF4, 1); 546fa3ba51bSKuninori Morimoto } 547fa3ba51bSKuninori Morimoto 5482153ad32SKuninori Morimoto /* enable CEU0 */ 5492153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D15, NULL); 5502153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D14, NULL); 5512153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D13, NULL); 5522153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D12, NULL); 5532153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D11, NULL); 5542153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D10, NULL); 5552153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D9, NULL); 5562153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D8, NULL); 5572153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D7, NULL); 5582153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D6, NULL); 5592153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D5, NULL); 5602153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D4, NULL); 5612153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D3, NULL); 5622153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D2, NULL); 5632153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D1, NULL); 5642153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_D0, NULL); 5652153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_VD, NULL); 5662153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_CLK, NULL); 5672153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_FLD, NULL); 5682153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO0_HD, NULL); 5692153ad32SKuninori Morimoto platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20); 5702153ad32SKuninori Morimoto 5712153ad32SKuninori Morimoto /* enable CEU1 */ 5722153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D7, NULL); 5732153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D6, NULL); 5742153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D5, NULL); 5752153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D4, NULL); 5762153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D3, NULL); 5772153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D2, NULL); 5782153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D1, NULL); 5792153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_D0, NULL); 5802153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_FLD, NULL); 5812153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_HD, NULL); 5822153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_VD, NULL); 5832153ad32SKuninori Morimoto gpio_request(GPIO_FN_VIO1_CLK, NULL); 5842153ad32SKuninori Morimoto platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20); 5852153ad32SKuninori Morimoto 586125ecce6SKuninori Morimoto /* enable I2C device */ 587125ecce6SKuninori Morimoto i2c_register_board_info(1, i2c1_devices, 588125ecce6SKuninori Morimoto ARRAY_SIZE(i2c1_devices)); 589125ecce6SKuninori Morimoto 5904138b740SKuninori Morimoto return platform_add_devices(ecovec_devices, 5914138b740SKuninori Morimoto ARRAY_SIZE(ecovec_devices)); 5924138b740SKuninori Morimoto } 593*4907d57fSKuninori Morimoto arch_initcall(arch_setup); 594*4907d57fSKuninori Morimoto 595*4907d57fSKuninori Morimoto static int __init devices_setup(void) 596*4907d57fSKuninori Morimoto { 597*4907d57fSKuninori Morimoto sh_eth_init(); 598*4907d57fSKuninori Morimoto return 0; 599*4907d57fSKuninori Morimoto } 600*4907d57fSKuninori Morimoto device_initcall(devices_setup); 601*4907d57fSKuninori Morimoto 6024138b740SKuninori Morimoto 6034138b740SKuninori Morimoto static struct sh_machine_vector mv_ecovec __initmv = { 6044138b740SKuninori Morimoto .mv_name = "R0P7724 (EcoVec)", 6054138b740SKuninori Morimoto }; 606