Clean up SMBus PIIX4 code
This commit is contained in:
@@ -126,24 +126,25 @@ smbus_piix4_write(uint16_t addr, uint8_t val, void *priv)
|
||||
smbus_read = (dev->addr & 0x01);
|
||||
|
||||
/* decode the 3-bit command protocol */
|
||||
dev->next_stat = 0x2; /* raise INTER (command completed) by default */
|
||||
switch ((val >> 2) & 0x7) {
|
||||
case 0x0: /* quick R/W */
|
||||
dev->next_stat = 0x2;
|
||||
break;
|
||||
|
||||
case 0x1: /* byte R/W */
|
||||
if (smbus_read)
|
||||
dev->data0 = smbus_read_byte(smbus_addr);
|
||||
else
|
||||
smbus_write_byte(smbus_addr, dev->data0);
|
||||
dev->next_stat = 0x2;
|
||||
break;
|
||||
|
||||
case 0x2: /* byte data R/W */
|
||||
if (smbus_read)
|
||||
dev->data0 = smbus_read_byte_cmd(smbus_addr, dev->cmd);
|
||||
else
|
||||
smbus_write_byte_cmd(smbus_addr, dev->cmd, dev->data0);
|
||||
dev->next_stat = 0x2;
|
||||
break;
|
||||
|
||||
case 0x3: /* word data R/W */
|
||||
if (smbus_read) {
|
||||
temp = smbus_read_word_cmd(smbus_addr, dev->cmd);
|
||||
@@ -153,15 +154,15 @@ smbus_piix4_write(uint16_t addr, uint8_t val, void *priv)
|
||||
temp = ((dev->data1 << 8) | dev->data0);
|
||||
smbus_write_word_cmd(smbus_addr, dev->cmd, temp);
|
||||
}
|
||||
dev->next_stat = 0x2;
|
||||
break;
|
||||
|
||||
case 0x5: /* block R/W */
|
||||
if (smbus_read)
|
||||
dev->data0 = smbus_read_block_cmd(smbus_addr, dev->cmd, dev->data, SMBUS_PIIX4_BLOCK_DATA_SIZE);
|
||||
else
|
||||
smbus_write_block_cmd(smbus_addr, dev->cmd, dev->data, dev->data0);
|
||||
dev->next_stat = 0x2;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* other command protocols have undefined behavior, but raise DEV_ERR to be safe */
|
||||
dev->next_stat = 0x4;
|
||||
@@ -210,13 +211,13 @@ smbus_piix4_response(void *priv)
|
||||
void
|
||||
smbus_piix4_remap(smbus_piix4_t *dev, uint16_t new_io_base, uint8_t enable)
|
||||
{
|
||||
if (dev->io_base != 0x0000)
|
||||
if (dev->io_base)
|
||||
io_removehandler(dev->io_base, 0x10, smbus_piix4_read, NULL, NULL, smbus_piix4_write, NULL, NULL, dev);
|
||||
|
||||
dev->io_base = new_io_base;
|
||||
smbus_piix4_log("SMBus PIIX4: remap to %04Xh (enable %d)\n", dev->io_base, !!enable);
|
||||
smbus_piix4_log("SMBus PIIX4: remap to %04Xh (%sabled)\n", dev->io_base, enable ? "en" : "dis");
|
||||
|
||||
if ((enable) && (dev->io_base != 0x0000))
|
||||
if (enable && dev->io_base)
|
||||
io_sethandler(dev->io_base, 0x10, smbus_piix4_read, NULL, NULL, smbus_piix4_write, NULL, NULL, dev);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user