1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

tree/: Case write_granularity enum values

Change-Id: Ic8c655225abe477c1b618dc685b743e691c16ebd
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/74165
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Edward O'Callaghan 2023-04-01 12:32:52 +11:00 committed by Edward O'Callaghan
parent 67b5526d5c
commit 21901c11e7
5 changed files with 41 additions and 41 deletions

View File

@ -200,12 +200,12 @@ int probe_spi_at45db(struct flashctx *flash)
} }
switch (chip->page_size) { switch (chip->page_size) {
case 256: chip->gran = write_gran_256bytes; break; case 256: chip->gran = WRITE_GRAN_256BYTES; break;
case 264: chip->gran = write_gran_264bytes; break; case 264: chip->gran = WRITE_GRAN_264BYTES; break;
case 512: chip->gran = write_gran_512bytes; break; case 512: chip->gran = WRITE_GRAN_512BYTES; break;
case 528: chip->gran = write_gran_528bytes; break; case 528: chip->gran = WRITE_GRAN_528BYTES; break;
case 1024: chip->gran = write_gran_1024bytes; break; case 1024: chip->gran = WRITE_GRAN_1024BYTES; break;
case 1056: chip->gran = write_gran_1056bytes; break; case 1056: chip->gran = WRITE_GRAN_1056BYTES; break;
default: default:
msg_cerr("%s: unknown page size %d.\n", __func__, chip->page_size); msg_cerr("%s: unknown page size %d.\n", __func__, chip->page_size);
return 0; return 0;

View File

@ -2762,7 +2762,7 @@ const struct flashchip flashchips[] = {
.write = SPI_WRITE_AT45DB, .write = SPI_WRITE_AT45DB,
.read = SPI_READ_AT45DB, .read = SPI_READ_AT45DB,
.voltage = {2700, 3600}, .voltage = {2700, 3600},
.gran = write_gran_1056bytes, .gran = WRITE_GRAN_1056BYTES,
}, },
{ {
@ -3015,7 +3015,7 @@ const struct flashchip flashchips[] = {
.write = SPI_WRITE_AT45DB, .write = SPI_WRITE_AT45DB,
.read = SPI_READ_AT45DB_E8, /* 3 address and 4 dummy bytes */ .read = SPI_READ_AT45DB_E8, /* 3 address and 4 dummy bytes */
.voltage = {2700, 3600}, .voltage = {2700, 3600},
.gran = write_gran_528bytes, .gran = WRITE_GRAN_528BYTES,
}, },
{ {
@ -3638,7 +3638,7 @@ const struct flashchip flashchips[] = {
.write = EDI_CHIP_WRITE, .write = EDI_CHIP_WRITE,
.read = EDI_CHIP_READ, .read = EDI_CHIP_READ,
.voltage = {2700, 3600}, .voltage = {2700, 3600},
.gran = write_gran_128bytes, .gran = WRITE_GRAN_128BYTES,
}, },
{ {

View File

@ -719,42 +719,42 @@ int need_erase(const uint8_t *have, const uint8_t *want, unsigned int len,
unsigned int i; unsigned int i;
switch (gran) { switch (gran) {
case write_gran_1bit: case WRITE_GRAN_1BIT:
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
if ((have[i] & want[i]) != want[i]) { if ((have[i] & want[i]) != want[i]) {
result = 1; result = 1;
break; break;
} }
break; break;
case write_gran_1byte: case WRITE_GRAN_1BYTE:
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
if ((have[i] != want[i]) && (have[i] != erased_value)) { if ((have[i] != want[i]) && (have[i] != erased_value)) {
result = 1; result = 1;
break; break;
} }
break; break;
case write_gran_128bytes: case WRITE_GRAN_128BYTES:
result = need_erase_gran_bytes(have, want, len, 128, erased_value); result = need_erase_gran_bytes(have, want, len, 128, erased_value);
break; break;
case write_gran_256bytes: case WRITE_GRAN_256BYTES:
result = need_erase_gran_bytes(have, want, len, 256, erased_value); result = need_erase_gran_bytes(have, want, len, 256, erased_value);
break; break;
case write_gran_264bytes: case WRITE_GRAN_264BYTES:
result = need_erase_gran_bytes(have, want, len, 264, erased_value); result = need_erase_gran_bytes(have, want, len, 264, erased_value);
break; break;
case write_gran_512bytes: case WRITE_GRAN_512BYTES:
result = need_erase_gran_bytes(have, want, len, 512, erased_value); result = need_erase_gran_bytes(have, want, len, 512, erased_value);
break; break;
case write_gran_528bytes: case WRITE_GRAN_528BYTES:
result = need_erase_gran_bytes(have, want, len, 528, erased_value); result = need_erase_gran_bytes(have, want, len, 528, erased_value);
break; break;
case write_gran_1024bytes: case WRITE_GRAN_1024BYTES:
result = need_erase_gran_bytes(have, want, len, 1024, erased_value); result = need_erase_gran_bytes(have, want, len, 1024, erased_value);
break; break;
case write_gran_1056bytes: case WRITE_GRAN_1056BYTES:
result = need_erase_gran_bytes(have, want, len, 1056, erased_value); result = need_erase_gran_bytes(have, want, len, 1056, erased_value);
break; break;
case write_gran_1byte_implicit_erase: case WRITE_GRAN_1BYTE_IMPLICIT_ERASE:
/* Do not erase, handle content changes from anything->0xff by writing 0xff. */ /* Do not erase, handle content changes from anything->0xff by writing 0xff. */
result = 0; result = 0;
break; break;
@ -797,30 +797,30 @@ unsigned int get_next_write(const uint8_t *have, const uint8_t *want, unsigned i
unsigned int i, limit, stride; unsigned int i, limit, stride;
switch (gran) { switch (gran) {
case write_gran_1bit: case WRITE_GRAN_1BIT:
case write_gran_1byte: case WRITE_GRAN_1BYTE:
case write_gran_1byte_implicit_erase: case WRITE_GRAN_1BYTE_IMPLICIT_ERASE:
stride = 1; stride = 1;
break; break;
case write_gran_128bytes: case WRITE_GRAN_128BYTES:
stride = 128; stride = 128;
break; break;
case write_gran_256bytes: case WRITE_GRAN_256BYTES:
stride = 256; stride = 256;
break; break;
case write_gran_264bytes: case WRITE_GRAN_264BYTES:
stride = 264; stride = 264;
break; break;
case write_gran_512bytes: case WRITE_GRAN_512BYTES:
stride = 512; stride = 512;
break; break;
case write_gran_528bytes: case WRITE_GRAN_528BYTES:
stride = 528; stride = 528;
break; break;
case write_gran_1024bytes: case WRITE_GRAN_1024BYTES:
stride = 1024; stride = 1024;
break; break;
case write_gran_1056bytes: case WRITE_GRAN_1056BYTES:
stride = 1056; stride = 1056;
break; break;
default: default:

View File

@ -83,17 +83,17 @@ enum chipbustype {
*/ */
enum write_granularity { enum write_granularity {
/* We assume 256 byte granularity by default. */ /* We assume 256 byte granularity by default. */
write_gran_256bytes = 0,/* If less than 256 bytes are written, the unwritten bytes are undefined. */ WRITE_GRAN_256BYTES = 0,/* If less than 256 bytes are written, the unwritten bytes are undefined. */
write_gran_1bit, /* Each bit can be cleared individually. */ WRITE_GRAN_1BIT, /* Each bit can be cleared individually. */
write_gran_1byte, /* A byte can be written once. Further writes to an already written byte cause WRITE_GRAN_1BYTE, /* A byte can be written once. Further writes to an already written byte cause
* its contents to be either undefined or to stay unchanged. */ * its contents to be either undefined or to stay unchanged. */
write_gran_128bytes, /* If less than 128 bytes are written, the unwritten bytes are undefined. */ WRITE_GRAN_128BYTES, /* If less than 128 bytes are written, the unwritten bytes are undefined. */
write_gran_264bytes, /* If less than 264 bytes are written, the unwritten bytes are undefined. */ WRITE_GRAN_264BYTES, /* If less than 264 bytes are written, the unwritten bytes are undefined. */
write_gran_512bytes, /* If less than 512 bytes are written, the unwritten bytes are undefined. */ WRITE_GRAN_512BYTES, /* If less than 512 bytes are written, the unwritten bytes are undefined. */
write_gran_528bytes, /* If less than 528 bytes are written, the unwritten bytes are undefined. */ WRITE_GRAN_528BYTES, /* If less than 528 bytes are written, the unwritten bytes are undefined. */
write_gran_1024bytes, /* If less than 1024 bytes are written, the unwritten bytes are undefined. */ WRITE_GRAN_1024BYTES, /* If less than 1024 bytes are written, the unwritten bytes are undefined. */
write_gran_1056bytes, /* If less than 1056 bytes are written, the unwritten bytes are undefined. */ WRITE_GRAN_1056BYTES, /* If less than 1056 bytes are written, the unwritten bytes are undefined. */
write_gran_1byte_implicit_erase, /* EEPROMs and other chips with implicit erase and 1-byte writes. */ WRITE_GRAN_1BYTE_IMPLICIT_ERASE, /* EEPROMs and other chips with implicit erase and 1-byte writes. */
}; };
/* /*

View File

@ -116,7 +116,7 @@ static int nicintel_ee_probe_i210(struct flashctx *flash)
flash->chip->total_size = 4; flash->chip->total_size = 4;
flash->chip->page_size = flash->chip->total_size * 1024; flash->chip->page_size = flash->chip->total_size * 1024;
flash->chip->tested = TEST_OK_PREWB; flash->chip->tested = TEST_OK_PREWB;
flash->chip->gran = write_gran_1byte_implicit_erase; flash->chip->gran = WRITE_GRAN_1BYTE_IMPLICIT_ERASE;
flash->chip->block_erasers->eraseblocks[0].size = flash->chip->page_size; flash->chip->block_erasers->eraseblocks[0].size = flash->chip->page_size;
flash->chip->block_erasers->eraseblocks[0].count = 1; flash->chip->block_erasers->eraseblocks[0].count = 1;
@ -147,7 +147,7 @@ static int nicintel_ee_probe_82580(struct flashctx *flash)
flash->chip->page_size = EE_PAGE_MASK + 1; flash->chip->page_size = EE_PAGE_MASK + 1;
flash->chip->tested = TEST_OK_PREWB; flash->chip->tested = TEST_OK_PREWB;
flash->chip->gran = write_gran_1byte_implicit_erase; flash->chip->gran = WRITE_GRAN_1BYTE_IMPLICIT_ERASE;
flash->chip->block_erasers->eraseblocks[0].size = (EE_PAGE_MASK + 1); flash->chip->block_erasers->eraseblocks[0].size = (EE_PAGE_MASK + 1);
flash->chip->block_erasers->eraseblocks[0].count = (flash->chip->total_size * 1024) / (EE_PAGE_MASK + 1); flash->chip->block_erasers->eraseblocks[0].count = (flash->chip->total_size * 1024) / (EE_PAGE_MASK + 1);