mirror of
https://github.com/xemu-project/xemu.git
synced 2025-02-10 14:24:15 +00:00
i2c:smbus: Correct the working of quick commands
The logic of handling quick SMBus commands was wrong. If you get a finish event with no data, that's a quick command. Document the quick command while we are at it. Signed-off-by: Corey Minyard <cminyard@mvista.com>
This commit is contained in:
parent
bc15cde0c4
commit
905cec6d11
@ -54,9 +54,7 @@ static void smbus_do_write(SMBusDevice *dev)
|
|||||||
{
|
{
|
||||||
SMBusDeviceClass *sc = SMBUS_DEVICE_GET_CLASS(dev);
|
SMBusDeviceClass *sc = SMBUS_DEVICE_GET_CLASS(dev);
|
||||||
|
|
||||||
if (dev->data_len == 0) {
|
if (dev->data_len == 1) {
|
||||||
smbus_do_quick_cmd(dev, 0);
|
|
||||||
} else if (dev->data_len == 1) {
|
|
||||||
DPRINTF("Send Byte\n");
|
DPRINTF("Send Byte\n");
|
||||||
if (sc->send_byte) {
|
if (sc->send_byte) {
|
||||||
sc->send_byte(dev, dev->data_buf[0]);
|
sc->send_byte(dev, dev->data_buf[0]);
|
||||||
@ -120,19 +118,24 @@ static int smbus_i2c_event(I2CSlave *s, enum i2c_event event)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case I2C_FINISH:
|
case I2C_FINISH:
|
||||||
switch (dev->mode) {
|
if (dev->data_len == 0) {
|
||||||
case SMBUS_WRITE_DATA:
|
if (dev->mode == SMBUS_WRITE_DATA || dev->mode == SMBUS_READ_DATA) {
|
||||||
smbus_do_write(dev);
|
smbus_do_quick_cmd(dev, dev->mode == SMBUS_READ_DATA);
|
||||||
break;
|
}
|
||||||
case SMBUS_RECV_BYTE:
|
} else {
|
||||||
smbus_do_quick_cmd(dev, 1);
|
switch (dev->mode) {
|
||||||
break;
|
case SMBUS_WRITE_DATA:
|
||||||
case SMBUS_READ_DATA:
|
smbus_do_write(dev);
|
||||||
BADF("Unexpected stop during receive\n");
|
break;
|
||||||
break;
|
|
||||||
default:
|
case SMBUS_READ_DATA:
|
||||||
/* Nothing to do. */
|
BADF("Unexpected stop during receive\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* Nothing to do. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dev->mode = SMBUS_IDLE;
|
dev->mode = SMBUS_IDLE;
|
||||||
dev->data_len = 0;
|
dev->data_len = 0;
|
||||||
|
@ -40,6 +40,11 @@ typedef struct SMBusDevice SMBusDevice;
|
|||||||
typedef struct SMBusDeviceClass
|
typedef struct SMBusDeviceClass
|
||||||
{
|
{
|
||||||
I2CSlaveClass parent_class;
|
I2CSlaveClass parent_class;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* An operation with no data, special in SMBus.
|
||||||
|
* This may be NULL, quick commands are ignore in that case.
|
||||||
|
*/
|
||||||
void (*quick_cmd)(SMBusDevice *dev, uint8_t read);
|
void (*quick_cmd)(SMBusDevice *dev, uint8_t read);
|
||||||
void (*send_byte)(SMBusDevice *dev, uint8_t val);
|
void (*send_byte)(SMBusDevice *dev, uint8_t val);
|
||||||
uint8_t (*receive_byte)(SMBusDevice *dev);
|
uint8_t (*receive_byte)(SMBusDevice *dev);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user