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/sh_mobile_sdhi.h>
36 #include <linux/mfd/tmio.h>
37 #include <linux/mmc/host.h>
38 #include <linux/mmc/sh_mmcif.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 -
72 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
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
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
105 * -----------------------
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
137 * USB0 : CN22 : Function
138 * USB1 : CN31 : Function/Host *1
141 * ----------+---------------+-------------
142 * 1-2 short | VBUS 5V | Host
143 * open | external VBUS | Function
146 * CN31 is used as Host in Linux.
160 * Power voltage : 1.8v or 3.3v
161 * J22 : select power voltage *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.
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)
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);
200 static struct mtd_partition nor_flash_partitions[] = {
203 .offset = 0x00000000,
205 .mask_flags = MTD_WRITEABLE,
209 .offset = MTDPART_OFS_APPEND,
211 .mask_flags = MTD_WRITEABLE,
215 .offset = MTDPART_OFS_APPEND,
216 .size = 8 * 1024 * 1024,
217 .mask_flags = MTD_WRITEABLE,
221 .offset = MTDPART_OFS_APPEND,
222 .size = 8 * 1024 * 1024,
226 .offset = MTDPART_OFS_APPEND,
227 .size = MTDPART_SIZ_FULL,
231 static struct physmap_flash_data nor_flash_data = {
233 .parts = nor_flash_partitions,
234 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
237 static struct resource nor_flash_resources[] = {
240 .end = 0x08000000 - 1,
241 .flags = IORESOURCE_MEM,
245 static struct platform_device nor_flash_device = {
246 .name = "physmap-flash",
248 .platform_data = &nor_flash_data,
250 .num_resources = ARRAY_SIZE(nor_flash_resources),
251 .resource = nor_flash_resources,
255 static struct resource smc911x_resources[] = {
258 .end = 0x16000000 - 1,
259 .flags = IORESOURCE_MEM,
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 = {
275 .num_resources = ARRAY_SIZE(smc911x_resources),
276 .resource = smc911x_resources,
278 .platform_data = &smsc911x_info,
283 static struct fb_videomode mackerel_lcdc_modes[] = {
285 .name = "WVGA Panel",
298 static struct sh_mobile_lcdc_info lcdc_info = {
299 .clock_source = LCDC_CLK_BUS,
301 .chan = LCDC_CHAN_MAINLCD,
303 .lcd_cfg = mackerel_lcdc_modes,
304 .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
305 .interface_type = RGB24,
308 .lcd_size_cfg.width = 152,
309 .lcd_size_cfg.height = 91,
313 static struct resource lcdc_resources[] = {
318 .flags = IORESOURCE_MEM,
321 .start = intcs_evt2irq(0x580),
322 .flags = IORESOURCE_IRQ,
326 static struct platform_device lcdc_device = {
327 .name = "sh_mobile_lcdc_fb",
328 .num_resources = ARRAY_SIZE(lcdc_resources),
329 .resource = lcdc_resources,
331 .platform_data = &lcdc_info,
332 .coherent_dma_mask = ~0,
337 static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
338 .clock_source = LCDC_CLK_EXTERNAL,
340 .chan = LCDC_CHAN_MAINLCD,
342 .interface_type = RGB24,
344 .flags = LCDC_FLAGS_DWPOL,
348 static struct resource hdmi_lcdc_resources[] = {
353 .flags = IORESOURCE_MEM,
356 .start = intcs_evt2irq(0x1780),
357 .flags = IORESOURCE_IRQ,
361 static struct platform_device hdmi_lcdc_device = {
362 .name = "sh_mobile_lcdc_fb",
363 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
364 .resource = hdmi_lcdc_resources,
367 .platform_data = &hdmi_lcdc_info,
368 .coherent_dma_mask = ~0,
372 static struct sh_mobile_hdmi_info hdmi_info = {
373 .lcd_chan = &hdmi_lcdc_info.ch[0],
374 .lcd_dev = &hdmi_lcdc_device.dev,
375 .flags = HDMI_SND_SRC_SPDIF,
378 static struct resource hdmi_resources[] = {
383 .flags = IORESOURCE_MEM,
386 /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
387 .start = evt2irq(0x17e0),
388 .flags = IORESOURCE_IRQ,
392 static struct platform_device hdmi_device = {
393 .name = "sh-mobile-hdmi",
394 .num_resources = ARRAY_SIZE(hdmi_resources),
395 .resource = hdmi_resources,
398 .platform_data = &hdmi_info,
402 static struct platform_device fsi_hdmi_device = {
403 .name = "sh_fsi2_b_hdmi",
406 static int __init hdmi_init_pm_clock(void)
408 struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
412 if (IS_ERR(hdmi_ick)) {
413 ret = PTR_ERR(hdmi_ick);
414 pr_err("Cannot get HDMI ICK: %d\n", ret);
418 ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
420 pr_err("Cannot set PLLC2 parent: %d, %d users\n",
421 ret, sh7372_pllc2_clk.usecount);
425 pr_debug("PLLC2 initial frequency %lu\n",
426 clk_get_rate(&sh7372_pllc2_clk));
428 rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
430 pr_err("Cannot get suitable rate: %ld\n", rate);
435 ret = clk_set_rate(&sh7372_pllc2_clk, rate);
437 pr_err("Cannot set rate %ld: %d\n", rate, ret);
441 ret = clk_enable(&sh7372_pllc2_clk);
443 pr_err("Cannot enable pllc2 clock\n");
447 pr_debug("PLLC2 set frequency %lu\n", rate);
449 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
451 pr_err("Cannot set HDMI parent: %d\n", ret);
456 if (!IS_ERR(hdmi_ick))
460 device_initcall(hdmi_init_pm_clock);
463 static void usb1_host_port_power(int port, int power)
465 if (!power) /* only power-on is supported for now */
468 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
469 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
472 static struct r8a66597_platdata usb1_host_data = {
474 .port_power = usb1_host_port_power,
477 static struct resource usb1_host_resources[] = {
481 .end = 0xE68B00E6 - 1,
482 .flags = IORESOURCE_MEM,
485 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
486 .flags = IORESOURCE_IRQ,
490 static struct platform_device usb1_host_device = {
491 .name = "r8a66597_hcd",
494 .dma_mask = NULL, /* not use dma */
495 .coherent_dma_mask = 0xffffffff,
496 .platform_data = &usb1_host_data,
498 .num_resources = ARRAY_SIZE(usb1_host_resources),
499 .resource = usb1_host_resources,
503 static struct gpio_led mackerel_leds[] = {
507 .default_state = LEDS_GPIO_DEFSTATE_ON,
512 .default_state = LEDS_GPIO_DEFSTATE_ON,
517 .default_state = LEDS_GPIO_DEFSTATE_ON,
521 .gpio = GPIO_PORT159,
522 .default_state = LEDS_GPIO_DEFSTATE_ON,
526 static struct gpio_led_platform_data mackerel_leds_pdata = {
527 .leds = mackerel_leds,
528 .num_leds = ARRAY_SIZE(mackerel_leds),
531 static struct platform_device leds_device = {
535 .platform_data = &mackerel_leds_pdata,
540 #define IRQ_FSI evt2irq(0x1840)
541 static int __fsi_set_round_rate(struct clk *clk, long rate, int enable)
553 ret = clk_set_rate(clk, clk_round_rate(clk, rate));
557 return clk_enable(clk);
560 static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
562 struct clk *fsib_clk;
563 struct clk *fdiv_clk = &sh7372_fsidivb_clk;
569 /* FSIA is slave mode. nothing to do here */
576 fsib_rate = rate * 256;
577 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
580 fsib_rate = 85428000; /* around 48kHz x 256 x 7 */
581 fdiv_rate = rate * 256;
582 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
585 pr_err("unsupported rate in FSI2 port B\n");
590 fsib_clk = clk_get(dev, "ickb");
591 if (IS_ERR(fsib_clk))
595 ret = __fsi_set_round_rate(fsib_clk, fsib_rate, enable);
597 goto fsi_set_rate_end;
600 ret = __fsi_set_round_rate(fdiv_clk, fdiv_rate, enable);
604 __fsi_set_round_rate(fsib_clk, fsib_rate, 0);
605 goto fsi_set_rate_end;
615 static struct sh_fsi_platform_info fsi_info = {
616 .porta_flags = SH_FSI_BRS_INV,
618 .portb_flags = SH_FSI_BRS_INV |
623 .set_rate = fsi_set_rate,
626 static struct resource fsi_resources[] = {
630 .end = 0xFE3C0400 - 1,
631 .flags = IORESOURCE_MEM,
635 .flags = IORESOURCE_IRQ,
639 static struct platform_device fsi_device = {
642 .num_resources = ARRAY_SIZE(fsi_resources),
643 .resource = fsi_resources,
645 .platform_data = &fsi_info,
649 static struct platform_device fsi_ak4643_device = {
650 .name = "sh_fsi2_a_ak4643",
654 * The card detect pin of the top SD/MMC slot (CN7) is active low and is
655 * connected to GPIO A22 of SH7372 (GPIO_PORT41).
657 static int slot_cn7_get_cd(struct platform_device *pdev)
659 return !gpio_get_value(GPIO_PORT41);
663 static struct sh_mobile_sdhi_info sdhi0_info = {
664 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
665 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
666 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
669 static struct resource sdhi0_resources[] = {
674 .flags = IORESOURCE_MEM,
677 .start = evt2irq(0x0e00) /* SDHI0 */,
678 .flags = IORESOURCE_IRQ,
682 static struct platform_device sdhi0_device = {
683 .name = "sh_mobile_sdhi",
684 .num_resources = ARRAY_SIZE(sdhi0_resources),
685 .resource = sdhi0_resources,
688 .platform_data = &sdhi0_info,
692 #if !defined(CONFIG_MMC_SH_MMCIF)
694 static struct sh_mobile_sdhi_info sdhi1_info = {
695 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
696 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
697 .tmio_ocr_mask = MMC_VDD_165_195,
698 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
699 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
701 .get_cd = slot_cn7_get_cd,
704 static struct resource sdhi1_resources[] = {
709 .flags = IORESOURCE_MEM,
712 .start = evt2irq(0x0e80),
713 .flags = IORESOURCE_IRQ,
717 static struct platform_device sdhi1_device = {
718 .name = "sh_mobile_sdhi",
719 .num_resources = ARRAY_SIZE(sdhi1_resources),
720 .resource = sdhi1_resources,
723 .platform_data = &sdhi1_info,
729 * The card detect pin of the top SD/MMC slot (CN23) is active low and is
730 * connected to GPIO SCIFB_SCK of SH7372 (GPIO_PORT162).
732 static int slot_cn23_get_cd(struct platform_device *pdev)
734 return !gpio_get_value(GPIO_PORT162);
738 static struct sh_mobile_sdhi_info sdhi2_info = {
739 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
740 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
741 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
742 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
744 .get_cd = slot_cn23_get_cd,
747 static struct resource sdhi2_resources[] = {
752 .flags = IORESOURCE_MEM,
755 .start = evt2irq(0x1200),
756 .flags = IORESOURCE_IRQ,
760 static struct platform_device sdhi2_device = {
761 .name = "sh_mobile_sdhi",
762 .num_resources = ARRAY_SIZE(sdhi2_resources),
763 .resource = sdhi2_resources,
766 .platform_data = &sdhi2_info,
771 static struct resource sh_mmcif_resources[] = {
776 .flags = IORESOURCE_MEM,
780 .start = evt2irq(0x1ac0),
781 .flags = IORESOURCE_IRQ,
785 .start = evt2irq(0x1ae0),
786 .flags = IORESOURCE_IRQ,
790 static struct sh_mmcif_plat_data sh_mmcif_plat = {
792 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
793 .caps = MMC_CAP_4_BIT_DATA |
796 .get_cd = slot_cn7_get_cd,
799 static struct platform_device sh_mmcif_device = {
804 .coherent_dma_mask = 0xffffffff,
805 .platform_data = &sh_mmcif_plat,
807 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
808 .resource = sh_mmcif_resources,
812 static int mackerel_camera_add(struct soc_camera_link *icl, struct device *dev);
813 static void mackerel_camera_del(struct soc_camera_link *icl);
815 static int camera_set_capture(struct soc_camera_platform_info *info,
818 return 0; /* camera sensor always enabled */
821 static struct soc_camera_platform_info camera_info = {
822 .format_name = "UYVY",
825 .code = V4L2_MBUS_FMT_UYVY8_2X8,
826 .colorspace = V4L2_COLORSPACE_SMPTE170M,
827 .field = V4L2_FIELD_NONE,
831 .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
832 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8 |
833 SOCAM_DATA_ACTIVE_HIGH,
834 .set_capture = camera_set_capture,
837 static struct soc_camera_link camera_link = {
839 .add_device = mackerel_camera_add,
840 .del_device = mackerel_camera_del,
841 .module_name = "soc_camera_platform",
842 .priv = &camera_info,
845 static void dummy_release(struct device *dev)
849 static struct platform_device camera_device = {
850 .name = "soc_camera_platform",
852 .platform_data = &camera_info,
853 .release = dummy_release,
857 static int mackerel_camera_add(struct soc_camera_link *icl,
860 if (icl != &camera_link)
863 camera_info.dev = dev;
865 return platform_device_register(&camera_device);
868 static void mackerel_camera_del(struct soc_camera_link *icl)
870 if (icl != &camera_link)
873 platform_device_unregister(&camera_device);
874 memset(&camera_device.dev.kobj, 0,
875 sizeof(camera_device.dev.kobj));
878 static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
879 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
882 static struct resource ceu_resources[] = {
887 .flags = IORESOURCE_MEM,
890 .start = intcs_evt2irq(0x880),
891 .flags = IORESOURCE_IRQ,
894 /* place holder for contiguous memory */
898 static struct platform_device ceu_device = {
899 .name = "sh_mobile_ceu",
900 .id = 0, /* "ceu0" clock */
901 .num_resources = ARRAY_SIZE(ceu_resources),
902 .resource = ceu_resources,
904 .platform_data = &sh_mobile_ceu_info,
908 static struct platform_device mackerel_camera = {
909 .name = "soc-camera-pdrv",
912 .platform_data = &camera_link,
916 static struct platform_device *mackerel_devices[] __initdata = {
926 #if !defined(CONFIG_MMC_SH_MMCIF)
937 /* Keypad Initialization */
938 #define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
942 .active_low = act_low, \
945 #define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
947 static struct tca6416_button mackerel_gpio_keys[] = {
948 KEYPAD_BUTTON_LOW(KEY_HOME),
949 KEYPAD_BUTTON_LOW(KEY_MENU),
950 KEYPAD_BUTTON_LOW(KEY_BACK),
951 KEYPAD_BUTTON_LOW(KEY_POWER),
954 static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
955 .buttons = mackerel_gpio_keys,
956 .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
963 #define IRQ7 evt2irq(0x02e0)
964 #define IRQ9 evt2irq(0x0320)
966 static struct i2c_board_info i2c0_devices[] = {
968 I2C_BOARD_INFO("ak4643", 0x13),
972 I2C_BOARD_INFO("tca6408-keys", 0x20),
973 .platform_data = &mackerel_tca6416_keys_info,
978 I2C_BOARD_INFO("st1232-ts", 0x55),
983 #define IRQ21 evt2irq(0x32a0)
985 static struct i2c_board_info i2c1_devices[] = {
988 I2C_BOARD_INFO("adxl34x", 0x53),
993 static struct map_desc mackerel_io_desc[] __initdata = {
994 /* create a 1:1 entity map for 0xe6xxxxxx
995 * used by CPGA, INTC and PFC.
998 .virtual = 0xe6000000,
999 .pfn = __phys_to_pfn(0xe6000000),
1000 .length = 256 << 20,
1001 .type = MT_DEVICE_NONSHARED
1005 static void __init mackerel_map_io(void)
1007 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
1009 /* setup early devices and console here as well */
1010 sh7372_add_early_devices();
1011 shmobile_setup_console();
1014 #define GPIO_PORT9CR 0xE6051009
1015 #define GPIO_PORT10CR 0xE605100A
1016 #define SRCR4 0xe61580bc
1017 #define USCCR1 0xE6058144
1018 static void __init mackerel_init(void)
1023 sh7372_pinmux_init();
1026 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
1027 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
1029 /* enable SMSC911X */
1030 gpio_request(GPIO_FN_CS5A, NULL);
1031 gpio_request(GPIO_FN_IRQ6_39, NULL);
1034 gpio_request(GPIO_FN_LCDD23, NULL);
1035 gpio_request(GPIO_FN_LCDD22, NULL);
1036 gpio_request(GPIO_FN_LCDD21, NULL);
1037 gpio_request(GPIO_FN_LCDD20, NULL);
1038 gpio_request(GPIO_FN_LCDD19, NULL);
1039 gpio_request(GPIO_FN_LCDD18, NULL);
1040 gpio_request(GPIO_FN_LCDD17, NULL);
1041 gpio_request(GPIO_FN_LCDD16, NULL);
1042 gpio_request(GPIO_FN_LCDD15, NULL);
1043 gpio_request(GPIO_FN_LCDD14, NULL);
1044 gpio_request(GPIO_FN_LCDD13, NULL);
1045 gpio_request(GPIO_FN_LCDD12, NULL);
1046 gpio_request(GPIO_FN_LCDD11, NULL);
1047 gpio_request(GPIO_FN_LCDD10, NULL);
1048 gpio_request(GPIO_FN_LCDD9, NULL);
1049 gpio_request(GPIO_FN_LCDD8, NULL);
1050 gpio_request(GPIO_FN_LCDD7, NULL);
1051 gpio_request(GPIO_FN_LCDD6, NULL);
1052 gpio_request(GPIO_FN_LCDD5, NULL);
1053 gpio_request(GPIO_FN_LCDD4, NULL);
1054 gpio_request(GPIO_FN_LCDD3, NULL);
1055 gpio_request(GPIO_FN_LCDD2, NULL);
1056 gpio_request(GPIO_FN_LCDD1, NULL);
1057 gpio_request(GPIO_FN_LCDD0, NULL);
1058 gpio_request(GPIO_FN_LCDDISP, NULL);
1059 gpio_request(GPIO_FN_LCDDCK, NULL);
1061 gpio_request(GPIO_PORT31, NULL); /* backlight */
1062 gpio_direction_output(GPIO_PORT31, 1);
1064 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
1065 gpio_direction_output(GPIO_PORT151, 1);
1068 gpio_request(GPIO_FN_VBUS0_1, NULL);
1069 gpio_request(GPIO_FN_IDIN_1_18, NULL);
1070 gpio_request(GPIO_FN_PWEN_1_115, NULL);
1071 gpio_request(GPIO_FN_OVCN_1_114, NULL);
1072 gpio_request(GPIO_FN_EXTLP_1, NULL);
1073 gpio_request(GPIO_FN_OVCN2_1, NULL);
1076 __raw_writew(0x8a0a, 0xE6058130); /* USBCR4 */
1078 /* enable FSI2 port A (ak4643) */
1079 gpio_request(GPIO_FN_FSIAIBT, NULL);
1080 gpio_request(GPIO_FN_FSIAILR, NULL);
1081 gpio_request(GPIO_FN_FSIAISLD, NULL);
1082 gpio_request(GPIO_FN_FSIAOSLD, NULL);
1083 gpio_request(GPIO_PORT161, NULL);
1084 gpio_direction_output(GPIO_PORT161, 0); /* slave */
1086 gpio_request(GPIO_PORT9, NULL);
1087 gpio_request(GPIO_PORT10, NULL);
1088 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1089 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
1091 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
1093 /* setup FSI2 port B (HDMI) */
1094 gpio_request(GPIO_FN_FSIBCK, NULL);
1095 __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
1097 /* set SPU2 clock to 119.6 MHz */
1098 clk = clk_get(NULL, "spu_clk");
1100 clk_set_rate(clk, clk_round_rate(clk, 119600000));
1105 gpio_request(GPIO_FN_IRQ9_42, NULL);
1106 set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
1108 /* enable Touchscreen */
1109 gpio_request(GPIO_FN_IRQ7_40, NULL);
1110 set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
1112 /* enable Accelerometer */
1113 gpio_request(GPIO_FN_IRQ21, NULL);
1114 set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
1117 gpio_request(GPIO_FN_SDHICD0, NULL);
1118 gpio_request(GPIO_FN_SDHIWP0, NULL);
1119 gpio_request(GPIO_FN_SDHICMD0, NULL);
1120 gpio_request(GPIO_FN_SDHICLK0, NULL);
1121 gpio_request(GPIO_FN_SDHID0_3, NULL);
1122 gpio_request(GPIO_FN_SDHID0_2, NULL);
1123 gpio_request(GPIO_FN_SDHID0_1, NULL);
1124 gpio_request(GPIO_FN_SDHID0_0, NULL);
1126 #if !defined(CONFIG_MMC_SH_MMCIF)
1128 gpio_request(GPIO_FN_SDHICMD1, NULL);
1129 gpio_request(GPIO_FN_SDHICLK1, NULL);
1130 gpio_request(GPIO_FN_SDHID1_3, NULL);
1131 gpio_request(GPIO_FN_SDHID1_2, NULL);
1132 gpio_request(GPIO_FN_SDHID1_1, NULL);
1133 gpio_request(GPIO_FN_SDHID1_0, NULL);
1135 /* card detect pin for MMC slot (CN7) */
1136 gpio_request(GPIO_PORT41, NULL);
1137 gpio_direction_input(GPIO_PORT41);
1140 gpio_request(GPIO_FN_SDHICMD2, NULL);
1141 gpio_request(GPIO_FN_SDHICLK2, NULL);
1142 gpio_request(GPIO_FN_SDHID2_3, NULL);
1143 gpio_request(GPIO_FN_SDHID2_2, NULL);
1144 gpio_request(GPIO_FN_SDHID2_1, NULL);
1145 gpio_request(GPIO_FN_SDHID2_0, NULL);
1147 /* card detect pin for microSD slot (CN23) */
1148 gpio_request(GPIO_PORT162, NULL);
1149 gpio_direction_input(GPIO_PORT162);
1152 gpio_request(GPIO_FN_MMCD0_0, NULL);
1153 gpio_request(GPIO_FN_MMCD0_1, NULL);
1154 gpio_request(GPIO_FN_MMCD0_2, NULL);
1155 gpio_request(GPIO_FN_MMCD0_3, NULL);
1156 gpio_request(GPIO_FN_MMCD0_4, NULL);
1157 gpio_request(GPIO_FN_MMCD0_5, NULL);
1158 gpio_request(GPIO_FN_MMCD0_6, NULL);
1159 gpio_request(GPIO_FN_MMCD0_7, NULL);
1160 gpio_request(GPIO_FN_MMCCMD0, NULL);
1161 gpio_request(GPIO_FN_MMCCLK0, NULL);
1163 /* enable GPS module (GT-720F) */
1164 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
1165 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
1168 gpio_request(GPIO_FN_VIO_CLK, NULL);
1169 gpio_request(GPIO_FN_VIO_VD, NULL);
1170 gpio_request(GPIO_FN_VIO_HD, NULL);
1171 gpio_request(GPIO_FN_VIO_FIELD, NULL);
1172 gpio_request(GPIO_FN_VIO_CKO, NULL);
1173 gpio_request(GPIO_FN_VIO_D7, NULL);
1174 gpio_request(GPIO_FN_VIO_D6, NULL);
1175 gpio_request(GPIO_FN_VIO_D5, NULL);
1176 gpio_request(GPIO_FN_VIO_D4, NULL);
1177 gpio_request(GPIO_FN_VIO_D3, NULL);
1178 gpio_request(GPIO_FN_VIO_D2, NULL);
1179 gpio_request(GPIO_FN_VIO_D1, NULL);
1180 gpio_request(GPIO_FN_VIO_D0, NULL);
1183 gpio_request(GPIO_FN_HDMI_HPD, NULL);
1184 gpio_request(GPIO_FN_HDMI_CEC, NULL);
1186 /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
1187 srcr4 = __raw_readl(SRCR4);
1188 __raw_writel(srcr4 | (1 << 13), SRCR4);
1190 __raw_writel(srcr4 & ~(1 << 13), SRCR4);
1192 i2c_register_board_info(0, i2c0_devices,
1193 ARRAY_SIZE(i2c0_devices));
1194 i2c_register_board_info(1, i2c1_devices,
1195 ARRAY_SIZE(i2c1_devices));
1197 sh7372_add_standard_devices();
1199 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
1202 static void __init mackerel_timer_init(void)
1204 sh7372_clock_init();
1205 shmobile_timer.init();
1207 /* External clock source */
1208 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1211 static struct sys_timer mackerel_timer = {
1212 .init = mackerel_timer_init,
1215 MACHINE_START(MACKEREL, "mackerel")
1216 .map_io = mackerel_map_io,
1217 .init_irq = sh7372_init_irq,
1218 .handle_irq = shmobile_handle_irq_intc,
1219 .init_machine = mackerel_init,
1220 .timer = &mackerel_timer,