Add Quanta GSZ BMC machine and PCA I2C GPIO expanders
cover Add Quanta GSZ BMC machine and PCA I2C GPIO expanders
This patch series bundles the GPIO sensors previously sent for review:
https://lore.kernel.org/all/[email protected]
and the GSZ board commit sent here:
https://lore.kernel.org/all/[email protected]/
The Quanta GSZ a current Google machine of the day. This machine will be used as a platform to enable features such as the PECI bmc interface, and Intel eSPI virtual wire interface in QEMU.
This patch series also contains a set of i2c GPIO expanders, with support for 4, 8, and 16 GPIO connections.
The devices are configured as GPIO inputs by default, but can have pins configured to be inputs with qmp commands.
These sensors and machine are maintained and used in CI daily within Google.
Titus Rwantare (6):
bitops.h: add deposit16 function
hw/gpio: add PCA953x i2c GPIO expanders
hw/gpio: add PCA9536 i2c gpio expander
hw/i2c: add canonical path to i2c event traces
hw/arm: imply I2C_DEVICES on NPCM7xx
hw/arm: add Quanta GSZ bmc machine
hw/arm/Kconfig | 1 + hw/arm/npcm7xx_boards.c | 160 +++++++++++++ hw/gpio/Kconfig | 5 + hw/gpio/meson.build | 1 + hw/gpio/pca_i2c_gpio.c | 409 ++++++++++++++++++++++++++++++++ hw/gpio/trace-events | 5 + hw/i2c/core.c | 8 +- hw/i2c/trace-events | 2 +- include/hw/gpio/pca_i2c_gpio.h | 70 ++++++ include/qemu/bitops.h | 26 ++ tests/qtest/meson.build | 1 + tests/qtest/pca_i2c_gpio-test.c | 188 +++++++++++++++ 12 files changed, 872 insertions(+), 4 deletions(-) create mode 100644 hw/gpio/pca_i2c_gpio.c create mode 100644 include/hw/gpio/pca_i2c_gpio.h create mode 100644 tests/qtest/pca_i2c_gpio-test.c
Signature · 1 line
2.47.0.277.g8800431eea-goog
PATCH 1/6 bitops.h: add deposit16 function
Makes it more explicit that 16 bit values are being used
--- include/qemu/bitops.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
include/qemu/bitops.h +26 -0
@@ -459,6 +459,32 @@ static inline int64_t sextract64(uint64_t value, int start, int length)return ((int64_t )(value << (64 - length - start))) >> (64 - length); } +/** +* deposit16: +* @value: initial value to insert bit field into +* @start: the lowest bit in the bit field (numbered from 0) +* @length: the length of the bit field +* @fieldval: the value to insert into the bit field +* +* Deposit @fieldval into the 16 bit @value at the bit field specified +* by the @start and @length parameters, and return the modified +* @value. Bits of @value outside the bit field are not modified. +* Bits of @fieldval above the least significant @length bits are +* ignored. The bit field must lie entirely within the 16 bit word. +* It is valid to request that all 16 bits are modified (ie @length +* 16 and @start 0). +* +* Returns: the modified @value. +*/ +static inline uint16_t deposit16 (uint16_t value,int start,int length, +uint16_t fieldval) +{ +uint16_t mask; +assert (start >=0 && length >0 && length <=16 - start); + mask = (~0U >> (16 - length)) << start; +return (value & ~mask) | ((fieldval << start) & mask); +} +/** * deposit32: * @value: initial value to insert bit field into
Signature · 1 line
2.47.0.277.g8800431eea-goog
PATCH 4/6 hw/i2c: add canonical path to i2c event traces
In reply to Titus Rwantare--- hw/i2c/core.c | 8 +++++--- hw/i2c/trace-events | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-)
hw/i2c/core.c +5 -3
@@ -161,7 +161,8 @@ static int i2c_do_start_transfer(I2CBus *bus, uint8_t address,start condition. */ if (sc->event) { -trace_i2c_event (event ==I2C_START_SEND ?"start" :"start_async" , +trace_i2c_event (DEVICE (s)->canonical_path, + event ==I2C_START_SEND ?"start" :"start_async" , s->address); rv = sc->event (s, event);if (rv && !bus->broadcast) {
@@ -244,7 +245,7 @@ void i2c_end_transfer(I2CBus *bus)I2CSlave *s = node->elt; sc =I2C_SLAVE_GET_CLASS (s);if (sc->event) { -trace_i2c_event ("finish" , s->address); +trace_i2c_event (DEVICE (s)->canonical_path,"finish" , s->address); sc->event (s,I2C_FINISH ); }QLIST_REMOVE (node, next);
@@ -321,7 +322,8 @@ void i2c_nack(I2CBus *bus) QLIST_FOREACH(node, &bus->current_devs, next) { sc =I2C_SLAVE_GET_CLASS (node->elt);if (sc->event) { -trace_i2c_event ("nack" , node->elt->address); +trace_i2c_event (DEVICE (node->elt)->canonical_path, +"nack" , node->elt->address); sc->event (node->elt,I2C_NACK ); } }
hw/i2c/trace-events +1 -1
@@ -9,7 +9,7 @@ bitbang_i2c_data(unsigned clk, unsigned dat, unsigned old_out, unsigned new_out) # core.c -i2c_event(const char *event, uint8_t address) "%s(addr:0x%02x)" +i2c_event(const char *id, const char *event, uint8_t address) "%s: %s(addr:0x%02x)" i2c_send(uint8_t address, uint8_t data) "send(addr:0x%02x) data:0x%02x" i2c_send_async(uint8_t address, uint8_t data) "send_async(addr:0x%02x) data:0x%02x" i2c_recv(uint8_t address, uint8_t data) "recv(addr:0x%02x) data:0x%02x"
Signature · 1 line
2.47.0.277.g8800431eea-goog
PATCH 6/6 hw/arm: add Quanta GSZ bmc machine
In reply to Titus RwantareThis patch adds the quanta-gsz-bmc target, a current Google machine of the day. This machine will be used as a platform to enable features such as the PECI bmc interface, and Intel eSPI virtual wire interface in QEMU.
--- hw/arm/npcm7xx_boards.c | 160 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+)
hw/arm/npcm7xx_boards.c +160 -0
@@ -48,6 +48,8 @@#define NPCM750_EVB_POWER_ON_STRAPS ( \ NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_J2EN)#define QUANTA_GSJ_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT +#define QUANTA_GSZ_POWER_ON_STRAPS ( \ + NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_SFAB)#define QUANTA_GBS_POWER_ON_STRAPS ( \ NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_SFAB)#define KUDO_BMC_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT
@@ -269,6 +271,129 @@ static void quanta_gsj_fan_init(NPCM7xxMachine *machine, NPCM7xxState *soc)npcm7xx_connect_pwm_fan (soc, &splitter[2 ],0x05 ,1 ); } +static void quanta_gsz_i2c_init (NPCM7xxState *soc) +{ +DeviceState *dev; +I2CSlave *i2c_mux; + +/* i2c1 */ + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,1 ),TYPE_PCA9548 , +0x75 ); +/* pca6416@0x20 */ + dev =DEVICE (i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,3 ), +"pca6416" ,0x20 )); +object_property_set_uint (OBJECT (dev),"gpio_config" ,0xF00 , &error_abort); +object_property_set_uint (OBJECT (dev),"gpio_input" ,0xF00 , &error_abort); + + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,1 ), +TYPE_PCA9548 ,0x77 ); + +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,0 ),"raa229004" ,0x72 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,1 ),"raa229004" ,0x72 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,2 ),"isl69260" ,0x72 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,3 ),"isl69260" ,0x72 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,4 ),"isl69260" ,0x72 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,5 ),"isl69260" ,0x72 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,6 ),"adm1272" ,0x1f ); + +/* i2c2 */ + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,2 ), +TYPE_PCA9548 ,0x77 ); +/* - channel 0: tps546d24 @25 +* - channel 1: delta,dps800 @69 +*/ +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,1 ),"raa228000" ,0x68 ); +/* - channel 2: delta,dps800 @68 */ +/* max31725 is compatible with tmp105. */ +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,4 ),"tmp105" ,0x5c ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,5 ),"tmp105" ,0x5c ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,6 ),"tmp105" ,0x5c ); + +/* i2c3 */ + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,3 ),TYPE_PCA9548 , +0x77 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,2 ),"pca9538" ,0x72 ); + +/* i2c4 */ +/* mobo_fru_1 */ +at24c_eeprom_init (npcm7xx_i2c_get_bus (soc,4 ),0x50 ,8192 ); + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,4 ), +TYPE_PCA9548 ,0x77 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,0 ),"max34451" ,0x59 ); +/* mobo_fru_2 */ +at24c_eeprom_init (npcm7xx_i2c_get_bus (soc,2 ),0x55 ,32768 ); + + dev =DEVICE (i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,3 ), +"pca6416" ,0x20 )); +object_property_set_uint (OBJECT (dev),"gpio_config" ,0x4000 , &error_abort); +object_property_set_uint (OBJECT (dev),"gpio_input" ,0x4000 , &error_abort); + + dev =DEVICE (i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,4 ), +"pca6416" ,0x20 )); +object_property_set_uint (OBJECT (dev),"gpio_config" ,0xFFFF , &error_abort); +object_property_set_uint (OBJECT (dev),"gpio_input" ,0x0000 , &error_abort); + +/* pdb_fru */ +at24c_eeprom_init (npcm7xx_i2c_get_bus (soc,6 ),0x55 ,8192 ); + +/* i2c5 */ + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,5 ),TYPE_PCA9548 , +0x77 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,2 ),"pca9538" ,0x72 ); + +/* i2c6 */ + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,6 ),TYPE_PCA9548 , +0x77 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,2 ),"pca9538" ,0x72 ); + +/* i2c7 */ + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,7 ),TYPE_PCA9548 , +0x77 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,2 ),"pca9538" ,0x72 ); + +/* i2c8 */ + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,8 ),TYPE_PCA9548 , +0x77 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,2 ),"pca9538" ,0x72 ); + +/* i2c9 */ + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,9 ),TYPE_PCA9548 , +0x77 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,2 ),"pca9538" ,0x72 ); + +/* i2c10 */ + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,10 ), +TYPE_PCA9548 ,0x77 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,1 ),"pca9538" ,0x72 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,2 ),"pca9538" ,0x72 ); +/* i2c11 */ + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,11 ), +TYPE_PCA9548 ,0x77 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,2 ),"pca9538" ,0x72 ); + +/* i2c12 */ + +/* i2c13 */ +i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,13 ),"pca6416" ,0x22 ); + +/* i2c14 */ +/* LEDs and PE Resets */ +i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,14 ),"pca6416" ,0x20 ); + +/* bmc_fru_1 */ +at24c_eeprom_init (npcm7xx_i2c_get_bus (soc,14 ),0x55 ,8192 ); + + i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,14 ), +TYPE_PCA9548 ,0x77 ); +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,0 ),"max34451" ,0x59 ); + +/* max31725 is compatible with tmp105 */ +i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,4 ),"tmp105" ,0x5c ); + +/* i2c15 */ +i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,15 ),TYPE_PCA9546 ,0x75 ); +} +static void quanta_gbs_i2c_init (NPCM7xxState *soc) {/*
@@ -392,6 +517,25 @@ static void quanta_gsj_init(MachineState *machine)npcm7xx_load_kernel (machine, soc); } +static void quanta_gsz_init (MachineState *machine) +{ +NPCM7xxState *soc; + + soc =npcm7xx_create_soc (machine,QUANTA_GSZ_POWER_ON_STRAPS ); +npcm7xx_connect_dram (soc, machine->ram); +qdev_realize (DEVICE (soc),NULL , &error_fatal); + +npcm7xx_load_bootrom (machine, soc); +npcm7xx_connect_flash (&soc->fiu[0 ],0 ,"mx66u51235f" , +drive_get (IF_MTD ,0 ,0 )); +npcm7xx_connect_flash (&soc->fiu[1 ],0 ,"mx66u51235f" , +drive_get (IF_MTD ,3 ,0 )); + +quanta_gsz_i2c_init (soc); +sdhci_attach_drive (&soc->mmc.sdhci,0 ); +npcm7xx_load_kernel (machine, soc); +} +static void quanta_gbs_init (MachineState *machine) {NPCM7xxState *soc;
@@ -496,6 +640,18 @@ static void gsj_machine_class_init(ObjectClass *oc, void *data) mc->default_ram_size =512 * MiB; }; +static void gsz_machine_class_init (ObjectClass *oc,void *data) +{ +NPCM7xxMachineClass *nmc =NPCM7XX_MACHINE_CLASS (oc); +MachineClass *mc =MACHINE_CLASS (oc); + +npcm7xx_set_soc_type (nmc,TYPE_NPCM730 ); + + mc->desc ="Quanta GSZ (Cortex-A9)" ; + mc->init = quanta_gsz_init; + mc->default_ram_size =1 * GiB; +} +static void gbs_bmc_machine_class_init (ObjectClass *oc,void *data) {NPCM7xxMachineClass *nmc =NPCM7XX_MACHINE_CLASS (oc);
@@ -548,6 +704,10 @@ static const TypeInfo npcm7xx_machine_types[] = { .name = MACHINE_TYPE_NAME("quanta-gsj"), .parent = TYPE_NPCM7XX_MACHINE, .class_init = gsj_machine_class_init, + }, { + .name = MACHINE_TYPE_NAME("quanta-gsz-bmc"), + .parent = TYPE_NPCM7XX_MACHINE, + .class_init = gsz_machine_class_init, }, { .name = MACHINE_TYPE_NAME("quanta-gbs-bmc"), .parent = TYPE_NPCM7XX_MACHINE,
Signature · 1 line
2.47.0.277.g8800431eea-goog
PATCH 3/6 hw/gpio: add PCA9536 i2c gpio expander
In reply to Titus RwantareThis device has the same register layout as the pca9538, but 4 fewer gpio pins. This commit lowers the number of pins initialised, and reuses the pca9538 logic.
--- hw/gpio/pca_i2c_gpio.c | 18 ++++++++++++++++++ include/hw/gpio/pca_i2c_gpio.h | 2 ++ 2 files changed, 20 insertions(+)
hw/gpio/pca_i2c_gpio.c +18 -0
@@ -336,6 +336,19 @@ static void pca9538_gpio_class_init(ObjectClass *klass, void *data) k->send = pca953x_send; } +static void pca9536_gpio_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +I2CSlaveClass *k =I2C_SLAVE_CLASS (klass); +PCAGPIOClass *pc =PCA_I2C_GPIO_CLASS (klass); + + dc->desc ="PCA9536 4-bit I/O expander" ; + pc->num_pins =PCA9536_NUM_PINS ; + + k->recv = pca953x_recv; + k->send = pca953x_send; +} +static void pca_i2c_gpio_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -386,6 +399,11 @@ static const TypeInfo pca_gpio_types[] = { .parent = TYPE_PCA_I2C_GPIO, .class_init = pca9538_gpio_class_init, }, + { + .name = TYPE_PCA9536_GPIO, + .parent = TYPE_PCA_I2C_GPIO, + .class_init = pca9536_gpio_class_init, + }, };DEFINE_TYPES (pca_gpio_types);
include/hw/gpio/pca_i2c_gpio.h +2 -0
@@ -21,6 +21,7 @@#define PCA_I2C_MAX_PINS 16#define PCA6416_NUM_PINS 16#define PCA9538_NUM_PINS 8 +#define PCA9536_NUM_PINS 4 typedef struct PCAGPIOClass { I2CSlaveClass parent;
@@ -64,5 +65,6 @@ OBJECT_DECLARE_TYPE(PCAGPIOState, PCAGPIOClass, PCA_I2C_GPIO)#define TYPE_PCA6416_GPIO "pca6416"#define TYPE_PCA9538_GPIO "pca9538" +#define TYPE_PCA9536_GPIO "pca9536"#endif
Signature · 1 line
2.47.0.277.g8800431eea-goog
PATCH 2/6 hw/gpio: add PCA953x i2c GPIO expanders
In reply to Titus RwantareThe PCA6416 is an i2c device with 16 GPIO pins, the PCA9538 has 8 pins.
--- hw/gpio/Kconfig | 5 + hw/gpio/meson.build | 1 + hw/gpio/pca_i2c_gpio.c | 391 ++++++++++++++++++++++++++++++++ hw/gpio/trace-events | 5 + include/hw/gpio/pca_i2c_gpio.h | 68 ++++++ tests/qtest/meson.build | 1 + tests/qtest/pca_i2c_gpio-test.c | 188 +++++++++++++++ 7 files changed, 659 insertions(+) create mode 100644 hw/gpio/pca_i2c_gpio.c create mode 100644 include/hw/gpio/pca_i2c_gpio.h create mode 100644 tests/qtest/pca_i2c_gpio-test.c
hw/gpio/Kconfig +5 -0
@@ -13,6 +13,11 @@ config GPIO_PWR config SIFIVE_GPIO bool +config PCA_I2C_GPIO + bool + depends on I2C + default y if I2C_DEVICES + config STM32L4X5_GPIO bool
hw/gpio/meson.build +1 -0
@@ -18,3 +18,4 @@ system_ss.add(when: 'CONFIG_STM32L4X5_SOC', if_true: files('stm32l4x5_gpio.c')) system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_gpio.c')) system_ss.add(when: 'CONFIG_SIFIVE_GPIO', if_true: files('sifive_gpio.c')) system_ss.add(when: 'CONFIG_PCF8574', if_true: files('pcf8574.c')) +system_ss.add(when: 'CONFIG_PCA_I2C_GPIO', if_true: files('pca_i2c_gpio.c'))
hw/gpio/pca_i2c_gpio.c new file +391 -0
391 lines not on this page · raw message
hw/gpio/trace-events +5 -0
@@ -41,3 +41,8 @@ stm32l4x5_gpio_read(char *gpio, uint64_t addr) "GPIO%s addr: 0x%" PRIx64 " " stm32l4x5_gpio_write(char *gpio, uint64_t addr, uint64_t data) "GPIO%s addr: 0x%" PRIx64 " val: 0x%" PRIx64 "" stm32l4x5_gpio_update_idr(char *gpio, uint32_t old_idr, uint32_t new_idr) "GPIO%s from: 0x%x to: 0x%x" stm32l4x5_gpio_pins(char *gpio, uint16_t disconnected, uint16_t high) "GPIO%s disconnected pins: 0x%x levels: 0x%x" + +# pca_i2c_gpio.c +pca_i2c_event(const char *id, const char *event) "%s: %s" +pca_i2c_recv(const char *id, uint8_t cmd, uint32_t shift, uint8_t data) "%s cmd: 0x%" PRIx8 "shift: %" PRIi32 " data 0x%" PRIx8 +pca_i2c_send(const char *id, uint8_t cmd, uint32_t shift, uint8_t data) "%s cmd: 0x%" PRIx8 "shift: %" PRIi32 " data 0x%" PRIx8
include/hw/gpio/pca_i2c_gpio.h new file +68 -0
68 lines not on this page · raw message
tests/qtest/meson.build +1 -0
@@ -291,6 +291,7 @@ qos_test_ss.add( 'ne2000-test.c', 'tulip-test.c', 'nvme-test.c', + 'pca_i2c_gpio-test.c', 'pca9552-test.c', 'pci-test.c', 'pcnet-test.c',
tests/qtest/pca_i2c_gpio-test.c new file +188 -0
188 lines not on this page · raw message
Signature · 1 line
2.47.0.277.g8800431eea-goog
PATCH 5/6 hw/arm: imply I2C_DEVICES on NPCM7xx
In reply to Titus Rwantare--- hw/arm/Kconfig | 1 + 1 file changed, 1 insertion(+)
hw/arm/Kconfig +1 -0
@@ -465,6 +465,7 @@ config NPCM7XX bool default y depends on TCG && ARM + imply I2C_DEVICES select A9MPCORE select ADM1266 select ADM1272
Signature · 1 line
2.47.0.277.g8800431eea-goog
Re: [PATCH 4/6] hw/i2c: add canonical path to i2c event traces
In reply to Titus RwantareQuoted 2 lines · Titus Rwantare
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Titus Rwantare <[email protected]>
Quoted 54 lines
--- hw/i2c/core.c | 8 +++++--- hw/i2c/trace-events | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-)hw/i2c/core.c +5
-3@@ -161,7 +161,8 @@ static int i2c_do_start_transfer(I2CBus *bus, uint8_t address,start condition. */ if (sc->event) { -trace_i2c_event (event ==I2C_START_SEND ?"start" :"start_async" , +trace_i2c_event (DEVICE (s)->canonical_path, + event ==I2C_START_SEND ?"start" :"start_async" , s->address); rv = sc->event (s, event);if (rv && !bus->broadcast) {@@ -244,7 +245,7 @@ void i2c_end_transfer(I2CBus *bus)I2CSlave *s = node->elt; sc =I2C_SLAVE_GET_CLASS (s);if (sc->event) { -trace_i2c_event ("finish" , s->address); +trace_i2c_event (DEVICE (s)->canonical_path,"finish" , s->address); sc->event (s,I2C_FINISH ); }QLIST_REMOVE (node, next);@@ -321,7 +322,8 @@ void i2c_nack(I2CBus *bus) QLIST_FOREACH(node, &bus->current_devs, next) { sc =I2C_SLAVE_GET_CLASS (node->elt);if (sc->event) { -trace_i2c_event ("nack" , node->elt->address); +trace_i2c_event (DEVICE (node->elt)->canonical_path, +"nack" , node->elt->address); sc->event (node->elt,I2C_NACK ); } }hw/i2c/trace-events +1
-1@@ -9,7 +9,7 @@ bitbang_i2c_data(unsigned clk, unsigned dat, unsigned old_out, unsigned new_out) # core.c -i2c_event(const char *event, uint8_t address) "%s(addr:0x%02x)" +i2c_event(const char *id, const char *event, uint8_t address) "%s: %s(addr:0x%02x)" i2c_send(uint8_t address, uint8_t data) "send(addr:0x%02x) data:0x%02x" i2c_send_async(uint8_t address, uint8_t data) "send_async(addr:0x%02x) data:0x%02x" i2c_recv(uint8_t address, uint8_t data) "recv(addr:0x%02x) data:0x%02x"Signature · 1 line
2.47.0.277.g8800431eea-goog
Re: [PATCH 1/6] bitops.h: add deposit16 function
In reply to Titus RwantareQuoted 48 lines · Titus Rwantare
Makes it more explicit that 16 bit values are being used
Signed-off-by Titus Rwantare <[email protected]>--- include/qemu/bitops.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)include/qemu/bitops.h +8
-0@@ -459,6 +459,32 @@ static inline int64_t sextract64(uint64_t value, int start, int length)return ((int64_t )(value << (64 - length - start))) >> (64 - length); } +/** +* deposit16: +* @value: initial value to insert bit field into +* @start: the lowest bit in the bit field (numbered from 0) +* @length: the length of the bit field +* @fieldval: the value to insert into the bit field +* +* Deposit @fieldval into the 16 bit @value at the bit field specified
+ * by the @start and @length parameters, and return the modified
+ * @value. Bits of @value outside the bit field are not modified.
+ * Bits of @fieldval above the least significant @length bits are
+ * ignored. The bit field must lie entirely within the 16 bit word.
+ * It is valid to request that all 16 bits are modified (ie @length
+ * 16 and @start 0).
+ *
+ * Returns: the modified @value.
+ */
+static inlineuint16_tdeposit16(uint16_t value, int start, int length,include/qemu/bitops.h +8
-0+ uint16_t fieldval) +{ +uint16_t mask; +assert (start >=0 && length >0 && length <=16 - start); + mask = (~0U >> (16 - length)) << start; +return (value & ~mask) | ((fieldval << start) & mask); +} +/** * deposit32: * @value: initial value to insert bit field into
Re: [PATCH 1/6] bitops.h: add deposit16 function
In reply to Titus RwantareQuoted 23 lines · Titus Rwantare
Makes it more explicit that 16 bit values are being used
Signed-off-by Titus Rwantare <[email protected]>--- include/qemu/bitops.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)include/qemu/bitops.h +7
-0@@ -459,6 +459,32 @@ static inline int64_t sextract64(uint64_t value, int start, int length)return ((int64_t )(value << (64 - length - start))) >> (64 - length); } +/** +* deposit16: +* @value: initial value to insert bit field into +* @start: the lowest bit in the bit field (numbered from 0) +* @length: the length of the bit field +* @fieldval: the value to insert into the bit field +*
include/qemu/bitops.h static inline int64_t sextract64(uint64_t value, int start, int length) · line 478
Quoted 10 lines
include/qemu/bitops.h +10
-0+* Deposit @fieldval into the 16 bit @value at the bit field specified +* by the @start and @length parameters, and return the modified +* @value. Bits of @value outside the bit field are not modified. +* Bits of @fieldval above the least significant @length bits are +* ignored. The bit field must lie entirely within the 16 bit word. +* It is valid to request that all 16 bits are modified (ie @length +* 16 and @start 0). +* +* Returns: the modified @value. +*/
Why do we need this rather than using deposit32()?
See also the comments in this thread
https://lore.kernel.org/qemu-devel/CAFEAcA9H=w29-8CQStYYNwEU=OEB=NzxpioaqGEgSpc4KnPOHQ@mail.gmail.com/
where a deposit8() was proposed.
thanks
-- PMM