mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
Convert all messages in sb600spi.c to the new message infrastructure
Corresponding to flashrom svn r857. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Sean Nelson <audiohacked@gmail.com>
This commit is contained in:
parent
08fa2f39f3
commit
643415bfdb
49
sb600spi.c
49
sb600spi.c
@ -24,17 +24,6 @@
|
|||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
|
|
||||||
/* Change this to #define if you want lowlevel debugging of commands
|
|
||||||
* sent to the SB600/SB700 SPI controller.
|
|
||||||
*/
|
|
||||||
#undef COMM_DEBUG
|
|
||||||
|
|
||||||
#ifdef COMM_DEBUG
|
|
||||||
#define msg_comm_debug printf_debug
|
|
||||||
#else
|
|
||||||
#define msg_comm_debug(...) do {} while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This struct is unused, but helps visualize the SB600 SPI BAR layout.
|
/* This struct is unused, but helps visualize the SB600 SPI BAR layout.
|
||||||
*struct sb600_spi_controller {
|
*struct sb600_spi_controller {
|
||||||
* unsigned int spi_cntrl0; / * 00h * /
|
* unsigned int spi_cntrl0; / * 00h * /
|
||||||
@ -65,28 +54,28 @@ int sb600_spi_write_1(struct flashchip *flash, uint8_t *buf)
|
|||||||
|
|
||||||
spi_disable_blockprotect();
|
spi_disable_blockprotect();
|
||||||
/* Erase first */
|
/* Erase first */
|
||||||
printf("Erasing flash before programming... ");
|
msg_pinfo("Erasing flash before programming... ");
|
||||||
if (erase_flash(flash)) {
|
if (erase_flash(flash)) {
|
||||||
fprintf(stderr, "ERASE FAILED!\n");
|
msg_perr("ERASE FAILED!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
printf("done.\n");
|
msg_pinfo("done.\n");
|
||||||
|
|
||||||
printf("Programming flash");
|
msg_pinfo("Programming flash");
|
||||||
for (i = 0; i < total_size; i++, buf++) {
|
for (i = 0; i < total_size; i++, buf++) {
|
||||||
result = spi_nbyte_program(i, buf, 1);
|
result = spi_nbyte_program(i, buf, 1);
|
||||||
if (result) {
|
if (result) {
|
||||||
fprintf(stderr, "Write error!\n");
|
msg_perr("Write error!\n");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wait program complete. */
|
/* wait program complete. */
|
||||||
if (i % 0x8000 == 0)
|
if (i % 0x8000 == 0)
|
||||||
printf(".");
|
msg_pspew(".");
|
||||||
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
|
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
printf(" done.\n");
|
msg_pinfo(" done.\n");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +84,7 @@ static void reset_internal_fifo_pointer(void)
|
|||||||
mmio_writeb(mmio_readb(sb600_spibar + 2) | 0x10, sb600_spibar + 2);
|
mmio_writeb(mmio_readb(sb600_spibar + 2) | 0x10, sb600_spibar + 2);
|
||||||
|
|
||||||
while (mmio_readb(sb600_spibar + 0xD) & 0x7)
|
while (mmio_readb(sb600_spibar + 0xD) & 0x7)
|
||||||
printf("reset\n");
|
msg_pspew("reset\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void execute_command(void)
|
static void execute_command(void)
|
||||||
@ -116,17 +105,17 @@ int sb600_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
|||||||
|
|
||||||
writecnt--;
|
writecnt--;
|
||||||
|
|
||||||
msg_comm_debug("%s, cmd=%x, writecnt=%x, readcnt=%x\n",
|
msg_pspew("%s, cmd=%x, writecnt=%x, readcnt=%x\n",
|
||||||
__func__, cmd, writecnt, readcnt);
|
__func__, cmd, writecnt, readcnt);
|
||||||
|
|
||||||
if (readcnt > 8) {
|
if (readcnt > 8) {
|
||||||
printf("%s, SB600 SPI controller can not receive %d bytes, "
|
msg_pinfo("%s, SB600 SPI controller can not receive %d bytes, "
|
||||||
"it is limited to 8 bytes\n", __func__, readcnt);
|
"it is limited to 8 bytes\n", __func__, readcnt);
|
||||||
return SPI_INVALID_LENGTH;
|
return SPI_INVALID_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (writecnt > 8) {
|
if (writecnt > 8) {
|
||||||
printf("%s, SB600 SPI controller can not send %d bytes, "
|
msg_pinfo("%s, SB600 SPI controller can not send %d bytes, "
|
||||||
"it is limited to 8 bytes\n", __func__, writecnt);
|
"it is limited to 8 bytes\n", __func__, writecnt);
|
||||||
return SPI_INVALID_LENGTH;
|
return SPI_INVALID_LENGTH;
|
||||||
}
|
}
|
||||||
@ -146,10 +135,10 @@ int sb600_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
|||||||
|
|
||||||
/* Send the write byte to FIFO. */
|
/* Send the write byte to FIFO. */
|
||||||
for (count = 0; count < writecnt; count++, writearr++) {
|
for (count = 0; count < writecnt; count++, writearr++) {
|
||||||
msg_comm_debug(" [%x]", *writearr);
|
msg_pspew(" [%x]", *writearr);
|
||||||
mmio_writeb(*writearr, sb600_spibar + 0xC);
|
mmio_writeb(*writearr, sb600_spibar + 0xC);
|
||||||
}
|
}
|
||||||
msg_comm_debug("\n");
|
msg_pspew("\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We should send the data by sequence, which means we need to reset
|
* We should send the data by sequence, which means we need to reset
|
||||||
@ -175,16 +164,16 @@ int sb600_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
|||||||
/* Skip the bytes we sent. */
|
/* Skip the bytes we sent. */
|
||||||
for (count = 0; count < writecnt; count++) {
|
for (count = 0; count < writecnt; count++) {
|
||||||
cmd = mmio_readb(sb600_spibar + 0xC);
|
cmd = mmio_readb(sb600_spibar + 0xC);
|
||||||
msg_comm_debug("[ %2x]", cmd);
|
msg_pspew("[ %2x]", cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_comm_debug("The FIFO pointer after skipping is %d.\n",
|
msg_pspew("The FIFO pointer after skipping is %d.\n",
|
||||||
mmio_readb(sb600_spibar + 0xd) & 0x07);
|
mmio_readb(sb600_spibar + 0xd) & 0x07);
|
||||||
for (count = 0; count < readcnt; count++, readarr++) {
|
for (count = 0; count < readcnt; count++, readarr++) {
|
||||||
*readarr = mmio_readb(sb600_spibar + 0xC);
|
*readarr = mmio_readb(sb600_spibar + 0xC);
|
||||||
msg_comm_debug("[%02x]", *readarr);
|
msg_pspew("[%02x]", *readarr);
|
||||||
}
|
}
|
||||||
msg_comm_debug("\n");
|
msg_pspew("\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user