blob: b10431451f39625afdba2a9e3e754c7db249d786 [file] [log] [blame]
Magnus Damm2b7eda62010-02-05 11:14:58 +00001/*
2 * AP4EVB board support
3 *
4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2008 Yoshihiro Shimoda
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/interrupt.h>
23#include <linux/irq.h>
24#include <linux/platform_device.h>
25#include <linux/delay.h>
26#include <linux/mtd/mtd.h>
27#include <linux/mtd/partitions.h>
28#include <linux/mtd/physmap.h>
Kuninori Morimoto91cf5082010-03-11 10:42:52 +000029#include <linux/i2c.h>
30#include <linux/i2c/tsc2007.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000031#include <linux/io.h>
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000032#include <linux/smsc911x.h>
33#include <linux/gpio.h>
Kuninori Morimoto17ccb832010-02-23 07:07:01 +000034#include <linux/input.h>
35#include <linux/input/sh_keysc.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000036#include <mach/common.h>
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000037#include <mach/sh7372.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000038#include <asm/mach-types.h>
39#include <asm/mach/arch.h>
40#include <asm/mach/map.h>
41
Kuninori Morimoto02624a12010-02-18 17:58:19 +090042/*
43 * Address Interface BusWidth note
44 * ------------------------------------------------------------------
45 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
46 * 0x0800_0000 user area -
47 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
48 * 0x1400_0000 Ether (LAN9220) 16bit
49 * 0x1600_0000 user area - cannot use with NAND
50 * 0x1800_0000 user area -
51 * 0x1A00_0000 -
52 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
53 */
54
55/*
56 * NOR Flash ROM
57 *
58 * SW1 | SW2 | SW7 | NOR Flash ROM
59 * bit1 | bit1 bit2 | bit1 | Memory allocation
60 * ------+------------+------+------------------
61 * OFF | ON OFF | ON | Area 0
62 * OFF | ON OFF | OFF | Area 4
63 */
64
65/*
66 * NAND Flash ROM
67 *
68 * SW1 | SW2 | SW7 | NAND Flash ROM
69 * bit1 | bit1 bit2 | bit2 | Memory allocation
70 * ------+------------+------+------------------
71 * OFF | ON OFF | ON | FCE 0
72 * OFF | ON OFF | OFF | FCE 1
73 */
74
75/*
76 * SMSC 9220
77 *
78 * SW1 SMSC 9220
79 * -----------------------
80 * ON access disable
81 * OFF access enable
82 */
83
Kuninori Morimoto17ccb832010-02-23 07:07:01 +000084/*
85 * KEYSC
86 *
87 * SW43 KEYSC
88 * -------------------------
89 * ON enable
90 * OFF disable
91 */
92
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000093/* MTD */
Magnus Damm2b7eda62010-02-05 11:14:58 +000094static struct mtd_partition nor_flash_partitions[] = {
95 {
96 .name = "loader",
97 .offset = 0x00000000,
98 .size = 512 * 1024,
99 },
100 {
101 .name = "bootenv",
102 .offset = MTDPART_OFS_APPEND,
103 .size = 512 * 1024,
104 },
105 {
106 .name = "kernel_ro",
107 .offset = MTDPART_OFS_APPEND,
108 .size = 8 * 1024 * 1024,
109 .mask_flags = MTD_WRITEABLE,
110 },
111 {
112 .name = "kernel",
113 .offset = MTDPART_OFS_APPEND,
114 .size = 8 * 1024 * 1024,
115 },
116 {
117 .name = "data",
118 .offset = MTDPART_OFS_APPEND,
119 .size = MTDPART_SIZ_FULL,
120 },
121};
122
123static struct physmap_flash_data nor_flash_data = {
124 .width = 2,
125 .parts = nor_flash_partitions,
126 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
127};
128
129static struct resource nor_flash_resources[] = {
130 [0] = {
131 .start = 0x00000000,
132 .end = 0x08000000 - 1,
133 .flags = IORESOURCE_MEM,
134 }
135};
136
137static struct platform_device nor_flash_device = {
138 .name = "physmap-flash",
139 .dev = {
140 .platform_data = &nor_flash_data,
141 },
142 .num_resources = ARRAY_SIZE(nor_flash_resources),
143 .resource = nor_flash_resources,
144};
145
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000146/* SMSC 9220 */
147static struct resource smc911x_resources[] = {
148 {
149 .start = 0x14000000,
150 .end = 0x16000000 - 1,
151 .flags = IORESOURCE_MEM,
152 }, {
153 .start = 6,
154 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
155 },
156};
157
158static struct smsc911x_platform_config smsc911x_info = {
159 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
160 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
161 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
162};
163
164static struct platform_device smc911x_device = {
165 .name = "smsc911x",
166 .id = -1,
167 .num_resources = ARRAY_SIZE(smc911x_resources),
168 .resource = smc911x_resources,
169 .dev = {
170 .platform_data = &smsc911x_info,
171 },
172};
Magnus Damm2b7eda62010-02-05 11:14:58 +0000173
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000174/* KEYSC (Needs SW43 set to ON) */
175static struct sh_keysc_info keysc_info = {
176 .mode = SH_KEYSC_MODE_1,
177 .scan_timing = 3,
178 .delay = 2500,
179 .keycodes = {
180 KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
181 KEY_5, KEY_6, KEY_7, KEY_8, KEY_9,
182 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
183 KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
184 KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
185 },
186};
187
188static struct resource keysc_resources[] = {
189 [0] = {
190 .name = "KEYSC",
191 .start = 0xe61b0000,
192 .end = 0xe61b0063,
193 .flags = IORESOURCE_MEM,
194 },
195 [1] = {
196 .start = 79,
197 .flags = IORESOURCE_IRQ,
198 },
199};
200
201static struct platform_device keysc_device = {
202 .name = "sh_keysc",
203 .id = 0, /* "keysc0" clock */
204 .num_resources = ARRAY_SIZE(keysc_resources),
205 .resource = keysc_resources,
206 .dev = {
207 .platform_data = &keysc_info,
208 },
209};
210
Magnus Damm3a14d032010-03-10 09:26:44 +0000211/* SDHI0 */
212static struct resource sdhi0_resources[] = {
213 [0] = {
214 .name = "SDHI0",
215 .start = 0xe6850000,
216 .end = 0xe68501ff,
217 .flags = IORESOURCE_MEM,
218 },
219 [1] = {
220 .start = 96,
221 .flags = IORESOURCE_IRQ,
222 },
223};
224
225static struct platform_device sdhi0_device = {
226 .name = "sh_mobile_sdhi",
227 .num_resources = ARRAY_SIZE(sdhi0_resources),
228 .resource = sdhi0_resources,
229 .id = 0,
230};
231
Magnus Damm2b7eda62010-02-05 11:14:58 +0000232static struct platform_device *ap4evb_devices[] __initdata = {
233 &nor_flash_device,
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000234 &smc911x_device,
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000235 &keysc_device,
Magnus Damm3a14d032010-03-10 09:26:44 +0000236 &sdhi0_device,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000237};
238
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000239/* TouchScreen */
240#define IRQ28 396
241struct tsc2007_platform_data tsc2007_info = {
242 .model = 2007,
243 .x_plate_ohms = 180,
244};
245
246/* I2C */
247static struct i2c_board_info i2c1_devices[] = {
248 {
249 I2C_BOARD_INFO("tsc2007", 0x48),
250 .type = "tsc2007",
251 .platform_data = &tsc2007_info,
252 .irq = IRQ28,
253 },
254};
255
Magnus Damm2b7eda62010-02-05 11:14:58 +0000256static struct map_desc ap4evb_io_desc[] __initdata = {
257 /* create a 1:1 entity map for 0xe6xxxxxx
258 * used by CPGA, INTC and PFC.
259 */
260 {
261 .virtual = 0xe6000000,
262 .pfn = __phys_to_pfn(0xe6000000),
263 .length = 256 << 20,
264 .type = MT_DEVICE_NONSHARED
265 },
266};
267
268static void __init ap4evb_map_io(void)
269{
270 iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
271
Magnus Damm4ae04ac2010-02-08 11:02:54 +0000272 /* setup early devices, clocks and console here as well */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000273 sh7372_add_early_devices();
274 sh7367_clock_init(); /* use g3 clocks for now */
Magnus Damm4ae04ac2010-02-08 11:02:54 +0000275 shmobile_setup_console();
Magnus Damm2b7eda62010-02-05 11:14:58 +0000276}
277
278static void __init ap4evb_init(void)
279{
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000280 sh7372_pinmux_init();
281
Kuninori Morimotob228b482010-02-18 16:44:41 +0900282 /* enable SCIFA0 */
283 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
284 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
285
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000286 /* enable SMSC911X */
287 gpio_request(GPIO_FN_CS5A, NULL);
288 gpio_request(GPIO_FN_IRQ6_39, NULL);
289
Kuninori Morimoto50982802010-02-22 09:20:39 +0000290 /* enable LED 1 - 4 */
291 gpio_request(GPIO_PORT185, NULL);
292 gpio_request(GPIO_PORT186, NULL);
293 gpio_request(GPIO_PORT187, NULL);
294 gpio_request(GPIO_PORT188, NULL);
295 gpio_direction_output(GPIO_PORT185, 1);
296 gpio_direction_output(GPIO_PORT186, 1);
297 gpio_direction_output(GPIO_PORT187, 1);
298 gpio_direction_output(GPIO_PORT188, 1);
299 gpio_export(GPIO_PORT185, 0);
300 gpio_export(GPIO_PORT186, 0);
301 gpio_export(GPIO_PORT187, 0);
302 gpio_export(GPIO_PORT188, 0);
303
Kuninori Morimoto8cb3a2e2010-02-22 09:30:12 +0000304 /* enable Debug switch (S6) */
305 gpio_request(GPIO_PORT32, NULL);
306 gpio_request(GPIO_PORT33, NULL);
307 gpio_request(GPIO_PORT34, NULL);
308 gpio_request(GPIO_PORT35, NULL);
309 gpio_direction_input(GPIO_PORT32);
310 gpio_direction_input(GPIO_PORT33);
311 gpio_direction_input(GPIO_PORT34);
312 gpio_direction_input(GPIO_PORT35);
313 gpio_export(GPIO_PORT32, 0);
314 gpio_export(GPIO_PORT33, 0);
315 gpio_export(GPIO_PORT34, 0);
316 gpio_export(GPIO_PORT35, 0);
317
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000318 /* enable KEYSC */
319 gpio_request(GPIO_FN_KEYOUT0, NULL);
320 gpio_request(GPIO_FN_KEYOUT1, NULL);
321 gpio_request(GPIO_FN_KEYOUT2, NULL);
322 gpio_request(GPIO_FN_KEYOUT3, NULL);
323 gpio_request(GPIO_FN_KEYOUT4, NULL);
324 gpio_request(GPIO_FN_KEYIN0_136, NULL);
325 gpio_request(GPIO_FN_KEYIN1_135, NULL);
326 gpio_request(GPIO_FN_KEYIN2_134, NULL);
327 gpio_request(GPIO_FN_KEYIN3_133, NULL);
328 gpio_request(GPIO_FN_KEYIN4, NULL);
329
Magnus Damm3a14d032010-03-10 09:26:44 +0000330 /* SDHI0 */
331 gpio_request(GPIO_FN_SDHICD0, NULL);
332 gpio_request(GPIO_FN_SDHIWP0, NULL);
333 gpio_request(GPIO_FN_SDHICMD0, NULL);
334 gpio_request(GPIO_FN_SDHICLK0, NULL);
335 gpio_request(GPIO_FN_SDHID0_3, NULL);
336 gpio_request(GPIO_FN_SDHID0_2, NULL);
337 gpio_request(GPIO_FN_SDHID0_1, NULL);
338 gpio_request(GPIO_FN_SDHID0_0, NULL);
339
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000340 /* enable TouchScreen */
341 gpio_request(GPIO_FN_IRQ28_123, NULL);
342 set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW);
343
344 i2c_register_board_info(1, i2c1_devices,
345 ARRAY_SIZE(i2c1_devices));
346
Magnus Damm2b7eda62010-02-05 11:14:58 +0000347 sh7372_add_standard_devices();
348
349 platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
350}
351
352MACHINE_START(AP4EVB, "ap4evb")
353 .phys_io = 0xe6000000,
354 .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
355 .map_io = ap4evb_map_io,
356 .init_irq = sh7372_init_irq,
357 .init_machine = ap4evb_init,
358 .timer = &shmobile_timer,
359MACHINE_END