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/machvec.h>
20 #include <asm/sh_keysc.h>
21 #include <asm/migor.h>
23 /* Address IRQ Size Bus Description
24 * 0x00000000 64MB 16 NOR Flash (SP29PL256N)
25 * 0x0c000000 64MB 64 SDRAM (2xK4M563233G)
26 * 0x10000000 IRQ0 16 Ethernet (SMC91C111)
27 * 0x14000000 IRQ4 16 USB 2.0 Host Controller (M66596)
28 * 0x18000000 8GB 8 NAND Flash (K9K8G08U0A)
31 static struct smc91x_platdata smc91x_info = {
32 .flags = SMC91X_USE_16BIT,
35 static struct resource smc91x_eth_resources[] = {
40 .flags = IORESOURCE_MEM,
43 .start = 32, /* IRQ0 */
44 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
48 static struct platform_device smc91x_eth_device = {
50 .num_resources = ARRAY_SIZE(smc91x_eth_resources),
51 .resource = smc91x_eth_resources,
53 .platform_data = &smc91x_info,
57 static struct sh_keysc_info sh_keysc_info = {
58 .mode = SH_KEYSC_MODE_2, /* KEYOUT0->4, KEYIN1->5 */
62 0, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_ENTER,
63 0, KEY_F, KEY_C, KEY_D, KEY_H, KEY_1,
64 0, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6,
65 0, KEY_7, KEY_8, KEY_9, KEY_S, KEY_0,
66 0, KEY_P, KEY_STOP, KEY_REWIND, KEY_PLAY, KEY_FASTFORWARD,
70 static struct resource sh_keysc_resources[] = {
74 .flags = IORESOURCE_MEM,
78 .flags = IORESOURCE_IRQ,
82 static struct platform_device sh_keysc_device = {
84 .num_resources = ARRAY_SIZE(sh_keysc_resources),
85 .resource = sh_keysc_resources,
87 .platform_data = &sh_keysc_info,
91 static struct mtd_partition migor_nor_flash_partitions[] =
96 .size = (1 * 1024 * 1024),
97 .mask_flags = MTD_WRITEABLE, /* Read-only */
101 .offset = MTDPART_OFS_APPEND,
102 .size = (15 * 1024 * 1024),
106 .offset = MTDPART_OFS_APPEND,
107 .size = MTDPART_SIZ_FULL,
111 static struct physmap_flash_data migor_nor_flash_data = {
113 .parts = migor_nor_flash_partitions,
114 .nr_parts = ARRAY_SIZE(migor_nor_flash_partitions),
117 static struct resource migor_nor_flash_resources[] = {
122 .flags = IORESOURCE_MEM,
126 static struct platform_device migor_nor_flash_device = {
127 .name = "physmap-flash",
128 .resource = migor_nor_flash_resources,
129 .num_resources = ARRAY_SIZE(migor_nor_flash_resources),
131 .platform_data = &migor_nor_flash_data,
135 static struct mtd_partition migor_nand_flash_partitions[] = {
139 .size = 512 * 1024 * 1024,
143 .offset = MTDPART_OFS_APPEND,
144 .size = 512 * 1024 * 1024,
148 static void migor_nand_flash_cmd_ctl(struct mtd_info *mtd, int cmd,
151 struct nand_chip *chip = mtd->priv;
153 if (cmd == NAND_CMD_NONE)
157 writeb(cmd, chip->IO_ADDR_W + 0x00400000);
158 else if (ctrl & NAND_ALE)
159 writeb(cmd, chip->IO_ADDR_W + 0x00800000);
161 writeb(cmd, chip->IO_ADDR_W);
164 static int migor_nand_flash_ready(struct mtd_info *mtd)
166 return ctrl_inb(PORT_PADR) & 0x02; /* PTA1 */
169 struct platform_nand_data migor_nand_flash_data = {
172 .partitions = migor_nand_flash_partitions,
173 .nr_partitions = ARRAY_SIZE(migor_nand_flash_partitions),
175 .part_probe_types = (const char *[]) { "cmdlinepart", NULL },
178 .dev_ready = migor_nand_flash_ready,
179 .cmd_ctrl = migor_nand_flash_cmd_ctl,
183 static struct resource migor_nand_flash_resources[] = {
185 .name = "NAND Flash",
188 .flags = IORESOURCE_MEM,
192 static struct platform_device migor_nand_flash_device = {
194 .resource = migor_nand_flash_resources,
195 .num_resources = ARRAY_SIZE(migor_nand_flash_resources),
197 .platform_data = &migor_nand_flash_data,
201 static struct platform_device *migor_devices[] __initdata = {
204 &migor_nor_flash_device,
205 &migor_nand_flash_device,
208 static struct i2c_board_info __initdata migor_i2c_devices[] = {
210 I2C_BOARD_INFO("rs5c372b", 0x32),
213 I2C_BOARD_INFO("migor_ts", 0x51),
214 .irq = 38, /* IRQ6 */
218 static int __init migor_devices_setup(void)
220 i2c_register_board_info(0, migor_i2c_devices,
221 ARRAY_SIZE(migor_i2c_devices));
223 return platform_add_devices(migor_devices, ARRAY_SIZE(migor_devices));
225 __initcall(migor_devices_setup);
227 static void __init migor_setup(char **cmdline_p)
229 /* SMC91C111 - Enable IRQ0 */
230 ctrl_outw(ctrl_inw(PORT_PJCR) & ~0x0003, PORT_PJCR);
233 ctrl_outw(ctrl_inw(PORT_PYCR) & ~0x0fff, PORT_PYCR);
234 ctrl_outw(ctrl_inw(PORT_PZCR) & ~0x0ff0, PORT_PZCR);
235 ctrl_outw(ctrl_inw(PORT_PSELA) & ~0x4100, PORT_PSELA);
236 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x4000, PORT_HIZCRA);
237 ctrl_outw(ctrl_inw(PORT_HIZCRC) & ~0xc000, PORT_HIZCRC);
238 ctrl_outl(ctrl_inl(MSTPCR2) & ~0x00004000, MSTPCR2);
241 ctrl_outw(ctrl_inw(PORT_PXCR) & 0x0fff, PORT_PXCR);
242 ctrl_outl((ctrl_inl(BSC_CS6ABCR) & ~0x00000600) | 0x00000200,
246 ctrl_outl(ctrl_inl(MSTPCR1) & ~0x00000200, MSTPCR1);
248 /* Touch Panel - Enable IRQ6 */
249 ctrl_outw(ctrl_inw(PORT_PZCR) & ~0xc, PORT_PZCR);
250 ctrl_outw((ctrl_inw(PORT_PSELA) | 0x8000), PORT_PSELA);
251 ctrl_outw((ctrl_inw(PORT_HIZCRC) & ~0x4000), PORT_HIZCRC);
254 static struct sh_machine_vector mv_migor __initmv = {
256 .mv_setup = migor_setup,