ARM: tegra11x: Define ncpu residency for 2 clusters
[linux-3.10.git] / arch / arm / mach-shmobile / board-mackerel.c
index 954b02e..fa3407d 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/physmap.h>
 #include <linux/mtd/sh_flctl.h>
+#include <linux/pinctrl/machine.h>
 #include <linux/pm_clock.h>
 #include <linux/regulator/fixed.h>
 #include <linux/regulator/machine.h>
@@ -64,6 +65,8 @@
 #include <asm/mach/arch.h>
 #include <asm/mach-types.h>
 
+#include "sh-gpio.h"
+
 /*
  * Address     Interface               BusWidth        note
  * ------------------------------------------------------------------
  *
  * it needs amixer settings for playing
  *
- * amixer set "Headphone" on
- * amixer set "HPOUTL Mixer DACH" on
- * amixer set "HPOUTR Mixer DACH" on
+ * amixer set "Headphone Enable" on
  */
 
 /* Fixed 3.3V and 1.8V regulators to be used by multiple devices */
@@ -363,16 +364,11 @@ static struct fb_videomode mackerel_lcdc_modes[] = {
 
 static int mackerel_set_brightness(int brightness)
 {
-       gpio_set_value(GPIO_PORT31, brightness);
+       gpio_set_value(31, brightness);
 
        return 0;
 }
 
-static int mackerel_get_brightness(void)
-{
-       return gpio_get_value(GPIO_PORT31);
-}
-
 static const struct sh_mobile_meram_cfg lcd_meram_cfg = {
        .icb[0] = {
                .meram_size     = 0x40,
@@ -401,7 +397,6 @@ static struct sh_mobile_lcdc_info lcdc_info = {
                        .name = "sh_mobile_lcdc_bl",
                        .max_brightness = 1,
                        .set_brightness = mackerel_set_brightness,
-                       .get_brightness = mackerel_get_brightness,
                },
                .meram_cfg = &lcd_meram_cfg,
        }
@@ -506,18 +501,18 @@ static struct platform_device hdmi_lcdc_device = {
        },
 };
 
-static struct asoc_simple_dai_init_info fsi2_hdmi_init_info = {
-       .cpu_daifmt     = SND_SOC_DAIFMT_CBM_CFM,
-};
-
 static struct asoc_simple_card_info fsi2_hdmi_info = {
        .name           = "HDMI",
        .card           = "FSI2B-HDMI",
-       .cpu_dai        = "fsib-dai",
        .codec          = "sh-mobile-hdmi",
        .platform       = "sh_fsi2",
-       .codec_dai      = "sh_mobile_hdmi-hifi",
-       .init           = &fsi2_hdmi_init_info,
+       .cpu_dai = {
+               .name   = "fsib-dai",
+               .fmt    = SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF,
+       },
+       .codec_dai = {
+               .name   = "sh_mobile_hdmi-hifi",
+       },
 };
 
 static struct platform_device fsi_hdmi_device = {
@@ -583,8 +578,8 @@ out:
 #define USBHS0_POLL_INTERVAL (HZ * 5)
 
 struct usbhs_private {
-       unsigned int usbphyaddr;
-       unsigned int usbcrcaddr;
+       void __iomem *usbphyaddr;
+       void __iomem *usbcrcaddr;
        struct renesas_usbhs_platform_info info;
        struct delayed_work work;
        struct platform_device *pdev;
@@ -602,12 +597,14 @@ static int usbhs_get_vbus(struct platform_device *pdev)
        return usbhs_is_connected(usbhs_get_priv(pdev));
 }
 
-static void usbhs_phy_reset(struct platform_device *pdev)
+static int usbhs_phy_reset(struct platform_device *pdev)
 {
        struct usbhs_private *priv = usbhs_get_priv(pdev);
 
        /* init phy */
        __raw_writew(0x8a0a, priv->usbcrcaddr);
+
+       return 0;
 }
 
 static int usbhs0_get_id(struct platform_device *pdev)
@@ -634,15 +631,17 @@ static int usbhs0_hardware_init(struct platform_device *pdev)
        return 0;
 }
 
-static void usbhs0_hardware_exit(struct platform_device *pdev)
+static int usbhs0_hardware_exit(struct platform_device *pdev)
 {
        struct usbhs_private *priv = usbhs_get_priv(pdev);
 
        cancel_delayed_work_sync(&priv->work);
+
+       return 0;
 }
 
 static struct usbhs_private usbhs0_private = {
-       .usbcrcaddr     = 0xe605810c,           /* USBCR2 */
+       .usbcrcaddr     = IOMEM(0xe605810c),            /* USBCR2 */
        .info = {
                .platform_callback = {
                        .hardware_init  = usbhs0_hardware_init,
@@ -695,6 +694,7 @@ static struct platform_device usbhs0_device = {
  *  - J30 "open"
  *  - modify usbhs1_get_id() USBHS_HOST -> USBHS_GADGET
  *  - add .get_vbus = usbhs_get_vbus in usbhs1_private
+ *  - check usbhs0_device(pio)/usbhs1_device(irq) order in mackerel_devices.
  */
 #define IRQ8 evt2irq(0x0300)
 #define USB_PHY_MODE           (1 << 4)
@@ -740,7 +740,7 @@ static int usbhs1_hardware_init(struct platform_device *pdev)
        return 0;
 }
 
-static void usbhs1_hardware_exit(struct platform_device *pdev)
+static int usbhs1_hardware_exit(struct platform_device *pdev)
 {
        struct usbhs_private *priv = usbhs_get_priv(pdev);
 
@@ -748,6 +748,8 @@ static void usbhs1_hardware_exit(struct platform_device *pdev)
        __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
 
        free_irq(IRQ8, pdev);
+
+       return 0;
 }
 
 static int usbhs1_get_id(struct platform_device *pdev)
@@ -775,8 +777,8 @@ static u32 usbhs1_pipe_cfg[] = {
 };
 
 static struct usbhs_private usbhs1_private = {
-       .usbphyaddr     = 0xe60581e2,           /* USBPHY1INTAP */
-       .usbcrcaddr     = 0xe6058130,           /* USBCR4 */
+       .usbphyaddr     = IOMEM(0xe60581e2),    /* USBPHY1INTAP */
+       .usbcrcaddr     = IOMEM(0xe6058130),    /* USBCR4 */
        .info = {
                .platform_callback = {
                        .hardware_init  = usbhs1_hardware_init,
@@ -813,6 +815,8 @@ static struct platform_device usbhs1_device = {
        .id     = 1,
        .dev = {
                .platform_data          = &usbhs1_private.info,
+               .dma_mask               = &usbhs1_device.dev.coherent_dma_mask,
+               .coherent_dma_mask      = DMA_BIT_MASK(32),
        },
        .num_resources  = ARRAY_SIZE(usbhs1_resources),
        .resource       = usbhs1_resources,
@@ -822,22 +826,22 @@ static struct platform_device usbhs1_device = {
 static struct gpio_led mackerel_leds[] = {
        {
                .name           = "led0",
-               .gpio           = GPIO_PORT0,
+               .gpio           = 0,
                .default_state  = LEDS_GPIO_DEFSTATE_ON,
        },
        {
                .name           = "led1",
-               .gpio           = GPIO_PORT1,
+               .gpio           = 1,
                .default_state  = LEDS_GPIO_DEFSTATE_ON,
        },
        {
                .name           = "led2",
-               .gpio           = GPIO_PORT2,
+               .gpio           = 2,
                .default_state  = LEDS_GPIO_DEFSTATE_ON,
        },
        {
                .name           = "led3",
-               .gpio           = GPIO_PORT159,
+               .gpio           = 159,
                .default_state  = LEDS_GPIO_DEFSTATE_ON,
        }
 };
@@ -857,88 +861,14 @@ static struct platform_device leds_device = {
 
 /* FSI */
 #define IRQ_FSI evt2irq(0x1840)
-static int __fsi_set_round_rate(struct clk *clk, long rate, int enable)
-{
-       int ret;
-
-       if (rate <= 0)
-               return 0;
-
-       if (!enable) {
-               clk_disable(clk);
-               return 0;
-       }
-
-       ret = clk_set_rate(clk, clk_round_rate(clk, rate));
-       if (ret < 0)
-               return ret;
-
-       return clk_enable(clk);
-}
-
-static int fsi_b_set_rate(struct device *dev, int rate, int enable)
-{
-       struct clk *fsib_clk;
-       struct clk *fdiv_clk = &sh7372_fsidivb_clk;
-       long fsib_rate = 0;
-       long fdiv_rate = 0;
-       int ackmd_bpfmd;
-       int ret;
-
-       /* clock start */
-       switch (rate) {
-       case 44100:
-               fsib_rate       = rate * 256;
-               ackmd_bpfmd     = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
-               break;
-       case 48000:
-               fsib_rate       = 85428000; /* around 48kHz x 256 x 7 */
-               fdiv_rate       = rate * 256;
-               ackmd_bpfmd     = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
-               break;
-       default:
-               pr_err("unsupported rate in FSI2 port B\n");
-               return -EINVAL;
-       }
-
-       /* FSI B setting */
-       fsib_clk = clk_get(dev, "ickb");
-       if (IS_ERR(fsib_clk))
-               return -EIO;
-
-       /* fsib */
-       ret = __fsi_set_round_rate(fsib_clk, fsib_rate, enable);
-       if (ret < 0)
-               goto fsi_set_rate_end;
-
-       /* FSI DIV */
-       ret = __fsi_set_round_rate(fdiv_clk, fdiv_rate, enable);
-       if (ret < 0) {
-               /* disable FSI B */
-               if (enable)
-                       __fsi_set_round_rate(fsib_clk, fsib_rate, 0);
-               goto fsi_set_rate_end;
-       }
-
-       ret = ackmd_bpfmd;
-
-fsi_set_rate_end:
-       clk_put(fsib_clk);
-       return ret;
-}
-
 static struct sh_fsi_platform_info fsi_info = {
        .port_a = {
-               .flags = SH_FSI_BRS_INV,
                .tx_id = SHDMA_SLAVE_FSIA_TX,
                .rx_id = SHDMA_SLAVE_FSIA_RX,
        },
        .port_b = {
-               .flags = SH_FSI_BRS_INV |
-                       SH_FSI_BRM_INV  |
-                       SH_FSI_LRS_INV  |
-                       SH_FSI_FMT_SPDIF,
-               .set_rate = fsi_b_set_rate,
+               .flags = SH_FSI_CLK_CPG |
+                        SH_FSI_FMT_SPDIF,
        }
 };
 
@@ -967,21 +897,21 @@ static struct platform_device fsi_device = {
        },
 };
 
-static struct asoc_simple_dai_init_info fsi2_ak4643_init_info = {
-       .fmt            = SND_SOC_DAIFMT_LEFT_J,
-       .codec_daifmt   = SND_SOC_DAIFMT_CBM_CFM,
-       .cpu_daifmt     = SND_SOC_DAIFMT_CBS_CFS,
-       .sysclk         = 11289600,
-};
-
 static struct asoc_simple_card_info fsi2_ak4643_info = {
        .name           = "AK4643",
        .card           = "FSI2A-AK4643",
-       .cpu_dai        = "fsia-dai",
        .codec          = "ak4642-codec.0-0013",
        .platform       = "sh_fsi2",
-       .codec_dai      = "ak4642-hifi",
-       .init           = &fsi2_ak4643_init_info,
+       .daifmt         = SND_SOC_DAIFMT_LEFT_J,
+       .cpu_dai = {
+               .name   = "fsia-dai",
+               .fmt    = SND_SOC_DAIFMT_CBS_CFS,
+       },
+       .codec_dai = {
+               .name   = "ak4642-hifi",
+               .fmt    = SND_SOC_DAIFMT_CBM_CFM,
+               .sysclk = 11289600,
+       },
 };
 
 static struct platform_device fsi_ak4643_device = {
@@ -1015,7 +945,11 @@ static struct resource nand_flash_resources[] = {
                .start  = 0xe6a30000,
                .end    = 0xe6a3009b,
                .flags  = IORESOURCE_MEM,
-       }
+       },
+       [1] = {
+               .start  = evt2irq(0x0d80), /* flstei: status error irq */
+               .flags  = IORESOURCE_IRQ,
+       },
 };
 
 static struct sh_flctl_platform_data nand_flash_data = {
@@ -1035,40 +969,27 @@ static struct platform_device nand_flash_device = {
        },
 };
 
-/*
- * The card detect pin of the top SD/MMC slot (CN7) is active low and is
- * connected to GPIO A22 of SH7372 (GPIO_PORT41).
- */
-static int slot_cn7_get_cd(struct platform_device *pdev)
-{
-       return !gpio_get_value(GPIO_PORT41);
-}
-
 /* SDHI0 */
 static struct sh_mobile_sdhi_info sdhi0_info = {
        .dma_slave_tx   = SHDMA_SLAVE_SDHI0_TX,
        .dma_slave_rx   = SHDMA_SLAVE_SDHI0_RX,
        .tmio_flags     = TMIO_MMC_USE_GPIO_CD,
        .tmio_caps      = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
-       .cd_gpio        = GPIO_PORT172,
+       .cd_gpio        = 172,
 };
 
 static struct resource sdhi0_resources[] = {
-       [0] = {
+       {
                .name   = "SDHI0",
                .start  = 0xe6850000,
                .end    = 0xe68500ff,
                .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x0e00) /* SDHI0_SDHI0I0 */,
-               .flags  = IORESOURCE_IRQ,
-       },
-       [2] = {
+       }, {
+               .name   = SH_MOBILE_SDHI_IRQ_SDCARD,
                .start  = evt2irq(0x0e20) /* SDHI0_SDHI0I1 */,
                .flags  = IORESOURCE_IRQ,
-       },
-       [3] = {
+       }, {
+               .name   = SH_MOBILE_SDHI_IRQ_SDIO,
                .start  = evt2irq(0x0e40) /* SDHI0_SDHI0I2 */,
                .flags  = IORESOURCE_IRQ,
        },
@@ -1084,36 +1005,30 @@ static struct platform_device sdhi0_device = {
        },
 };
 
-#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
+#if !IS_ENABLED(CONFIG_MMC_SH_MMCIF)
 /* SDHI1 */
+
+/* GPIO 41 can trigger IRQ8, but it is used by USBHS1, we have to poll */
 static struct sh_mobile_sdhi_info sdhi1_info = {
        .dma_slave_tx   = SHDMA_SLAVE_SDHI1_TX,
        .dma_slave_rx   = SHDMA_SLAVE_SDHI1_RX,
-       .tmio_ocr_mask  = MMC_VDD_165_195,
-       .tmio_flags     = TMIO_MMC_WRPROTECT_DISABLE,
+       .tmio_flags     = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_USE_GPIO_CD,
        .tmio_caps      = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
                          MMC_CAP_NEEDS_POLL,
-       .get_cd         = slot_cn7_get_cd,
+       .cd_gpio        = 41,
 };
 
 static struct resource sdhi1_resources[] = {
-       [0] = {
+       {
                .name   = "SDHI1",
                .start  = 0xe6860000,
                .end    = 0xe68600ff,
                .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .name   = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
-               .start  = evt2irq(0x0e80), /* SDHI1_SDHI1I0 */
-               .flags  = IORESOURCE_IRQ,
-       },
-       [2] = {
+       }, {
                .name   = SH_MOBILE_SDHI_IRQ_SDCARD,
                .start  = evt2irq(0x0ea0), /* SDHI1_SDHI1I1 */
                .flags  = IORESOURCE_IRQ,
-       },
-       [3] = {
+       }, {
                .name   = SH_MOBILE_SDHI_IRQ_SDIO,
                .start  = evt2irq(0x0ec0), /* SDHI1_SDHI1I2 */
                .flags  = IORESOURCE_IRQ,
@@ -1131,43 +1046,32 @@ static struct platform_device sdhi1_device = {
 };
 #endif
 
+/* SDHI2 */
+
 /*
  * The card detect pin of the top SD/MMC slot (CN23) is active low and is
- * connected to GPIO SCIFB_SCK of SH7372 (GPIO_PORT162).
+ * connected to GPIO SCIFB_SCK of SH7372 (GPIO 162).
  */
-static int slot_cn23_get_cd(struct platform_device *pdev)
-{
-       return !gpio_get_value(GPIO_PORT162);
-}
-
-/* SDHI2 */
 static struct sh_mobile_sdhi_info sdhi2_info = {
        .dma_slave_tx   = SHDMA_SLAVE_SDHI2_TX,
        .dma_slave_rx   = SHDMA_SLAVE_SDHI2_RX,
-       .tmio_flags     = TMIO_MMC_WRPROTECT_DISABLE,
+       .tmio_flags     = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_USE_GPIO_CD,
        .tmio_caps      = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
                          MMC_CAP_NEEDS_POLL,
-       .get_cd         = slot_cn23_get_cd,
+       .cd_gpio        = 162,
 };
 
 static struct resource sdhi2_resources[] = {
-       [0] = {
+       {
                .name   = "SDHI2",
                .start  = 0xe6870000,
                .end    = 0xe68700ff,
                .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .name   = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
-               .start  = evt2irq(0x1200), /* SDHI2_SDHI2I0 */
-               .flags  = IORESOURCE_IRQ,
-       },
-       [2] = {
+       }, {
                .name   = SH_MOBILE_SDHI_IRQ_SDCARD,
                .start  = evt2irq(0x1220), /* SDHI2_SDHI2I1 */
                .flags  = IORESOURCE_IRQ,
-       },
-       [3] = {
+       }, {
                .name   = SH_MOBILE_SDHI_IRQ_SDIO,
                .start  = evt2irq(0x1240), /* SDHI2_SDHI2I2 */
                .flags  = IORESOURCE_IRQ,
@@ -1185,6 +1089,7 @@ static struct platform_device sdhi2_device = {
 };
 
 /* SH_MMCIF */
+#if IS_ENABLED(CONFIG_MMC_SH_MMCIF)
 static struct resource sh_mmcif_resources[] = {
        [0] = {
                .name   = "MMCIF",
@@ -1206,11 +1111,12 @@ static struct resource sh_mmcif_resources[] = {
 
 static struct sh_mmcif_plat_data sh_mmcif_plat = {
        .sup_pclk       = 0,
-       .ocr            = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
        .caps           = MMC_CAP_4_BIT_DATA |
                          MMC_CAP_8_BIT_DATA |
                          MMC_CAP_NEEDS_POLL,
-       .get_cd         = slot_cn7_get_cd,
+       .use_cd_gpio    = true,
+       /* card detect pin for SD/MMC slot (CN7) */
+       .cd_gpio        = 41,
        .slave_id_tx    = SHDMA_SLAVE_MMCIF_TX,
        .slave_id_rx    = SHDMA_SLAVE_MMCIF_RX,
 };
@@ -1226,7 +1132,7 @@ static struct platform_device sh_mmcif_device = {
        .num_resources  = ARRAY_SIZE(sh_mmcif_resources),
        .resource       = sh_mmcif_resources,
 };
-
+#endif
 
 static int mackerel_camera_add(struct soc_camera_device *icd);
 static void mackerel_camera_del(struct soc_camera_device *icd);
@@ -1325,19 +1231,20 @@ static struct platform_device *mackerel_devices[] __initdata = {
        &nor_flash_device,
        &smc911x_device,
        &lcdc_device,
-       &usbhs1_device,
        &usbhs0_device,
+       &usbhs1_device,
        &leds_device,
        &fsi_device,
        &fsi_ak4643_device,
        &fsi_hdmi_device,
        &nand_flash_device,
        &sdhi0_device,
-#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
+#if !IS_ENABLED(CONFIG_MMC_SH_MMCIF)
        &sdhi1_device,
+#else
+       &sh_mmcif_device,
 #endif
        &sdhi2_device,
-       &sh_mmcif_device,
        &ceu_device,
        &mackerel_camera,
        &hdmi_device,
@@ -1401,14 +1308,59 @@ static struct i2c_board_info i2c1_devices[] = {
        },
 };
 
-#define GPIO_PORT9CR   0xE6051009
-#define GPIO_PORT10CR  0xE605100A
-#define GPIO_PORT167CR 0xE60520A7
-#define GPIO_PORT168CR 0xE60520A8
-#define SRCR4          0xe61580bc
-#define USCCR1         0xE6058144
+static const struct pinctrl_map mackerel_pinctrl_map[] = {
+       /* SDHI0 */
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
+                                 "sdhi0_data4", "sdhi0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
+                                 "sdhi0_ctrl", "sdhi0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
+                                 "sdhi0_wp", "sdhi0"),
+       /* SDHI1 */
+#if !IS_ENABLED(CONFIG_MMC_SH_MMCIF)
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-sh7372",
+                                 "sdhi1_data4", "sdhi1"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-sh7372",
+                                 "sdhi1_ctrl", "sdhi1"),
+#else
+       /* MMCIF */
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh7372",
+                                 "mmc0_data8_0", "mmc0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh7372",
+                                 "mmc0_ctrl_0", "mmc0"),
+#endif
+       /* SDHI2 */
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh7372",
+                                 "sdhi2_data4", "sdhi2"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh7372",
+                                 "sdhi2_ctrl", "sdhi2"),
+};
+
+#define GPIO_PORT9CR   IOMEM(0xE6051009)
+#define GPIO_PORT10CR  IOMEM(0xE605100A)
+#define GPIO_PORT167CR IOMEM(0xE60520A7)
+#define GPIO_PORT168CR IOMEM(0xE60520A8)
+#define SRCR4          IOMEM(0xe61580bc)
+#define USCCR1         IOMEM(0xE6058144)
 static void __init mackerel_init(void)
 {
+       struct pm_domain_device domain_devices[] = {
+               { "A4LC", &lcdc_device, },
+               { "A4LC", &hdmi_lcdc_device, },
+               { "A4LC", &meram_device, },
+               { "A4MP", &fsi_device, },
+               { "A3SP", &usbhs0_device, },
+               { "A3SP", &usbhs1_device, },
+               { "A3SP", &nand_flash_device, },
+               { "A3SP", &sdhi0_device, },
+#if !IS_ENABLED(CONFIG_MMC_SH_MMCIF)
+               { "A3SP", &sdhi1_device, },
+#else
+               { "A3SP", &sh_mmcif_device, },
+#endif
+               { "A3SP", &sdhi2_device, },
+               { "A4R", &ceu_device, },
+       };
        u32 srcr4;
        struct clk *clk;
 
@@ -1421,6 +1373,8 @@ static void __init mackerel_init(void)
        /* External clock source */
        clk_set_rate(&sh7372_dv_clki_clk, 27000000);
 
+       pinctrl_register_mappings(mackerel_pinctrl_map,
+                                 ARRAY_SIZE(mackerel_pinctrl_map));
        sh7372_pinmux_init();
 
        /* enable SCIFA0 */
@@ -1459,11 +1413,10 @@ static void __init mackerel_init(void)
        gpio_request(GPIO_FN_LCDDISP,  NULL);
        gpio_request(GPIO_FN_LCDDCK,   NULL);
 
-       gpio_request(GPIO_PORT31, NULL); /* backlight */
-       gpio_direction_output(GPIO_PORT31, 0); /* off by default */
+       /* backlight, off by default */
+       gpio_request_one(31, GPIOF_OUT_INIT_LOW, NULL);
 
-       gpio_request(GPIO_PORT151, NULL); /* LCDDON */
-       gpio_direction_output(GPIO_PORT151, 1);
+       gpio_request_one(151, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */
 
        /* USBHS0 */
        gpio_request(GPIO_FN_VBUS0_0, NULL);
@@ -1479,11 +1432,10 @@ static void __init mackerel_init(void)
        gpio_request(GPIO_FN_FSIAILR,   NULL);
        gpio_request(GPIO_FN_FSIAISLD,  NULL);
        gpio_request(GPIO_FN_FSIAOSLD,  NULL);
-       gpio_request(GPIO_PORT161,      NULL);
-       gpio_direction_output(GPIO_PORT161, 0); /* slave */
+       gpio_request_one(161, GPIOF_OUT_INIT_LOW, NULL); /* slave */
 
-       gpio_request(GPIO_PORT9,  NULL);
-       gpio_request(GPIO_PORT10, NULL);
+       gpio_request(9,  NULL);
+       gpio_request(10, NULL);
        gpio_direction_none(GPIO_PORT9CR);  /* FSIAOBT needs no direction */
        gpio_direction_none(GPIO_PORT10CR); /* FSIAOLR needs no direction */
 
@@ -1512,55 +1464,9 @@ static void __init mackerel_init(void)
        gpio_request(GPIO_FN_IRQ21,     NULL);
        irq_set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
 
-       /* enable SDHI0 */
-       gpio_request(GPIO_FN_SDHIWP0, NULL);
-       gpio_request(GPIO_FN_SDHICMD0, NULL);
-       gpio_request(GPIO_FN_SDHICLK0, NULL);
-       gpio_request(GPIO_FN_SDHID0_3, NULL);
-       gpio_request(GPIO_FN_SDHID0_2, NULL);
-       gpio_request(GPIO_FN_SDHID0_1, NULL);
-       gpio_request(GPIO_FN_SDHID0_0, NULL);
-
        /* SDHI0 PORT172 card-detect IRQ26 */
        gpio_request(GPIO_FN_IRQ26_172, NULL);
 
-#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
-       /* enable SDHI1 */
-       gpio_request(GPIO_FN_SDHICMD1, NULL);
-       gpio_request(GPIO_FN_SDHICLK1, NULL);
-       gpio_request(GPIO_FN_SDHID1_3, NULL);
-       gpio_request(GPIO_FN_SDHID1_2, NULL);
-       gpio_request(GPIO_FN_SDHID1_1, NULL);
-       gpio_request(GPIO_FN_SDHID1_0, NULL);
-#endif
-       /* card detect pin for MMC slot (CN7) */
-       gpio_request(GPIO_PORT41, NULL);
-       gpio_direction_input(GPIO_PORT41);
-
-       /* enable SDHI2 */
-       gpio_request(GPIO_FN_SDHICMD2, NULL);
-       gpio_request(GPIO_FN_SDHICLK2, NULL);
-       gpio_request(GPIO_FN_SDHID2_3, NULL);
-       gpio_request(GPIO_FN_SDHID2_2, NULL);
-       gpio_request(GPIO_FN_SDHID2_1, NULL);
-       gpio_request(GPIO_FN_SDHID2_0, NULL);
-
-       /* card detect pin for microSD slot (CN23) */
-       gpio_request(GPIO_PORT162, NULL);
-       gpio_direction_input(GPIO_PORT162);
-
-       /* MMCIF */
-       gpio_request(GPIO_FN_MMCD0_0, NULL);
-       gpio_request(GPIO_FN_MMCD0_1, NULL);
-       gpio_request(GPIO_FN_MMCD0_2, NULL);
-       gpio_request(GPIO_FN_MMCD0_3, NULL);
-       gpio_request(GPIO_FN_MMCD0_4, NULL);
-       gpio_request(GPIO_FN_MMCD0_5, NULL);
-       gpio_request(GPIO_FN_MMCD0_6, NULL);
-       gpio_request(GPIO_FN_MMCD0_7, NULL);
-       gpio_request(GPIO_FN_MMCCMD0, NULL);
-       gpio_request(GPIO_FN_MMCCLK0, NULL);
-
        /* FLCTL */
        gpio_request(GPIO_FN_D0_NAF0, NULL);
        gpio_request(GPIO_FN_D1_NAF1, NULL);
@@ -1623,20 +1529,8 @@ static void __init mackerel_init(void)
 
        platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
 
-       rmobile_add_device_to_domain("A4LC", &lcdc_device);
-       rmobile_add_device_to_domain("A4LC", &hdmi_lcdc_device);
-       rmobile_add_device_to_domain("A4LC", &meram_device);
-       rmobile_add_device_to_domain("A4MP", &fsi_device);
-       rmobile_add_device_to_domain("A3SP", &usbhs0_device);
-       rmobile_add_device_to_domain("A3SP", &usbhs1_device);
-       rmobile_add_device_to_domain("A3SP", &nand_flash_device);
-       rmobile_add_device_to_domain("A3SP", &sh_mmcif_device);
-       rmobile_add_device_to_domain("A3SP", &sdhi0_device);
-#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
-       rmobile_add_device_to_domain("A3SP", &sdhi1_device);
-#endif
-       rmobile_add_device_to_domain("A3SP", &sdhi2_device);
-       rmobile_add_device_to_domain("A4R", &ceu_device);
+       rmobile_add_devices_to_domains(domain_devices,
+                                      ARRAY_SIZE(domain_devices));
 
        hdmi_init_pm_clock();
        sh7372_pm_init();
@@ -1644,12 +1538,18 @@ static void __init mackerel_init(void)
        pm_clk_add(&hdmi_lcdc_device.dev, "hdmi");
 }
 
-MACHINE_START(MACKEREL, "mackerel")
+static const char *mackerel_boards_compat_dt[] __initdata = {
+       "renesas,mackerel",
+       NULL,
+};
+
+DT_MACHINE_START(MACKEREL_DT, "mackerel")
        .map_io         = sh7372_map_io,
        .init_early     = sh7372_add_early_devices,
        .init_irq       = sh7372_init_irq,
        .handle_irq     = shmobile_handle_irq_intc,
        .init_machine   = mackerel_init,
-       .init_late      = shmobile_init_late,
-       .timer          = &shmobile_timer,
+       .init_late      = sh7372_pm_init_late,
+       .init_time      = sh7372_earlytimer_init,
+       .dt_compat  = mackerel_boards_compat_dt,
 MACHINE_END