]> git.baikalelectronics.ru Git - uboot.git/commitdiff
riscv: Support booting SiFive Unmatched from SPI.
authorThomas Skibo <thomas-git@skibo.net>
Wed, 24 Nov 2021 22:32:09 +0000 (14:32 -0800)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Thu, 2 Dec 2021 08:43:56 +0000 (16:43 +0800)
Configure SPI flash devices into SPL.  Add SPI boot option to spl.c.
Document how to format flash for booting.

Signed-off-by: Thomas Skibo <thomas-git@skibo.net>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
arch/riscv/dts/hifive-unmatched-a00-u-boot.dtsi
board/sifive/unmatched/spl.c
configs/sifive_unmatched_defconfig
doc/board/sifive/unmatched.rst

index c5475aa149873d1cf76d94e4f22faa5758f70990..1ee8ab1868d96a922faa8b70e7dbe1e8b5c085bc 100644 (file)
                u-boot,dm-spl;
        };
 
+       config {
+               u-boot,spl-payload-offset = <0x105000>; /* loader2 @1044KB */
+       };
+
        hfclk {
                u-boot,dm-spl;
        };
        clocks = <&rtcclk>;
 };
 
+&qspi0 {
+       u-boot,dm-spl;
+       flash@0 {
+               u-boot,dm-spl;
+       };
+};
+
 &spi0 {
        mmc@0 {
                u-boot,dm-spl;
index d5663274cd13281ab3afadc3dd62f42ad8eb314f..7c0beedc083082fa510e3146f3e2dcc512d74f5d 100644 (file)
@@ -22,6 +22,7 @@
 #define GEM_PHY_RESET  SIFIVE_GENERIC_GPIO_NR(0, 12)
 
 #define MODE_SELECT_REG                0x1000
+#define MODE_SELECT_SPI                0x6
 #define MODE_SELECT_SD         0xb
 #define MODE_SELECT_MASK       GENMASK(3, 0)
 
@@ -123,6 +124,8 @@ u32 spl_boot_device(void)
        u32 boot_device = mode_select & MODE_SELECT_MASK;
 
        switch (boot_device) {
+       case MODE_SELECT_SPI:
+               return BOOT_DEVICE_SPI;
        case MODE_SELECT_SD:
                return BOOT_DEVICE_MMC1;
        default:
index 9cc18b029c7b000b23d28296b0b73a41d546b0b5..d400ed0b23c06f1a9bf1b6056b99fe0b3be5f77e 100644 (file)
@@ -8,6 +8,7 @@ CONFIG_SPL_DM_SPI=y
 CONFIG_DEFAULT_DEVICE_TREE="hifive-unmatched-a00"
 CONFIG_SPL_MMC=y
 CONFIG_SPL=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
 CONFIG_AHCI=y
 CONFIG_TARGET_SIFIVE_UNMATCHED=y
@@ -23,17 +24,22 @@ CONFIG_DISPLAY_BOARDINFO=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_ID_EEPROM=y
 CONFIG_SPL_SEPARATE_BSS=y
+CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_DM_RESET=y
+CONFIG_SPL_SPI_LOAD=y
 CONFIG_CMD_EEPROM=y
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_PWM=y
 CONFIG_CMD_GPT_RENAME=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_USB=y
+CONFIG_USE_ENV_SPI_BUS=y
+CONFIG_ENV_SPI_BUS=1
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SCSI_AHCI=y
 CONFIG_AHCI_PCI=y
 CONFIG_SPL_CLK=y
+CONFIG_SPI_FLASH_ISSI=y
 CONFIG_SYS_I2C_EEPROM_ADDR=0x54
 CONFIG_E1000=y
 CONFIG_NVME=y
index 6b024f07f6db3dbbf070a1ead02f8d37dd30076c..b52a1f690cc669b4244d8fb9cca89cdc1f7b0237 100644 (file)
@@ -534,3 +534,34 @@ Sample boot log from HiFive Unmatched board
        OpenEmbedded nodistro.0 unmatched ttySIF0
 
        unmatched login:
+
+
+Booting from SPI
+----------------
+
+Use Building steps from "Booting from uSD using U-Boot SPL" section.
+
+Partition the SPI in Linux via mtdblock.  The partition types here are
+"HiFive Unleashed FSBL", "HiFive Unleashed BBL", and "U-Boot environment"
+for partitions one through three respectively.
+
+.. code-block:: none
+
+       sgdisk --clear -a 1 \
+           --new=1:40:2087     --change-name=1:spl   --typecode=1:5B193300-FC78-40CD-8002-E86C45580B47 \
+           --new=2:2088:10279  --change-name=2:uboot --typecode=2:2E54B353-1271-4842-806F-E436D6AF6985 \
+           --new=3:10280:10535 --change-name=3:env   --typecode=3:3DE21764-95BD-54BD-A5C3-4ABE786F38A8 \
+           /dev/mtdblock0
+
+Write U-boot SPL and U-boot to their partitions.
+
+.. code-block:: none
+
+       dd if=u-boot-spl.bin of=/dev/mtdblock0 bs=4096 seek=5 conv=sync
+       dd if=u-boot.itb  of=/dev/mtdblock0 bs=4096 seek=261 conv=sync
+
+Power off the board.
+
+Change DIP switches MSEL[3:0] to 0110.
+
+Power up the board.