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
This commit is contained in:
committed by
Stefan Reinauer
parent
e16d43c041
commit
d9b7ae8bec
@ -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))
|
||||
case BUS_TYPE_ICH7_SPI:
|
||||
case BUS_TYPE_ICH9_SPI:
|
||||
case BUS_TYPE_VIA_SPI:
|
||||
return ich_spi_read(flash, buf);
|
||||
else if (ich9_detected)
|
||||
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user