udoo_neo: Fixes for booting from the mSD card
authorPeter Robinson <pbrobinson@gmail.com>
Tue, 21 Dec 2021 12:32:47 +0000 (12:32 +0000)
committerTom Rini <trini@konsulko.com>
Fri, 7 Jan 2022 14:30:44 +0000 (09:30 -0500)
This fixes booting from the mSD card from both SPL and when
using it for the OS booting. It also cleans up a few mmc
booting bits that are no longer needed.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
arch/arm/dts/imx6sx-udoo-neo-u-boot.dtsi [deleted file]
board/udoo/neo/neo.c
configs/udoo_neo_defconfig
include/configs/udoo_neo.h

diff --git a/arch/arm/dts/imx6sx-udoo-neo-u-boot.dtsi b/arch/arm/dts/imx6sx-udoo-neo-u-boot.dtsi
deleted file mode 100644 (file)
index daf2489..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-
-/ {
-       aliases {
-               mmc0 = &usdhc2;
-       };
-};
index 61195be7449618ab28f2270b8e4f2f14c4fcbe81..8b0d13b1cae108b0cc95351aadf798d5b0159b50 100644 (file)
@@ -19,6 +19,8 @@
 #include <asm/mach-imx/iomux-v3.h>
 #include <dm.h>
 #include <env.h>
+#include <mmc.h>
+#include <fsl_esdhc_imx.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/io.h>
 #include <asm/mach-imx/mxc_i2c.h>
@@ -214,6 +216,19 @@ static iomux_v3_cfg_t const uart1_pads[] = {
        MX6_PAD_GPIO1_IO05__UART1_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
 };
 
+static iomux_v3_cfg_t const usdhc2_pads[] = {
+       MX6_PAD_SD2_CLK__USDHC2_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+       MX6_PAD_SD2_CMD__USDHC2_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+       MX6_PAD_SD2_DATA0__USDHC2_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+       MX6_PAD_SD2_DATA1__USDHC2_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+       MX6_PAD_SD2_DATA2__USDHC2_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+       MX6_PAD_SD2_DATA3__USDHC2_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+       /* CD pin */
+       MX6_PAD_SD1_DATA0__GPIO6_IO_2 | MUX_PAD_CTRL(NO_PAD_CTRL),
+       /* Power */
+       MX6_PAD_SD1_CMD__GPIO6_IO_1 | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
 static iomux_v3_cfg_t const phy_control_pads[] = {
        /* 25MHz Ethernet PHY Clock */
        MX6_PAD_ENET2_RX_CLK__ENET2_REF_CLK_25M |
@@ -327,6 +342,31 @@ int board_early_init_f(void)
        return 0;
 }
 
+static struct fsl_esdhc_cfg usdhc_cfg[1] = {
+       {USDHC2_BASE_ADDR},
+};
+
+#define USDHC2_PWR_GPIO IMX_GPIO_NR(6, 1)
+#define USDHC2_CD_GPIO IMX_GPIO_NR(6, 2)
+
+int board_mmc_getcd(struct mmc *mmc)
+{
+       return !gpio_get_value(USDHC2_CD_GPIO);
+}
+
+int board_mmc_init(struct bd_info *bis)
+{
+       SETUP_IOMUX_PADS(usdhc2_pads);
+       usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
+       usdhc_cfg[0].max_bus_width = 4;
+       gpio_request(IMX_GPIO_NR(6, 1), "usdhc2_pwr");
+       gpio_request(IMX_GPIO_NR(6, 2), "usdhc2_cd");
+       gpio_direction_input(USDHC2_CD_GPIO);
+       gpio_direction_output(USDHC2_PWR_GPIO, 1);
+
+       return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
+}
+
 static char *board_string(void)
 {
        switch (get_board_value()) {
index b2a3e9be4ca978e41cf3a15a962da42f699f3a02..f01d2e22e99044ccfe5e63fdeaab7a7e5f49d411 100644 (file)
@@ -35,6 +35,7 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=1
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_SYS_I2C_LEGACY=y
index b06abc9286b15f404657555fadeee7d0287aadf1..e2b432e1c4894bcb399c11c74705ca9683b84395 100644 (file)
@@ -29,7 +29,7 @@
        "fdt_addr=0x83000000\0" \
        "fdt_addr_r=0x83000000\0" \
        "ip_dyn=yes\0" \
-       "mmcdev=0\0" \
+       "mmcdev=1\0" \
        "mmcrootfstype=ext4\0" \
        "findfdt="\
                "if test $board_name = BASIC; then " \
@@ -49,7 +49,7 @@
        BOOTENV
 
 #define BOOT_TARGET_DEVICES(func) \
-       func(MMC, mmc, 0) \
+       func(MMC, mmc, 1) \
        func(DHCP, dhcp, na)
 
 #include <config_distro_bootcmd.h>