Patch set to get full IPMI over SMBus
PATCH 1/18 Patch set to get full IPMI over SMBus
I've had this working for a while, primarily for my own testing capability, but I guess I should put it out there for other people as this interface is starting to show up in ARM64 devices and maybe it's useful to others.
It's actually a few sets of patches that each accomplish a different things, but all required for full function of the device.
[PATCH 01/19] i2c: Allow I2C devices to NAK start events [PATCH 02/19] i2c-smbus: Use a int for return
The above two are more general bug fixes. The first has already been sent out, it's required for the SMBus alert device and for IPMI to be able to NAK when they have no data. The second is just a little bug fix, and may not be strictly necessary.
[PATCH 03/19] i2c:pm_smbus: Clean up some style issues [PATCH 04/19] i2c:pm_smbus: Fix the semantics of block I2C transfers [PATCH 05/19] i2c:pm_smbus: Make the I2C block read command read-only [PATCH 06/19] i2c:pm_smbus: Add block transfer capability [PATCH 07/19] i2c:pm_smbus: Fix state transfer
[PATCH 08/19] i2c:pm_smbus: Add interrupt handling
[PATCH 09/19] i2c:pm_smbus: Add the ability to force block transfer
The above changes fix the pm_smbus device so it works properly and so it can do block transfers, which are required by IPMI.
[PATCH 10/19] ipmi: Add an SMBus IPMI interface [PATCH 11/19] acpi: Add i2c serial bus CRS handling [PATCH 12/19] ipmi: Fix SSIF ACPI handling to use the right CRS [PATCH 13/19] pc: Add _enabled to the end of some boolean flags [PATCH 14/19] pc: Add an SMB0 ACPI device to q35
The above add the IPMI on SMBus device itself and then add the ACPI handling for it.
[PATCH 15/19] hw: Add an IRQ interface
[PATCH 16/19] isa: Add an irq device.
I'm not sure about the above patches. They add a generic "interrupt" device then add an ISA version of them. The SMBus alert device requires an interrupt of some type. It seemed like having a generic interrupt that could be tied to a device was a nice feature, it would keep from having to have a separate isa/pci/whatever version of the alert device for something that was on an I2C bus. But I'm not really sure this is the best way.
[PATCH 17/19] i2c: Allow SMBus device to NAK start events [PATCH 18/19] i2c: Add an SMBus alert device.
[PATCH 19/19] ipmi_smbus: Add alert capability to the IPMI SSIF code
The above add an SMBus alert device. It's basically something that muxes "interrupt" signals from I2C device onto a single interrupt and allows the I2C master to fetch which I2C device in sending the interrupt. This allows the IPMI device to tell the host that it has something ready for it, thus really speeding things up.
-corey
PATCH 2/19 i2c-smbus: Use a int for return
From: Corey Minyard <[email protected]>
The return value from getting the data may be an error, so use an integer to hold it.
--- hw/i2c/smbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i2c/smbus.c +1 -1
@@ -222,7 +222,7 @@ int smbus_quick_command(I2CBus *bus, uint8_t addr, int read)int smbus_receive_byte (I2CBus *bus,uint8_t addr) { -uint8_t data; +int data;if (i2c_start_transfer (bus, addr,1 )) {return -1 ;
Signature · 1 line
2.7.4
PATCH 3/19 i2c:pm_smbus: Clean up some style issues
In reply to [email protected]From: Corey Minyard <[email protected]>
Fix some spacing issues, remove extraneous comments, add some defines instead of hard-coding numbers.
--- hw/i2c/pm_smbus.c | 58 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 20 deletions(-)
hw/i2c/pm_smbus.c +38 -20
@@ -23,8 +23,6 @@#include "hw/i2c/pm_smbus.h" #include "hw/i2c/smbus.h" -/* no save/load? */ -#define SMBHSTSTS 0x00#define SMBHSTCNT 0x02#define SMBHSTCMD 0x03
@@ -33,19 +31,34 @@#define SMBHSTDAT1 0x06#define SMBBLKDAT 0x07 -#define STS_HOST_BUSY (1) -#define STS_INTR (1<<1) -#define STS_DEV_ERR (1<<2) -#define STS_BUS_ERR (1<<3) -#define STS_FAILED (1<<4) -#define STS_SMBALERT (1<<5) -#define STS_INUSE_STS (1<<6) -#define STS_BYTE_DONE (1<<7) +#define STS_HOST_BUSY (1 << 0) +#define STS_INTR (1 << 1) +#define STS_DEV_ERR (1 << 2) +#define STS_BUS_ERR (1 << 3) +#define STS_FAILED (1 << 4) +#define STS_SMBALERT (1 << 5) +#define STS_INUSE_STS (1 << 6) +#define STS_BYTE_DONE (1 << 7)/* Signs of successfully transaction end : * ByteDoneStatus = 1 (STS_BYTE_DONE) and INTR = 1 (STS_INTR ) */ -//#define DEBUG +#define CTL_INTREN (1 << 0) +#define CTL_KILL (1 << 1) +#define CTL_LAST_BYTE (1 << 5) +#define CTL_START (1 << 6) +#define CTL_PEC_EN (1 << 7) +#define CTL_RETURN_MASK 0x1f + +#define PROT_QUICK 0 +#define PROT_BYTE 1 +#define PROT_BYTE_DATA 2 +#define PROT_WORD_DATA 3 +#define PROT_PROC_CALL 4 +#define PROT_BLOCK_DATA 5 +#define PROT_I2C_BLOCK_DATA 6 + +/*#define DEBUG*/ #ifdef DEBUG # define SMBUS_DPRINTF (format, ...) printf(format, ## __VA_ARGS__)
@@ -68,11 +81,12 @@ static void smb_transaction(PMSMBus *s)if ((s->smb_stat &STS_DEV_ERR ) !=0 ) { goto error; } +switch (prot) { -case 0x0 : +case PROT_QUICK : ret =smbus_quick_command (bus, addr, read); goto done; -case 0x1 : +case PROT_BYTE :if (read) { ret =smbus_receive_byte (bus, addr); goto data8;
@@ -80,7 +94,7 @@ static void smb_transaction(PMSMBus *s) ret =smbus_send_byte (bus, addr, cmd); goto done; } -case 0x2 : +case PROT_BYTE_DATA :if (read) { ret =smbus_read_byte (bus, addr, cmd); goto data8;
@@ -89,16 +103,17 @@ static void smb_transaction(PMSMBus *s) goto done; }break ; -case 0x3 : +case PROT_WORD_DATA :if (read) { ret =smbus_read_word (bus, addr, cmd); goto data16; }else { - ret =smbus_write_word (bus, addr, cmd, (s->smb_data1 <<8 ) | s->smb_data0); + ret =smbus_write_word (bus, addr, cmd, + (s->smb_data1 <<8 ) | s->smb_data0); goto done; }break ; -case 0x5 : +case PROT_I2C_BLOCK_DATA :if (read) { ret =smbus_read_block (bus, addr, cmd, s->smb_data); goto data8;
@@ -149,8 +164,9 @@ static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val,break ;case SMBHSTCNT : s->smb_ctl = val; -if (val &0x40 ) +if (s->smb_ctl &CTL_START ) {smb_transaction (s); + }break ;case SMBHSTCMD : s->smb_cmd = val;
@@ -185,7 +201,7 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width)break ;case SMBHSTCNT : s->smb_index =0 ; - val = s->smb_ctl &0x1f ; + val = s->smb_ctl &CTL_RETURN_MASK ;break ;case SMBHSTCMD : val = s->smb_cmd;
@@ -208,7 +224,9 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width) val =0 ;break ; } -SMBUS_DPRINTF ("SMB readb port=0x%04" HWADDR_PRIx" val=0x%02x\n" , addr, val); +SMBUS_DPRINTF ("SMB readb port=0x%04" HWADDR_PRIx" val=0x%02x\n" , + addr, val); +return val; }
Signature · 1 line
2.7.4
PATCH 5/19 i2c:pm_smbus: Make the I2C block read command read-only
In reply to [email protected]From: Corey Minyard <[email protected]>
It did have write capability, but the manual says the behavior with write enabled is undefined. So just set an error in this case.
--- hw/i2c/pm_smbus.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
hw/i2c/pm_smbus.c +4 -5
@@ -56,7 +56,7 @@#define PROT_WORD_DATA 3#define PROT_PROC_CALL 4#define PROT_BLOCK_DATA 5 -#define PROT_I2C_BLOCK_DATA 6 +#define PROT_I2C_BLOCK_READ 6/*#define DEBUG*/
@@ -113,7 +113,7 @@ static void smb_transaction(PMSMBus *s) goto done; }break ; -case PROT_I2C_BLOCK_DATA : +case PROT_I2C_BLOCK_READ :if (read) {int xfersize = s->smb_data0;if (xfersize >sizeof (s->smb_data)) {
@@ -123,9 +123,8 @@ static void smb_transaction(PMSMBus *s) xfersize, false, true); goto data8; }else { - ret =smbus_write_block (bus, addr, cmd, s->smb_data, s->smb_data0, - false); - goto done; +/* The manual says the behavior is undefined, just set DEV_ERR. */ + goto error; }break ;default :
Signature · 1 line
2.7.4
PATCH 17/19 i2c: Allow SMBus device to NAK start events
In reply to [email protected]From: Corey Minyard <[email protected]>
The I2C code has been modified to allow devices to NAK start events, the SMBus code should, too.
--- hw/i2c/smbus.c | 11 +++++++++++ include/hw/i2c/smbus.h | 2 ++ 2 files changed, 13 insertions(+)
hw/i2c/smbus.c +11 -0
@@ -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) {
include/hw/i2c/smbus.h +2 -0
@@ -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);
Signature · 1 line
2.7.4
PATCH 1/19 i2c: Allow I2C devices to NAK start events
In reply to [email protected]From: Corey Minyard <[email protected]>
Add a return value to the event handler. Some I2C devices will NAK if they have no data, so allow them to do this. This required the following changes:
Go through all the event handlers and change them to return int and return 0.
Modify i2c_start_transfer to terminate the transaction on a NAK.
Modify smbus handing to not assert if a NAK occurs on a second operation, and terminate the transaction and return -1 instead.
Add some information on semantics to I2CSlaveClass.
--- hw/arm/pxa2xx.c | 4 +++- hw/arm/tosa.c | 4 +++- hw/arm/z2.c | 4 +++- hw/audio/wm8750.c | 4 +++- hw/display/ssd0303.c | 4 +++- hw/gpio/max7310.c | 4 +++- hw/i2c/core.c | 31 +++++++++++++++++++++++++------ hw/i2c/i2c-ddc.c | 4 +++- hw/i2c/smbus.c | 13 +++++++++---- hw/input/lm832x.c | 4 +++- hw/misc/tmp105.c | 3 ++- hw/timer/ds1338.c | 4 +++- hw/timer/twl92230.c | 4 +++- include/hw/i2c/i2c.h | 16 ++++++++++++---- 14 files changed, 78 insertions(+), 25 deletions(-)
hw/arm/pxa2xx.c +3 -1
@@ -1258,7 +1258,7 @@ static void pxa2xx_i2c_update(PXA2xxI2CState *s) }/* These are only stubs now. */ -static void pxa2xx_i2c_event (I2CSlave *i2c,enum i2c_event event) +static int pxa2xx_i2c_event (I2CSlave *i2c,enum i2c_event event) {PXA2xxI2CSlaveState *slave =PXA2XX_I2C_SLAVE (i2c);PXA2xxI2CState *s = slave->host;
@@ -1280,6 +1280,8 @@ static void pxa2xx_i2c_event(I2CSlave *i2c, enum i2c_event event)break ; }pxa2xx_i2c_update (s); + +return 0 ; }static int pxa2xx_i2c_rx (I2CSlave *i2c)
hw/arm/tosa.c +3 -1
@@ -172,7 +172,7 @@ static int tosa_dac_send(I2CSlave *i2c, uint8_t data)return 0 ; } -static void tosa_dac_event (I2CSlave *i2c,enum i2c_event event) +static int tosa_dac_event (I2CSlave *i2c,enum i2c_event event) {TosaDACState *s =TOSA_DAC (i2c);
@@ -194,6 +194,8 @@ static void tosa_dac_event(I2CSlave *i2c, enum i2c_event event)default :break ; } + +return 0 ; }static int tosa_dac_recv (I2CSlave *s)
hw/arm/z2.c +3 -1
@@ -220,7 +220,7 @@ static int aer915_send(I2CSlave *i2c, uint8_t data)return 0 ; } -static void aer915_event (I2CSlave *i2c,enum i2c_event event) +static int aer915_event (I2CSlave *i2c,enum i2c_event event) {AER915State *s =AER915 (i2c);
@@ -238,6 +238,8 @@ static void aer915_event(I2CSlave *i2c, enum i2c_event event)default :break ; } + +return 0 ; }static int aer915_recv (I2CSlave *slave)
hw/audio/wm8750.c +3 -1
@@ -303,7 +303,7 @@ static void wm8750_reset(I2CSlave *i2c) s->i2c_len =0 ; } -static void wm8750_event (I2CSlave *i2c,enum i2c_event event) +static int wm8750_event (I2CSlave *i2c,enum i2c_event event) {WM8750State *s =WM8750 (i2c);
@@ -321,6 +321,8 @@ static void wm8750_event(I2CSlave *i2c, enum i2c_event event)default :break ; } + +return 0 ; }#define WM8750_LINVOL 0x00
hw/display/ssd0303.c +3 -1
@@ -179,7 +179,7 @@ static int ssd0303_send(I2CSlave *i2c, uint8_t data)return 0 ; } -static void ssd0303_event (I2CSlave *i2c,enum i2c_event event) +static int ssd0303_event (I2CSlave *i2c,enum i2c_event event) {ssd0303_state *s =SSD0303 (i2c);
@@ -193,6 +193,8 @@ static void ssd0303_event(I2CSlave *i2c, enum i2c_event event)/* Nothing to do. */ break ; } + +return 0 ; }static void ssd0303_update_display (void *opaque)
hw/gpio/max7310.c +3 -1
@@ -129,7 +129,7 @@ static int max7310_tx(I2CSlave *i2c, uint8_t data)return 0 ; } -static void max7310_event (I2CSlave *i2c,enum i2c_event event) +static int max7310_event (I2CSlave *i2c,enum i2c_event event) {MAX7310State *s =MAX7310 (i2c); s->len =0 ;
@@ -147,6 +147,8 @@ static void max7310_event(I2CSlave *i2c, enum i2c_event event)default :break ; } + +return 0 ; }static const VMStateDescription vmstate_max7310 = {
hw/i2c/core.c +25 -6
@@ -88,18 +88,26 @@ int i2c_bus_busy(I2CBus *bus)return !QLIST_EMPTY (&bus->current_devs); } +/* TODO: Make this handle multiple masters. */ /* -* Returns non-zero if the address is not valid. If this is called -* again without an intervening i2c_end_transfer(), like in the SMBus -* case where the operation is switched from write to read, this -* function will not rescan the bus and thus cannot fail. +* Start or continue an i2c transaction. When this is called for the +* first time or after an i2c_end_transfer(), if it returns an error +* the bus transaction is terminated (or really never started). If +* this is called after another i2c_start_transfer() without an +* intervening i2c_end_transfer(), and it returns an error, the +* transaction will not be terminated. The caller must do it. +* +* This corresponds with the way real hardware works. The SMBus +* protocol uses a start transfer to switch from write to read mode +* without releasing the bus. If that fails, the bus is still +* in a transaction. */ -/* TODO: Make this handle multiple masters. */ int i2c_start_transfer (I2CBus *bus,uint8_t address,int recv) {BusChild *kid;I2CSlaveClass *sc;I2CNode *node; +bool bus_scanned = false;if (address ==I2C_BROADCAST ) {/*
@@ -130,6 +138,7 @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv) } } } + bus_scanned = true; }if (QLIST_EMPTY (&bus->current_devs)) {
@@ -137,11 +146,21 @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv) } QLIST_FOREACH(node, &bus->current_devs, next) { +int rv; + sc =I2C_SLAVE_GET_CLASS (node->elt);/* If the bus is already busy, assume this is a repeated start condition. */ +if (sc->event) { - sc->event (node->elt, recv ?I2C_START_RECV :I2C_START_SEND ); + rv = sc->event (node->elt, recv ?I2C_START_RECV :I2C_START_SEND ); +if (rv && !bus->broadcast) { +if (bus_scanned) { +/* First call, terminate the transfer. */ +i2c_end_transfer (bus); + } +return rv; + } } }return 0 ;
hw/i2c/i2c-ddc.c +3 -1
@@ -230,13 +230,15 @@ static void i2c_ddc_reset(DeviceState *ds) s->reg =0 ; } -static void i2c_ddc_event (I2CSlave *i2c,enum i2c_event event) +static int i2c_ddc_event (I2CSlave *i2c,enum i2c_event event) {I2CDDCState *s =I2CDDC (i2c);if (event ==I2C_START_SEND ) { s->firstbyte = true; } + +return 0 ; }static int i2c_ddc_rx (I2CSlave *i2c)
hw/i2c/smbus.c +9 -4
@@ -67,7 +67,7 @@ static void smbus_do_write(SMBusDevice *dev) } } -static void smbus_i2c_event (I2CSlave *s,enum i2c_event event) +static int smbus_i2c_event (I2CSlave *s,enum i2c_event event) {SMBusDevice *dev =SMBUS_DEVICE (s);
@@ -148,6 +148,8 @@ static void smbus_i2c_event(I2CSlave *s, enum i2c_event event)break ; } } + +return 0 ; }static int smbus_i2c_recv (I2CSlave *s)
@@ -249,7 +251,8 @@ int smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command) }i2c_send (bus, command);if (i2c_start_transfer (bus, addr,1 )) { -assert (0 ); +i2c_end_transfer (bus); +return -1 ; } data =i2c_recv (bus);i2c_nack (bus);
@@ -276,7 +279,8 @@ int smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command) }i2c_send (bus, command);if (i2c_start_transfer (bus, addr,1 )) { -assert (0 ); +i2c_end_transfer (bus); +return -1 ; } data =i2c_recv (bus); data |=i2c_recv (bus) <<8 ;
@@ -307,7 +311,8 @@ int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data) }i2c_send (bus, command);if (i2c_start_transfer (bus, addr,1 )) { -assert (0 ); +i2c_end_transfer (bus); +return -1 ; } len =i2c_recv (bus);if (len >32 ) {
hw/input/lm832x.c +3 -1
@@ -383,7 +383,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value) } } -static void lm_i2c_event (I2CSlave *i2c,enum i2c_event event) +static int lm_i2c_event (I2CSlave *i2c,enum i2c_event event) {LM823KbdState *s =LM8323 (i2c);
@@ -397,6 +397,8 @@ static void lm_i2c_event(I2CSlave *i2c, enum i2c_event event)default :break ; } + +return 0 ; }static int lm_i2c_rx (I2CSlave *i2c)
hw/misc/tmp105.c +2 -1
@@ -176,7 +176,7 @@ static int tmp105_tx(I2CSlave *i2c, uint8_t data)return 0 ; } -static void tmp105_event (I2CSlave *i2c,enum i2c_event event) +static int tmp105_event (I2CSlave *i2c,enum i2c_event event) {TMP105State *s =TMP105 (i2c);
@@ -185,6 +185,7 @@ static void tmp105_event(I2CSlave *i2c, enum i2c_event event) } s->len =0 ; +return 0 ; }static int tmp105_post_load (void *opaque,int version_id)
hw/timer/ds1338.c +3 -1
@@ -94,7 +94,7 @@ static void inc_regptr(DS1338State *s) } } -static void ds1338_event (I2CSlave *i2c,enum i2c_event event) +static int ds1338_event (I2CSlave *i2c,enum i2c_event event) {DS1338State *s =DS1338 (i2c);
@@ -113,6 +113,8 @@ static void ds1338_event(I2CSlave *i2c, enum i2c_event event)default :break ; } + +return 0 ; }static int ds1338_recv (I2CSlave *i2c)
hw/timer/twl92230.c +3 -1
@@ -713,12 +713,14 @@ static void menelaus_write(void *opaque, uint8_t addr, uint8_t value) } } -static void menelaus_event (I2CSlave *i2c,enum i2c_event event) +static int menelaus_event (I2CSlave *i2c,enum i2c_event event) {MenelausState *s =TWL92230 (i2c);if (event ==I2C_START_SEND ) s->firstbyte =1 ; + +return 0 ; }static int menelaus_tx (I2CSlave *i2c,uint8_t data)
include/hw/i2c/i2c.h +12 -4
@@ -32,14 +32,22 @@ typedef struct I2CSlaveClass/* Callbacks provided by the device. */ int (*init)(I2CSlave *dev); -/* Master to slave. */ +/* Master to slave. Returns non-zero for a NAK, 0 for success. */ int (*send)(I2CSlave *s,uint8_t data); -/* Slave to master. */ +/* +* Slave to master. This cannot fail, the device should always +* return something here. Negative values probably result in 0xff +* and a possible log from the driver, and shouldn't be used. +*/ int (*recv)(I2CSlave *s); -/* Notify the slave of a bus state change. */ -void (*event)(I2CSlave *s,enum i2c_event event); +/* +* Notify the slave of a bus state change. For start event, +* returns non-zero to NAK an operation. For other events the +* return code is not used and should be zero. +*/ +int (*event)(I2CSlave *s,enum i2c_event event); } I2CSlaveClass;struct I2CSlave
Signature · 1 line
2.7.4
PATCH 8/19 i2c:pm_smbus: Add interrupt handling
In reply to [email protected]From: Corey Minyard <[email protected]>
Add the necessary code so that interrupts actually work from the pm_smbus device.
--- hw/i2c/pm_smbus.c | 14 +++++++++++++- hw/i2c/smbus_ich9.c | 17 +++++++++++++++++ include/hw/i2c/pm_smbus.h | 2 ++ 3 files changed, 32 insertions(+), 1 deletion(-)
hw/i2c/pm_smbus.c +13 -1
@@ -205,6 +205,12 @@ error:return ; } +static bool +smb_irq_value (PMSMBus *s) +{ +return ((s->smb_stat & ~STS_HOST_BUSY ) !=0 ) && (s->smb_ctl &CTL_INTREN ); +} +static void smb_ioport_writeb (void *opaque,hwaddr addr,uint64_t val,unsigned width) {
@@ -300,7 +306,9 @@ static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, } out: -return ; +if (s->set_irq) { + s->set_irq (s,smb_irq_value (s)); + } }static uint64_t smb_ioport_readb (void *opaque,hwaddr addr,unsigned width)
@@ -352,6 +360,10 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width)SMBUS_DPRINTF ("SMB readb port=0x%04" HWADDR_PRIx" val=0x%02x\n" , addr, val); +if (s->set_irq) { + s->set_irq (s,smb_irq_value (s)); + } +return val; }
hw/i2c/smbus_ich9.c +17 -0
@@ -41,6 +41,8 @@typedef struct ICH9SMBState {PCIDevice dev; +bool irq_enabled; +PMSMBus smb; }ICH9SMBState ;
@@ -50,6 +52,7 @@ static const VMStateDescription vmstate_ich9_smbus = { .minimum_version_id = 1, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (dev, ICH9SMBState), +VMSTATE_BOOL (irq_enabled, ICH9SMBState),VMSTATE_STRUCT (smb, ICH9SMBState,1 , pmsmb_vmstate, PMSMBus),VMSTATE_END_OF_LIST () }
@@ -111,11 +114,25 @@ static void ich9_smb_class_init(ObjectClass *klass, void *data) dc->cannot_instantiate_with_device_add_yet = true; } +static void ich9_smb_set_irq (PMSMBus *pmsmb,bool enabled) +{ +ICH9SMBState *s = pmsmb->opaque; + +if (enabled == s->irq_enabled) { +return ; + } + + s->irq_enabled = enabled; +pci_set_irq (&s->dev, enabled); +} +I2CBus *ich9_smb_init (PCIBus *bus,int devfn,uint32_t smb_io_base) {PCIDevice *d =pci_create_simple_multifunction (bus, devfn, true,TYPE_ICH9_SMB_DEVICE );ICH9SMBState *s =ICH9_SMB_DEVICE (d); + s->smb.set_irq = ich9_smb_set_irq; + s->smb.opaque = s;return s->smb.smbus; }
include/hw/i2c/pm_smbus.h +2 -0
@@ -23,6 +23,8 @@ typedef struct PMSMBus {/* Set by the user. */ bool i2c_enable; +void (*set_irq)(struct PMSMBus *s,bool enabled); +void *opaque;/* Internally used by pm_smbus. */
Signature · 1 line
2.7.4
PATCH 9/19 i2c:pm_smbus: Add the ability to force block transfer enable
In reply to [email protected]From: Corey Minyard <[email protected]>
The PIIX4 hardware has block transfer buffer always enabled in the hardware, but the i801 does not. Add a parameter to pm_smbus_init to force on the block transfer so the PIIX4 handler can enable this by default, as it was disabled by default before.
--- hw/acpi/piix4.c | 2 +- hw/i2c/pm_smbus.c | 5 ++++- hw/i2c/smbus_ich9.c | 2 +- hw/isa/vt82c686.c | 2 +- include/hw/i2c/pm_smbus.h | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-)
hw/acpi/piix4.c +1 -1
@@ -512,7 +512,7 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp) pci_conf[0x90 ] = s->smb_io_base |1 ; pci_conf[0x91 ] = s->smb_io_base >>8 ; pci_conf[0xd2 ] =0x09 ; -pm_smbus_init (DEVICE (dev), &s->smb); +pm_smbus_init (DEVICE (dev), &s->smb, true);memory_region_set_enabled (&s->smb.io, pci_conf[0xd2 ] &1 );memory_region_add_subregion (pci_address_space_io (dev), s->smb_io_base, &s->smb.io);
hw/i2c/pm_smbus.c +4 -1
@@ -401,11 +401,14 @@ const VMStateDescription pmsmb_vmstate = { } }; -void pm_smbus_init (DeviceState *parent,PMSMBus *smb) +void pm_smbus_init (DeviceState *parent,PMSMBus *smb,bool force_aux_blk) { smb->op_done = true; smb->reset = pm_smbus_reset; smb->smbus =i2c_init_bus (parent,"i2c" ); +if (force_aux_blk) { + smb->smb_auxctl |=AUX_BLK ; + }memory_region_init_io (&smb->io,OBJECT (parent), &pm_smbus_ops, smb,"pm-smbus" ,64 ); }
hw/i2c/smbus_ich9.c +1 -1
@@ -89,7 +89,7 @@ static void ich9_smbus_realize(PCIDevice *d, Error **errp)pci_set_byte (d->config +ICH9_SMB_HOSTC ,0 );/* TODO bar0, bar1: 64bit BAR support*/ -pm_smbus_init (&d->qdev, &s->smb); +pm_smbus_init (&d->qdev, &s->smb, false);pci_register_bar (d,ICH9_SMB_SMB_BASE_BAR ,PCI_BASE_ADDRESS_SPACE_IO , &s->smb.io); }
hw/isa/vt82c686.c +1 -1
@@ -362,7 +362,7 @@ static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp) pci_conf[0x90 ] = s->smb_io_base |1 ; pci_conf[0x91 ] = s->smb_io_base >>8 ; pci_conf[0xd2 ] =0x90 ; -pm_smbus_init (&s->dev.qdev, &s->smb); +pm_smbus_init (&s->dev.qdev, &s->smb, false);memory_region_add_subregion (get_system_io (), s->smb_io_base, &s->smb.io);apm_init (dev, &s->apm,NULL , s);
include/hw/i2c/pm_smbus.h +1 -1
@@ -33,7 +33,7 @@ typedef struct PMSMBus {bool op_done; } PMSMBus; -void pm_smbus_init (DeviceState *parent,PMSMBus *smb); +void pm_smbus_init (DeviceState *parent,PMSMBus *smb,bool force_aux_blk);extern const VMStateDescription pmsmb_vmstate;
Signature · 1 line
2.7.4
PATCH 4/19 i2c:pm_smbus: Fix the semantics of block I2C transfers
In reply to [email protected]From: Corey Minyard <[email protected]>
The I2C block transfer commands was not implemented correctly, it read a length byte and such like it was an smbus transfer.
So fix the smbus_read_block() and smbus_write_block() functions so they can properly handle I2C transfers, and normal SMBus transfers (for upcoming changes). Pass in a transfer size and a bool to know whether to use the size byte (like SMBus) or use the length given (like I2C).
--- hw/i2c/pm_smbus.c | 10 ++++++++-- hw/i2c/smbus.c | 37 ++++++++++++++++++++++++------------- include/hw/i2c/smbus.h | 17 +++++++++++++++-- 3 files changed, 47 insertions(+), 17 deletions(-)
hw/i2c/pm_smbus.c +8 -2
@@ -115,10 +115,16 @@ static void smb_transaction(PMSMBus *s)break ;case PROT_I2C_BLOCK_DATA :if (read) { - ret =smbus_read_block (bus, addr, cmd, s->smb_data); +int xfersize = s->smb_data0; +if (xfersize >sizeof (s->smb_data)) { + xfersize =sizeof (s->smb_data); + } + ret =smbus_read_block (bus, addr, s->smb_data1, s->smb_data, + xfersize, false, true); goto data8; }else { - ret =smbus_write_block (bus, addr, cmd, s->smb_data, s->smb_data0); + ret =smbus_write_block (bus, addr, cmd, s->smb_data, s->smb_data0, + false); goto done; }break ;
hw/i2c/smbus.c +24 -13
@@ -301,33 +301,42 @@ int smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data)return 0 ; } -int smbus_read_block (I2CBus *bus,uint8_t addr,uint8_t command,uint8_t *data) +int smbus_read_block (I2CBus *bus,uint8_t addr,uint8_t command,uint8_t *data, +int len,bool recv_len,bool send_cmd) { -int len; +int rlen;int i; -if (i2c_start_transfer (bus, addr,0 )) { -return -1 ; +if (send_cmd) { +if (i2c_start_transfer (bus, addr,0 )) { +return -1 ; + } +i2c_send (bus, command); } -i2c_send (bus, command);if (i2c_start_transfer (bus, addr,1 )) { -i2c_end_transfer (bus); +if (send_cmd) { +i2c_end_transfer (bus); + }return -1 ; } - len =i2c_recv (bus); -if (len >32 ) { - len =0 ; +if (recv_len) { + rlen =i2c_recv (bus); + }else { + rlen = len; } -for (i =0 ; i < len; i++) { +if (rlen > len) { + rlen =0 ; + } +for (i =0 ; i < rlen; i++) { data[i] =i2c_recv (bus); }i2c_nack (bus);i2c_end_transfer (bus); -return len; +return rlen; }int smbus_write_block (I2CBus *bus,uint8_t addr,uint8_t command,uint8_t *data, -int len) +int len,bool send_len) {int i;
@@ -338,7 +347,9 @@ int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,return -1 ; }i2c_send (bus, command); -i2c_send (bus, len); +if (send_len) { +i2c_send (bus, len); + }for (i =0 ; i < len; i++) {i2c_send (bus, data[i]); }
include/hw/i2c/smbus.h +15 -2
@@ -73,9 +73,22 @@ int smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command);int smbus_write_byte (I2CBus *bus,uint8_t addr,uint8_t command,uint8_t data);int smbus_read_word (I2CBus *bus,uint8_t addr,uint8_t command);int smbus_write_word (I2CBus *bus,uint8_t addr,uint8_t command,uint16_t data); -int smbus_read_block (I2CBus *bus,uint8_t addr,uint8_t command,uint8_t *data); + +/* +* Do a block transfer from an I2C device. If recv_len is set, then the +* first received byte is a length field and is used to know how much data +* to receive. Otherwise receive "len" bytes. If send_cmd is set, send +* the command byte first before receiving the data. +*/ +int smbus_read_block (I2CBus *bus,uint8_t addr,uint8_t command,uint8_t *data, +int len,bool recv_len,bool send_cmd); + +/* +* Do a block transfer to an I2C device. If send_len is set, send the +* "len" value before the data. +*/ int smbus_write_block (I2CBus *bus,uint8_t addr,uint8_t command,uint8_t *data, -int len); +int len,bool send_len);void smbus_eeprom_init (I2CBus *smbus,int nb_eeprom,const uint8_t *eeprom_spd,int size);
Signature · 1 line
2.7.4
PATCH 12/19 ipmi: Fix SSIF ACPI handling to use the right CRS
In reply to [email protected]From: Corey Minyard <[email protected]>
--- hw/acpi/ipmi.c | 13 +++++++------ hw/i386/acpi-build.c | 2 +- include/hw/acpi/ipmi.h | 2 +- stubs/ipmi.c | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-)
hw/acpi/ipmi.c +7 -6
@@ -13,7 +13,7 @@#include "hw/acpi/acpi.h" #include "hw/acpi/ipmi.h" -static Aml *aml_ipmi_crs (IPMIFwInfo *info) +static Aml *aml_ipmi_crs (IPMIFwInfo *info,const char *resource) {Aml *crs =aml_resource_template ();
@@ -48,7 +48,8 @@ static Aml *aml_ipmi_crs(IPMIFwInfo *info) info->register_spacing, info->register_length));break ;case IPMI_MEMSPACE_SMBUS : -aml_append (crs,aml_return (aml_int (info->base_address))); +aml_append (crs,aml_i2c_serial_bus_device (info->base_address, + resource));break ;default :abort ();
@@ -61,7 +62,7 @@ static Aml *aml_ipmi_crs(IPMIFwInfo *info)return crs; } -static Aml *aml_ipmi_device (IPMIFwInfo *info) +static Aml *aml_ipmi_device (IPMIFwInfo *info,const char *resource) {Aml *dev; uint16_t version = ((info->ipmi_spec_major_revision << 8)
@@ -74,14 +75,14 @@ static Aml *aml_ipmi_device(IPMIFwInfo *info)aml_append (dev,aml_name_decl ("_STR" ,aml_string ("ipmi_%s" , info->interface_name)));aml_append (dev,aml_name_decl ("_UID" ,aml_int (info->uuid))); -aml_append (dev,aml_name_decl ("_CRS" ,aml_ipmi_crs (info))); +aml_append (dev,aml_name_decl ("_CRS" ,aml_ipmi_crs (info, resource)));aml_append (dev,aml_name_decl ("_IFT" ,aml_int (info->interface_type)));aml_append (dev,aml_name_decl ("_SRV" ,aml_int (version)));return dev; } -void build_acpi_ipmi_devices (Aml *scope,BusState *bus) +void build_acpi_ipmi_devices (Aml *scope,BusState *bus,const char *resource) {BusChild *kid;
@@ -101,6 +102,6 @@ void build_acpi_ipmi_devices(Aml *scope, BusState *bus) iic =IPMI_INTERFACE_GET_CLASS (obj);memset (&info,0 ,sizeof (info)); iic->get_fwinfo (ii, &info); -aml_append (scope,aml_ipmi_device (&info)); +aml_append (scope,aml_ipmi_device (&info, resource)); } }
hw/i386/acpi-build.c +1 -1
@@ -1455,7 +1455,7 @@ static void build_isa_devices_aml(Aml *table) }else if (!obj) {error_report ("No ISA bus, unable to define IPMI ACPI data" ); }else { -build_acpi_ipmi_devices (scope,BUS (obj)); +build_acpi_ipmi_devices (scope,BUS (obj),"\\_SB.PCI0.ISA" ); }aml_append (table, scope);
include/hw/acpi/ipmi.h +1 -1
@@ -17,6 +17,6 @@* bus matches the given bus. The resource is the ACPI resource that * contains the IPMI device, this is required for the I2C CRS. */ -void build_acpi_ipmi_devices (Aml *table,BusState *bus); +void build_acpi_ipmi_devices (Aml *table,BusState *bus,const char *resource);#endif /* HW_ACPI_IPMI_H */
stubs/ipmi.c +1 -1
@@ -9,6 +9,6 @@#include "hw/acpi/ipmi.h" -void build_acpi_ipmi_devices (Aml *table,BusState *bus) +void build_acpi_ipmi_devices (Aml *table,BusState *bus,const char *resource) { }
Signature · 1 line
2.7.4
PATCH 16/19 isa: Add an irq device.
In reply to [email protected]From: Corey Minyard <[email protected]>
This uses the new irq interface to allow an ISA irq to be specified by name. This will let other things (like the upcoming smbus alert device) to specify ISA irqs by name.
To create an name ISA irq, add:
-device isa-irq,irq=<name>,irq=<n>
where you will use the name to look up the irq on a following device.
--- hw/isa/Makefile.objs | 2 +- hw/isa/isa-irq.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 hw/isa/isa-irq.c
hw/isa/Makefile.objs +1 -1
@@ -1,4 +1,4 @@ -common-obj-y += isa-bus.o +common-obj-y += isa-bus.o isa-irq.o common-obj-$(CONFIG_APM) += apm.o common-obj-$(CONFIG_I82378) += i82378.o common-obj-$(CONFIG_PC87312) += pc87312.o
hw/isa/isa-irq.c new file +84 -0
84 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 19/19 ipmi_smbus: Add alert capability to the IPMI SSIF code
In reply to [email protected]From: Corey Minyard <[email protected]>
This lets you add "alertname=<name>" to specify an alert device to use for letting the host know that the IPMI device has data ready.
--- hw/ipmi/smbus_ipmi.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-)
hw/ipmi/smbus_ipmi.c +43 -2
@@ -24,6 +24,7 @@#include "qemu/osdep.h" #include "hw/hw.h" #include "hw/i2c/smbus.h" +#include "hw/i2c/smbus_alert.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/ipmi/ipmi.h"
@@ -49,6 +50,8 @@ typedef struct SMBusIPMIDevice {uint8_t inmsg[MAX_IPMI_MSG_SIZE ];uint32_t inlen; +bool irqs_enabled; +/* * This is a response number that we send with the command to make * sure that the response matches the command.
@@ -56,11 +59,15 @@ typedef struct SMBusIPMIDevice {uint8_t waiting_rsp;uint32_t uuid; + +SMBusAlertEntry alert_entry; +SMBusAlertDevice *alertdev; +SMBusAlertDeviceClass *alertdevclass; } SMBusIPMIDevice;static void smbus_ipmi_handle_event (IPMIInterface *ii) { -/* No interrupts, so nothing to do here. */ +/* Nothing to do here, we don't use events for SMBus. */ } static void smbus_ipmi_handle_rsp(IPMIInterface *ii, uint8_t msg_id,
@@ -74,16 +81,27 @@ static void smbus_ipmi_handle_rsp(IPMIInterface *ii, uint8_t msg_id,memcpy (sid->outmsg, rsp, rsp_len); sid->outlen = rsp_len; sid->outpos =0 ; + +if (sid->alertdev && sid->irqs_enabled) { + sid->alertdevclass->alert (sid->alertdev, &sid->alert_entry); + } } }static void smbus_ipmi_set_atn (IPMIInterface *ii,int val,int irq) { -/* This is where PEC would go. */ +SMBusIPMIDevice *sid =SMBUS_IPMI (ii); + +if (sid->alertdev && sid->irqs_enabled) { + sid->alertdevclass->alert (sid->alertdev, &sid->alert_entry); + } }static void smbus_ipmi_set_irq_enable (IPMIInterface *ii,int val) { +SMBusIPMIDevice *sid =SMBUS_IPMI (ii); + + sid->irqs_enabled = val; }static void ipmi_quick_cmd (SMBusDevice *dev,uint8_t read)
@@ -149,6 +167,12 @@ static const VMStateDescription vmstate_smbus_ipmi = { .minimum_version_id = 1, .fields = (VMStateField []) {VMSTATE_UINT8 (waiting_rsp, SMBusIPMIDevice), +VMSTATE_BOOL (irqs_enabled, SMBusIPMIDevice), +VMSTATE_UINT32 (outpos, SMBusIPMIDevice), +VMSTATE_VBUFFER_UINT32 (outmsg, SMBusIPMIDevice,1 ,NULL ,0 , + outlen), +VMSTATE_VBUFFER_UINT32 (inmsg, SMBusIPMIDevice,1 ,NULL ,0 , + inlen),VMSTATE_END_OF_LIST () } };
@@ -165,14 +189,31 @@ static void smbus_ipmi_realize(DeviceState *dev, Error **errp) sid->uuid =ipmi_next_uuid (); +if (sid->alertdev) { + sid->alertdevclass =SMBUS_ALERT_DEVICE_GET_CLASS (sid->alertdev); + } + + sid->alert_entry.val = sid->parent.i2c.address <<1 ; + sid->bmc->intf = ii; } +static void alert_check (Object *obj,const char *name, +Object *val,Error **errp) +{ +/* Always succeed. */ +} +static void smbus_ipmi_init (Object *obj) {SMBusIPMIDevice *sid =SMBUS_IPMI (obj);ipmi_bmc_find_and_link (OBJECT (obj), (Object **) &sid->bmc); + +object_property_add_link (obj,"alert" ,TYPE_SMBUS_ALERT_DEVICE , + (Object **) &sid->alertdev, alert_check, +OBJ_PROP_LINK_UNREF_ON_RELEASE , + &error_abort); }static void smbus_ipmi_get_fwinfo (struct IPMIInterface *ii,IPMIFwInfo *info)
Signature · 1 line
2.7.4
PATCH 7/19 i2c:pm_smbus: Fix state transfer
In reply to [email protected]From: Corey Minyard <[email protected]>
Transfer the state information for the SMBus registers and internal data so it will work on a VM transfer.
--- hw/acpi/piix4.c | 1 + hw/i2c/pm_smbus.c | 19 +++++++++++++++++++ hw/i2c/smbus_ich9.c | 3 ++- include/hw/i2c/pm_smbus.h | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-)
hw/acpi/piix4.c +1 -0
@@ -321,6 +321,7 @@ static const VMStateDescription vmstate_acpi = {VMSTATE_UINT16 (ar.pm1.evt.en, PIIX4PMState),VMSTATE_UINT16 (ar.pm1.cnt.cnt, PIIX4PMState),VMSTATE_STRUCT (apm, PIIX4PMState,0 , vmstate_apm, APMState), +VMSTATE_STRUCT (smb, PIIX4PMState,1 , pmsmb_vmstate, PMSMBus),VMSTATE_TIMER_PTR (ar.tmr.timer, PIIX4PMState),VMSTATE_INT64 (ar.tmr.overflow_time, PIIX4PMState), VMSTATE_STRUCT(ar.gpe, PIIX4PMState, 2, vmstate_gpe, ACPIGPE),
hw/i2c/pm_smbus.c +19 -0
@@ -370,6 +370,25 @@ static const MemoryRegionOps pm_smbus_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; +const VMStateDescription pmsmb_vmstate = { + .name ="pmsmb" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT8 (smb_stat, PMSMBus), +VMSTATE_UINT8 (smb_ctl, PMSMBus), +VMSTATE_UINT8 (smb_cmd, PMSMBus), +VMSTATE_UINT8 (smb_addr, PMSMBus), +VMSTATE_UINT8 (smb_data0, PMSMBus), +VMSTATE_UINT8 (smb_data1, PMSMBus), +VMSTATE_VBUFFER_UINT32 (smb_data, PMSMBus,1 ,NULL ,0 , smb_index), +VMSTATE_UINT8 (smb_auxctl, PMSMBus), +VMSTATE_BOOL (i2c_enable, PMSMBus), +VMSTATE_BOOL (op_done, PMSMBus), +VMSTATE_END_OF_LIST () + } +}; +void pm_smbus_init (DeviceState *parent,PMSMBus *smb) { smb->op_done = true;
hw/i2c/smbus_ich9.c +2 -1
@@ -49,7 +49,8 @@ static const VMStateDescription vmstate_ich9_smbus = { .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField []) { - VMSTATE_PCI_DEVICE(dev, struct ICH9SMBState), +VMSTATE_PCI_DEVICE (dev, ICH9SMBState), +VMSTATE_STRUCT (smb, ICH9SMBState,1 , pmsmb_vmstate, PMSMBus),VMSTATE_END_OF_LIST () } };
include/hw/i2c/pm_smbus.h +2 -0
@@ -33,4 +33,6 @@ typedef struct PMSMBus {void pm_smbus_init (DeviceState *parent,PMSMBus *smb); +extern const VMStateDescription pmsmb_vmstate; +#endif /* PM_SMBUS_H */
Signature · 1 line
2.7.4
PATCH 13/19 pc: Add _enabled to the end of some boolean flags
In reply to [email protected]From: Corey Minyard <[email protected]>
This makes the function of the variable more clear and avoids some conflicts in later patches.
--- hw/i386/pc.c | 37 +++++++++++++++++++------------------ hw/i386/pc_piix.c | 3 ++- hw/i386/pc_q35.c | 6 +++--- include/hw/i386/pc.h | 6 +++--- 4 files changed, 27 insertions(+), 25 deletions(-)
hw/i386/pc.c +19 -18
@@ -2160,46 +2160,46 @@ static void pc_machine_set_nvdimm(Object *obj, bool value, Error **errp) pcms->acpi_nvdimm_state.is_enabled = value; } -static bool pc_machine_get_smbus (Object *obj,Error **errp) +static bool pc_machine_get_smbus_enabled (Object *obj,Error **errp) {PCMachineState *pcms =PC_MACHINE (obj); -return pcms->smbus; +return pcms->smbus_enabled; } -static void pc_machine_set_smbus (Object *obj,bool value,Error **errp) +static void pc_machine_set_smbus_enabled (Object *obj,bool value,Error **errp) {PCMachineState *pcms =PC_MACHINE (obj); - pcms->smbus = value; + pcms->smbus_enabled = value; } -static bool pc_machine_get_sata (Object *obj,Error **errp) +static bool pc_machine_get_sata_enabled (Object *obj,Error **errp) {PCMachineState *pcms =PC_MACHINE (obj); -return pcms->sata; +return pcms->sata_enabled; } -static void pc_machine_set_sata (Object *obj,bool value,Error **errp) +static void pc_machine_set_sata_enabled (Object *obj,bool value,Error **errp) {PCMachineState *pcms =PC_MACHINE (obj); - pcms->sata = value; + pcms->sata_enabled = value; } -static bool pc_machine_get_pit (Object *obj,Error **errp) +static bool pc_machine_get_pit_enabled (Object *obj,Error **errp) {PCMachineState *pcms =PC_MACHINE (obj); -return pcms->pit; +return pcms->pit_enabled; } -static void pc_machine_set_pit (Object *obj,bool value,Error **errp) +static void pc_machine_set_pit_enabled (Object *obj,bool value,Error **errp) {PCMachineState *pcms =PC_MACHINE (obj); - pcms->pit = value; + pcms->pit_enabled = value; }static void pc_machine_initfn (Object *obj)
@@ -2213,9 +2213,9 @@ static void pc_machine_initfn(Object *obj) pcms->acpi_nvdimm_state.is_enabled = false;/* acpi build is enabled by default if machine supports it */ pcms->acpi_build_enabled =PC_MACHINE_GET_CLASS (pcms)->has_acpi_build; - pcms->smbus = true; - pcms->sata = true; - pcms->pit = true; + pcms->smbus_enabled = true; + pcms->sata_enabled = true; + pcms->pit_enabled = true; }static void pc_machine_reset (void )
@@ -2378,13 +2378,14 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pc_machine_get_nvdimm, pc_machine_set_nvdimm, &error_abort);object_class_property_add_bool (oc,PC_MACHINE_SMBUS , - pc_machine_get_smbus, pc_machine_set_smbus, &error_abort); + pc_machine_get_smbus_enabled, pc_machine_set_smbus_enabled, + &error_abort);object_class_property_add_bool (oc,PC_MACHINE_SATA , - pc_machine_get_sata, pc_machine_set_sata, &error_abort); + pc_machine_get_sata_enabled, pc_machine_set_sata_enabled, &error_abort);object_class_property_add_bool (oc,PC_MACHINE_PIT , - pc_machine_get_pit, pc_machine_set_pit, &error_abort); + pc_machine_get_pit_enabled, pc_machine_set_pit_enabled, &error_abort); }static const TypeInfo pc_machine_info = {
hw/i386/pc_piix.c +2 -1
@@ -235,7 +235,8 @@ static void pc_init1(MachineState *machine,/* init basic PC hardware */ pc_basic_device_init (isa_bus, pcms->gsi, &rtc_state, true, - (pcms->vmport !=ON_OFF_AUTO_ON ), pcms->pit,0x4 ); + (pcms->vmport !=ON_OFF_AUTO_ON ), pcms->pit_enabled, +0x4 );pc_nic_init (isa_bus, pci_bus);
hw/i386/pc_q35.c +3 -3
@@ -227,13 +227,13 @@ static void pc_q35_init(MachineState *machine)/* init basic PC hardware */ pc_basic_device_init (isa_bus, pcms->gsi, &rtc_state, !mc->no_floppy, - (pcms->vmport !=ON_OFF_AUTO_ON ), pcms->pit, + (pcms->vmport !=ON_OFF_AUTO_ON ), pcms->pit_enabled,0xff0104 );/* connect pm stuff to lpc */ ich9_lpc_pm_init (lpc,pc_machine_is_smm_enabled (pcms)); -if (pcms->sata) { +if (pcms->sata_enabled) {/* ahci and SATA device, for q35 1 ahci controller is built-in */ ahci = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_SATA1_DEV,
@@ -253,7 +253,7 @@ static void pc_q35_init(MachineState *machine)ehci_create_ich9_with_companions (host_bus,0x1d ); } -if (pcms->smbus) { +if (pcms->smbus_enabled) {/* TODO: Populate SPD eeprom data. */ smbus_eeprom_init(ich9_smb_init(host_bus, PCI_DEVFN(ICH9_SMB_DEV, ICH9_SMB_FUNC),
include/hw/i386/pc.h +3 -3
@@ -63,9 +63,9 @@ struct PCMachineState {AcpiNVDIMMState acpi_nvdimm_state;bool acpi_build_enabled; -bool smbus; -bool sata; -bool pit; +bool smbus_enabled; +bool sata_enabled; +bool pit_enabled;/* RAM information (sizes, addresses, configuration): */ ram_addr_t below_4g_mem_size, above_4g_mem_size;
Signature · 1 line
2.7.4
PATCH 6/19 i2c:pm_smbus: Add block transfer capability
In reply to [email protected]From: Corey Minyard <[email protected]>
There was no block transfer code in pm_smbus.c, and it is needed for some devices. So add it.
This adds both byte-by-byte block transfers and buffered block transfers.
--- hw/i2c/pm_smbus.c | 151 ++++++++++++++++++++++++++++++++++++++++++---- hw/i2c/smbus_ich9.c | 8 ++- include/hw/i2c/pm_smbus.h | 20 +++++- 3 files changed, 164 insertions(+), 15 deletions(-)
hw/i2c/pm_smbus.c +140 -11
@@ -30,6 +30,7 @@#define SMBHSTDAT0 0x05#define SMBHSTDAT1 0x06#define SMBBLKDAT 0x07 +#define SMBAUXCTL 0x0d#define STS_HOST_BUSY (1 << 0)#define STS_INTR (1 << 1)
@@ -58,6 +59,10 @@#define PROT_BLOCK_DATA 5#define PROT_I2C_BLOCK_READ 6 +#define AUX_PEC (1 << 0) +#define AUX_BLK (1 << 1) +#define AUX_MASK 0x3 +/*#define DEBUG*/ #ifdef DEBUG
@@ -127,6 +132,51 @@ static void smb_transaction(PMSMBus *s) goto error; }break ; +case PROT_BLOCK_DATA : +if (read) { + ret =smbus_read_block (bus, addr, cmd, s->smb_data, +sizeof (s->smb_data), !s->i2c_enable, + !s->i2c_enable); +if (ret <0 ) { + goto error; + } + s->smb_index =0 ; + s->op_done = false; +if (s->smb_auxctl &AUX_BLK ) { + s->smb_stat |=STS_INTR ; + }else { + s->smb_blkdata = s->smb_data[0 ]; + s->smb_stat |=STS_HOST_BUSY |STS_BYTE_DONE ; + } + s->smb_data0 = ret; + goto out; + }else { +if (s->smb_auxctl &AUX_BLK ) { +if (s->smb_index != s->smb_data0) { + s->smb_index =0 ; + goto error; + } +/* Data is already all written to the queue, just do +the operation. */ + s->smb_index =0 ; + ret =smbus_write_block (bus, addr, cmd, s->smb_data, + s->smb_data0, !s->i2c_enable); +if (ret <0 ) { + goto error; + } + s->op_done = true; + s->smb_stat |=STS_INTR ; + s->smb_stat &= ~STS_HOST_BUSY ; + }else { + s->op_done = false; + s->smb_stat |=STS_HOST_BUSY |STS_BYTE_DONE ; + s->smb_data[0 ] = s->smb_blkdata; + s->smb_index =0 ; + ret =0 ; + } + goto out; + } +break ;default : goto error; }
@@ -146,13 +196,13 @@ done:if (ret <0 ) { goto error; } - s->smb_stat |=STS_BYTE_DONE |STS_INTR ; + s->smb_stat |=STS_INTR ; +out:return ; error: s->smb_stat |=STS_DEV_ERR ;return ; - } static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val,
@@ -164,14 +214,61 @@ static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, " val=0x%02" PRIx64 "\n", addr, val);switch (addr) {case SMBHSTSTS : - s->smb_stat = (~(val &0xff )) & s->smb_stat; - s->smb_index =0 ; + s->smb_stat &= ~(val & ~STS_HOST_BUSY ); +if (!s->op_done && !(s->smb_auxctl &AUX_BLK )) { +uint8_t read = s->smb_addr &0x01 ; + + s->smb_index++; +if (!read && s->smb_index == s->smb_data0) { +uint8_t prot = (s->smb_ctl >>2 ) &0x07 ; +uint8_t cmd = s->smb_cmd; +uint8_t addr = s->smb_addr >>1 ; +int ret; + +if (prot ==PROT_I2C_BLOCK_READ ) { + s->smb_stat |=STS_DEV_ERR ; + goto out; + } + + ret =smbus_write_block (s->smbus, addr, cmd, s->smb_data, + s->smb_data0, !s->i2c_enable); +if (ret <0 ) { + s->smb_stat |=STS_DEV_ERR ; + goto out; + } + s->op_done = true; + s->smb_stat |=STS_INTR ; + s->smb_stat &= ~STS_HOST_BUSY ; + }else if (!read) { + s->smb_data[s->smb_index] = s->smb_blkdata; + s->smb_stat |=STS_BYTE_DONE ; + }else if (s->smb_ctl &CTL_LAST_BYTE ) { + s->op_done = true; + s->smb_blkdata = s->smb_data[s->smb_index]; + s->smb_index =0 ; + s->smb_stat |=STS_INTR ; + s->smb_stat &= ~STS_HOST_BUSY ; + }else { + s->smb_blkdata = s->smb_data[s->smb_index]; + s->smb_stat |=STS_BYTE_DONE ; + } + }break ;case SMBHSTCNT : - s->smb_ctl = val; -if (s->smb_ctl &CTL_START ) { + s->smb_ctl = val & ~CTL_START ;/* CTL_START always reads 0 */ +if (val &CTL_START ) { +if (!s->op_done) { + s->smb_index =0 ; + s->op_done = true; + }smb_transaction (s); } +if (s->smb_ctl &CTL_KILL ) { + s->op_done = true; + s->smb_index =0 ; + s->smb_stat |=STS_FAILED ; + s->smb_stat &= ~STS_HOST_BUSY ; + }break ;case SMBHSTCMD : s->smb_cmd = val;
@@ -186,13 +283,24 @@ static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, s->smb_data1 = val;break ;case SMBBLKDAT : - s->smb_data[s->smb_index++] = val; -if (s->smb_index >31 ) +if (s->smb_index >=PM_SMBUS_MAX_MSG_SIZE ) { s->smb_index =0 ; + } +if (s->smb_auxctl &AUX_BLK ) { + s->smb_data[s->smb_index++] = val; + }else { + s->smb_blkdata = val; + } +break ; +case SMBAUXCTL : + s->smb_auxctl = val &AUX_MASK ;break ;default :break ; } + + out: +return ; }static uint64_t smb_ioport_readb (void *opaque,hwaddr addr,unsigned width)
@@ -205,7 +313,6 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width) val = s->smb_stat;break ;case SMBHSTCNT : - s->smb_index =0 ; val = s->smb_ctl &CTL_RETURN_MASK ;break ;case SMBHSTCMD :
@@ -221,9 +328,22 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width) val = s->smb_data1;break ;case SMBBLKDAT : - val = s->smb_data[s->smb_index++]; -if (s->smb_index >31 ) +if (s->smb_index >=PM_SMBUS_MAX_MSG_SIZE ) { s->smb_index =0 ; + } +if (s->smb_auxctl &AUX_BLK ) { + val = s->smb_data[s->smb_index++]; +if (!s->op_done && s->smb_index == s->smb_data0) { + s->op_done = true; + s->smb_index =0 ; + s->smb_stat &= ~STS_HOST_BUSY ; + } + }else { + val = s->smb_blkdata; + } +break ; +case SMBAUXCTL : + val = s->smb_auxctl;break ;default : val =0 ;
@@ -235,6 +355,13 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width)return val; } +static void pm_smbus_reset (PMSMBus *s) +{ + s->op_done = true; + s->smb_index =0 ; + s->smb_stat =0 ; +} +static const MemoryRegionOps pm_smbus_ops = { .read = smb_ioport_readb, .write = smb_ioport_writeb,
@@ -245,6 +372,8 @@ static const MemoryRegionOps pm_smbus_ops = {void pm_smbus_init (DeviceState *parent,PMSMBus *smb) { + smb->op_done = true; + smb->reset = pm_smbus_reset; smb->smbus =i2c_init_bus (parent,"i2c" );memory_region_init_io (&smb->io,OBJECT (parent), &pm_smbus_ops, smb,"pm-smbus" ,64 );
hw/i2c/smbus_ich9.c +6 -2
@@ -62,12 +62,16 @@ static void ich9_smbus_write_config(PCIDevice *d, uint32_t address,pci_default_write_config (d, address, val, len);if (range_covers_byte (address, len,ICH9_SMB_HOSTC )) {uint8_t hostc = s->dev.config[ICH9_SMB_HOSTC ]; -if ((hostc &ICH9_SMB_HOSTC_HST_EN ) && - !(hostc &ICH9_SMB_HOSTC_I2C_EN )) { +if (hostc &ICH9_SMB_HOSTC_HST_EN ) {memory_region_set_enabled (&s->smb.io, true); }else {memory_region_set_enabled (&s->smb.io, false); } + s->smb.i2c_enable = (hostc &ICH9_SMB_HOSTC_I2C_EN ) !=0 ; +if (hostc &ICH9_SMB_HOSTC_SSRESET ) { + s->smb.reset (&s->smb); + s->dev.config[ICH9_SMB_HOSTC ] &= ~ICH9_SMB_HOSTC_SSRESET ; + } } }
include/hw/i2c/pm_smbus.h +18 -2
@@ -1,6 +1,8 @@ #ifndef PM_SMBUS_H #define PM_SMBUS_H +#define PM_SMBUS_MAX_MSG_SIZE 32 + typedef struct PMSMBus { I2CBus *smbus; MemoryRegion io;
@@ -11,8 +13,22 @@ typedef struct PMSMBus {uint8_t smb_addr;uint8_t smb_data0;uint8_t smb_data1; -uint8_t smb_data[32 ]; -uint8_t smb_index; +uint8_t smb_data[PM_SMBUS_MAX_MSG_SIZE ]; +uint8_t smb_blkdata; +uint8_t smb_auxctl; +uint32_t smb_index; + +/* Set by pm_smbus.c */ +void (*reset)(struct PMSMBus *s); + +/* Set by the user. */ +bool i2c_enable; + +/* Internally used by pm_smbus. */ + +/* Set on block transfers after the last byte has been read, so the +INTR bit can be set at the right time. */ +bool op_done; } PMSMBus;void pm_smbus_init (DeviceState *parent,PMSMBus *smb);
Signature · 1 line
2.7.4
PATCH 11/19 acpi: Add i2c serial bus CRS handling
In reply to [email protected]From: Corey Minyard <[email protected]>
--- hw/acpi/aml-build.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 18 ++++++++++++++++++ 2 files changed, 58 insertions(+)
hw/acpi/aml-build.c +40 -0
@@ -1607,3 +1607,43 @@ void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, numamem->base_addr =cpu_to_le64 (base); numamem->range_length =cpu_to_le64 (len); } + +/* ACPI 5.0: 6.4.3.8.2 Serial Bus Connection Descriptors */ +static Aml *aml_serial_bus_device (uint8_t serial_bus_type,uint8_t flags, +uint16_t type_flags, +uint8_t revid,uint16_t data_length, +uint16_t resource_source_len) +{ +Aml *var =aml_alloc (); +uint16_t length = data_length + resource_source_len +9 ; + +build_append_byte (var->buf,0x8e );/* Serial Bus Connection Descriptor */ +build_append_int_noprefix (var->buf, length,sizeof (length)); +build_append_byte (var->buf,1 );/* Revision ID */ +build_append_byte (var->buf,0 );/* Resource Source Index */ +build_append_byte (var->buf, serial_bus_type);/* Serial Bus Type */ +build_append_byte (var->buf, flags);/* General Flags */ +build_append_int_noprefix (var->buf, type_flags,/* Type Specific Flags */ +sizeof (type_flags)); +build_append_byte (var->buf, revid);/* Type Specification Revision ID */ +build_append_int_noprefix (var->buf, data_length,sizeof (data_length)); + +return var; +} + +/* ACPI 5.0: 6.4.3.8.2.1 I2C Serial Bus Connection Resource Descriptor */ +Aml *aml_i2c_serial_bus_device (uint16_t address,const char *resource_source) +{ +uint16_t resource_source_len =strlen (resource_source) +1 ; +Aml *var =aml_serial_bus_device (AML_SERIAL_BUS_TYPE_I2C ,0 ,0 ,1 , +6 , resource_source_len); + +/* Connection Speed. Just set to 100K for now, it doesn't really matter. */ +build_append_int_noprefix (var->buf,100000 ,4 ); +build_append_int_noprefix (var->buf, address,sizeof (address)); + +/* This is a string, not a name, so just copy it directly in. */ +g_array_append_vals (var->buf, resource_source, resource_source_len); + +return var; +}
include/hw/acpi/aml-build.h +18 -0
@@ -213,6 +213,23 @@ struct AcpiBuildTables {BIOSLinker *linker; } AcpiBuildTables; +/* +* ACPI 5.0: 6.4.3.8.2 Serial Bus Connection Descriptors +* Serial Bus Type +*/ +#define AML_SERIAL_BUS_TYPE_I2C 1 +#define AML_SERIAL_BUS_TYPE_SPI 2 +#define AML_SERIAL_BUS_TYPE_UART 3 + +/* +* ACPI 5.0: 6.4.3.8.2 Serial Bus Connection Descriptors +* General Flags +*/ +/* Slave Mode */ +#define AML_SERIAL_BUS_FLAG_MASTER_DEVICE (1 << 0) +/* Consumer/Producer */ +#define AML_SERIAL_BUS_FLAG_CONSUME_ONLY (1 << 1) +/** * init_aml_allocator: *
@@ -337,6 +354,7 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed,Aml *aml_dma (AmlDmaType typ,AmlDmaBusMaster bm,AmlTransferSize sz,uint8_t channel);Aml *aml_sleep (uint64_t msec); +Aml *aml_i2c_serial_bus_device (uint16_t address,const char *resource_source);/* Block AML object primitives */ Aml *aml_scope (const char *name_format, ...)GCC_FMT_ATTR (1 ,2 );
Signature · 1 line
2.7.4
PATCH 18/19 i2c: Add an SMBus alert device.
In reply to [email protected]From: Corey Minyard <[email protected]>
This adds a device that conforms to the SMBus alert extension. This allows other I2C devices to register with this device so that when they have data ready, it will interrupt the processor and allow the processor to read from the alert device to see which i2c device has data.
To use this, you must first create a named irq and then create this device with:
-device smbus-alert,name=<name>,irqname=<irqname>,address=..,bus=..
where the name is the value that other I2C devices will use to attach to this device and the irqname is the name of the named irq that will be raised when the data is ready.
--- hw/i2c/Makefile.objs | 2 +- hw/i2c/smbus_alert.c | 130 +++++++++++++++++++++++++++++++++++++++++++ include/hw/i2c/smbus.h | 1 + include/hw/i2c/smbus_alert.h | 65 ++++++++++++++++++++++ 4 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 hw/i2c/smbus_alert.c create mode 100644 include/hw/i2c/smbus_alert.h
hw/i2c/Makefile.objs +1 -1
@@ -1,4 +1,4 @@ -common-obj-y += core.o smbus.o smbus_eeprom.o +common-obj-y += core.o smbus.o smbus_eeprom.o smbus_alert.o common-obj-$(CONFIG_DDC) += i2c-ddc.o common-obj-$(CONFIG_VERSATILE_I2C) += versatile_i2c.o common-obj-$(CONFIG_ACPI_X86) += smbus_ich9.o
hw/i2c/smbus_alert.c new file +130 -0
130 lines not on this page · raw message
include/hw/i2c/smbus.h +1 -0
@@ -26,6 +26,7 @@*/ #include "hw/i2c/i2c.h" +#include "qemu/queue.h" #define TYPE_SMBUS_DEVICE "smbus-device"#define SMBUS_DEVICE (obj) \
include/hw/i2c/smbus_alert.h new file +65 -0
65 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 14/19 pc: Add an SMB0 ACPI device to q35
In reply to [email protected]From: Corey Minyard <[email protected]>
This is so I2C devices can be found in the ACPI namespace. Currently that's only IPMI, but devices can be easily added now.
Adding the devices required some PCI information, and the bus itself to be added to the PCMachineState structure.
Note that this only works on Q35, the ACPI for PIIX4 is not capable of handling an SMBus device.
--- hw/i386/acpi-build.c | 15 +++++++++++++++ hw/i386/pc_piix.c | 12 ++++++------ hw/i386/pc_q35.c | 9 +++++---- include/hw/i386/pc.h | 2 ++ tests/acpi-test-data/q35/DSDT | Bin 8770 -> 8808 bytes tests/acpi-test-data/q35/DSDT.bridge | Bin 8787 -> 8825 bytes tests/acpi-test-data/q35/DSDT.cphp | Bin 9233 -> 9271 bytes tests/acpi-test-data/q35/DSDT.ipmibt | Bin 8845 -> 8883 bytes 8 files changed, 28 insertions(+), 10 deletions(-)
hw/i386/acpi-build.c +15 -0
@@ -1975,6 +1975,18 @@ static Aml *build_q35_osc_method(void)return method; } +static void build_smb0 (Aml *table,I2CBus *smbus,int devnr,int func) +{ +Aml *scope =aml_scope ("_SB.PCI0" ); +Aml *dev =aml_device ("SMB0" ); + +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("APP0005" ))); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (devnr <<16 | func))); +build_acpi_ipmi_devices (dev,BUS (smbus),"\\_SB.PCI0.SMB0" ); +aml_append (scope, dev); +aml_append (table, scope); +} + static void build_dsdt(GArray *table_data, BIOSLinker *linker, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -2038,6 +2050,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,build_q35_isa_bridge (dsdt);build_isa_devices_aml (dsdt);build_q35_pci0_int (dsdt); +if (pcms->smbus && !pcmc->do_not_add_smb_acpi) { +build_smb0 (dsdt, pcms->smbus,ICH9_SMB_DEV ,ICH9_SMB_FUNC ); + } }if (pcmc->legacy_cpu_hotplug) {
hw/i386/pc_piix.c +6 -6
@@ -274,15 +274,14 @@ static void pc_init1(MachineState *machine,if (pcmc->pci_enabled && acpi_enabled) {DeviceState *piix4_pm; -I2CBus *smbus; smi_irq =qemu_allocate_irq (pc_acpi_smi_interrupt, first_cpu,0 );/* TODO: Populate SPD eeprom data. */ - smbus =piix4_pm_init (pci_bus, piix3_devfn +3 ,0xb100 , - pcms->gsi[9 ], smi_irq, -pc_machine_is_smm_enabled (pcms), - &piix4_pm); -smbus_eeprom_init (smbus,8 ,NULL ,0 ); + pcms->smbus =piix4_pm_init (pci_bus, piix3_devfn +3 ,0xb100 , + pcms->gsi[9 ], smi_irq, +pc_machine_is_smm_enabled (pcms), + &piix4_pm); +smbus_eeprom_init (pcms->smbus,8 ,NULL ,0 ); object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, TYPE_HOTPLUG_HANDLER,
@@ -466,6 +465,7 @@ static void pc_i440fx_2_6_machine_options(MachineClass *m)PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_i440fx_2_7_machine_options (m); pcmc->legacy_cpu_hotplug = true; + pcmc->do_not_add_smb_acpi = true;SET_MACHINE_COMPAT (m,PC_COMPAT_2_6 ); }
hw/i386/pc_q35.c +5 -4
@@ -255,10 +255,10 @@ static void pc_q35_init(MachineState *machine)if (pcms->smbus_enabled) {/* TODO: Populate SPD eeprom data. */ -smbus_eeprom_init (ich9_smb_init (host_bus, -PCI_DEVFN (ICH9_SMB_DEV ,ICH9_SMB_FUNC ), -0xb100 ), -8 ,NULL ,0 ); + pcms->smbus =ich9_smb_init (host_bus, +PCI_DEVFN (ICH9_SMB_DEV ,ICH9_SMB_FUNC ), +0xb100 ); +smbus_eeprom_init (pcms->smbus,8 ,NULL ,0 ); }pc_cmos_init (pcms, idebus[0 ], idebus[1 ], rtc_state);
@@ -326,6 +326,7 @@ static void pc_q35_2_6_machine_options(MachineClass *m)PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_q35_2_7_machine_options (m); pcmc->legacy_cpu_hotplug = true; + pcmc->do_not_add_smb_acpi = true;SET_MACHINE_COMPAT (m,PC_COMPAT_2_6 ); }
include/hw/i386/pc.h +2 -0
@@ -52,6 +52,7 @@ struct PCMachineState {HotplugHandler *acpi_dev;ISADevice *rtc;PCIBus *bus; +I2CBus *smbus;FWCfgState *fw_cfg;qemu_irq *gsi;
@@ -136,6 +137,7 @@ struct PCMachineClass {bool rsdp_in_ram;int legacy_acpi_table_size;unsigned acpi_data_size; +bool do_not_add_smb_acpi;/* SMBIOS compat: */ bool smbios_defaults;
tests/acpi-test-data/q35/DSDT binary +0 -0
tests/acpi-test-data/q35/DSDT.bridge binary +0 -0
tests/acpi-test-data/q35/DSDT.cphp binary +0 -0
tests/acpi-test-data/q35/DSDT.ipmibt binary +0 -0
Signature · 1 line
2.7.4
PATCH 15/19 hw: Add an IRQ interface
In reply to [email protected]From: Corey Minyard <[email protected]>
This allows IRQs to be created that can be found by other devices so they can be used without having a direct tie to the irq.
--- hw/core/Makefile.objs | 1 + hw/core/irqif.c | 39 +++++++++++++++++++++++++++++++++++++++ include/hw/irqif.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 hw/core/irqif.c create mode 100644 include/hw/irqif.h
hw/core/Makefile.objs +1 -0
@@ -6,6 +6,7 @@ common-obj-y += fw-path-provider.o common-obj-y += irq.o common-obj-y += hotplug.o obj-y += nmi.o +common-obj-y += irqif.o common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o common-obj-$(CONFIG_XILINX_AXI) += stream.o
hw/core/irqif.c new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Interrupt Interface class +* +* Copyright (c) 2015,2016 Corey Minyard, MontaVista Software, LLC +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include "qemu/osdep.h" +#include "hw/irqif.h" + +static TypeInfo irq_interface_type_info = { + .name =TYPE_IRQ_INTERFACE , + .parent =TYPE_INTERFACE , + .class_size =sizeof (IRQInterfaceClass), +}; + +static void ipmi_register_types (void ) +{ +type_register_static (&irq_interface_type_info); +} + +type_init (ipmi_register_types)
include/hw/irqif.h new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 10/19 ipmi: Add an SMBus IPMI interface
In reply to [email protected]From: Corey Minyard <[email protected]>
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/smbus_ipmi.c | 230 +++++++++++++++++++++++++++++++++++++ 4 files changed, 233 insertions(+) create mode 100644 hw/ipmi/smbus_ipmi.c
default-configs/i386-softmmu.mak +1 -0
@@ -14,6 +14,7 @@ CONFIG_IPMI_LOCAL=y CONFIG_IPMI_EXTERN=y CONFIG_ISA_IPMI_KCS=y CONFIG_ISA_IPMI_BT=y +CONFIG_IPMI_SSIF=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -14,6 +14,7 @@ CONFIG_IPMI_LOCAL=y CONFIG_IPMI_EXTERN=y CONFIG_ISA_IPMI_KCS=y CONFIG_ISA_IPMI_BT=y +CONFIG_IPMI_SSIF=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/ipmi/Makefile.objs +1 -0
@@ -3,3 +3,4 @@ common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_sim.o common-obj-$(CONFIG_IPMI_EXTERN) += ipmi_bmc_extern.o common-obj-$(CONFIG_ISA_IPMI_KCS) += isa_ipmi_kcs.o common-obj-$(CONFIG_ISA_IPMI_BT) += isa_ipmi_bt.o +common-obj-$(CONFIG_IPMI_SSIF) += smbus_ipmi.o
hw/ipmi/smbus_ipmi.c new file +230 -0
230 lines not on this page · raw message
Signature · 1 line
2.7.4