[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 17/19] i2c: Allow SMBus device to NAK start events
From: |
minyard |
Subject: |
[Qemu-devel] [PATCH 17/19] i2c: Allow SMBus device to NAK start events |
Date: |
Fri, 30 Dec 2016 09:21:48 -0600 |
From: Corey Minyard <address@hidden>
The I2C code has been modified to allow devices to NAK start
events, the SMBus code should, too.
Signed-off-by: Corey Minyard <address@hidden>
---
hw/i2c/smbus.c | 11 +++++++++++
include/hw/i2c/smbus.h | 2 ++
2 files changed, 13 insertions(+)
diff --git a/hw/i2c/smbus.c b/hw/i2c/smbus.c
index 4cb651e..87a1669 100644
--- a/hw/i2c/smbus.c
+++ b/hw/i2c/smbus.c
@@ -71,6 +71,17 @@ static int smbus_i2c_event(I2CSlave *s, enum i2c_event event)
{
SMBusDevice *dev = SMBUS_DEVICE(s);
+ if (event == I2C_START_SEND || event == I2C_START_RECV) {
+ /* Allow the device to NAK the start event. */
+ SMBusDeviceClass *sc = SMBUS_DEVICE_GET_CLASS(dev);
+
+ if (sc->event) {
+ int rv = sc->event(dev, event);
+ if (rv)
+ return rv;
+ }
+ }
+
switch (event) {
case I2C_START_SEND:
switch (dev->mode) {
diff --git a/include/hw/i2c/smbus.h b/include/hw/i2c/smbus.h
index f1b8078..fc995eb 100644
--- a/include/hw/i2c/smbus.h
+++ b/include/hw/i2c/smbus.h
@@ -39,6 +39,8 @@ typedef struct SMBusDeviceClass
{
I2CSlaveClass parent_class;
int (*init)(SMBusDevice *dev);
+ /* Allow the device to get start and stop events so they can NAK them. */
+ int (*event)(SMBusDevice *dev, enum i2c_event event);
void (*quick_cmd)(SMBusDevice *dev, uint8_t read);
void (*send_byte)(SMBusDevice *dev, uint8_t val);
uint8_t (*receive_byte)(SMBusDevice *dev);
--
2.7.4
- [Qemu-devel] [PATCH 01/18] Patch set to get full IPMI over SMBus, minyard, 2016/12/30
- [Qemu-devel] [PATCH 02/19] i2c-smbus: Use a int for return, minyard, 2016/12/30
- [Qemu-devel] [PATCH 05/19] i2c:pm_smbus: Make the I2C block read command read-only, minyard, 2016/12/30
- [Qemu-devel] [PATCH 17/19] i2c: Allow SMBus device to NAK start events,
minyard <=
- [Qemu-devel] [PATCH 01/19] i2c: Allow I2C devices to NAK start events, minyard, 2016/12/30
- [Qemu-devel] [PATCH 03/19] i2c:pm_smbus: Clean up some style issues, minyard, 2016/12/30
- [Qemu-devel] [PATCH 08/19] i2c:pm_smbus: Add interrupt handling, minyard, 2016/12/30
- [Qemu-devel] [PATCH 09/19] i2c:pm_smbus: Add the ability to force block transfer enable, minyard, 2016/12/30
- [Qemu-devel] [PATCH 16/19] isa: Add an irq device., minyard, 2016/12/30
- [Qemu-devel] [PATCH 19/19] ipmi_smbus: Add alert capability to the IPMI SSIF code, minyard, 2016/12/30
- [Qemu-devel] [PATCH 04/19] i2c:pm_smbus: Fix the semantics of block I2C transfers, minyard, 2016/12/30
- [Qemu-devel] [PATCH 12/19] ipmi: Fix SSIF ACPI handling to use the right CRS, minyard, 2016/12/30
- [Qemu-devel] [PATCH 06/19] i2c:pm_smbus: Add block transfer capability, minyard, 2016/12/30
- [Qemu-devel] [PATCH 07/19] i2c:pm_smbus: Fix state transfer, minyard, 2016/12/30