* [PATCH] toradex: colibri_imx7: Enable nand/emmc detection and set boot variant
@ 2023-10-02 11:57 Hiago De Franco
2023-10-02 14:50 ` Marcel Ziswiler
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Hiago De Franco @ 2023-10-02 11:57 UTC (permalink / raw)
To: Marcel Ziswiler; +Cc: u-boot, Hiago De Franco
From: Hiago De Franco <hiago.franco@toradex.com>
Add detection of eMMC vs NAND devices on the Colibri iMX7
board. A GPIO is configured to detect the presence of an on-board resistor
that is configured differently based on the flash memory used. Depending on
the detection result, the 'variant' environment variable is set to '-emmc'
or cleared, indicating the type of storage device.
This enhancement improves variant detection during system initialization
through USB recovery mode, where U-Boot is loaded directly to RAM. This
allows variant detection for an accurate device tree selection.
Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
---
board/toradex/colibri_imx7/colibri_imx7.c | 24 +++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/board/toradex/colibri_imx7/colibri_imx7.c b/board/toradex/colibri_imx7/colibri_imx7.c
index 119e67b47f..f0356af008 100644
--- a/board/toradex/colibri_imx7/colibri_imx7.c
+++ b/board/toradex/colibri_imx7/colibri_imx7.c
@@ -53,6 +53,11 @@ DECLARE_GLOBAL_DATA_PTR;
#define USB_CDET_GPIO IMX_GPIO_NR(7, 14)
+#define FLASH_DETECTION_CTRL (PAD_CTL_HYS | PAD_CTL_PUE)
+#define FLASH_DET_GPIO IMX_GPIO_NR(6, 11)
+
+static bool is_emmc;
+
int dram_init(void)
{
gd->ram_size = get_ram_size((void *)PHYS_SDRAM, imx_ddr_size());
@@ -60,6 +65,10 @@ int dram_init(void)
return 0;
}
+static iomux_v3_cfg_t const flash_detection_pads[] = {
+ MX7D_PAD_SD3_RESET_B__GPIO6_IO11 | MUX_PAD_CTRL(FLASH_DETECTION_CTRL),
+};
+
static iomux_v3_cfg_t const uart1_pads[] = {
MX7D_PAD_UART1_RX_DATA__UART1_DTE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
MX7D_PAD_UART1_TX_DATA__UART1_DTE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
@@ -183,6 +192,16 @@ int board_init(void)
/* address of boot parameters */
gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
+ /*
+ * Enable GPIO on NAND_WE_B/eMMC_RST with 100k pull-down. eMMC_RST
+ * is pulled high with 4.7k for eMMC devices. This allows to reliably
+ * detect eMMC/NAND flash
+ */
+ imx_iomux_v3_setup_multiple_pads(flash_detection_pads, ARRAY_SIZE(flash_detection_pads));
+ gpio_request(FLASH_DET_GPIO, "flash-detection-gpio");
+ is_emmc = gpio_get_value(FLASH_DET_GPIO);
+ gpio_free(FLASH_DET_GPIO);
+
#ifdef CONFIG_FEC_MXC
setup_fec();
#endif
@@ -348,6 +367,11 @@ int board_late_init(void)
env_set("bootcmd", "sdp 0");
}
#endif
+ if (is_emmc)
+ env_set("variant", "-emmc");
+ else
+ env_set("variant", "");
+
return 0;
}
#endif /* CONFIG_BOARD_LATE_INIT */
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] toradex: colibri_imx7: Enable nand/emmc detection and set boot variant
2023-10-02 11:57 [PATCH] toradex: colibri_imx7: Enable nand/emmc detection and set boot variant Hiago De Franco
@ 2023-10-02 14:50 ` Marcel Ziswiler
2023-10-07 12:51 ` Fabio Estevam
2023-10-16 9:22 ` sbabic
2 siblings, 0 replies; 4+ messages in thread
From: Marcel Ziswiler @ 2023-10-02 14:50 UTC (permalink / raw)
To: hiagofranco@gmail.com; +Cc: u-boot@lists.denx.de, Hiago De Franco
On Mon, 2023-10-02 at 08:57 -0300, Hiago De Franco wrote:
> From: Hiago De Franco <hiago.franco@toradex.com>
>
> Add detection of eMMC vs NAND devices on the Colibri iMX7
> board. A GPIO is configured to detect the presence of an on-board resistor
> that is configured differently based on the flash memory used. Depending on
> the detection result, the 'variant' environment variable is set to '-emmc'
> or cleared, indicating the type of storage device.
>
> This enhancement improves variant detection during system initialization
> through USB recovery mode, where U-Boot is loaded directly to RAM. This
> allows variant detection for an accurate device tree selection.
>
> Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> ---
> board/toradex/colibri_imx7/colibri_imx7.c | 24 +++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/board/toradex/colibri_imx7/colibri_imx7.c b/board/toradex/colibri_imx7/colibri_imx7.c
> index 119e67b47f..f0356af008 100644
> --- a/board/toradex/colibri_imx7/colibri_imx7.c
> +++ b/board/toradex/colibri_imx7/colibri_imx7.c
> @@ -53,6 +53,11 @@ DECLARE_GLOBAL_DATA_PTR;
>
> #define USB_CDET_GPIO IMX_GPIO_NR(7, 14)
>
> +#define FLASH_DETECTION_CTRL (PAD_CTL_HYS | PAD_CTL_PUE)
> +#define FLASH_DET_GPIO IMX_GPIO_NR(6, 11)
> +
> +static bool is_emmc;
> +
> int dram_init(void)
> {
> gd->ram_size = get_ram_size((void *)PHYS_SDRAM, imx_ddr_size());
> @@ -60,6 +65,10 @@ int dram_init(void)
> return 0;
> }
>
> +static iomux_v3_cfg_t const flash_detection_pads[] = {
> + MX7D_PAD_SD3_RESET_B__GPIO6_IO11 | MUX_PAD_CTRL(FLASH_DETECTION_CTRL),
> +};
> +
> static iomux_v3_cfg_t const uart1_pads[] = {
> MX7D_PAD_UART1_RX_DATA__UART1_DTE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
> MX7D_PAD_UART1_TX_DATA__UART1_DTE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
> @@ -183,6 +192,16 @@ int board_init(void)
> /* address of boot parameters */
> gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
>
> + /*
> + * Enable GPIO on NAND_WE_B/eMMC_RST with 100k pull-down. eMMC_RST
> + * is pulled high with 4.7k for eMMC devices. This allows to reliably
> + * detect eMMC/NAND flash
> + */
> + imx_iomux_v3_setup_multiple_pads(flash_detection_pads, ARRAY_SIZE(flash_detection_pads));
> + gpio_request(FLASH_DET_GPIO, "flash-detection-gpio");
> + is_emmc = gpio_get_value(FLASH_DET_GPIO);
> + gpio_free(FLASH_DET_GPIO);
> +
> #ifdef CONFIG_FEC_MXC
> setup_fec();
> #endif
> @@ -348,6 +367,11 @@ int board_late_init(void)
> env_set("bootcmd", "sdp 0");
> }
> #endif
> + if (is_emmc)
> + env_set("variant", "-emmc");
> + else
> + env_set("variant", "");
> +
> return 0;
> }
> #endif /* CONFIG_BOARD_LATE_INIT */
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] toradex: colibri_imx7: Enable nand/emmc detection and set boot variant
2023-10-02 11:57 [PATCH] toradex: colibri_imx7: Enable nand/emmc detection and set boot variant Hiago De Franco
2023-10-02 14:50 ` Marcel Ziswiler
@ 2023-10-07 12:51 ` Fabio Estevam
2023-10-16 9:22 ` sbabic
2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2023-10-07 12:51 UTC (permalink / raw)
To: Hiago De Franco; +Cc: Marcel Ziswiler, u-boot, Hiago De Franco
On Mon, Oct 2, 2023 at 10:08 AM Hiago De Franco <hiagofranco@gmail.com> wrote:
>
> From: Hiago De Franco <hiago.franco@toradex.com>
>
> Add detection of eMMC vs NAND devices on the Colibri iMX7
> board. A GPIO is configured to detect the presence of an on-board resistor
> that is configured differently based on the flash memory used. Depending on
> the detection result, the 'variant' environment variable is set to '-emmc'
> or cleared, indicating the type of storage device.
>
> This enhancement improves variant detection during system initialization
> through USB recovery mode, where U-Boot is loaded directly to RAM. This
> allows variant detection for an accurate device tree selection.
>
> Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] toradex: colibri_imx7: Enable nand/emmc detection and set boot variant
2023-10-02 11:57 [PATCH] toradex: colibri_imx7: Enable nand/emmc detection and set boot variant Hiago De Franco
2023-10-02 14:50 ` Marcel Ziswiler
2023-10-07 12:51 ` Fabio Estevam
@ 2023-10-16 9:22 ` sbabic
2 siblings, 0 replies; 4+ messages in thread
From: sbabic @ 2023-10-16 9:22 UTC (permalink / raw)
To: Hiago De Franco, u-boot
> From: Hiago De Franco <hiago.franco@toradex.com>
> Add detection of eMMC vs NAND devices on the Colibri iMX7
> board. A GPIO is configured to detect the presence of an on-board resistor
> that is configured differently based on the flash memory used. Depending on
> the detection result, the 'variant' environment variable is set to '-emmc'
> or cleared, indicating the type of storage device.
> This enhancement improves variant detection during system initialization
> through USB recovery mode, where U-Boot is loaded directly to RAM. This
> allows variant detection for an accurate device tree selection.
> Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Reviewed-by: Fabio Estevam <festevam@gmail.com>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-16 9:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-02 11:57 [PATCH] toradex: colibri_imx7: Enable nand/emmc detection and set boot variant Hiago De Franco
2023-10-02 14:50 ` Marcel Ziswiler
2023-10-07 12:51 ` Fabio Estevam
2023-10-16 9:22 ` sbabic
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox