Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc
[cris-mirror.git] / arch / arm / mach-shmobile / board-mackerel.c
blob8184d4d4f234dddd7cf219114a1d57787332391b
1 /*
2 * mackerel board support
4 * Copyright (C) 2010 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7 * based on ap4evb
8 * Copyright (C) 2010 Magnus Damm
9 * Copyright (C) 2008 Yoshihiro Shimoda
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.
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.
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
24 #include <linux/delay.h>
25 #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>
33 #include <linux/i2c.h>
34 #include <linux/leds.h>
35 #include <linux/mfd/tmio.h>
36 #include <linux/mmc/host.h>
37 #include <linux/mmc/sh_mmcif.h>
38 #include <linux/mmc/sh_mobile_sdhi.h>
39 #include <linux/mtd/mtd.h>
40 #include <linux/mtd/partitions.h>
41 #include <linux/mtd/physmap.h>
42 #include <linux/smsc911x.h>
43 #include <linux/sh_intc.h>
44 #include <linux/tca6416_keypad.h>
45 #include <linux/usb/r8a66597.h>
47 #include <video/sh_mobile_hdmi.h>
48 #include <video/sh_mobile_lcdc.h>
49 #include <media/sh_mobile_ceu.h>
50 #include <media/soc_camera.h>
51 #include <media/soc_camera_platform.h>
52 #include <sound/sh_fsi.h>
54 #include <mach/common.h>
55 #include <mach/sh7372.h>
57 #include <asm/mach/arch.h>
58 #include <asm/mach/time.h>
59 #include <asm/mach/map.h>
60 #include <asm/mach-types.h>
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
76 * CPU mode
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
92 * NOR Flash ROM
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
102 * SMSC 9220
104 * SW1 SMSC 9220
105 * -----------------------
106 * ON access disable
107 * OFF access enable
111 * NAND Flash ROM
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
121 * External interrupt pin settings
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
135 * USB
137 * USB0 : CN22 : Function
138 * USB1 : CN31 : Function/Host *1
140 * J30 (for CN31) *1
141 * ----------+---------------+-------------
142 * 1-2 short | VBUS 5V | Host
143 * open | external VBUS | Function
145 * *1
146 * CN31 is used as Host in Linux.
150 * SDHI0 (CN12)
152 * SW56 : OFF
156 /* MMC /SDHI1 (CN7)
158 * I/O voltage : 1.8v
160 * Power voltage : 1.8v or 3.3v
161 * J22 : select power voltage *1
162 * 1-2 pin : 1.8v
163 * 2-3 pin : 3.3v
165 * *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.
169 * SW1 | SW33
170 * | bit1 | bit2 | bit3 | bit4
171 * -------------+------+------+------+-------
172 * MMC0 OFF | OFF | X | ON | X (Use MMCIF)
173 * SDHI1 OFF | ON | X | OFF | X (Use MFD_SH_MOBILE_SDHI)
178 * SDHI2 (CN23)
180 * microSD card sloct
185 * FIXME !!
187 * gpio_no_direction
188 * are quick_hack.
190 * current gpio frame work doesn't have
191 * the method to control only pull up/down/free.
192 * this function should be replaced by correct gpio function
194 static void __init gpio_no_direction(u32 addr)
196 __raw_writeb(0x00, addr);
199 /* MTD */
200 static struct mtd_partition nor_flash_partitions[] = {
202 .name = "loader",
203 .offset = 0x00000000,
204 .size = 512 * 1024,
205 .mask_flags = MTD_WRITEABLE,
208 .name = "bootenv",
209 .offset = MTDPART_OFS_APPEND,
210 .size = 512 * 1024,
211 .mask_flags = MTD_WRITEABLE,
214 .name = "kernel_ro",
215 .offset = MTDPART_OFS_APPEND,
216 .size = 8 * 1024 * 1024,
217 .mask_flags = MTD_WRITEABLE,
220 .name = "kernel",
221 .offset = MTDPART_OFS_APPEND,
222 .size = 8 * 1024 * 1024,
225 .name = "data",
226 .offset = MTDPART_OFS_APPEND,
227 .size = MTDPART_SIZ_FULL,
231 static struct physmap_flash_data nor_flash_data = {
232 .width = 2,
233 .parts = nor_flash_partitions,
234 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
237 static struct resource nor_flash_resources[] = {
238 [0] = {
239 .start = 0x00000000,
240 .end = 0x08000000 - 1,
241 .flags = IORESOURCE_MEM,
245 static struct platform_device nor_flash_device = {
246 .name = "physmap-flash",
247 .dev = {
248 .platform_data = &nor_flash_data,
250 .num_resources = ARRAY_SIZE(nor_flash_resources),
251 .resource = nor_flash_resources,
254 /* SMSC */
255 static struct resource smc911x_resources[] = {
257 .start = 0x14000000,
258 .end = 0x16000000 - 1,
259 .flags = IORESOURCE_MEM,
260 }, {
261 .start = evt2irq(0x02c0) /* IRQ6A */,
262 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
266 static struct smsc911x_platform_config smsc911x_info = {
267 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
268 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
269 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
272 static struct platform_device smc911x_device = {
273 .name = "smsc911x",
274 .id = -1,
275 .num_resources = ARRAY_SIZE(smc911x_resources),
276 .resource = smc911x_resources,
277 .dev = {
278 .platform_data = &smsc911x_info,
282 /* LCDC */
283 static struct fb_videomode mackerel_lcdc_modes[] = {
285 .name = "WVGA Panel",
286 .xres = 800,
287 .yres = 480,
288 .left_margin = 220,
289 .right_margin = 110,
290 .hsync_len = 70,
291 .upper_margin = 20,
292 .lower_margin = 5,
293 .vsync_len = 5,
294 .sync = 0,
298 static int mackerel_set_brightness(void *board_data, int brightness)
300 gpio_set_value(GPIO_PORT31, brightness);
302 return 0;
305 static int mackerel_get_brightness(void *board_data)
307 return gpio_get_value(GPIO_PORT31);
310 static struct sh_mobile_lcdc_info lcdc_info = {
311 .clock_source = LCDC_CLK_BUS,
312 .ch[0] = {
313 .chan = LCDC_CHAN_MAINLCD,
314 .bpp = 16,
315 .lcd_cfg = mackerel_lcdc_modes,
316 .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
317 .interface_type = RGB24,
318 .clock_divider = 3,
319 .flags = 0,
320 .lcd_size_cfg.width = 152,
321 .lcd_size_cfg.height = 91,
322 .board_cfg = {
323 .set_brightness = mackerel_set_brightness,
324 .get_brightness = mackerel_get_brightness,
326 .bl_info = {
327 .name = "sh_mobile_lcdc_bl",
328 .max_brightness = 1,
333 static struct resource lcdc_resources[] = {
334 [0] = {
335 .name = "LCDC",
336 .start = 0xfe940000,
337 .end = 0xfe943fff,
338 .flags = IORESOURCE_MEM,
340 [1] = {
341 .start = intcs_evt2irq(0x580),
342 .flags = IORESOURCE_IRQ,
346 static struct platform_device lcdc_device = {
347 .name = "sh_mobile_lcdc_fb",
348 .num_resources = ARRAY_SIZE(lcdc_resources),
349 .resource = lcdc_resources,
350 .dev = {
351 .platform_data = &lcdc_info,
352 .coherent_dma_mask = ~0,
356 /* HDMI */
357 static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
358 .clock_source = LCDC_CLK_EXTERNAL,
359 .ch[0] = {
360 .chan = LCDC_CHAN_MAINLCD,
361 .bpp = 16,
362 .interface_type = RGB24,
363 .clock_divider = 1,
364 .flags = LCDC_FLAGS_DWPOL,
368 static struct resource hdmi_lcdc_resources[] = {
369 [0] = {
370 .name = "LCDC1",
371 .start = 0xfe944000,
372 .end = 0xfe947fff,
373 .flags = IORESOURCE_MEM,
375 [1] = {
376 .start = intcs_evt2irq(0x1780),
377 .flags = IORESOURCE_IRQ,
381 static struct platform_device hdmi_lcdc_device = {
382 .name = "sh_mobile_lcdc_fb",
383 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
384 .resource = hdmi_lcdc_resources,
385 .id = 1,
386 .dev = {
387 .platform_data = &hdmi_lcdc_info,
388 .coherent_dma_mask = ~0,
392 static struct sh_mobile_hdmi_info hdmi_info = {
393 .lcd_chan = &hdmi_lcdc_info.ch[0],
394 .lcd_dev = &hdmi_lcdc_device.dev,
395 .flags = HDMI_SND_SRC_SPDIF,
398 static struct resource hdmi_resources[] = {
399 [0] = {
400 .name = "HDMI",
401 .start = 0xe6be0000,
402 .end = 0xe6be00ff,
403 .flags = IORESOURCE_MEM,
405 [1] = {
406 /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
407 .start = evt2irq(0x17e0),
408 .flags = IORESOURCE_IRQ,
412 static struct platform_device hdmi_device = {
413 .name = "sh-mobile-hdmi",
414 .num_resources = ARRAY_SIZE(hdmi_resources),
415 .resource = hdmi_resources,
416 .id = -1,
417 .dev = {
418 .platform_data = &hdmi_info,
422 static struct platform_device fsi_hdmi_device = {
423 .name = "sh_fsi2_b_hdmi",
426 static int __init hdmi_init_pm_clock(void)
428 struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
429 int ret;
430 long rate;
432 if (IS_ERR(hdmi_ick)) {
433 ret = PTR_ERR(hdmi_ick);
434 pr_err("Cannot get HDMI ICK: %d\n", ret);
435 goto out;
438 ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
439 if (ret < 0) {
440 pr_err("Cannot set PLLC2 parent: %d, %d users\n",
441 ret, sh7372_pllc2_clk.usecount);
442 goto out;
445 pr_debug("PLLC2 initial frequency %lu\n",
446 clk_get_rate(&sh7372_pllc2_clk));
448 rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
449 if (rate < 0) {
450 pr_err("Cannot get suitable rate: %ld\n", rate);
451 ret = rate;
452 goto out;
455 ret = clk_set_rate(&sh7372_pllc2_clk, rate);
456 if (ret < 0) {
457 pr_err("Cannot set rate %ld: %d\n", rate, ret);
458 goto out;
461 ret = clk_enable(&sh7372_pllc2_clk);
462 if (ret < 0) {
463 pr_err("Cannot enable pllc2 clock\n");
464 goto out;
467 pr_debug("PLLC2 set frequency %lu\n", rate);
469 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
470 if (ret < 0) {
471 pr_err("Cannot set HDMI parent: %d\n", ret);
472 goto out;
475 out:
476 if (!IS_ERR(hdmi_ick))
477 clk_put(hdmi_ick);
478 return ret;
480 device_initcall(hdmi_init_pm_clock);
482 /* USB1 (Host) */
483 static void usb1_host_port_power(int port, int power)
485 if (!power) /* only power-on is supported for now */
486 return;
488 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
489 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
492 static struct r8a66597_platdata usb1_host_data = {
493 .on_chip = 1,
494 .port_power = usb1_host_port_power,
497 static struct resource usb1_host_resources[] = {
498 [0] = {
499 .name = "USBHS",
500 .start = 0xE68B0000,
501 .end = 0xE68B00E6 - 1,
502 .flags = IORESOURCE_MEM,
504 [1] = {
505 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
506 .flags = IORESOURCE_IRQ,
510 static struct platform_device usb1_host_device = {
511 .name = "r8a66597_hcd",
512 .id = 1,
513 .dev = {
514 .dma_mask = NULL, /* not use dma */
515 .coherent_dma_mask = 0xffffffff,
516 .platform_data = &usb1_host_data,
518 .num_resources = ARRAY_SIZE(usb1_host_resources),
519 .resource = usb1_host_resources,
522 /* LED */
523 static struct gpio_led mackerel_leds[] = {
525 .name = "led0",
526 .gpio = GPIO_PORT0,
527 .default_state = LEDS_GPIO_DEFSTATE_ON,
530 .name = "led1",
531 .gpio = GPIO_PORT1,
532 .default_state = LEDS_GPIO_DEFSTATE_ON,
535 .name = "led2",
536 .gpio = GPIO_PORT2,
537 .default_state = LEDS_GPIO_DEFSTATE_ON,
540 .name = "led3",
541 .gpio = GPIO_PORT159,
542 .default_state = LEDS_GPIO_DEFSTATE_ON,
546 static struct gpio_led_platform_data mackerel_leds_pdata = {
547 .leds = mackerel_leds,
548 .num_leds = ARRAY_SIZE(mackerel_leds),
551 static struct platform_device leds_device = {
552 .name = "leds-gpio",
553 .id = 0,
554 .dev = {
555 .platform_data = &mackerel_leds_pdata,
559 /* FSI */
560 #define IRQ_FSI evt2irq(0x1840)
561 static int __fsi_set_round_rate(struct clk *clk, long rate, int enable)
563 int ret;
565 if (rate <= 0)
566 return 0;
568 if (!enable) {
569 clk_disable(clk);
570 return 0;
573 ret = clk_set_rate(clk, clk_round_rate(clk, rate));
574 if (ret < 0)
575 return ret;
577 return clk_enable(clk);
580 static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
582 struct clk *fsib_clk;
583 struct clk *fdiv_clk = &sh7372_fsidivb_clk;
584 long fsib_rate = 0;
585 long fdiv_rate = 0;
586 int ackmd_bpfmd;
587 int ret;
589 /* FSIA is slave mode. nothing to do here */
590 if (is_porta)
591 return 0;
593 /* clock start */
594 switch (rate) {
595 case 44100:
596 fsib_rate = rate * 256;
597 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
598 break;
599 case 48000:
600 fsib_rate = 85428000; /* around 48kHz x 256 x 7 */
601 fdiv_rate = rate * 256;
602 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
603 break;
604 default:
605 pr_err("unsupported rate in FSI2 port B\n");
606 return -EINVAL;
609 /* FSI B setting */
610 fsib_clk = clk_get(dev, "ickb");
611 if (IS_ERR(fsib_clk))
612 return -EIO;
614 /* fsib */
615 ret = __fsi_set_round_rate(fsib_clk, fsib_rate, enable);
616 if (ret < 0)
617 goto fsi_set_rate_end;
619 /* FSI DIV */
620 ret = __fsi_set_round_rate(fdiv_clk, fdiv_rate, enable);
621 if (ret < 0) {
622 /* disable FSI B */
623 if (enable)
624 __fsi_set_round_rate(fsib_clk, fsib_rate, 0);
625 goto fsi_set_rate_end;
628 ret = ackmd_bpfmd;
630 fsi_set_rate_end:
631 clk_put(fsib_clk);
632 return ret;
635 static struct sh_fsi_platform_info fsi_info = {
636 .porta_flags = SH_FSI_BRS_INV,
638 .portb_flags = SH_FSI_BRS_INV |
639 SH_FSI_BRM_INV |
640 SH_FSI_LRS_INV |
641 SH_FSI_FMT_SPDIF,
643 .set_rate = fsi_set_rate,
646 static struct resource fsi_resources[] = {
647 [0] = {
648 .name = "FSI",
649 .start = 0xFE3C0000,
650 .end = 0xFE3C0400 - 1,
651 .flags = IORESOURCE_MEM,
653 [1] = {
654 .start = IRQ_FSI,
655 .flags = IORESOURCE_IRQ,
659 static struct platform_device fsi_device = {
660 .name = "sh_fsi2",
661 .id = -1,
662 .num_resources = ARRAY_SIZE(fsi_resources),
663 .resource = fsi_resources,
664 .dev = {
665 .platform_data = &fsi_info,
669 static struct platform_device fsi_ak4643_device = {
670 .name = "sh_fsi2_a_ak4643",
674 * The card detect pin of the top SD/MMC slot (CN7) is active low and is
675 * connected to GPIO A22 of SH7372 (GPIO_PORT41).
677 static int slot_cn7_get_cd(struct platform_device *pdev)
679 return !gpio_get_value(GPIO_PORT41);
682 /* SDHI0 */
683 static struct sh_mobile_sdhi_info sdhi0_info = {
684 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
685 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
686 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
689 static struct resource sdhi0_resources[] = {
690 [0] = {
691 .name = "SDHI0",
692 .start = 0xe6850000,
693 .end = 0xe68500ff,
694 .flags = IORESOURCE_MEM,
696 [1] = {
697 .start = evt2irq(0x0e00) /* SDHI0 */,
698 .flags = IORESOURCE_IRQ,
702 static struct platform_device sdhi0_device = {
703 .name = "sh_mobile_sdhi",
704 .num_resources = ARRAY_SIZE(sdhi0_resources),
705 .resource = sdhi0_resources,
706 .id = 0,
707 .dev = {
708 .platform_data = &sdhi0_info,
712 #if !defined(CONFIG_MMC_SH_MMCIF)
713 /* SDHI1 */
714 static struct sh_mobile_sdhi_info sdhi1_info = {
715 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
716 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
717 .tmio_ocr_mask = MMC_VDD_165_195,
718 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
719 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
720 MMC_CAP_NEEDS_POLL,
721 .get_cd = slot_cn7_get_cd,
724 static struct resource sdhi1_resources[] = {
725 [0] = {
726 .name = "SDHI1",
727 .start = 0xe6860000,
728 .end = 0xe68600ff,
729 .flags = IORESOURCE_MEM,
731 [1] = {
732 .start = evt2irq(0x0e80),
733 .flags = IORESOURCE_IRQ,
737 static struct platform_device sdhi1_device = {
738 .name = "sh_mobile_sdhi",
739 .num_resources = ARRAY_SIZE(sdhi1_resources),
740 .resource = sdhi1_resources,
741 .id = 1,
742 .dev = {
743 .platform_data = &sdhi1_info,
746 #endif
749 * The card detect pin of the top SD/MMC slot (CN23) is active low and is
750 * connected to GPIO SCIFB_SCK of SH7372 (GPIO_PORT162).
752 static int slot_cn23_get_cd(struct platform_device *pdev)
754 return !gpio_get_value(GPIO_PORT162);
757 /* SDHI2 */
758 static struct sh_mobile_sdhi_info sdhi2_info = {
759 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
760 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
761 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
762 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
763 MMC_CAP_NEEDS_POLL,
764 .get_cd = slot_cn23_get_cd,
767 static struct resource sdhi2_resources[] = {
768 [0] = {
769 .name = "SDHI2",
770 .start = 0xe6870000,
771 .end = 0xe68700ff,
772 .flags = IORESOURCE_MEM,
774 [1] = {
775 .start = evt2irq(0x1200),
776 .flags = IORESOURCE_IRQ,
780 static struct platform_device sdhi2_device = {
781 .name = "sh_mobile_sdhi",
782 .num_resources = ARRAY_SIZE(sdhi2_resources),
783 .resource = sdhi2_resources,
784 .id = 2,
785 .dev = {
786 .platform_data = &sdhi2_info,
790 /* SH_MMCIF */
791 static struct resource sh_mmcif_resources[] = {
792 [0] = {
793 .name = "MMCIF",
794 .start = 0xE6BD0000,
795 .end = 0xE6BD00FF,
796 .flags = IORESOURCE_MEM,
798 [1] = {
799 /* MMC ERR */
800 .start = evt2irq(0x1ac0),
801 .flags = IORESOURCE_IRQ,
803 [2] = {
804 /* MMC NOR */
805 .start = evt2irq(0x1ae0),
806 .flags = IORESOURCE_IRQ,
810 static struct sh_mmcif_plat_data sh_mmcif_plat = {
811 .sup_pclk = 0,
812 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
813 .caps = MMC_CAP_4_BIT_DATA |
814 MMC_CAP_8_BIT_DATA |
815 MMC_CAP_NEEDS_POLL,
816 .get_cd = slot_cn7_get_cd,
819 static struct platform_device sh_mmcif_device = {
820 .name = "sh_mmcif",
821 .id = 0,
822 .dev = {
823 .dma_mask = NULL,
824 .coherent_dma_mask = 0xffffffff,
825 .platform_data = &sh_mmcif_plat,
827 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
828 .resource = sh_mmcif_resources,
832 static int mackerel_camera_add(struct soc_camera_link *icl, struct device *dev);
833 static void mackerel_camera_del(struct soc_camera_link *icl);
835 static int camera_set_capture(struct soc_camera_platform_info *info,
836 int enable)
838 return 0; /* camera sensor always enabled */
841 static struct soc_camera_platform_info camera_info = {
842 .format_name = "UYVY",
843 .format_depth = 16,
844 .format = {
845 .code = V4L2_MBUS_FMT_UYVY8_2X8,
846 .colorspace = V4L2_COLORSPACE_SMPTE170M,
847 .field = V4L2_FIELD_NONE,
848 .width = 640,
849 .height = 480,
851 .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
852 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8 |
853 SOCAM_DATA_ACTIVE_HIGH,
854 .set_capture = camera_set_capture,
857 static struct soc_camera_link camera_link = {
858 .bus_id = 0,
859 .add_device = mackerel_camera_add,
860 .del_device = mackerel_camera_del,
861 .module_name = "soc_camera_platform",
862 .priv = &camera_info,
865 static void dummy_release(struct device *dev)
869 static struct platform_device camera_device = {
870 .name = "soc_camera_platform",
871 .dev = {
872 .platform_data = &camera_info,
873 .release = dummy_release,
877 static int mackerel_camera_add(struct soc_camera_link *icl,
878 struct device *dev)
880 if (icl != &camera_link)
881 return -ENODEV;
883 camera_info.dev = dev;
885 return platform_device_register(&camera_device);
888 static void mackerel_camera_del(struct soc_camera_link *icl)
890 if (icl != &camera_link)
891 return;
893 platform_device_unregister(&camera_device);
894 memset(&camera_device.dev.kobj, 0,
895 sizeof(camera_device.dev.kobj));
898 static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
899 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
902 static struct resource ceu_resources[] = {
903 [0] = {
904 .name = "CEU",
905 .start = 0xfe910000,
906 .end = 0xfe91009f,
907 .flags = IORESOURCE_MEM,
909 [1] = {
910 .start = intcs_evt2irq(0x880),
911 .flags = IORESOURCE_IRQ,
913 [2] = {
914 /* place holder for contiguous memory */
918 static struct platform_device ceu_device = {
919 .name = "sh_mobile_ceu",
920 .id = 0, /* "ceu0" clock */
921 .num_resources = ARRAY_SIZE(ceu_resources),
922 .resource = ceu_resources,
923 .dev = {
924 .platform_data = &sh_mobile_ceu_info,
925 .coherent_dma_mask = 0xffffffff,
929 static struct platform_device mackerel_camera = {
930 .name = "soc-camera-pdrv",
931 .id = 0,
932 .dev = {
933 .platform_data = &camera_link,
937 static struct platform_device *mackerel_devices[] __initdata = {
938 &nor_flash_device,
939 &smc911x_device,
940 &lcdc_device,
941 &usb1_host_device,
942 &leds_device,
943 &fsi_device,
944 &fsi_ak4643_device,
945 &fsi_hdmi_device,
946 &sdhi0_device,
947 #if !defined(CONFIG_MMC_SH_MMCIF)
948 &sdhi1_device,
949 #endif
950 &sdhi2_device,
951 &sh_mmcif_device,
952 &ceu_device,
953 &mackerel_camera,
954 &hdmi_lcdc_device,
955 &hdmi_device,
958 /* Keypad Initialization */
959 #define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
961 .type = ev_type, \
962 .code = ev_code, \
963 .active_low = act_low, \
966 #define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
968 static struct tca6416_button mackerel_gpio_keys[] = {
969 KEYPAD_BUTTON_LOW(KEY_HOME),
970 KEYPAD_BUTTON_LOW(KEY_MENU),
971 KEYPAD_BUTTON_LOW(KEY_BACK),
972 KEYPAD_BUTTON_LOW(KEY_POWER),
975 static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
976 .buttons = mackerel_gpio_keys,
977 .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
978 .rep = 1,
979 .use_polling = 0,
980 .pinmask = 0x000F,
983 /* I2C */
984 #define IRQ7 evt2irq(0x02e0)
985 #define IRQ9 evt2irq(0x0320)
987 static struct i2c_board_info i2c0_devices[] = {
989 I2C_BOARD_INFO("ak4643", 0x13),
991 /* Keypad */
993 I2C_BOARD_INFO("tca6408-keys", 0x20),
994 .platform_data = &mackerel_tca6416_keys_info,
995 .irq = IRQ9,
997 /* Touchscreen */
999 I2C_BOARD_INFO("st1232-ts", 0x55),
1000 .irq = IRQ7,
1004 #define IRQ21 evt2irq(0x32a0)
1006 static struct i2c_board_info i2c1_devices[] = {
1007 /* Accelerometer */
1009 I2C_BOARD_INFO("adxl34x", 0x53),
1010 .irq = IRQ21,
1014 static struct map_desc mackerel_io_desc[] __initdata = {
1015 /* create a 1:1 entity map for 0xe6xxxxxx
1016 * used by CPGA, INTC and PFC.
1019 .virtual = 0xe6000000,
1020 .pfn = __phys_to_pfn(0xe6000000),
1021 .length = 256 << 20,
1022 .type = MT_DEVICE_NONSHARED
1026 static void __init mackerel_map_io(void)
1028 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
1030 /* setup early devices and console here as well */
1031 sh7372_add_early_devices();
1032 shmobile_setup_console();
1035 #define GPIO_PORT9CR 0xE6051009
1036 #define GPIO_PORT10CR 0xE605100A
1037 #define SRCR4 0xe61580bc
1038 #define USCCR1 0xE6058144
1039 static void __init mackerel_init(void)
1041 u32 srcr4;
1042 struct clk *clk;
1044 sh7372_pinmux_init();
1046 /* enable SCIFA0 */
1047 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
1048 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
1050 /* enable SMSC911X */
1051 gpio_request(GPIO_FN_CS5A, NULL);
1052 gpio_request(GPIO_FN_IRQ6_39, NULL);
1054 /* LCDC */
1055 gpio_request(GPIO_FN_LCDD23, NULL);
1056 gpio_request(GPIO_FN_LCDD22, NULL);
1057 gpio_request(GPIO_FN_LCDD21, NULL);
1058 gpio_request(GPIO_FN_LCDD20, NULL);
1059 gpio_request(GPIO_FN_LCDD19, NULL);
1060 gpio_request(GPIO_FN_LCDD18, NULL);
1061 gpio_request(GPIO_FN_LCDD17, NULL);
1062 gpio_request(GPIO_FN_LCDD16, NULL);
1063 gpio_request(GPIO_FN_LCDD15, NULL);
1064 gpio_request(GPIO_FN_LCDD14, NULL);
1065 gpio_request(GPIO_FN_LCDD13, NULL);
1066 gpio_request(GPIO_FN_LCDD12, NULL);
1067 gpio_request(GPIO_FN_LCDD11, NULL);
1068 gpio_request(GPIO_FN_LCDD10, NULL);
1069 gpio_request(GPIO_FN_LCDD9, NULL);
1070 gpio_request(GPIO_FN_LCDD8, NULL);
1071 gpio_request(GPIO_FN_LCDD7, NULL);
1072 gpio_request(GPIO_FN_LCDD6, NULL);
1073 gpio_request(GPIO_FN_LCDD5, NULL);
1074 gpio_request(GPIO_FN_LCDD4, NULL);
1075 gpio_request(GPIO_FN_LCDD3, NULL);
1076 gpio_request(GPIO_FN_LCDD2, NULL);
1077 gpio_request(GPIO_FN_LCDD1, NULL);
1078 gpio_request(GPIO_FN_LCDD0, NULL);
1079 gpio_request(GPIO_FN_LCDDISP, NULL);
1080 gpio_request(GPIO_FN_LCDDCK, NULL);
1082 gpio_request(GPIO_PORT31, NULL); /* backlight */
1083 gpio_direction_output(GPIO_PORT31, 0); /* off by default */
1085 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
1086 gpio_direction_output(GPIO_PORT151, 1);
1088 /* USB enable */
1089 gpio_request(GPIO_FN_VBUS0_1, NULL);
1090 gpio_request(GPIO_FN_IDIN_1_18, NULL);
1091 gpio_request(GPIO_FN_PWEN_1_115, NULL);
1092 gpio_request(GPIO_FN_OVCN_1_114, NULL);
1093 gpio_request(GPIO_FN_EXTLP_1, NULL);
1094 gpio_request(GPIO_FN_OVCN2_1, NULL);
1096 /* setup USB phy */
1097 __raw_writew(0x8a0a, 0xE6058130); /* USBCR4 */
1099 /* enable FSI2 port A (ak4643) */
1100 gpio_request(GPIO_FN_FSIAIBT, NULL);
1101 gpio_request(GPIO_FN_FSIAILR, NULL);
1102 gpio_request(GPIO_FN_FSIAISLD, NULL);
1103 gpio_request(GPIO_FN_FSIAOSLD, NULL);
1104 gpio_request(GPIO_PORT161, NULL);
1105 gpio_direction_output(GPIO_PORT161, 0); /* slave */
1107 gpio_request(GPIO_PORT9, NULL);
1108 gpio_request(GPIO_PORT10, NULL);
1109 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1110 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
1112 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
1114 /* setup FSI2 port B (HDMI) */
1115 gpio_request(GPIO_FN_FSIBCK, NULL);
1116 __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
1118 /* set SPU2 clock to 119.6 MHz */
1119 clk = clk_get(NULL, "spu_clk");
1120 if (!IS_ERR(clk)) {
1121 clk_set_rate(clk, clk_round_rate(clk, 119600000));
1122 clk_put(clk);
1125 /* enable Keypad */
1126 gpio_request(GPIO_FN_IRQ9_42, NULL);
1127 irq_set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
1129 /* enable Touchscreen */
1130 gpio_request(GPIO_FN_IRQ7_40, NULL);
1131 irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
1133 /* enable Accelerometer */
1134 gpio_request(GPIO_FN_IRQ21, NULL);
1135 irq_set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
1137 /* enable SDHI0 */
1138 gpio_request(GPIO_FN_SDHICD0, NULL);
1139 gpio_request(GPIO_FN_SDHIWP0, NULL);
1140 gpio_request(GPIO_FN_SDHICMD0, NULL);
1141 gpio_request(GPIO_FN_SDHICLK0, NULL);
1142 gpio_request(GPIO_FN_SDHID0_3, NULL);
1143 gpio_request(GPIO_FN_SDHID0_2, NULL);
1144 gpio_request(GPIO_FN_SDHID0_1, NULL);
1145 gpio_request(GPIO_FN_SDHID0_0, NULL);
1147 #if !defined(CONFIG_MMC_SH_MMCIF)
1148 /* enable SDHI1 */
1149 gpio_request(GPIO_FN_SDHICMD1, NULL);
1150 gpio_request(GPIO_FN_SDHICLK1, NULL);
1151 gpio_request(GPIO_FN_SDHID1_3, NULL);
1152 gpio_request(GPIO_FN_SDHID1_2, NULL);
1153 gpio_request(GPIO_FN_SDHID1_1, NULL);
1154 gpio_request(GPIO_FN_SDHID1_0, NULL);
1155 #endif
1156 /* card detect pin for MMC slot (CN7) */
1157 gpio_request(GPIO_PORT41, NULL);
1158 gpio_direction_input(GPIO_PORT41);
1160 /* enable SDHI2 */
1161 gpio_request(GPIO_FN_SDHICMD2, NULL);
1162 gpio_request(GPIO_FN_SDHICLK2, NULL);
1163 gpio_request(GPIO_FN_SDHID2_3, NULL);
1164 gpio_request(GPIO_FN_SDHID2_2, NULL);
1165 gpio_request(GPIO_FN_SDHID2_1, NULL);
1166 gpio_request(GPIO_FN_SDHID2_0, NULL);
1168 /* card detect pin for microSD slot (CN23) */
1169 gpio_request(GPIO_PORT162, NULL);
1170 gpio_direction_input(GPIO_PORT162);
1172 /* MMCIF */
1173 gpio_request(GPIO_FN_MMCD0_0, NULL);
1174 gpio_request(GPIO_FN_MMCD0_1, NULL);
1175 gpio_request(GPIO_FN_MMCD0_2, NULL);
1176 gpio_request(GPIO_FN_MMCD0_3, NULL);
1177 gpio_request(GPIO_FN_MMCD0_4, NULL);
1178 gpio_request(GPIO_FN_MMCD0_5, NULL);
1179 gpio_request(GPIO_FN_MMCD0_6, NULL);
1180 gpio_request(GPIO_FN_MMCD0_7, NULL);
1181 gpio_request(GPIO_FN_MMCCMD0, NULL);
1182 gpio_request(GPIO_FN_MMCCLK0, NULL);
1184 /* enable GPS module (GT-720F) */
1185 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
1186 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
1188 /* CEU */
1189 gpio_request(GPIO_FN_VIO_CLK, NULL);
1190 gpio_request(GPIO_FN_VIO_VD, NULL);
1191 gpio_request(GPIO_FN_VIO_HD, NULL);
1192 gpio_request(GPIO_FN_VIO_FIELD, NULL);
1193 gpio_request(GPIO_FN_VIO_CKO, NULL);
1194 gpio_request(GPIO_FN_VIO_D7, NULL);
1195 gpio_request(GPIO_FN_VIO_D6, NULL);
1196 gpio_request(GPIO_FN_VIO_D5, NULL);
1197 gpio_request(GPIO_FN_VIO_D4, NULL);
1198 gpio_request(GPIO_FN_VIO_D3, NULL);
1199 gpio_request(GPIO_FN_VIO_D2, NULL);
1200 gpio_request(GPIO_FN_VIO_D1, NULL);
1201 gpio_request(GPIO_FN_VIO_D0, NULL);
1203 /* HDMI */
1204 gpio_request(GPIO_FN_HDMI_HPD, NULL);
1205 gpio_request(GPIO_FN_HDMI_CEC, NULL);
1207 /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
1208 srcr4 = __raw_readl(SRCR4);
1209 __raw_writel(srcr4 | (1 << 13), SRCR4);
1210 udelay(50);
1211 __raw_writel(srcr4 & ~(1 << 13), SRCR4);
1213 i2c_register_board_info(0, i2c0_devices,
1214 ARRAY_SIZE(i2c0_devices));
1215 i2c_register_board_info(1, i2c1_devices,
1216 ARRAY_SIZE(i2c1_devices));
1218 sh7372_add_standard_devices();
1220 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
1223 static void __init mackerel_timer_init(void)
1225 sh7372_clock_init();
1226 shmobile_timer.init();
1228 /* External clock source */
1229 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1232 static struct sys_timer mackerel_timer = {
1233 .init = mackerel_timer_init,
1236 MACHINE_START(MACKEREL, "mackerel")
1237 .map_io = mackerel_map_io,
1238 .init_irq = sh7372_init_irq,
1239 .handle_irq = shmobile_handle_irq_intc,
1240 .init_machine = mackerel_init,
1241 .timer = &mackerel_timer,
1242 MACHINE_END