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/mtd/sh_flctl.h>
43 #include <linux/pinctrl/machine.h>
44 #include <linux/pm_clock.h>
45 #include <linux/regulator/fixed.h>
46 #include <linux/regulator/machine.h>
47 #include <linux/smsc911x.h>
48 #include <linux/sh_intc.h>
49 #include <linux/tca6416_keypad.h>
50 #include <linux/usb/renesas_usbhs.h>
51 #include <linux/dma-mapping.h>
53 #include <video/sh_mobile_hdmi.h>
54 #include <video/sh_mobile_lcdc.h>
55 #include <media/sh_mobile_ceu.h>
56 #include <media/soc_camera.h>
57 #include <media/soc_camera_platform.h>
58 #include <sound/sh_fsi.h>
59 #include <sound/simple_card.h>
61 #include <mach/common.h>
62 #include <mach/irqs.h>
63 #include <mach/sh7372.h>
65 #include <asm/mach/arch.h>
66 #include <asm/mach-types.h>
71 * Address Interface BusWidth note
72 * ------------------------------------------------------------------
73 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
74 * 0x0800_0000 user area -
75 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
76 * 0x1400_0000 Ether (LAN9220) 16bit
77 * 0x1600_0000 user area - cannot use with NAND
78 * 0x1800_0000 user area -
80 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
86 * SW4 | Boot Area| Master | Remarks
87 * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor|
88 * ----+-----+-----+-----+-----+-----+-----+----------+----------+--------------
89 * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM
90 * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug
91 * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug
92 * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM
93 * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM
94 * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM
95 * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone
96 * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone
102 * SW1 | SW2 | SW7 | NOR Flash ROM
103 * bit1 | bit1 bit2 | bit1 | Memory allocation
104 * ------+------------+------+------------------
105 * OFF | ON OFF | ON | Area 0
106 * OFF | ON OFF | OFF | Area 4
113 * -----------------------
121 * SW1 | SW2 | SW7 | NAND Flash ROM
122 * bit1 | bit1 bit2 | bit2 | Memory allocation
123 * ------+------------+------+------------------
124 * OFF | ON OFF | ON | FCE 0
125 * OFF | ON OFF | OFF | FCE 1
129 * External interrupt pin settings
131 * IRQX | pin setting | device | level
132 * ------+--------------------+--------------------+-------
133 * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low
134 * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High
135 * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Touch Panel | Low
136 * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low
137 * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low
138 * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High
139 * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High
145 * USB0 : CN22 : Function
146 * USB1 : CN31 : Function/Host *1
149 * ----------+---------------+-------------
150 * 1-2 short | VBUS 5V | Host
151 * open | external VBUS | Function
155 * renesas_usbhs driver can use external interrupt mode
156 * (which come from USB-PHY) or autonomy mode (it use own interrupt)
157 * for detecting connection/disconnection when Function.
158 * USB will be power OFF while it has been disconnecting
159 * if external interrupt mode, and it is always power ON if autonomy mode,
161 * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0",
162 * because Touchscreen is using IRQ7-PORT40.
163 * It is impossible to use IRQ7 demux on this board.
177 * Power voltage : 1.8v or 3.3v
178 * J22 : select power voltage *1
183 * Please change J22 depends the card to be used.
184 * MMC's OCR field set to support either voltage for the card inserted.
187 * | bit1 | bit2 | bit3 | bit4
188 * -------------+------+------+------+-------
189 * MMC0 OFF | OFF | X | ON | X (Use MMCIF)
190 * SDHI1 OFF | ON | X | OFF | X (Use MFD_SH_MOBILE_SDHI)
204 * it needs amixer settings for playing
206 * amixer set "Headphone Enable" on
209 /* Fixed 3.3V and 1.8V regulators to be used by multiple devices */
210 static struct regulator_consumer_supply fixed1v8_power_consumers
[] =
213 * J22 on mackerel switches mmcif.0 and sdhi.1 between 1.8V and 3.3V
214 * Since we cannot support both voltages, we support the default 1.8V
216 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
217 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
218 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
219 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
222 static struct regulator_consumer_supply fixed3v3_power_consumers
[] =
224 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
225 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
226 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"),
227 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.2"),
230 /* Dummy supplies, where voltage doesn't matter */
231 static struct regulator_consumer_supply dummy_supplies
[] = {
232 REGULATOR_SUPPLY("vddvario", "smsc911x"),
233 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
237 static struct mtd_partition nor_flash_partitions
[] = {
240 .offset
= 0x00000000,
242 .mask_flags
= MTD_WRITEABLE
,
246 .offset
= MTDPART_OFS_APPEND
,
248 .mask_flags
= MTD_WRITEABLE
,
252 .offset
= MTDPART_OFS_APPEND
,
253 .size
= 8 * 1024 * 1024,
254 .mask_flags
= MTD_WRITEABLE
,
258 .offset
= MTDPART_OFS_APPEND
,
259 .size
= 8 * 1024 * 1024,
263 .offset
= MTDPART_OFS_APPEND
,
264 .size
= MTDPART_SIZ_FULL
,
268 static struct physmap_flash_data nor_flash_data
= {
270 .parts
= nor_flash_partitions
,
271 .nr_parts
= ARRAY_SIZE(nor_flash_partitions
),
274 static struct resource nor_flash_resources
[] = {
276 .start
= 0x20000000, /* CS0 shadow instead of regular CS0 */
277 .end
= 0x28000000 - 1, /* needed by USB MASK ROM boot */
278 .flags
= IORESOURCE_MEM
,
282 static struct platform_device nor_flash_device
= {
283 .name
= "physmap-flash",
285 .platform_data
= &nor_flash_data
,
287 .num_resources
= ARRAY_SIZE(nor_flash_resources
),
288 .resource
= nor_flash_resources
,
292 static struct resource smc911x_resources
[] = {
295 .end
= 0x16000000 - 1,
296 .flags
= IORESOURCE_MEM
,
298 .start
= evt2irq(0x02c0) /* IRQ6A */,
299 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWLEVEL
,
303 static struct smsc911x_platform_config smsc911x_info
= {
304 .flags
= SMSC911X_USE_16BIT
| SMSC911X_SAVE_MAC_ADDRESS
,
305 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
306 .irq_type
= SMSC911X_IRQ_TYPE_PUSH_PULL
,
309 static struct platform_device smc911x_device
= {
312 .num_resources
= ARRAY_SIZE(smc911x_resources
),
313 .resource
= smc911x_resources
,
315 .platform_data
= &smsc911x_info
,
320 static struct sh_mobile_meram_info mackerel_meram_info
= {
321 .addr_mode
= SH_MOBILE_MERAM_MODE1
,
324 static struct resource meram_resources
[] = {
329 .flags
= IORESOURCE_MEM
,
335 .flags
= IORESOURCE_MEM
,
339 static struct platform_device meram_device
= {
340 .name
= "sh_mobile_meram",
342 .num_resources
= ARRAY_SIZE(meram_resources
),
343 .resource
= meram_resources
,
345 .platform_data
= &mackerel_meram_info
,
350 static struct fb_videomode mackerel_lcdc_modes
[] = {
352 .name
= "WVGA Panel",
365 static int mackerel_set_brightness(int brightness
)
367 gpio_set_value(31, brightness
);
372 static const struct sh_mobile_meram_cfg lcd_meram_cfg
= {
381 static struct sh_mobile_lcdc_info lcdc_info
= {
382 .meram_dev
= &mackerel_meram_info
,
383 .clock_source
= LCDC_CLK_BUS
,
385 .chan
= LCDC_CHAN_MAINLCD
,
386 .fourcc
= V4L2_PIX_FMT_RGB565
,
387 .lcd_modes
= mackerel_lcdc_modes
,
388 .num_modes
= ARRAY_SIZE(mackerel_lcdc_modes
),
389 .interface_type
= RGB24
,
397 .name
= "sh_mobile_lcdc_bl",
399 .set_brightness
= mackerel_set_brightness
,
401 .meram_cfg
= &lcd_meram_cfg
,
405 static struct resource lcdc_resources
[] = {
410 .flags
= IORESOURCE_MEM
,
413 .start
= intcs_evt2irq(0x580),
414 .flags
= IORESOURCE_IRQ
,
418 static struct platform_device lcdc_device
= {
419 .name
= "sh_mobile_lcdc_fb",
420 .num_resources
= ARRAY_SIZE(lcdc_resources
),
421 .resource
= lcdc_resources
,
423 .platform_data
= &lcdc_info
,
424 .coherent_dma_mask
= ~0,
429 static struct sh_mobile_hdmi_info hdmi_info
= {
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 const struct sh_mobile_meram_cfg hdmi_meram_cfg
= {
466 static struct sh_mobile_lcdc_info hdmi_lcdc_info
= {
467 .meram_dev
= &mackerel_meram_info
,
468 .clock_source
= LCDC_CLK_EXTERNAL
,
470 .chan
= LCDC_CHAN_MAINLCD
,
471 .fourcc
= V4L2_PIX_FMT_RGB565
,
472 .interface_type
= RGB24
,
474 .flags
= LCDC_FLAGS_DWPOL
,
475 .meram_cfg
= &hdmi_meram_cfg
,
476 .tx_dev
= &hdmi_device
,
480 static struct resource hdmi_lcdc_resources
[] = {
485 .flags
= IORESOURCE_MEM
,
488 .start
= intcs_evt2irq(0x1780),
489 .flags
= IORESOURCE_IRQ
,
493 static struct platform_device hdmi_lcdc_device
= {
494 .name
= "sh_mobile_lcdc_fb",
495 .num_resources
= ARRAY_SIZE(hdmi_lcdc_resources
),
496 .resource
= hdmi_lcdc_resources
,
499 .platform_data
= &hdmi_lcdc_info
,
500 .coherent_dma_mask
= ~0,
504 static struct asoc_simple_card_info fsi2_hdmi_info
= {
506 .card
= "FSI2B-HDMI",
507 .codec
= "sh-mobile-hdmi",
508 .platform
= "sh_fsi2",
511 .fmt
= SND_SOC_DAIFMT_CBM_CFM
| SND_SOC_DAIFMT_IB_NF
,
514 .name
= "sh_mobile_hdmi-hifi",
518 static struct platform_device fsi_hdmi_device
= {
519 .name
= "asoc-simple-card",
522 .platform_data
= &fsi2_hdmi_info
,
526 static void __init
hdmi_init_pm_clock(void)
528 struct clk
*hdmi_ick
= clk_get(&hdmi_device
.dev
, "ick");
532 if (IS_ERR(hdmi_ick
)) {
533 ret
= PTR_ERR(hdmi_ick
);
534 pr_err("Cannot get HDMI ICK: %d\n", ret
);
538 ret
= clk_set_parent(&sh7372_pllc2_clk
, &sh7372_dv_clki_div2_clk
);
540 pr_err("Cannot set PLLC2 parent: %d, %d users\n",
541 ret
, sh7372_pllc2_clk
.usecount
);
545 pr_debug("PLLC2 initial frequency %lu\n",
546 clk_get_rate(&sh7372_pllc2_clk
));
548 rate
= clk_round_rate(&sh7372_pllc2_clk
, 594000000);
550 pr_err("Cannot get suitable rate: %ld\n", rate
);
555 ret
= clk_set_rate(&sh7372_pllc2_clk
, rate
);
557 pr_err("Cannot set rate %ld: %d\n", rate
, ret
);
561 pr_debug("PLLC2 set frequency %lu\n", rate
);
563 ret
= clk_set_parent(hdmi_ick
, &sh7372_pllc2_clk
);
565 pr_err("Cannot set HDMI parent: %d\n", ret
);
568 if (!IS_ERR(hdmi_ick
))
572 /* USBHS0 is connected to CN22 which takes a USB Mini-B plug
574 * The sh7372 SoC has IRQ7 set aside for USBHS0 hotplug,
575 * but on this particular board IRQ7 is already used by
576 * the touch screen. This leaves us with software polling.
578 #define USBHS0_POLL_INTERVAL (HZ * 5)
580 struct usbhs_private
{
581 void __iomem
*usbphyaddr
;
582 void __iomem
*usbcrcaddr
;
583 struct renesas_usbhs_platform_info info
;
584 struct delayed_work work
;
585 struct platform_device
*pdev
;
588 #define usbhs_get_priv(pdev) \
589 container_of(renesas_usbhs_get_info(pdev), \
590 struct usbhs_private, info)
592 #define usbhs_is_connected(priv) \
593 (!((1 << 7) & __raw_readw(priv->usbcrcaddr)))
595 static int usbhs_get_vbus(struct platform_device
*pdev
)
597 return usbhs_is_connected(usbhs_get_priv(pdev
));
600 static int usbhs_phy_reset(struct platform_device
*pdev
)
602 struct usbhs_private
*priv
= usbhs_get_priv(pdev
);
605 __raw_writew(0x8a0a, priv
->usbcrcaddr
);
610 static int usbhs0_get_id(struct platform_device
*pdev
)
615 static void usbhs0_work_function(struct work_struct
*work
)
617 struct usbhs_private
*priv
= container_of(work
, struct usbhs_private
,
620 renesas_usbhs_call_notify_hotplug(priv
->pdev
);
621 schedule_delayed_work(&priv
->work
, USBHS0_POLL_INTERVAL
);
624 static int usbhs0_hardware_init(struct platform_device
*pdev
)
626 struct usbhs_private
*priv
= usbhs_get_priv(pdev
);
629 INIT_DELAYED_WORK(&priv
->work
, usbhs0_work_function
);
630 schedule_delayed_work(&priv
->work
, USBHS0_POLL_INTERVAL
);
634 static int usbhs0_hardware_exit(struct platform_device
*pdev
)
636 struct usbhs_private
*priv
= usbhs_get_priv(pdev
);
638 cancel_delayed_work_sync(&priv
->work
);
643 static struct usbhs_private usbhs0_private
= {
644 .usbcrcaddr
= IOMEM(0xe605810c), /* USBCR2 */
646 .platform_callback
= {
647 .hardware_init
= usbhs0_hardware_init
,
648 .hardware_exit
= usbhs0_hardware_exit
,
649 .phy_reset
= usbhs_phy_reset
,
650 .get_id
= usbhs0_get_id
,
651 .get_vbus
= usbhs_get_vbus
,
655 .d0_tx_id
= SHDMA_SLAVE_USB0_TX
,
656 .d1_rx_id
= SHDMA_SLAVE_USB0_RX
,
661 static struct resource usbhs0_resources
[] = {
665 .end
= 0xe68900e6 - 1,
666 .flags
= IORESOURCE_MEM
,
669 .start
= evt2irq(0x1ca0) /* USB0_USB0I0 */,
670 .flags
= IORESOURCE_IRQ
,
674 static struct platform_device usbhs0_device
= {
675 .name
= "renesas_usbhs",
678 .platform_data
= &usbhs0_private
.info
,
680 .num_resources
= ARRAY_SIZE(usbhs0_resources
),
681 .resource
= usbhs0_resources
,
684 /* USBHS1 is connected to CN31 which takes a USB Mini-AB plug
686 * Use J30 to select between Host and Function. This setting
687 * can however not be detected by software. Hotplug of USBHS1
688 * is provided via IRQ8.
690 * Current USB1 works as "USB Host".
693 * If you want to use it as "USB gadget",
695 * - modify usbhs1_get_id() USBHS_HOST -> USBHS_GADGET
696 * - add .get_vbus = usbhs_get_vbus in usbhs1_private
697 * - check usbhs0_device(pio)/usbhs1_device(irq) order in mackerel_devices.
699 #define IRQ8 evt2irq(0x0300)
700 #define USB_PHY_MODE (1 << 4)
701 #define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
702 #define USB_PHY_ON (1 << 1)
703 #define USB_PHY_OFF (1 << 0)
704 #define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
706 static irqreturn_t
usbhs1_interrupt(int irq
, void *data
)
708 struct platform_device
*pdev
= data
;
709 struct usbhs_private
*priv
= usbhs_get_priv(pdev
);
711 dev_dbg(&pdev
->dev
, "%s\n", __func__
);
713 renesas_usbhs_call_notify_hotplug(pdev
);
716 __raw_writew(__raw_readw(priv
->usbphyaddr
) | USB_PHY_INT_CLR
,
722 static int usbhs1_hardware_init(struct platform_device
*pdev
)
724 struct usbhs_private
*priv
= usbhs_get_priv(pdev
);
727 /* clear interrupt status */
728 __raw_writew(USB_PHY_MODE
| USB_PHY_INT_CLR
, priv
->usbphyaddr
);
730 ret
= request_irq(IRQ8
, usbhs1_interrupt
, IRQF_TRIGGER_HIGH
,
731 dev_name(&pdev
->dev
), pdev
);
733 dev_err(&pdev
->dev
, "request_irq err\n");
737 /* enable USB phy interrupt */
738 __raw_writew(USB_PHY_MODE
| USB_PHY_INT_EN
, priv
->usbphyaddr
);
743 static int usbhs1_hardware_exit(struct platform_device
*pdev
)
745 struct usbhs_private
*priv
= usbhs_get_priv(pdev
);
747 /* clear interrupt status */
748 __raw_writew(USB_PHY_MODE
| USB_PHY_INT_CLR
, priv
->usbphyaddr
);
750 free_irq(IRQ8
, pdev
);
755 static int usbhs1_get_id(struct platform_device
*pdev
)
760 static u32 usbhs1_pipe_cfg
[] = {
761 USB_ENDPOINT_XFER_CONTROL
,
762 USB_ENDPOINT_XFER_ISOC
,
763 USB_ENDPOINT_XFER_ISOC
,
764 USB_ENDPOINT_XFER_BULK
,
765 USB_ENDPOINT_XFER_BULK
,
766 USB_ENDPOINT_XFER_BULK
,
767 USB_ENDPOINT_XFER_INT
,
768 USB_ENDPOINT_XFER_INT
,
769 USB_ENDPOINT_XFER_INT
,
770 USB_ENDPOINT_XFER_BULK
,
771 USB_ENDPOINT_XFER_BULK
,
772 USB_ENDPOINT_XFER_BULK
,
773 USB_ENDPOINT_XFER_BULK
,
774 USB_ENDPOINT_XFER_BULK
,
775 USB_ENDPOINT_XFER_BULK
,
776 USB_ENDPOINT_XFER_BULK
,
779 static struct usbhs_private usbhs1_private
= {
780 .usbphyaddr
= IOMEM(0xe60581e2), /* USBPHY1INTAP */
781 .usbcrcaddr
= IOMEM(0xe6058130), /* USBCR4 */
783 .platform_callback
= {
784 .hardware_init
= usbhs1_hardware_init
,
785 .hardware_exit
= usbhs1_hardware_exit
,
786 .get_id
= usbhs1_get_id
,
787 .phy_reset
= usbhs_phy_reset
,
792 .pipe_type
= usbhs1_pipe_cfg
,
793 .pipe_size
= ARRAY_SIZE(usbhs1_pipe_cfg
),
794 .d0_tx_id
= SHDMA_SLAVE_USB1_TX
,
795 .d1_rx_id
= SHDMA_SLAVE_USB1_RX
,
800 static struct resource usbhs1_resources
[] = {
804 .end
= 0xe68b00e6 - 1,
805 .flags
= IORESOURCE_MEM
,
808 .start
= evt2irq(0x1ce0) /* USB1_USB1I0 */,
809 .flags
= IORESOURCE_IRQ
,
813 static struct platform_device usbhs1_device
= {
814 .name
= "renesas_usbhs",
817 .platform_data
= &usbhs1_private
.info
,
818 .dma_mask
= &usbhs1_device
.dev
.coherent_dma_mask
,
819 .coherent_dma_mask
= DMA_BIT_MASK(32),
821 .num_resources
= ARRAY_SIZE(usbhs1_resources
),
822 .resource
= usbhs1_resources
,
826 static struct gpio_led mackerel_leds
[] = {
830 .default_state
= LEDS_GPIO_DEFSTATE_ON
,
835 .default_state
= LEDS_GPIO_DEFSTATE_ON
,
840 .default_state
= LEDS_GPIO_DEFSTATE_ON
,
845 .default_state
= LEDS_GPIO_DEFSTATE_ON
,
849 static struct gpio_led_platform_data mackerel_leds_pdata
= {
850 .leds
= mackerel_leds
,
851 .num_leds
= ARRAY_SIZE(mackerel_leds
),
854 static struct platform_device leds_device
= {
858 .platform_data
= &mackerel_leds_pdata
,
863 #define IRQ_FSI evt2irq(0x1840)
864 static struct sh_fsi_platform_info fsi_info
= {
866 .tx_id
= SHDMA_SLAVE_FSIA_TX
,
867 .rx_id
= SHDMA_SLAVE_FSIA_RX
,
870 .flags
= SH_FSI_CLK_CPG
|
875 static struct resource fsi_resources
[] = {
877 /* we need 0xFE1F0000 to access DMA
878 * instead of 0xFE3C0000 */
881 .end
= 0xFE1F0400 - 1,
882 .flags
= IORESOURCE_MEM
,
886 .flags
= IORESOURCE_IRQ
,
890 static struct platform_device fsi_device
= {
893 .num_resources
= ARRAY_SIZE(fsi_resources
),
894 .resource
= fsi_resources
,
896 .platform_data
= &fsi_info
,
900 static struct asoc_simple_card_info fsi2_ak4643_info
= {
902 .card
= "FSI2A-AK4643",
903 .codec
= "ak4642-codec.0-0013",
904 .platform
= "sh_fsi2",
905 .daifmt
= SND_SOC_DAIFMT_LEFT_J
,
908 .fmt
= SND_SOC_DAIFMT_CBS_CFS
,
911 .name
= "ak4642-hifi",
912 .fmt
= SND_SOC_DAIFMT_CBM_CFM
,
917 static struct platform_device fsi_ak4643_device
= {
918 .name
= "asoc-simple-card",
920 .platform_data
= &fsi2_ak4643_info
,
925 static struct mtd_partition nand_partition_info
[] = {
929 .size
= 128 * 1024 * 1024,
933 .offset
= MTDPART_OFS_APPEND
,
934 .size
= 256 * 1024 * 1024,
938 .offset
= MTDPART_OFS_APPEND
,
939 .size
= 128 * 1024 * 1024,
943 static struct resource nand_flash_resources
[] = {
947 .flags
= IORESOURCE_MEM
,
950 .start
= evt2irq(0x0d80), /* flstei: status error irq */
951 .flags
= IORESOURCE_IRQ
,
955 static struct sh_flctl_platform_data nand_flash_data
= {
956 .parts
= nand_partition_info
,
957 .nr_parts
= ARRAY_SIZE(nand_partition_info
),
958 .flcmncr_val
= CLK_16B_12L_4H
| TYPESEL_SET
959 | SHBUSSEL
| SEL_16BIT
| SNAND_E
,
963 static struct platform_device nand_flash_device
= {
965 .resource
= nand_flash_resources
,
966 .num_resources
= ARRAY_SIZE(nand_flash_resources
),
968 .platform_data
= &nand_flash_data
,
973 static struct sh_mobile_sdhi_info sdhi0_info
= {
974 .dma_slave_tx
= SHDMA_SLAVE_SDHI0_TX
,
975 .dma_slave_rx
= SHDMA_SLAVE_SDHI0_RX
,
976 .tmio_flags
= TMIO_MMC_USE_GPIO_CD
,
977 .tmio_caps
= MMC_CAP_SD_HIGHSPEED
| MMC_CAP_SDIO_IRQ
,
981 static struct resource sdhi0_resources
[] = {
986 .flags
= IORESOURCE_MEM
,
988 .name
= SH_MOBILE_SDHI_IRQ_SDCARD
,
989 .start
= evt2irq(0x0e20) /* SDHI0_SDHI0I1 */,
990 .flags
= IORESOURCE_IRQ
,
992 .name
= SH_MOBILE_SDHI_IRQ_SDIO
,
993 .start
= evt2irq(0x0e40) /* SDHI0_SDHI0I2 */,
994 .flags
= IORESOURCE_IRQ
,
998 static struct platform_device sdhi0_device
= {
999 .name
= "sh_mobile_sdhi",
1000 .num_resources
= ARRAY_SIZE(sdhi0_resources
),
1001 .resource
= sdhi0_resources
,
1004 .platform_data
= &sdhi0_info
,
1008 #if !IS_ENABLED(CONFIG_MMC_SH_MMCIF)
1011 /* GPIO 41 can trigger IRQ8, but it is used by USBHS1, we have to poll */
1012 static struct sh_mobile_sdhi_info sdhi1_info
= {
1013 .dma_slave_tx
= SHDMA_SLAVE_SDHI1_TX
,
1014 .dma_slave_rx
= SHDMA_SLAVE_SDHI1_RX
,
1015 .tmio_flags
= TMIO_MMC_WRPROTECT_DISABLE
| TMIO_MMC_USE_GPIO_CD
,
1016 .tmio_caps
= MMC_CAP_SD_HIGHSPEED
| MMC_CAP_SDIO_IRQ
|
1021 static struct resource sdhi1_resources
[] = {
1024 .start
= 0xe6860000,
1026 .flags
= IORESOURCE_MEM
,
1028 .name
= SH_MOBILE_SDHI_IRQ_SDCARD
,
1029 .start
= evt2irq(0x0ea0), /* SDHI1_SDHI1I1 */
1030 .flags
= IORESOURCE_IRQ
,
1032 .name
= SH_MOBILE_SDHI_IRQ_SDIO
,
1033 .start
= evt2irq(0x0ec0), /* SDHI1_SDHI1I2 */
1034 .flags
= IORESOURCE_IRQ
,
1038 static struct platform_device sdhi1_device
= {
1039 .name
= "sh_mobile_sdhi",
1040 .num_resources
= ARRAY_SIZE(sdhi1_resources
),
1041 .resource
= sdhi1_resources
,
1044 .platform_data
= &sdhi1_info
,
1052 * The card detect pin of the top SD/MMC slot (CN23) is active low and is
1053 * connected to GPIO SCIFB_SCK of SH7372 (GPIO 162).
1055 static struct sh_mobile_sdhi_info sdhi2_info
= {
1056 .dma_slave_tx
= SHDMA_SLAVE_SDHI2_TX
,
1057 .dma_slave_rx
= SHDMA_SLAVE_SDHI2_RX
,
1058 .tmio_flags
= TMIO_MMC_WRPROTECT_DISABLE
| TMIO_MMC_USE_GPIO_CD
,
1059 .tmio_caps
= MMC_CAP_SD_HIGHSPEED
| MMC_CAP_SDIO_IRQ
|
1064 static struct resource sdhi2_resources
[] = {
1067 .start
= 0xe6870000,
1069 .flags
= IORESOURCE_MEM
,
1071 .name
= SH_MOBILE_SDHI_IRQ_SDCARD
,
1072 .start
= evt2irq(0x1220), /* SDHI2_SDHI2I1 */
1073 .flags
= IORESOURCE_IRQ
,
1075 .name
= SH_MOBILE_SDHI_IRQ_SDIO
,
1076 .start
= evt2irq(0x1240), /* SDHI2_SDHI2I2 */
1077 .flags
= IORESOURCE_IRQ
,
1081 static struct platform_device sdhi2_device
= {
1082 .name
= "sh_mobile_sdhi",
1083 .num_resources
= ARRAY_SIZE(sdhi2_resources
),
1084 .resource
= sdhi2_resources
,
1087 .platform_data
= &sdhi2_info
,
1092 #if IS_ENABLED(CONFIG_MMC_SH_MMCIF)
1093 static struct resource sh_mmcif_resources
[] = {
1096 .start
= 0xE6BD0000,
1098 .flags
= IORESOURCE_MEM
,
1102 .start
= evt2irq(0x1ac0),
1103 .flags
= IORESOURCE_IRQ
,
1107 .start
= evt2irq(0x1ae0),
1108 .flags
= IORESOURCE_IRQ
,
1112 static struct sh_mmcif_plat_data sh_mmcif_plat
= {
1114 .caps
= MMC_CAP_4_BIT_DATA
|
1115 MMC_CAP_8_BIT_DATA
|
1117 .use_cd_gpio
= true,
1118 /* card detect pin for SD/MMC slot (CN7) */
1120 .slave_id_tx
= SHDMA_SLAVE_MMCIF_TX
,
1121 .slave_id_rx
= SHDMA_SLAVE_MMCIF_RX
,
1124 static struct platform_device sh_mmcif_device
= {
1129 .coherent_dma_mask
= 0xffffffff,
1130 .platform_data
= &sh_mmcif_plat
,
1132 .num_resources
= ARRAY_SIZE(sh_mmcif_resources
),
1133 .resource
= sh_mmcif_resources
,
1137 static int mackerel_camera_add(struct soc_camera_device
*icd
);
1138 static void mackerel_camera_del(struct soc_camera_device
*icd
);
1140 static int camera_set_capture(struct soc_camera_platform_info
*info
,
1143 return 0; /* camera sensor always enabled */
1146 static struct soc_camera_platform_info camera_info
= {
1147 .format_name
= "UYVY",
1150 .code
= V4L2_MBUS_FMT_UYVY8_2X8
,
1151 .colorspace
= V4L2_COLORSPACE_SMPTE170M
,
1152 .field
= V4L2_FIELD_NONE
,
1156 .mbus_param
= V4L2_MBUS_PCLK_SAMPLE_RISING
| V4L2_MBUS_MASTER
|
1157 V4L2_MBUS_VSYNC_ACTIVE_HIGH
| V4L2_MBUS_HSYNC_ACTIVE_HIGH
|
1158 V4L2_MBUS_DATA_ACTIVE_HIGH
,
1159 .mbus_type
= V4L2_MBUS_PARALLEL
,
1160 .set_capture
= camera_set_capture
,
1163 static struct soc_camera_link camera_link
= {
1165 .add_device
= mackerel_camera_add
,
1166 .del_device
= mackerel_camera_del
,
1167 .module_name
= "soc_camera_platform",
1168 .priv
= &camera_info
,
1171 static struct platform_device
*camera_device
;
1173 static void mackerel_camera_release(struct device
*dev
)
1175 soc_camera_platform_release(&camera_device
);
1178 static int mackerel_camera_add(struct soc_camera_device
*icd
)
1180 return soc_camera_platform_add(icd
, &camera_device
, &camera_link
,
1181 mackerel_camera_release
, 0);
1184 static void mackerel_camera_del(struct soc_camera_device
*icd
)
1186 soc_camera_platform_del(icd
, camera_device
, &camera_link
);
1189 static struct sh_mobile_ceu_info sh_mobile_ceu_info
= {
1190 .flags
= SH_CEU_FLAG_USE_8BIT_BUS
,
1195 static struct resource ceu_resources
[] = {
1198 .start
= 0xfe910000,
1200 .flags
= IORESOURCE_MEM
,
1203 .start
= intcs_evt2irq(0x880),
1204 .flags
= IORESOURCE_IRQ
,
1207 /* place holder for contiguous memory */
1211 static struct platform_device ceu_device
= {
1212 .name
= "sh_mobile_ceu",
1213 .id
= 0, /* "ceu0" clock */
1214 .num_resources
= ARRAY_SIZE(ceu_resources
),
1215 .resource
= ceu_resources
,
1217 .platform_data
= &sh_mobile_ceu_info
,
1218 .coherent_dma_mask
= 0xffffffff,
1222 static struct platform_device mackerel_camera
= {
1223 .name
= "soc-camera-pdrv",
1226 .platform_data
= &camera_link
,
1230 static struct platform_device
*mackerel_devices
[] __initdata
= {
1242 #if !IS_ENABLED(CONFIG_MMC_SH_MMCIF)
1255 /* Keypad Initialization */
1256 #define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
1260 .active_low = act_low, \
1263 #define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
1265 static struct tca6416_button mackerel_gpio_keys
[] = {
1266 KEYPAD_BUTTON_LOW(KEY_HOME
),
1267 KEYPAD_BUTTON_LOW(KEY_MENU
),
1268 KEYPAD_BUTTON_LOW(KEY_BACK
),
1269 KEYPAD_BUTTON_LOW(KEY_POWER
),
1272 static struct tca6416_keys_platform_data mackerel_tca6416_keys_info
= {
1273 .buttons
= mackerel_gpio_keys
,
1274 .nbuttons
= ARRAY_SIZE(mackerel_gpio_keys
),
1281 #define IRQ7 evt2irq(0x02e0)
1282 #define IRQ9 evt2irq(0x0320)
1284 static struct i2c_board_info i2c0_devices
[] = {
1286 I2C_BOARD_INFO("ak4643", 0x13),
1290 I2C_BOARD_INFO("tca6408-keys", 0x20),
1291 .platform_data
= &mackerel_tca6416_keys_info
,
1296 I2C_BOARD_INFO("st1232-ts", 0x55),
1301 #define IRQ21 evt2irq(0x32a0)
1303 static struct i2c_board_info i2c1_devices
[] = {
1306 I2C_BOARD_INFO("adxl34x", 0x53),
1311 static const struct pinctrl_map mackerel_pinctrl_map
[] = {
1313 PIN_MAP_MUX_GROUP_DEFAULT("1-0053", "pfc-sh7372",
1314 "intc_irq21", "intc"),
1316 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-sh7372",
1317 "ceu_data_0_7", "ceu"),
1318 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-sh7372",
1319 "ceu_clk_0", "ceu"),
1320 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-sh7372",
1322 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-sh7372",
1323 "ceu_field", "ceu"),
1325 PIN_MAP_MUX_GROUP_DEFAULT("sh_flctl.0", "pfc-sh7372",
1326 "flctl_data", "flctl"),
1327 PIN_MAP_MUX_GROUP_DEFAULT("sh_flctl.0", "pfc-sh7372",
1328 "flctl_ce0", "flctl"),
1329 PIN_MAP_MUX_GROUP_DEFAULT("sh_flctl.0", "pfc-sh7372",
1330 "flctl_ctrl", "flctl"),
1332 PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-sh7372",
1333 "fsia_sclk_in", "fsia"),
1334 PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-sh7372",
1335 "fsia_data_in", "fsia"),
1336 PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-sh7372",
1337 "fsia_data_out", "fsia"),
1339 PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.1", "pfc-sh7372",
1340 "fsib_mclk_in", "fsib"),
1342 PIN_MAP_MUX_GROUP_DEFAULT("sh-mobile-hdmi", "pfc-sh7372",
1345 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh7372",
1346 "lcd_data24", "lcd"),
1347 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh7372",
1350 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-sh7372",
1351 "scifa0_data", "scifa0"),
1352 /* SCIFA2 (GT-720F GPS module) */
1353 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-sh7372",
1354 "scifa2_data", "scifa2"),
1356 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
1357 "sdhi0_data4", "sdhi0"),
1358 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
1359 "sdhi0_ctrl", "sdhi0"),
1360 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
1361 "sdhi0_wp", "sdhi0"),
1362 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
1363 "intc_irq26_1", "intc"),
1365 #if !IS_ENABLED(CONFIG_MMC_SH_MMCIF)
1366 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-sh7372",
1367 "sdhi1_data4", "sdhi1"),
1368 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-sh7372",
1369 "sdhi1_ctrl", "sdhi1"),
1372 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh7372",
1373 "mmc0_data8_0", "mmc0"),
1374 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh7372",
1375 "mmc0_ctrl_0", "mmc0"),
1378 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh7372",
1379 "sdhi2_data4", "sdhi2"),
1380 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh7372",
1381 "sdhi2_ctrl", "sdhi2"),
1383 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-sh7372",
1385 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-sh7372",
1386 "intc_irq6_0", "intc"),
1388 PIN_MAP_MUX_GROUP_DEFAULT("0-0055", "pfc-sh7372",
1389 "intc_irq7_0", "intc"),
1391 PIN_MAP_MUX_GROUP_DEFAULT("0-0020", "pfc-sh7372",
1392 "intc_irq9_0", "intc"),
1394 PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs.0", "pfc-sh7372",
1395 "usb0_vbus", "usb0"),
1397 PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs.1", "pfc-sh7372",
1398 "usb1_vbus", "usb1"),
1399 PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs.1", "pfc-sh7372",
1400 "usb1_otg_id_0", "usb1"),
1403 #define GPIO_PORT9CR IOMEM(0xE6051009)
1404 #define GPIO_PORT10CR IOMEM(0xE605100A)
1405 #define GPIO_PORT167CR IOMEM(0xE60520A7)
1406 #define GPIO_PORT168CR IOMEM(0xE60520A8)
1407 #define SRCR4 IOMEM(0xe61580bc)
1408 #define USCCR1 IOMEM(0xE6058144)
1409 static void __init
mackerel_init(void)
1411 struct pm_domain_device domain_devices
[] = {
1412 { "A4LC", &lcdc_device
, },
1413 { "A4LC", &hdmi_lcdc_device
, },
1414 { "A4LC", &meram_device
, },
1415 { "A4MP", &fsi_device
, },
1416 { "A3SP", &usbhs0_device
, },
1417 { "A3SP", &usbhs1_device
, },
1418 { "A3SP", &nand_flash_device
, },
1419 { "A3SP", &sdhi0_device
, },
1420 #if !IS_ENABLED(CONFIG_MMC_SH_MMCIF)
1421 { "A3SP", &sdhi1_device
, },
1423 { "A3SP", &sh_mmcif_device
, },
1425 { "A3SP", &sdhi2_device
, },
1426 { "A4R", &ceu_device
, },
1431 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers
,
1432 ARRAY_SIZE(fixed1v8_power_consumers
), 1800000);
1433 regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers
,
1434 ARRAY_SIZE(fixed3v3_power_consumers
), 3300000);
1435 regulator_register_fixed(2, dummy_supplies
, ARRAY_SIZE(dummy_supplies
));
1437 /* External clock source */
1438 clk_set_rate(&sh7372_dv_clki_clk
, 27000000);
1440 pinctrl_register_mappings(mackerel_pinctrl_map
,
1441 ARRAY_SIZE(mackerel_pinctrl_map
));
1442 sh7372_pinmux_init();
1444 /* backlight, off by default */
1445 gpio_request_one(31, GPIOF_OUT_INIT_LOW
, NULL
);
1447 gpio_request_one(151, GPIOF_OUT_INIT_HIGH
, NULL
); /* LCDDON */
1450 gpio_request_pulldown(GPIO_PORT168CR
); /* VBUS0_0 pull down */
1453 gpio_request_pulldown(GPIO_PORT167CR
); /* VBUS0_1 pull down */
1455 /* FSI2 port A (ak4643) */
1456 gpio_request_one(161, GPIOF_OUT_INIT_LOW
, NULL
); /* slave */
1458 gpio_request(9, NULL
);
1459 gpio_request(10, NULL
);
1460 gpio_direction_none(GPIO_PORT9CR
); /* FSIAOBT needs no direction */
1461 gpio_direction_none(GPIO_PORT10CR
); /* FSIAOLR needs no direction */
1463 intc_set_priority(IRQ_FSI
, 3); /* irq priority FSI(3) > SMSC911X(2) */
1465 /* FSI2 port B (HDMI) */
1466 __raw_writew(__raw_readw(USCCR1
) & ~(1 << 6), USCCR1
); /* use SPDIF */
1468 /* set SPU2 clock to 119.6 MHz */
1469 clk
= clk_get(NULL
, "spu_clk");
1471 clk_set_rate(clk
, clk_round_rate(clk
, 119600000));
1476 irq_set_irq_type(IRQ9
, IRQ_TYPE_LEVEL_HIGH
);
1479 irq_set_irq_type(IRQ7
, IRQ_TYPE_LEVEL_LOW
);
1482 irq_set_irq_type(IRQ21
, IRQ_TYPE_LEVEL_HIGH
);
1484 /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
1485 srcr4
= __raw_readl(SRCR4
);
1486 __raw_writel(srcr4
| (1 << 13), SRCR4
);
1488 __raw_writel(srcr4
& ~(1 << 13), SRCR4
);
1490 i2c_register_board_info(0, i2c0_devices
,
1491 ARRAY_SIZE(i2c0_devices
));
1492 i2c_register_board_info(1, i2c1_devices
,
1493 ARRAY_SIZE(i2c1_devices
));
1495 sh7372_add_standard_devices();
1497 platform_add_devices(mackerel_devices
, ARRAY_SIZE(mackerel_devices
));
1499 rmobile_add_devices_to_domains(domain_devices
,
1500 ARRAY_SIZE(domain_devices
));
1502 hdmi_init_pm_clock();
1504 pm_clk_add(&fsi_device
.dev
, "spu2");
1505 pm_clk_add(&hdmi_lcdc_device
.dev
, "hdmi");
1508 static const char *mackerel_boards_compat_dt
[] __initdata
= {
1513 DT_MACHINE_START(MACKEREL_DT
, "mackerel")
1514 .map_io
= sh7372_map_io
,
1515 .init_early
= sh7372_add_early_devices
,
1516 .init_irq
= sh7372_init_irq
,
1517 .handle_irq
= shmobile_handle_irq_intc
,
1518 .init_machine
= mackerel_init
,
1519 .init_late
= sh7372_pm_init_late
,
1520 .init_time
= sh7372_earlytimer_init
,
1521 .dt_compat
= mackerel_boards_compat_dt
,