Skip to contentSkip to conversation

mx6qsabre{sd, auto}: Add update_sd_firmware support

PATCH New Otavio Salvador 2 participants 14 messages Apr 19, 2013 – Apr 25, 2013 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/7 mx6qsabre{sd, auto}: Add update_sd_firmware support

This allow for easy update of firmware in the SD card from a running U-Boot.

---
Changes in v3:
- New patch

Changes in v2: None

 include/configs/mx6qsabre_common.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
include/configs/mx6qsabre_common.h +14 -0
index 015e2b0..a32d7dd 100644
@@ -78,6 +78,7 @@
 
 #define CONFIG_CMD_BMODE
 #define CONFIG_CMD_BOOTZ
+#define CONFIG_CMD_SETEXPR
 #undef CONFIG_CMD_IMLS
 
 #define CONFIG_BOOTDELAY               10
@@ -98,6 +99,19 @@
 	"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
 	"mmcpart=" __stringify(CONFIG_SYS_MMC_ENV_PART) "\0" \
 	"mmcroot=" CONFIG_MMCROOT " rootwait rw\0" \
+	"update_sd_firmware=" \
+		"if test ${ip_dyn} = yes; then " \
+			"setenv get_cmd dhcp; " \
+		"else " \
+			"setenv get_cmd tftp; " \
+		"fi; " \
+		"if mmc dev ${mmcdev}; then "	\
+			"if ${get_cmd} ${update_sd_firmware_filename}; then " \
+				"setexpr fw_sz ${filesize} / 0x200; " \
+				"setexpr fw_sz ${fw_sz} + 1; "	\
+				"mmc write ${loadaddr} 0x2 ${fw_sz}; " \
+			"fi; "	\
+		"fi\0" \
 	"mmcargs=setenv bootargs console=${console},${baudrate} " \
 		"root=${mmcroot}\0" \
 	"loadbootscript=" \
Signature · 1 line
1.8.1
#1 lore raw

PATCH v3 2/7 mx6qsabresd: Return status when initializing MMC

---
Changes in v3:
- New patch

Changes in v2: None

 board/freescale/mx6qsabresd/mx6qsabresd.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
board/freescale/mx6qsabresd/mx6qsabresd.c +7 -6
index 0d7cb9e..bf9beef 100644
@@ -166,6 +166,7 @@ int board_mmc_getcd(struct mmc *mmc)
 
 int board_mmc_init(bd_t *bis)
 {
+	s32 status = 0;
 	int i;
 
 	/*
@@ -196,15 +197,15 @@ int board_mmc_init(bd_t *bis)
 			break;
 		default:
 			printf("Warning: you configured more USDHC controllers"
-				"(%d) than supported by the board\n", i + 1);
-			return 0;
-	       }
+			       "(%d) then supported by the board (%d)\n",
+			       i + 1, CONFIG_SYS_FSL_USDHC_NUM);
+			return status;
+		}
 
-	       if (fsl_esdhc_initialize(bis, &usdhc_cfg[i]))
-			printf("Warning: failed to initialize mmc dev %d\n", i);
+		status |= fsl_esdhc_initialize(bis, &usdhc_cfg[i]);
 	}
 
-	return 0;
+	return status;
 }
 #endif
 
Signature · 1 line
1.8.1
#2 lore raw

PATCH v3 2/7 mx6qsabresd: Return status when initializing MMC

Quoted 2 lines · Otavio Salvador

---

Applied to u-boot-imx, -next branch, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#3 lore raw

PATCH v3 3/7 wandboard: Use env storage info for mmcdev/mmcpart

In reply to Otavio Salvador

This makes environment and mmcdev/mmcpart in sync with SYS_MMC_ENV_DEV and SYS_MMC_ENV_PART settings.

---
Changes in v3:
- New patch

Changes in v2: None

 include/configs/wandboard.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
include/configs/wandboard.h +3 -2
index 120e3f6..bd3e727 100644
@@ -97,8 +97,8 @@
 	"fdt_addr=0x11000000\0" \
 	"boot_fdt=try\0" \
 	"ip_dyn=yes\0" \
-	"mmcdev=0\0" \
-	"mmcpart=2\0" \
+	"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
+	"mmcpart=" __stringify(CONFIG_SYS_MMC_ENV_PART) "\0" \
 	"mmcroot=/dev/mmcblk0p3 rootwait rw\0" \
 	"mmcargs=setenv bootargs console=${console},${baudrate} " \
 		"root=${mmcroot}\0" \
@@ -198,6 +198,7 @@
 #define CONFIG_ENV_IS_IN_MMC
 #define CONFIG_ENV_OFFSET		(6 * 64 * 1024)
 #define CONFIG_SYS_MMC_ENV_DEV		0
+#define CONFIG_SYS_MMC_ENV_PART		2
 
 #define CONFIG_OF_LIBFDT
 #define CONFIG_CMD_BOOTZ
Signature · 1 line
1.8.1
#4 lore raw

PATCH v3 3/7 wandboard: Use env storage info for mmcdev/mmcpart

Quoted 5 lines · Otavio Salvador

This makes environment and mmcdev/mmcpart in sync with SYS_MMC_ENV_DEV and SYS_MMC_ENV_PART settings.

---

Applied to u-boot-imx, -next branch, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#5 lore raw

PATCH v3 4/7 wandboard: Add update_sd_firmware support

In reply to Otavio Salvador

This allow for easy update of firmware in the SD card from a running U-Boot.

---
Changes in v3:
- New patch

Changes in v2: None

 include/configs/wandboard.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
include/configs/wandboard.h +16 -0
index bd3e727..0dc3286 100644
@@ -47,6 +47,8 @@
 
 #undef CONFIG_CMD_IMLS
 
+#define CONFIG_CMD_SETEXPR
+
 #define CONFIG_BOOTDELAY		5
 
 #define CONFIG_SYS_MEMTEST_START	0x10000000
@@ -100,6 +102,20 @@
 	"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
 	"mmcpart=" __stringify(CONFIG_SYS_MMC_ENV_PART) "\0" \
 	"mmcroot=/dev/mmcblk0p3 rootwait rw\0" \
+	"update_sd_firmware_filename=u-boot.imx\0" \
+	"update_sd_firmware=" \
+		"if test ${ip_dyn} = yes; then " \
+			"setenv get_cmd dhcp; " \
+		"else " \
+			"setenv get_cmd tftp; " \
+		"fi; " \
+		"if mmc dev ${mmcdev}; then "	\
+			"if ${get_cmd} ${update_sd_firmware_filename}; then " \
+				"setexpr fw_sz ${filesize} / 0x200; " \
+				"setexpr fw_sz ${fw_sz} + 1; "	\
+				"mmc write ${loadaddr} 0x2 ${fw_sz}; " \
+			"fi; "	\
+		"fi\0" \
 	"mmcargs=setenv bootargs console=${console},${baudrate} " \
 		"root=${mmcroot}\0" \
 	"loadbootscript=" \
Signature · 1 line
1.8.1
#6 lore raw

PATCH v3 4/7 wandboard: Add update_sd_firmware support

Quoted 4 lines · Otavio Salvador

This allow for easy update of firmware in the SD card from a running U-Boot.

Quoted 9 lines

---
Changes in v3:
- New patch

Changes in v2: None

 include/configs/wandboard.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Applied to u-boot-imx branch, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#7 lore raw

PATCH v3 5/7 wandboard: Add card detection for SOM MicroSD card

In reply to Otavio Salvador

This add support to identify if the card is connected or not; so it does not try to communicate with the controller if no card is available.

---
Changes in v3:
- Move GPIO definition to the top

Changes in v2: None

 arch/arm/include/asm/arch-mx6/mx6dl_pins.h |  1 +
 board/wandboard/wandboard.c                | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
arch/arm/include/asm/arch-mx6/mx6dl_pins.h +1 -0
index 9846f1b..b8e6bf0 100644
@@ -93,6 +93,7 @@ enum {
 	MX6_PAD_EIM_D28__I2C1_SDA		= IOMUX_PAD(0x0544, 0x0174, 1 | IOMUX_CONFIG_SION, 0x086C, 1, 0),
 	MX6_PAD_EIM_D28__GPIO_3_28		= IOMUX_PAD(0x0544, 0x0174, 5, 0x0000, 0, 0),
 	MX6_PAD_EIM_D29__GPIO_3_29		= IOMUX_PAD(0x0548, 0x0178, 5, 0x0000, 0, 0),
+	MX6_PAD_EIM_DA9__GPIO_3_9		= IOMUX_PAD(0x0590, 0x01C0, 5, 0x0000, 0, 0),
 	MX6_PAD_ENET_MDC__ENET_MDC		= IOMUX_PAD(0x05B8, 0x01E8, 1, 0x0000, 0,  0),
 	MX6_PAD_ENET_MDIO__ENET_MDIO		= IOMUX_PAD(0x05BC, 0x01EC, 1, 0x0810, 0, 0),
 	MX6_PAD_ENET_REF_CLK__ENET_TX_CLK	= IOMUX_PAD(0x05C0, 0x01F0, 1, 0x0000, 0, 0),
board/wandboard/wandboard.c +18 -0
index ac7b89a..8ec7eb9 100644
@@ -38,6 +38,7 @@ DECLARE_GLOBAL_DATA_PTR;
 	PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED   |		\
 	PAD_CTL_DSE_40ohm   | PAD_CTL_HYS)
 
+#define USDHC3_CD_GPIO		IMX_GPIO_NR(3, 9)
 #define ETH_PHY_RESET		IMX_GPIO_NR(3, 29)
 
 int dram_init(void)
@@ -59,6 +60,8 @@ static iomux_v3_cfg_t const usdhc3_pads[] = {
 	MX6_PAD_SD3_DAT1__USDHC3_DAT1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
 	MX6_PAD_SD3_DAT2__USDHC3_DAT2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
 	MX6_PAD_SD3_DAT3__USDHC3_DAT3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	/* SOM MicroSD Card Detect */
+	MX6_PAD_EIM_DA9__GPIO_3_9     | MUX_PAD_CTRL(NO_PAD_CTRL),
 };
 
 static iomux_v3_cfg_t const enet_pads[] = {
@@ -100,12 +103,27 @@ static struct fsl_esdhc_cfg usdhc_cfg[1] = {
 	{USDHC3_BASE_ADDR},
 };
 
+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 USDHC3_BASE_ADDR:
+		ret = !gpio_get_value(USDHC3_CD_GPIO);
+		break;
+	}
+
+	return ret;
+}
+
 int board_mmc_init(bd_t *bis)
 {
 	imx_iomux_v3_setup_multiple_pads(usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
 
 	usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
 	usdhc_cfg[0].max_bus_width = 4;
+	gpio_direction_input(USDHC3_CD_GPIO);
 
 	return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
 }
Signature · 1 line
1.8.1
#8 lore raw

PATCH v3 5/7 wandboard: Add card detection for SOM MicroSD card

Quoted 6 lines · Otavio Salvador

This add support to identify if the card is connected or not; so it does not try to communicate with the controller if no card is available.

---

Discharge wrong applied message - patches are applied to u-boot-imx, master branch.

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#9 lore raw

PATCH v3 6/7 wandboard: Add support for Carrier Board MicroSD card

In reply to Otavio Salvador

Allow use of the carrier board MicroSD card available in the Wandboard; this allow for loading alternative system from the other card for testing or upgrade proposes.

---
Changes in v3:
- Improve commit log
- Reword comment about the 'mmc' mapping
- Rework code which initialize mmc
- Move GPIO definition to the top

Changes in v2:
- Return -EINVAL when trying to initialize a wrong controller

 arch/arm/include/asm/arch-mx6/mx6dl_pins.h |  7 ++++
 board/wandboard/wandboard.c                | 59 ++++++++++++++++++++++++++----
 include/configs/wandboard.h                |  1 +
 3 files changed, 60 insertions(+), 7 deletions(-)
arch/arm/include/asm/arch-mx6/mx6dl_pins.h +7 -0
index b8e6bf0..8cedbdc 100644
@@ -103,6 +103,7 @@ enum {
 	MX6_PAD_GPIO_17__GPIO_7_12		= IOMUX_PAD(0x05E8, 0x0218, 5, 0x0000, 0, 0),
 	MX6_PAD_GPIO_18__GPIO_7_13		= IOMUX_PAD(0x05EC, 0x021C, 5, 0x0000, 0, 0),
 	MX6_PAD_GPIO_19__GPIO_4_5		= IOMUX_PAD(0x05F0, 0x0220, 5, 0x0000, 0, 0),
+	MX6_PAD_GPIO_2__GPIO_1_2		= IOMUX_PAD(0x05F4, 0x0224, 5, 0x0000, 0, 0),
 	MX6_PAD_GPIO_5__GPIO_1_5		= IOMUX_PAD(0x0600, 0x0230, 5, 0x0000, 0, 0),
 	MX6_PAD_GPIO_5__I2C3_SCL		= IOMUX_PAD(0x0600, 0x0230, 6 | IOMUX_CONFIG_SION, 0x0878, 2, 0),
 	MX6_PAD_KEY_COL3__I2C2_SCL		= IOMUX_PAD(0x0638, 0x0250, 4 | IOMUX_CONFIG_SION, 0x0870, 1, 0),
@@ -135,8 +136,14 @@ enum {
 	MX6_PAD_RGMII_TD3__ENET_RGMII_TD3	= IOMUX_PAD(0x06B8, 0x02D0, 1, 0x0000, 0, 0),
 	MX6_PAD_RGMII_TX_CTL__RGMII_TX_CTL	= IOMUX_PAD(0x06BC, 0x02D4, 1, 0x0000, 0, 0),
 	MX6_PAD_RGMII_TXC__ENET_RGMII_TXC	= IOMUX_PAD(0x06C0, 0x02D8, 1, 0x0000, 0, 0),
+	MX6_PAD_SD1_CLK__USDHC1_CLK		= IOMUX_PAD(0x06C4, 0x02DC, 0, 0x0928, 1, 0),
+	MX6_PAD_SD1_CMD__USDHC1_CMD		= IOMUX_PAD(0x06C8, 0x02E0, 0 | IOMUX_CONFIG_SION, 0x0000, 0, 0),
 	MX6_PAD_SD1_CMD__GPIO_1_18		= IOMUX_PAD(0x06C8, 0x02E0, 5, 0x0000, 0, 0),
 	MX6_PAD_SD1_DAT3__GPIO_1_21		= IOMUX_PAD(0x06D8, 0x02F0, 5, 0x0000, 0, 0),
+	MX6_PAD_SD1_DAT0__USDHC1_DAT0		= IOMUX_PAD(0x06CC, 0x02E4, 0, 0x0000, 0, 0),
+	MX6_PAD_SD1_DAT1__USDHC1_DAT1		= IOMUX_PAD(0x06D0, 0x02E8, 0, 0x0000, 0, 0),
+	MX6_PAD_SD1_DAT2__USDHC1_DAT2		= IOMUX_PAD(0x06D4, 0x02EC, 0, 0x0000, 0, 0),
+	MX6_PAD_SD1_DAT3__USDHC1_DAT3		= IOMUX_PAD(0x06D8, 0x02F0, 0, 0x0000, 0, 0),
 	MX6_PAD_SD3_CLK__USDHC3_CLK		= IOMUX_PAD(0x06F4, 0x030C, 0, 0x0934, 1, 0),
 	MX6_PAD_SD3_CMD__USDHC3_CMD		= IOMUX_PAD(0x06F8, 0x0310, 0 | IOMUX_CONFIG_SION, 0x0000, 0, 0),
 	MX6_PAD_SD3_DAT0__USDHC3_DAT0		= IOMUX_PAD(0x06FC, 0x0314, 0, 0x0000, 0, 0),
board/wandboard/wandboard.c +52 -7

91 lines not on this page · raw message

include/configs/wandboard.h +1 -0
index 0dc3286..9898f55 100644
@@ -59,6 +59,7 @@
 /* MMC Configuration */
 #define CONFIG_FSL_ESDHC
 #define CONFIG_FSL_USDHC
+#define CONFIG_SYS_FSL_USDHC_NUM	2
 #define CONFIG_SYS_FSL_ESDHC_ADDR	0
 
 #define CONFIG_MMC
Signature · 1 line
1.8.1
#10 lore raw

PATCH v3 6/7 wandboard: Add support for Carrier Board MicroSD card

Quoted 6 lines · Otavio Salvador

Allow use of the carrier board MicroSD card available in the Wandboard; this allow for loading alternative system from the other card for testing or upgrade proposes.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#11 lore raw

PATCH v3 7/7 wandboard: Add boot selection support

In reply to Otavio Salvador

Adds support for 'bmode' command which let user to choose where to boot from; this allows U-Boot to load system from another storage without messing with jumpers.

---
Changes in v3: None
Changes in v2: None

 board/wandboard/wandboard.c | 19 +++++++++++++++++++
 include/configs/wandboard.h |  2 ++
 2 files changed, 21 insertions(+)
board/wandboard/wandboard.c +19 -0
index 2bf121c..c71c90d 100644
@@ -16,6 +16,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/gpio.h>
 #include <asm/imx-common/iomux-v3.h>
+#include <asm/imx-common/boot_mode.h>
 #include <asm/io.h>
 #include <asm/sizes.h>
 #include <common.h>
@@ -225,6 +226,24 @@ int board_early_init_f(void)
 	return 0;
 }
 
+#ifdef CONFIG_CMD_BMODE
+static const struct boot_mode board_boot_modes[] = {
+	/* 4 bit bus width */
+	{"mmc0",	  MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)},
+	{"mmc1",	  MAKE_CFGVAL(0x40, 0x20, 0x00, 0x00)},
+	{NULL,	 0},
+};
+#endif
+
+int board_late_init(void)
+{
+#ifdef CONFIG_CMD_BMODE
+	add_board_boot_modes(board_boot_modes);
+#endif
+
+	return 0;
+}
+
 int board_init(void)
 {
 	/* address of boot parameters */
include/configs/wandboard.h +2 -0
index 9898f55..9d7ec3f 100644
@@ -32,6 +32,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(3 * SZ_1M)
 
 #define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_BOARD_LATE_INIT
 #define CONFIG_MXC_GPIO
 
 #define CONFIG_MXC_UART
@@ -47,6 +48,7 @@
 
 #undef CONFIG_CMD_IMLS
 
+#define CONFIG_CMD_BMODE
 #define CONFIG_CMD_SETEXPR
 
 #define CONFIG_BOOTDELAY		5
Signature · 1 line
1.8.1
#12 lore raw

PATCH v3 7/7 wandboard: Add boot selection support

Quoted 6 lines · Otavio Salvador

Adds support for 'bmode' command which let user to choose where to boot from; this allows U-Boot to load system from another storage without messing with jumpers.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#13 lore raw

PATCH v3 1/7 mx6qsabre{sd, auto}: Add update_sd_firmware support

In reply to Otavio Salvador
Quoted 5 lines · Otavio Salvador

This allow for easy update of firmware in the SD card from a running U-Boot.

---

Applied to u-boot-imx, -next branch, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================