summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorPatrick Rudolph <patrick.rudolph@9elements.com>2018-09-25 14:26:33 +0200
committerPatrick Rudolph <siro@das-labor.org>2018-10-01 06:58:13 +0000
commit87471366e42106b136d6cd0fba008b8c7eb53f85 (patch)
tree446b1b19e93a0132affe890aaf34fa10839c456a /src/drivers
parent339ae162b6a666d558c49a6794966f5e339e76e7 (diff)
drivers/spi/winbond: Fix read protection bits
Don't care about SRPx and print correct protected range. Change-Id: I051f1459c585a7ed6a4878dc217d11df5ef00d74 Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/28731 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/spi/winbond.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c
index a0e3884e07..a6089b538d 100644
--- a/src/drivers/spi/winbond.c
+++ b/src/drivers/spi/winbond.c
@@ -293,12 +293,10 @@ static int winbond_get_write_protection(const struct spi_flash *flash,
const size_t granularity = (1 << params->protection_granularity_shift);
if (params->bp_bits == 3) {
- union status_reg1_bp3 reg1_bp3;
+ union status_reg1_bp3 reg1_bp3 = { .u = 0 };
ret = spi_flash_cmd(&flash->spi, flash->status_cmd, &reg1_bp3.u,
sizeof(reg1_bp3.u));
- if (ret)
- return ret;
if (reg1_bp3.sec) {
// FIXME: not supported
@@ -308,12 +306,10 @@ static int winbond_get_write_protection(const struct spi_flash *flash,
bp = reg1_bp3.bp;
tb = reg1_bp3.tb;
} else if (params->bp_bits == 4) {
- union status_reg1_bp4 reg1_bp4;
+ union status_reg1_bp4 reg1_bp4 = { .u = 0 };
ret = spi_flash_cmd(&flash->spi, flash->status_cmd, &reg1_bp4.u,
sizeof(reg1_bp4.u));
- if (ret)
- return ret;
bp = reg1_bp4.bp;
tb = reg1_bp4.tb;
@@ -321,6 +317,8 @@ static int winbond_get_write_protection(const struct spi_flash *flash,
// FIXME: not supported
return -1;
}
+ if (ret)
+ return ret;
ret = spi_flash_cmd(&flash->spi, CMD_W25_RDSR2, &reg2.u,
sizeof(reg2.u));
@@ -330,14 +328,15 @@ static int winbond_get_write_protection(const struct spi_flash *flash,
winbond_bpbits_to_region(granularity, bp, tb, reg2.cmp, flash->size,
&wp_region);
- if (!reg2.srp1 || !wp_region.size) {
+ if (!region_sz(&wp_region)) {
printk(BIOS_DEBUG, "WINBOND: flash isn't protected\n");
return 0;
}
printk(BIOS_DEBUG, "WINBOND: flash protected range 0x%08zx-0x%08zx\n",
- wp_region.offset, wp_region.size);
+ region_offset(&wp_region),
+ region_offset(&wp_region) + region_sz(&wp_region));
return region_is_subregion(&wp_region, region);
}