ron minnich has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/81031?usp=email )
Change subject: SiFive Unmatched: add support for spi1 x4 mode ......................................................................
SiFive Unmatched: add support for spi1 x4 mode
Tested on an unmatched, both SPI1 x1 and x4 work now.
Change-Id: Ida7f195eb6e4fc85018ceb83cf317595127c4af5 Signed-off-by: Ronald G Minnich rminnich@gmail.com --- M src/mainboard/sifive/hifive-unleashed/media.c M src/mainboard/sifive/hifive-unmatched/cbfs_spi.c 2 files changed, 29 insertions(+), 14 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/31/81031/1
diff --git a/src/mainboard/sifive/hifive-unleashed/media.c b/src/mainboard/sifive/hifive-unleashed/media.c index a225dda..6a3878b 100644 --- a/src/mainboard/sifive/hifive-unleashed/media.c +++ b/src/mainboard/sifive/hifive-unleashed/media.c @@ -47,12 +47,13 @@
const struct region_device *boot_device_ro(void) { - uint32_t m = read32((uint32_t *)FU540_MSEL); - if (MSEL_SPI0x1(m) || MSEL_SPI0x4(m)) + uint32_t m = read32((uint32_t *)FU540_MSEL) & 0xf; + if (MSEL_SPI0x1(m) || MSEL_SPI0x4(m) || MSEL_SPI1x4(m)) return &spi_mdev.rdev; if (MSEL_SPI2SD(m)) return &sd_mdev.rdev; - die("Wrong configuration of MSEL\n"); + printk(BIOS_EMERG, "MSEL: %#02x", m); + die("Unsupported configuration of MSEL\n"); return NULL; }
diff --git a/src/mainboard/sifive/hifive-unmatched/cbfs_spi.c b/src/mainboard/sifive/hifive-unmatched/cbfs_spi.c index 787d8e7..f47da22 100644 --- a/src/mainboard/sifive/hifive-unmatched/cbfs_spi.c +++ b/src/mainboard/sifive/hifive-unmatched/cbfs_spi.c @@ -116,15 +116,34 @@ if (spi_flash_init_done == true) return;
- uint32_t m = read32((uint32_t *)FU740_MSEL); + uint32_t m = read32((uint32_t *)FU740_MSEL) & 0xf; + printk(BIOS_DEBUG, "%s MSEL %#x\n", __func__, m); + + // We have not yet found a way to reliably program the + // on-board SPI part (sifive neglected to put a diode on vcc ...) + // Once we work that out, we can test this code. + // It is left here as a hint of what needs to be done. // Pass the information of the flash read operation to the spi controller - //.pad_cnt = 6, - if (MSEL_SPI0x4(m) || MSEL_SPI1x4(m)) { + if (MSEL_SPI0x4(m)) { + die("SPI0x4 is not supported yet"); //config.ffmt_config.data_proto = FU740_SPI_PROTO_Q; //config.ffmt_config.cmd_code = 0x6B; // Quad output read //.cmd_code = 0xec, + //.pad_cnt = 6, } - if (MSEL_SPI1x1(m)) { + if (MSEL_SPI1x4(m)) { + printk(BIOS_DEBUG, "%s SPI1x4 1\n", __func__); + fu740_spi_configs[1].ffmt_config.data_proto = FU740_SPI_PROTO_Q; + fu740_spi_configs[1].ffmt_config.cmd_code = 0x6b; // quad + if (spi_flash_probe(1, 0, &spi_flash)) { + printk(BIOS_EMERG, "SPI1x4 failed to init SPI flash\n"); + return; + } + if (fu740_spi_setup(&spi_flash.spi) == -1) { + printk(BIOS_EMERG, "SPI1x4 failed to configure mmap for SPI flash\n"); + } + printk(BIOS_DEBUG, "%s SPI1x4 2\n", __func__); + } else if (MSEL_SPI1x1(m)) { printk(BIOS_DEBUG, "%s 1\n", __func__); fu740_spi_configs[1].ffmt_config.data_proto = FU740_SPI_PROTO_S; fu740_spi_configs[1].ffmt_config.cmd_code = 0x03; // Normal read @@ -133,17 +152,12 @@ printk(BIOS_EMERG, "failed to init SPI flash\n"); return; } - // initialize soc spi controller - //if (fu740_spi_setup(&spi1_flash.spi) == -1) { - // printk(BIOS_EMERG, "failed to configure mmap for SPI flash\n"); - //} - //hexdump((void*)0x10041000, 0x100); - //hexdump((void*)0x30000000, 0x100); printk(BIOS_DEBUG, "%s 2\n", __func__); } else if (MSEL_SPI2SD(m)) { spi_sdcard_init(&spi2_sdcard, 2, 0); } else { - die("Wrong configuration of MSEL\n"); + printk(BIOS_EMERG, "MSEL: %#02x: ", m); + die("unsupported configuration of MSEL\n"); }
spi_flash_init_done = true;