blob: 1c2ec96ce2610c88a9292b7edcf6adc1f390b808 [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>
29#include <linux/io.h>
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000030#include <linux/smsc911x.h>
31#include <linux/gpio.h>
Kuninori Morimoto17ccb832010-02-23 07:07:01 +000032#include <linux/input.h>
33#include <linux/input/sh_keysc.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000034#include <mach/common.h>
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000035#include <mach/sh7372.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000036#include <asm/mach-types.h>
37#include <asm/mach/arch.h>
38#include <asm/mach/map.h>
39
Kuninori Morimoto02624a12010-02-18 17:58:19 +090040/*
41 * Address Interface BusWidth note
42 * ------------------------------------------------------------------
43 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
44 * 0x0800_0000 user area -
45 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
46 * 0x1400_0000 Ether (LAN9220) 16bit
47 * 0x1600_0000 user area - cannot use with NAND
48 * 0x1800_0000 user area -
49 * 0x1A00_0000 -
50 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
51 */
52
53/*
54 * NOR Flash ROM
55 *
56 * SW1 | SW2 | SW7 | NOR Flash ROM
57 * bit1 | bit1 bit2 | bit1 | Memory allocation
58 * ------+------------+------+------------------
59 * OFF | ON OFF | ON | Area 0
60 * OFF | ON OFF | OFF | Area 4
61 */
62
63/*
64 * NAND Flash ROM
65 *
66 * SW1 | SW2 | SW7 | NAND Flash ROM
67 * bit1 | bit1 bit2 | bit2 | Memory allocation
68 * ------+------------+------+------------------
69 * OFF | ON OFF | ON | FCE 0
70 * OFF | ON OFF | OFF | FCE 1
71 */
72
73/*
74 * SMSC 9220
75 *
76 * SW1 SMSC 9220
77 * -----------------------
78 * ON access disable
79 * OFF access enable
80 */
81
Kuninori Morimoto17ccb832010-02-23 07:07:01 +000082/*
83 * KEYSC
84 *
85 * SW43 KEYSC
86 * -------------------------
87 * ON enable
88 * OFF disable
89 */
90
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000091/* MTD */
Magnus Damm2b7eda62010-02-05 11:14:58 +000092static struct mtd_partition nor_flash_partitions[] = {
93 {
94 .name = "loader",
95 .offset = 0x00000000,
96 .size = 512 * 1024,
97 },
98 {
99 .name = "bootenv",
100 .offset = MTDPART_OFS_APPEND,
101 .size = 512 * 1024,
102 },
103 {
104 .name = "kernel_ro",
105 .offset = MTDPART_OFS_APPEND,
106 .size = 8 * 1024 * 1024,
107 .mask_flags = MTD_WRITEABLE,
108 },
109 {
110 .name = "kernel",
111 .offset = MTDPART_OFS_APPEND,
112 .size = 8 * 1024 * 1024,
113 },
114 {
115 .name = "data",
116 .offset = MTDPART_OFS_APPEND,
117 .size = MTDPART_SIZ_FULL,
118 },
119};
120
121static struct physmap_flash_data nor_flash_data = {
122 .width = 2,
123 .parts = nor_flash_partitions,
124 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
125};
126
127static struct resource nor_flash_resources[] = {
128 [0] = {
129 .start = 0x00000000,
130 .end = 0x08000000 - 1,
131 .flags = IORESOURCE_MEM,
132 }
133};
134
135static struct platform_device nor_flash_device = {
136 .name = "physmap-flash",
137 .dev = {
138 .platform_data = &nor_flash_data,
139 },
140 .num_resources = ARRAY_SIZE(nor_flash_resources),
141 .resource = nor_flash_resources,
142};
143
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000144/* SMSC 9220 */
145static struct resource smc911x_resources[] = {
146 {
147 .start = 0x14000000,
148 .end = 0x16000000 - 1,
149 .flags = IORESOURCE_MEM,
150 }, {
151 .start = 6,
152 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
153 },
154};
155
156static struct smsc911x_platform_config smsc911x_info = {
157 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
158 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
159 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
160};
161
162static struct platform_device smc911x_device = {
163 .name = "smsc911x",
164 .id = -1,
165 .num_resources = ARRAY_SIZE(smc911x_resources),
166 .resource = smc911x_resources,
167 .dev = {
168 .platform_data = &smsc911x_info,
169 },
170};
Magnus Damm2b7eda62010-02-05 11:14:58 +0000171
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000172/* KEYSC (Needs SW43 set to ON) */
173static struct sh_keysc_info keysc_info = {
174 .mode = SH_KEYSC_MODE_1,
175 .scan_timing = 3,
176 .delay = 2500,
177 .keycodes = {
178 KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
179 KEY_5, KEY_6, KEY_7, KEY_8, KEY_9,
180 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
181 KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
182 KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
183 },
184};
185
186static struct resource keysc_resources[] = {
187 [0] = {
188 .name = "KEYSC",
189 .start = 0xe61b0000,
190 .end = 0xe61b0063,
191 .flags = IORESOURCE_MEM,
192 },
193 [1] = {
194 .start = 79,
195 .flags = IORESOURCE_IRQ,
196 },
197};
198
199static struct platform_device keysc_device = {
200 .name = "sh_keysc",
201 .id = 0, /* "keysc0" clock */
202 .num_resources = ARRAY_SIZE(keysc_resources),
203 .resource = keysc_resources,
204 .dev = {
205 .platform_data = &keysc_info,
206 },
207};
208
Magnus Damm3a14d032010-03-10 09:26:44 +0000209/* SDHI0 */
210static struct resource sdhi0_resources[] = {
211 [0] = {
212 .name = "SDHI0",
213 .start = 0xe6850000,
214 .end = 0xe68501ff,
215 .flags = IORESOURCE_MEM,
216 },
217 [1] = {
218 .start = 96,
219 .flags = IORESOURCE_IRQ,
220 },
221};
222
223static struct platform_device sdhi0_device = {
224 .name = "sh_mobile_sdhi",
225 .num_resources = ARRAY_SIZE(sdhi0_resources),
226 .resource = sdhi0_resources,
227 .id = 0,
228};
229
Magnus Damm2b7eda62010-02-05 11:14:58 +0000230static struct platform_device *ap4evb_devices[] __initdata = {
231 &nor_flash_device,
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000232 &smc911x_device,
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000233 &keysc_device,
Magnus Damm3a14d032010-03-10 09:26:44 +0000234 &sdhi0_device,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000235};
236
237static struct map_desc ap4evb_io_desc[] __initdata = {
238 /* create a 1:1 entity map for 0xe6xxxxxx
239 * used by CPGA, INTC and PFC.
240 */
241 {
242 .virtual = 0xe6000000,
243 .pfn = __phys_to_pfn(0xe6000000),
244 .length = 256 << 20,
245 .type = MT_DEVICE_NONSHARED
246 },
247};
248
249static void __init ap4evb_map_io(void)
250{
251 iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
252
Magnus Damm4ae04ac2010-02-08 11:02:54 +0000253 /* setup early devices, clocks and console here as well */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000254 sh7372_add_early_devices();
255 sh7367_clock_init(); /* use g3 clocks for now */
Magnus Damm4ae04ac2010-02-08 11:02:54 +0000256 shmobile_setup_console();
Magnus Damm2b7eda62010-02-05 11:14:58 +0000257}
258
259static void __init ap4evb_init(void)
260{
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000261 sh7372_pinmux_init();
262
Kuninori Morimotob228b482010-02-18 16:44:41 +0900263 /* enable SCIFA0 */
264 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
265 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
266
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000267 /* enable SMSC911X */
268 gpio_request(GPIO_FN_CS5A, NULL);
269 gpio_request(GPIO_FN_IRQ6_39, NULL);
270
Kuninori Morimoto50982802010-02-22 09:20:39 +0000271 /* enable LED 1 - 4 */
272 gpio_request(GPIO_PORT185, NULL);
273 gpio_request(GPIO_PORT186, NULL);
274 gpio_request(GPIO_PORT187, NULL);
275 gpio_request(GPIO_PORT188, NULL);
276 gpio_direction_output(GPIO_PORT185, 1);
277 gpio_direction_output(GPIO_PORT186, 1);
278 gpio_direction_output(GPIO_PORT187, 1);
279 gpio_direction_output(GPIO_PORT188, 1);
280 gpio_export(GPIO_PORT185, 0);
281 gpio_export(GPIO_PORT186, 0);
282 gpio_export(GPIO_PORT187, 0);
283 gpio_export(GPIO_PORT188, 0);
284
Kuninori Morimoto8cb3a2e2010-02-22 09:30:12 +0000285 /* enable Debug switch (S6) */
286 gpio_request(GPIO_PORT32, NULL);
287 gpio_request(GPIO_PORT33, NULL);
288 gpio_request(GPIO_PORT34, NULL);
289 gpio_request(GPIO_PORT35, NULL);
290 gpio_direction_input(GPIO_PORT32);
291 gpio_direction_input(GPIO_PORT33);
292 gpio_direction_input(GPIO_PORT34);
293 gpio_direction_input(GPIO_PORT35);
294 gpio_export(GPIO_PORT32, 0);
295 gpio_export(GPIO_PORT33, 0);
296 gpio_export(GPIO_PORT34, 0);
297 gpio_export(GPIO_PORT35, 0);
298
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000299 /* enable KEYSC */
300 gpio_request(GPIO_FN_KEYOUT0, NULL);
301 gpio_request(GPIO_FN_KEYOUT1, NULL);
302 gpio_request(GPIO_FN_KEYOUT2, NULL);
303 gpio_request(GPIO_FN_KEYOUT3, NULL);
304 gpio_request(GPIO_FN_KEYOUT4, NULL);
305 gpio_request(GPIO_FN_KEYIN0_136, NULL);
306 gpio_request(GPIO_FN_KEYIN1_135, NULL);
307 gpio_request(GPIO_FN_KEYIN2_134, NULL);
308 gpio_request(GPIO_FN_KEYIN3_133, NULL);
309 gpio_request(GPIO_FN_KEYIN4, NULL);
310
Magnus Damm3a14d032010-03-10 09:26:44 +0000311 /* SDHI0 */
312 gpio_request(GPIO_FN_SDHICD0, NULL);
313 gpio_request(GPIO_FN_SDHIWP0, NULL);
314 gpio_request(GPIO_FN_SDHICMD0, NULL);
315 gpio_request(GPIO_FN_SDHICLK0, NULL);
316 gpio_request(GPIO_FN_SDHID0_3, NULL);
317 gpio_request(GPIO_FN_SDHID0_2, NULL);
318 gpio_request(GPIO_FN_SDHID0_1, NULL);
319 gpio_request(GPIO_FN_SDHID0_0, NULL);
320
Magnus Damm2b7eda62010-02-05 11:14:58 +0000321 sh7372_add_standard_devices();
322
323 platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
324}
325
326MACHINE_START(AP4EVB, "ap4evb")
327 .phys_io = 0xe6000000,
328 .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
329 .map_io = ap4evb_map_io,
330 .init_irq = sh7372_init_irq,
331 .init_machine = ap4evb_init,
332 .timer = &shmobile_timer,
333MACHINE_END