1c8b5d9dcSPaul Mundt /* 2c8b5d9dcSPaul Mundt * Renesas Technology Corp. R0P7785LC0011RL Support. 3c8b5d9dcSPaul Mundt * 4c8b5d9dcSPaul Mundt * Copyright (C) 2008 Yoshihiro Shimoda 5c8b5d9dcSPaul Mundt * 6c8b5d9dcSPaul Mundt * This file is subject to the terms and conditions of the GNU General Public 7c8b5d9dcSPaul Mundt * License. See the file "COPYING" in the main directory of this archive 8c8b5d9dcSPaul Mundt * for more details. 9c8b5d9dcSPaul Mundt */ 10c8b5d9dcSPaul Mundt 11c8b5d9dcSPaul Mundt #include <linux/init.h> 12c8b5d9dcSPaul Mundt #include <linux/platform_device.h> 13c8b5d9dcSPaul Mundt #include <linux/sm501.h> 14c8b5d9dcSPaul Mundt #include <linux/sm501-regs.h> 15c8b5d9dcSPaul Mundt #include <linux/fb.h> 16c8b5d9dcSPaul Mundt #include <linux/mtd/physmap.h> 17c8b5d9dcSPaul Mundt #include <linux/delay.h> 18c8b5d9dcSPaul Mundt #include <linux/i2c.h> 19c8b5d9dcSPaul Mundt #include <linux/i2c-pca-platform.h> 20c8b5d9dcSPaul Mundt #include <linux/i2c-algo-pca.h> 21c8b5d9dcSPaul Mundt #include <asm/heartbeat.h> 22*7639a454SPaul Mundt #include <mach/sh7785lcr.h> 23c8b5d9dcSPaul Mundt 24c8b5d9dcSPaul Mundt /* 25c8b5d9dcSPaul Mundt * NOTE: This board has 2 physical memory maps. 26c8b5d9dcSPaul Mundt * Please look at include/asm-sh/sh7785lcr.h or hardware manual. 27c8b5d9dcSPaul Mundt */ 28c8b5d9dcSPaul Mundt static struct resource heartbeat_resources[] = { 29c8b5d9dcSPaul Mundt [0] = { 30c8b5d9dcSPaul Mundt .start = PLD_LEDCR, 31c8b5d9dcSPaul Mundt .end = PLD_LEDCR, 32c8b5d9dcSPaul Mundt .flags = IORESOURCE_MEM, 33c8b5d9dcSPaul Mundt }, 34c8b5d9dcSPaul Mundt }; 35c8b5d9dcSPaul Mundt 36c8b5d9dcSPaul Mundt static struct heartbeat_data heartbeat_data = { 37c8b5d9dcSPaul Mundt .regsize = 8, 38c8b5d9dcSPaul Mundt }; 39c8b5d9dcSPaul Mundt 40c8b5d9dcSPaul Mundt static struct platform_device heartbeat_device = { 41c8b5d9dcSPaul Mundt .name = "heartbeat", 42c8b5d9dcSPaul Mundt .id = -1, 43c8b5d9dcSPaul Mundt .dev = { 44c8b5d9dcSPaul Mundt .platform_data = &heartbeat_data, 45c8b5d9dcSPaul Mundt }, 46c8b5d9dcSPaul Mundt .num_resources = ARRAY_SIZE(heartbeat_resources), 47c8b5d9dcSPaul Mundt .resource = heartbeat_resources, 48c8b5d9dcSPaul Mundt }; 49c8b5d9dcSPaul Mundt 50c8b5d9dcSPaul Mundt static struct mtd_partition nor_flash_partitions[] = { 51c8b5d9dcSPaul Mundt { 52c8b5d9dcSPaul Mundt .name = "loader", 53c8b5d9dcSPaul Mundt .offset = 0x00000000, 54c8b5d9dcSPaul Mundt .size = 512 * 1024, 55c8b5d9dcSPaul Mundt }, 56c8b5d9dcSPaul Mundt { 57c8b5d9dcSPaul Mundt .name = "bootenv", 58c8b5d9dcSPaul Mundt .offset = MTDPART_OFS_APPEND, 59c8b5d9dcSPaul Mundt .size = 512 * 1024, 60c8b5d9dcSPaul Mundt }, 61c8b5d9dcSPaul Mundt { 62c8b5d9dcSPaul Mundt .name = "kernel", 63c8b5d9dcSPaul Mundt .offset = MTDPART_OFS_APPEND, 64c8b5d9dcSPaul Mundt .size = 4 * 1024 * 1024, 65c8b5d9dcSPaul Mundt }, 66c8b5d9dcSPaul Mundt { 67c8b5d9dcSPaul Mundt .name = "data", 68c8b5d9dcSPaul Mundt .offset = MTDPART_OFS_APPEND, 69c8b5d9dcSPaul Mundt .size = MTDPART_SIZ_FULL, 70c8b5d9dcSPaul Mundt }, 71c8b5d9dcSPaul Mundt }; 72c8b5d9dcSPaul Mundt 73c8b5d9dcSPaul Mundt static struct physmap_flash_data nor_flash_data = { 74c8b5d9dcSPaul Mundt .width = 4, 75c8b5d9dcSPaul Mundt .parts = nor_flash_partitions, 76c8b5d9dcSPaul Mundt .nr_parts = ARRAY_SIZE(nor_flash_partitions), 77c8b5d9dcSPaul Mundt }; 78c8b5d9dcSPaul Mundt 79c8b5d9dcSPaul Mundt static struct resource nor_flash_resources[] = { 80c8b5d9dcSPaul Mundt [0] = { 81c8b5d9dcSPaul Mundt .start = NOR_FLASH_ADDR, 82c8b5d9dcSPaul Mundt .end = NOR_FLASH_ADDR + NOR_FLASH_SIZE - 1, 83c8b5d9dcSPaul Mundt .flags = IORESOURCE_MEM, 84c8b5d9dcSPaul Mundt } 85c8b5d9dcSPaul Mundt }; 86c8b5d9dcSPaul Mundt 87c8b5d9dcSPaul Mundt static struct platform_device nor_flash_device = { 88c8b5d9dcSPaul Mundt .name = "physmap-flash", 89c8b5d9dcSPaul Mundt .dev = { 90c8b5d9dcSPaul Mundt .platform_data = &nor_flash_data, 91c8b5d9dcSPaul Mundt }, 92c8b5d9dcSPaul Mundt .num_resources = ARRAY_SIZE(nor_flash_resources), 93c8b5d9dcSPaul Mundt .resource = nor_flash_resources, 94c8b5d9dcSPaul Mundt }; 95c8b5d9dcSPaul Mundt 96c8b5d9dcSPaul Mundt static struct resource r8a66597_usb_host_resources[] = { 97c8b5d9dcSPaul Mundt [0] = { 98c8b5d9dcSPaul Mundt .name = "r8a66597_hcd", 99c8b5d9dcSPaul Mundt .start = R8A66597_ADDR, 100c8b5d9dcSPaul Mundt .end = R8A66597_ADDR + R8A66597_SIZE - 1, 101c8b5d9dcSPaul Mundt .flags = IORESOURCE_MEM, 102c8b5d9dcSPaul Mundt }, 103c8b5d9dcSPaul Mundt [1] = { 104c8b5d9dcSPaul Mundt .name = "r8a66597_hcd", 105c8b5d9dcSPaul Mundt .start = 2, 106c8b5d9dcSPaul Mundt .end = 2, 107c8b5d9dcSPaul Mundt .flags = IORESOURCE_IRQ, 108c8b5d9dcSPaul Mundt }, 109c8b5d9dcSPaul Mundt }; 110c8b5d9dcSPaul Mundt 111c8b5d9dcSPaul Mundt static struct platform_device r8a66597_usb_host_device = { 112c8b5d9dcSPaul Mundt .name = "r8a66597_hcd", 113c8b5d9dcSPaul Mundt .id = -1, 114c8b5d9dcSPaul Mundt .dev = { 115c8b5d9dcSPaul Mundt .dma_mask = NULL, 116c8b5d9dcSPaul Mundt .coherent_dma_mask = 0xffffffff, 117c8b5d9dcSPaul Mundt }, 118c8b5d9dcSPaul Mundt .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources), 119c8b5d9dcSPaul Mundt .resource = r8a66597_usb_host_resources, 120c8b5d9dcSPaul Mundt }; 121c8b5d9dcSPaul Mundt 122c8b5d9dcSPaul Mundt static struct resource sm501_resources[] = { 123c8b5d9dcSPaul Mundt [0] = { 124c8b5d9dcSPaul Mundt .start = SM107_MEM_ADDR, 125c8b5d9dcSPaul Mundt .end = SM107_MEM_ADDR + SM107_MEM_SIZE - 1, 126c8b5d9dcSPaul Mundt .flags = IORESOURCE_MEM, 127c8b5d9dcSPaul Mundt }, 128c8b5d9dcSPaul Mundt [1] = { 129c8b5d9dcSPaul Mundt .start = SM107_REG_ADDR, 130c8b5d9dcSPaul Mundt .end = SM107_REG_ADDR + SM107_REG_SIZE - 1, 131c8b5d9dcSPaul Mundt .flags = IORESOURCE_MEM, 132c8b5d9dcSPaul Mundt }, 133c8b5d9dcSPaul Mundt [2] = { 134c8b5d9dcSPaul Mundt .start = 10, 135c8b5d9dcSPaul Mundt .flags = IORESOURCE_IRQ, 136c8b5d9dcSPaul Mundt }, 137c8b5d9dcSPaul Mundt }; 138c8b5d9dcSPaul Mundt 139c8b5d9dcSPaul Mundt static struct fb_videomode sm501_default_mode_crt = { 140c8b5d9dcSPaul Mundt .pixclock = 35714, /* 28MHz */ 141c8b5d9dcSPaul Mundt .xres = 640, 142c8b5d9dcSPaul Mundt .yres = 480, 143c8b5d9dcSPaul Mundt .left_margin = 105, 144c8b5d9dcSPaul Mundt .right_margin = 16, 145c8b5d9dcSPaul Mundt .upper_margin = 33, 146c8b5d9dcSPaul Mundt .lower_margin = 10, 147c8b5d9dcSPaul Mundt .hsync_len = 39, 148c8b5d9dcSPaul Mundt .vsync_len = 2, 149c8b5d9dcSPaul Mundt .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 150c8b5d9dcSPaul Mundt }; 151c8b5d9dcSPaul Mundt 152c8b5d9dcSPaul Mundt static struct fb_videomode sm501_default_mode_pnl = { 153c8b5d9dcSPaul Mundt .pixclock = 40000, /* 25MHz */ 154c8b5d9dcSPaul Mundt .xres = 640, 155c8b5d9dcSPaul Mundt .yres = 480, 156c8b5d9dcSPaul Mundt .left_margin = 2, 157c8b5d9dcSPaul Mundt .right_margin = 16, 158c8b5d9dcSPaul Mundt .upper_margin = 33, 159c8b5d9dcSPaul Mundt .lower_margin = 10, 160c8b5d9dcSPaul Mundt .hsync_len = 39, 161c8b5d9dcSPaul Mundt .vsync_len = 2, 162c8b5d9dcSPaul Mundt .sync = 0, 163c8b5d9dcSPaul Mundt }; 164c8b5d9dcSPaul Mundt 165c8b5d9dcSPaul Mundt static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = { 166c8b5d9dcSPaul Mundt .def_bpp = 16, 167c8b5d9dcSPaul Mundt .def_mode = &sm501_default_mode_pnl, 168c8b5d9dcSPaul Mundt .flags = SM501FB_FLAG_USE_INIT_MODE | 169c8b5d9dcSPaul Mundt SM501FB_FLAG_USE_HWCURSOR | 170c8b5d9dcSPaul Mundt SM501FB_FLAG_USE_HWACCEL | 171c8b5d9dcSPaul Mundt SM501FB_FLAG_DISABLE_AT_EXIT | 172c8b5d9dcSPaul Mundt SM501FB_FLAG_PANEL_NO_VBIASEN, 173c8b5d9dcSPaul Mundt }; 174c8b5d9dcSPaul Mundt 175c8b5d9dcSPaul Mundt static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt = { 176c8b5d9dcSPaul Mundt .def_bpp = 16, 177c8b5d9dcSPaul Mundt .def_mode = &sm501_default_mode_crt, 178c8b5d9dcSPaul Mundt .flags = SM501FB_FLAG_USE_INIT_MODE | 179c8b5d9dcSPaul Mundt SM501FB_FLAG_USE_HWCURSOR | 180c8b5d9dcSPaul Mundt SM501FB_FLAG_USE_HWACCEL | 181c8b5d9dcSPaul Mundt SM501FB_FLAG_DISABLE_AT_EXIT, 182c8b5d9dcSPaul Mundt }; 183c8b5d9dcSPaul Mundt 184c8b5d9dcSPaul Mundt static struct sm501_platdata_fb sm501_fb_pdata = { 185c8b5d9dcSPaul Mundt .fb_route = SM501_FB_OWN, 186c8b5d9dcSPaul Mundt .fb_crt = &sm501_pdata_fbsub_crt, 187c8b5d9dcSPaul Mundt .fb_pnl = &sm501_pdata_fbsub_pnl, 188c8b5d9dcSPaul Mundt }; 189c8b5d9dcSPaul Mundt 190c8b5d9dcSPaul Mundt static struct sm501_initdata sm501_initdata = { 191c8b5d9dcSPaul Mundt .gpio_high = { 192c8b5d9dcSPaul Mundt .set = 0x00001fe0, 193c8b5d9dcSPaul Mundt .mask = 0x0, 194c8b5d9dcSPaul Mundt }, 195c8b5d9dcSPaul Mundt .devices = 0, 196c8b5d9dcSPaul Mundt .mclk = 84 * 1000000, 197c8b5d9dcSPaul Mundt .m1xclk = 112 * 1000000, 198c8b5d9dcSPaul Mundt }; 199c8b5d9dcSPaul Mundt 200c8b5d9dcSPaul Mundt static struct sm501_platdata sm501_platform_data = { 201c8b5d9dcSPaul Mundt .init = &sm501_initdata, 202c8b5d9dcSPaul Mundt .fb = &sm501_fb_pdata, 203c8b5d9dcSPaul Mundt }; 204c8b5d9dcSPaul Mundt 205c8b5d9dcSPaul Mundt static struct platform_device sm501_device = { 206c8b5d9dcSPaul Mundt .name = "sm501", 207c8b5d9dcSPaul Mundt .id = -1, 208c8b5d9dcSPaul Mundt .dev = { 209c8b5d9dcSPaul Mundt .platform_data = &sm501_platform_data, 210c8b5d9dcSPaul Mundt }, 211c8b5d9dcSPaul Mundt .num_resources = ARRAY_SIZE(sm501_resources), 212c8b5d9dcSPaul Mundt .resource = sm501_resources, 213c8b5d9dcSPaul Mundt }; 214c8b5d9dcSPaul Mundt 215c8b5d9dcSPaul Mundt static struct resource i2c_resources[] = { 216c8b5d9dcSPaul Mundt [0] = { 217c8b5d9dcSPaul Mundt .start = PCA9564_ADDR, 218c8b5d9dcSPaul Mundt .end = PCA9564_ADDR + PCA9564_SIZE - 1, 219c8b5d9dcSPaul Mundt .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT, 220c8b5d9dcSPaul Mundt }, 221c8b5d9dcSPaul Mundt [1] = { 222c8b5d9dcSPaul Mundt .start = 12, 223c8b5d9dcSPaul Mundt .end = 12, 224c8b5d9dcSPaul Mundt .flags = IORESOURCE_IRQ, 225c8b5d9dcSPaul Mundt }, 226c8b5d9dcSPaul Mundt }; 227c8b5d9dcSPaul Mundt 228c8b5d9dcSPaul Mundt static struct i2c_pca9564_pf_platform_data i2c_platform_data = { 229c8b5d9dcSPaul Mundt .gpio = 0, 230c8b5d9dcSPaul Mundt .i2c_clock_speed = I2C_PCA_CON_330kHz, 231c8b5d9dcSPaul Mundt .timeout = 100, 232c8b5d9dcSPaul Mundt }; 233c8b5d9dcSPaul Mundt 234c8b5d9dcSPaul Mundt static struct platform_device i2c_device = { 235c8b5d9dcSPaul Mundt .name = "i2c-pca-platform", 236c8b5d9dcSPaul Mundt .id = -1, 237c8b5d9dcSPaul Mundt .dev = { 238c8b5d9dcSPaul Mundt .platform_data = &i2c_platform_data, 239c8b5d9dcSPaul Mundt }, 240c8b5d9dcSPaul Mundt .num_resources = ARRAY_SIZE(i2c_resources), 241c8b5d9dcSPaul Mundt .resource = i2c_resources, 242c8b5d9dcSPaul Mundt }; 243c8b5d9dcSPaul Mundt 244c8b5d9dcSPaul Mundt static struct platform_device *sh7785lcr_devices[] __initdata = { 245c8b5d9dcSPaul Mundt &heartbeat_device, 246c8b5d9dcSPaul Mundt &nor_flash_device, 247c8b5d9dcSPaul Mundt &r8a66597_usb_host_device, 248c8b5d9dcSPaul Mundt &sm501_device, 249c8b5d9dcSPaul Mundt &i2c_device, 250c8b5d9dcSPaul Mundt }; 251c8b5d9dcSPaul Mundt 252c8b5d9dcSPaul Mundt static struct i2c_board_info __initdata sh7785lcr_i2c_devices[] = { 253c8b5d9dcSPaul Mundt { 254c8b5d9dcSPaul Mundt I2C_BOARD_INFO("r2025sd", 0x32), 255c8b5d9dcSPaul Mundt }, 256c8b5d9dcSPaul Mundt }; 257c8b5d9dcSPaul Mundt 258c8b5d9dcSPaul Mundt static int __init sh7785lcr_devices_setup(void) 259c8b5d9dcSPaul Mundt { 260c8b5d9dcSPaul Mundt i2c_register_board_info(0, sh7785lcr_i2c_devices, 261c8b5d9dcSPaul Mundt ARRAY_SIZE(sh7785lcr_i2c_devices)); 262c8b5d9dcSPaul Mundt 263c8b5d9dcSPaul Mundt return platform_add_devices(sh7785lcr_devices, 264c8b5d9dcSPaul Mundt ARRAY_SIZE(sh7785lcr_devices)); 265c8b5d9dcSPaul Mundt } 266c8b5d9dcSPaul Mundt __initcall(sh7785lcr_devices_setup); 267c8b5d9dcSPaul Mundt 268c8b5d9dcSPaul Mundt /* Initialize IRQ setting */ 269c8b5d9dcSPaul Mundt void __init init_sh7785lcr_IRQ(void) 270c8b5d9dcSPaul Mundt { 271c8b5d9dcSPaul Mundt plat_irq_setup_pins(IRQ_MODE_IRQ7654); 272c8b5d9dcSPaul Mundt plat_irq_setup_pins(IRQ_MODE_IRQ3210); 273c8b5d9dcSPaul Mundt } 274c8b5d9dcSPaul Mundt 275c8b5d9dcSPaul Mundt static void sh7785lcr_power_off(void) 276c8b5d9dcSPaul Mundt { 277c8b5d9dcSPaul Mundt ctrl_outb(0x01, P2SEGADDR(PLD_POFCR)); 278c8b5d9dcSPaul Mundt } 279c8b5d9dcSPaul Mundt 280c8b5d9dcSPaul Mundt /* Initialize the board */ 281c8b5d9dcSPaul Mundt static void __init sh7785lcr_setup(char **cmdline_p) 282c8b5d9dcSPaul Mundt { 283c8b5d9dcSPaul Mundt void __iomem *sm501_reg; 284c8b5d9dcSPaul Mundt 285c8b5d9dcSPaul Mundt printk(KERN_INFO "Renesas Technology Corp. R0P7785LC0011RL support.\n"); 286c8b5d9dcSPaul Mundt 287c8b5d9dcSPaul Mundt pm_power_off = sh7785lcr_power_off; 288c8b5d9dcSPaul Mundt 289c8b5d9dcSPaul Mundt /* sm501 DRAM configuration */ 290c8b5d9dcSPaul Mundt sm501_reg = (void __iomem *)0xb3e00000 + SM501_DRAM_CONTROL; 291c8b5d9dcSPaul Mundt writel(0x000307c2, sm501_reg); 292c8b5d9dcSPaul Mundt } 293c8b5d9dcSPaul Mundt 294c8b5d9dcSPaul Mundt /* 295c8b5d9dcSPaul Mundt * The Machine Vector 296c8b5d9dcSPaul Mundt */ 297c8b5d9dcSPaul Mundt static struct sh_machine_vector mv_sh7785lcr __initmv = { 298c8b5d9dcSPaul Mundt .mv_name = "SH7785LCR", 299c8b5d9dcSPaul Mundt .mv_setup = sh7785lcr_setup, 300c8b5d9dcSPaul Mundt .mv_init_irq = init_sh7785lcr_IRQ, 301c8b5d9dcSPaul Mundt }; 302c8b5d9dcSPaul Mundt 303