aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/spi/winbond.c
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2019-06-06 17:03:44 -0700
committerJulius Werner <jwerner@chromium.org>2019-06-10 18:02:33 +0000
commit99e45ceb35ff9a4c48e516e6d005ebfae54b6591 (patch)
tree8f42f859485f2dd4a0c101e613fd607b3000f219 /src/drivers/spi/winbond.c
parent1b7f99bd6b52e3fd03653dca80af3faf6e7e8852 (diff)
spi_flash: Add Dual SPI support
This patch adds support to read SPI flash in Dual SPI mode, where both MISO and MOSI lines are used for output mode (specifically Fast Read Dual Output (0x3b) where the command is still sent normally, not Fast Read Dual I/O (0xbb) whose additional benefit should be extremely marginal for our use cases but which would be more complicated to implement). This feature needs to be supported by both the flash chip and the controller, so we add a new dual_spi flag (and a new flags field to hold it) to the spi_flash structure and a new optional xfer_dual() function pointer to the spi_ctrlr structure. When both are provided, Dual SPI mode is used automatically, otherwise things work as before. This patch only adds the dual_spi flag exemplary to all Winbond and Gigadevice chips, other vendors need to be added as needed. Change-Id: Ic6808224c99af32b6c5c43054135c8f4c03c1feb Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/33283 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/drivers/spi/winbond.c')
-rw-r--r--src/drivers/spi/winbond.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c
index d0ef3cd6e0..9e9bb00464 100644
--- a/src/drivers/spi/winbond.c
+++ b/src/drivers/spi/winbond.c
@@ -26,7 +26,9 @@
struct winbond_spi_flash_params {
uint16_t id;
- uint8_t l2_page_size_shift;
+ uint8_t dual_spi : 1;
+ uint8_t _reserved_for_flags : 3;
+ uint8_t l2_page_size_shift : 4;
uint8_t pages_per_sector_shift : 4;
uint8_t sectors_per_block_shift : 4;
uint8_t nr_blocks_shift;
@@ -123,6 +125,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 4,
.name = "W25X80",
+ .dual_spi = 1,
},
{
.id = 0x3015,
@@ -131,6 +134,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 5,
.name = "W25X16",
+ .dual_spi = 1,
},
{
.id = 0x3016,
@@ -139,6 +143,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 6,
.name = "W25X32",
+ .dual_spi = 1,
},
{
.id = 0x3017,
@@ -147,6 +152,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 7,
.name = "W25X64",
+ .dual_spi = 1,
},
{
.id = 0x4014,
@@ -155,6 +161,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 4,
.name = "W25Q80_V",
+ .dual_spi = 1,
},
{
.id = 0x4015,
@@ -163,6 +170,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 5,
.name = "W25Q16_V",
+ .dual_spi = 1,
.protection_granularity_shift = 16,
.bp_bits = 3,
},
@@ -173,6 +181,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 5,
.name = "W25Q16DW",
+ .dual_spi = 1,
.protection_granularity_shift = 16,
.bp_bits = 3,
},
@@ -183,6 +192,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 6,
.name = "W25Q32_V",
+ .dual_spi = 1,
.protection_granularity_shift = 16,
.bp_bits = 3,
},
@@ -193,6 +203,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 6,
.name = "W25Q32DW",
+ .dual_spi = 1,
.protection_granularity_shift = 16,
.bp_bits = 3,
},
@@ -203,6 +214,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 7,
.name = "W25Q64_V",
+ .dual_spi = 1,
.protection_granularity_shift = 17,
.bp_bits = 3,
},
@@ -213,6 +225,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 7,
.name = "W25Q64DW",
+ .dual_spi = 1,
.protection_granularity_shift = 17,
.bp_bits = 3,
},
@@ -223,6 +236,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 8,
.name = "W25Q128_V",
+ .dual_spi = 1,
.protection_granularity_shift = 18,
.bp_bits = 3,
},
@@ -233,6 +247,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 8,
.name = "W25Q128FW",
+ .dual_spi = 1,
.protection_granularity_shift = 18,
.bp_bits = 3,
},
@@ -243,6 +258,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 8,
.name = "W25Q128J",
+ .dual_spi = 1,
.protection_granularity_shift = 18,
.bp_bits = 3,
},
@@ -253,6 +269,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 9,
.name = "W25Q256_V",
+ .dual_spi = 1,
.protection_granularity_shift = 16,
.bp_bits = 4,
},
@@ -263,6 +280,7 @@ static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
.sectors_per_block_shift = 4,
.nr_blocks_shift = 9,
.name = "W25Q256J",
+ .dual_spi = 1,
.protection_granularity_shift = 16,
.bp_bits = 4,
},
@@ -681,6 +699,8 @@ int spi_flash_probe_winbond(const struct spi_slave *spi, u8 *idcode,
flash->erase_cmd = CMD_W25_SE;
flash->status_cmd = CMD_W25_RDSR;
+ flash->flags.dual_spi = params->dual_spi;
+
flash->ops = &spi_flash_ops;
flash->driver_private = params;