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