2 * Renesas System Solutions Asia Pte. Ltd - Migo-R
4 * Copyright (C) 2008 Magnus Damm
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
10 #include <linux/init.h>
11 #include <linux/platform_device.h>
12 #include <linux/interrupt.h>
13 #include <linux/input.h>
14 #include <linux/mtd/physmap.h>
15 #include <linux/mtd/nand.h>
16 #include <linux/i2c.h>
17 #include <linux/smc91x.h>
18 #include <asm/clock.h>
19 #include <asm/machvec.h>
21 #include <asm/sh_keysc.h>
22 #include <asm/sh_mobile_lcdc.h>
23 #include <asm/migor.h>
25 /* Address IRQ Size Bus Description
26 * 0x00000000 64MB 16 NOR Flash (SP29PL256N)
27 * 0x0c000000 64MB 64 SDRAM (2xK4M563233G)
28 * 0x10000000 IRQ0 16 Ethernet (SMC91C111)
29 * 0x14000000 IRQ4 16 USB 2.0 Host Controller (M66596)
30 * 0x18000000 8GB 8 NAND Flash (K9K8G08U0A)
33 static struct smc91x_platdata smc91x_info = {
34 .flags = SMC91X_USE_16BIT,
37 static struct resource smc91x_eth_resources[] = {
42 .flags = IORESOURCE_MEM,
45 .start = 32, /* IRQ0 */
46 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
50 static struct platform_device smc91x_eth_device = {
52 .num_resources = ARRAY_SIZE(smc91x_eth_resources),
53 .resource = smc91x_eth_resources,
55 .platform_data = &smc91x_info,
59 static struct sh_keysc_info sh_keysc_info = {
60 .mode = SH_KEYSC_MODE_2, /* KEYOUT0->4, KEYIN1->5 */
64 0, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_ENTER,
65 0, KEY_F, KEY_C, KEY_D, KEY_H, KEY_1,
66 0, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6,
67 0, KEY_7, KEY_8, KEY_9, KEY_S, KEY_0,
68 0, KEY_P, KEY_STOP, KEY_REWIND, KEY_PLAY, KEY_FASTFORWARD,
72 static struct resource sh_keysc_resources[] = {
76 .flags = IORESOURCE_MEM,
80 .flags = IORESOURCE_IRQ,
84 static struct platform_device sh_keysc_device = {
86 .num_resources = ARRAY_SIZE(sh_keysc_resources),
87 .resource = sh_keysc_resources,
89 .platform_data = &sh_keysc_info,
93 static struct mtd_partition migor_nor_flash_partitions[] =
98 .size = (1 * 1024 * 1024),
99 .mask_flags = MTD_WRITEABLE, /* Read-only */
103 .offset = MTDPART_OFS_APPEND,
104 .size = (15 * 1024 * 1024),
108 .offset = MTDPART_OFS_APPEND,
109 .size = MTDPART_SIZ_FULL,
113 static struct physmap_flash_data migor_nor_flash_data = {
115 .parts = migor_nor_flash_partitions,
116 .nr_parts = ARRAY_SIZE(migor_nor_flash_partitions),
119 static struct resource migor_nor_flash_resources[] = {
124 .flags = IORESOURCE_MEM,
128 static struct platform_device migor_nor_flash_device = {
129 .name = "physmap-flash",
130 .resource = migor_nor_flash_resources,
131 .num_resources = ARRAY_SIZE(migor_nor_flash_resources),
133 .platform_data = &migor_nor_flash_data,
137 static struct mtd_partition migor_nand_flash_partitions[] = {
141 .size = 512 * 1024 * 1024,
145 .offset = MTDPART_OFS_APPEND,
146 .size = 512 * 1024 * 1024,
150 static void migor_nand_flash_cmd_ctl(struct mtd_info *mtd, int cmd,
153 struct nand_chip *chip = mtd->priv;
155 if (cmd == NAND_CMD_NONE)
159 writeb(cmd, chip->IO_ADDR_W + 0x00400000);
160 else if (ctrl & NAND_ALE)
161 writeb(cmd, chip->IO_ADDR_W + 0x00800000);
163 writeb(cmd, chip->IO_ADDR_W);
166 static int migor_nand_flash_ready(struct mtd_info *mtd)
168 return ctrl_inb(PORT_PADR) & 0x02; /* PTA1 */
171 struct platform_nand_data migor_nand_flash_data = {
174 .partitions = migor_nand_flash_partitions,
175 .nr_partitions = ARRAY_SIZE(migor_nand_flash_partitions),
177 .part_probe_types = (const char *[]) { "cmdlinepart", NULL },
180 .dev_ready = migor_nand_flash_ready,
181 .cmd_ctrl = migor_nand_flash_cmd_ctl,
185 static struct resource migor_nand_flash_resources[] = {
187 .name = "NAND Flash",
190 .flags = IORESOURCE_MEM,
194 static struct platform_device migor_nand_flash_device = {
196 .resource = migor_nand_flash_resources,
197 .num_resources = ARRAY_SIZE(migor_nand_flash_resources),
199 .platform_data = &migor_nand_flash_data,
203 static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = {
204 #ifdef CONFIG_SH_MIGOR_RTA_WVGA
205 .clock_source = LCDC_CLK_BUS,
207 .chan = LCDC_CHAN_MAINLCD,
209 .interface_type = RGB16,
225 #ifdef CONFIG_SH_MIGOR_QVGA
226 .clock_source = LCDC_CLK_PERIPHERAL,
228 .chan = LCDC_CHAN_MAINLCD,
230 .interface_type = SYS16A,
242 .sync = FB_SYNC_HOR_HIGH_ACT,
245 .setup_sys = migor_lcd_qvga_setup,
248 .ldmt2r = 0x06000a09,
249 .ldmt3r = 0x180e3418,
255 static struct resource migor_lcdc_resources[] = {
258 .start = 0xfe940000, /* P4-only space */
260 .flags = IORESOURCE_MEM,
264 static struct platform_device migor_lcdc_device = {
265 .name = "sh_mobile_lcdc_fb",
266 .num_resources = ARRAY_SIZE(migor_lcdc_resources),
267 .resource = migor_lcdc_resources,
269 .platform_data = &sh_mobile_lcdc_info,
273 static struct platform_device *migor_devices[] __initdata = {
277 &migor_nor_flash_device,
278 &migor_nand_flash_device,
281 static struct i2c_board_info __initdata migor_i2c_devices[] = {
283 I2C_BOARD_INFO("rs5c372b", 0x32),
286 I2C_BOARD_INFO("migor_ts", 0x51),
287 .irq = 38, /* IRQ6 */
291 static int __init migor_devices_setup(void)
293 clk_always_enable("mstp214"); /* KEYSC */
294 clk_always_enable("mstp200"); /* LCDC */
296 i2c_register_board_info(0, migor_i2c_devices,
297 ARRAY_SIZE(migor_i2c_devices));
299 return platform_add_devices(migor_devices, ARRAY_SIZE(migor_devices));
301 __initcall(migor_devices_setup);
303 static void __init migor_setup(char **cmdline_p)
305 /* SMC91C111 - Enable IRQ0 */
306 ctrl_outw(ctrl_inw(PORT_PJCR) & ~0x0003, PORT_PJCR);
309 ctrl_outw(ctrl_inw(PORT_PYCR) & ~0x0fff, PORT_PYCR);
310 ctrl_outw(ctrl_inw(PORT_PZCR) & ~0x0ff0, PORT_PZCR);
311 ctrl_outw(ctrl_inw(PORT_PSELA) & ~0x4100, PORT_PSELA);
312 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x4000, PORT_HIZCRA);
313 ctrl_outw(ctrl_inw(PORT_HIZCRC) & ~0xc000, PORT_HIZCRC);
316 ctrl_outw(ctrl_inw(PORT_PXCR) & 0x0fff, PORT_PXCR);
317 ctrl_outl((ctrl_inl(BSC_CS6ABCR) & ~0x00000600) | 0x00000200,
320 /* Touch Panel - Enable IRQ6 */
321 ctrl_outw(ctrl_inw(PORT_PZCR) & ~0xc, PORT_PZCR);
322 ctrl_outw((ctrl_inw(PORT_PSELA) | 0x8000), PORT_PSELA);
323 ctrl_outw((ctrl_inw(PORT_HIZCRC) & ~0x4000), PORT_HIZCRC);
325 #ifdef CONFIG_SH_MIGOR_RTA_WVGA
326 /* LCDC - WVGA - Enable RGB Interface signals */
327 ctrl_outw(ctrl_inw(PORT_PACR) & ~0x0003, PORT_PACR);
328 ctrl_outw(0x0000, PORT_PHCR);
329 ctrl_outw(0x0000, PORT_PLCR);
330 ctrl_outw(0x0000, PORT_PMCR);
331 ctrl_outw(ctrl_inw(PORT_PRCR) & ~0x000f, PORT_PRCR);
332 ctrl_outw((ctrl_inw(PORT_PSELD) & ~0x000d) | 0x0400, PORT_PSELD);
333 ctrl_outw(ctrl_inw(PORT_MSELCRB) & ~0x0100, PORT_MSELCRB);
334 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x01e0, PORT_HIZCRA);
336 #ifdef CONFIG_SH_MIGOR_QVGA
337 /* LCDC - QVGA - Enable SYS Interface signals */
338 ctrl_outw(ctrl_inw(PORT_PACR) & ~0x0003, PORT_PACR);
339 ctrl_outw((ctrl_inw(PORT_PHCR) & ~0xcfff) | 0x0010, PORT_PHCR);
340 ctrl_outw(0x0000, PORT_PLCR);
341 ctrl_outw(0x0000, PORT_PMCR);
342 ctrl_outw(ctrl_inw(PORT_PRCR) & ~0x030f, PORT_PRCR);
343 ctrl_outw((ctrl_inw(PORT_PSELD) & ~0x0001) | 0x0420, PORT_PSELD);
344 ctrl_outw(ctrl_inw(PORT_MSELCRB) | 0x0100, PORT_MSELCRB);
345 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x01e0, PORT_HIZCRA);
349 static struct sh_machine_vector mv_migor __initmv = {
351 .mv_setup = migor_setup,