* [PATCH 1/8] hw/i2c: Clear ACK bit in NPCM7xx SMBus module
2022-07-14 18:27 [PATCH 0/8] Misc NPCM7XX patches Hao Wu
@ 2022-07-14 18:27 ` Hao Wu
2022-07-14 18:27 ` [PATCH 2/8] hw/i2c: Read FIFO during RXF_CTL change in NPCM7XX SMBus Hao Wu
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Hao Wu @ 2022-07-14 18:27 UTC (permalink / raw)
To: peter.maydell
Cc: richard.henderson, qemu-arm, qemu-devel, wuhaotsh, venture,
Avi.Fishman, kfting, hskinnemoen, f4bug, bin.meng, qemu-block,
armbru, thuth, Titus Rwantare
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.
Signed-off-by: Hao Wu <wuhaotsh@google.com>
Reviewed-by: Titus Rwantare <titusr@google.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/i2c/npcm7xx_smbus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/i2c/npcm7xx_smbus.c b/hw/i2c/npcm7xx_smbus.c
index e7e0ba66fe..f18e311556 100644
--- a/hw/i2c/npcm7xx_smbus.c
+++ b/hw/i2c/npcm7xx_smbus.c
@@ -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);
--
2.37.0.170.g444d1eabd0-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/8] hw/i2c: Read FIFO during RXF_CTL change in NPCM7XX SMBus
2022-07-14 18:27 [PATCH 0/8] Misc NPCM7XX patches Hao Wu
2022-07-14 18:27 ` [PATCH 1/8] hw/i2c: Clear ACK bit in NPCM7xx SMBus module Hao Wu
@ 2022-07-14 18:27 ` Hao Wu
2022-07-14 18:27 ` [PATCH 3/8] hw/adc: Fix CONV bit in NPCM7XX ADC CON register Hao Wu
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Hao Wu @ 2022-07-14 18:27 UTC (permalink / raw)
To: peter.maydell
Cc: richard.henderson, qemu-arm, qemu-devel, wuhaotsh, venture,
Avi.Fishman, kfting, hskinnemoen, f4bug, bin.meng, qemu-block,
armbru, thuth, Titus Rwantare, Corey Minyard
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.
Signed-off-by: Hao Wu <wuhaotsh@google.com>
Reviewed-by: Titus Rwantare <titusr@google.com>
Acked-by: Corey Minyard <cminyard@mvista.com>
---
hw/i2c/npcm7xx_smbus.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/i2c/npcm7xx_smbus.c b/hw/i2c/npcm7xx_smbus.c
index f18e311556..1435daea94 100644
--- a/hw/i2c/npcm7xx_smbus.c
+++ b/hw/i2c/npcm7xx_smbus.c
@@ -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)
--
2.37.0.170.g444d1eabd0-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/8] hw/adc: Fix CONV bit in NPCM7XX ADC CON register
2022-07-14 18:27 [PATCH 0/8] Misc NPCM7XX patches Hao Wu
2022-07-14 18:27 ` [PATCH 1/8] hw/i2c: Clear ACK bit in NPCM7xx SMBus module Hao Wu
2022-07-14 18:27 ` [PATCH 2/8] hw/i2c: Read FIFO during RXF_CTL change in NPCM7XX SMBus Hao Wu
@ 2022-07-14 18:27 ` Hao Wu
2022-07-14 18:27 ` [PATCH 4/8] hw/adc: Make adci[*] R/W in NPCM7XX ADC Hao Wu
2022-07-14 18:27 ` [PATCH 5/8] blockdev: Add a new IF type IF_OTHER Hao Wu
4 siblings, 0 replies; 7+ messages in thread
From: Hao Wu @ 2022-07-14 18:27 UTC (permalink / raw)
To: peter.maydell
Cc: richard.henderson, qemu-arm, qemu-devel, wuhaotsh, venture,
Avi.Fishman, kfting, hskinnemoen, f4bug, bin.meng, qemu-block,
armbru, thuth
The 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.
Signed-off-by: Hao Wu <wuhaotsh@google.com>
Reviewed-by: Patrick Venture<venture@google.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/adc/npcm7xx_adc.c | 2 +-
tests/qtest/npcm7xx_adc-test.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/adc/npcm7xx_adc.c b/hw/adc/npcm7xx_adc.c
index 0f0a9f63e2..47fb9e5f74 100644
--- a/hw/adc/npcm7xx_adc.c
+++ b/hw/adc/npcm7xx_adc.c
@@ -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
diff --git a/tests/qtest/npcm7xx_adc-test.c b/tests/qtest/npcm7xx_adc-test.c
index 3fa6d9ece0..8048044d28 100644
--- a/tests/qtest/npcm7xx_adc-test.c
+++ b/tests/qtest/npcm7xx_adc-test.c
@@ -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)
--
2.37.0.170.g444d1eabd0-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/8] hw/adc: Make adci[*] R/W in NPCM7XX ADC
2022-07-14 18:27 [PATCH 0/8] Misc NPCM7XX patches Hao Wu
` (2 preceding siblings ...)
2022-07-14 18:27 ` [PATCH 3/8] hw/adc: Fix CONV bit in NPCM7XX ADC CON register Hao Wu
@ 2022-07-14 18:27 ` Hao Wu
2022-07-14 18:27 ` [PATCH 5/8] blockdev: Add a new IF type IF_OTHER Hao Wu
4 siblings, 0 replies; 7+ messages in thread
From: Hao Wu @ 2022-07-14 18:27 UTC (permalink / raw)
To: peter.maydell
Cc: richard.henderson, qemu-arm, qemu-devel, wuhaotsh, venture,
Avi.Fishman, kfting, hskinnemoen, f4bug, bin.meng, qemu-block,
armbru, thuth, Titus Rwantare
Our 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.
Signed-off-by: Hao Wu <wuhaotsh@google.com>
Reviewed-by: Titus Rwantare <titusr@google.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/adc/npcm7xx_adc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/adc/npcm7xx_adc.c b/hw/adc/npcm7xx_adc.c
index 47fb9e5f74..bc6f3f55e6 100644
--- a/hw/adc/npcm7xx_adc.c
+++ b/hw/adc/npcm7xx_adc.c
@@ -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);
--
2.37.0.170.g444d1eabd0-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 5/8] blockdev: Add a new IF type IF_OTHER
2022-07-14 18:27 [PATCH 0/8] Misc NPCM7XX patches Hao Wu
` (3 preceding siblings ...)
2022-07-14 18:27 ` [PATCH 4/8] hw/adc: Make adci[*] R/W in NPCM7XX ADC Hao Wu
@ 2022-07-14 18:27 ` Hao Wu
4 siblings, 0 replies; 7+ messages in thread
From: Hao Wu @ 2022-07-14 18:27 UTC (permalink / raw)
To: peter.maydell
Cc: richard.henderson, qemu-arm, qemu-devel, wuhaotsh, venture,
Avi.Fishman, kfting, hskinnemoen, f4bug, bin.meng, qemu-block,
armbru, thuth
This type is used to represent block devs that are not suitable to
be represented by other existing types.
A sample use is to represent an at24c eeprom device defined in
hw/nvram/eeprom_at24c.c. The block device can be used to contain the
content of the said eeprom device.
Signed-off-by: Hao Wu <wuhaotsh@google.com>
---
blockdev.c | 4 +++-
include/sysemu/blockdev.h | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index 9230888e34..befd69ac5f 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -82,6 +82,7 @@ static const char *const if_name[IF_COUNT] = {
[IF_MTD] = "mtd",
[IF_SD] = "sd",
[IF_VIRTIO] = "virtio",
+ [IF_OTHER] = "other",
[IF_XEN] = "xen",
};
@@ -726,7 +727,8 @@ QemuOptsList qemu_legacy_drive_opts = {
},{
.name = "if",
.type = QEMU_OPT_STRING,
- .help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
+ .help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio,"
+ " other)",
},{
.name = "file",
.type = QEMU_OPT_STRING,
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
index 3211b16513..d9dd5af291 100644
--- a/include/sysemu/blockdev.h
+++ b/include/sysemu/blockdev.h
@@ -21,6 +21,7 @@ typedef enum {
*/
IF_NONE = 0,
IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
+ IF_OTHER,
IF_COUNT
} BlockInterfaceType;
--
2.37.0.170.g444d1eabd0-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread