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,
33 .irq_flags = IRQF_TRIGGER_HIGH,
36 static struct resource smc91x_eth_resources[] = {
41 .flags = IORESOURCE_MEM,
44 .start = 32, /* IRQ0 */
45 .flags = IORESOURCE_IRQ,
49 static struct platform_device smc91x_eth_device = {
51 .num_resources = ARRAY_SIZE(smc91x_eth_resources),
52 .resource = smc91x_eth_resources,
54 .platform_data = &smc91x_info,
58 static struct sh_keysc_info sh_keysc_info = {
59 .mode = SH_KEYSC_MODE_2, /* KEYOUT0->4, KEYIN1->5 */
63 0, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_ENTER,
64 0, KEY_F, KEY_C, KEY_D, KEY_H, KEY_1,
65 0, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6,
66 0, KEY_7, KEY_8, KEY_9, KEY_S, KEY_0,
67 0, KEY_P, KEY_STOP, KEY_REWIND, KEY_PLAY, KEY_FASTFORWARD,
71 static struct resource sh_keysc_resources[] = {
75 .flags = IORESOURCE_MEM,
79 .flags = IORESOURCE_IRQ,
83 static struct platform_device sh_keysc_device = {
85 .num_resources = ARRAY_SIZE(sh_keysc_resources),
86 .resource = sh_keysc_resources,
88 .platform_data = &sh_keysc_info,
92 static struct mtd_partition migor_nor_flash_partitions[] =
97 .size = (1 * 1024 * 1024),
98 .mask_flags = MTD_WRITEABLE, /* Read-only */
102 .offset = MTDPART_OFS_APPEND,
103 .size = (15 * 1024 * 1024),
107 .offset = MTDPART_OFS_APPEND,
108 .size = MTDPART_SIZ_FULL,
112 static struct physmap_flash_data migor_nor_flash_data = {
114 .parts = migor_nor_flash_partitions,
115 .nr_parts = ARRAY_SIZE(migor_nor_flash_partitions),
118 static struct resource migor_nor_flash_resources[] = {
123 .flags = IORESOURCE_MEM,
127 static struct platform_device migor_nor_flash_device = {
128 .name = "physmap-flash",
129 .resource = migor_nor_flash_resources,
130 .num_resources = ARRAY_SIZE(migor_nor_flash_resources),
132 .platform_data = &migor_nor_flash_data,
136 static struct mtd_partition migor_nand_flash_partitions[] = {
140 .size = 512 * 1024 * 1024,
144 .offset = MTDPART_OFS_APPEND,
145 .size = 512 * 1024 * 1024,
149 static void migor_nand_flash_cmd_ctl(struct mtd_info *mtd, int cmd,
152 struct nand_chip *chip = mtd->priv;
154 if (cmd == NAND_CMD_NONE)
158 writeb(cmd, chip->IO_ADDR_W + 0x00400000);
159 else if (ctrl & NAND_ALE)
160 writeb(cmd, chip->IO_ADDR_W + 0x00800000);
162 writeb(cmd, chip->IO_ADDR_W);
165 static int migor_nand_flash_ready(struct mtd_info *mtd)
167 return ctrl_inb(PORT_PADR) & 0x02; /* PTA1 */
170 struct platform_nand_data migor_nand_flash_data = {
173 .partitions = migor_nand_flash_partitions,
174 .nr_partitions = ARRAY_SIZE(migor_nand_flash_partitions),
176 .part_probe_types = (const char *[]) { "cmdlinepart", NULL },
179 .dev_ready = migor_nand_flash_ready,
180 .cmd_ctrl = migor_nand_flash_cmd_ctl,
184 static struct resource migor_nand_flash_resources[] = {
186 .name = "NAND Flash",
189 .flags = IORESOURCE_MEM,
193 static struct platform_device migor_nand_flash_device = {
195 .resource = migor_nand_flash_resources,
196 .num_resources = ARRAY_SIZE(migor_nand_flash_resources),
198 .platform_data = &migor_nand_flash_data,
202 static struct platform_device *migor_devices[] __initdata = {
205 &migor_nor_flash_device,
206 &migor_nand_flash_device,
209 static struct i2c_board_info __initdata migor_i2c_devices[] = {
211 I2C_BOARD_INFO("rs5c372b", 0x32),
214 I2C_BOARD_INFO("migor_ts", 0x51),
215 .irq = 38, /* IRQ6 */
219 static int __init migor_devices_setup(void)
221 i2c_register_board_info(0, migor_i2c_devices,
222 ARRAY_SIZE(migor_i2c_devices));
224 return platform_add_devices(migor_devices, ARRAY_SIZE(migor_devices));
226 __initcall(migor_devices_setup);
228 static void __init migor_setup(char **cmdline_p)
230 /* SMC91C111 - Enable IRQ0 */
231 ctrl_outw(ctrl_inw(PORT_PJCR) & ~0x0003, PORT_PJCR);
234 ctrl_outw(ctrl_inw(PORT_PYCR) & ~0x0fff, PORT_PYCR);
235 ctrl_outw(ctrl_inw(PORT_PZCR) & ~0x0ff0, PORT_PZCR);
236 ctrl_outw(ctrl_inw(PORT_PSELA) & ~0x4100, PORT_PSELA);
237 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x4000, PORT_HIZCRA);
238 ctrl_outw(ctrl_inw(PORT_HIZCRC) & ~0xc000, PORT_HIZCRC);
239 ctrl_outl(ctrl_inl(MSTPCR2) & ~0x00004000, MSTPCR2);
242 ctrl_outw(ctrl_inw(PORT_PXCR) & 0x0fff, PORT_PXCR);
243 ctrl_outl((ctrl_inl(BSC_CS6ABCR) & ~0x00000600) | 0x00000200,
247 ctrl_outl(ctrl_inl(MSTPCR1) & ~0x00000200, MSTPCR1);
249 /* Touch Panel - Enable IRQ6 */
250 ctrl_outw(ctrl_inw(PORT_PZCR) & ~0xc, PORT_PZCR);
251 ctrl_outw((ctrl_inw(PORT_PSELA) | 0x8000), PORT_PSELA);
252 ctrl_outw((ctrl_inw(PORT_HIZCRC) & ~0x4000), PORT_HIZCRC);
255 static struct sh_machine_vector mv_migor __initmv = {
257 .mv_setup = migor_setup,