mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 15:12:36 +02:00
spi25: Remove now obsolete four_bytes_addr_funcs
path
Change-Id: Idb7c576cb159630da2268813388b497cb5f46b43 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/22386 Reviewed-by: David Hendricks <david.hendricks@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
a1672f8293
commit
7a07722256
9
flash.h
9
flash.h
@ -169,14 +169,6 @@ struct flashchip {
|
||||
unsigned int page_size;
|
||||
int feature_bits;
|
||||
|
||||
/* set of function pointers to use in 4-bytes addressing mode */
|
||||
struct four_bytes_addr_funcs_set {
|
||||
int (*set_4ba) (struct flashctx *flash);
|
||||
int (*read_nbyte) (struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len);
|
||||
int (*program_byte) (struct flashctx *flash, unsigned int addr, const uint8_t databyte);
|
||||
int (*program_nbyte) (struct flashctx *flash, unsigned int addr, const uint8_t *bytes, unsigned int len);
|
||||
} four_bytes_addr_funcs;
|
||||
|
||||
/* Indicate how well flashrom supports different operations of this flash chip. */
|
||||
struct tested {
|
||||
enum test_state probe;
|
||||
@ -213,6 +205,7 @@ struct flashchip {
|
||||
int (*unlock) (struct flashctx *flash);
|
||||
int (*write) (struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
|
||||
int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||
int (*set_4ba) (struct flashctx *flash);
|
||||
struct voltage {
|
||||
uint16_t min;
|
||||
uint16_t max;
|
||||
|
54
flashchips.c
54
flashchips.c
@ -8135,13 +8135,6 @@ const struct flashchip flashchips[] = {
|
||||
.page_size = 256,
|
||||
/* OTP: 512B total; enter 0xB1, exit 0xC1 */
|
||||
.feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_SUPPORT,
|
||||
.four_bytes_addr_funcs =
|
||||
{
|
||||
.set_4ba = spi_enter_4ba_b7, /* enter 4-bytes addressing mode by CMD B7 */
|
||||
.read_nbyte = spi_nbyte_read_4ba, /* read from 4-bytes addressing mode */
|
||||
.program_byte = spi_byte_program_4ba, /* write from 4-bytes addressing mode */
|
||||
.program_nbyte = spi_nbyte_program_4ba /* write from 4-bytes addressing mode */
|
||||
},
|
||||
.tested = TEST_OK_PREW,
|
||||
.probe = probe_spi_rdid,
|
||||
.probe_timing = TIMING_ZERO,
|
||||
@ -8149,13 +8142,13 @@ const struct flashchip flashchips[] = {
|
||||
{
|
||||
{
|
||||
.eraseblocks = { {4 * 1024, 8192} },
|
||||
.block_erase = spi_block_erase_20_4ba,
|
||||
.block_erase = spi_block_erase_20,
|
||||
}, {
|
||||
.eraseblocks = { {32 * 1024, 1024} },
|
||||
.block_erase = spi_block_erase_52_4ba,
|
||||
.block_erase = spi_block_erase_52,
|
||||
}, {
|
||||
.eraseblocks = { {64 * 1024, 512} },
|
||||
.block_erase = spi_block_erase_d8_4ba,
|
||||
.block_erase = spi_block_erase_d8,
|
||||
}, {
|
||||
.eraseblocks = { {32 * 1024 * 1024, 1} },
|
||||
.block_erase = spi_block_erase_60,
|
||||
@ -8169,6 +8162,7 @@ const struct flashchip flashchips[] = {
|
||||
.unlock = spi_disable_blockprotect_bp3_srwd,
|
||||
.write = spi_chip_write_256,
|
||||
.read = spi_chip_read, /* Fast read (0x0B) supported */
|
||||
.set_4ba = spi_enter_4ba_b7,
|
||||
.voltage = {2700, 3600},
|
||||
},
|
||||
|
||||
@ -8182,13 +8176,6 @@ const struct flashchip flashchips[] = {
|
||||
.page_size = 256,
|
||||
/* OTP: 512B total; enter 0xB1, exit 0xC1 */
|
||||
.feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_SUPPORT,
|
||||
.four_bytes_addr_funcs =
|
||||
{
|
||||
.set_4ba = spi_enter_4ba_b7, /* enter 4-bytes addressing mode by CMD B7 */
|
||||
.read_nbyte = spi_nbyte_read_4ba, /* read from 4-bytes addressing mode */
|
||||
.program_byte = spi_byte_program_4ba, /* write from 4-bytes addressing mode */
|
||||
.program_nbyte = spi_nbyte_program_4ba /* write from 4-bytes addressing mode */
|
||||
},
|
||||
.tested = TEST_OK_PREW,
|
||||
.probe = probe_spi_rdid,
|
||||
.probe_timing = TIMING_ZERO,
|
||||
@ -8196,13 +8183,13 @@ const struct flashchip flashchips[] = {
|
||||
{
|
||||
{
|
||||
.eraseblocks = { {4 * 1024, 16384} },
|
||||
.block_erase = spi_block_erase_20_4ba,
|
||||
.block_erase = spi_block_erase_20,
|
||||
}, {
|
||||
.eraseblocks = { {32 * 1024, 2048} },
|
||||
.block_erase = spi_block_erase_52_4ba,
|
||||
.block_erase = spi_block_erase_52,
|
||||
}, {
|
||||
.eraseblocks = { {64 * 1024, 1024} },
|
||||
.block_erase = spi_block_erase_d8_4ba,
|
||||
.block_erase = spi_block_erase_d8,
|
||||
}, {
|
||||
.eraseblocks = { {64 * 1024 * 1024, 1} },
|
||||
.block_erase = spi_block_erase_60,
|
||||
@ -8216,6 +8203,7 @@ const struct flashchip flashchips[] = {
|
||||
.unlock = spi_disable_blockprotect_bp3_srwd,
|
||||
.write = spi_chip_write_256,
|
||||
.read = spi_chip_read, /* Fast read (0x0B) supported */
|
||||
.set_4ba = spi_enter_4ba_b7,
|
||||
.voltage = {2700, 3600},
|
||||
},
|
||||
|
||||
@ -9929,12 +9917,6 @@ const struct flashchip flashchips[] = {
|
||||
/* supports SFDP */
|
||||
/* OTP: 64B total; read 0x4B, write 0x42 */
|
||||
.feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_SUPPORT | FEATURE_4BA_READ | FEATURE_4BA_WRITE,
|
||||
.four_bytes_addr_funcs =
|
||||
{
|
||||
.read_nbyte = spi_nbyte_read_4ba_direct,
|
||||
.program_byte = spi_byte_program_4ba_direct,
|
||||
.program_nbyte = spi_nbyte_program_4ba_direct
|
||||
},
|
||||
.tested = TEST_OK_PREW,
|
||||
.probe = probe_spi_rdid,
|
||||
.probe_timing = TIMING_ZERO,
|
||||
@ -9968,12 +9950,6 @@ const struct flashchip flashchips[] = {
|
||||
/* supports SFDP */
|
||||
/* OTP: 64B total; read 0x4B, write 0x42 */
|
||||
.feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_SUPPORT | FEATURE_4BA_READ | FEATURE_4BA_WRITE,
|
||||
.four_bytes_addr_funcs =
|
||||
{
|
||||
.read_nbyte = spi_nbyte_read_4ba_direct,
|
||||
.program_byte = spi_byte_program_4ba_direct,
|
||||
.program_nbyte = spi_nbyte_program_4ba_direct
|
||||
},
|
||||
.tested = TEST_OK_PREW,
|
||||
.probe = probe_spi_rdid,
|
||||
.probe_timing = TIMING_ZERO,
|
||||
@ -14852,13 +14828,6 @@ const struct flashchip flashchips[] = {
|
||||
/* OTP: 1024B total, 256B reserved; read 0x48; write 0x42, erase 0x44, read ID 0x4B */
|
||||
/* FOUR_BYTE_ADDR: supports 4-bytes addressing mode */
|
||||
.feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_SUPPORT | FEATURE_4BA_READ,
|
||||
.four_bytes_addr_funcs =
|
||||
{
|
||||
.set_4ba = spi_enter_4ba_b7_we, /* enter 4-bytes addressing mode by CMD B7 + WREN */
|
||||
.read_nbyte = spi_nbyte_read_4ba_direct, /* read directly from any mode, no need to enter 4ba */
|
||||
.program_byte = spi_byte_program_4ba, /* write from 4-bytes addressing mode */
|
||||
.program_nbyte = spi_nbyte_program_4ba /* write from 4-bytes addressing mode */
|
||||
},
|
||||
.tested = TEST_OK_PREW,
|
||||
.probe = probe_spi_rdid,
|
||||
.probe_timing = TIMING_ZERO,
|
||||
@ -14866,13 +14835,13 @@ const struct flashchip flashchips[] = {
|
||||
{
|
||||
{
|
||||
.eraseblocks = { {4 * 1024, 8192} },
|
||||
.block_erase = spi_block_erase_20_4ba, /* erases 4k from 4-bytes addressing mode */
|
||||
.block_erase = spi_block_erase_20,
|
||||
}, {
|
||||
.eraseblocks = { {32 * 1024, 1024} },
|
||||
.block_erase = spi_block_erase_52_4ba, /* erases 32k from 4-bytes addressing mode */
|
||||
.block_erase = spi_block_erase_52,
|
||||
}, {
|
||||
.eraseblocks = { {64 * 1024, 512} },
|
||||
.block_erase = spi_block_erase_d8_4ba, /* erases 64k from 4-bytes addressing mode */
|
||||
.block_erase = spi_block_erase_d8,
|
||||
}, {
|
||||
.eraseblocks = { {32 * 1024 * 1024, 1} },
|
||||
.block_erase = spi_block_erase_60,
|
||||
@ -14885,6 +14854,7 @@ const struct flashchip flashchips[] = {
|
||||
.unlock = spi_disable_blockprotect,
|
||||
.write = spi_chip_write_256,
|
||||
.read = spi_chip_read,
|
||||
.set_4ba = spi_enter_4ba_b7_we,
|
||||
.voltage = {2700, 3600},
|
||||
},
|
||||
|
||||
|
@ -2219,9 +2219,8 @@ int prepare_flash_access(struct flashctx *const flash,
|
||||
flash->in_4ba_mode = false;
|
||||
|
||||
/* Enable/disable 4-byte addressing mode if flash chip supports it */
|
||||
if ((flash->chip->feature_bits & FEATURE_4BA_SUPPORT) &&
|
||||
flash->chip->four_bytes_addr_funcs.set_4ba) {
|
||||
if (flash->chip->four_bytes_addr_funcs.set_4ba(flash)) {
|
||||
if ((flash->chip->feature_bits & FEATURE_4BA_SUPPORT) && flash->chip->set_4ba) {
|
||||
if (flash->chip->set_4ba(flash)) {
|
||||
msg_cerr("Enabling/disabling 4-byte addressing mode failed!\n");
|
||||
return 1;
|
||||
}
|
||||
|
30
spi25.c
30
spi25.c
@ -652,10 +652,7 @@ int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start,
|
||||
lenhere = min(start + len, (i + 1) * area_size) - starthere;
|
||||
for (j = 0; j < lenhere; j += chunksize) {
|
||||
toread = min(chunksize, lenhere - j);
|
||||
rc = (flash->chip->feature_bits & FEATURE_4BA_SUPPORT) == 0
|
||||
? spi_nbyte_read(flash, starthere + j, buf + starthere - start + j, toread)
|
||||
: flash->chip->four_bytes_addr_funcs.read_nbyte(flash, starthere + j,
|
||||
buf + starthere - start + j, toread);
|
||||
rc = spi_nbyte_read(flash, starthere + j, buf + starthere - start + j, toread);
|
||||
if (rc)
|
||||
break;
|
||||
}
|
||||
@ -674,7 +671,6 @@ int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start,
|
||||
int spi_write_chunked(struct flashctx *flash, const uint8_t *buf, unsigned int start,
|
||||
unsigned int len, unsigned int chunksize)
|
||||
{
|
||||
int rc = 0;
|
||||
unsigned int i, j, starthere, lenhere, towrite;
|
||||
/* FIXME: page_size is the wrong variable. We need max_writechunk_size
|
||||
* in struct flashctx to do this properly. All chips using
|
||||
@ -699,21 +695,16 @@ int spi_write_chunked(struct flashctx *flash, const uint8_t *buf, unsigned int s
|
||||
/* Length of bytes in the range in this page. */
|
||||
lenhere = min(start + len, (i + 1) * page_size) - starthere;
|
||||
for (j = 0; j < lenhere; j += chunksize) {
|
||||
int rc;
|
||||
|
||||
towrite = min(chunksize, lenhere - j);
|
||||
rc = (flash->chip->feature_bits & FEATURE_4BA_SUPPORT) == 0
|
||||
? spi_nbyte_program(flash, starthere + j, buf + starthere - start + j, towrite)
|
||||
: flash->chip->four_bytes_addr_funcs.program_nbyte(flash, starthere + j,
|
||||
buf + starthere - start + j, towrite);
|
||||
rc = spi_nbyte_program(flash, starthere + j, buf + starthere - start + j, towrite);
|
||||
if (rc)
|
||||
break;
|
||||
while (spi_read_status_register(flash) & SPI_SR_WIP)
|
||||
programmer_delay(10);
|
||||
return rc;
|
||||
}
|
||||
if (rc)
|
||||
break;
|
||||
}
|
||||
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -726,18 +717,11 @@ int spi_write_chunked(struct flashctx *flash, const uint8_t *buf, unsigned int s
|
||||
int spi_chip_write_1(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len)
|
||||
{
|
||||
unsigned int i;
|
||||
int result = 0;
|
||||
|
||||
for (i = start; i < start + len; i++) {
|
||||
result = (flash->chip->feature_bits & FEATURE_4BA_SUPPORT) == 0
|
||||
? spi_nbyte_program(flash, i, buf + i - start, 1)
|
||||
: flash->chip->four_bytes_addr_funcs.program_byte(flash, i, buf[i - start]);
|
||||
if (result)
|
||||
if (spi_nbyte_program(flash, i, buf + i - start, 1))
|
||||
return 1;
|
||||
while (spi_read_status_register(flash) & SPI_SR_WIP)
|
||||
programmer_delay(10);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user