diff options
author | jhb <jhb@FreeBSD.org> | 2009-02-03 16:14:37 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2009-02-03 16:14:37 +0000 |
commit | 5515d5597b757d3c81d8ded55b1209509a2d4cd0 (patch) | |
tree | 9aca21032933c973a3881f8f79e208911283bc2c | |
parent | 02f472a38c34915a171f58b5337454f4a5408cf4 (diff) | |
download | FreeBSD-src-5515d5597b757d3c81d8ded55b1209509a2d4cd0.zip FreeBSD-src-5515d5597b757d3c81d8ded55b1209509a2d4cd0.tar.gz |
- Change ichsmb(4) to follow the format of all the other smbus controllers
for slave addressing by using left-adjusted slave addresses (i.e.
xxxxxxx0b).
- Require the low bit of the slave address to always be zero in smb(4) to
help catch broken applications.
- Adjust some code in the IPMI driver to not convert the slave address for
SSIF to a right-adjusted address. I (or possibly ambrisko@) added this in
the past to (unknowingly) work around the bug in ichsmb(4).
Submitted by: Andriy Gapon <avg of icyb.net.ua> (1,2)
MFC after: 1 month
-rw-r--r-- | sys/dev/ichsmb/ichsmb.c | 20 | ||||
-rw-r--r-- | sys/dev/ipmi/ipmi_smbios.c | 4 | ||||
-rw-r--r-- | sys/dev/smbus/smb.c | 4 |
3 files changed, 16 insertions, 12 deletions
diff --git a/sys/dev/ichsmb/ichsmb.c b/sys/dev/ichsmb/ichsmb.c index d902442..5ff54db 100644 --- a/sys/dev/ichsmb/ichsmb.c +++ b/sys/dev/ichsmb/ichsmb.c @@ -182,7 +182,7 @@ ichsmb_quick(device_t dev, u_char slave, int how) mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_QUICK; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | (how == SMB_QREAD ? + slave | (how == SMB_QREAD ? ICH_XMIT_SLVA_READ : ICH_XMIT_SLVA_WRITE)); bus_write_1(sc->io_res, ICH_HST_CNT, ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); @@ -208,7 +208,7 @@ ichsmb_sendb(device_t dev, u_char slave, char byte) mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_WRITE); + slave | ICH_XMIT_SLVA_WRITE); bus_write_1(sc->io_res, ICH_HST_CMD, byte); bus_write_1(sc->io_res, ICH_HST_CNT, ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); @@ -230,7 +230,7 @@ ichsmb_recvb(device_t dev, u_char slave, char *byte) mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_READ); + slave | ICH_XMIT_SLVA_READ); bus_write_1(sc->io_res, ICH_HST_CNT, ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR) @@ -253,7 +253,7 @@ ichsmb_writeb(device_t dev, u_char slave, char cmd, char byte) mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE_DATA; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_WRITE); + slave | ICH_XMIT_SLVA_WRITE); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_D0, byte); bus_write_1(sc->io_res, ICH_HST_CNT, @@ -277,7 +277,7 @@ ichsmb_writew(device_t dev, u_char slave, char cmd, short word) mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_WORD_DATA; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_WRITE); + slave | ICH_XMIT_SLVA_WRITE); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_D0, word & 0xff); bus_write_1(sc->io_res, ICH_D1, word >> 8); @@ -301,7 +301,7 @@ ichsmb_readb(device_t dev, u_char slave, char cmd, char *byte) mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE_DATA; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_READ); + slave | ICH_XMIT_SLVA_READ); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_HST_CNT, ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); @@ -324,7 +324,7 @@ ichsmb_readw(device_t dev, u_char slave, char cmd, short *word) mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_WORD_DATA; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_READ); + slave | ICH_XMIT_SLVA_READ); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_HST_CNT, ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); @@ -352,7 +352,7 @@ ichsmb_pcall(device_t dev, u_char slave, char cmd, short sdata, short *rdata) mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_PROC_CALL; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_WRITE); + slave | ICH_XMIT_SLVA_WRITE); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_D0, sdata & 0xff); bus_write_1(sc->io_res, ICH_D1, sdata >> 8); @@ -403,7 +403,7 @@ ichsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf) mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BLOCK; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_WRITE); + slave | ICH_XMIT_SLVA_WRITE); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_D0, count); bus_write_1(sc->io_res, ICH_BLOCK_DB, buf[0]); @@ -434,7 +434,7 @@ ichsmb_bread(device_t dev, u_char slave, char cmd, u_char *count, char *buf) mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BLOCK; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_READ); + slave | ICH_XMIT_SLVA_READ); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_D0, *count); /* XXX? */ bus_write_1(sc->io_res, ICH_HST_CNT, diff --git a/sys/dev/ipmi/ipmi_smbios.c b/sys/dev/ipmi/ipmi_smbios.c index d9fcff8..31424d6 100644 --- a/sys/dev/ipmi/ipmi_smbios.c +++ b/sys/dev/ipmi/ipmi_smbios.c @@ -154,10 +154,10 @@ smbios_t38_proc_info(uint8_t *p, char **table, struct ipmi_get_info *info) case SSIF_MODE: if ((s->base_address & 0xffffffffffffff00) != 0) { printf("SMBIOS: Invalid SSIF SMBus address, using BMC I2C slave address instead\n"); - info->address = s->i2c_slave_address >> 1; + info->address = s->i2c_slave_address; break; } - info->address = IPMI_BAR_ADDR(s->base_address) >> 1; + info->address = IPMI_BAR_ADDR(s->base_address); break; default: return; diff --git a/sys/dev/smbus/smb.c b/sys/dev/smbus/smb.c index df3ebe9..579204d 100644 --- a/sys/dev/smbus/smb.c +++ b/sys/dev/smbus/smb.c @@ -180,6 +180,10 @@ smbioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *t parent = device_get_parent(smbdev); + /* Make sure that LSB bit is cleared. */ + if (s->slave & 0x1) + return (EINVAL); + /* Allocate the bus. */ if ((error = smbus_request_bus(parent, smbdev, (flags & O_NONBLOCK) ? SMB_DONTWAIT : (SMB_WAIT | SMB_INTR)))) |