]>
Commit | Line | Data |
---|---|---|
920adc75 KM |
1 | /* |
2 | * mackerel board support | |
3 | * | |
4 | * Copyright (C) 2010 Renesas Solutions Corp. | |
5 | * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | |
6 | * | |
7 | * based on ap4evb | |
8 | * Copyright (C) 2010 Magnus Damm | |
9 | * Copyright (C) 2008 Yoshihiro Shimoda | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License as published by | |
13 | * the Free Software Foundation; version 2 of the License. | |
14 | * | |
15 | * This program is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | * GNU General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License | |
21 | * along with this program; if not, write to the Free Software | |
22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
23 | */ | |
24 | #include <linux/kernel.h> | |
25 | #include <linux/init.h> | |
26 | #include <linux/interrupt.h> | |
27 | #include <linux/irq.h> | |
28 | #include <linux/platform_device.h> | |
29 | #include <linux/gpio.h> | |
30 | #include <linux/input.h> | |
31 | #include <linux/io.h> | |
1a44d72a | 32 | #include <linux/i2c.h> |
d44deb35 | 33 | #include <linux/leds.h> |
6dff7da2 YG |
34 | #include <linux/mfd/sh_mobile_sdhi.h> |
35 | #include <linux/mfd/tmio.h> | |
36 | #include <linux/mmc/host.h> | |
41491b9a | 37 | #include <linux/mmc/sh_mmcif.h> |
920adc75 KM |
38 | #include <linux/mtd/mtd.h> |
39 | #include <linux/mtd/partitions.h> | |
40 | #include <linux/mtd/physmap.h> | |
2264c151 | 41 | #include <linux/smsc911x.h> |
1a44d72a | 42 | #include <linux/sh_intc.h> |
cd8ab004 | 43 | #include <linux/tca6416_keypad.h> |
25338f2e | 44 | #include <linux/usb/r8a66597.h> |
920adc75 | 45 | |
11fee467 | 46 | #include <video/sh_mobile_lcdc.h> |
ae37c8de MD |
47 | #include <media/sh_mobile_ceu.h> |
48 | #include <media/soc_camera.h> | |
49 | #include <media/soc_camera_platform.h> | |
1a44d72a KM |
50 | #include <sound/sh_fsi.h> |
51 | ||
920adc75 KM |
52 | #include <mach/common.h> |
53 | #include <mach/sh7372.h> | |
54 | ||
55 | #include <asm/mach/arch.h> | |
56 | #include <asm/mach/time.h> | |
57 | #include <asm/mach/map.h> | |
58 | #include <asm/mach-types.h> | |
59 | ||
60 | /* | |
61 | * Address Interface BusWidth note | |
62 | * ------------------------------------------------------------------ | |
63 | * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON | |
64 | * 0x0800_0000 user area - | |
65 | * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF | |
66 | * 0x1400_0000 Ether (LAN9220) 16bit | |
67 | * 0x1600_0000 user area - cannot use with NAND | |
68 | * 0x1800_0000 user area - | |
69 | * 0x1A00_0000 - | |
70 | * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit | |
71 | */ | |
72 | ||
4b82b689 KM |
73 | /* |
74 | * CPU mode | |
75 | * | |
76 | * SW4 | Boot Area| Master | Remarks | |
77 | * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor| | |
78 | * ----+-----+-----+-----+-----+-----+-----+----------+----------+-------------- | |
79 | * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM | |
80 | * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug | |
81 | * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug | |
82 | * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM | |
83 | * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM | |
84 | * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM | |
85 | * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone | |
86 | * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone | |
87 | */ | |
88 | ||
89 | /* | |
90 | * NOR Flash ROM | |
91 | * | |
92 | * SW1 | SW2 | SW7 | NOR Flash ROM | |
93 | * bit1 | bit1 bit2 | bit1 | Memory allocation | |
94 | * ------+------------+------+------------------ | |
95 | * OFF | ON OFF | ON | Area 0 | |
96 | * OFF | ON OFF | OFF | Area 4 | |
97 | */ | |
98 | ||
99 | /* | |
100 | * SMSC 9220 | |
101 | * | |
102 | * SW1 SMSC 9220 | |
103 | * ----------------------- | |
104 | * ON access disable | |
105 | * OFF access enable | |
106 | */ | |
107 | ||
108 | /* | |
109 | * NAND Flash ROM | |
110 | * | |
111 | * SW1 | SW2 | SW7 | NAND Flash ROM | |
112 | * bit1 | bit1 bit2 | bit2 | Memory allocation | |
113 | * ------+------------+------+------------------ | |
114 | * OFF | ON OFF | ON | FCE 0 | |
115 | * OFF | ON OFF | OFF | FCE 1 | |
116 | */ | |
117 | ||
118 | /* | |
119 | * External interrupt pin settings | |
120 | * | |
121 | * IRQX | pin setting | device | level | |
122 | * ------+--------------------+--------------------+------- | |
123 | * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low | |
124 | * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High | |
125 | * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Tuch Panel | Low | |
126 | * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low | |
127 | * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low | |
128 | * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High | |
129 | * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High | |
25338f2e | 130 | */ |
4b82b689 | 131 | |
25338f2e KM |
132 | /* |
133 | * USB | |
134 | * | |
135 | * USB0 : CN22 : Function | |
136 | * USB1 : CN31 : Function/Host *1 | |
137 | * | |
138 | * J30 (for CN31) *1 | |
139 | * ----------+---------------+------------- | |
140 | * 1-2 short | VBUS 5V | Host | |
141 | * open | external VBUS | Function | |
142 | * | |
143 | * *1 | |
144 | * CN31 is used as Host in Linux. | |
145 | */ | |
4b82b689 | 146 | |
6dff7da2 YG |
147 | /* |
148 | * SDHI0 (CN12) | |
149 | * | |
150 | * SW56 : OFF | |
151 | * | |
152 | */ | |
153 | ||
154 | /* MMC /SDHI1 (CN7) | |
155 | * | |
156 | * I/O voltage : 1.8v | |
157 | * | |
158 | * Power voltage : 1.8v or 3.3v | |
41491b9a | 159 | * J22 : select power voltage *1 |
6dff7da2 YG |
160 | * 1-2 pin : 1.8v |
161 | * 2-3 pin : 3.3v | |
162 | * | |
41491b9a YG |
163 | * *1 |
164 | * Please change J22 depends the card to be used. | |
165 | * MMC's OCR field set to support either voltage for the card inserted. | |
166 | * | |
6dff7da2 YG |
167 | * SW1 | SW33 |
168 | * | bit1 | bit2 | bit3 | bit4 | |
169 | * -------------+------+------+------+------- | |
170 | * MMC0 OFF | OFF | ON | ON | X | |
171 | * MMC1 ON | OFF | ON | X | ON | |
172 | * SDHI1 OFF | ON | X | OFF | ON | |
173 | * | |
174 | */ | |
175 | ||
176 | /* | |
177 | * SDHI2 (CN23) | |
178 | * | |
179 | * microSD card sloct | |
180 | * | |
181 | */ | |
182 | ||
1a44d72a KM |
183 | /* |
184 | * FIXME !! | |
185 | * | |
186 | * gpio_no_direction | |
187 | * are quick_hack. | |
188 | * | |
189 | * current gpio frame work doesn't have | |
190 | * the method to control only pull up/down/free. | |
191 | * this function should be replaced by correct gpio function | |
192 | */ | |
193 | static void __init gpio_no_direction(u32 addr) | |
194 | { | |
195 | __raw_writeb(0x00, addr); | |
196 | } | |
197 | ||
920adc75 KM |
198 | /* MTD */ |
199 | static struct mtd_partition nor_flash_partitions[] = { | |
200 | { | |
201 | .name = "loader", | |
202 | .offset = 0x00000000, | |
203 | .size = 512 * 1024, | |
204 | .mask_flags = MTD_WRITEABLE, | |
205 | }, | |
206 | { | |
207 | .name = "bootenv", | |
208 | .offset = MTDPART_OFS_APPEND, | |
209 | .size = 512 * 1024, | |
210 | .mask_flags = MTD_WRITEABLE, | |
211 | }, | |
212 | { | |
213 | .name = "kernel_ro", | |
214 | .offset = MTDPART_OFS_APPEND, | |
215 | .size = 8 * 1024 * 1024, | |
216 | .mask_flags = MTD_WRITEABLE, | |
217 | }, | |
218 | { | |
219 | .name = "kernel", | |
220 | .offset = MTDPART_OFS_APPEND, | |
221 | .size = 8 * 1024 * 1024, | |
222 | }, | |
223 | { | |
224 | .name = "data", | |
225 | .offset = MTDPART_OFS_APPEND, | |
226 | .size = MTDPART_SIZ_FULL, | |
227 | }, | |
228 | }; | |
229 | ||
230 | static struct physmap_flash_data nor_flash_data = { | |
231 | .width = 2, | |
232 | .parts = nor_flash_partitions, | |
233 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), | |
234 | }; | |
235 | ||
236 | static struct resource nor_flash_resources[] = { | |
237 | [0] = { | |
238 | .start = 0x00000000, | |
239 | .end = 0x08000000 - 1, | |
240 | .flags = IORESOURCE_MEM, | |
241 | } | |
242 | }; | |
243 | ||
244 | static struct platform_device nor_flash_device = { | |
245 | .name = "physmap-flash", | |
246 | .dev = { | |
247 | .platform_data = &nor_flash_data, | |
248 | }, | |
249 | .num_resources = ARRAY_SIZE(nor_flash_resources), | |
250 | .resource = nor_flash_resources, | |
251 | }; | |
252 | ||
2264c151 KM |
253 | /* SMSC */ |
254 | static struct resource smc911x_resources[] = { | |
255 | { | |
256 | .start = 0x14000000, | |
257 | .end = 0x16000000 - 1, | |
258 | .flags = IORESOURCE_MEM, | |
259 | }, { | |
260 | .start = evt2irq(0x02c0) /* IRQ6A */, | |
261 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, | |
262 | }, | |
263 | }; | |
264 | ||
265 | static struct smsc911x_platform_config smsc911x_info = { | |
266 | .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, | |
267 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, | |
268 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, | |
269 | }; | |
270 | ||
271 | static struct platform_device smc911x_device = { | |
272 | .name = "smsc911x", | |
273 | .id = -1, | |
274 | .num_resources = ARRAY_SIZE(smc911x_resources), | |
275 | .resource = smc911x_resources, | |
276 | .dev = { | |
277 | .platform_data = &smsc911x_info, | |
278 | }, | |
279 | }; | |
280 | ||
11fee467 KM |
281 | /* LCDC */ |
282 | static struct fb_videomode mackerel_lcdc_modes[] = { | |
283 | { | |
284 | .name = "WVGA Panel", | |
285 | .xres = 800, | |
286 | .yres = 480, | |
287 | .left_margin = 220, | |
288 | .right_margin = 110, | |
289 | .hsync_len = 70, | |
290 | .upper_margin = 20, | |
291 | .lower_margin = 5, | |
292 | .vsync_len = 5, | |
293 | .sync = 0, | |
294 | }, | |
295 | }; | |
296 | ||
297 | static struct sh_mobile_lcdc_info lcdc_info = { | |
298 | .clock_source = LCDC_CLK_BUS, | |
299 | .ch[0] = { | |
300 | .chan = LCDC_CHAN_MAINLCD, | |
301 | .bpp = 16, | |
302 | .lcd_cfg = mackerel_lcdc_modes, | |
303 | .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes), | |
304 | .interface_type = RGB24, | |
305 | .clock_divider = 2, | |
306 | .flags = 0, | |
307 | .lcd_size_cfg.width = 152, | |
308 | .lcd_size_cfg.height = 91, | |
309 | } | |
310 | }; | |
311 | ||
312 | static struct resource lcdc_resources[] = { | |
313 | [0] = { | |
314 | .name = "LCDC", | |
315 | .start = 0xfe940000, | |
316 | .end = 0xfe943fff, | |
317 | .flags = IORESOURCE_MEM, | |
318 | }, | |
319 | [1] = { | |
320 | .start = intcs_evt2irq(0x580), | |
321 | .flags = IORESOURCE_IRQ, | |
322 | }, | |
323 | }; | |
324 | ||
325 | static struct platform_device lcdc_device = { | |
326 | .name = "sh_mobile_lcdc_fb", | |
327 | .num_resources = ARRAY_SIZE(lcdc_resources), | |
328 | .resource = lcdc_resources, | |
329 | .dev = { | |
330 | .platform_data = &lcdc_info, | |
331 | .coherent_dma_mask = ~0, | |
332 | }, | |
333 | }; | |
334 | ||
25338f2e KM |
335 | /* USB1 (Host) */ |
336 | static void usb1_host_port_power(int port, int power) | |
337 | { | |
338 | if (!power) /* only power-on is supported for now */ | |
339 | return; | |
340 | ||
341 | /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */ | |
342 | __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008); | |
343 | } | |
344 | ||
345 | static struct r8a66597_platdata usb1_host_data = { | |
346 | .on_chip = 1, | |
347 | .port_power = usb1_host_port_power, | |
348 | }; | |
349 | ||
350 | static struct resource usb1_host_resources[] = { | |
351 | [0] = { | |
352 | .name = "USBHS", | |
353 | .start = 0xE68B0000, | |
354 | .end = 0xE68B00E6 - 1, | |
355 | .flags = IORESOURCE_MEM, | |
356 | }, | |
357 | [1] = { | |
358 | .start = evt2irq(0x1ce0) /* USB1_USB1I0 */, | |
359 | .flags = IORESOURCE_IRQ, | |
360 | }, | |
361 | }; | |
362 | ||
363 | static struct platform_device usb1_host_device = { | |
364 | .name = "r8a66597_hcd", | |
365 | .id = 1, | |
366 | .dev = { | |
367 | .dma_mask = NULL, /* not use dma */ | |
368 | .coherent_dma_mask = 0xffffffff, | |
369 | .platform_data = &usb1_host_data, | |
370 | }, | |
371 | .num_resources = ARRAY_SIZE(usb1_host_resources), | |
372 | .resource = usb1_host_resources, | |
373 | }; | |
374 | ||
d44deb35 KM |
375 | /* LED */ |
376 | static struct gpio_led mackerel_leds[] = { | |
377 | { | |
378 | .name = "led0", | |
379 | .gpio = GPIO_PORT0, | |
380 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
381 | }, | |
382 | { | |
383 | .name = "led1", | |
384 | .gpio = GPIO_PORT1, | |
385 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
386 | }, | |
387 | { | |
388 | .name = "led2", | |
389 | .gpio = GPIO_PORT2, | |
390 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
391 | }, | |
392 | { | |
393 | .name = "led3", | |
394 | .gpio = GPIO_PORT159, | |
395 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
396 | } | |
397 | }; | |
398 | ||
399 | static struct gpio_led_platform_data mackerel_leds_pdata = { | |
400 | .leds = mackerel_leds, | |
401 | .num_leds = ARRAY_SIZE(mackerel_leds), | |
402 | }; | |
403 | ||
404 | static struct platform_device leds_device = { | |
405 | .name = "leds-gpio", | |
406 | .id = 0, | |
407 | .dev = { | |
408 | .platform_data = &mackerel_leds_pdata, | |
409 | }, | |
410 | }; | |
411 | ||
1a44d72a KM |
412 | /* FSI */ |
413 | #define IRQ_FSI evt2irq(0x1840) | |
414 | static struct sh_fsi_platform_info fsi_info = { | |
415 | .porta_flags = SH_FSI_BRS_INV | | |
416 | SH_FSI_OUT_SLAVE_MODE | | |
417 | SH_FSI_IN_SLAVE_MODE | | |
418 | SH_FSI_OFMT(PCM) | | |
419 | SH_FSI_IFMT(PCM), | |
420 | }; | |
421 | ||
422 | static struct resource fsi_resources[] = { | |
423 | [0] = { | |
424 | .name = "FSI", | |
425 | .start = 0xFE3C0000, | |
426 | .end = 0xFE3C0400 - 1, | |
427 | .flags = IORESOURCE_MEM, | |
428 | }, | |
429 | [1] = { | |
430 | .start = IRQ_FSI, | |
431 | .flags = IORESOURCE_IRQ, | |
432 | }, | |
433 | }; | |
434 | ||
435 | static struct platform_device fsi_device = { | |
436 | .name = "sh_fsi2", | |
437 | .id = -1, | |
438 | .num_resources = ARRAY_SIZE(fsi_resources), | |
439 | .resource = fsi_resources, | |
440 | .dev = { | |
441 | .platform_data = &fsi_info, | |
442 | }, | |
443 | }; | |
444 | ||
445 | static struct platform_device fsi_ak4643_device = { | |
446 | .name = "sh_fsi2_a_ak4643", | |
447 | }; | |
d44deb35 | 448 | |
6dff7da2 YG |
449 | /* |
450 | * The card detect pin of the top SD/MMC slot (CN7) is active low and is | |
451 | * connected to GPIO A22 of SH7372 (GPIO_PORT41). | |
452 | */ | |
453 | static int slot_cn7_get_cd(struct platform_device *pdev) | |
454 | { | |
455 | if (gpio_is_valid(GPIO_PORT41)) | |
456 | return !gpio_get_value(GPIO_PORT41); | |
457 | else | |
458 | return -ENXIO; | |
459 | } | |
460 | ||
461 | /* SDHI0 */ | |
462 | static struct sh_mobile_sdhi_info sdhi0_info = { | |
463 | .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, | |
464 | .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, | |
465 | .tmio_caps = MMC_CAP_SD_HIGHSPEED, | |
466 | }; | |
467 | ||
468 | static struct resource sdhi0_resources[] = { | |
469 | [0] = { | |
470 | .name = "SDHI0", | |
471 | .start = 0xe6850000, | |
472 | .end = 0xe68501ff, | |
473 | .flags = IORESOURCE_MEM, | |
474 | }, | |
475 | [1] = { | |
476 | .start = evt2irq(0x0e00) /* SDHI0 */, | |
477 | .flags = IORESOURCE_IRQ, | |
478 | }, | |
479 | }; | |
480 | ||
481 | static struct platform_device sdhi0_device = { | |
482 | .name = "sh_mobile_sdhi", | |
483 | .num_resources = ARRAY_SIZE(sdhi0_resources), | |
484 | .resource = sdhi0_resources, | |
485 | .id = 0, | |
486 | .dev = { | |
487 | .platform_data = &sdhi0_info, | |
488 | }, | |
489 | }; | |
490 | ||
41491b9a | 491 | #if !defined(CONFIG_MMC_SH_MMCIF) |
6dff7da2 YG |
492 | /* SDHI1 */ |
493 | static struct sh_mobile_sdhi_info sdhi1_info = { | |
494 | .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX, | |
495 | .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX, | |
496 | .tmio_ocr_mask = MMC_VDD_165_195, | |
497 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, | |
498 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | | |
499 | MMC_CAP_NEEDS_POLL, | |
500 | .get_cd = slot_cn7_get_cd, | |
501 | }; | |
502 | ||
503 | static struct resource sdhi1_resources[] = { | |
504 | [0] = { | |
505 | .name = "SDHI1", | |
506 | .start = 0xe6860000, | |
507 | .end = 0xe68601ff, | |
508 | .flags = IORESOURCE_MEM, | |
509 | }, | |
510 | [1] = { | |
511 | .start = evt2irq(0x0e80), | |
512 | .flags = IORESOURCE_IRQ, | |
513 | }, | |
514 | }; | |
515 | ||
516 | static struct platform_device sdhi1_device = { | |
517 | .name = "sh_mobile_sdhi", | |
518 | .num_resources = ARRAY_SIZE(sdhi1_resources), | |
519 | .resource = sdhi1_resources, | |
520 | .id = 1, | |
521 | .dev = { | |
522 | .platform_data = &sdhi1_info, | |
523 | }, | |
524 | }; | |
41491b9a | 525 | #endif |
6dff7da2 YG |
526 | |
527 | /* SDHI2 */ | |
528 | static struct sh_mobile_sdhi_info sdhi2_info = { | |
529 | .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX, | |
530 | .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX, | |
531 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, | |
532 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | | |
533 | MMC_CAP_NEEDS_POLL, | |
534 | }; | |
535 | ||
536 | static struct resource sdhi2_resources[] = { | |
537 | [0] = { | |
538 | .name = "SDHI2", | |
539 | .start = 0xe6870000, | |
540 | .end = 0xe68701ff, | |
541 | .flags = IORESOURCE_MEM, | |
542 | }, | |
543 | [1] = { | |
544 | .start = evt2irq(0x1200), | |
545 | .flags = IORESOURCE_IRQ, | |
546 | }, | |
547 | }; | |
548 | ||
549 | static struct platform_device sdhi2_device = { | |
550 | .name = "sh_mobile_sdhi", | |
551 | .num_resources = ARRAY_SIZE(sdhi2_resources), | |
552 | .resource = sdhi2_resources, | |
553 | .id = 2, | |
554 | .dev = { | |
555 | .platform_data = &sdhi2_info, | |
556 | }, | |
557 | }; | |
558 | ||
41491b9a YG |
559 | /* SH_MMCIF */ |
560 | static struct resource sh_mmcif_resources[] = { | |
561 | [0] = { | |
562 | .name = "MMCIF", | |
563 | .start = 0xE6BD0000, | |
564 | .end = 0xE6BD00FF, | |
565 | .flags = IORESOURCE_MEM, | |
566 | }, | |
567 | [1] = { | |
568 | /* MMC ERR */ | |
569 | .start = evt2irq(0x1ac0), | |
570 | .flags = IORESOURCE_IRQ, | |
571 | }, | |
572 | [2] = { | |
573 | /* MMC NOR */ | |
574 | .start = evt2irq(0x1ae0), | |
575 | .flags = IORESOURCE_IRQ, | |
576 | }, | |
577 | }; | |
578 | ||
579 | static struct sh_mmcif_plat_data sh_mmcif_plat = { | |
580 | .sup_pclk = 0, | |
581 | .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, | |
582 | .caps = MMC_CAP_4_BIT_DATA | | |
583 | MMC_CAP_8_BIT_DATA | | |
584 | MMC_CAP_NEEDS_POLL, | |
585 | .get_cd = slot_cn7_get_cd, | |
586 | }; | |
587 | ||
588 | static struct platform_device sh_mmcif_device = { | |
589 | .name = "sh_mmcif", | |
590 | .id = 0, | |
591 | .dev = { | |
592 | .dma_mask = NULL, | |
593 | .coherent_dma_mask = 0xffffffff, | |
594 | .platform_data = &sh_mmcif_plat, | |
595 | }, | |
596 | .num_resources = ARRAY_SIZE(sh_mmcif_resources), | |
597 | .resource = sh_mmcif_resources, | |
598 | }; | |
599 | ||
ae37c8de MD |
600 | |
601 | static int mackerel_camera_add(struct soc_camera_link *icl, struct device *dev); | |
602 | static void mackerel_camera_del(struct soc_camera_link *icl); | |
603 | ||
604 | static int camera_set_capture(struct soc_camera_platform_info *info, | |
605 | int enable) | |
606 | { | |
607 | return 0; /* camera sensor always enabled */ | |
608 | } | |
609 | ||
610 | static struct soc_camera_platform_info camera_info = { | |
611 | .format_name = "UYVY", | |
612 | .format_depth = 16, | |
613 | .format = { | |
614 | .code = V4L2_MBUS_FMT_UYVY8_2X8, | |
615 | .colorspace = V4L2_COLORSPACE_SMPTE170M, | |
616 | .field = V4L2_FIELD_NONE, | |
617 | .width = 640, | |
618 | .height = 480, | |
619 | }, | |
620 | .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH | | |
621 | SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8 | | |
622 | SOCAM_DATA_ACTIVE_HIGH, | |
623 | .set_capture = camera_set_capture, | |
624 | }; | |
625 | ||
626 | static struct soc_camera_link camera_link = { | |
627 | .bus_id = 0, | |
628 | .add_device = mackerel_camera_add, | |
629 | .del_device = mackerel_camera_del, | |
630 | .module_name = "soc_camera_platform", | |
631 | .priv = &camera_info, | |
632 | }; | |
633 | ||
634 | static void dummy_release(struct device *dev) | |
635 | { | |
636 | } | |
637 | ||
638 | static struct platform_device camera_device = { | |
639 | .name = "soc_camera_platform", | |
640 | .dev = { | |
641 | .platform_data = &camera_info, | |
642 | .release = dummy_release, | |
643 | }, | |
644 | }; | |
645 | ||
646 | static int mackerel_camera_add(struct soc_camera_link *icl, | |
647 | struct device *dev) | |
648 | { | |
649 | if (icl != &camera_link) | |
650 | return -ENODEV; | |
651 | ||
652 | camera_info.dev = dev; | |
653 | ||
654 | return platform_device_register(&camera_device); | |
655 | } | |
656 | ||
657 | static void mackerel_camera_del(struct soc_camera_link *icl) | |
658 | { | |
659 | if (icl != &camera_link) | |
660 | return; | |
661 | ||
662 | platform_device_unregister(&camera_device); | |
663 | memset(&camera_device.dev.kobj, 0, | |
664 | sizeof(camera_device.dev.kobj)); | |
665 | } | |
666 | ||
667 | static struct sh_mobile_ceu_info sh_mobile_ceu_info = { | |
668 | .flags = SH_CEU_FLAG_USE_8BIT_BUS, | |
669 | }; | |
670 | ||
671 | static struct resource ceu_resources[] = { | |
672 | [0] = { | |
673 | .name = "CEU", | |
674 | .start = 0xfe910000, | |
675 | .end = 0xfe91009f, | |
676 | .flags = IORESOURCE_MEM, | |
677 | }, | |
678 | [1] = { | |
679 | .start = intcs_evt2irq(0x880), | |
680 | .flags = IORESOURCE_IRQ, | |
681 | }, | |
682 | [2] = { | |
683 | /* place holder for contiguous memory */ | |
684 | }, | |
685 | }; | |
686 | ||
687 | static struct platform_device ceu_device = { | |
688 | .name = "sh_mobile_ceu", | |
689 | .id = 0, /* "ceu0" clock */ | |
690 | .num_resources = ARRAY_SIZE(ceu_resources), | |
691 | .resource = ceu_resources, | |
692 | .dev = { | |
693 | .platform_data = &sh_mobile_ceu_info, | |
694 | }, | |
695 | }; | |
696 | ||
697 | static struct platform_device mackerel_camera = { | |
698 | .name = "soc-camera-pdrv", | |
699 | .id = 0, | |
700 | .dev = { | |
701 | .platform_data = &camera_link, | |
702 | }, | |
703 | }; | |
704 | ||
920adc75 KM |
705 | static struct platform_device *mackerel_devices[] __initdata = { |
706 | &nor_flash_device, | |
2264c151 | 707 | &smc911x_device, |
11fee467 | 708 | &lcdc_device, |
25338f2e | 709 | &usb1_host_device, |
d44deb35 | 710 | &leds_device, |
1a44d72a KM |
711 | &fsi_device, |
712 | &fsi_ak4643_device, | |
6dff7da2 | 713 | &sdhi0_device, |
41491b9a | 714 | #if !defined(CONFIG_MMC_SH_MMCIF) |
6dff7da2 | 715 | &sdhi1_device, |
41491b9a | 716 | #endif |
6dff7da2 | 717 | &sdhi2_device, |
41491b9a | 718 | &sh_mmcif_device, |
ae37c8de MD |
719 | &ceu_device, |
720 | &mackerel_camera, | |
1a44d72a KM |
721 | }; |
722 | ||
cd8ab004 TS |
723 | /* Keypad Initialization */ |
724 | #define KEYPAD_BUTTON(ev_type, ev_code, act_low) \ | |
725 | { \ | |
726 | .type = ev_type, \ | |
727 | .code = ev_code, \ | |
728 | .active_low = act_low, \ | |
729 | } | |
730 | ||
731 | #define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1) | |
732 | ||
733 | static struct tca6416_button mackerel_gpio_keys[] = { | |
734 | KEYPAD_BUTTON_LOW(KEY_HOME), | |
735 | KEYPAD_BUTTON_LOW(KEY_MENU), | |
736 | KEYPAD_BUTTON_LOW(KEY_BACK), | |
737 | KEYPAD_BUTTON_LOW(KEY_POWER), | |
738 | }; | |
739 | ||
740 | static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = { | |
741 | .buttons = mackerel_gpio_keys, | |
742 | .nbuttons = ARRAY_SIZE(mackerel_gpio_keys), | |
743 | .rep = 1, | |
744 | .use_polling = 0, | |
745 | .pinmask = 0x000F, | |
746 | }; | |
747 | ||
1a44d72a | 748 | /* I2C */ |
cd8ab004 TS |
749 | #define IRQ9 evt2irq(0x0320) |
750 | ||
1a44d72a KM |
751 | static struct i2c_board_info i2c0_devices[] = { |
752 | { | |
753 | I2C_BOARD_INFO("ak4643", 0x13), | |
754 | }, | |
cd8ab004 TS |
755 | /* Keypad */ |
756 | { | |
757 | I2C_BOARD_INFO("tca6408-keys", 0x20), | |
758 | .platform_data = &mackerel_tca6416_keys_info, | |
759 | .irq = IRQ9, | |
760 | }, | |
920adc75 KM |
761 | }; |
762 | ||
80f1dc7c TS |
763 | #define IRQ21 evt2irq(0x32a0) |
764 | ||
765 | static struct i2c_board_info i2c1_devices[] = { | |
766 | /* Accelerometer */ | |
767 | { | |
768 | I2C_BOARD_INFO("adxl34x", 0x53), | |
769 | .irq = IRQ21, | |
770 | }, | |
771 | }; | |
772 | ||
920adc75 KM |
773 | static struct map_desc mackerel_io_desc[] __initdata = { |
774 | /* create a 1:1 entity map for 0xe6xxxxxx | |
775 | * used by CPGA, INTC and PFC. | |
776 | */ | |
777 | { | |
778 | .virtual = 0xe6000000, | |
779 | .pfn = __phys_to_pfn(0xe6000000), | |
780 | .length = 256 << 20, | |
781 | .type = MT_DEVICE_NONSHARED | |
782 | }, | |
783 | }; | |
784 | ||
785 | static void __init mackerel_map_io(void) | |
786 | { | |
787 | iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc)); | |
788 | ||
789 | /* setup early devices and console here as well */ | |
790 | sh7372_add_early_devices(); | |
791 | shmobile_setup_console(); | |
792 | } | |
793 | ||
1a44d72a KM |
794 | #define GPIO_PORT9CR 0xE6051009 |
795 | #define GPIO_PORT10CR 0xE605100A | |
920adc75 KM |
796 | static void __init mackerel_init(void) |
797 | { | |
798 | sh7372_pinmux_init(); | |
799 | ||
800 | /* enable SCIFA0 */ | |
801 | gpio_request(GPIO_FN_SCIFA0_TXD, NULL); | |
802 | gpio_request(GPIO_FN_SCIFA0_RXD, NULL); | |
803 | ||
2264c151 KM |
804 | /* enable SMSC911X */ |
805 | gpio_request(GPIO_FN_CS5A, NULL); | |
806 | gpio_request(GPIO_FN_IRQ6_39, NULL); | |
807 | ||
11fee467 | 808 | /* LCDC */ |
eb87e677 KM |
809 | gpio_request(GPIO_FN_LCDD23, NULL); |
810 | gpio_request(GPIO_FN_LCDD22, NULL); | |
811 | gpio_request(GPIO_FN_LCDD21, NULL); | |
812 | gpio_request(GPIO_FN_LCDD20, NULL); | |
813 | gpio_request(GPIO_FN_LCDD19, NULL); | |
814 | gpio_request(GPIO_FN_LCDD18, NULL); | |
11fee467 KM |
815 | gpio_request(GPIO_FN_LCDD17, NULL); |
816 | gpio_request(GPIO_FN_LCDD16, NULL); | |
817 | gpio_request(GPIO_FN_LCDD15, NULL); | |
818 | gpio_request(GPIO_FN_LCDD14, NULL); | |
819 | gpio_request(GPIO_FN_LCDD13, NULL); | |
820 | gpio_request(GPIO_FN_LCDD12, NULL); | |
821 | gpio_request(GPIO_FN_LCDD11, NULL); | |
822 | gpio_request(GPIO_FN_LCDD10, NULL); | |
823 | gpio_request(GPIO_FN_LCDD9, NULL); | |
824 | gpio_request(GPIO_FN_LCDD8, NULL); | |
825 | gpio_request(GPIO_FN_LCDD7, NULL); | |
826 | gpio_request(GPIO_FN_LCDD6, NULL); | |
827 | gpio_request(GPIO_FN_LCDD5, NULL); | |
828 | gpio_request(GPIO_FN_LCDD4, NULL); | |
829 | gpio_request(GPIO_FN_LCDD3, NULL); | |
830 | gpio_request(GPIO_FN_LCDD2, NULL); | |
831 | gpio_request(GPIO_FN_LCDD1, NULL); | |
832 | gpio_request(GPIO_FN_LCDD0, NULL); | |
833 | gpio_request(GPIO_FN_LCDDISP, NULL); | |
834 | gpio_request(GPIO_FN_LCDDCK, NULL); | |
835 | ||
836 | gpio_request(GPIO_PORT31, NULL); /* backlight */ | |
837 | gpio_direction_output(GPIO_PORT31, 1); | |
838 | ||
839 | gpio_request(GPIO_PORT151, NULL); /* LCDDON */ | |
840 | gpio_direction_output(GPIO_PORT151, 1); | |
841 | ||
25338f2e KM |
842 | /* USB enable */ |
843 | gpio_request(GPIO_FN_VBUS0_1, NULL); | |
844 | gpio_request(GPIO_FN_IDIN_1_18, NULL); | |
845 | gpio_request(GPIO_FN_PWEN_1_115, NULL); | |
846 | gpio_request(GPIO_FN_OVCN_1_114, NULL); | |
847 | gpio_request(GPIO_FN_EXTLP_1, NULL); | |
848 | gpio_request(GPIO_FN_OVCN2_1, NULL); | |
849 | ||
850 | /* setup USB phy */ | |
d0fb0c4b | 851 | __raw_writew(0x8a0a, 0xE6058130); /* USBCR4 */ |
25338f2e | 852 | |
1a44d72a KM |
853 | /* enable FSI2 port A (ak4643) */ |
854 | gpio_request(GPIO_FN_FSIAIBT, NULL); | |
855 | gpio_request(GPIO_FN_FSIAILR, NULL); | |
856 | gpio_request(GPIO_FN_FSIAISLD, NULL); | |
857 | gpio_request(GPIO_FN_FSIAOSLD, NULL); | |
858 | gpio_request(GPIO_PORT161, NULL); | |
859 | gpio_direction_output(GPIO_PORT161, 0); /* slave */ | |
860 | ||
861 | gpio_request(GPIO_PORT9, NULL); | |
862 | gpio_request(GPIO_PORT10, NULL); | |
863 | gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */ | |
864 | gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */ | |
865 | ||
866 | intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */ | |
867 | ||
cd8ab004 TS |
868 | /* enable Keypad */ |
869 | gpio_request(GPIO_FN_IRQ9_42, NULL); | |
870 | set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH); | |
871 | ||
80f1dc7c TS |
872 | /* enable Accelerometer */ |
873 | gpio_request(GPIO_FN_IRQ21, NULL); | |
874 | set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH); | |
1a44d72a | 875 | |
6dff7da2 YG |
876 | /* enable SDHI0 */ |
877 | gpio_request(GPIO_FN_SDHICD0, NULL); | |
878 | gpio_request(GPIO_FN_SDHIWP0, NULL); | |
879 | gpio_request(GPIO_FN_SDHICMD0, NULL); | |
880 | gpio_request(GPIO_FN_SDHICLK0, NULL); | |
881 | gpio_request(GPIO_FN_SDHID0_3, NULL); | |
882 | gpio_request(GPIO_FN_SDHID0_2, NULL); | |
883 | gpio_request(GPIO_FN_SDHID0_1, NULL); | |
884 | gpio_request(GPIO_FN_SDHID0_0, NULL); | |
885 | ||
41491b9a | 886 | #if !defined(CONFIG_MMC_SH_MMCIF) |
6dff7da2 YG |
887 | /* enable SDHI1 */ |
888 | gpio_request(GPIO_FN_SDHICMD1, NULL); | |
889 | gpio_request(GPIO_FN_SDHICLK1, NULL); | |
890 | gpio_request(GPIO_FN_SDHID1_3, NULL); | |
891 | gpio_request(GPIO_FN_SDHID1_2, NULL); | |
892 | gpio_request(GPIO_FN_SDHID1_1, NULL); | |
893 | gpio_request(GPIO_FN_SDHID1_0, NULL); | |
41491b9a | 894 | #endif |
6dff7da2 YG |
895 | /* card detect pin for MMC slot (CN7) */ |
896 | gpio_request(GPIO_PORT41, NULL); | |
897 | gpio_direction_input(GPIO_PORT41); | |
898 | ||
899 | /* enable SDHI2 */ | |
900 | gpio_request(GPIO_FN_SDHICMD2, NULL); | |
901 | gpio_request(GPIO_FN_SDHICLK2, NULL); | |
902 | gpio_request(GPIO_FN_SDHID2_3, NULL); | |
903 | gpio_request(GPIO_FN_SDHID2_2, NULL); | |
904 | gpio_request(GPIO_FN_SDHID2_1, NULL); | |
905 | gpio_request(GPIO_FN_SDHID2_0, NULL); | |
906 | ||
41491b9a YG |
907 | /* MMCIF */ |
908 | gpio_request(GPIO_FN_MMCD0_0, NULL); | |
909 | gpio_request(GPIO_FN_MMCD0_1, NULL); | |
910 | gpio_request(GPIO_FN_MMCD0_2, NULL); | |
911 | gpio_request(GPIO_FN_MMCD0_3, NULL); | |
912 | gpio_request(GPIO_FN_MMCD0_4, NULL); | |
913 | gpio_request(GPIO_FN_MMCD0_5, NULL); | |
914 | gpio_request(GPIO_FN_MMCD0_6, NULL); | |
915 | gpio_request(GPIO_FN_MMCD0_7, NULL); | |
916 | gpio_request(GPIO_FN_MMCCMD0, NULL); | |
917 | gpio_request(GPIO_FN_MMCCLK0, NULL); | |
918 | ||
56e78daf YG |
919 | /* enable GPS module (GT-720F) */ |
920 | gpio_request(GPIO_FN_SCIFA2_TXD1, NULL); | |
921 | gpio_request(GPIO_FN_SCIFA2_RXD1, NULL); | |
922 | ||
ae37c8de MD |
923 | /* CEU */ |
924 | gpio_request(GPIO_FN_VIO_CLK, NULL); | |
925 | gpio_request(GPIO_FN_VIO_VD, NULL); | |
926 | gpio_request(GPIO_FN_VIO_HD, NULL); | |
927 | gpio_request(GPIO_FN_VIO_FIELD, NULL); | |
928 | gpio_request(GPIO_FN_VIO_CKO, NULL); | |
929 | gpio_request(GPIO_FN_VIO_D7, NULL); | |
930 | gpio_request(GPIO_FN_VIO_D6, NULL); | |
931 | gpio_request(GPIO_FN_VIO_D5, NULL); | |
932 | gpio_request(GPIO_FN_VIO_D4, NULL); | |
933 | gpio_request(GPIO_FN_VIO_D3, NULL); | |
934 | gpio_request(GPIO_FN_VIO_D2, NULL); | |
935 | gpio_request(GPIO_FN_VIO_D1, NULL); | |
936 | gpio_request(GPIO_FN_VIO_D0, NULL); | |
937 | ||
1a44d72a KM |
938 | i2c_register_board_info(0, i2c0_devices, |
939 | ARRAY_SIZE(i2c0_devices)); | |
80f1dc7c TS |
940 | i2c_register_board_info(1, i2c1_devices, |
941 | ARRAY_SIZE(i2c1_devices)); | |
11fee467 | 942 | |
920adc75 KM |
943 | sh7372_add_standard_devices(); |
944 | ||
945 | platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices)); | |
946 | } | |
947 | ||
948 | static void __init mackerel_timer_init(void) | |
949 | { | |
950 | sh7372_clock_init(); | |
951 | shmobile_timer.init(); | |
952 | } | |
953 | ||
954 | static struct sys_timer mackerel_timer = { | |
955 | .init = mackerel_timer_init, | |
956 | }; | |
957 | ||
958 | MACHINE_START(MACKEREL, "mackerel") | |
959 | .map_io = mackerel_map_io, | |
960 | .init_irq = sh7372_init_irq, | |
961 | .init_machine = mackerel_init, | |
962 | .timer = &mackerel_timer, | |
963 | MACHINE_END |