Decouple the ITE code from fintek.c, it doesn't belong there.

Add common 'enter configuration mode' function for most Winbond/Fintek/ITE
chips which use the 0x87 0x87 sequence for that reason.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>



git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2794 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Uwe Hermann 2007-09-20 23:37:56 +00:00
parent 0702469f16
commit b4db2209f9
5 changed files with 37 additions and 63 deletions

View File

@ -102,68 +102,32 @@ void dump_fintek(uint16_t port, uint16_t did)
regval(port, 0xf6), regval(port, 0xf7), regval(port, 0xf8));
}
static void enter_conf_mode_fintek(uint16_t port)
{
/* Enable configuration sequence (Fintek uses this for example)
* Older ITE chips have the same enable sequence.
*/
outb(0x87, port);
outb(0x87, port);
}
static void exit_conf_mode_fintek(uint16_t port)
{
/* Exit MB PnP mode (for Fintek, doesn't hurt ITE). */
outb(0xaa, port);
}
void probe_idregs_fintek(uint16_t port)
{
uint16_t vid, did, did_ite, success = 0;
uint16_t vid, did;
enter_conf_mode_fintek(port);
enter_conf_mode_winbond_fintek_ite_8787(port);
did = regval(port, DEVICE_ID_BYTE1_REG);
did |= (regval(port, DEVICE_ID_BYTE2_REG) << 8);
did_ite = ((did & 0xff) << 8) | ((did & 0xff00) >> 8);
vid = regval(port, VENDOR_ID_BYTE1_REG);
vid |= (regval(port, VENDOR_ID_BYTE2_REG) << 8);
/* FIXME */
if (vid != 0x3419 && did_ite != 0x8708 && did_ite != 0x8710) {
if (vid != 0x3419) {
no_superio_found(port);
exit_conf_mode_fintek(port);
return;
}
if (did_ite == 0x8708 || did_ite == 0x8701) {
printf("Found ITE IT%04xF (id=0x%04x, rev=0x%01x) at port=0x%x\n", did_ite, did_ite, 0, port); /* FIXME */
dump_ite(port, did_ite);
regwrite(port, 0x02, 0x02); /* FIXME */
return;
}
if (vid == 0xff || vid == 0xffff) {
exit_conf_mode_fintek(port);
exit_conf_mode_winbond_fintek_ite_8787(port);
return;
}
printf("Found Fintek %s (vid=0x%04x, id=0x%04x) at port=0x%x\n",
get_superio_name(reg_table, did), vid, did, port);
switch (vid) {
case 0x3419:
success = 1;
dump_fintek(port, did);
break;
default:
break;
}
dump_superio("Fintek", reg_table, port, did);
if (!success)
printf("No dump for vid 0x%04x, did 0x%04x\n", vid, did);
/* TODO: Revive this as --dump-human-readable output. */
/* dump_fintek(port, did); */
exit_conf_mode_fintek(port);
exit_conf_mode_winbond_fintek_ite_8787(port);
}

View File

@ -226,12 +226,10 @@ static void exit_conf_mode_ite(uint16_t port)
regwrite(port, 0x02, 0x02);
}
void probe_idregs_ite(uint16_t port)
static void probe_idregs_ite_helper(uint16_t port)
{
uint16_t id, chipver;
enter_conf_mode_ite(port);
id = regval(port, CHIP_ID_BYTE1_REG) << 8;
id |= regval(port, CHIP_ID_BYTE2_REG);
chipver = regval(port, CHIP_VERSION_REG) & 0x0f; /* Only bits 3..0 */
@ -246,7 +244,16 @@ void probe_idregs_ite(uint16_t port)
get_superio_name(reg_table, id), id, chipver, port);
dump_superio("ITE", reg_table, port, id);
exit_conf_mode_ite(port);
}
void probe_idregs_ite(uint16_t port)
{
enter_conf_mode_ite(port);
probe_idregs_ite_helper(port);
exit_conf_mode_ite(port);
enter_conf_mode_winbond_fintek_ite_8787(port);
probe_idregs_ite_helper(port);
exit_conf_mode_winbond_fintek_ite_8787(port);
}

View File

@ -37,6 +37,18 @@ void regwrite(uint16_t port, uint8_t reg, uint8_t val)
outb(val, port + 1);
}
void enter_conf_mode_winbond_fintek_ite_8787(uint16_t port)
{
outb(0x87, port);
outb(0x87, port);
}
void exit_conf_mode_winbond_fintek_ite_8787(uint16_t port)
{
outb(0xaa, port); /* Fintek, Winbond */
regwrite(port, 0x02, 0x02); /* ITE */
}
int superio_unknown(const struct superio_registers reg_table[], uint16_t id)
{
return !strncmp(get_superio_name(reg_table, id), "<unknown>", 9);

View File

@ -70,6 +70,8 @@ struct superio_registers {
/* superiotool.c */
uint8_t regval(uint16_t port, uint8_t reg);
void regwrite(uint16_t port, uint8_t reg, uint8_t val);
void enter_conf_mode_winbond_fintek_ite_8787(uint16_t port);
void exit_conf_mode_winbond_fintek_ite_8787(uint16_t port);
int superio_unknown(const struct superio_registers reg_table[], uint16_t id);
const char *get_superio_name(const struct superio_registers reg_table[],
uint16_t id);

View File

@ -126,23 +126,12 @@ const static struct superio_registers reg_table[] = {
{EOT}
};
static void enter_conf_mode_winbond(uint16_t port)
{
outb(0x87, port);
outb(0x87, port);
}
static void exit_conf_mode_winbond(uint16_t port)
{
outb(0xaa, port);
}
void probe_idregs_winbond(uint16_t port)
{
uint16_t id;
uint8_t devid, rev;
enter_conf_mode_winbond(port);
enter_conf_mode_winbond_fintek_ite_8787(port);
devid = regval(port, DEVICE_ID_REG);
rev = regval(port, DEVICE_REV_REG);
@ -152,7 +141,7 @@ void probe_idregs_winbond(uint16_t port)
if (superio_unknown(reg_table, id)) {
no_superio_found(port);
exit_conf_mode_winbond(port);
exit_conf_mode_winbond_fintek_ite_8787(port);
return;
}
@ -162,6 +151,6 @@ void probe_idregs_winbond(uint16_t port)
/* TODO: Special notes in dump output for the MISC entries. */
dump_superio("Winbond", reg_table, port, id);
exit_conf_mode_winbond(port);
exit_conf_mode_winbond_fintek_ite_8787(port);
}