Skip to contentSkip to conversation

Misc NPCM7XX patches

PATCH Superseded Hao Wu 1 participant 3 messages Nov 3, 2021

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Hao Wu

author
#0 lore raw

v4 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 adds a new blockdev IF type IF_OTHER.

Patch 6 modifies at24c_eeprom_init in NPCM7xx boards so that it can fit more use cases.

Patch 7 uses the function defined in patch 5 to add the EEPROM and other I2C devices for Quanta GBS board.

-- Changes since v3:
1. Add a new blockdev IF type IF_OTHER.
2. Use IF_OTHER instead of IF_NONE.

-- 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 (6):
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
blockdev: Add a new IF type IF_OTHER
hw/nvram: Update at24c EEPROM init function in NPCM7xx boards

Patrick Venture (1):
hw/arm: quanta-gbs-bmc add i2c devices

 blockdev.c                     |  3 +-
 hw/adc/npcm7xx_adc.c           |  4 +-
 hw/arm/npcm7xx_boards.c        | 96 ++++++++++++++++++++--------------
 hw/i2c/npcm7xx_smbus.c         |  8 +--
 include/sysemu/blockdev.h      |  1 +
 meson                          |  2 +-
 tests/qtest/npcm7xx_adc-test.c |  2 +-
 7 files changed, 69 insertions(+), 47 deletions(-)
Signature · 1 line
2.33.1.1089.g2158813163f-goog
author
#1 lore raw

PATCH v4 1/7 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
index e7e0ba66fe..f18e311556 100644
@@ -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
author
#2 lore raw

PATCH v4 2/7 hw/i2c: Read FIFO during RXF_CTL change in NPCM7XX SMBus

In reply to Hao Wu

Originally 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
index f18e311556..1435daea94 100644
@@ -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