blob: c7d378b57cfce61e5580c2ab0de39a26107e88a2 [file] [log] [blame]
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001/*
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 */
Kuninori Morimoto12c43092011-01-06 02:44:09 +000024#include <linux/delay.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000025#include <linux/kernel.h>
26#include <linux/init.h>
27#include <linux/interrupt.h>
28#include <linux/irq.h>
29#include <linux/platform_device.h>
30#include <linux/gpio.h>
31#include <linux/input.h>
32#include <linux/io.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000033#include <linux/i2c.h>
Kuninori Morimotod44deb32010-11-30 06:52:18 +000034#include <linux/leds.h>
Yusuke Goda6dff7da2010-12-14 14:18:03 +090035#include <linux/mfd/sh_mobile_sdhi.h>
36#include <linux/mfd/tmio.h>
37#include <linux/mmc/host.h>
Yusuke Goda41491b92010-12-15 08:31:04 +000038#include <linux/mmc/sh_mmcif.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000039#include <linux/mtd/mtd.h>
40#include <linux/mtd/partitions.h>
41#include <linux/mtd/physmap.h>
Kuninori Morimoto2264c152010-11-29 02:21:37 +000042#include <linux/smsc911x.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000043#include <linux/sh_intc.h>
Tony SIMcd8ab002010-12-09 01:55:55 +000044#include <linux/tca6416_keypad.h>
Kuninori Morimoto25338f22010-11-30 04:37:33 +000045#include <linux/usb/r8a66597.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000046
Kuninori Morimoto12c43092011-01-06 02:44:09 +000047#include <video/sh_mobile_hdmi.h>
Kuninori Morimoto11fee462010-11-29 02:21:43 +000048#include <video/sh_mobile_lcdc.h>
Magnus Dammae37c8d2010-12-22 14:47:40 +000049#include <media/sh_mobile_ceu.h>
50#include <media/soc_camera.h>
51#include <media/soc_camera_platform.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000052#include <sound/sh_fsi.h>
53
Kuninori Morimoto920adc72010-11-29 02:21:21 +000054#include <mach/common.h>
55#include <mach/sh7372.h>
56
57#include <asm/mach/arch.h>
58#include <asm/mach/time.h>
59#include <asm/mach/map.h>
60#include <asm/mach-types.h>
61
62/*
63 * Address Interface BusWidth note
64 * ------------------------------------------------------------------
65 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
66 * 0x0800_0000 user area -
67 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
68 * 0x1400_0000 Ether (LAN9220) 16bit
69 * 0x1600_0000 user area - cannot use with NAND
70 * 0x1800_0000 user area -
71 * 0x1A00_0000 -
72 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
73 */
74
Kuninori Morimoto4b82b682010-11-29 02:21:48 +000075/*
76 * CPU mode
77 *
78 * SW4 | Boot Area| Master | Remarks
79 * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor|
80 * ----+-----+-----+-----+-----+-----+-----+----------+----------+--------------
81 * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM
82 * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug
83 * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug
84 * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM
85 * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM
86 * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM
87 * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone
88 * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone
89*/
90
91/*
92 * NOR Flash ROM
93 *
94 * SW1 | SW2 | SW7 | NOR Flash ROM
95 * bit1 | bit1 bit2 | bit1 | Memory allocation
96 * ------+------------+------+------------------
97 * OFF | ON OFF | ON | Area 0
98 * OFF | ON OFF | OFF | Area 4
99 */
100
101/*
102 * SMSC 9220
103 *
104 * SW1 SMSC 9220
105 * -----------------------
106 * ON access disable
107 * OFF access enable
108 */
109
110/*
111 * NAND Flash ROM
112 *
113 * SW1 | SW2 | SW7 | NAND Flash ROM
114 * bit1 | bit1 bit2 | bit2 | Memory allocation
115 * ------+------------+------+------------------
116 * OFF | ON OFF | ON | FCE 0
117 * OFF | ON OFF | OFF | FCE 1
118 */
119
120/*
121 * External interrupt pin settings
122 *
123 * IRQX | pin setting | device | level
124 * ------+--------------------+--------------------+-------
125 * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low
126 * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High
127 * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Tuch Panel | Low
128 * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low
129 * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low
130 * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High
131 * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000132 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000133
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000134/*
135 * USB
136 *
137 * USB0 : CN22 : Function
138 * USB1 : CN31 : Function/Host *1
139 *
140 * J30 (for CN31) *1
141 * ----------+---------------+-------------
142 * 1-2 short | VBUS 5V | Host
143 * open | external VBUS | Function
144 *
145 * *1
146 * CN31 is used as Host in Linux.
147 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000148
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000149/*
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900150 * SDHI0 (CN12)
151 *
152 * SW56 : OFF
153 *
154 */
155
156/* MMC /SDHI1 (CN7)
157 *
158 * I/O voltage : 1.8v
159 *
160 * Power voltage : 1.8v or 3.3v
Yusuke Goda41491b92010-12-15 08:31:04 +0000161 * J22 : select power voltage *1
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900162 * 1-2 pin : 1.8v
163 * 2-3 pin : 3.3v
164 *
Yusuke Goda41491b92010-12-15 08:31:04 +0000165 * *1
166 * Please change J22 depends the card to be used.
167 * MMC's OCR field set to support either voltage for the card inserted.
168 *
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900169 * SW1 | SW33
170 * | bit1 | bit2 | bit3 | bit4
171 * -------------+------+------+------+-------
172 * MMC0 OFF | OFF | ON | ON | X
173 * MMC1 ON | OFF | ON | X | ON
174 * SDHI1 OFF | ON | X | OFF | ON
175 *
176 */
177
178/*
179 * SDHI2 (CN23)
180 *
181 * microSD card sloct
182 *
183 */
184
185/*
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000186 * FIXME !!
187 *
188 * gpio_no_direction
189 * are quick_hack.
190 *
191 * current gpio frame work doesn't have
192 * the method to control only pull up/down/free.
193 * this function should be replaced by correct gpio function
194 */
195static void __init gpio_no_direction(u32 addr)
196{
197 __raw_writeb(0x00, addr);
198}
199
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000200/* MTD */
201static struct mtd_partition nor_flash_partitions[] = {
202 {
203 .name = "loader",
204 .offset = 0x00000000,
205 .size = 512 * 1024,
206 .mask_flags = MTD_WRITEABLE,
207 },
208 {
209 .name = "bootenv",
210 .offset = MTDPART_OFS_APPEND,
211 .size = 512 * 1024,
212 .mask_flags = MTD_WRITEABLE,
213 },
214 {
215 .name = "kernel_ro",
216 .offset = MTDPART_OFS_APPEND,
217 .size = 8 * 1024 * 1024,
218 .mask_flags = MTD_WRITEABLE,
219 },
220 {
221 .name = "kernel",
222 .offset = MTDPART_OFS_APPEND,
223 .size = 8 * 1024 * 1024,
224 },
225 {
226 .name = "data",
227 .offset = MTDPART_OFS_APPEND,
228 .size = MTDPART_SIZ_FULL,
229 },
230};
231
232static struct physmap_flash_data nor_flash_data = {
233 .width = 2,
234 .parts = nor_flash_partitions,
235 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
236};
237
238static struct resource nor_flash_resources[] = {
239 [0] = {
240 .start = 0x00000000,
241 .end = 0x08000000 - 1,
242 .flags = IORESOURCE_MEM,
243 }
244};
245
246static struct platform_device nor_flash_device = {
247 .name = "physmap-flash",
248 .dev = {
249 .platform_data = &nor_flash_data,
250 },
251 .num_resources = ARRAY_SIZE(nor_flash_resources),
252 .resource = nor_flash_resources,
253};
254
Kuninori Morimoto2264c152010-11-29 02:21:37 +0000255/* SMSC */
256static struct resource smc911x_resources[] = {
257 {
258 .start = 0x14000000,
259 .end = 0x16000000 - 1,
260 .flags = IORESOURCE_MEM,
261 }, {
262 .start = evt2irq(0x02c0) /* IRQ6A */,
263 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
264 },
265};
266
267static struct smsc911x_platform_config smsc911x_info = {
268 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
269 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
270 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
271};
272
273static struct platform_device smc911x_device = {
274 .name = "smsc911x",
275 .id = -1,
276 .num_resources = ARRAY_SIZE(smc911x_resources),
277 .resource = smc911x_resources,
278 .dev = {
279 .platform_data = &smsc911x_info,
280 },
281};
282
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000283/* LCDC */
284static struct fb_videomode mackerel_lcdc_modes[] = {
285 {
286 .name = "WVGA Panel",
287 .xres = 800,
288 .yres = 480,
289 .left_margin = 220,
290 .right_margin = 110,
291 .hsync_len = 70,
292 .upper_margin = 20,
293 .lower_margin = 5,
294 .vsync_len = 5,
295 .sync = 0,
296 },
297};
298
299static struct sh_mobile_lcdc_info lcdc_info = {
300 .clock_source = LCDC_CLK_BUS,
301 .ch[0] = {
302 .chan = LCDC_CHAN_MAINLCD,
303 .bpp = 16,
304 .lcd_cfg = mackerel_lcdc_modes,
305 .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
306 .interface_type = RGB24,
307 .clock_divider = 2,
308 .flags = 0,
309 .lcd_size_cfg.width = 152,
310 .lcd_size_cfg.height = 91,
311 }
312};
313
314static struct resource lcdc_resources[] = {
315 [0] = {
316 .name = "LCDC",
317 .start = 0xfe940000,
318 .end = 0xfe943fff,
319 .flags = IORESOURCE_MEM,
320 },
321 [1] = {
322 .start = intcs_evt2irq(0x580),
323 .flags = IORESOURCE_IRQ,
324 },
325};
326
327static struct platform_device lcdc_device = {
328 .name = "sh_mobile_lcdc_fb",
329 .num_resources = ARRAY_SIZE(lcdc_resources),
330 .resource = lcdc_resources,
331 .dev = {
332 .platform_data = &lcdc_info,
333 .coherent_dma_mask = ~0,
334 },
335};
336
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000337/* HDMI */
338static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
339 .clock_source = LCDC_CLK_EXTERNAL,
340 .ch[0] = {
341 .chan = LCDC_CHAN_MAINLCD,
342 .bpp = 16,
343 .interface_type = RGB24,
344 .clock_divider = 1,
345 .flags = LCDC_FLAGS_DWPOL,
346 }
347};
348
349static struct resource hdmi_lcdc_resources[] = {
350 [0] = {
351 .name = "LCDC1",
352 .start = 0xfe944000,
353 .end = 0xfe947fff,
354 .flags = IORESOURCE_MEM,
355 },
356 [1] = {
357 .start = intcs_evt2irq(0x1780),
358 .flags = IORESOURCE_IRQ,
359 },
360};
361
362static struct platform_device hdmi_lcdc_device = {
363 .name = "sh_mobile_lcdc_fb",
364 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
365 .resource = hdmi_lcdc_resources,
366 .id = 1,
367 .dev = {
368 .platform_data = &hdmi_lcdc_info,
369 .coherent_dma_mask = ~0,
370 },
371};
372
373static struct sh_mobile_hdmi_info hdmi_info = {
374 .lcd_chan = &hdmi_lcdc_info.ch[0],
375 .lcd_dev = &hdmi_lcdc_device.dev,
376};
377
378static struct resource hdmi_resources[] = {
379 [0] = {
380 .name = "HDMI",
381 .start = 0xe6be0000,
382 .end = 0xe6be00ff,
383 .flags = IORESOURCE_MEM,
384 },
385 [1] = {
386 /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
387 .start = evt2irq(0x17e0),
388 .flags = IORESOURCE_IRQ,
389 },
390};
391
392static struct platform_device hdmi_device = {
393 .name = "sh-mobile-hdmi",
394 .num_resources = ARRAY_SIZE(hdmi_resources),
395 .resource = hdmi_resources,
396 .id = -1,
397 .dev = {
398 .platform_data = &hdmi_info,
399 },
400};
401
402static int __init hdmi_init_pm_clock(void)
403{
404 struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
405 int ret;
406 long rate;
407
408 if (IS_ERR(hdmi_ick)) {
409 ret = PTR_ERR(hdmi_ick);
410 pr_err("Cannot get HDMI ICK: %d\n", ret);
411 goto out;
412 }
413
414 ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
415 if (ret < 0) {
416 pr_err("Cannot set PLLC2 parent: %d, %d users\n",
417 ret, sh7372_pllc2_clk.usecount);
418 goto out;
419 }
420
421 pr_debug("PLLC2 initial frequency %lu\n",
422 clk_get_rate(&sh7372_pllc2_clk));
423
424 rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
425 if (rate < 0) {
426 pr_err("Cannot get suitable rate: %ld\n", rate);
427 ret = rate;
428 goto out;
429 }
430
431 ret = clk_set_rate(&sh7372_pllc2_clk, rate);
432 if (ret < 0) {
433 pr_err("Cannot set rate %ld: %d\n", rate, ret);
434 goto out;
435 }
436
437 ret = clk_enable(&sh7372_pllc2_clk);
438 if (ret < 0) {
439 pr_err("Cannot enable pllc2 clock\n");
440 goto out;
441 }
442
443 pr_debug("PLLC2 set frequency %lu\n", rate);
444
445 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
446 if (ret < 0) {
447 pr_err("Cannot set HDMI parent: %d\n", ret);
448 goto out;
449 }
450
451out:
452 if (!IS_ERR(hdmi_ick))
453 clk_put(hdmi_ick);
454 return ret;
455}
456device_initcall(hdmi_init_pm_clock);
457
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000458/* USB1 (Host) */
459static void usb1_host_port_power(int port, int power)
460{
461 if (!power) /* only power-on is supported for now */
462 return;
463
464 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
465 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
466}
467
468static struct r8a66597_platdata usb1_host_data = {
469 .on_chip = 1,
470 .port_power = usb1_host_port_power,
471};
472
473static struct resource usb1_host_resources[] = {
474 [0] = {
475 .name = "USBHS",
476 .start = 0xE68B0000,
477 .end = 0xE68B00E6 - 1,
478 .flags = IORESOURCE_MEM,
479 },
480 [1] = {
481 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
482 .flags = IORESOURCE_IRQ,
483 },
484};
485
486static struct platform_device usb1_host_device = {
487 .name = "r8a66597_hcd",
488 .id = 1,
489 .dev = {
490 .dma_mask = NULL, /* not use dma */
491 .coherent_dma_mask = 0xffffffff,
492 .platform_data = &usb1_host_data,
493 },
494 .num_resources = ARRAY_SIZE(usb1_host_resources),
495 .resource = usb1_host_resources,
496};
497
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000498/* LED */
499static struct gpio_led mackerel_leds[] = {
500 {
501 .name = "led0",
502 .gpio = GPIO_PORT0,
503 .default_state = LEDS_GPIO_DEFSTATE_ON,
504 },
505 {
506 .name = "led1",
507 .gpio = GPIO_PORT1,
508 .default_state = LEDS_GPIO_DEFSTATE_ON,
509 },
510 {
511 .name = "led2",
512 .gpio = GPIO_PORT2,
513 .default_state = LEDS_GPIO_DEFSTATE_ON,
514 },
515 {
516 .name = "led3",
517 .gpio = GPIO_PORT159,
518 .default_state = LEDS_GPIO_DEFSTATE_ON,
519 }
520};
521
522static struct gpio_led_platform_data mackerel_leds_pdata = {
523 .leds = mackerel_leds,
524 .num_leds = ARRAY_SIZE(mackerel_leds),
525};
526
527static struct platform_device leds_device = {
528 .name = "leds-gpio",
529 .id = 0,
530 .dev = {
531 .platform_data = &mackerel_leds_pdata,
532 },
533};
534
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000535/* FSI */
536#define IRQ_FSI evt2irq(0x1840)
537static struct sh_fsi_platform_info fsi_info = {
538 .porta_flags = SH_FSI_BRS_INV |
539 SH_FSI_OUT_SLAVE_MODE |
540 SH_FSI_IN_SLAVE_MODE |
541 SH_FSI_OFMT(PCM) |
542 SH_FSI_IFMT(PCM),
543};
544
545static struct resource fsi_resources[] = {
546 [0] = {
547 .name = "FSI",
548 .start = 0xFE3C0000,
549 .end = 0xFE3C0400 - 1,
550 .flags = IORESOURCE_MEM,
551 },
552 [1] = {
553 .start = IRQ_FSI,
554 .flags = IORESOURCE_IRQ,
555 },
556};
557
558static struct platform_device fsi_device = {
559 .name = "sh_fsi2",
560 .id = -1,
561 .num_resources = ARRAY_SIZE(fsi_resources),
562 .resource = fsi_resources,
563 .dev = {
564 .platform_data = &fsi_info,
565 },
566};
567
568static struct platform_device fsi_ak4643_device = {
569 .name = "sh_fsi2_a_ak4643",
570};
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000571
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900572/*
573 * The card detect pin of the top SD/MMC slot (CN7) is active low and is
574 * connected to GPIO A22 of SH7372 (GPIO_PORT41).
575 */
576static int slot_cn7_get_cd(struct platform_device *pdev)
577{
578 if (gpio_is_valid(GPIO_PORT41))
579 return !gpio_get_value(GPIO_PORT41);
580 else
581 return -ENXIO;
582}
583
584/* SDHI0 */
585static struct sh_mobile_sdhi_info sdhi0_info = {
586 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
587 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
588 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
589};
590
591static struct resource sdhi0_resources[] = {
592 [0] = {
593 .name = "SDHI0",
594 .start = 0xe6850000,
595 .end = 0xe68501ff,
596 .flags = IORESOURCE_MEM,
597 },
598 [1] = {
599 .start = evt2irq(0x0e00) /* SDHI0 */,
600 .flags = IORESOURCE_IRQ,
601 },
602};
603
604static struct platform_device sdhi0_device = {
605 .name = "sh_mobile_sdhi",
606 .num_resources = ARRAY_SIZE(sdhi0_resources),
607 .resource = sdhi0_resources,
608 .id = 0,
609 .dev = {
610 .platform_data = &sdhi0_info,
611 },
612};
613
Yusuke Goda41491b92010-12-15 08:31:04 +0000614#if !defined(CONFIG_MMC_SH_MMCIF)
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900615/* SDHI1 */
616static struct sh_mobile_sdhi_info sdhi1_info = {
617 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
618 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
619 .tmio_ocr_mask = MMC_VDD_165_195,
620 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
621 .tmio_caps = MMC_CAP_SD_HIGHSPEED |
622 MMC_CAP_NEEDS_POLL,
623 .get_cd = slot_cn7_get_cd,
624};
625
626static struct resource sdhi1_resources[] = {
627 [0] = {
628 .name = "SDHI1",
629 .start = 0xe6860000,
630 .end = 0xe68601ff,
631 .flags = IORESOURCE_MEM,
632 },
633 [1] = {
634 .start = evt2irq(0x0e80),
635 .flags = IORESOURCE_IRQ,
636 },
637};
638
639static struct platform_device sdhi1_device = {
640 .name = "sh_mobile_sdhi",
641 .num_resources = ARRAY_SIZE(sdhi1_resources),
642 .resource = sdhi1_resources,
643 .id = 1,
644 .dev = {
645 .platform_data = &sdhi1_info,
646 },
647};
Yusuke Goda41491b92010-12-15 08:31:04 +0000648#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900649
650/* SDHI2 */
651static struct sh_mobile_sdhi_info sdhi2_info = {
652 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
653 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
654 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
655 .tmio_caps = MMC_CAP_SD_HIGHSPEED |
656 MMC_CAP_NEEDS_POLL,
657};
658
659static struct resource sdhi2_resources[] = {
660 [0] = {
661 .name = "SDHI2",
662 .start = 0xe6870000,
663 .end = 0xe68701ff,
664 .flags = IORESOURCE_MEM,
665 },
666 [1] = {
667 .start = evt2irq(0x1200),
668 .flags = IORESOURCE_IRQ,
669 },
670};
671
672static struct platform_device sdhi2_device = {
673 .name = "sh_mobile_sdhi",
674 .num_resources = ARRAY_SIZE(sdhi2_resources),
675 .resource = sdhi2_resources,
676 .id = 2,
677 .dev = {
678 .platform_data = &sdhi2_info,
679 },
680};
681
Yusuke Goda41491b92010-12-15 08:31:04 +0000682/* SH_MMCIF */
683static struct resource sh_mmcif_resources[] = {
684 [0] = {
685 .name = "MMCIF",
686 .start = 0xE6BD0000,
687 .end = 0xE6BD00FF,
688 .flags = IORESOURCE_MEM,
689 },
690 [1] = {
691 /* MMC ERR */
692 .start = evt2irq(0x1ac0),
693 .flags = IORESOURCE_IRQ,
694 },
695 [2] = {
696 /* MMC NOR */
697 .start = evt2irq(0x1ae0),
698 .flags = IORESOURCE_IRQ,
699 },
700};
701
702static struct sh_mmcif_plat_data sh_mmcif_plat = {
703 .sup_pclk = 0,
704 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
705 .caps = MMC_CAP_4_BIT_DATA |
706 MMC_CAP_8_BIT_DATA |
707 MMC_CAP_NEEDS_POLL,
708 .get_cd = slot_cn7_get_cd,
709};
710
711static struct platform_device sh_mmcif_device = {
712 .name = "sh_mmcif",
713 .id = 0,
714 .dev = {
715 .dma_mask = NULL,
716 .coherent_dma_mask = 0xffffffff,
717 .platform_data = &sh_mmcif_plat,
718 },
719 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
720 .resource = sh_mmcif_resources,
721};
722
Magnus Dammae37c8d2010-12-22 14:47:40 +0000723
724static int mackerel_camera_add(struct soc_camera_link *icl, struct device *dev);
725static void mackerel_camera_del(struct soc_camera_link *icl);
726
727static int camera_set_capture(struct soc_camera_platform_info *info,
728 int enable)
729{
730 return 0; /* camera sensor always enabled */
731}
732
733static struct soc_camera_platform_info camera_info = {
734 .format_name = "UYVY",
735 .format_depth = 16,
736 .format = {
737 .code = V4L2_MBUS_FMT_UYVY8_2X8,
738 .colorspace = V4L2_COLORSPACE_SMPTE170M,
739 .field = V4L2_FIELD_NONE,
740 .width = 640,
741 .height = 480,
742 },
743 .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
744 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8 |
745 SOCAM_DATA_ACTIVE_HIGH,
746 .set_capture = camera_set_capture,
747};
748
749static struct soc_camera_link camera_link = {
750 .bus_id = 0,
751 .add_device = mackerel_camera_add,
752 .del_device = mackerel_camera_del,
753 .module_name = "soc_camera_platform",
754 .priv = &camera_info,
755};
756
757static void dummy_release(struct device *dev)
758{
759}
760
761static struct platform_device camera_device = {
762 .name = "soc_camera_platform",
763 .dev = {
764 .platform_data = &camera_info,
765 .release = dummy_release,
766 },
767};
768
769static int mackerel_camera_add(struct soc_camera_link *icl,
770 struct device *dev)
771{
772 if (icl != &camera_link)
773 return -ENODEV;
774
775 camera_info.dev = dev;
776
777 return platform_device_register(&camera_device);
778}
779
780static void mackerel_camera_del(struct soc_camera_link *icl)
781{
782 if (icl != &camera_link)
783 return;
784
785 platform_device_unregister(&camera_device);
786 memset(&camera_device.dev.kobj, 0,
787 sizeof(camera_device.dev.kobj));
788}
789
790static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
791 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
792};
793
794static struct resource ceu_resources[] = {
795 [0] = {
796 .name = "CEU",
797 .start = 0xfe910000,
798 .end = 0xfe91009f,
799 .flags = IORESOURCE_MEM,
800 },
801 [1] = {
802 .start = intcs_evt2irq(0x880),
803 .flags = IORESOURCE_IRQ,
804 },
805 [2] = {
806 /* place holder for contiguous memory */
807 },
808};
809
810static struct platform_device ceu_device = {
811 .name = "sh_mobile_ceu",
812 .id = 0, /* "ceu0" clock */
813 .num_resources = ARRAY_SIZE(ceu_resources),
814 .resource = ceu_resources,
815 .dev = {
816 .platform_data = &sh_mobile_ceu_info,
817 },
818};
819
820static struct platform_device mackerel_camera = {
821 .name = "soc-camera-pdrv",
822 .id = 0,
823 .dev = {
824 .platform_data = &camera_link,
825 },
826};
827
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000828static struct platform_device *mackerel_devices[] __initdata = {
829 &nor_flash_device,
Kuninori Morimoto2264c152010-11-29 02:21:37 +0000830 &smc911x_device,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000831 &lcdc_device,
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000832 &usb1_host_device,
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000833 &leds_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000834 &fsi_device,
835 &fsi_ak4643_device,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900836 &sdhi0_device,
Yusuke Goda41491b92010-12-15 08:31:04 +0000837#if !defined(CONFIG_MMC_SH_MMCIF)
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900838 &sdhi1_device,
Yusuke Goda41491b92010-12-15 08:31:04 +0000839#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900840 &sdhi2_device,
Yusuke Goda41491b92010-12-15 08:31:04 +0000841 &sh_mmcif_device,
Magnus Dammae37c8d2010-12-22 14:47:40 +0000842 &ceu_device,
843 &mackerel_camera,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000844 &hdmi_lcdc_device,
845 &hdmi_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000846};
847
Tony SIMcd8ab002010-12-09 01:55:55 +0000848/* Keypad Initialization */
849#define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
850{ \
851 .type = ev_type, \
852 .code = ev_code, \
853 .active_low = act_low, \
854}
855
856#define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
857
858static struct tca6416_button mackerel_gpio_keys[] = {
859 KEYPAD_BUTTON_LOW(KEY_HOME),
860 KEYPAD_BUTTON_LOW(KEY_MENU),
861 KEYPAD_BUTTON_LOW(KEY_BACK),
862 KEYPAD_BUTTON_LOW(KEY_POWER),
863};
864
865static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
866 .buttons = mackerel_gpio_keys,
867 .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
868 .rep = 1,
869 .use_polling = 0,
870 .pinmask = 0x000F,
871};
872
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000873/* I2C */
Tony SIMcd8ab002010-12-09 01:55:55 +0000874#define IRQ9 evt2irq(0x0320)
875
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000876static struct i2c_board_info i2c0_devices[] = {
877 {
878 I2C_BOARD_INFO("ak4643", 0x13),
879 },
Tony SIMcd8ab002010-12-09 01:55:55 +0000880 /* Keypad */
881 {
882 I2C_BOARD_INFO("tca6408-keys", 0x20),
883 .platform_data = &mackerel_tca6416_keys_info,
884 .irq = IRQ9,
885 },
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000886};
887
Tony SIM80f1dc72010-12-07 09:12:14 +0000888#define IRQ21 evt2irq(0x32a0)
889
890static struct i2c_board_info i2c1_devices[] = {
891 /* Accelerometer */
892 {
893 I2C_BOARD_INFO("adxl34x", 0x53),
894 .irq = IRQ21,
895 },
896};
897
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000898static struct map_desc mackerel_io_desc[] __initdata = {
899 /* create a 1:1 entity map for 0xe6xxxxxx
900 * used by CPGA, INTC and PFC.
901 */
902 {
903 .virtual = 0xe6000000,
904 .pfn = __phys_to_pfn(0xe6000000),
905 .length = 256 << 20,
906 .type = MT_DEVICE_NONSHARED
907 },
908};
909
910static void __init mackerel_map_io(void)
911{
912 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
913
914 /* setup early devices and console here as well */
915 sh7372_add_early_devices();
916 shmobile_setup_console();
917}
918
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000919#define GPIO_PORT9CR 0xE6051009
920#define GPIO_PORT10CR 0xE605100A
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000921#define SRCR4 0xe61580bc
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000922static void __init mackerel_init(void)
923{
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000924 u32 srcr4;
925
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000926 sh7372_pinmux_init();
927
928 /* enable SCIFA0 */
929 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
930 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
931
Kuninori Morimoto2264c152010-11-29 02:21:37 +0000932 /* enable SMSC911X */
933 gpio_request(GPIO_FN_CS5A, NULL);
934 gpio_request(GPIO_FN_IRQ6_39, NULL);
935
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000936 /* LCDC */
Kuninori Morimotoeb87e672010-11-29 06:19:52 +0000937 gpio_request(GPIO_FN_LCDD23, NULL);
938 gpio_request(GPIO_FN_LCDD22, NULL);
939 gpio_request(GPIO_FN_LCDD21, NULL);
940 gpio_request(GPIO_FN_LCDD20, NULL);
941 gpio_request(GPIO_FN_LCDD19, NULL);
942 gpio_request(GPIO_FN_LCDD18, NULL);
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000943 gpio_request(GPIO_FN_LCDD17, NULL);
944 gpio_request(GPIO_FN_LCDD16, NULL);
945 gpio_request(GPIO_FN_LCDD15, NULL);
946 gpio_request(GPIO_FN_LCDD14, NULL);
947 gpio_request(GPIO_FN_LCDD13, NULL);
948 gpio_request(GPIO_FN_LCDD12, NULL);
949 gpio_request(GPIO_FN_LCDD11, NULL);
950 gpio_request(GPIO_FN_LCDD10, NULL);
951 gpio_request(GPIO_FN_LCDD9, NULL);
952 gpio_request(GPIO_FN_LCDD8, NULL);
953 gpio_request(GPIO_FN_LCDD7, NULL);
954 gpio_request(GPIO_FN_LCDD6, NULL);
955 gpio_request(GPIO_FN_LCDD5, NULL);
956 gpio_request(GPIO_FN_LCDD4, NULL);
957 gpio_request(GPIO_FN_LCDD3, NULL);
958 gpio_request(GPIO_FN_LCDD2, NULL);
959 gpio_request(GPIO_FN_LCDD1, NULL);
960 gpio_request(GPIO_FN_LCDD0, NULL);
961 gpio_request(GPIO_FN_LCDDISP, NULL);
962 gpio_request(GPIO_FN_LCDDCK, NULL);
963
964 gpio_request(GPIO_PORT31, NULL); /* backlight */
965 gpio_direction_output(GPIO_PORT31, 1);
966
967 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
968 gpio_direction_output(GPIO_PORT151, 1);
969
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000970 /* USB enable */
971 gpio_request(GPIO_FN_VBUS0_1, NULL);
972 gpio_request(GPIO_FN_IDIN_1_18, NULL);
973 gpio_request(GPIO_FN_PWEN_1_115, NULL);
974 gpio_request(GPIO_FN_OVCN_1_114, NULL);
975 gpio_request(GPIO_FN_EXTLP_1, NULL);
976 gpio_request(GPIO_FN_OVCN2_1, NULL);
977
978 /* setup USB phy */
Kuninori Morimotod0fb0c42010-12-28 05:54:53 +0000979 __raw_writew(0x8a0a, 0xE6058130); /* USBCR4 */
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000980
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000981 /* enable FSI2 port A (ak4643) */
982 gpio_request(GPIO_FN_FSIAIBT, NULL);
983 gpio_request(GPIO_FN_FSIAILR, NULL);
984 gpio_request(GPIO_FN_FSIAISLD, NULL);
985 gpio_request(GPIO_FN_FSIAOSLD, NULL);
986 gpio_request(GPIO_PORT161, NULL);
987 gpio_direction_output(GPIO_PORT161, 0); /* slave */
988
989 gpio_request(GPIO_PORT9, NULL);
990 gpio_request(GPIO_PORT10, NULL);
991 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
992 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
993
994 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
995
Tony SIMcd8ab002010-12-09 01:55:55 +0000996 /* enable Keypad */
997 gpio_request(GPIO_FN_IRQ9_42, NULL);
998 set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
999
Tony SIM80f1dc72010-12-07 09:12:14 +00001000 /* enable Accelerometer */
1001 gpio_request(GPIO_FN_IRQ21, NULL);
1002 set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001003
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001004 /* enable SDHI0 */
1005 gpio_request(GPIO_FN_SDHICD0, NULL);
1006 gpio_request(GPIO_FN_SDHIWP0, NULL);
1007 gpio_request(GPIO_FN_SDHICMD0, NULL);
1008 gpio_request(GPIO_FN_SDHICLK0, NULL);
1009 gpio_request(GPIO_FN_SDHID0_3, NULL);
1010 gpio_request(GPIO_FN_SDHID0_2, NULL);
1011 gpio_request(GPIO_FN_SDHID0_1, NULL);
1012 gpio_request(GPIO_FN_SDHID0_0, NULL);
1013
Yusuke Goda41491b92010-12-15 08:31:04 +00001014#if !defined(CONFIG_MMC_SH_MMCIF)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001015 /* enable SDHI1 */
1016 gpio_request(GPIO_FN_SDHICMD1, NULL);
1017 gpio_request(GPIO_FN_SDHICLK1, NULL);
1018 gpio_request(GPIO_FN_SDHID1_3, NULL);
1019 gpio_request(GPIO_FN_SDHID1_2, NULL);
1020 gpio_request(GPIO_FN_SDHID1_1, NULL);
1021 gpio_request(GPIO_FN_SDHID1_0, NULL);
Yusuke Goda41491b92010-12-15 08:31:04 +00001022#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001023 /* card detect pin for MMC slot (CN7) */
1024 gpio_request(GPIO_PORT41, NULL);
1025 gpio_direction_input(GPIO_PORT41);
1026
1027 /* enable SDHI2 */
1028 gpio_request(GPIO_FN_SDHICMD2, NULL);
1029 gpio_request(GPIO_FN_SDHICLK2, NULL);
1030 gpio_request(GPIO_FN_SDHID2_3, NULL);
1031 gpio_request(GPIO_FN_SDHID2_2, NULL);
1032 gpio_request(GPIO_FN_SDHID2_1, NULL);
1033 gpio_request(GPIO_FN_SDHID2_0, NULL);
1034
Yusuke Goda41491b92010-12-15 08:31:04 +00001035 /* MMCIF */
1036 gpio_request(GPIO_FN_MMCD0_0, NULL);
1037 gpio_request(GPIO_FN_MMCD0_1, NULL);
1038 gpio_request(GPIO_FN_MMCD0_2, NULL);
1039 gpio_request(GPIO_FN_MMCD0_3, NULL);
1040 gpio_request(GPIO_FN_MMCD0_4, NULL);
1041 gpio_request(GPIO_FN_MMCD0_5, NULL);
1042 gpio_request(GPIO_FN_MMCD0_6, NULL);
1043 gpio_request(GPIO_FN_MMCD0_7, NULL);
1044 gpio_request(GPIO_FN_MMCCMD0, NULL);
1045 gpio_request(GPIO_FN_MMCCLK0, NULL);
1046
Yusuke Goda56e78da2010-12-20 01:06:04 +00001047 /* enable GPS module (GT-720F) */
1048 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
1049 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
1050
Magnus Dammae37c8d2010-12-22 14:47:40 +00001051 /* CEU */
1052 gpio_request(GPIO_FN_VIO_CLK, NULL);
1053 gpio_request(GPIO_FN_VIO_VD, NULL);
1054 gpio_request(GPIO_FN_VIO_HD, NULL);
1055 gpio_request(GPIO_FN_VIO_FIELD, NULL);
1056 gpio_request(GPIO_FN_VIO_CKO, NULL);
1057 gpio_request(GPIO_FN_VIO_D7, NULL);
1058 gpio_request(GPIO_FN_VIO_D6, NULL);
1059 gpio_request(GPIO_FN_VIO_D5, NULL);
1060 gpio_request(GPIO_FN_VIO_D4, NULL);
1061 gpio_request(GPIO_FN_VIO_D3, NULL);
1062 gpio_request(GPIO_FN_VIO_D2, NULL);
1063 gpio_request(GPIO_FN_VIO_D1, NULL);
1064 gpio_request(GPIO_FN_VIO_D0, NULL);
1065
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001066 /* HDMI */
1067 gpio_request(GPIO_FN_HDMI_HPD, NULL);
1068 gpio_request(GPIO_FN_HDMI_CEC, NULL);
1069
1070 /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
1071 srcr4 = __raw_readl(SRCR4);
1072 __raw_writel(srcr4 | (1 << 13), SRCR4);
1073 udelay(50);
1074 __raw_writel(srcr4 & ~(1 << 13), SRCR4);
1075
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001076 i2c_register_board_info(0, i2c0_devices,
1077 ARRAY_SIZE(i2c0_devices));
Tony SIM80f1dc72010-12-07 09:12:14 +00001078 i2c_register_board_info(1, i2c1_devices,
1079 ARRAY_SIZE(i2c1_devices));
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001080
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001081 sh7372_add_standard_devices();
1082
1083 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
1084}
1085
1086static void __init mackerel_timer_init(void)
1087{
1088 sh7372_clock_init();
1089 shmobile_timer.init();
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001090
1091 /* External clock source */
1092 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001093}
1094
1095static struct sys_timer mackerel_timer = {
1096 .init = mackerel_timer_init,
1097};
1098
1099MACHINE_START(MACKEREL, "mackerel")
1100 .map_io = mackerel_map_io,
1101 .init_irq = sh7372_init_irq,
1102 .init_machine = mackerel_init,
1103 .timer = &mackerel_timer,
1104MACHINE_END