Skip to contentSkip to conversation

ARM: imx6q_logic: Cleanup boot sequence check

PATCH New Adam Ford 2 participants 2 messages Nov 3, 2019 – Dec 28, 2019 Arm i.MX and Layerscape

lore
Share & tools
lore

Adam Ford

author
#0 lore raw

PATCH 1/1 ARM: imx6q_logic: Cleanup boot sequence check

The board_boot_order() function currenly assumes that the boot source is MMC/eMMC, but this isn't true for the NAND devices.

This patch cleans up board_boot_order() to check for NAND, SD, ESD, MMC or EMMC. Anything beyond these are not supported, so it will default back to the serial downloader if any of those devices are not available.

Fixes 9fb50c68daa6 ("ARM: imx6q_logic: Fix MMC2 booting")
board/logicpd/imx6/imx6logic.c +38 -18
index 3c1a3a9fa2..fc4ce34ce4 100644
@@ -154,29 +154,49 @@ void board_boot_order(u32 *spl_boot_list)
 {
 	struct src *psrc = (struct src *)SRC_BASE_ADDR;
 	unsigned int reg = readl(&psrc->sbmr1) >> 11;
-	/*
-	 * Upon reading BOOT_CFG register the following map is done:
-	 * Bit 11 and 12 of BOOT_CFG register can determine the current
-	 * mmc port
-	 * 0x1                  SD1-SOM
-	 * 0x2                  SD2-Baseboard
-	 */
-
-	reg &= 0x3; /* Only care about bottom 2 bits */
-	switch (reg) {
-	case 0:
-		spl_boot_list[0] = BOOT_DEVICE_MMC1;
+	u32 boot_mode = imx6_src_get_boot_mode() & IMX6_BMODE_MASK;
+	unsigned int bmode = readl(&src_base->sbmr2);
+
+	/* If bmode is serial or USB phy is active, return serial */
+	if (((bmode >> 24) & 0x03) == 0x01 || is_usbotg_phy_active()) {
+		spl_boot_list[0] = BOOT_DEVICE_BOARD;
+		return;
+	}
+
+	switch (boot_mode >> IMX6_BMODE_SHIFT) {
+	case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX:
+		spl_boot_list[0] = BOOT_DEVICE_NAND;
 		break;
-	case 1:
-		spl_boot_list[0] = BOOT_DEVICE_MMC2;
+	case IMX6_BMODE_SD:
+	case IMX6_BMODE_ESD:
+	case IMX6_BMODE_MMC:
+	case IMX6_BMODE_EMMC:
+		/*
+		 * Upon reading BOOT_CFG register the following map is done:
+		 * Bit 11 and 12 of BOOT_CFG register can determine the current
+		 * mmc port
+		 * 0x1                  SD1-SOM
+		 * 0x2                  SD2-Baseboard
+		 */
+
+		reg &= 0x3; /* Only care about bottom 2 bits */
+		switch (reg) {
+		case 0:
+			spl_boot_list[0] = BOOT_DEVICE_MMC1;
+			break;
+		case 1:
+			spl_boot_list[0] = BOOT_DEVICE_MMC2;
+			break;
+		}
+		break;
+	default:
+		/* By default use USB downloader */
+		spl_boot_list[0] = BOOT_DEVICE_BOARD;
 		break;
 	}
 
-	/* If we cannot find a valid MMC/SD card, try NAND */
-	spl_boot_list[1] = BOOT_DEVICE_NAND;
-
 	/* As a last resort, use serial downloader */
-	spl_boot_list[2] = BOOT_DEVICE_BOARD;
+	spl_boot_list[1] = BOOT_DEVICE_BOARD;
 }
 
 static void ccgr_init(void)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 ARM: imx6q_logic: Cleanup boot sequence check

Quoted 70 lines

The board_boot_order() function currenly assumes that the boot source is MMC/eMMC, but this isn't true for the NAND devices. This patch cleans up board_boot_order() to check for NAND, SD, ESD, MMC or EMMC. Anything beyond these are not supported, so it will default back to the serial downloader if any of those devices are not available.

Fixes 9fb50c68daa6 ("ARM: imx6q_logic: Fix MMC2 booting")
board/logicpd/imx6/imx6logic.c +37 -14
index 3c1a3a9fa2..fc4ce34ce4 100644
@@ -154,29 +154,49 @@ void board_boot_order(u32 *spl_boot_list)
 {
 	struct src *psrc = (struct src *)SRC_BASE_ADDR;
 	unsigned int reg = readl(&psrc->sbmr1) >> 11;
-	/*
-	 * Upon reading BOOT_CFG register the following map is done:
-	 * Bit 11 and 12 of BOOT_CFG register can determine the current
-	 * mmc port
-	 * 0x1                  SD1-SOM
-	 * 0x2                  SD2-Baseboard
-	 */
-
-	reg &= 0x3; /* Only care about bottom 2 bits */
-	switch (reg) {
-	case 0:
-		spl_boot_list[0] = BOOT_DEVICE_MMC1;
+	u32 boot_mode = imx6_src_get_boot_mode() & IMX6_BMODE_MASK;
+	unsigned int bmode = readl(&src_base->sbmr2);
+
+	/* If bmode is serial or USB phy is active, return serial */
+	if (((bmode >> 24) & 0x03) == 0x01 || is_usbotg_phy_active()) {
+		spl_boot_list[0] = BOOT_DEVICE_BOARD;
+		return;
+	}
+
+	switch (boot_mode >> IMX6_BMODE_SHIFT) {
+	case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX:
+		spl_boot_list[0] = BOOT_DEVICE_NAND;
 		break;
-	case 1:
-		spl_boot_list[0] = BOOT_DEVICE_MMC2;
+	case IMX6_BMODE_SD:
+	case IMX6_BMODE_ESD:
+	case IMX6_BMODE_MMC:
+	case IMX6_BMODE_EMMC:
+		/*
+		 * Upon reading BOOT_CFG register the following map is done:
+		 * Bit 11 and 12 of BOOT_CFG register can determine the current
+		 * mmc port
+		 * 0x1                  SD1-SOM
+		 * 0x2                  SD2-Baseboard
+		 */
+
+		reg &= 0x3; /* Only care about bottom 2 bits */
+		switch (reg) {
+		case 0:
+			spl_boot_list[0] = BOOT_DEVICE_MMC1;
+			break;
+		case 1:
+			spl_boot_list[0] = BOOT_DEVICE_MMC2;
+			break;
+		}
+		break;
+	default:
+		/* By default use USB downloader */
+		spl_boot_list[0] = BOOT_DEVICE_BOARD;
 		break;
 	}

board/logicpd/imx6/imx6logic.c void board_boot_order(u32 *spl_boot_list) · line 202

Quoted 10 lines
board/logicpd/imx6/imx6logic.c +1 -4
 
-	/* If we cannot find a valid MMC/SD card, try NAND */
-	spl_boot_list[1] = BOOT_DEVICE_NAND;
-
 	/* As a last resort, use serial downloader */
-	spl_boot_list[2] = BOOT_DEVICE_BOARD;
+	spl_boot_list[1] = BOOT_DEVICE_BOARD;
 }
 
 static void ccgr_init(void)

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
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
=====================================================================