aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonald G Minnich <rminnich@gmail.com>2024-02-15 22:28:01 -0800
committerFelix Singer <service+coreboot-gerrit@felixsinger.de>2024-03-06 04:33:52 +0000
commitd31b1091e724b9d5934b7e8d3911abbe04b4afcd (patch)
tree7564434ff03584d93c01a9ad3bf022f2af6e02f3
parent4d9549b95fe15d3cdd2cf975dfffd4760602e23b (diff)
mb/sifive/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> Reviewed-on: https://review.coreboot.org/c/coreboot/+/81031 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Philipp Hug <philipp@hug.cx> Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de>
-rw-r--r--src/mainboard/sifive/hifive-unmatched/cbfs_spi.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/mainboard/sifive/hifive-unmatched/cbfs_spi.c b/src/mainboard/sifive/hifive-unmatched/cbfs_spi.c
index 787d8e7af3..f47da22626 100644
--- a/src/mainboard/sifive/hifive-unmatched/cbfs_spi.c
+++ b/src/mainboard/sifive/hifive-unmatched/cbfs_spi.c
@@ -116,15 +116,34 @@ void boot_device_init(void)
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 @@ void boot_device_init(void)
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;