summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2007-10-16 21:09:06 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2007-10-16 21:09:06 +0000
commit3d94a0e00e4d3fdb5f799861d3b354d13a1fcd95 (patch)
tree99411d8ca9990c7d7c5120067e54501782f68584
parent70539260f5108c9550bde7fa2fb0b9c6653bd78b (diff)
downloadast2050-flashrom-3d94a0e00e4d3fdb5f799861d3b354d13a1fcd95.zip
ast2050-flashrom-3d94a0e00e4d3fdb5f799861d3b354d13a1fcd95.tar.gz
Convert the existing it8716f_* functions to generic_spi_* functions
Corresponding to flashrom svn r147 and coreboot v2 svn r2863. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Reinauer <stepan@coresystems.de>
-rw-r--r--board_enable.c2
-rw-r--r--flash.h2
-rw-r--r--spi.c33
3 files changed, 22 insertions, 15 deletions
diff --git a/board_enable.c b/board_enable.c
index 243251a..9f2fc8a 100644
--- a/board_enable.c
+++ b/board_enable.c
@@ -355,7 +355,7 @@ struct board_pciid_enable {
struct board_pciid_enable board_pciid_enables[] = {
{0x10de, 0x0360, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- "gigabyte", "m57sli", "GIGABYTE GA-M57SLI", it87xx_probe_serial_flash},
+ "gigabyte", "m57sli", "GIGABYTE GA-M57SLI", it87xx_probe_spi_flash},
{0x1022, 0x7468, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
"iwill", "dk8_htx", "IWILL DK8-HTX", w83627hf_gpio24_raise_2e},
{0x10de, 0x005e, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
diff --git a/flash.h b/flash.h
index 6029828..0e419ff 100644
--- a/flash.h
+++ b/flash.h
@@ -209,7 +209,7 @@ extern char *lb_part, *lb_vendor;
/* spi.c */
int probe_spi(struct flashchip *flash);
-int it87xx_probe_serial_flash(const char *name);
+int it87xx_probe_spi_flash(const char *name);
/* 82802ab.c */
int probe_82802ab(struct flashchip *flash);
diff --git a/spi.c b/spi.c
index 5071f52..8a6a61c 100644
--- a/spi.c
+++ b/spi.c
@@ -68,7 +68,7 @@ static void exit_conf_mode_ite(uint16_t port)
regwrite(port, 0x02, 0x02);
}
-static uint16_t find_ite_serial_flash_port(uint16_t port)
+static uint16_t find_ite_spi_flash_port(uint16_t port)
{
uint8_t tmp = 0;
uint16_t id, flashport = 0;
@@ -102,6 +102,14 @@ static uint16_t find_ite_serial_flash_port(uint16_t port)
return flashport;
}
+int it87xx_probe_spi_flash(const char *name)
+{
+ it8716f_flashport = find_ite_spi_flash_port(ITE_SUPERIO_PORT1);
+ if (!it8716f_flashport)
+ it8716f_flashport = find_ite_spi_flash_port(ITE_SUPERIO_PORT2);
+ return (!it8716f_flashport);
+}
+
/* The IT8716F only supports commands with length 1,2,4,5 bytes including
command byte and can not read more than 3 bytes from the device.
This function expects writearr[0] to be the first byte sent to the device,
@@ -162,31 +170,30 @@ static int it8716f_spi_command(uint16_t port, unsigned char writecnt, unsigned c
return 0;
}
-static int it8716f_serial_rdid(uint16_t port, unsigned char *readarr)
+static int generic_spi_command(unsigned char writecnt, unsigned char readcnt, const unsigned char *writearr, unsigned char *readarr)
+{
+ if (it8716f_flashport)
+ return it8716f_spi_command(it8716f_flashport, writecnt, readcnt, writearr, readarr);
+ printf("%s called, but no SPI chipset detected\n", __FUNCTION__);
+ return 1;
+}
+
+static int generic_spi_rdid(unsigned char *readarr)
{
const unsigned char cmd[] = JEDEC_RDID;
- if (it8716f_spi_command(port, JEDEC_RDID_OUTSIZE, JEDEC_RDID_INSIZE, cmd, readarr))
+ if (generic_spi_command(JEDEC_RDID_OUTSIZE, JEDEC_RDID_INSIZE, cmd, readarr))
return 1;
printf("RDID returned %02x %02x %02x\n", readarr[0], readarr[1], readarr[2]);
return 0;
}
-int it87xx_probe_serial_flash(const char *name)
-{
- it8716f_flashport = find_ite_serial_flash_port(ITE_SUPERIO_PORT1);
- if (!it8716f_flashport)
- it8716f_flashport = find_ite_serial_flash_port(ITE_SUPERIO_PORT2);
- return (!it8716f_flashport);
-}
-
int probe_spi(struct flashchip *flash)
{
unsigned char readarr[3];
uint8_t manuf_id;
uint16_t model_id;
- if (it8716f_flashport) {
- it8716f_serial_rdid(it8716f_flashport, readarr);
+ if (!generic_spi_rdid(readarr)) {
manuf_id = readarr[0];
model_id = (readarr[1] << 8) | readarr[2];
printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, manuf_id, model_id);
OpenPOWER on IntegriCloud