2 * mackerel board support
4 * Copyright (C) 2010 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
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>
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>
46 #include <linux/usb/renesas_usbhs.h>
48 #include <video/sh_mobile_hdmi.h>
49 #include <video/sh_mobile_lcdc.h>
50 #include <media/sh_mobile_ceu.h>
51 #include <media/soc_camera.h>
52 #include <media/soc_camera_platform.h>
53 #include <sound/sh_fsi.h>
55 #include <mach/common.h>
56 #include <mach/sh7372.h>
58 #include <asm/mach/arch.h>
59 #include <asm/mach/time.h>
60 #include <asm/mach/map.h>
61 #include <asm/mach-types.h>
64 * Address Interface BusWidth note
65 * ------------------------------------------------------------------
66 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
67 * 0x0800_0000 user area -
68 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
69 * 0x1400_0000 Ether (LAN9220) 16bit
70 * 0x1600_0000 user area - cannot use with NAND
71 * 0x1800_0000 user area -
73 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
79 * SW4 | Boot Area| Master | Remarks
80 * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor|
81 * ----+-----+-----+-----+-----+-----+-----+----------+----------+--------------
82 * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM
83 * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug
84 * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug
85 * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM
86 * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM
87 * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM
88 * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone
89 * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone
95 * SW1 | SW2 | SW7 | NOR Flash ROM
96 * bit1 | bit1 bit2 | bit1 | Memory allocation
97 * ------+------------+------+------------------
98 * OFF | ON OFF | ON | Area 0
99 * OFF | ON OFF | OFF | Area 4
106 * -----------------------
114 * SW1 | SW2 | SW7 | NAND Flash ROM
115 * bit1 | bit1 bit2 | bit2 | Memory allocation
116 * ------+------------+------+------------------
117 * OFF | ON OFF | ON | FCE 0
118 * OFF | ON OFF | OFF | FCE 1
122 * External interrupt pin settings
124 * IRQX | pin setting | device | level
125 * ------+--------------------+--------------------+-------
126 * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low
127 * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High
128 * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Tuch Panel | Low
129 * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low
130 * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low
131 * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High
132 * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High
138 * USB0 : CN22 : Function
139 * USB1 : CN31 : Function/Host *1
142 * ----------+---------------+-------------
143 * 1-2 short | VBUS 5V | Host
144 * open | external VBUS | Function
148 * CONFIG_USB_R8A66597_HCD Host
149 * CONFIG_USB_RENESAS_USBHS Function
153 * renesas_usbhs driver can use external interrupt mode
154 * (which come from USB-PHY) or autonomy mode (it use own interrupt)
155 * for detecting connection/disconnection when Function.
156 * USB will be power OFF while it has been disconnecting
157 * if external interrupt mode, and it is always power ON if autonomy mode,
159 * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0",
160 * because Touchscreen is using IRQ7-PORT40.
161 * It is impossible to use IRQ7 demux on this board.
163 * We can use external interrupt mode USB-Function on "USB1".
164 * USB1 can become Host by r8a66597, and become Function by renesas_usbhs.
165 * But don't select both drivers in same time.
166 * These uses same IRQ number for request_irq(), and aren't supporting
167 * IRQF_SHARD / IORESOURCE_IRQ_SHAREABLE.
169 * Actually these are old/new version of USB driver.
170 * This mean its register will be broken if it supports SHARD IRQ,
184 * Power voltage : 1.8v or 3.3v
185 * J22 : select power voltage *1
190 * Please change J22 depends the card to be used.
191 * MMC's OCR field set to support either voltage for the card inserted.
194 * | bit1 | bit2 | bit3 | bit4
195 * -------------+------+------+------+-------
196 * MMC0 OFF | OFF | X | ON | X (Use MMCIF)
197 * SDHI1 OFF | ON | X | OFF | X (Use MFD_SH_MOBILE_SDHI)
215 * current gpio frame work doesn't have
216 * the method to control only pull up/down/free.
217 * this function should be replaced by correct gpio function
219 static void __init gpio_no_direction(u32 addr)
221 __raw_writeb(0x00, addr);
224 static void __init gpio_pull_down(u32 addr)
226 u8 data = __raw_readb(addr);
231 __raw_writeb(data, addr);
235 static struct mtd_partition nor_flash_partitions[] = {
238 .offset = 0x00000000,
240 .mask_flags = MTD_WRITEABLE,
244 .offset = MTDPART_OFS_APPEND,
246 .mask_flags = MTD_WRITEABLE,
250 .offset = MTDPART_OFS_APPEND,
251 .size = 8 * 1024 * 1024,
252 .mask_flags = MTD_WRITEABLE,
256 .offset = MTDPART_OFS_APPEND,
257 .size = 8 * 1024 * 1024,
261 .offset = MTDPART_OFS_APPEND,
262 .size = MTDPART_SIZ_FULL,
266 static struct physmap_flash_data nor_flash_data = {
268 .parts = nor_flash_partitions,
269 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
272 static struct resource nor_flash_resources[] = {
275 .end = 0x08000000 - 1,
276 .flags = IORESOURCE_MEM,
280 static struct platform_device nor_flash_device = {
281 .name = "physmap-flash",
283 .platform_data = &nor_flash_data,
285 .num_resources = ARRAY_SIZE(nor_flash_resources),
286 .resource = nor_flash_resources,
290 static struct resource smc911x_resources[] = {
293 .end = 0x16000000 - 1,
294 .flags = IORESOURCE_MEM,
296 .start = evt2irq(0x02c0) /* IRQ6A */,
297 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
301 static struct smsc911x_platform_config smsc911x_info = {
302 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
303 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
304 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
307 static struct platform_device smc911x_device = {
310 .num_resources = ARRAY_SIZE(smc911x_resources),
311 .resource = smc911x_resources,
313 .platform_data = &smsc911x_info,
318 static struct fb_videomode mackerel_lcdc_modes[] = {
320 .name = "WVGA Panel",
333 static int mackerel_set_brightness(void *board_data, int brightness)
335 gpio_set_value(GPIO_PORT31, brightness);
340 static int mackerel_get_brightness(void *board_data)
342 return gpio_get_value(GPIO_PORT31);
345 static struct sh_mobile_lcdc_info lcdc_info = {
346 .clock_source = LCDC_CLK_BUS,
348 .chan = LCDC_CHAN_MAINLCD,
350 .lcd_cfg = mackerel_lcdc_modes,
351 .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
352 .interface_type = RGB24,
355 .lcd_size_cfg.width = 152,
356 .lcd_size_cfg.height = 91,
358 .set_brightness = mackerel_set_brightness,
359 .get_brightness = mackerel_get_brightness,
362 .name = "sh_mobile_lcdc_bl",
368 static struct resource lcdc_resources[] = {
373 .flags = IORESOURCE_MEM,
376 .start = intcs_evt2irq(0x580),
377 .flags = IORESOURCE_IRQ,
381 static struct platform_device lcdc_device = {
382 .name = "sh_mobile_lcdc_fb",
383 .num_resources = ARRAY_SIZE(lcdc_resources),
384 .resource = lcdc_resources,
386 .platform_data = &lcdc_info,
387 .coherent_dma_mask = ~0,
392 static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
393 .clock_source = LCDC_CLK_EXTERNAL,
395 .chan = LCDC_CHAN_MAINLCD,
397 .interface_type = RGB24,
399 .flags = LCDC_FLAGS_DWPOL,
403 static struct resource hdmi_lcdc_resources[] = {
408 .flags = IORESOURCE_MEM,
411 .start = intcs_evt2irq(0x1780),
412 .flags = IORESOURCE_IRQ,
416 static struct platform_device hdmi_lcdc_device = {
417 .name = "sh_mobile_lcdc_fb",
418 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
419 .resource = hdmi_lcdc_resources,
422 .platform_data = &hdmi_lcdc_info,
423 .coherent_dma_mask = ~0,
427 static struct sh_mobile_hdmi_info hdmi_info = {
428 .lcd_chan = &hdmi_lcdc_info.ch[0],
429 .lcd_dev = &hdmi_lcdc_device.dev,
430 .flags = HDMI_SND_SRC_SPDIF,
433 static struct resource hdmi_resources[] = {
438 .flags = IORESOURCE_MEM,
441 /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
442 .start = evt2irq(0x17e0),
443 .flags = IORESOURCE_IRQ,
447 static struct platform_device hdmi_device = {
448 .name = "sh-mobile-hdmi",
449 .num_resources = ARRAY_SIZE(hdmi_resources),
450 .resource = hdmi_resources,
453 .platform_data = &hdmi_info,
457 static struct platform_device fsi_hdmi_device = {
458 .name = "sh_fsi2_b_hdmi",
461 static void __init hdmi_init_pm_clock(void)
463 struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
467 if (IS_ERR(hdmi_ick)) {
468 ret = PTR_ERR(hdmi_ick);
469 pr_err("Cannot get HDMI ICK: %d\n", ret);
473 ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
475 pr_err("Cannot set PLLC2 parent: %d, %d users\n",
476 ret, sh7372_pllc2_clk.usecount);
480 pr_debug("PLLC2 initial frequency %lu\n",
481 clk_get_rate(&sh7372_pllc2_clk));
483 rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
485 pr_err("Cannot get suitable rate: %ld\n", rate);
490 ret = clk_set_rate(&sh7372_pllc2_clk, rate);
492 pr_err("Cannot set rate %ld: %d\n", rate, ret);
496 pr_debug("PLLC2 set frequency %lu\n", rate);
498 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
500 pr_err("Cannot set HDMI parent: %d\n", ret);
503 if (!IS_ERR(hdmi_ick))
508 static void usb1_host_port_power(int port, int power)
510 if (!power) /* only power-on is supported for now */
513 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
514 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
517 static struct r8a66597_platdata usb1_host_data = {
519 .port_power = usb1_host_port_power,
522 static struct resource usb1_host_resources[] = {
526 .end = 0xE68B00E6 - 1,
527 .flags = IORESOURCE_MEM,
530 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
531 .flags = IORESOURCE_IRQ,
535 static struct platform_device usb1_host_device = {
536 .name = "r8a66597_hcd",
539 .dma_mask = NULL, /* not use dma */
540 .coherent_dma_mask = 0xffffffff,
541 .platform_data = &usb1_host_data,
543 .num_resources = ARRAY_SIZE(usb1_host_resources),
544 .resource = usb1_host_resources,
547 /* USB1 (Function) */
548 #define USB_PHY_MODE (1 << 4)
549 #define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
550 #define USB_PHY_ON (1 << 1)
551 #define USB_PHY_OFF (1 << 0)
552 #define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
554 struct usbhs_private {
556 unsigned int usbphyaddr;
557 unsigned int usbcrcaddr;
558 struct renesas_usbhs_platform_info info;
561 #define usbhs_get_priv(pdev) \
562 container_of(renesas_usbhs_get_info(pdev), \
563 struct usbhs_private, info)
565 #define usbhs_is_connected(priv) \
566 (!((1 << 7) & __raw_readw(priv->usbcrcaddr)))
568 static int usbhs1_get_id(struct platform_device *pdev)
573 static int usbhs1_get_vbus(struct platform_device *pdev)
575 return usbhs_is_connected(usbhs_get_priv(pdev));
578 static irqreturn_t usbhs1_interrupt(int irq, void *data)
580 struct platform_device *pdev = data;
581 struct usbhs_private *priv = usbhs_get_priv(pdev);
583 dev_dbg(&pdev->dev, "%s\n", __func__);
585 renesas_usbhs_call_notify_hotplug(pdev);
588 __raw_writew(__raw_readw(priv->usbphyaddr) | USB_PHY_INT_CLR,
594 static int usbhs1_hardware_init(struct platform_device *pdev)
596 struct usbhs_private *priv = usbhs_get_priv(pdev);
599 irq_set_irq_type(priv->irq, IRQ_TYPE_LEVEL_HIGH);
601 /* clear interrupt status */
602 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
604 ret = request_irq(priv->irq, usbhs1_interrupt, 0,
605 dev_name(&pdev->dev), pdev);
607 dev_err(&pdev->dev, "request_irq err\n");
611 /* enable USB phy interrupt */
612 __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->usbphyaddr);
617 static void usbhs1_hardware_exit(struct platform_device *pdev)
619 struct usbhs_private *priv = usbhs_get_priv(pdev);
621 /* clear interrupt status */
622 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
624 free_irq(priv->irq, pdev);
627 static void usbhs1_phy_reset(struct platform_device *pdev)
629 struct usbhs_private *priv = usbhs_get_priv(pdev);
632 __raw_writew(0x8a0a, priv->usbcrcaddr);
635 static u32 usbhs1_pipe_cfg[] = {
636 USB_ENDPOINT_XFER_CONTROL,
637 USB_ENDPOINT_XFER_ISOC,
638 USB_ENDPOINT_XFER_ISOC,
639 USB_ENDPOINT_XFER_BULK,
640 USB_ENDPOINT_XFER_BULK,
641 USB_ENDPOINT_XFER_BULK,
642 USB_ENDPOINT_XFER_INT,
643 USB_ENDPOINT_XFER_INT,
644 USB_ENDPOINT_XFER_INT,
645 USB_ENDPOINT_XFER_BULK,
646 USB_ENDPOINT_XFER_BULK,
647 USB_ENDPOINT_XFER_BULK,
648 USB_ENDPOINT_XFER_BULK,
649 USB_ENDPOINT_XFER_BULK,
650 USB_ENDPOINT_XFER_BULK,
651 USB_ENDPOINT_XFER_BULK,
654 static struct usbhs_private usbhs1_private = {
655 .irq = evt2irq(0x0300), /* IRQ8 */
656 .usbphyaddr = 0xE60581E2, /* USBPHY1INTAP */
657 .usbcrcaddr = 0xE6058130, /* USBCR4 */
659 .platform_callback = {
660 .hardware_init = usbhs1_hardware_init,
661 .hardware_exit = usbhs1_hardware_exit,
662 .phy_reset = usbhs1_phy_reset,
663 .get_id = usbhs1_get_id,
664 .get_vbus = usbhs1_get_vbus,
668 .pipe_type = usbhs1_pipe_cfg,
669 .pipe_size = ARRAY_SIZE(usbhs1_pipe_cfg),
674 static struct resource usbhs1_resources[] = {
678 .end = 0xE68B00E6 - 1,
679 .flags = IORESOURCE_MEM,
682 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
683 .flags = IORESOURCE_IRQ,
687 static struct platform_device usbhs1_device = {
688 .name = "renesas_usbhs",
691 .platform_data = &usbhs1_private.info,
693 .num_resources = ARRAY_SIZE(usbhs1_resources),
694 .resource = usbhs1_resources,
699 static struct gpio_led mackerel_leds[] = {
703 .default_state = LEDS_GPIO_DEFSTATE_ON,
708 .default_state = LEDS_GPIO_DEFSTATE_ON,
713 .default_state = LEDS_GPIO_DEFSTATE_ON,
717 .gpio = GPIO_PORT159,
718 .default_state = LEDS_GPIO_DEFSTATE_ON,
722 static struct gpio_led_platform_data mackerel_leds_pdata = {
723 .leds = mackerel_leds,
724 .num_leds = ARRAY_SIZE(mackerel_leds),
727 static struct platform_device leds_device = {
731 .platform_data = &mackerel_leds_pdata,
736 #define IRQ_FSI evt2irq(0x1840)
737 static int __fsi_set_round_rate(struct clk *clk, long rate, int enable)
749 ret = clk_set_rate(clk, clk_round_rate(clk, rate));
753 return clk_enable(clk);
756 static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
758 struct clk *fsib_clk;
759 struct clk *fdiv_clk = &sh7372_fsidivb_clk;
765 /* FSIA is slave mode. nothing to do here */
772 fsib_rate = rate * 256;
773 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
776 fsib_rate = 85428000; /* around 48kHz x 256 x 7 */
777 fdiv_rate = rate * 256;
778 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
781 pr_err("unsupported rate in FSI2 port B\n");
786 fsib_clk = clk_get(dev, "ickb");
787 if (IS_ERR(fsib_clk))
791 ret = __fsi_set_round_rate(fsib_clk, fsib_rate, enable);
793 goto fsi_set_rate_end;
796 ret = __fsi_set_round_rate(fdiv_clk, fdiv_rate, enable);
800 __fsi_set_round_rate(fsib_clk, fsib_rate, 0);
801 goto fsi_set_rate_end;
811 static struct sh_fsi_platform_info fsi_info = {
812 .porta_flags = SH_FSI_BRS_INV,
814 .portb_flags = SH_FSI_BRS_INV |
819 .set_rate = fsi_set_rate,
822 static struct resource fsi_resources[] = {
826 .end = 0xFE3C0400 - 1,
827 .flags = IORESOURCE_MEM,
831 .flags = IORESOURCE_IRQ,
835 static struct platform_device fsi_device = {
838 .num_resources = ARRAY_SIZE(fsi_resources),
839 .resource = fsi_resources,
841 .platform_data = &fsi_info,
845 static struct platform_device fsi_ak4643_device = {
846 .name = "sh_fsi2_a_ak4643",
850 * The card detect pin of the top SD/MMC slot (CN7) is active low and is
851 * connected to GPIO A22 of SH7372 (GPIO_PORT41).
853 static int slot_cn7_get_cd(struct platform_device *pdev)
855 return !gpio_get_value(GPIO_PORT41);
859 static struct sh_mobile_sdhi_info sdhi0_info = {
860 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
861 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
862 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
865 static struct resource sdhi0_resources[] = {
870 .flags = IORESOURCE_MEM,
873 .start = evt2irq(0x0e00) /* SDHI0_SDHI0I0 */,
874 .flags = IORESOURCE_IRQ,
877 .start = evt2irq(0x0e20) /* SDHI0_SDHI0I1 */,
878 .flags = IORESOURCE_IRQ,
881 .start = evt2irq(0x0e40) /* SDHI0_SDHI0I2 */,
882 .flags = IORESOURCE_IRQ,
886 static struct platform_device sdhi0_device = {
887 .name = "sh_mobile_sdhi",
888 .num_resources = ARRAY_SIZE(sdhi0_resources),
889 .resource = sdhi0_resources,
892 .platform_data = &sdhi0_info,
896 #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
898 static struct sh_mobile_sdhi_info sdhi1_info = {
899 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
900 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
901 .tmio_ocr_mask = MMC_VDD_165_195,
902 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
903 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
905 .get_cd = slot_cn7_get_cd,
908 static struct resource sdhi1_resources[] = {
913 .flags = IORESOURCE_MEM,
916 .start = evt2irq(0x0e80), /* SDHI1_SDHI1I0 */
917 .flags = IORESOURCE_IRQ,
920 .start = evt2irq(0x0ea0), /* SDHI1_SDHI1I1 */
921 .flags = IORESOURCE_IRQ,
924 .start = evt2irq(0x0ec0), /* SDHI1_SDHI1I2 */
925 .flags = IORESOURCE_IRQ,
929 static struct platform_device sdhi1_device = {
930 .name = "sh_mobile_sdhi",
931 .num_resources = ARRAY_SIZE(sdhi1_resources),
932 .resource = sdhi1_resources,
935 .platform_data = &sdhi1_info,
941 * The card detect pin of the top SD/MMC slot (CN23) is active low and is
942 * connected to GPIO SCIFB_SCK of SH7372 (GPIO_PORT162).
944 static int slot_cn23_get_cd(struct platform_device *pdev)
946 return !gpio_get_value(GPIO_PORT162);
950 static struct sh_mobile_sdhi_info sdhi2_info = {
951 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
952 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
953 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
954 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
956 .get_cd = slot_cn23_get_cd,
959 static struct resource sdhi2_resources[] = {
964 .flags = IORESOURCE_MEM,
967 .start = evt2irq(0x1200), /* SDHI2_SDHI2I0 */
968 .flags = IORESOURCE_IRQ,
971 .start = evt2irq(0x1220), /* SDHI2_SDHI2I1 */
972 .flags = IORESOURCE_IRQ,
975 .start = evt2irq(0x1240), /* SDHI2_SDHI2I2 */
976 .flags = IORESOURCE_IRQ,
980 static struct platform_device sdhi2_device = {
981 .name = "sh_mobile_sdhi",
982 .num_resources = ARRAY_SIZE(sdhi2_resources),
983 .resource = sdhi2_resources,
986 .platform_data = &sdhi2_info,
991 static struct resource sh_mmcif_resources[] = {
996 .flags = IORESOURCE_MEM,
1000 .start = evt2irq(0x1ac0),
1001 .flags = IORESOURCE_IRQ,
1005 .start = evt2irq(0x1ae0),
1006 .flags = IORESOURCE_IRQ,
1010 static struct sh_mmcif_dma sh_mmcif_dma = {
1012 .slave_id = SHDMA_SLAVE_MMCIF_RX,
1015 .slave_id = SHDMA_SLAVE_MMCIF_TX,
1019 static struct sh_mmcif_plat_data sh_mmcif_plat = {
1021 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
1022 .caps = MMC_CAP_4_BIT_DATA |
1023 MMC_CAP_8_BIT_DATA |
1025 .get_cd = slot_cn7_get_cd,
1026 .dma = &sh_mmcif_dma,
1029 static struct platform_device sh_mmcif_device = {
1034 .coherent_dma_mask = 0xffffffff,
1035 .platform_data = &sh_mmcif_plat,
1037 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
1038 .resource = sh_mmcif_resources,
1042 static int mackerel_camera_add(struct soc_camera_link *icl, struct device *dev);
1043 static void mackerel_camera_del(struct soc_camera_link *icl);
1045 static int camera_set_capture(struct soc_camera_platform_info *info,
1048 return 0; /* camera sensor always enabled */
1051 static struct soc_camera_platform_info camera_info = {
1052 .format_name = "UYVY",
1055 .code = V4L2_MBUS_FMT_UYVY8_2X8,
1056 .colorspace = V4L2_COLORSPACE_SMPTE170M,
1057 .field = V4L2_FIELD_NONE,
1061 .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
1062 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8 |
1063 SOCAM_DATA_ACTIVE_HIGH,
1064 .set_capture = camera_set_capture,
1067 static struct soc_camera_link camera_link = {
1069 .add_device = mackerel_camera_add,
1070 .del_device = mackerel_camera_del,
1071 .module_name = "soc_camera_platform",
1072 .priv = &camera_info,
1075 static struct platform_device *camera_device;
1077 static void mackerel_camera_release(struct device *dev)
1079 soc_camera_platform_release(&camera_device);
1082 static int mackerel_camera_add(struct soc_camera_link *icl,
1085 return soc_camera_platform_add(icl, dev, &camera_device, &camera_link,
1086 mackerel_camera_release, 0);
1089 static void mackerel_camera_del(struct soc_camera_link *icl)
1091 soc_camera_platform_del(icl, camera_device, &camera_link);
1094 static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
1095 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
1098 static struct resource ceu_resources[] = {
1101 .start = 0xfe910000,
1103 .flags = IORESOURCE_MEM,
1106 .start = intcs_evt2irq(0x880),
1107 .flags = IORESOURCE_IRQ,
1110 /* place holder for contiguous memory */
1114 static struct platform_device ceu_device = {
1115 .name = "sh_mobile_ceu",
1116 .id = 0, /* "ceu0" clock */
1117 .num_resources = ARRAY_SIZE(ceu_resources),
1118 .resource = ceu_resources,
1120 .platform_data = &sh_mobile_ceu_info,
1121 .coherent_dma_mask = 0xffffffff,
1125 static struct platform_device mackerel_camera = {
1126 .name = "soc-camera-pdrv",
1129 .platform_data = &camera_link,
1133 static struct platform_device *mackerel_devices[] __initdata = {
1144 #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1155 /* Keypad Initialization */
1156 #define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
1160 .active_low = act_low, \
1163 #define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
1165 static struct tca6416_button mackerel_gpio_keys[] = {
1166 KEYPAD_BUTTON_LOW(KEY_HOME),
1167 KEYPAD_BUTTON_LOW(KEY_MENU),
1168 KEYPAD_BUTTON_LOW(KEY_BACK),
1169 KEYPAD_BUTTON_LOW(KEY_POWER),
1172 static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
1173 .buttons = mackerel_gpio_keys,
1174 .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
1181 #define IRQ7 evt2irq(0x02e0)
1182 #define IRQ9 evt2irq(0x0320)
1184 static struct i2c_board_info i2c0_devices[] = {
1186 I2C_BOARD_INFO("ak4643", 0x13),
1190 I2C_BOARD_INFO("tca6408-keys", 0x20),
1191 .platform_data = &mackerel_tca6416_keys_info,
1196 I2C_BOARD_INFO("st1232-ts", 0x55),
1201 #define IRQ21 evt2irq(0x32a0)
1203 static struct i2c_board_info i2c1_devices[] = {
1206 I2C_BOARD_INFO("adxl34x", 0x53),
1211 static struct map_desc mackerel_io_desc[] __initdata = {
1212 /* create a 1:1 entity map for 0xe6xxxxxx
1213 * used by CPGA, INTC and PFC.
1216 .virtual = 0xe6000000,
1217 .pfn = __phys_to_pfn(0xe6000000),
1218 .length = 256 << 20,
1219 .type = MT_DEVICE_NONSHARED
1223 static void __init mackerel_map_io(void)
1225 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
1227 /* setup early devices and console here as well */
1228 sh7372_add_early_devices();
1229 shmobile_setup_console();
1232 #define GPIO_PORT9CR 0xE6051009
1233 #define GPIO_PORT10CR 0xE605100A
1234 #define GPIO_PORT168CR 0xE60520A8
1235 #define SRCR4 0xe61580bc
1236 #define USCCR1 0xE6058144
1237 static void __init mackerel_init(void)
1242 sh7372_pinmux_init();
1245 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
1246 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
1248 /* enable SMSC911X */
1249 gpio_request(GPIO_FN_CS5A, NULL);
1250 gpio_request(GPIO_FN_IRQ6_39, NULL);
1253 gpio_request(GPIO_FN_LCDD23, NULL);
1254 gpio_request(GPIO_FN_LCDD22, NULL);
1255 gpio_request(GPIO_FN_LCDD21, NULL);
1256 gpio_request(GPIO_FN_LCDD20, NULL);
1257 gpio_request(GPIO_FN_LCDD19, NULL);
1258 gpio_request(GPIO_FN_LCDD18, NULL);
1259 gpio_request(GPIO_FN_LCDD17, NULL);
1260 gpio_request(GPIO_FN_LCDD16, NULL);
1261 gpio_request(GPIO_FN_LCDD15, NULL);
1262 gpio_request(GPIO_FN_LCDD14, NULL);
1263 gpio_request(GPIO_FN_LCDD13, NULL);
1264 gpio_request(GPIO_FN_LCDD12, NULL);
1265 gpio_request(GPIO_FN_LCDD11, NULL);
1266 gpio_request(GPIO_FN_LCDD10, NULL);
1267 gpio_request(GPIO_FN_LCDD9, NULL);
1268 gpio_request(GPIO_FN_LCDD8, NULL);
1269 gpio_request(GPIO_FN_LCDD7, NULL);
1270 gpio_request(GPIO_FN_LCDD6, NULL);
1271 gpio_request(GPIO_FN_LCDD5, NULL);
1272 gpio_request(GPIO_FN_LCDD4, NULL);
1273 gpio_request(GPIO_FN_LCDD3, NULL);
1274 gpio_request(GPIO_FN_LCDD2, NULL);
1275 gpio_request(GPIO_FN_LCDD1, NULL);
1276 gpio_request(GPIO_FN_LCDD0, NULL);
1277 gpio_request(GPIO_FN_LCDDISP, NULL);
1278 gpio_request(GPIO_FN_LCDDCK, NULL);
1280 gpio_request(GPIO_PORT31, NULL); /* backlight */
1281 gpio_direction_output(GPIO_PORT31, 0); /* off by default */
1283 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
1284 gpio_direction_output(GPIO_PORT151, 1);
1287 gpio_request(GPIO_FN_VBUS0_1, NULL);
1288 gpio_request(GPIO_FN_IDIN_1_18, NULL);
1289 gpio_request(GPIO_FN_PWEN_1_115, NULL);
1290 gpio_request(GPIO_FN_OVCN_1_114, NULL);
1291 gpio_request(GPIO_FN_EXTLP_1, NULL);
1292 gpio_request(GPIO_FN_OVCN2_1, NULL);
1293 gpio_pull_down(GPIO_PORT168CR);
1296 __raw_writew(0x8a0a, 0xE6058130); /* USBCR4 */
1298 /* enable FSI2 port A (ak4643) */
1299 gpio_request(GPIO_FN_FSIAIBT, NULL);
1300 gpio_request(GPIO_FN_FSIAILR, NULL);
1301 gpio_request(GPIO_FN_FSIAISLD, NULL);
1302 gpio_request(GPIO_FN_FSIAOSLD, NULL);
1303 gpio_request(GPIO_PORT161, NULL);
1304 gpio_direction_output(GPIO_PORT161, 0); /* slave */
1306 gpio_request(GPIO_PORT9, NULL);
1307 gpio_request(GPIO_PORT10, NULL);
1308 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1309 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
1311 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
1313 /* setup FSI2 port B (HDMI) */
1314 gpio_request(GPIO_FN_FSIBCK, NULL);
1315 __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
1317 /* set SPU2 clock to 119.6 MHz */
1318 clk = clk_get(NULL, "spu_clk");
1320 clk_set_rate(clk, clk_round_rate(clk, 119600000));
1325 gpio_request(GPIO_FN_IRQ9_42, NULL);
1326 irq_set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
1328 /* enable Touchscreen */
1329 gpio_request(GPIO_FN_IRQ7_40, NULL);
1330 irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
1332 /* enable Accelerometer */
1333 gpio_request(GPIO_FN_IRQ21, NULL);
1334 irq_set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
1337 gpio_request(GPIO_FN_SDHICD0, NULL);
1338 gpio_request(GPIO_FN_SDHIWP0, NULL);
1339 gpio_request(GPIO_FN_SDHICMD0, NULL);
1340 gpio_request(GPIO_FN_SDHICLK0, NULL);
1341 gpio_request(GPIO_FN_SDHID0_3, NULL);
1342 gpio_request(GPIO_FN_SDHID0_2, NULL);
1343 gpio_request(GPIO_FN_SDHID0_1, NULL);
1344 gpio_request(GPIO_FN_SDHID0_0, NULL);
1346 #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1348 gpio_request(GPIO_FN_SDHICMD1, NULL);
1349 gpio_request(GPIO_FN_SDHICLK1, NULL);
1350 gpio_request(GPIO_FN_SDHID1_3, NULL);
1351 gpio_request(GPIO_FN_SDHID1_2, NULL);
1352 gpio_request(GPIO_FN_SDHID1_1, NULL);
1353 gpio_request(GPIO_FN_SDHID1_0, NULL);
1355 /* card detect pin for MMC slot (CN7) */
1356 gpio_request(GPIO_PORT41, NULL);
1357 gpio_direction_input(GPIO_PORT41);
1360 gpio_request(GPIO_FN_SDHICMD2, NULL);
1361 gpio_request(GPIO_FN_SDHICLK2, NULL);
1362 gpio_request(GPIO_FN_SDHID2_3, NULL);
1363 gpio_request(GPIO_FN_SDHID2_2, NULL);
1364 gpio_request(GPIO_FN_SDHID2_1, NULL);
1365 gpio_request(GPIO_FN_SDHID2_0, NULL);
1367 /* card detect pin for microSD slot (CN23) */
1368 gpio_request(GPIO_PORT162, NULL);
1369 gpio_direction_input(GPIO_PORT162);
1372 gpio_request(GPIO_FN_MMCD0_0, NULL);
1373 gpio_request(GPIO_FN_MMCD0_1, NULL);
1374 gpio_request(GPIO_FN_MMCD0_2, NULL);
1375 gpio_request(GPIO_FN_MMCD0_3, NULL);
1376 gpio_request(GPIO_FN_MMCD0_4, NULL);
1377 gpio_request(GPIO_FN_MMCD0_5, NULL);
1378 gpio_request(GPIO_FN_MMCD0_6, NULL);
1379 gpio_request(GPIO_FN_MMCD0_7, NULL);
1380 gpio_request(GPIO_FN_MMCCMD0, NULL);
1381 gpio_request(GPIO_FN_MMCCLK0, NULL);
1383 /* enable GPS module (GT-720F) */
1384 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
1385 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
1388 gpio_request(GPIO_FN_VIO_CLK, NULL);
1389 gpio_request(GPIO_FN_VIO_VD, NULL);
1390 gpio_request(GPIO_FN_VIO_HD, NULL);
1391 gpio_request(GPIO_FN_VIO_FIELD, NULL);
1392 gpio_request(GPIO_FN_VIO_CKO, NULL);
1393 gpio_request(GPIO_FN_VIO_D7, NULL);
1394 gpio_request(GPIO_FN_VIO_D6, NULL);
1395 gpio_request(GPIO_FN_VIO_D5, NULL);
1396 gpio_request(GPIO_FN_VIO_D4, NULL);
1397 gpio_request(GPIO_FN_VIO_D3, NULL);
1398 gpio_request(GPIO_FN_VIO_D2, NULL);
1399 gpio_request(GPIO_FN_VIO_D1, NULL);
1400 gpio_request(GPIO_FN_VIO_D0, NULL);
1403 gpio_request(GPIO_FN_HDMI_HPD, NULL);
1404 gpio_request(GPIO_FN_HDMI_CEC, NULL);
1406 /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
1407 srcr4 = __raw_readl(SRCR4);
1408 __raw_writel(srcr4 | (1 << 13), SRCR4);
1410 __raw_writel(srcr4 & ~(1 << 13), SRCR4);
1412 i2c_register_board_info(0, i2c0_devices,
1413 ARRAY_SIZE(i2c0_devices));
1414 i2c_register_board_info(1, i2c1_devices,
1415 ARRAY_SIZE(i2c1_devices));
1417 sh7372_add_standard_devices();
1419 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
1421 hdmi_init_pm_clock();
1425 static void __init mackerel_timer_init(void)
1427 sh7372_clock_init();
1428 shmobile_timer.init();
1430 /* External clock source */
1431 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1434 static struct sys_timer mackerel_timer = {
1435 .init = mackerel_timer_init,
1438 MACHINE_START(MACKEREL, "mackerel")
1439 .map_io = mackerel_map_io,
1440 .init_irq = sh7372_init_irq,
1441 .handle_irq = shmobile_handle_irq_intc,
1442 .init_machine = mackerel_init,
1443 .timer = &mackerel_timer,