summaryrefslogtreecommitdiff
path: root/util/flashrom/spi.c
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2008-06-30 23:45:22 +0000
committerStefan Reinauer <stepan@openbios.org>2008-06-30 23:45:22 +0000
commitd9b7ae8becf903e1cb9d66a194f098fd9644b49a (patch)
tree8368f56baa81289f2630d3b12e0bd0a2f52a4c77 /util/flashrom/spi.c
parente16d43c041f0de4b9be0d78e632e968ad865b75b (diff)
downloadcoreboot-d9b7ae8becf903e1cb9d66a194f098fd9644b49a.tar.xz
First attempt to clean up SPI probing and create a common
construct: the flash bus. At some point the flash bus will be part of struct flashchip. Pardon me for pushing this in, but I think it is important to beware of further decay and it will improve things for other developers in the short run. Carl-Daniel, I will consider your suggestions in another patch. I want to keep things from getting too much for now. The patch includes Rudolf's VIA SPI changes though. Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3401 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/flashrom/spi.c')
-rw-r--r--util/flashrom/spi.c69
1 files changed, 47 insertions, 22 deletions
diff --git a/util/flashrom/spi.c b/util/flashrom/spi.c
index 7fdad82c49..d89bef6ea4 100644
--- a/util/flashrom/spi.c
+++ b/util/flashrom/spi.c
@@ -34,13 +34,16 @@ void spi_prettyprint_status_register(struct flashchip *flash);
int spi_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr)
{
- if (it8716f_flashport)
+ switch (flashbus) {
+ case BUS_TYPE_IT87XX_SPI:
return it8716f_spi_command(writecnt, readcnt, writearr, readarr);
- else if ((ich7_detected) || (viaspi_detected))
- return ich_spi_command(writecnt, readcnt, writearr, readarr);
- else if (ich9_detected)
- return ich_spi_command(writecnt, readcnt, writearr, readarr);
- printf_debug("%s called, but no SPI chipset detected\n", __FUNCTION__);
+ case BUS_TYPE_ICH7_SPI:
+ case BUS_TYPE_ICH9_SPI:
+ case BUS_TYPE_VIA_SPI:
+ return ich_spi_command(writecnt, readcnt, writearr, readarr);
+ default:
+ printf_debug("%s called, but no SPI chipset/strapping detected\n", __FUNCTION__);
+ }
return 1;
}
@@ -135,9 +138,16 @@ int probe_spi_rdid(struct flashchip *flash) {
int probe_spi_rdid4(struct flashchip *flash) {
/* only some SPI chipsets support 4 bytes commands */
- if (!((ich7_detected) || (ich9_detected) || (viaspi_detected)))
- return 0;
- return probe_spi_rdid_generic(flash, 4);
+ switch (flashbus) {
+ case BUS_TYPE_ICH7_SPI:
+ case BUS_TYPE_ICH9_SPI:
+ case BUS_TYPE_VIA_SPI:
+ return probe_spi_rdid_generic(flash, 4);
+ default:
+ printf_debug("4b ID not supported on this SPI controller\n");
+ }
+
+ return 0;
}
int probe_spi_res(struct flashchip *flash)
@@ -316,11 +326,17 @@ int spi_sector_erase(const struct flashchip *flash, unsigned long addr)
void spi_page_program(int block, uint8_t *buf, uint8_t *bios)
{
- if (it8716f_flashport) {
+ switch (flashbus) {
+ case BUS_TYPE_IT87XX_SPI:
it8716f_spi_page_program(block, buf, bios);
- return;
+ break;
+ case BUS_TYPE_ICH7_SPI:
+ case BUS_TYPE_ICH9_SPI:
+ printf_debug("%s called, but not implemented for ICH\n", __FUNCTION__);
+ break;
+ default:
+ printf_debug("%s called, but no SPI chipset/strapping detected\n", __FUNCTION__);
}
- printf_debug("%s called, but no SPI chipset detected\n", __FUNCTION__);
}
/*
@@ -375,25 +391,34 @@ void spi_nbyte_read(int address, uint8_t *bytes, int len)
int spi_chip_read(struct flashchip *flash, uint8_t *buf)
{
- if (it8716f_flashport)
+
+ switch (flashbus) {
+ case BUS_TYPE_IT87XX_SPI:
return it8716f_spi_chip_read(flash, buf);
- else if ((ich7_detected) || (viaspi_detected))
- return ich_spi_read(flash, buf);
- else if (ich9_detected)
+ case BUS_TYPE_ICH7_SPI:
+ case BUS_TYPE_ICH9_SPI:
+ case BUS_TYPE_VIA_SPI:
return ich_spi_read(flash, buf);
- printf_debug("%s called, but no SPI chipset detected\n", __FUNCTION__);
+ default:
+ printf_debug("%s called, but no SPI chipset/strapping detected\n", __FUNCTION__);
+ }
+
return 1;
}
int spi_chip_write(struct flashchip *flash, uint8_t *buf)
{
- if (it8716f_flashport)
+ switch (flashbus) {
+ case BUS_TYPE_IT87XX_SPI:
return it8716f_spi_chip_write(flash, buf);
- else if ((ich7_detected) || (viaspi_detected))
+ case BUS_TYPE_ICH7_SPI:
+ case BUS_TYPE_ICH9_SPI:
+ case BUS_TYPE_VIA_SPI:
return ich_spi_write(flash, buf);
- else if (ich9_detected)
- return ich_spi_write(flash, buf);
- printf_debug("%s called, but no SPI chipset detected\n", __FUNCTION__);
+ default:
+ printf_debug("%s called, but no SPI chipset/strapping detected\n", __FUNCTION__);
+ }
+
return 1;
}