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>
This commit is contained in:
parent
339ae162b6
commit
87471366e4
1 changed files with 7 additions and 8 deletions
|
@ -293,12 +293,10 @@ static int winbond_get_write_protection(const struct spi_flash *flash,
|
||||||
const size_t granularity = (1 << params->protection_granularity_shift);
|
const size_t granularity = (1 << params->protection_granularity_shift);
|
||||||
|
|
||||||
if (params->bp_bits == 3) {
|
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, ®1_bp3.u,
|
ret = spi_flash_cmd(&flash->spi, flash->status_cmd, ®1_bp3.u,
|
||||||
sizeof(reg1_bp3.u));
|
sizeof(reg1_bp3.u));
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (reg1_bp3.sec) {
|
if (reg1_bp3.sec) {
|
||||||
// FIXME: not supported
|
// FIXME: not supported
|
||||||
|
@ -308,12 +306,10 @@ static int winbond_get_write_protection(const struct spi_flash *flash,
|
||||||
bp = reg1_bp3.bp;
|
bp = reg1_bp3.bp;
|
||||||
tb = reg1_bp3.tb;
|
tb = reg1_bp3.tb;
|
||||||
} else if (params->bp_bits == 4) {
|
} 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, ®1_bp4.u,
|
ret = spi_flash_cmd(&flash->spi, flash->status_cmd, ®1_bp4.u,
|
||||||
sizeof(reg1_bp4.u));
|
sizeof(reg1_bp4.u));
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
bp = reg1_bp4.bp;
|
bp = reg1_bp4.bp;
|
||||||
tb = reg1_bp4.tb;
|
tb = reg1_bp4.tb;
|
||||||
|
@ -321,6 +317,8 @@ static int winbond_get_write_protection(const struct spi_flash *flash,
|
||||||
// FIXME: not supported
|
// FIXME: not supported
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
ret = spi_flash_cmd(&flash->spi, CMD_W25_RDSR2, ®2.u,
|
ret = spi_flash_cmd(&flash->spi, CMD_W25_RDSR2, ®2.u,
|
||||||
sizeof(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,
|
winbond_bpbits_to_region(granularity, bp, tb, reg2.cmp, flash->size,
|
||||||
&wp_region);
|
&wp_region);
|
||||||
|
|
||||||
if (!reg2.srp1 || !wp_region.size) {
|
if (!region_sz(&wp_region)) {
|
||||||
printk(BIOS_DEBUG, "WINBOND: flash isn't protected\n");
|
printk(BIOS_DEBUG, "WINBOND: flash isn't protected\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
printk(BIOS_DEBUG, "WINBOND: flash protected range 0x%08zx-0x%08zx\n",
|
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);
|
return region_is_subregion(&wp_region, region);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue