hw/sensor: Add ISL69259 with IC_DEVICE_ID
cover hw/sensor: Add ISL69259 with IC_DEVICE_ID
From: Peter Delevoryas <[email protected]>
Resubmitting these patches separately after having included and partially reviewd them here:
- https://lore.kernel.org/qemu-devel/[email protected]/
- https://lore.kernel.org/qemu-devel/[email protected]/
- https://lore.kernel.org/qemu-devel/[email protected]/
I added Titus's reviewed-by tags, but Cedric still had one outstanding issue:
- https://lore.kernel.org/qemu-devel/[email protected]/
But Titus had a response to that issue, so we may or may not ignore it:
Changes since then:
- Replaced g_assert_cmphex with g_assert to avoid portability issues.
Thanks,
Peter
Peter Delevoryas (3):
hw/i2c/pmbus: Add idle state to return 0xff's hw/sensor: Add IC_DEVICE_ID to ISL voltage regulators hw/sensor: Add Renesas ISL69259 device model
hw/i2c/pmbus_device.c | 9 +++++++ hw/sensor/isl_pmbus_vr.c | 40 ++++++++++++++++++++++++++++++++ include/hw/i2c/pmbus_device.h | 7 ++++++ include/hw/sensor/isl_pmbus_vr.h | 5 ++++ 4 files changed, 61 insertions(+)
Signature · 1 line
2.37.0
PATCH 1/3 hw/i2c/pmbus: Add idle state to return 0xff's
From: Peter Delevoryas <[email protected]>
--- hw/i2c/pmbus_device.c | 9 +++++++++ include/hw/i2c/pmbus_device.h | 7 +++++++ 2 files changed, 16 insertions(+)
hw/i2c/pmbus_device.c +9 -0
@@ -261,6 +261,11 @@ void pmbus_check_limits(PMBusDevice *pmdev) } } +void pmbus_idle (PMBusDevice *pmdev) +{ + pmdev->code =PMBUS_IDLE_STATE ; +} +/* assert the status_cml error upon receipt of malformed command */ static void pmbus_cml_error (PMBusDevice *pmdev) {
@@ -984,6 +989,10 @@ static uint8_t pmbus_receive_byte(SMBusDevice *smd) }break ; +case PMBUS_IDLE_STATE : +pmbus_send8 (pmdev,PMBUS_ERR_BYTE ); +break ; +case PMBUS_CLEAR_FAULTS :/* Send Byte */ case PMBUS_PAGE_PLUS_WRITE :/* Block Write-only */ case PMBUS_STORE_DEFAULT_ALL :/* Send Byte */
include/hw/i2c/pmbus_device.h +7 -0
@@ -155,6 +155,7 @@ enum pmbus_registers {PMBUS_MFR_MAX_TEMP_1 =0xC0 ,/* R/W word */ PMBUS_MFR_MAX_TEMP_2 =0xC1 ,/* R/W word */ PMBUS_MFR_MAX_TEMP_3 =0xC2 ,/* R/W word */ + PMBUS_IDLE_STATE = 0xFF, };/* STATUS_WORD */
@@ -527,6 +528,12 @@ int pmbus_page_config(PMBusDevice *pmdev, uint8_t page_index, uint64_t flags);*/ void pmbus_check_limits (PMBusDevice *pmdev); +/** +* Enter an idle state where only the PMBUS_ERR_BYTE will be returned +* indefinitely until a new command is issued. +*/ +void pmbus_idle (PMBusDevice *pmdev); +extern const VMStateDescription vmstate_pmbus_device;#define VMSTATE_PMBUS_DEVICE (_field, _state) { \
Signature · 1 line
2.37.0
PATCH 2/3 hw/sensor: Add IC_DEVICE_ID to ISL voltage regulators
In reply to Peter DelevoryasFrom: Peter Delevoryas <[email protected]>
This commit adds a passthrough for PMBUS_IC_DEVICE_ID to allow Renesas voltage regulators to return the integrated circuit device ID if they would like to.
The behavior is very device specific, so it hasn't been added to the general PMBUS model. Additionally, if the device ID hasn't been set, then the voltage regulator will respond with the error byte value. The guest error message will change slightly for IC_DEVICE_ID with this commit.
--- hw/sensor/isl_pmbus_vr.c | 12 ++++++++++++ include/hw/sensor/isl_pmbus_vr.h | 5 +++++ 2 files changed, 17 insertions(+)
hw/sensor/isl_pmbus_vr.c +12 -0
@@ -15,6 +15,18 @@static uint8_t isl_pmbus_vr_read_byte (PMBusDevice *pmdev) { +ISLState *s =ISL69260 (pmdev); + +switch (pmdev->code) { +case PMBUS_IC_DEVICE_ID : +if (!s->ic_device_id_len) { +break ; + } +pmbus_send (pmdev, s->ic_device_id, s->ic_device_id_len); +pmbus_idle (pmdev); +return 0 ; + } +qemu_log_mask (LOG_GUEST_ERROR ,"%s: reading from unsupported register: 0x%02x\n" , __func__, pmdev->code);
include/hw/sensor/isl_pmbus_vr.h +5 -0
@@ -12,12 +12,17 @@#include "hw/i2c/pmbus_device.h" #include "qom/object.h" +#define TYPE_ISL69259 "isl69259"#define TYPE_ISL69260 "isl69260"#define TYPE_RAA228000 "raa228000"#define TYPE_RAA229004 "raa229004" +#define ISL_MAX_IC_DEVICE_ID_LEN 16struct ISLState {PMBusDevice parent; + +uint8_t ic_device_id[ISL_MAX_IC_DEVICE_ID_LEN ]; +uint8_t ic_device_id_len; };OBJECT_DECLARE_SIMPLE_TYPE (ISLState,ISL69260 )
Signature · 1 line
2.37.0
PATCH 3/3 hw/sensor: Add Renesas ISL69259 device model
In reply to Peter DelevoryasFrom: Peter Delevoryas <[email protected]>
This adds the ISL69259, using all the same functionality as the existing ISL69260 but overriding the IC_DEVICE_ID.
--- hw/sensor/isl_pmbus_vr.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
hw/sensor/isl_pmbus_vr.c +28 -0
@@ -119,6 +119,18 @@ static void raa228000_exit_reset(Object *obj) pmdev->pages[0 ].read_temperature_3 =0 ; } +static void isl69259_exit_reset (Object *obj) +{ +ISLState *s =ISL69260 (obj); +static const uint8_t ic_device_id[] = {0x04 ,0x00 ,0x81 ,0xD2 ,0x49 ,0x3c }; +g_assert (sizeof (ic_device_id) <=sizeof (s->ic_device_id)); + +isl_pmbus_vr_exit_reset (obj); + + s->ic_device_id_len =sizeof (ic_device_id); +memcpy (s->ic_device_id, ic_device_id,sizeof (ic_device_id)); +} +static void isl_pmbus_vr_add_props (Object *obj,uint64_t *flags,uint8_t pages) {PMBusDevice *pmdev =PMBUS_DEVICE (obj);
@@ -257,6 +269,21 @@ static void raa229004_class_init(ObjectClass *klass, void *data)isl_pmbus_vr_class_init (klass, data,2 ); } +static void isl69259_class_init (ObjectClass *klass,void *data) +{ +ResettableClass *rc =RESETTABLE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); + dc->desc ="Renesas ISL69259 Digital Multiphase Voltage Regulator" ; + rc->phases.exit = isl69259_exit_reset; +isl_pmbus_vr_class_init (klass, data,2 ); +} + +static const TypeInfo isl69259_info = { + .name =TYPE_ISL69259 , + .parent =TYPE_ISL69260 , + .class_init = isl69259_class_init, +}; +static const TypeInfo isl69260_info = { .name =TYPE_ISL69260 , .parent =TYPE_PMBUS_DEVICE ,
@@ -283,6 +310,7 @@ static const TypeInfo raa228000_info = {static void isl_pmbus_vr_register_types (void ) { +type_register_static (&isl69259_info);type_register_static (&isl69260_info);type_register_static (&raa228000_info);type_register_static (&raa229004_info);
Signature · 1 line
2.37.0