All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Robinson <pbrobinson@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH 5/8] ARM: embestmx6boards: convert the mars/riot boards to DM_MMC
Date: Fri,  2 Apr 2021 15:52:30 +0100	[thread overview]
Message-ID: <20210402145233.918645-5-pbrobinson@gmail.com> (raw)
In-Reply-To: <20210402145233.918645-1-pbrobinson@gmail.com>

Convert the two Embest boards to use DM MMC.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Cc: "Eric B?nard" <eric@eukrea.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
---
 arch/arm/dts/imx6dl-riotboard-u-boot.dtsi |   8 ++
 arch/arm/dts/imx6q-marsboard-u-boot.dtsi  |   8 ++
 board/embest/mx6boards/mx6boards.c        | 137 ----------------------
 configs/marsboard_defconfig               |   1 +
 configs/riotboard_defconfig               |   1 +
 5 files changed, 18 insertions(+), 137 deletions(-)
 create mode 100644 arch/arm/dts/imx6dl-riotboard-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx6q-marsboard-u-boot.dtsi

diff --git a/arch/arm/dts/imx6dl-riotboard-u-boot.dtsi b/arch/arm/dts/imx6dl-riotboard-u-boot.dtsi
new file mode 100644
index 0000000000..e51cd24d7e
--- /dev/null
+++ b/arch/arm/dts/imx6dl-riotboard-u-boot.dtsi
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/ {
+	aliases {
+		mmc0 = &usdhc2;
+		mmc1 = &usdhc3;
+	};
+};
diff --git a/arch/arm/dts/imx6q-marsboard-u-boot.dtsi b/arch/arm/dts/imx6q-marsboard-u-boot.dtsi
new file mode 100644
index 0000000000..e51cd24d7e
--- /dev/null
+++ b/arch/arm/dts/imx6q-marsboard-u-boot.dtsi
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/ {
+	aliases {
+		mmc0 = &usdhc2;
+		mmc1 = &usdhc3;
+	};
+};
diff --git a/board/embest/mx6boards/mx6boards.c b/board/embest/mx6boards/mx6boards.c
index 65b3942e39..c3bbcff0cf 100644
--- a/board/embest/mx6boards/mx6boards.c
+++ b/board/embest/mx6boards/mx6boards.c
@@ -31,8 +31,6 @@
 #include <asm/mach-imx/video.h>
 #include <i2c.h>
 #include <input.h>
-#include <mmc.h>
-#include <fsl_esdhc_imx.h>
 #include <miiphy.h>
 #include <netdev.h>
 #include <asm/arch/mxc_hdmi.h>
@@ -150,141 +148,6 @@ int board_phy_config(struct phy_device *phydev)
 	return 0;
 }
 
-iomux_v3_cfg_t const usdhc2_pads[] = {
-	MX6_PAD_SD2_CLK__SD2_CLK | MUX_PAD_CTRL(USDHC_PAD_CLK_CTRL),
-	MX6_PAD_SD2_CMD__SD2_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD2_DAT0__SD2_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD2_DAT1__SD2_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD2_DAT2__SD2_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD2_DAT3__SD2_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_GPIO_2__GPIO1_IO02 | MUX_PAD_CTRL(NO_PAD_CTRL), /* WP */
-	MX6_PAD_GPIO_4__GPIO1_IO04 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */
-};
-
-iomux_v3_cfg_t const usdhc3_pads[] = {
-	MX6_PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CLK_CTRL),
-	MX6_PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-};
-
-iomux_v3_cfg_t const riotboard_usdhc3_pads[] = {
-	MX6_PAD_SD3_DAT4__GPIO7_IO01 | MUX_PAD_CTRL(NO_PAD_CTRL), /* WP */
-	MX6_PAD_SD3_DAT5__GPIO7_IO00 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */
-};
-
-iomux_v3_cfg_t const usdhc4_pads[] = {
-	MX6_PAD_SD4_CLK__SD4_CLK | MUX_PAD_CTRL(USDHC_PAD_CLK_CTRL),
-	MX6_PAD_SD4_CMD__SD4_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD4_DAT0__SD4_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD4_DAT1__SD4_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD4_DAT2__SD4_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD4_DAT3__SD4_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	/* eMMC RST */
-	MX6_PAD_NANDF_ALE__GPIO6_IO08 | MUX_PAD_CTRL(NO_PAD_CTRL),
-};
-
-#ifdef CONFIG_FSL_ESDHC_IMX
-struct fsl_esdhc_cfg usdhc_cfg[3] = {
-	{USDHC2_BASE_ADDR},
-	{USDHC3_BASE_ADDR},
-	{USDHC4_BASE_ADDR},
-};
-
-#define USDHC2_CD_GPIO	IMX_GPIO_NR(1, 4)
-#define USDHC3_CD_GPIO	IMX_GPIO_NR(7, 0)
-
-int board_mmc_getcd(struct mmc *mmc)
-{
-	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
-	int ret = 0;
-
-	switch (cfg->esdhc_base) {
-	case USDHC2_BASE_ADDR:
-		ret = !gpio_get_value(USDHC2_CD_GPIO);
-		break;
-	case USDHC3_BASE_ADDR:
-		if (board_type == BOARD_IS_RIOTBOARD)
-			ret = !gpio_get_value(USDHC3_CD_GPIO);
-		else if (board_type == BOARD_IS_MARSBOARD)
-			ret = 1; /* eMMC/uSDHC3 is always present */
-		break;
-	case USDHC4_BASE_ADDR:
-		ret = 1; /* eMMC/uSDHC4 is always present */
-		break;
-	}
-
-	return ret;
-}
-
-int board_mmc_init(struct bd_info *bis)
-{
-	int ret;
-	int i;
-
-	/*
-	 * According to the board_mmc_init() the following map is done:
-	 * (U-Boot device node)    (Physical Port)
-	 * ** RiOTboard :
-	 * mmc0                    SDCard slot (bottom)
-	 * mmc1                    uSDCard slot (top)
-	 * mmc2                    eMMC
-	 * ** MarSBoard :
-	 * mmc0                    uSDCard slot (bottom)
-	 * mmc1                    eMMC
-	 */
-	for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++) {
-		switch (i) {
-		case 0:
-			imx_iomux_v3_setup_multiple_pads(
-				usdhc2_pads, ARRAY_SIZE(usdhc2_pads));
-			gpio_direction_input(USDHC2_CD_GPIO);
-			usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
-			usdhc_cfg[0].max_bus_width = 4;
-			break;
-		case 1:
-			imx_iomux_v3_setup_multiple_pads(
-				usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
-			if (board_type == BOARD_IS_RIOTBOARD) {
-				imx_iomux_v3_setup_multiple_pads(
-					riotboard_usdhc3_pads,
-					ARRAY_SIZE(riotboard_usdhc3_pads));
-				gpio_direction_input(USDHC3_CD_GPIO);
-			} else {
-				gpio_direction_output(IMX_GPIO_NR(7, 8) , 0);
-				udelay(250);
-				gpio_set_value(IMX_GPIO_NR(7, 8), 1);
-			}
-			usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
-			usdhc_cfg[1].max_bus_width = 4;
-			break;
-		case 2:
-			imx_iomux_v3_setup_multiple_pads(
-				usdhc4_pads, ARRAY_SIZE(usdhc4_pads));
-			usdhc_cfg[2].sdhc_clk = mxc_get_clock(MXC_ESDHC4_CLK);
-			usdhc_cfg[2].max_bus_width = 4;
-			gpio_direction_output(IMX_GPIO_NR(6, 8) , 0);
-			udelay(250);
-			gpio_set_value(IMX_GPIO_NR(6, 8), 1);
-			break;
-		default:
-			printf("Warning: you configured more USDHC controllers"
-			       "(%d) then supported by the board (%d)\n",
-			       i + 1, CONFIG_SYS_FSL_USDHC_NUM);
-			return -EINVAL;
-		}
-
-		ret = fsl_esdhc_initialize(bis, &usdhc_cfg[i]);
-		if (ret)
-			return ret;
-	}
-
-	return 0;
-}
-#endif
-
 #ifdef CONFIG_MXC_SPI
 iomux_v3_cfg_t const ecspi1_pads[] = {
 	MX6_PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
diff --git a/configs/marsboard_defconfig b/configs/marsboard_defconfig
index 4d15f0432e..63fc60a884 100644
--- a/configs/marsboard_defconfig
+++ b/configs/marsboard_defconfig
@@ -30,6 +30,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_DM_GPIO=y
 CONFIG_BOUNCE_BUFFER=y
+CONFIG_DM_MMC=y
 CONFIG_FSL_USDHC=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
diff --git a/configs/riotboard_defconfig b/configs/riotboard_defconfig
index 0284f86405..4f86a08e78 100644
--- a/configs/riotboard_defconfig
+++ b/configs/riotboard_defconfig
@@ -42,6 +42,7 @@ CONFIG_DM=y
 CONFIG_DM_GPIO=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_SUPPORT_EMMC_BOOT=y
+CONFIG_DM_MMC=y
 CONFIG_FSL_USDHC=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
-- 
2.31.1

  parent reply	other threads:[~2021-04-02 14:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02 14:52 [PATCH 1/8] ARM: embestmx6boards: Import the marsboard/riotboard. dts files Peter Robinson
2021-04-02 14:52 ` [PATCH 2/8] ARM: marsboard: Enable OF_CONTROL and DM gpio/pin control Peter Robinson
2021-04-08 20:59   ` sbabic at denx.de
2021-04-02 14:52 ` [PATCH 3/8] ARM: embestmx6boards: merge the riotboard's configs together Peter Robinson
2021-04-08 20:58   ` sbabic at denx.de
2021-04-02 14:52 ` [PATCH 4/8] ARM: riotboard: Enable OF_CONTROL and DM gpio/pin control Peter Robinson
2021-04-08 20:57   ` sbabic at denx.de
2021-04-02 14:52 ` Peter Robinson [this message]
2021-04-08 20:58   ` [PATCH 5/8] ARM: embestmx6boards: convert the mars/riot boards to DM_MMC sbabic at denx.de
2021-04-02 14:52 ` [PATCH 6/8] ARM: embestmx6boards: convert mars/riot boards to DM_USB Peter Robinson
2021-04-08 20:58   ` sbabic at denx.de
2021-04-02 14:52 ` [PATCH 7/8] ARM: embestmx6boards: convert mars/riot boards to DM_ETH Peter Robinson
2021-04-08 20:59   ` sbabic at denx.de
2021-04-02 14:52 ` [PATCH 8/8] ARM: embestmx6boards: convert the mars/riot boards to DM SPI Peter Robinson
2021-04-08 20:58   ` sbabic at denx.de
2021-04-03 14:13 ` [PATCH 1/8] ARM: embestmx6boards: Import the marsboard/riotboard. dts files Fabio Estevam
2021-04-08 20:58 ` sbabic at denx.de

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210402145233.918645-5-pbrobinson@gmail.com \
    --to=pbrobinson@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.