Skip to contentSkip to conversation

AST2600: Boot from eMMC

PATCH In review Eddie James 2 participants 8 messages Aug 31, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover AST2600: Boot from eMMC

This series includes the necessary fixes and features to boot SPL and U-Boot from the eMMC chip for Tacoma and Rainier systems.

Eddie James (5):
ARM: Aspeed: AST2600: Support booting from eMMC
spl: mmc: Switch partition error to debug
mmc: Add support for devicetree parameters for Aspeed controller
ARM: dts: Aspeed: Tacoma and Rainier: Add eMMC nodes and parameters
configs: AST2600 Openbmc: Update config for eMMC boot

 arch/arm/dts/ast2600-rainier.dts            |  8 +++
 arch/arm/dts/ast2600-tacoma.dts             |  8 +++
 arch/arm/include/asm/arch-aspeed/boot0.h    |  2 +-
 arch/arm/mach-aspeed/ast2600/board_common.c | 72 +++++++++++++++++++++
 arch/arm/mach-aspeed/ast2600/spl.c          |  9 +--
 common/spl/spl_mmc.c                        |  4 +-
 configs/ast2600_openbmc_spl_defconfig       |  7 +-
 drivers/mmc/aspeed_sdhci.c                  |  2 +
 drivers/mmc/aspeed_sdhci_ic.c               | 16 +++++
 drivers/mmc/sdhci.c                         |  8 +++
 include/configs/aspeed-common.h             |  3 +
 include/mmc.h                               |  1 +
 include/sdhci.h                             |  6 +-
 13 files changed, 132 insertions(+), 14 deletions(-)
 mode change 100755 => 100644 drivers/mmc/aspeed_sdhci.c
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/5 ARM: Aspeed: AST2600: Support booting from eMMC

Fix a number of things in the platform code for the AST2600 to support booting the SPL from eMMC and then loading U-Boot from eMMC.

---
 arch/arm/include/asm/arch-aspeed/boot0.h    |  2 +-
 arch/arm/mach-aspeed/ast2600/board_common.c | 72 +++++++++++++++++++++
 arch/arm/mach-aspeed/ast2600/spl.c          |  9 +--
 include/configs/aspeed-common.h             |  3 +
 4 files changed, 78 insertions(+), 8 deletions(-)
arch/arm/include/asm/arch-aspeed/boot0.h +1 -1
index ecd1e927c7..7fd5208773 100644
@@ -13,7 +13,7 @@ _start:
 #ifdef CONFIG_SPL_BUILD
 	.word	0x0	/* Key location */
 	.word	0x0	/* start address of image */
-	.word	0X0	/* image size */
+	.word	0Xfc00	/* image size 63KB */
 	.word	0x0	/* signature address */
 	.word	0x0	/* header revision ID low */
 	.word	0x0	/* header revision ID high */
arch/arm/mach-aspeed/ast2600/board_common.c +72 -0

81 lines not on this page · raw message

arch/arm/mach-aspeed/ast2600/spl.c +2 -7
index 27796b7385..1a248724ee 100644
@@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define AST_BOOTMODE_UART	2
 
 u32 aspeed_bootmode(void);
+void aspeed_mmc_init(void);
 
 void board_init_f(ulong dummy)
 {
@@ -26,6 +27,7 @@ void board_init_f(ulong dummy)
 	timer_init();
 	preloader_console_init();
 	dram_init();
+	aspeed_mmc_init();
 #endif
 }
 
@@ -68,13 +70,6 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 }
 #endif
 
-#ifdef CONFIG_SPL_MMC_SUPPORT
-u32 spl_boot_mode(const u32 boot_device)
-{
-	return MMCSD_MODE_RAW;
-}
-#endif
-
 #ifdef CONFIG_SPL_OS_BOOT
 int spl_start_uboot(void)
 {
include/configs/aspeed-common.h +3 -0
index cdbffc97a2..7901bc2aff 100644
@@ -11,6 +11,8 @@
 
 #include <asm/arch/platform.h>
 
+#define CONFIG_SUPPORT_EMMC_BOOT
+
 #define CONFIG_BOOTFILE		"all.bin"
 
 #define CONFIG_GATEWAYIP	192.168.0.1
@@ -40,6 +42,7 @@
 
 #define CONFIG_SYS_BOOTMAPSZ		(256 * 1024 * 1024)
 #define CONFIG_SYS_MALLOC_LEN		(32 << 20)
+#define CONFIG_SYS_MONITOR_LEN		0xD0000
 
 /*
  * BOOTP options
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/5 spl: mmc: Switch partition error to debug

In reply to Eddie James

The partition error is normal when loading U-Boot from the eMMC boot partition. This is because the partition is switched first, and then the SPL attempts to get partition info, but it will read it from the wrong spot. The raw load will still work after the error, so make it a debug statement.

---
 common/spl/spl_mmc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
common/spl/spl_mmc.c +1 -3
index 324d91c884..aa0bcea937 100644
@@ -173,9 +173,7 @@ static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
 
 	err = part_get_info(mmc_get_blk_desc(mmc), partition, &info);
 	if (err) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
-		puts("spl: partition error\n");
-#endif
+		debug("spl: partition error\n");
 		return -1;
 	}
 
Signature · 1 line
2.26.2
#3 lore raw

PATCH 3/5 mmc: Add support for devicetree parameters for Aspeed controller

In reply to Eddie James

The Aspeed SDHC needs some additional parameters set to function correctly. These should be encoded in the devicetree.

---
 drivers/mmc/aspeed_sdhci.c    |  2 ++
 drivers/mmc/aspeed_sdhci_ic.c | 16 ++++++++++++++++
 drivers/mmc/sdhci.c           |  8 ++++++++
 include/mmc.h                 |  1 +
 include/sdhci.h               |  6 +++++-
 5 files changed, 32 insertions(+), 1 deletion(-)
 mode change 100755 => 100644 drivers/mmc/aspeed_sdhci.c
drivers/mmc/aspeed_sdhci.c +2 -0
old mode 100755
new mode 100644
index f4cdfe039f..36cbf29db5
@@ -93,6 +93,8 @@ static int aspeed_sdhci_probe(struct udevice *dev)
 	host->mmc = &plat->mmc;
 	if (ret)
 		return ret;
+
+	host->mmc->drv_type = dev_read_u32_default(dev, "sdhci-drive-type", 0);
 	host->mmc->priv = host;
 	host->mmc->dev = dev;
 	upriv->mmc = host->mmc;
drivers/mmc/aspeed_sdhci_ic.c +16 -0
index fd62ab3eae..b8dd5d52f9 100644
@@ -9,6 +9,10 @@
 #include <errno.h>
 #include <fdtdec.h>
 #include <asm/io.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+
+#define TIMING_PHASE_OFFSET 0xf4
 
 struct aspeed_sdhci_general_reg {
 	u32 genreal_info;
@@ -32,6 +36,9 @@ static int aspeed_sdhci_irq_probe(struct udevice *dev)
 {
 	struct aspeed_sdhci_general_data *priv = dev_get_priv(dev);
 	int ret = 0;
+	struct resource regs;
+	void __iomem  *sdhci_ctrl_base;
+	u32 timing_phase;
 
 	debug("%s(dev=%p) \n", __func__, dev);
 
@@ -41,6 +48,15 @@ static int aspeed_sdhci_irq_probe(struct udevice *dev)
 		return ret;
 	}
 
+	ret = dev_read_resource(dev, 0, &regs);
+	if (ret < 0)
+		return ret;
+
+	sdhci_ctrl_base = (void __iomem  *)regs.start;
+
+	timing_phase = dev_read_u32_default(dev, "timing-phase", 0);
+	writel(timing_phase, sdhci_ctrl_base + TIMING_PHASE_OFFSET);
+
 	return 0;
 }
 
drivers/mmc/sdhci.c +8 -0
index ff506cdf9d..2505d5b8be 100644
@@ -460,6 +460,7 @@ static int sdhci_set_ios(struct mmc *mmc)
 #endif
 	u32 ctrl;
 	u32 gen_addr, gen_ctrl;
+	u16 ctrl_2;
 	struct sdhci_host *host = mmc->priv;
 
 	if (host->ops && host->ops->set_control_reg)
@@ -518,6 +519,13 @@ static int sdhci_set_ios(struct mmc *mmc)
 
 	sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
 
+	if ((SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300)) {
+		ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL_2);
+		ctrl_2 &= ~SDHCI_DRIVER_STRENGTH_MASK;
+		ctrl_2 |= host->mmc->drv_type << SDHCI_DRIVER_STRENGTH_SHIFT;
+		sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL_2);
+	}
+
 	/* If available, call the driver specific "post" set_ios() function */
 	if (host->ops && host->ops->set_ios_post)
 		host->ops->set_ios_post(host);
include/mmc.h +1 -0
index 1f30f71d25..4834dbaf81 100644
@@ -639,6 +639,7 @@ struct mmc {
 				  * accessing the boot partitions
 				  */
 	u32 quirks;
+	int drv_type;
 };
 
 struct mmc_hwpart_conf {
include/sdhci.h +5 -1
index 14884e4dbb..6f85895480 100644
@@ -144,7 +144,11 @@
 
 #define SDHCI_ACMD12_ERR	0x3C
 
-/* 3E-3F reserved */
+#define SDHCI_HOST_CONTROL_2        0x3E
+#define SDHCI_DRIVER_STRENGTH_MASK  0x30
+#define SDHCI_DRIVER_STRENGTH_SHIFT 4
+
+/* 3F reserved */
 
 #define SDHCI_CAPABILITIES	0x40
 #define  SDHCI_TIMEOUT_CLK_MASK	0x0000003F
Signature · 1 line
2.26.2
maintainer
#4 lore raw

Re: [PATCH u-boot v2019.04-aspeed-openbmc 3/5] mmc: Add support for devicetree parameters for Aspeed controller

Quoted 5 lines · Eddie James

The Aspeed SDHC needs some additional parameters set to function correctly. These should be encoded in the devicetree.

Does this use the same binding as the kernel patches that Andrew is going to send upstream?

Can this one go straight to upstream u-boot?

Quoted 123 lines
---
 drivers/mmc/aspeed_sdhci.c    |  2 ++
 drivers/mmc/aspeed_sdhci_ic.c | 16 ++++++++++++++++
 drivers/mmc/sdhci.c           |  8 ++++++++
 include/mmc.h                 |  1 +
 include/sdhci.h               |  6 +++++-
 5 files changed, 32 insertions(+), 1 deletion(-)
 mode change 100755 => 100644 drivers/mmc/aspeed_sdhci.c
drivers/mmc/aspeed_sdhci.c +2 -0
old mode 100755
new mode 100644
index f4cdfe039f..36cbf29db5
@@ -93,6 +93,8 @@ static int aspeed_sdhci_probe(struct udevice *dev)
        host->mmc = &plat->mmc;
        if (ret)
                return ret;
+
+       host->mmc->drv_type = dev_read_u32_default(dev, "sdhci-drive-type", 0);
        host->mmc->priv = host;
        host->mmc->dev = dev;
        upriv->mmc = host->mmc;
drivers/mmc/aspeed_sdhci_ic.c +16 -0
index fd62ab3eae..b8dd5d52f9 100644
@@ -9,6 +9,10 @@
 #include <errno.h>
 #include <fdtdec.h>
 #include <asm/io.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+
+#define TIMING_PHASE_OFFSET 0xf4
 
 struct aspeed_sdhci_general_reg {
        u32 genreal_info;
@@ -32,6 +36,9 @@ static int aspeed_sdhci_irq_probe(struct udevice *dev)
 {
        struct aspeed_sdhci_general_data *priv = dev_get_priv(dev);
        int ret = 0;
+       struct resource regs;
+       void __iomem  *sdhci_ctrl_base;
+       u32 timing_phase;
 
        debug("%s(dev=%p) \n", __func__, dev);
 
@@ -41,6 +48,15 @@ static int aspeed_sdhci_irq_probe(struct udevice *dev)
                return ret;
        }
 
+       ret = dev_read_resource(dev, 0, &regs);
+       if (ret < 0)
+               return ret;
+
+       sdhci_ctrl_base = (void __iomem  *)regs.start;
+
+       timing_phase = dev_read_u32_default(dev, "timing-phase", 0);
+       writel(timing_phase, sdhci_ctrl_base + TIMING_PHASE_OFFSET);
+
        return 0;
 }
 
drivers/mmc/sdhci.c +8 -0
index ff506cdf9d..2505d5b8be 100644
@@ -460,6 +460,7 @@ static int sdhci_set_ios(struct mmc *mmc)
 #endif
        u32 ctrl;
        u32 gen_addr, gen_ctrl;
+       u16 ctrl_2;
        struct sdhci_host *host = mmc->priv;
 
        if (host->ops && host->ops->set_control_reg)
@@ -518,6 +519,13 @@ static int sdhci_set_ios(struct mmc *mmc)
 
        sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
 
+       if ((SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300)) {
+               ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL_2);
+               ctrl_2 &= ~SDHCI_DRIVER_STRENGTH_MASK;
+               ctrl_2 |= host->mmc->drv_type << SDHCI_DRIVER_STRENGTH_SHIFT;
+               sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL_2);
+       }
+
        /* If available, call the driver specific "post" set_ios() function */
        if (host->ops && host->ops->set_ios_post)
                host->ops->set_ios_post(host);
include/mmc.h +1 -0
index 1f30f71d25..4834dbaf81 100644
@@ -639,6 +639,7 @@ struct mmc {
                                  * accessing the boot partitions
                                  */
        u32 quirks;
+       int drv_type;
 };
 
 struct mmc_hwpart_conf {
include/sdhci.h +5 -2
index 14884e4dbb..6f85895480 100644
@@ -144,7 +144,11 @@
 
 #define SDHCI_ACMD12_ERR       0x3C
 
-/* 3E-3F reserved */
+#define SDHCI_HOST_CONTROL_2        0x3E
+#define SDHCI_DRIVER_STRENGTH_MASK  0x30
+#define SDHCI_DRIVER_STRENGTH_SHIFT 4
+
+/* 3F reserved */
 
 #define SDHCI_CAPABILITIES     0x40
 #define  SDHCI_TIMEOUT_CLK_MASK        0x0000003F
--

2.26.2

#5 lore raw

PATCH 4/5 ARM: dts: Aspeed: Tacoma and Rainier: Add eMMC nodes and parameters

In reply to Eddie James

Add the necessary eMMC/SDHC nodes and information to use the eMMC from SPL and U-Boot.

---
 arch/arm/dts/ast2600-rainier.dts | 8 ++++++++
 arch/arm/dts/ast2600-tacoma.dts  | 8 ++++++++
 2 files changed, 16 insertions(+)
arch/arm/dts/ast2600-rainier.dts +8 -0
index ce530eb92b..67e177baf1 100644
@@ -18,6 +18,7 @@
 	};
 
 	aliases {
+		mmc0 = &emmc_slot0;
 		spi0 = &fmc;
 		spi1 = &spi1;
 	};
@@ -89,9 +90,16 @@
 	};
 };
 
+&emmc {
+	u-boot,dm-pre-reloc;
+	timing-phase = <0x700ff>;
+};
+
 &emmc_slot0 {
+	u-boot,dm-pre-reloc;
 	status = "okay";
 	bus-width = <4>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_emmc_default>;
+	sdhci-drive-type = <1>;
 };
arch/arm/dts/ast2600-tacoma.dts +8 -0
index 22b9f39fa2..85d1e3902b 100644
@@ -18,6 +18,7 @@
 	};
 
 	aliases {
+		mmc0 = &emmc_slot0;
 		spi0 = &fmc;
 		spi1 = &spi1;
 	};
@@ -80,9 +81,16 @@
 	};
 };
 
+&emmc {
+	u-boot,dm-pre-reloc;
+	timing-phase = <0x700ff>;
+};
+
 &emmc_slot0 {
+	u-boot,dm-pre-reloc;
 	status = "okay";
 	bus-width = <4>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_emmc_default>;
+	sdhci-drive-type = <1>;
 };
Signature · 1 line
2.26.2
maintainer
#6 lore raw

Re: [PATCH u-boot v2019.04-aspeed-openbmc 4/5] ARM: dts: Aspeed: Tacoma and Rainier: Add eMMC nodes and parameters

Quoted 3 lines · Eddie James

Add the necessary eMMC/SDHC nodes and information to use the eMMC from SPL and U-Boot.

I assume these are the same values we use in the kernel?

Quoted 68 lines
---
 arch/arm/dts/ast2600-rainier.dts | 8 ++++++++
 arch/arm/dts/ast2600-tacoma.dts  | 8 ++++++++
 2 files changed, 16 insertions(+)
arch/arm/dts/ast2600-rainier.dts +8 -0
index ce530eb92b..67e177baf1 100644
@@ -18,6 +18,7 @@
        };
 
        aliases {
+               mmc0 = &emmc_slot0;
                spi0 = &fmc;
                spi1 = &spi1;
        };
@@ -89,9 +90,16 @@
        };
 };
 
+&emmc {
+       u-boot,dm-pre-reloc;
+       timing-phase = <0x700ff>;
+};
+
 &emmc_slot0 {
+       u-boot,dm-pre-reloc;
        status = "okay";
        bus-width = <4>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_emmc_default>;
+       sdhci-drive-type = <1>;
 };
arch/arm/dts/ast2600-tacoma.dts +8 -1
index 22b9f39fa2..85d1e3902b 100644
@@ -18,6 +18,7 @@
        };
 
        aliases {
+               mmc0 = &emmc_slot0;
                spi0 = &fmc;
                spi1 = &spi1;
        };
@@ -80,9 +81,16 @@
        };
 };
 
+&emmc {
+       u-boot,dm-pre-reloc;
+       timing-phase = <0x700ff>;
+};
+
 &emmc_slot0 {
+       u-boot,dm-pre-reloc;
        status = "okay";
        bus-width = <4>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_emmc_default>;
+       sdhci-drive-type = <1>;
 };
--

2.26.2

#7 lore raw

PATCH 5/5 configs: AST2600 Openbmc: Update config for eMMC boot

In reply to Eddie James

Set some additional parameters to boot eMMC.

---
 configs/ast2600_openbmc_spl_defconfig | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
configs/ast2600_openbmc_spl_defconfig +5 -2
index c2e3393708..86e3ea289d 100644
@@ -3,9 +3,10 @@ CONFIG_SYS_CONFIG_NAME="evb_ast2600a1_spl"
 CONFIG_SYS_DCACHE_OFF=y
 CONFIG_POSITION_INDEPENDENT=y
 CONFIG_SPL_SYS_THUMB_BUILD=y
+CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
 CONFIG_SPL_LDSCRIPT="arch/$(ARCH)/mach-aspeed/ast2600/u-boot-spl.lds"
 CONFIG_ARCH_ASPEED=y
-CONFIG_SYS_TEXT_BASE=0x10000
+CONFIG_SYS_TEXT_BASE=0x8b000000
 CONFIG_ASPEED_AST2600=y
 CONFIG_TARGET_EVB_AST2600A1=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
@@ -33,8 +34,9 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_ARCH_EARLY_INIT_R=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
-CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x0
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x80
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=1
 CONFIG_SPL_DM_RESET=y
 CONFIG_SPL_RAM_SUPPORT=y
 CONFIG_SPL_RAM_DEVICE=y
@@ -80,6 +82,7 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_DM=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
+CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
 CONFIG_DM_GPIO=y
Signature · 1 line
2.26.2