Re: [PULL 17/21] hw/adc: Add an ADC module for NPCM7XX

2021-01-29 Thread wuhaotsh--- via
On Fri, Jan 29, 2021 at 6:41 AM Philippe Mathieu-Daudé wrote: > Hi Hao Wu, > > On 1/12/21 5:57 PM, Peter Maydell wrote: > > From: Hao Wu > > > > The ADC is part of NPCM7XX Module. Its behavior is controled by the > > ADC_CON register. It converts one of the eight analog inputs into a > > digital

[PATCH v2 5/6] hw/i2c: Add a QTest for NPCM7XX SMBus Device

2021-01-28 Thread wuhaotsh--- via
This patch adds a QTest for NPCM7XX SMBus's single byte mode. It sends a byte to a device in the evaluation board, and verify the retrieved value is equivalent to the sent value. Reviewed-by: Doug Evans Reviewed-by: Tyrong Ting Signed-off-by: Hao Wu --- tests/qtest/meson.build | 1 +

[PATCH v2 6/6] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode

2021-01-28 Thread wuhaotsh--- via
This patch implements the FIFO mode of the SMBus module. In FIFO, the user transmits or receives at most 16 bytes at a time. The FIFO mode allows the module to transmit large amount of data faster than single byte mode. Reviewed-by: Doug Evans Reviewed-by: Tyrong Ting Signed-off-by: Hao Wu Review

[PATCH v2 4/6] hw/arm: Add I2C sensors and EEPROM for GSJ machine

2021-01-28 Thread wuhaotsh--- via
Add AT24 EEPROM and temperature sensors for GSJ machine. Reviewed-by: Doug Evans Reviewed-by: Tyrong Ting Signed-off-by: Hao Wu --- default-configs/devices/arm-softmmu.mak | 1 + hw/arm/npcm7xx_boards.c | 27 + 2 files changed, 28 insertions(+) diff --gi

[PATCH v2 1/6] hw/arm: Remove GPIO from unimplemented NPCM7XX

2021-01-28 Thread wuhaotsh--- via
NPCM7XX GPIO devices have been implemented in hw/gpio/npcm7xx-gpio.c. So we removed them from the unimplemented devices list. Reviewed-by: Doug Evans Reviewed-by: Tyrong Ting Signed-off-by: Hao Wu --- hw/arm/npcm7xx.c | 8 1 file changed, 8 deletions(-) diff --git a/hw/arm/npcm7xx.c b/h

[PATCH v2 2/6] hw/i2c: Implement NPCM7XX SMBus Module Single Mode

2021-01-28 Thread wuhaotsh--- via
This commit implements the single-byte mode of the SMBus. Each Nuvoton SoC has 16 System Management Bus (SMBus). These buses compliant with SMBus and I2C protocol. This patch implements the single-byte mode of the SMBus. In this mode, the user sends or receives a byte each time. The SMBus device

[PATCH v2 0/6] hw/i2c: Add NPCM7XX SMBus Device

2021-01-28 Thread wuhaotsh--- via
This patch set implements the System manager bus (SMBus) module in NPCM7XX SoC. Basically, it emulates the data transactions of the module, not the SDA/SCL levels. We have also added a QTest which contains read and write operations for both single-byte and FIFO mode, and added basic I2C devices for

[PATCH v2 3/6] hw/arm: Add I2C sensors for NPCM750 eval board

2021-01-28 Thread wuhaotsh--- via
Add I2C temperature sensors for NPCM750 eval board. Reviewed-by: Doug Evans Reviewed-by: Tyrong Ting Signed-off-by: Hao Wu --- hw/arm/npcm7xx_boards.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c index 3fdd5cab01..47a2

Re: [PATCH 6/6] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode

2021-01-27 Thread wuhaotsh--- via
On Wed, Jan 27, 2021 at 1:42 PM Corey Minyard wrote: > On Wed, Jan 27, 2021 at 12:37:46PM -0800, wuhaotsh--- via wrote: > > On Tue, Jan 26, 2021 at 3:47 PM Corey Minyard wrote: > > > > > On Tue, Jan 26, 2021 at 11:32:37AM -0800, wuhaotsh--- via wrote: > &

Re: [PATCH 6/6] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode

2021-01-27 Thread wuhaotsh--- via
On Tue, Jan 26, 2021 at 3:47 PM Corey Minyard wrote: > On Tue, Jan 26, 2021 at 11:32:37AM -0800, wuhaotsh--- via wrote: > > + > > +static void npcm7xx_smbus_read_byte_fifo(NPCM7xxSMBusState *s) > > +{ > > +uint8_t received_bytes = NPCM7XX_SMBRXF_STS_RX_BYTES(s-&

[PATCH v2] hw/misc: Fix arith overflow in NPCM7XX PWM module

2021-01-26 Thread wuhaotsh--- via
Fix potential overflow problem when calculating pwm_duty. 1. Ensure p->cmr and p->cnr to be from [0,65535], according to the hardware specification. 2. Changed duty to uint32_t. However, since MAX_DUTY * (p->cmr+1) can excceed UINT32_MAX, we convert them to uint64_t in computation and conv

[PATCH 4/6] hw/arm: Add I2C device tree for Quanta GSJ

2021-01-26 Thread wuhaotsh--- via
Add an I2C device tree for Quanta GSJ. We only included devices with existing QEMU implementation, including AT24 EEPROM and temperature sensors. Reviewed-by: Doug Evans Reviewed-by: Tyrong Ting Signed-off-by: Hao Wu --- hw/arm/npcm7xx_boards.c | 17 + 1 file changed, 17 insertio

[PATCH 1/6] hw/arm: Remove GPIO from unimplemented NPCM7XX

2021-01-26 Thread wuhaotsh--- via
NPCM7XX GPIO devices have been implemented in hw/gpio/npcm7xx-gpio.c. So we removed them from the unimplemented devices list. Reviewed-by: Doug Evans Reviewed-by: Tyrong Ting Signed-off-by: Hao Wu --- hw/arm/npcm7xx.c | 8 1 file changed, 8 deletions(-) diff --git a/hw/arm/npcm7xx.c b/h

[PATCH 5/6] hw/i2c: Add a QTest for NPCM7XX SMBus Device

2021-01-26 Thread wuhaotsh--- via
This patch adds a QTest for NPCM7XX SMBus's single byte mode. It sends a byte to a device in the evaluation board, and verify the retrieved value is equivalent to the sent value. Reviewed-by: Doug Evans Reviewed-by: Tyrong Ting Signed-off-by: Hao Wu --- tests/qtest/meson.build | 1 +

[PATCH 6/6] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode

2021-01-26 Thread wuhaotsh--- via
This patch implements the FIFO mode of the SMBus module. In FIFO, the user transmits or receives at most 16 bytes at a time. The FIFO mode allows the module to transmit large amount of data faster than single byte mode. Reviewed-by: Doug Evans Reviewed-by: Tyrong Ting Signed-off-by: Hao Wu --- h

[PATCH 3/6] hw/arm: Add I2C device tree for NPCM750 eval board

2021-01-26 Thread wuhaotsh--- via
Add an I2C device tree for NPCM750 evaluation board. Reviewed-by: Doug Evans Reviewed-by: Tyrong Ting Signed-off-by: Hao Wu --- hw/arm/npcm7xx_boards.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c index 3fdd5cab01..2d82f48

[PATCH 0/6] hw/i2c: Add NPCM7XX SMBus Device

2021-01-26 Thread wuhaotsh--- via
This patch set implements the System manager bus (SMBus) module in NPCM7XX SoC. Basically, it emulates the data transactions of the module, not the SDA/SCL levels. We have also added a QTest which contains read and write operations for both single-byte and FIFO mode, and added basic I2C device tree

[PATCH 2/6] hw/i2c: Implement NPCM7XX SMBus Module Single Mode

2021-01-26 Thread wuhaotsh--- via
This commit implements the single-byte mode of the SMBus. Each Nuvoton SoC has 16 System Management Bus (SMBus). These buses compliant with SMBus and I2C protocol. This patch implements the single-byte mode of the SMBus. In this mode, the user sends or receives a byte each time. The SMBus device

[PATCH] hw/misc: Fix arith overflow in NPCM7XX PWM module

2021-01-25 Thread wuhaotsh--- via
There's a potential arith overflow in npcm7xx_pwm_calculate_duty. This patch fixes it. Thanks Peter for finding this out. Signed-off-by: Hao Wu --- hw/misc/npcm7xx_pwm.c | 4 ++-- tests/qtest/npcm7xx_pwm-test.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/m

Re: [PATCH] npcm7xx_adc-test: Fix memleak in adc_qom_set

2021-01-18 Thread wuhaotsh--- via
On Sun, Jan 17, 2021 at 10:59 PM Gan Qixin wrote: > The adc_qom_set function didn't free "response", which caused an indirect > memory leak. So use qobject_unref() to fix it. > > ASAN shows memory leak stack: > > Indirect leak of 593280 byte(s) in 144 object(s) allocated from: > #0 0x7f9a5e7e