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 <asm/machvec.h>
19 #include <asm/sh_keysc.h>
20 #include <asm/migor.h>
22 /* Address IRQ Size Bus Description
23 * 0x00000000 64MB 16 NOR Flash (SP29PL256N)
24 * 0x0c000000 64MB 64 SDRAM (2xK4M563233G)
25 * 0x10000000 IRQ0 16 Ethernet (SMC91C111)
26 * 0x14000000 IRQ4 16 USB 2.0 Host Controller (M66596)
27 * 0x18000000 8GB 8 NAND Flash (K9K8G08U0A)
30 static struct resource smc91x_eth_resources
[] = {
35 .flags
= IORESOURCE_MEM
,
38 .start
= 32, /* IRQ0 */
39 .flags
= IORESOURCE_IRQ
| IRQF_TRIGGER_HIGH
,
43 static struct platform_device smc91x_eth_device
= {
45 .num_resources
= ARRAY_SIZE(smc91x_eth_resources
),
46 .resource
= smc91x_eth_resources
,
49 static struct sh_keysc_info sh_keysc_info
= {
50 .mode
= SH_KEYSC_MODE_2
, /* KEYOUT0->4, KEYIN1->5 */
54 0, KEY_UP
, KEY_DOWN
, KEY_LEFT
, KEY_RIGHT
, KEY_ENTER
,
55 0, KEY_F
, KEY_C
, KEY_D
, KEY_H
, KEY_1
,
56 0, KEY_2
, KEY_3
, KEY_4
, KEY_5
, KEY_6
,
57 0, KEY_7
, KEY_8
, KEY_9
, KEY_S
, KEY_0
,
58 0, KEY_P
, KEY_STOP
, KEY_REWIND
, KEY_PLAY
, KEY_FASTFORWARD
,
62 static struct resource sh_keysc_resources
[] = {
66 .flags
= IORESOURCE_MEM
,
70 .flags
= IORESOURCE_IRQ
,
74 static struct platform_device sh_keysc_device
= {
76 .num_resources
= ARRAY_SIZE(sh_keysc_resources
),
77 .resource
= sh_keysc_resources
,
79 .platform_data
= &sh_keysc_info
,
83 static struct mtd_partition migor_nor_flash_partitions
[] =
88 .size
= (1 * 1024 * 1024),
89 .mask_flags
= MTD_WRITEABLE
, /* Read-only */
93 .offset
= MTDPART_OFS_APPEND
,
94 .size
= (15 * 1024 * 1024),
98 .offset
= MTDPART_OFS_APPEND
,
99 .size
= MTDPART_SIZ_FULL
,
103 static struct physmap_flash_data migor_nor_flash_data
= {
105 .parts
= migor_nor_flash_partitions
,
106 .nr_parts
= ARRAY_SIZE(migor_nor_flash_partitions
),
109 static struct resource migor_nor_flash_resources
[] = {
114 .flags
= IORESOURCE_MEM
,
118 static struct platform_device migor_nor_flash_device
= {
119 .name
= "physmap-flash",
120 .resource
= migor_nor_flash_resources
,
121 .num_resources
= ARRAY_SIZE(migor_nor_flash_resources
),
123 .platform_data
= &migor_nor_flash_data
,
127 static struct mtd_partition migor_nand_flash_partitions
[] = {
131 .size
= 512 * 1024 * 1024,
135 .offset
= MTDPART_OFS_APPEND
,
136 .size
= 512 * 1024 * 1024,
140 static void migor_nand_flash_cmd_ctl(struct mtd_info
*mtd
, int cmd
,
143 struct nand_chip
*chip
= mtd
->priv
;
145 if (cmd
== NAND_CMD_NONE
)
149 writeb(cmd
, chip
->IO_ADDR_W
+ 0x00400000);
150 else if (ctrl
& NAND_ALE
)
151 writeb(cmd
, chip
->IO_ADDR_W
+ 0x00800000);
153 writeb(cmd
, chip
->IO_ADDR_W
);
156 static int migor_nand_flash_ready(struct mtd_info
*mtd
)
158 return ctrl_inb(PORT_PADR
) & 0x02; /* PTA1 */
161 struct platform_nand_data migor_nand_flash_data
= {
164 .partitions
= migor_nand_flash_partitions
,
165 .nr_partitions
= ARRAY_SIZE(migor_nand_flash_partitions
),
167 .part_probe_types
= (const char *[]) { "cmdlinepart", NULL
},
170 .dev_ready
= migor_nand_flash_ready
,
171 .cmd_ctrl
= migor_nand_flash_cmd_ctl
,
175 static struct resource migor_nand_flash_resources
[] = {
177 .name
= "NAND Flash",
180 .flags
= IORESOURCE_MEM
,
184 static struct platform_device migor_nand_flash_device
= {
186 .resource
= migor_nand_flash_resources
,
187 .num_resources
= ARRAY_SIZE(migor_nand_flash_resources
),
189 .platform_data
= &migor_nand_flash_data
,
193 static struct platform_device
*migor_devices
[] __initdata
= {
196 &migor_nor_flash_device
,
197 &migor_nand_flash_device
,
200 static struct i2c_board_info __initdata migor_i2c_devices
[] = {
202 I2C_BOARD_INFO("rs5c372b", 0x32),
205 I2C_BOARD_INFO("migor_ts", 0x51),
206 .irq
= 38, /* IRQ6 */
210 static int __init
migor_devices_setup(void)
212 i2c_register_board_info(0, migor_i2c_devices
,
213 ARRAY_SIZE(migor_i2c_devices
));
215 return platform_add_devices(migor_devices
, ARRAY_SIZE(migor_devices
));
217 __initcall(migor_devices_setup
);
219 static void __init
migor_setup(char **cmdline_p
)
221 /* SMC91C111 - Enable IRQ0 */
222 ctrl_outw(ctrl_inw(PORT_PJCR
) & ~0x0003, PORT_PJCR
);
225 ctrl_outw(ctrl_inw(PORT_PYCR
) & ~0x0fff, PORT_PYCR
);
226 ctrl_outw(ctrl_inw(PORT_PZCR
) & ~0x0ff0, PORT_PZCR
);
227 ctrl_outw(ctrl_inw(PORT_PSELA
) & ~0x4100, PORT_PSELA
);
228 ctrl_outw(ctrl_inw(PORT_HIZCRA
) & ~0x4000, PORT_HIZCRA
);
229 ctrl_outw(ctrl_inw(PORT_HIZCRC
) & ~0xc000, PORT_HIZCRC
);
230 ctrl_outl(ctrl_inl(MSTPCR2
) & ~0x00004000, MSTPCR2
);
233 ctrl_outw(ctrl_inw(PORT_PXCR
) & 0x0fff, PORT_PXCR
);
234 ctrl_outl((ctrl_inl(BSC_CS6ABCR
) & ~0x00000600) | 0x00000200,
238 ctrl_outl(ctrl_inl(MSTPCR1
) & ~0x00000200, MSTPCR1
);
240 /* Touch Panel - Enable IRQ6 */
241 ctrl_outw(ctrl_inw(PORT_PZCR
) & ~0xc, PORT_PZCR
);
242 ctrl_outw((ctrl_inw(PORT_PSELA
) | 0x8000), PORT_PSELA
);
243 ctrl_outw((ctrl_inw(PORT_HIZCRC
) & ~0x4000), PORT_HIZCRC
);
246 static struct sh_machine_vector mv_migor __initmv
= {
248 .mv_setup
= migor_setup
,