engicam: Move uart mux init to SPL
[platform/kernel/u-boot.git] / board / engicam / icorem6_rqs / icorem6_rqs.c
index cc7f897..d6ca62d 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <common.h>
+#include <mmc.h>
 
 #include <asm/io.h>
 #include <asm/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define UART_PAD_CTRL  (PAD_CTL_PKE | PAD_CTL_PUE |            \
-       PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED |               \
-       PAD_CTL_DSE_40ohm   | PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
-
-static iomux_v3_cfg_t const uart4_pads[] = {
-       IOMUX_PADS(PAD_KEY_COL0__UART4_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
-       IOMUX_PADS(PAD_KEY_ROW0__UART4_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
-};
-
-int board_early_init_f(void)
+int board_init(void)
 {
-       SETUP_IOMUX_PADS(uart4_pads);
+       /* Address of boot parameters */
+       gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
 
        return 0;
 }
 
-int board_init(void)
+#ifdef CONFIG_ENV_IS_IN_MMC
+int board_mmc_get_env_dev(int devno)
 {
-       /* Address of boot parameters */
-       gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
+       /* dev 0 for SD/eSD, dev 1 for MMC/eMMC */
+       return (devno == 3) ? 1 : 0;
+}
 
-       return 0;
+static void mmc_late_init(void)
+{
+       char cmd[32];
+       char mmcblk[32];
+       u32 dev_no = mmc_get_env_dev();
+
+       setenv_ulong("mmcdev", dev_no);
+
+       /* Set mmcblk env */
+       sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
+       setenv("mmcroot", mmcblk);
+
+       sprintf(cmd, "mmc dev %d", dev_no);
+       run_command(cmd, 0);
 }
+#endif
 
 int board_late_init(void)
 {
@@ -53,6 +62,9 @@ int board_late_init(void)
        case IMX6_BMODE_ESD:
        case IMX6_BMODE_MMC:
        case IMX6_BMODE_EMMC:
+#ifdef CONFIG_ENV_IS_IN_MMC
+               mmc_late_init();
+#endif
                setenv("modeboot", "mmcboot");
                break;
        default:
@@ -60,6 +72,11 @@ int board_late_init(void)
                break;
        }
 
+       if (is_mx6dq())
+               setenv("fdt_file", "imx6q-icore-rqs.dtb");
+       else if(is_mx6dl() || is_mx6solo())
+               setenv("fdt_file", "imx6dl-icore-rqs.dtb");
+
        return 0;
 }
 
@@ -77,6 +94,15 @@ int dram_init(void)
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/mx6-ddr.h>
 
+#define UART_PAD_CTRL  (PAD_CTL_PKE | PAD_CTL_PUE |            \
+       PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED |               \
+       PAD_CTL_DSE_40ohm   | PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
+
+static iomux_v3_cfg_t const uart4_pads[] = {
+       IOMUX_PADS(PAD_KEY_COL0__UART4_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
+       IOMUX_PADS(PAD_KEY_ROW0__UART4_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
+};
+
 /* MMC board initialization is needed till adding DM support in SPL */
 #if defined(CONFIG_FSL_ESDHC) && !defined(CONFIG_DM_MMC)
 #include <mmc.h>
@@ -191,6 +217,18 @@ void board_boot_order(u32 *spl_boot_list)
 #endif
 #endif
 
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name)
+{
+       if (is_mx6dq() && !strcmp(name, "imx6q-icore-rqs"))
+               return 0;
+       else if ((is_mx6dl() || is_mx6solo()) && !strcmp(name, "imx6dl-icore-rqs"))
+               return 0;
+       else
+               return -1;
+}
+#endif
+
 /*
  * Driving strength:
  *   0x30 == 40 Ohm
@@ -443,7 +481,7 @@ void board_init_f(ulong dummy)
        gpr_init();
 
        /* iomux */
-       board_early_init_f();
+       SETUP_IOMUX_PADS(uart4_pads);
 
        /* setup GP timer */
        timer_init();