]>
Commit | Line | Data |
---|---|---|
2b7eda63 MD |
1 | /* |
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> | |
91cf5082 KM |
29 | #include <linux/i2c.h> |
30 | #include <linux/i2c/tsc2007.h> | |
2b7eda63 | 31 | #include <linux/io.h> |
1b7e0677 KM |
32 | #include <linux/smsc911x.h> |
33 | #include <linux/gpio.h> | |
17ccb834 KM |
34 | #include <linux/input.h> |
35 | #include <linux/input/sh_keysc.h> | |
2b7eda63 | 36 | #include <mach/common.h> |
1b7e0677 | 37 | #include <mach/sh7372.h> |
2b7eda63 MD |
38 | #include <asm/mach-types.h> |
39 | #include <asm/mach/arch.h> | |
40 | #include <asm/mach/map.h> | |
41 | ||
02624a17 KM |
42 | /* |
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 | ||
17ccb834 | 84 | /* |
dda128dc | 85 | * LCD / IRQ / KEYSC / IrDA |
17ccb834 | 86 | * |
dda128dc KM |
87 | * IRQ = IRQ26 (TS), IRQ27 (VIO), IRQ28 (TouchScreen) |
88 | * LCD = 2nd LCDC | |
89 | * | |
90 | * | SW43 | | |
91 | * SW3 | ON | OFF | | |
92 | * -------------+-----------------------+---------------+ | |
93 | * ON | KEY / IrDA | LCD | | |
94 | * OFF | KEY / IrDA / IRQ | IRQ | | |
17ccb834 KM |
95 | */ |
96 | ||
1b7e0677 | 97 | /* MTD */ |
2b7eda63 MD |
98 | static struct mtd_partition nor_flash_partitions[] = { |
99 | { | |
100 | .name = "loader", | |
101 | .offset = 0x00000000, | |
102 | .size = 512 * 1024, | |
103 | }, | |
104 | { | |
105 | .name = "bootenv", | |
106 | .offset = MTDPART_OFS_APPEND, | |
107 | .size = 512 * 1024, | |
108 | }, | |
109 | { | |
110 | .name = "kernel_ro", | |
111 | .offset = MTDPART_OFS_APPEND, | |
112 | .size = 8 * 1024 * 1024, | |
113 | .mask_flags = MTD_WRITEABLE, | |
114 | }, | |
115 | { | |
116 | .name = "kernel", | |
117 | .offset = MTDPART_OFS_APPEND, | |
118 | .size = 8 * 1024 * 1024, | |
119 | }, | |
120 | { | |
121 | .name = "data", | |
122 | .offset = MTDPART_OFS_APPEND, | |
123 | .size = MTDPART_SIZ_FULL, | |
124 | }, | |
125 | }; | |
126 | ||
127 | static struct physmap_flash_data nor_flash_data = { | |
128 | .width = 2, | |
129 | .parts = nor_flash_partitions, | |
130 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), | |
131 | }; | |
132 | ||
133 | static struct resource nor_flash_resources[] = { | |
134 | [0] = { | |
135 | .start = 0x00000000, | |
136 | .end = 0x08000000 - 1, | |
137 | .flags = IORESOURCE_MEM, | |
138 | } | |
139 | }; | |
140 | ||
141 | static struct platform_device nor_flash_device = { | |
142 | .name = "physmap-flash", | |
143 | .dev = { | |
144 | .platform_data = &nor_flash_data, | |
145 | }, | |
146 | .num_resources = ARRAY_SIZE(nor_flash_resources), | |
147 | .resource = nor_flash_resources, | |
148 | }; | |
149 | ||
1b7e0677 KM |
150 | /* SMSC 9220 */ |
151 | static struct resource smc911x_resources[] = { | |
152 | { | |
153 | .start = 0x14000000, | |
154 | .end = 0x16000000 - 1, | |
155 | .flags = IORESOURCE_MEM, | |
156 | }, { | |
157 | .start = 6, | |
158 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, | |
159 | }, | |
160 | }; | |
161 | ||
162 | static struct smsc911x_platform_config smsc911x_info = { | |
163 | .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, | |
164 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, | |
165 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, | |
166 | }; | |
167 | ||
168 | static struct platform_device smc911x_device = { | |
169 | .name = "smsc911x", | |
170 | .id = -1, | |
171 | .num_resources = ARRAY_SIZE(smc911x_resources), | |
172 | .resource = smc911x_resources, | |
173 | .dev = { | |
174 | .platform_data = &smsc911x_info, | |
175 | }, | |
176 | }; | |
2b7eda63 | 177 | |
17ccb834 KM |
178 | /* KEYSC (Needs SW43 set to ON) */ |
179 | static struct sh_keysc_info keysc_info = { | |
180 | .mode = SH_KEYSC_MODE_1, | |
181 | .scan_timing = 3, | |
182 | .delay = 2500, | |
183 | .keycodes = { | |
184 | KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, | |
185 | KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, | |
186 | KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, | |
187 | KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, | |
188 | KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, | |
189 | }, | |
190 | }; | |
191 | ||
192 | static struct resource keysc_resources[] = { | |
193 | [0] = { | |
194 | .name = "KEYSC", | |
195 | .start = 0xe61b0000, | |
196 | .end = 0xe61b0063, | |
197 | .flags = IORESOURCE_MEM, | |
198 | }, | |
199 | [1] = { | |
200 | .start = 79, | |
201 | .flags = IORESOURCE_IRQ, | |
202 | }, | |
203 | }; | |
204 | ||
205 | static struct platform_device keysc_device = { | |
206 | .name = "sh_keysc", | |
207 | .id = 0, /* "keysc0" clock */ | |
208 | .num_resources = ARRAY_SIZE(keysc_resources), | |
209 | .resource = keysc_resources, | |
210 | .dev = { | |
211 | .platform_data = &keysc_info, | |
212 | }, | |
213 | }; | |
214 | ||
3a14d039 MD |
215 | /* SDHI0 */ |
216 | static struct resource sdhi0_resources[] = { | |
217 | [0] = { | |
218 | .name = "SDHI0", | |
219 | .start = 0xe6850000, | |
220 | .end = 0xe68501ff, | |
221 | .flags = IORESOURCE_MEM, | |
222 | }, | |
223 | [1] = { | |
224 | .start = 96, | |
225 | .flags = IORESOURCE_IRQ, | |
226 | }, | |
227 | }; | |
228 | ||
229 | static struct platform_device sdhi0_device = { | |
230 | .name = "sh_mobile_sdhi", | |
231 | .num_resources = ARRAY_SIZE(sdhi0_resources), | |
232 | .resource = sdhi0_resources, | |
233 | .id = 0, | |
234 | }; | |
235 | ||
2b7eda63 MD |
236 | static struct platform_device *ap4evb_devices[] __initdata = { |
237 | &nor_flash_device, | |
1b7e0677 | 238 | &smc911x_device, |
17ccb834 | 239 | &keysc_device, |
3a14d039 | 240 | &sdhi0_device, |
2b7eda63 MD |
241 | }; |
242 | ||
dda128dc | 243 | /* TouchScreen (Needs SW3 set to OFF) */ |
91cf5082 KM |
244 | #define IRQ28 396 |
245 | struct tsc2007_platform_data tsc2007_info = { | |
246 | .model = 2007, | |
247 | .x_plate_ohms = 180, | |
248 | }; | |
249 | ||
250 | /* I2C */ | |
251 | static struct i2c_board_info i2c1_devices[] = { | |
8fc883c2 KM |
252 | { |
253 | I2C_BOARD_INFO("r2025sd", 0x32), | |
254 | }, | |
91cf5082 KM |
255 | { |
256 | I2C_BOARD_INFO("tsc2007", 0x48), | |
257 | .type = "tsc2007", | |
258 | .platform_data = &tsc2007_info, | |
259 | .irq = IRQ28, | |
260 | }, | |
261 | }; | |
262 | ||
2b7eda63 MD |
263 | static struct map_desc ap4evb_io_desc[] __initdata = { |
264 | /* create a 1:1 entity map for 0xe6xxxxxx | |
265 | * used by CPGA, INTC and PFC. | |
266 | */ | |
267 | { | |
268 | .virtual = 0xe6000000, | |
269 | .pfn = __phys_to_pfn(0xe6000000), | |
270 | .length = 256 << 20, | |
271 | .type = MT_DEVICE_NONSHARED | |
272 | }, | |
273 | }; | |
274 | ||
275 | static void __init ap4evb_map_io(void) | |
276 | { | |
277 | iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc)); | |
278 | ||
4ae04acb | 279 | /* setup early devices, clocks and console here as well */ |
2b7eda63 MD |
280 | sh7372_add_early_devices(); |
281 | sh7367_clock_init(); /* use g3 clocks for now */ | |
4ae04acb | 282 | shmobile_setup_console(); |
2b7eda63 MD |
283 | } |
284 | ||
285 | static void __init ap4evb_init(void) | |
286 | { | |
1b7e0677 KM |
287 | sh7372_pinmux_init(); |
288 | ||
b228b48e KM |
289 | /* enable SCIFA0 */ |
290 | gpio_request(GPIO_FN_SCIFA0_TXD, NULL); | |
291 | gpio_request(GPIO_FN_SCIFA0_RXD, NULL); | |
292 | ||
1b7e0677 KM |
293 | /* enable SMSC911X */ |
294 | gpio_request(GPIO_FN_CS5A, NULL); | |
295 | gpio_request(GPIO_FN_IRQ6_39, NULL); | |
296 | ||
5098280e KM |
297 | /* enable LED 1 - 4 */ |
298 | gpio_request(GPIO_PORT185, NULL); | |
299 | gpio_request(GPIO_PORT186, NULL); | |
300 | gpio_request(GPIO_PORT187, NULL); | |
301 | gpio_request(GPIO_PORT188, NULL); | |
302 | gpio_direction_output(GPIO_PORT185, 1); | |
303 | gpio_direction_output(GPIO_PORT186, 1); | |
304 | gpio_direction_output(GPIO_PORT187, 1); | |
305 | gpio_direction_output(GPIO_PORT188, 1); | |
306 | gpio_export(GPIO_PORT185, 0); | |
307 | gpio_export(GPIO_PORT186, 0); | |
308 | gpio_export(GPIO_PORT187, 0); | |
309 | gpio_export(GPIO_PORT188, 0); | |
310 | ||
8cb3a2eb KM |
311 | /* enable Debug switch (S6) */ |
312 | gpio_request(GPIO_PORT32, NULL); | |
313 | gpio_request(GPIO_PORT33, NULL); | |
314 | gpio_request(GPIO_PORT34, NULL); | |
315 | gpio_request(GPIO_PORT35, NULL); | |
316 | gpio_direction_input(GPIO_PORT32); | |
317 | gpio_direction_input(GPIO_PORT33); | |
318 | gpio_direction_input(GPIO_PORT34); | |
319 | gpio_direction_input(GPIO_PORT35); | |
320 | gpio_export(GPIO_PORT32, 0); | |
321 | gpio_export(GPIO_PORT33, 0); | |
322 | gpio_export(GPIO_PORT34, 0); | |
323 | gpio_export(GPIO_PORT35, 0); | |
324 | ||
17ccb834 KM |
325 | /* enable KEYSC */ |
326 | gpio_request(GPIO_FN_KEYOUT0, NULL); | |
327 | gpio_request(GPIO_FN_KEYOUT1, NULL); | |
328 | gpio_request(GPIO_FN_KEYOUT2, NULL); | |
329 | gpio_request(GPIO_FN_KEYOUT3, NULL); | |
330 | gpio_request(GPIO_FN_KEYOUT4, NULL); | |
331 | gpio_request(GPIO_FN_KEYIN0_136, NULL); | |
332 | gpio_request(GPIO_FN_KEYIN1_135, NULL); | |
333 | gpio_request(GPIO_FN_KEYIN2_134, NULL); | |
334 | gpio_request(GPIO_FN_KEYIN3_133, NULL); | |
335 | gpio_request(GPIO_FN_KEYIN4, NULL); | |
336 | ||
3a14d039 MD |
337 | /* SDHI0 */ |
338 | gpio_request(GPIO_FN_SDHICD0, NULL); | |
339 | gpio_request(GPIO_FN_SDHIWP0, NULL); | |
340 | gpio_request(GPIO_FN_SDHICMD0, NULL); | |
341 | gpio_request(GPIO_FN_SDHICLK0, NULL); | |
342 | gpio_request(GPIO_FN_SDHID0_3, NULL); | |
343 | gpio_request(GPIO_FN_SDHID0_2, NULL); | |
344 | gpio_request(GPIO_FN_SDHID0_1, NULL); | |
345 | gpio_request(GPIO_FN_SDHID0_0, NULL); | |
346 | ||
91cf5082 KM |
347 | /* enable TouchScreen */ |
348 | gpio_request(GPIO_FN_IRQ28_123, NULL); | |
349 | set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW); | |
350 | ||
351 | i2c_register_board_info(1, i2c1_devices, | |
352 | ARRAY_SIZE(i2c1_devices)); | |
353 | ||
2b7eda63 MD |
354 | sh7372_add_standard_devices(); |
355 | ||
356 | platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices)); | |
357 | } | |
358 | ||
359 | MACHINE_START(AP4EVB, "ap4evb") | |
360 | .phys_io = 0xe6000000, | |
361 | .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc, | |
362 | .map_io = ap4evb_map_io, | |
363 | .init_irq = sh7372_init_irq, | |
364 | .init_machine = ap4evb_init, | |
365 | .timer = &shmobile_timer, | |
366 | MACHINE_END |