2 * Renesas Technology Corp. R0P7785LC0011RL Support.
4 * Copyright (C) 2008 Yoshihiro Shimoda
5 * Copyright (C) 2009 Paul Mundt
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/sm501.h>
14 #include <linux/sm501-regs.h>
16 #include <linux/mtd/physmap.h>
17 #include <linux/delay.h>
18 #include <linux/interrupt.h>
19 #include <linux/i2c.h>
20 #include <linux/i2c-pca-platform.h>
21 #include <linux/i2c-algo-pca.h>
22 #include <linux/usb/r8a66597.h>
23 #include <linux/irq.h>
24 #include <linux/clk.h>
25 #include <linux/errno.h>
26 #include <mach/sh7785lcr.h>
27 #include <cpu/sh7785.h>
28 #include <asm/heartbeat.h>
29 #include <asm/clock.h>
32 * NOTE: This board has 2 physical memory maps.
33 * Please look at include/asm-sh/sh7785lcr.h or hardware manual.
35 static struct resource heartbeat_resource = {
38 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
41 static struct platform_device heartbeat_device = {
45 .resource = &heartbeat_resource,
48 static struct mtd_partition nor_flash_partitions[] = {
56 .offset = MTDPART_OFS_APPEND,
61 .offset = MTDPART_OFS_APPEND,
62 .size = 4 * 1024 * 1024,
66 .offset = MTDPART_OFS_APPEND,
67 .size = MTDPART_SIZ_FULL,
71 static struct physmap_flash_data nor_flash_data = {
73 .parts = nor_flash_partitions,
74 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
77 static struct resource nor_flash_resources[] = {
79 .start = NOR_FLASH_ADDR,
80 .end = NOR_FLASH_ADDR + NOR_FLASH_SIZE - 1,
81 .flags = IORESOURCE_MEM,
85 static struct platform_device nor_flash_device = {
86 .name = "physmap-flash",
88 .platform_data = &nor_flash_data,
90 .num_resources = ARRAY_SIZE(nor_flash_resources),
91 .resource = nor_flash_resources,
94 static struct r8a66597_platdata r8a66597_data = {
95 .xtal = R8A66597_PLATDATA_XTAL_12MHZ,
99 static struct resource r8a66597_usb_host_resources[] = {
101 .start = R8A66597_ADDR,
102 .end = R8A66597_ADDR + R8A66597_SIZE - 1,
103 .flags = IORESOURCE_MEM,
108 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
112 static struct platform_device r8a66597_usb_host_device = {
113 .name = "r8a66597_hcd",
117 .coherent_dma_mask = 0xffffffff,
118 .platform_data = &r8a66597_data,
120 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
121 .resource = r8a66597_usb_host_resources,
124 static struct resource sm501_resources[] = {
126 .start = SM107_MEM_ADDR,
127 .end = SM107_MEM_ADDR + SM107_MEM_SIZE - 1,
128 .flags = IORESOURCE_MEM,
131 .start = SM107_REG_ADDR,
132 .end = SM107_REG_ADDR + SM107_REG_SIZE - 1,
133 .flags = IORESOURCE_MEM,
137 .flags = IORESOURCE_IRQ,
141 static struct fb_videomode sm501_default_mode_crt = {
142 .pixclock = 35714, /* 28MHz */
151 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
154 static struct fb_videomode sm501_default_mode_pnl = {
155 .pixclock = 40000, /* 25MHz */
167 static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = {
169 .def_mode = &sm501_default_mode_pnl,
170 .flags = SM501FB_FLAG_USE_INIT_MODE |
171 SM501FB_FLAG_USE_HWCURSOR |
172 SM501FB_FLAG_USE_HWACCEL |
173 SM501FB_FLAG_DISABLE_AT_EXIT |
174 SM501FB_FLAG_PANEL_NO_VBIASEN,
177 static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt = {
179 .def_mode = &sm501_default_mode_crt,
180 .flags = SM501FB_FLAG_USE_INIT_MODE |
181 SM501FB_FLAG_USE_HWCURSOR |
182 SM501FB_FLAG_USE_HWACCEL |
183 SM501FB_FLAG_DISABLE_AT_EXIT,
186 static struct sm501_platdata_fb sm501_fb_pdata = {
187 .fb_route = SM501_FB_OWN,
188 .fb_crt = &sm501_pdata_fbsub_crt,
189 .fb_pnl = &sm501_pdata_fbsub_pnl,
192 static struct sm501_initdata sm501_initdata = {
198 .mclk = 84 * 1000000,
199 .m1xclk = 112 * 1000000,
202 static struct sm501_platdata sm501_platform_data = {
203 .init = &sm501_initdata,
204 .fb = &sm501_fb_pdata,
207 static struct platform_device sm501_device = {
211 .platform_data = &sm501_platform_data,
213 .num_resources = ARRAY_SIZE(sm501_resources),
214 .resource = sm501_resources,
217 static struct resource i2c_proto_resources[] = {
219 .start = PCA9564_PROTO_32BIT_ADDR,
220 .end = PCA9564_PROTO_32BIT_ADDR + PCA9564_SIZE - 1,
221 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
226 .flags = IORESOURCE_IRQ,
230 static struct resource i2c_resources[] = {
232 .start = PCA9564_ADDR,
233 .end = PCA9564_ADDR + PCA9564_SIZE - 1,
234 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
239 .flags = IORESOURCE_IRQ,
243 static struct i2c_pca9564_pf_platform_data i2c_platform_data = {
245 .i2c_clock_speed = I2C_PCA_CON_330kHz,
249 static struct platform_device i2c_device = {
250 .name = "i2c-pca-platform",
253 .platform_data = &i2c_platform_data,
255 .num_resources = ARRAY_SIZE(i2c_resources),
256 .resource = i2c_resources,
259 static struct platform_device *sh7785lcr_devices[] __initdata = {
262 &r8a66597_usb_host_device,
267 static struct i2c_board_info __initdata sh7785lcr_i2c_devices[] = {
269 I2C_BOARD_INFO("r2025sd", 0x32),
273 static int __init sh7785lcr_devices_setup(void)
275 i2c_register_board_info(0, sh7785lcr_i2c_devices,
276 ARRAY_SIZE(sh7785lcr_i2c_devices));
278 if (mach_is_sh7785lcr_pt()) {
279 i2c_device.resource = i2c_proto_resources;
280 i2c_device.num_resources = ARRAY_SIZE(i2c_proto_resources);
283 return platform_add_devices(sh7785lcr_devices,
284 ARRAY_SIZE(sh7785lcr_devices));
286 __initcall(sh7785lcr_devices_setup);
288 /* Initialize IRQ setting */
289 void __init init_sh7785lcr_IRQ(void)
291 plat_irq_setup_pins(IRQ_MODE_IRQ7654);
292 plat_irq_setup_pins(IRQ_MODE_IRQ3210);
295 static int sh7785lcr_clk_init(void)
300 clk = clk_get(NULL, "extal");
301 if (!clk || IS_ERR(clk))
303 ret = clk_set_rate(clk, 33333333);
309 static void sh7785lcr_power_off(void)
313 p = ioremap(PLD_POFCR, PLD_POFCR + 1);
315 printk(KERN_ERR "%s: ioremap error.\n", __func__);
325 /* Initialize the board */
326 static void __init sh7785lcr_setup(char **cmdline_p)
328 void __iomem *sm501_reg;
330 printk(KERN_INFO "Renesas Technology Corp. R0P7785LC0011RL support.\n");
332 pm_power_off = sh7785lcr_power_off;
334 /* sm501 DRAM configuration */
335 sm501_reg = ioremap_fixed(SM107_REG_ADDR, SM501_DRAM_CONTROL,
338 printk(KERN_ERR "%s: ioremap error.\n", __func__);
342 writel(0x000307c2, sm501_reg + SM501_DRAM_CONTROL);
343 iounmap_fixed(sm501_reg);
346 /* Return the board specific boot mode pin configuration */
347 static int sh7785lcr_mode_pins(void)
351 /* These are the factory default settings of S1 and S2.
352 * If you change these dip switches then you will need to
353 * adjust the values below as well.
355 value |= MODE_PIN4; /* Clock Mode 16 */
356 value |= MODE_PIN5; /* 32-bit Area0 bus width */
357 value |= MODE_PIN6; /* 32-bit Area0 bus width */
358 value |= MODE_PIN7; /* Area 0 SRAM interface [fixed] */
359 value |= MODE_PIN8; /* Little Endian */
360 value |= MODE_PIN9; /* Master Mode */
361 value |= MODE_PIN14; /* No PLL step-up */
369 static struct sh_machine_vector mv_sh7785lcr __initmv = {
370 .mv_name = "SH7785LCR",
371 .mv_setup = sh7785lcr_setup,
372 .mv_clk_init = sh7785lcr_clk_init,
373 .mv_init_irq = init_sh7785lcr_IRQ,
374 .mv_mode_pins = sh7785lcr_mode_pins,