diff options
author | Stefan Reinauer <stepan@coresystems.de> | 2008-06-30 23:45:22 +0000 |
---|---|---|
committer | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2008-06-30 23:45:22 +0000 |
commit | 2cb94e183be9c69afcf426f70a9b4cb2bbd8bded (patch) | |
tree | 151967e33263eafe4b36b556765e565532349af0 /spi.c | |
parent | e3eb9c1d69fcd878b8f6c153dbc1e15fd8b3d08d (diff) | |
download | ast2050-flashrom-2cb94e183be9c69afcf426f70a9b4cb2bbd8bded.zip ast2050-flashrom-2cb94e183be9c69afcf426f70a9b4cb2bbd8bded.tar.gz |
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.
Corresponding to flashrom svn r285 and coreboot v2 svn r3401.
Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'spi.c')
-rw-r--r-- | spi.c | 69 |
1 files changed, 47 insertions, 22 deletions
@@ -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; } |