blob: 91819fb61b3e81ce1e5e04bc9ae0c8b6d44790bb [file] [log] [blame]
Magnus Damm70f784e2008-02-07 00:38:24 +09001/*
2 * Renesas System Solutions Asia Pte. Ltd - Migo-R
3 *
4 * Copyright (C) 2008 Magnus Damm
5 *
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
8 * for more details.
9 */
10#include <linux/init.h>
11#include <linux/platform_device.h>
12#include <linux/interrupt.h>
Magnus Damm92cfeb62008-03-04 15:23:45 -080013#include <linux/input.h>
Magnus Dammb8808782008-03-21 18:43:55 +090014#include <linux/mtd/physmap.h>
Magnus Damm3c803a92008-03-21 18:44:04 +090015#include <linux/mtd/nand.h>
Magnus Damm0c6111e2008-03-25 17:20:24 +090016#include <linux/i2c.h>
Magnus Damm8a3ee0f2008-04-23 20:13:59 +090017#include <linux/smc91x.h>
Magnus Damm6c7d8262008-07-17 19:16:11 +090018#include <asm/clock.h>
Magnus Damm70f784e2008-02-07 00:38:24 +090019#include <asm/machvec.h>
20#include <asm/io.h>
Magnus Damm92cfeb62008-03-04 15:23:45 -080021#include <asm/sh_keysc.h>
Magnus Damm9db913c2008-03-21 18:43:19 +090022#include <asm/migor.h>
Magnus Damm70f784e2008-02-07 00:38:24 +090023
24/* Address IRQ Size Bus Description
25 * 0x00000000 64MB 16 NOR Flash (SP29PL256N)
26 * 0x0c000000 64MB 64 SDRAM (2xK4M563233G)
27 * 0x10000000 IRQ0 16 Ethernet (SMC91C111)
28 * 0x14000000 IRQ4 16 USB 2.0 Host Controller (M66596)
29 * 0x18000000 8GB 8 NAND Flash (K9K8G08U0A)
30 */
31
Magnus Damm8a3ee0f2008-04-23 20:13:59 +090032static struct smc91x_platdata smc91x_info = {
33 .flags = SMC91X_USE_16BIT,
Magnus Damm8a3ee0f2008-04-23 20:13:59 +090034};
35
Magnus Damm70f784e2008-02-07 00:38:24 +090036static struct resource smc91x_eth_resources[] = {
37 [0] = {
Magnus Dammb026a232008-03-21 18:43:46 +090038 .name = "SMC91C111" ,
39 .start = 0x10000300,
40 .end = 0x1000030f,
Magnus Damm70f784e2008-02-07 00:38:24 +090041 .flags = IORESOURCE_MEM,
42 },
43 [1] = {
44 .start = 32, /* IRQ0 */
Eric Miaod280ead2008-06-06 17:13:02 +080045 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
Magnus Damm70f784e2008-02-07 00:38:24 +090046 },
47};
48
49static struct platform_device smc91x_eth_device = {
50 .name = "smc91x",
51 .num_resources = ARRAY_SIZE(smc91x_eth_resources),
52 .resource = smc91x_eth_resources,
Magnus Damm8a3ee0f2008-04-23 20:13:59 +090053 .dev = {
54 .platform_data = &smc91x_info,
55 },
Magnus Damm70f784e2008-02-07 00:38:24 +090056};
57
Magnus Damm92cfeb62008-03-04 15:23:45 -080058static struct sh_keysc_info sh_keysc_info = {
59 .mode = SH_KEYSC_MODE_2, /* KEYOUT0->4, KEYIN1->5 */
60 .scan_timing = 3,
61 .delay = 5,
62 .keycodes = {
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,
68 },
69};
70
71static struct resource sh_keysc_resources[] = {
72 [0] = {
73 .start = 0x044b0000,
74 .end = 0x044b000f,
75 .flags = IORESOURCE_MEM,
76 },
77 [1] = {
78 .start = 79,
79 .flags = IORESOURCE_IRQ,
80 },
81};
82
83static struct platform_device sh_keysc_device = {
84 .name = "sh_keysc",
85 .num_resources = ARRAY_SIZE(sh_keysc_resources),
86 .resource = sh_keysc_resources,
87 .dev = {
88 .platform_data = &sh_keysc_info,
89 },
90};
91
Magnus Dammb8808782008-03-21 18:43:55 +090092static struct mtd_partition migor_nor_flash_partitions[] =
93{
94 {
95 .name = "uboot",
96 .offset = 0,
97 .size = (1 * 1024 * 1024),
98 .mask_flags = MTD_WRITEABLE, /* Read-only */
99 },
100 {
101 .name = "rootfs",
102 .offset = MTDPART_OFS_APPEND,
103 .size = (15 * 1024 * 1024),
104 },
105 {
106 .name = "other",
107 .offset = MTDPART_OFS_APPEND,
108 .size = MTDPART_SIZ_FULL,
109 },
110};
111
112static struct physmap_flash_data migor_nor_flash_data = {
113 .width = 2,
114 .parts = migor_nor_flash_partitions,
115 .nr_parts = ARRAY_SIZE(migor_nor_flash_partitions),
116};
117
118static struct resource migor_nor_flash_resources[] = {
119 [0] = {
120 .name = "NOR Flash",
121 .start = 0x00000000,
122 .end = 0x03ffffff,
123 .flags = IORESOURCE_MEM,
124 }
125};
126
127static 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),
131 .dev = {
132 .platform_data = &migor_nor_flash_data,
133 },
134};
135
Magnus Damm3c803a92008-03-21 18:44:04 +0900136static struct mtd_partition migor_nand_flash_partitions[] = {
137 {
138 .name = "nanddata1",
139 .offset = 0x0,
140 .size = 512 * 1024 * 1024,
141 },
142 {
143 .name = "nanddata2",
144 .offset = MTDPART_OFS_APPEND,
145 .size = 512 * 1024 * 1024,
146 },
147};
148
149static void migor_nand_flash_cmd_ctl(struct mtd_info *mtd, int cmd,
150 unsigned int ctrl)
151{
152 struct nand_chip *chip = mtd->priv;
153
154 if (cmd == NAND_CMD_NONE)
155 return;
156
157 if (ctrl & NAND_CLE)
158 writeb(cmd, chip->IO_ADDR_W + 0x00400000);
159 else if (ctrl & NAND_ALE)
160 writeb(cmd, chip->IO_ADDR_W + 0x00800000);
161 else
162 writeb(cmd, chip->IO_ADDR_W);
163}
164
165static int migor_nand_flash_ready(struct mtd_info *mtd)
166{
167 return ctrl_inb(PORT_PADR) & 0x02; /* PTA1 */
168}
169
170struct platform_nand_data migor_nand_flash_data = {
171 .chip = {
172 .nr_chips = 1,
173 .partitions = migor_nand_flash_partitions,
174 .nr_partitions = ARRAY_SIZE(migor_nand_flash_partitions),
175 .chip_delay = 20,
176 .part_probe_types = (const char *[]) { "cmdlinepart", NULL },
177 },
178 .ctrl = {
179 .dev_ready = migor_nand_flash_ready,
180 .cmd_ctrl = migor_nand_flash_cmd_ctl,
181 },
182};
183
184static struct resource migor_nand_flash_resources[] = {
185 [0] = {
186 .name = "NAND Flash",
187 .start = 0x18000000,
188 .end = 0x18ffffff,
189 .flags = IORESOURCE_MEM,
190 },
191};
192
193static struct platform_device migor_nand_flash_device = {
194 .name = "gen_nand",
195 .resource = migor_nand_flash_resources,
196 .num_resources = ARRAY_SIZE(migor_nand_flash_resources),
197 .dev = {
198 .platform_data = &migor_nand_flash_data,
199 }
200};
201
Magnus Damm70f784e2008-02-07 00:38:24 +0900202static struct platform_device *migor_devices[] __initdata = {
203 &smc91x_eth_device,
Magnus Damm92cfeb62008-03-04 15:23:45 -0800204 &sh_keysc_device,
Magnus Dammb8808782008-03-21 18:43:55 +0900205 &migor_nor_flash_device,
Magnus Damm3c803a92008-03-21 18:44:04 +0900206 &migor_nand_flash_device,
Magnus Damm70f784e2008-02-07 00:38:24 +0900207};
208
Magnus Damm0c6111e2008-03-25 17:20:24 +0900209static struct i2c_board_info __initdata migor_i2c_devices[] = {
Magnus Damm57795862008-03-25 17:24:31 +0900210 {
Jean Delvare3760f732008-04-29 23:11:40 +0200211 I2C_BOARD_INFO("rs5c372b", 0x32),
Magnus Damm57795862008-03-25 17:24:31 +0900212 },
Magnus Damm67908ab2008-03-25 17:30:45 +0900213 {
214 I2C_BOARD_INFO("migor_ts", 0x51),
215 .irq = 38, /* IRQ6 */
216 },
Magnus Damm0c6111e2008-03-25 17:20:24 +0900217};
218
Magnus Damm70f784e2008-02-07 00:38:24 +0900219static int __init migor_devices_setup(void)
220{
Magnus Damm6c7d8262008-07-17 19:16:11 +0900221 clk_always_enable("mstp214"); /* KEYSC */
222
Magnus Damm0c6111e2008-03-25 17:20:24 +0900223 i2c_register_board_info(0, migor_i2c_devices,
224 ARRAY_SIZE(migor_i2c_devices));
225
Magnus Damm70f784e2008-02-07 00:38:24 +0900226 return platform_add_devices(migor_devices, ARRAY_SIZE(migor_devices));
227}
228__initcall(migor_devices_setup);
229
230static void __init migor_setup(char **cmdline_p)
231{
Magnus Damm92cfeb62008-03-04 15:23:45 -0800232 /* SMC91C111 - Enable IRQ0 */
233 ctrl_outw(ctrl_inw(PORT_PJCR) & ~0x0003, PORT_PJCR);
234
235 /* KEYSC */
236 ctrl_outw(ctrl_inw(PORT_PYCR) & ~0x0fff, PORT_PYCR);
237 ctrl_outw(ctrl_inw(PORT_PZCR) & ~0x0ff0, PORT_PZCR);
238 ctrl_outw(ctrl_inw(PORT_PSELA) & ~0x4100, PORT_PSELA);
239 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x4000, PORT_HIZCRA);
240 ctrl_outw(ctrl_inw(PORT_HIZCRC) & ~0xc000, PORT_HIZCRC);
Magnus Damm3c803a92008-03-21 18:44:04 +0900241
242 /* NAND Flash */
243 ctrl_outw(ctrl_inw(PORT_PXCR) & 0x0fff, PORT_PXCR);
244 ctrl_outl((ctrl_inl(BSC_CS6ABCR) & ~0x00000600) | 0x00000200,
245 BSC_CS6ABCR);
Magnus Damm0c6111e2008-03-25 17:20:24 +0900246
Magnus Damm67908ab2008-03-25 17:30:45 +0900247 /* Touch Panel - Enable IRQ6 */
248 ctrl_outw(ctrl_inw(PORT_PZCR) & ~0xc, PORT_PZCR);
249 ctrl_outw((ctrl_inw(PORT_PSELA) | 0x8000), PORT_PSELA);
250 ctrl_outw((ctrl_inw(PORT_HIZCRC) & ~0x4000), PORT_HIZCRC);
Magnus Damm70f784e2008-02-07 00:38:24 +0900251}
252
253static struct sh_machine_vector mv_migor __initmv = {
254 .mv_name = "Migo-R",
255 .mv_setup = migor_setup,
256};