Misc NPCM7XX patches
v3 cover Misc NPCM7XX patches
This patch set contains a few bug fixes and I2C devices for some NPCM7XX boards.
Patch 1~2 fix a problem that causes the SMBus module to behave incorrectly when it's in FIFO mode and trying to receive more than 16 bytes at a time.
Patch 3 fixes a error in a register for ADC module.
Patch 4 makes the ADC input to be R/W instead of write only. It allows a test system to read these via QMP and has no negative effect.
Patch 5 modifies at24c_eeprom_init in NPCM7xx boards so that it can fit more use cases.
Patch 6 uses the function defined in patch 5 to add the EEPROM and other I2C devices for Quanta GBS board.
-- Changes since v2:
1. Dropped patch 7.
2. Drop an extra variable in patch 5.
-- Changes since v1:
1. Rewrote patch 5 to implement the function in NPCM7xx board file instead of the EEPROM device file.
2. Slightly modify patch 6 to adapt to the changes and QEMU comment style.
3. Squash patch 7 into patch 5 to make it compile.
4. Add a new patch 7.
Hao Wu (5):
hw/i2c: Clear ACK bit in NPCM7xx SMBus module hw/i2c: Read FIFO during RXF_CTL change in NPCM7XX SMBus hw/adc: Fix CONV bit in NPCM7XX ADC CON register hw/adc: Make adci[*] R/W in NPCM7XX ADC
hw/nvram: Update at24c EEPROM init function in NPCM7xx boards
Patrick Venture (1):
hw/arm: quanta-gbs-bmc add i2c devices
hw/adc/npcm7xx_adc.c | 4 +- hw/arm/npcm7xx_boards.c | 96 ++++++++++++++++++++-------------- hw/i2c/npcm7xx_smbus.c | 8 +-- tests/qtest/npcm7xx_adc-test.c | 2 +- 4 files changed, 65 insertions(+), 45 deletions(-)
Signature · 1 line
2.33.1.1089.g2158813163f-goog
PATCH v3 1/6 hw/i2c: Clear ACK bit in NPCM7xx SMBus module
The ACK bit in NPCM7XX SMBus module should be cleared each time it sends out a NACK signal. This patch fixes the bug that it fails to do so.
--- hw/i2c/npcm7xx_smbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i2c/npcm7xx_smbus.c +1 -1
@@ -270,7 +270,7 @@ static void npcm7xx_smbus_recv_byte(NPCM7xxSMBusState *s)if (s->st &NPCM7XX_SMBCTL1_ACK ) {trace_npcm7xx_smbus_nack (DEVICE (s)->canonical_path);i2c_nack (s->bus); - s->st &=NPCM7XX_SMBCTL1_ACK ; + s->st &= ~NPCM7XX_SMBCTL1_ACK ; }trace_npcm7xx_smbus_recv_byte ((DEVICE (s)->canonical_path), s->sda);npcm7xx_smbus_update_irq (s);
Signature · 1 line
2.33.1.1089.g2158813163f-goog
PATCH v3 2/6 hw/i2c: Read FIFO during RXF_CTL change in NPCM7XX SMBus
In reply to Hao WuOriginally we read in from SMBus when RXF_STS is cleared. However, the driver clears RXF_STS before setting RXF_CTL, causing the SM bus module to read incorrect amount of bytes in FIFO mode when the number of bytes read changed. This patch fixes this issue.
--- hw/i2c/npcm7xx_smbus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/i2c/npcm7xx_smbus.c +3 -3
@@ -637,9 +637,6 @@ static void npcm7xx_smbus_write_rxf_sts(NPCM7xxSMBusState *s, uint8_t value) {if (value &NPCM7XX_SMBRXF_STS_RX_THST ) { s->rxf_sts &= ~NPCM7XX_SMBRXF_STS_RX_THST ; -if (s->status ==NPCM7XX_SMBUS_STATUS_RECEIVING ) { -npcm7xx_smbus_recv_fifo (s); - } } }
@@ -651,6 +648,9 @@ static void npcm7xx_smbus_write_rxf_ctl(NPCM7xxSMBusState *s, uint8_t value) new_ctl =KEEP_OLD_BIT (s->rxf_ctl, new_ctl,NPCM7XX_SMBRXF_CTL_LAST ); } s->rxf_ctl = new_ctl; +if (s->status ==NPCM7XX_SMBUS_STATUS_RECEIVING ) { +npcm7xx_smbus_recv_fifo (s); + } }static uint64_t npcm7xx_smbus_read (void *opaque,hwaddr offset,unsigned size)
Signature · 1 line
2.33.1.1089.g2158813163f-goog
PATCH v3 3/6 hw/adc: Fix CONV bit in NPCM7XX ADC CON register
In reply to Hao WuThe correct bit for the CONV bit in NPCM7XX ADC is bit 13. This patch fixes that in the module, and also lower the IRQ when the guest is done handling an interrupt event from the ADC module.
--- hw/adc/npcm7xx_adc.c | 2 +- tests/qtest/npcm7xx_adc-test.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/adc/npcm7xx_adc.c +1 -1
@@ -36,7 +36,7 @@ REG32(NPCM7XX_ADC_DATA, 0x4)#define NPCM7XX_ADC_CON_INT BIT(18)#define NPCM7XX_ADC_CON_EN BIT(17)#define NPCM7XX_ADC_CON_RST BIT(16) -#define NPCM7XX_ADC_CON_CONV BIT(14) +#define NPCM7XX_ADC_CON_CONV BIT(13)#define NPCM7XX_ADC_CON_DIV (rv) extract32(rv, 1, 8)#define NPCM7XX_ADC_MAX_RESULT 1023
tests/qtest/npcm7xx_adc-test.c +1 -1
@@ -50,7 +50,7 @@#define CON_INT BIT(18)#define CON_EN BIT(17)#define CON_RST BIT(16) -#define CON_CONV BIT(14) +#define CON_CONV BIT(13)#define CON_DIV (rv) extract32(rv, 1, 8)#define FST_RDST BIT(1)
Signature · 1 line
2.33.1.1089.g2158813163f-goog
PATCH v3 4/6 hw/adc: Make adci[*] R/W in NPCM7XX ADC
In reply to Hao WuOur sensor test requires both reading and writing from a sensor's QOM property. So we need to make the input of ADC module R/W instead of write only for that to work.
--- hw/adc/npcm7xx_adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/adc/npcm7xx_adc.c +1 -1
@@ -242,7 +242,7 @@ static void npcm7xx_adc_init(Object *obj)for (i =0 ; i <NPCM7XX_ADC_NUM_INPUTS ; ++i) {object_property_add_uint32_ptr (obj,"adci[*]" , - &s->adci[i],OBJ_PROP_FLAG_WRITE ); + &s->adci[i],OBJ_PROP_FLAG_READWRITE ); }object_property_add_uint32_ptr (obj,"vref" , &s->vref,OBJ_PROP_FLAG_WRITE );
Signature · 1 line
2.33.1.1089.g2158813163f-goog
PATCH v3 5/6 hw/nvram: Update at24c EEPROM init function in NPCM7xx boards
In reply to Hao WuWe made 3 changes to the at24c_eeprom_init function in npcm7xx_boards.c:
1. We allow the function to take a I2CBus* as parameter. This allows us to attach an EEPROM device behind an I2C mux which is not possible with the old method.
2. We make at24c EEPROMs are backed by drives so that we can specify the content of the EEPROMs.
3. Instead of using i2c address as unit number, This patch assigns unique unit numbers for each eeproms in each board. This avoids conflict in providing multiple eeprom contents with the same address. In the old method if we specify two drives with the same unit number, the following error will occur: Device with id 'none85' exists.
--- hw/arm/npcm7xx_boards.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
hw/arm/npcm7xx_boards.c +9 -5
@@ -107,13 +107,17 @@ static I2CBus *npcm7xx_i2c_get_bus(NPCM7xxState *soc, uint32_t num)return I2C_BUS (qdev_get_child_bus (DEVICE (&soc->smbus[num]),"i2c-bus" )); } -static void at24c_eeprom_init (NPCM7xxState *soc,int bus,uint8_t addr, -uint32_t rsize) +static void at24c_eeprom_init (I2CBus *i2c_bus,int bus,uint8_t addr, +uint32_t rsize,int unit_number) { -I2CBus *i2c_bus =npcm7xx_i2c_get_bus (soc, bus);I2CSlave *i2c_dev =i2c_slave_new ("at24c-eeprom" , addr);DeviceState *dev =DEVICE (i2c_dev); +DriveInfo *dinfo; + dinfo =drive_get (IF_NONE , bus, unit_number); +if (dinfo) { +qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (dinfo)); + }qdev_prop_set_uint32 (dev,"rom-size" , rsize);i2c_slave_realize_and_unref (i2c_dev, i2c_bus, &error_abort); }
@@ -220,8 +224,8 @@ static void quanta_gsj_i2c_init(NPCM7xxState *soc)i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,3 ),"tmp105" ,0x5c );i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,4 ),"tmp105" ,0x5c ); -at24c_eeprom_init (soc,9 ,0x55 ,8192 ); -at24c_eeprom_init (soc,10 ,0x55 ,8192 ); +at24c_eeprom_init (npcm7xx_i2c_get_bus (soc,9 ),9 ,0x55 ,8192 ,0 ); +at24c_eeprom_init (npcm7xx_i2c_get_bus (soc,10 ),10 ,0x55 ,8192 ,1 );/* * i2c-11:
Signature · 1 line
2.33.1.1089.g2158813163f-goog
PATCH v3 6/6 hw/arm: quanta-gbs-bmc add i2c devices
In reply to Hao WuFrom: Patrick Venture <[email protected]>
Adds supported i2c devices to the quanta-gbc-bmc board.
--- hw/arm/npcm7xx_boards.c | 82 ++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 33 deletions(-)
hw/arm/npcm7xx_boards.c +49 -33
@@ -257,10 +257,12 @@ static void quanta_gsj_fan_init(NPCM7xxMachine *machine, NPCM7xxState *soc)static void quanta_gbs_i2c_init (NPCM7xxState *soc) { +I2CSlave *i2c_mux; + +/* i2c-0: */ +i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,0 ),TYPE_PCA9546 ,0x71 ); +/* -* i2c-0: -* pca9546@71 -* * i2c-1: * pca9535@24 * pca9535@20
@@ -269,46 +271,60 @@ static void quanta_gbs_i2c_init(NPCM7xxState *soc)* pca9535@23 * pca9535@25 * pca9535@26 -* -* i2c-2: -* sbtsi@4c -* -* i2c-5: -* atmel,24c64@50 mb_fru -* pca9546@71 -* - channel 0: max31725@54 -* - channel 1: max31725@55 -* - channel 2: max31725@5d -* atmel,24c64@51 fan_fru -* - channel 3: atmel,24c64@52 hsbp_fru -* +*/ + +/* i2c-2: sbtsi@4c */ + +/* i2c-5: */ +/* mb_fru */ +at24c_eeprom_init (npcm7xx_i2c_get_bus (soc,5 ),5 ,0x50 ,8192 ,0 ); + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,5 ), +TYPE_PCA9546 ,0x71 ); +/* max31725 is tmp105 compatible. */ +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,0 ),"tmp105" ,0x54 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,1 ),"tmp105" ,0x55 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,2 ),"tmp105" ,0x5d ); +/* fan_fru */ +at24c_eeprom_init (pca954x_i2c_get_bus (i2c_mux,2 ),5 ,0x51 ,8192 ,1 ); +/* hsbp_fru */ +at24c_eeprom_init (pca954x_i2c_get_bus (i2c_mux,3 ),5 ,0x52 ,8192 ,2 ); + +/* * i2c-6: * pca9545@73 * * i2c-7: * pca9545@72 -* -* i2c-8: -* adi,adm1272@10 -* -* i2c-9: -* pca9546@71 -* - channel 0: isil,isl68137@60 -* - channel 1: isil,isl68137@61 -* - channel 2: isil,isl68137@63 -* - channel 3: isil,isl68137@45 -* +*/ + +/* i2c-8: */ +i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,8 ),"adm1272" ,0x10 ); + +/* i2c-9: */ +i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,9 ),TYPE_PCA9546 ,0x71 ); +/* +* - channel 0: isil,isl68137@60 +* - channel 1: isil,isl68137@61 +* - channel 2: isil,isl68137@63 +* - channel 3: isil,isl68137@45 +*/ + +/* * i2c-10: * pca9545@71 * * i2c-11: * pca9545@76 -* -* i2c-12: -* maxim,max34451@4e -* isil,isl68137@5d -* isil,isl68137@5e -* +*/ + +/* i2c-12: */ +i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,12 ),"max34451" ,0x4e ); +/* +* isil,isl68137@5d +* isil,isl68137@5e +*/ + +/* * i2c-14: * pca9545@70 */
Signature · 1 line
2.33.1.1089.g2158813163f-goog