* [PATCH 0/3] hw/sensor: Add ISL69259 with IC_DEVICE_ID
@ 2022-07-01 0:06 Peter Delevoryas
2022-07-01 0:06 ` [PATCH 1/3] hw/i2c/pmbus: Add idle state to return 0xff's Peter Delevoryas
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Peter Delevoryas @ 2022-07-01 0:06 UTC (permalink / raw)
Cc: qemu-devel, clg, titusr, qemu-arm
From: Peter Delevoryas <pdel@fb.com>
Resubmitting these patches separately after having included
and partially reviewd them here:
- https://lore.kernel.org/qemu-devel/20220630045133.32251-9-me@pjd.dev/
- https://lore.kernel.org/qemu-devel/20220630045133.32251-10-me@pjd.dev/
- https://lore.kernel.org/qemu-devel/20220630045133.32251-11-me@pjd.dev/
I added Titus's reviewed-by tags, but Cedric still had one outstanding
issue:
- https://lore.kernel.org/qemu-devel/293da11c-dde2-e646-c754-820720c410de@kaod.org/
But Titus had a response to that issue, so we may or may not ignore it:
- https://lore.kernel.org/qemu-devel/CAMvPwGpZZgAd2RHXmvmxfgyTyVGd6Rx+avj=E24NWc0masdc=A@mail.gmail.com/
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(+)
--
2.37.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] hw/i2c/pmbus: Add idle state to return 0xff's
2022-07-01 0:06 [PATCH 0/3] hw/sensor: Add ISL69259 with IC_DEVICE_ID Peter Delevoryas
@ 2022-07-01 0:06 ` Peter Delevoryas
2022-07-01 0:06 ` [PATCH 2/3] hw/sensor: Add IC_DEVICE_ID to ISL voltage regulators Peter Delevoryas
2022-07-01 0:06 ` [PATCH 3/3] hw/sensor: Add Renesas ISL69259 device model Peter Delevoryas
2 siblings, 0 replies; 4+ messages in thread
From: Peter Delevoryas @ 2022-07-01 0:06 UTC (permalink / raw)
Cc: qemu-devel, clg, titusr, qemu-arm
From: Peter Delevoryas <pdel@fb.com>
Signed-off-by: Peter Delevoryas <pdel@fb.com>
Reviewed-by: Titus Rwantare <titusr@google.com>
---
hw/i2c/pmbus_device.c | 9 +++++++++
include/hw/i2c/pmbus_device.h | 7 +++++++
2 files changed, 16 insertions(+)
diff --git a/hw/i2c/pmbus_device.c b/hw/i2c/pmbus_device.c
index 62885fa6a1..f89fea65f3 100644
--- a/hw/i2c/pmbus_device.c
+++ b/hw/i2c/pmbus_device.c
@@ -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 */
diff --git a/include/hw/i2c/pmbus_device.h b/include/hw/i2c/pmbus_device.h
index 0f4d6b3fad..93f5d57c9d 100644
--- a/include/hw/i2c/pmbus_device.h
+++ b/include/hw/i2c/pmbus_device.h
@@ -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) { \
--
2.37.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] hw/sensor: Add IC_DEVICE_ID to ISL voltage regulators
2022-07-01 0:06 [PATCH 0/3] hw/sensor: Add ISL69259 with IC_DEVICE_ID Peter Delevoryas
2022-07-01 0:06 ` [PATCH 1/3] hw/i2c/pmbus: Add idle state to return 0xff's Peter Delevoryas
@ 2022-07-01 0:06 ` Peter Delevoryas
2022-07-01 0:06 ` [PATCH 3/3] hw/sensor: Add Renesas ISL69259 device model Peter Delevoryas
2 siblings, 0 replies; 4+ messages in thread
From: Peter Delevoryas @ 2022-07-01 0:06 UTC (permalink / raw)
Cc: qemu-devel, clg, titusr, qemu-arm
From: Peter Delevoryas <pdel@fb.com>
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.
Signed-off-by: Peter Delevoryas <pdel@fb.com>
Reviewed-by: Titus Rwantare <titusr@google.com>
---
hw/sensor/isl_pmbus_vr.c | 12 ++++++++++++
include/hw/sensor/isl_pmbus_vr.h | 5 +++++
2 files changed, 17 insertions(+)
diff --git a/hw/sensor/isl_pmbus_vr.c b/hw/sensor/isl_pmbus_vr.c
index e11e028884..799ea9d89e 100644
--- a/hw/sensor/isl_pmbus_vr.c
+++ b/hw/sensor/isl_pmbus_vr.c
@@ -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);
diff --git a/include/hw/sensor/isl_pmbus_vr.h b/include/hw/sensor/isl_pmbus_vr.h
index 3e47ff7e48..aa2c2767df 100644
--- a/include/hw/sensor/isl_pmbus_vr.h
+++ b/include/hw/sensor/isl_pmbus_vr.h
@@ -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 16
struct 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)
--
2.37.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] hw/sensor: Add Renesas ISL69259 device model
2022-07-01 0:06 [PATCH 0/3] hw/sensor: Add ISL69259 with IC_DEVICE_ID Peter Delevoryas
2022-07-01 0:06 ` [PATCH 1/3] hw/i2c/pmbus: Add idle state to return 0xff's Peter Delevoryas
2022-07-01 0:06 ` [PATCH 2/3] hw/sensor: Add IC_DEVICE_ID to ISL voltage regulators Peter Delevoryas
@ 2022-07-01 0:06 ` Peter Delevoryas
2 siblings, 0 replies; 4+ messages in thread
From: Peter Delevoryas @ 2022-07-01 0:06 UTC (permalink / raw)
Cc: qemu-devel, clg, titusr, qemu-arm
From: Peter Delevoryas <pdel@fb.com>
This adds the ISL69259, using all the same functionality as the existing
ISL69260 but overriding the IC_DEVICE_ID.
Signed-off-by: Peter Delevoryas <pdel@fb.com>
Reviewed-by: Titus Rwantare <titusr@google.com>
---
hw/sensor/isl_pmbus_vr.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/hw/sensor/isl_pmbus_vr.c b/hw/sensor/isl_pmbus_vr.c
index 799ea9d89e..eb344dd5a9 100644
--- a/hw/sensor/isl_pmbus_vr.c
+++ b/hw/sensor/isl_pmbus_vr.c
@@ -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);
--
2.37.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-07-01 0:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-01 0:06 [PATCH 0/3] hw/sensor: Add ISL69259 with IC_DEVICE_ID Peter Delevoryas
2022-07-01 0:06 ` [PATCH 1/3] hw/i2c/pmbus: Add idle state to return 0xff's Peter Delevoryas
2022-07-01 0:06 ` [PATCH 2/3] hw/sensor: Add IC_DEVICE_ID to ISL voltage regulators Peter Delevoryas
2022-07-01 0:06 ` [PATCH 3/3] hw/sensor: Add Renesas ISL69259 device model Peter Delevoryas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).