initial support for yosemite 4
Subsystems (2)
v8 cover initial support for yosemite 4
From: Alexander Hansen <[email protected]>
compared to v7, there is now also partial support for PCA9544, which was needed since it's apparently in front of the FRU eeproms [1]. Previous versions of this series did not account for that because testing was done with a downstream image which had patches still applied [2].
This updated version should line up with the dts [1] and work with an unmodified yv4 image.
References:
[1] https://github.com/torvalds/linux/blob/24a19b953e2a3d0ea5a8c4951a0ab8f32720c907/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts#L597
[2] https://discordapp.com/channels/775381525260664832/867820390406422538/1541811213988528128
Alexander Hansen (5):
hw/i2c: support PCA9544
ast2600: yosemite4 initial support
ast2600: yosemite4 functional test
hw/sensor: MAX31790 support
hw/sensor: support MAX11615
MAINTAINERS | 2 + docs/system/arm/aspeed.rst | 5 +- hw/arm/Kconfig | 2 + hw/arm/aspeed_ast2600_fby4.c | 292 +++++++++++++ hw/arm/meson.build | 1 + hw/i2c/i2c_mux_pca954x.c | 88 +++- hw/sensor/Kconfig | 8 + hw/sensor/max1161x.c | 314 ++++++++++++++ hw/sensor/max31790.c | 508 +++++++++++++++++++++++ hw/sensor/meson.build | 2 + hw/sensor/trace-events | 22 + include/hw/i2c/i2c_mux_pca954x.h | 1 + include/hw/sensor/max1161x.h | 7 + include/hw/sensor/max31790.h | 7 + tests/functional/arm/meson.build | 2 + tests/functional/arm/test_aspeed_fby4.py | 101 +++++ 16 files changed, 1349 insertions(+), 13 deletions(-) create mode 100644 hw/arm/aspeed_ast2600_fby4.c create mode 100644 hw/sensor/max1161x.c create mode 100644 hw/sensor/max31790.c create mode 100644 include/hw/sensor/max1161x.h create mode 100644 include/hw/sensor/max31790.h create mode 100755 tests/functional/arm/test_aspeed_fby4.py
Signature · 1 line
2.56.0
PATCH v8 1/5 hw/i2c: support PCA9544
From: Alexander Hansen <[email protected]>
Who to explain it better than the manufacturer:
``` The PCA9544A is a 1-of-4 bidirectional translating multiplexer, controlled via the I2C-bus. The SCL/SDA upstream pair fans out to four SCx/SDx downstream pairs, or channels. Only one SCx/SDx channel is selected at a time, determined by the contents of the programmable control register. ```
The device updates the selected channel after STOP condition, not on the last byte written [1].
For this reason the parent event handler has to be hooked to prevent write-read sequence from updating channel selection before STOP condition.
Reset also had to be modified since a write would not apply the channel selection by itself.
This emulation is done to support yosemite4 machine emulation.
Interrupt forwarding is currently UNSUPPORTED.
References:
[1] https://www.nxp.com/docs/en/data-sheet/PCA9544A.pdf
--- hw/i2c/i2c_mux_pca954x.c | 88 ++++++++++++++++++++++++++++---- include/hw/i2c/i2c_mux_pca954x.h | 1 + 2 files changed, 78 insertions(+), 11 deletions(-)
hw/i2c/i2c_mux_pca954x.c +77 -11
@@ -30,6 +30,10 @@#define PCA9548_CHANNEL_COUNT 8#define PCA9546_CHANNEL_COUNT 4 +#define PCA9544_CHANNEL_COUNT 4 + +/* enable bit */ +#define PCA9544_ENABLE 0x4/* * struct Pca954xState - The pca954x state object.
@@ -56,6 +60,11 @@ typedef struct Pca954xClass {SMBusDeviceClass parent;uint8_t nchans; + +/* channel enable bit for mux devices, zero for switches */ +uint8_t mux_enable; + +int (*parent_event)(I2CSlave *s,enum i2c_event event); } Pca954xClass;#define TYPE_PCA954X "pca954x"
@@ -99,28 +108,43 @@ static bool pca954x_match(I2CSlave *candidate, uint8_t address,return broadcast; } -static void pca954x_enable_channel (Pca954xState *s,uint8_t enable_mask) +static void pca954x_enable_channel (Pca954xState *s,uint8_t control) {Pca954xClass *mc =PCA954X_GET_CLASS (s);int i; +if (mc->mux_enable) { +uint8_t selected = control & (mc->mux_enable -1 ); +bool enabled = control & mc->mux_enable; + +for (i =0 ; i < mc->nchans; i++) { + s->enabled[i] = enabled && i == selected; + } +return ; + } +/* -* For each channel, check if their bit is set in enable_mask and if yes, +* For each channel, check if their bit is set in control and if yes, * enable it, otherwise disable, hide it. */ for (i =0 ; i < mc->nchans; i++) { -if (enable_mask & (1 << i)) { - s->enabled[i] = true; - }else { - s->enabled[i] = false; - } + s->enabled[i] = control & (1 << i); } }static void pca954x_write (Pca954xState *s,uint8_t data) { - s->control = data; -pca954x_enable_channel (s, data); +Pca954xClass *mc =PCA954X_GET_CLASS (s); +uint8_t data_writable = data; + +if (mc->mux_enable) { + data_writable = data &0x0f ; + } + + s->control = data_writable; +if (!mc->mux_enable) { +pca954x_enable_channel (s, data_writable); + }trace_pca954x_write_bytes (data); }
@@ -128,6 +152,7 @@ static void pca954x_write(Pca954xState *s, uint8_t data)static int pca954x_write_data (SMBusDevice *d,uint8_t *buf,uint8_t len) {Pca954xState *s =PCA954X (d); +Pca954xClass *mc =PCA954X_GET_CLASS (s);if (len ==0 ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: writing empty data\n" , __func__);
@@ -136,15 +161,17 @@ static int pca954x_write_data(SMBusDevice *d, uint8_t *buf, uint8_t len)/* * len should be 1, because they write one byte to enable/disable channels. +* In case of PCA9544A, multiple bytes can be written but only the last one +* will be used. */ -if (len >1 ) { +if (len >1 && !mc->mux_enable) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: extra data after channel selection mask\n" , __func__);return -1 ; } -pca954x_write (s, buf[0 ]); +pca954x_write (s, buf[len -1 ]);return 0 ; }
@@ -156,11 +183,33 @@ static uint8_t pca954x_read_byte(SMBusDevice *d)return data; } +static int pca954x_event (I2CSlave *s,enum i2c_event event) +{ +Pca954xState *state =PCA954X (s); +Pca954xClass *mc =PCA954X_GET_CLASS (state); + +int res = mc->parent_event (s, event); + +/* +* When a channel is selected, it will become active after +* a STOP condition has been placed on the I2C-bus. +*/ +if (mc->mux_enable && event ==I2C_FINISH ) { +pca954x_enable_channel (state, state->control); + } +return res; +} +static void pca954x_enter_reset (Object *obj,ResetType type) {Pca954xState *s =PCA954X (obj); +Pca954xClass *mc =PCA954X_GET_CLASS (s);/* Reset will disable all channels. */ pca954x_write (s,0 ); + +if (mc->mux_enable) { +pca954x_enable_channel (s, s->control); + } }I2CBus *pca954x_i2c_get_bus (I2CSlave *mux,uint8_t channel)
@@ -172,6 +221,13 @@ I2CBus *pca954x_i2c_get_bus(I2CSlave *mux, uint8_t channel)return pca954x->bus[channel]; } +static void pca9544_class_init (ObjectClass *klass,const void *data) +{ +Pca954xClass *s =PCA954X_CLASS (klass); + s->nchans =PCA9544_CHANNEL_COUNT ; + s->mux_enable =PCA9544_ENABLE ; +} +static void pca9546_class_init (ObjectClass *klass,const void *data) {Pca954xClass *s =PCA954X_CLASS (klass);
@@ -221,8 +277,13 @@ static void pca954x_class_init(ObjectClass *klass, const void *data)ResettableClass *rc =RESETTABLE_CLASS (klass);DeviceClass *dc =DEVICE_CLASS (klass);SMBusDeviceClass *k =SMBUS_DEVICE_CLASS (klass); +Pca954xClass *s =PCA954X_CLASS (klass); + +/* hook our parent event handler */ + s->parent_event = sc->event; sc->match_and_add = pca954x_match; + sc->event = pca954x_event; rc->phases.enter = pca954x_enter_reset;
@@ -245,6 +306,11 @@ static const TypeInfo pca954x_info[] = { .class_init = pca954x_class_init, .abstract = true, }, + { + .name = TYPE_PCA9544, + .parent = TYPE_PCA954X, + .class_init = pca9544_class_init, + }, { .name = TYPE_PCA9546, .parent = TYPE_PCA954X,
include/hw/i2c/i2c_mux_pca954x.h +1 -0
@@ -3,6 +3,7 @@#include "hw/i2c/i2c.h" +#define TYPE_PCA9544 "pca9544"#define TYPE_PCA9546 "pca9546"#define TYPE_PCA9548 "pca9548"
Signature · 1 line
2.56.0
Re: [PATCH v8 1/5] hw/i2c: support PCA9544
Quoted 11 lines · On 13 Oct 2026, at 20:46, [email protected] wrote:
From: Alexander Hansen <[email protected]>
Who to explain it better than the manufacturer:
``` The PCA9544A is a 1-of-4 bidirectional translating multiplexer, controlled via the I2C-bus. The SCL/SDA upstream pair fans out to four SCx/SDx downstream pairs, or channels. Only one SCx/SDx channel is selected at a time, determined by the contents of the programmable control register. ```
Might be worth to add a note on how this device differs from the previously supported ones, to spot the channel selection behavior?
Quoted 2 lines
The device updates the selected channel after STOP condition, not on the last byte written [1].
See below: I think this is the case for all supported devices, and that existing emulation is not fully valid on this point.
Quoted 8 lines
For this reason the parent event handler has to be hooked to prevent write-read sequence from updating channel selection before STOP condition.
Reset also had to be modified since a write would not apply the channel selection by itself.
This emulation is done to support yosemite4 machine emulation.
Maybe part of the cover letter rather than this specific commit?
Quoted 24 lines
Interrupt forwarding is currently UNSUPPORTED.
References:
[1] https://www.nxp.com/docs/en/data-sheet/PCA9544A.pdfCc Patrick Leis <[email protected]> (maintainer:pca954x)Cc Emmanuel Blot <[email protected]>Cc Titus Rwantare <[email protected]>Cc "Cédric Le Goater" <[email protected]> (maintainer:ASPEED BMCs)Cc [email protected] (open list:ASPEED BMCs)Cc [email protected] (open list:All patches CC here)Signed-off-by Alexander Hansen <[email protected]>--- hw/i2c/i2c_mux_pca954x.c | 88 ++++++++++++++++++++++++++++---- include/hw/i2c/i2c_mux_pca954x.h | 1 + 2 files changed, 78 insertions(+), 11 deletions(-)hw/i2c/i2c_mux_pca954x.c +0
-0
hw/i2c/i2c_mux_pca954x.c line 35
Quoted 6 lines
hw/i2c/i2c_mux_pca954x.c +4
-0@@ -30,6 +30,10 @@#define PCA9548_CHANNEL_COUNT 8#define PCA9546_CHANNEL_COUNT 4 +#define PCA9544_CHANNEL_COUNT 4 + +/* enable bit */ +#define PCA9544_ENABLE 0x4
It seems PCA9544_ENABLE is used both as a flag and to compute the channel mask.
It might be easier to read using a boolean for the flag, and (PCA9544_CHANNEL_COUNT - 1) or (mc->nchans - 1) for the mask?
hw/i2c/i2c_mux_pca954x.c typedef struct Pca954xClass { · line 65
Quoted 9 lines
hw/i2c/i2c_mux_pca954x.c +3
-0/* * struct Pca954xState - The pca954x state object. @@ -56,6 +60,11 @@ typedef struct Pca954xClass {SMBusDeviceClass parent;uint8_t nchans; + +/* channel enable bit for mux devices, zero for switches */ +uint8_t mux_enable;
Exiting document style (@mux_enable …) in struct Pca954xClass comment block should be preferred.
Quoted 39 lines
hw/i2c/i2c_mux_pca954x.c +15
-7+ +int (*parent_event)(I2CSlave *s,enum i2c_event event); } Pca954xClass;#define TYPE_PCA954X "pca954x"@@ -99,28 +108,43 @@ static bool pca954x_match(I2CSlave *candidate, uint8_t address,return broadcast; } -static void pca954x_enable_channel (Pca954xState *s,uint8_t enable_mask) +static void pca954x_enable_channel (Pca954xState *s,uint8_t control) {Pca954xClass *mc =PCA954X_GET_CLASS (s);int i; +if (mc->mux_enable) { +uint8_t selected = control & (mc->mux_enable -1 ); +bool enabled = control & mc->mux_enable; + +for (i =0 ; i < mc->nchans; i++) { + s->enabled[i] = enabled && i == selected; + } +return ; + } +/* -* For each channel, check if their bit is set in enable_mask and if yes, +* For each channel, check if their bit is set in control and if yes, * enable it, otherwise disable, hide it. */ for (i =0 ; i < mc->nchans; i++) { -if (enable_mask & (1 << i)) { - s->enabled[i] = true; - }else { - s->enabled[i] = false; - } + s->enabled[i] = control & (1 << i); } }
hw/i2c/i2c_mux_pca954x.c static bool pca954x_match(I2CSlave *candidate, uint8_t address, · line 141
Quoted 10 lines
hw/i2c/i2c_mux_pca954x.c +5
-2static void pca954x_write (Pca954xState *s,uint8_t data) { - s->control = data; -pca954x_enable_channel (s, data); +Pca954xClass *mc =PCA954X_GET_CLASS (s); +uint8_t data_writable = data; + +if (mc->mux_enable) { + data_writable = data &0x0f ;
Maybe use a named constant here
hw/i2c/i2c_mux_pca954x.c static bool pca954x_match(I2CSlave *candidate, uint8_t address, · line 147
Quoted 6 lines
hw/i2c/i2c_mux_pca954x.c +6
-0+ } + + s->control = data_writable; +if (!mc->mux_enable) { +pca954x_enable_channel (s, data_writable); + }
Maybe simplify this whole function:
- channel enablement occurs on STOP condition for all devices, not only PCA9544; channel enablement should be deferred to this event.
- I think pca954x_enable_channel always ignore non-channel bits, whatever the device
Could be as simple as:s->control = mc->mux_enable ? data & 0x0f : data;
Quoted 12 lines
hw/i2c/i2c_mux_pca954x.c +1
-0trace_pca954x_write_bytes (data); }@@ -128,6 +152,7 @@ static void pca954x_write(Pca954xState *s, uint8_t data)static int pca954x_write_data (SMBusDevice *d,uint8_t *buf,uint8_t len) {Pca954xState *s =PCA954X (d); +Pca954xClass *mc =PCA954X_GET_CLASS (s);if (len ==0 ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: writing empty data\n" , __func__);
hw/i2c/i2c_mux_pca954x.c static int pca954x_write_data(SMBusDevice *d, uint8_t *buf, uint8_t len) · line 166
Quoted 6 lines
hw/i2c/i2c_mux_pca954x.c +2
-0@@ -136,15 +161,17 @@ static int pca954x_write_data(SMBusDevice *d, uint8_t *buf, uint8_t len)/* * len should be 1, because they write one byte to enable/disable channels. +* In case of PCA9544A, multiple bytes can be written but only the last one +* will be used. */
I think for all devices, last byte is always considered, there is no special case for PCA9544. The error log call / return error could then be removed.
Quoted 30 lines
hw/i2c/i2c_mux_pca954x.c +15
-2-if (len >1 ) { +if (len >1 && !mc->mux_enable) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: extra data after channel selection mask\n" , __func__);return -1 ; } -pca954x_write (s, buf[0 ]); +pca954x_write (s, buf[len -1 ]);return 0 ; }@@ -156,11 +183,33 @@ static uint8_t pca954x_read_byte(SMBusDevice *d)return data; } +static int pca954x_event (I2CSlave *s,enum i2c_event event) +{ +Pca954xState *state =PCA954X (s); +Pca954xClass *mc =PCA954X_GET_CLASS (state); + +int res = mc->parent_event (s, event); + +/* +* When a channel is selected, it will become active after +* a STOP condition has been placed on the I2C-bus. +*/ +if (mc->mux_enable && event ==I2C_FINISH ) { +pca954x_enable_channel (state, state->control);
hw/i2c/i2c_mux_pca954x.c static uint8_t pca954x_read_byte(SMBusDevice *d) · line 208
Quoted 10 lines
hw/i2c/i2c_mux_pca954x.c +5
-0+ } +return res; +} +static void pca954x_enter_reset (Object *obj,ResetType type) {Pca954xState *s =PCA954X (obj); +Pca954xClass *mc =PCA954X_GET_CLASS (s);/* Reset will disable all channels. */ pca954x_write (s,0 );
I would favor a call to pca954x_enable_channel rather than pca954x_write here whatever the device kind, it would be cleaner as pca954x_write does masking then call pca954x_enable_channel and it’s not a write call per se.
Quoted 8 lines
hw/i2c/i2c_mux_pca954x.c +4
-0+ +if (mc->mux_enable) { +pca954x_enable_channel (s, s->control); + } }I2CBus *pca954x_i2c_get_bus (I2CSlave *mux,uint8_t channel)
hw/i2c/i2c_mux_pca954x.c I2CBus *pca954x_i2c_get_bus(I2CSlave *mux, uint8_t channel) · line 226
Quoted 6 lines
hw/i2c/i2c_mux_pca954x.c +3
-0@@ -172,6 +221,13 @@ I2CBus *pca954x_i2c_get_bus(I2CSlave *mux, uint8_t channel)return pca954x->bus[channel]; } +static void pca9544_class_init (ObjectClass *klass,const void *data) +{ +Pca954xClass *s =PCA954X_CLASS (klass);
Prefer c or k, as s is usually used with *State structures.
Quoted 47 lines
hw/i2c/i2c_mux_pca954x.c +14
-0+ s->nchans =PCA9544_CHANNEL_COUNT ; + s->mux_enable =PCA9544_ENABLE ; +} +static void pca9546_class_init (ObjectClass *klass,const void *data) {Pca954xClass *s =PCA954X_CLASS (klass);@@ -221,8 +277,13 @@ static void pca954x_class_init(ObjectClass *klass, const void *data)ResettableClass *rc =RESETTABLE_CLASS (klass);DeviceClass *dc =DEVICE_CLASS (klass);SMBusDeviceClass *k =SMBUS_DEVICE_CLASS (klass); +Pca954xClass *s =PCA954X_CLASS (klass); + +/* hook our parent event handler */ + s->parent_event = sc->event; sc->match_and_add = pca954x_match; + sc->event = pca954x_event; rc->phases.enter = pca954x_enter_reset;@@ -245,6 +306,11 @@ static const TypeInfo pca954x_info[] = { .class_init = pca954x_class_init, .abstract = true, }, + { + .name = TYPE_PCA9544, + .parent = TYPE_PCA954X, + .class_init = pca9544_class_init, + }, { .name = TYPE_PCA9546, .parent = TYPE_PCA954X,include/hw/i2c/i2c_mux_pca954x.h +1
-0@@ -3,6 +3,7 @@#include "hw/i2c/i2c.h" +#define TYPE_PCA9544 "pca9544"#define TYPE_PCA9546 "pca9546"#define TYPE_PCA9548 "pca9548"Signature · 1 line
2.56.0
Note: it might be worth splitting this commit into:
1. existing PCA954x fixes:
- update channel enablement on STOP bit
- last-byte-wins
- enable_channel loop simplification
- reset calls …enable_channel rather than …write
- header inclusion removal (sys bus.h at least)
- …
2. adding support for PCA9544
Emmanuel.
PATCH v8 2/5 ast2600: yosemite4 initial support
In reply to [email protected]From: Alexander Hansen <[email protected]>
Initial patch based on [1] to support yosemite v4 bmc emulation.
The goal of this machine support is to support OpenBMC development.
Reference linux devicetree from openbmc linux is [2].
Status:
- Enclosure FRU: showing up - Management Board FRU: showing up - Blade Board FRU: showing up - Blade Board sensors: not implemented - Blade Chassis FRU: showing up - Fan Board FRU: both showing up - Fan Board sensors: supported
Overall the emulation is incomplete but already helpful in development and testing.
The focus of this initial support is on the FRU eeproms and fanboard sensors.
Tested: booted an OpenBMC image for yosemite4 target.
References:
[1] https://github.com/9elements/qemu/commit/32139f913c2bd0ebe4bd26c46765861f6f9f2d49
[2] arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts
[3] https://github.com/legoater/qemu-aspeed-boot/pull/5
--- docs/system/arm/aspeed.rst | 5 +- hw/arm/aspeed_ast2600_fby4.c | 290 +++++++++++++++++++++++++++++++++++ hw/arm/meson.build | 1 + 3 files changed, 294 insertions(+), 2 deletions(-) create mode 100644 hw/arm/aspeed_ast2600_fby4.c
docs/system/arm/aspeed.rst +3 -2
@@ -1,5 +1,5 @@ -Aspeed family boards (``anacapa-bmc``, ``ast2500-evb``, ``ast2600-evb``, ``bletchley-bmc``, ``fuji-bmc``, ``gb200nvl-bmc``, ``fby35-bmc``, ``g220a-bmc``, ``palmetto-bmc``, ``quanta-q71l-bmc``, ``rainier-bmc``, ``romulus-bmc``, ``supermicrox11-bmc``, ``supermicrox11spi-bmc``, ``tiogapass-bmc``, ``witherspoon-bmc``, ``yosemitev2-bmc``) -=============================================================================================================================================================================================================================================================================================================================================== +Aspeed family boards (``anacapa-bmc``, ``ast2500-evb``, ``ast2600-evb``, ``bletchley-bmc``, ``fuji-bmc``, ``gb200nvl-bmc``, ``fby35-bmc``, ``fby4-bmc``, ``g220a-bmc``, ``palmetto-bmc``, ``quanta-q71l-bmc``, ``rainier-bmc``, ``romulus-bmc``, ``supermicrox11-bmc``, ``supermicrox11spi-bmc``, ``tiogapass-bmc``, ``witherspoon-bmc``, ``yosemitev2-bmc``) +============================================================================================================================================================================================================================================================================================================================================================= The QEMU Aspeed machines model BMCs of various OpenPOWER systems and Aspeed evaluation boards. They are based on different releases of the
@@ -33,6 +33,7 @@ AST2600 SoC based machines : - ``fuji-bmc`` Facebook Fuji BMC - ``bletchley-bmc`` Facebook Bletchley BMC - ``fby35-bmc`` Facebook fby35 BMC +- ``fby4-bmc`` Facebook fby4 BMC - ``anacapa-bmc`` Facebook Anacapa BMC - ``gb200nvl-bmc`` Nvidia GB200nvl BMC
hw/arm/aspeed_ast2600_fby4.c new file +290 -0
290 lines not on this page · raw message
hw/arm/meson.build +1 -0
@@ -61,6 +61,7 @@ arm_common_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( 'aspeed_ast2600_catalina.c', 'aspeed_ast2600_evb.c', 'aspeed_ast2600_fby35.c', + 'aspeed_ast2600_fby4.c', 'aspeed_ast2600_fuji.c', 'aspeed_ast2600_gb200nvl.c', 'aspeed_ast2600_rainier.c',
Signature · 1 line
2.56.0
PATCH v8 3/5 ast2600: yosemite4 functional test
In reply to [email protected]From: Alexander Hansen <[email protected]>
Add a functional test for the Yosemite V4 (fby4-bmc) machine that validates:
- U-Boot initialization and kernel boot sequence
The test uses an OpenBMC image built for the yosemite4 board and validates console output through the boot process.
--- tests/functional/arm/meson.build | 2 ++ tests/functional/arm/test_aspeed_fby4.py | 45 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100755 tests/functional/arm/test_aspeed_fby4.py
tests/functional/arm/meson.build +2 -0
@@ -15,6 +15,7 @@ test_arm_timeouts = { 'aspeed_anacapa' : 480, 'aspeed_bletchley' : 480, 'aspeed_catalina' : 480, + 'aspeed_fby4': 480, 'aspeed_gb200nvl_bmc' : 480, 'aspeed_rainier' : 480, 'bpim2u' : 500,
@@ -50,6 +51,7 @@ tests_arm_system_thorough = [ 'aspeed_anacapa', 'aspeed_bletchley', 'aspeed_catalina', + 'aspeed_fby4', 'aspeed_gb200nvl_bmc', 'aspeed_rainier', 'bpim2u',
tests/functional/arm/test_aspeed_fby4.py new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.56.0
PATCH v8 4/5 hw/sensor: MAX31790 support
In reply to [email protected]From: Alexander Hansen <[email protected]>
Product: [1]
Datasheet: [2]
MAX31790 Support:
- fan inputs are reading
- tach reading propertional to pwm setting from linux driver
- fans do not show any fault
- 6 PWM registers influence 6 TACH registers
There is intentional stub behavior in some places and various functions of the device are currently unsupported.
MAX31790 currently unsupported:
- slave address restriction
- fan dynamics
- spin-up configuration
- fault state / failure possibility
- rate-of-change control
- tach mode
- mixed layouts where number of fans != number of tachs
- see Figure 5.9 in [2] for example of mixed layout
Anyone could expand it in the future for more accurate emulation.
The reason for adding this device is to support Yosemite V4 emulation.
Tested: on yosemite 4 qemu
root@yosemite4:~# ls /sys/class/hwmon/hwmon2/ device fan2_fault fan3_target fan5_fault fan6_target pwm2 pwm5 fan1_enable fan2_input fan4_enable fan5_input name pwm2_enable pwm5_enable fan1_fault fan2_target fan4_fault fan5_target of_node pwm3 pwm6 fan1_input fan3_enable fan4_input fan6_enable power pwm3_enable pwm6_enable fan1_target fan3_fault fan4_target fan6_fault pwm1 pwm4 subsystem fan2_enable fan3_input fan5_enable fan6_input pwm1_enable pwm4_enable uevent root@yosemite4:~# cat /sys/class/hwmon/hwmon2/fan1_input 4551 root@yosemite4:~# cat /sys/class/hwmon/hwmon2/fan1_enable 1 root@yosemite4:~# cat /sys/class/hwmon/hwmon2/fan1_fault 0 root@yosemite4:~# cat /sys/class/hwmon/hwmon2/fan1_target 2048 root@yosemite4:~# cat /sys/class/hwmon/hwmon2/pwm1 178 root@yosemite4:~# cat /sys/class/hwmon/hwmon2/name max31790
Trace output:max31790_realize i2c_addr: 0x20 max31790_realize i2c_addr: 0x2f max31790_realize i2c_addr: 0x20 max31790_realize i2c_addr: 0x2f max31790_event i2c_addr: 0x20, event: 0x01 max31790_send i2c_addr: 0x20, data: 0x02 max31790_event i2c_addr: 0x20, event: 0x00 max31790_recv i2c_addr: 0x20, reg_addr: 0x02 max31790_recv_return i2c_addr: 0x20, returns: 0x08
...
References:
[1] https://www.analog.com/en/products/MAX31790.html
[2] https://www.analog.com/media/en/technical-documentation/data-sheets/MAX31790.pdf
--- MAINTAINERS | 1 + hw/arm/Kconfig | 1 + hw/arm/aspeed_ast2600_fby4.c | 5 +- hw/sensor/Kconfig | 4 + hw/sensor/max31790.c | 508 +++++++++++++++++++++++ hw/sensor/meson.build | 1 + hw/sensor/trace-events | 13 + include/hw/sensor/max31790.h | 7 + tests/functional/arm/test_aspeed_fby4.py | 47 +++ 9 files changed, 585 insertions(+), 2 deletions(-) create mode 100644 hw/sensor/max31790.c create mode 100644 include/hw/sensor/max31790.h
MAINTAINERS +1 -0
@@ -4119,6 +4119,7 @@ S: Maintained F: hw/i2c/pmbus_device.c F: hw/sensor/adm1272.c F: hw/sensor/isl_pmbus_vr.c +F: hw/sensor/max31790.c F: hw/sensor/max34451.c F: include/hw/i2c/pmbus_device.h F: include/hw/sensor/isl_pmbus_vr.h
hw/arm/Kconfig +1 -0
@@ -545,6 +545,7 @@ config ASPEED_SOC select PMBUS select MAX31785 select ADC128D818 + select MAX31790 select FSI_APB2OPB_ASPEED select AT24C select PCI_EXPRESS_ASPEED
hw/arm/aspeed_ast2600_fby4.c +3 -2
@@ -12,6 +12,7 @@#include "hw/arm/aspeed_soc.h" #include "hw/nvram/eeprom_at24c.h" #include "hw/i2c/i2c_mux_pca954x.h" +#include "hw/sensor/max31790.h" #include "hw/gpio/pca9552.h" #include "hw/sensor/tmp105.h"
@@ -166,7 +167,7 @@ static void fby4_i2c_init_fanboard(I2CSlave *fan_mux, size_t eepromSize)i2c_slave_create_simple (bus,TYPE_ADC128D818 ,0x1f );/* maxim,max31790 @ 0x20 (pwm) */ -/* TODO */ +i2c_slave_create_simple (bus,TYPE_MAX31790 ,0x20 );/* * ti,tca6424 @ 0x22 (gpio)
@@ -184,7 +185,7 @@ static void fby4_i2c_init_fanboard(I2CSlave *fan_mux, size_t eepromSize)*/ /* maxim,max31790 @ 0x2f (pwm) */ -/* TODO */ +i2c_slave_create_simple (bus,TYPE_MAX31790 ,0x2f );/* maxim,max11615 @ 0x33 (adc) */ /* TODO */
hw/sensor/Kconfig +4 -0
@@ -47,3 +47,7 @@ config ISL_PMBUS_VR config MAX31785 bool depends on PMBUS + +config MAX31790 + bool + depends on I2C
hw/sensor/max31790.c new file +508 -0
508 lines not on this page · raw message
hw/sensor/meson.build +1 -0
@@ -9,3 +9,4 @@ system_ss.add(when: 'CONFIG_MAX34451', if_true: files('max34451.c')) system_ss.add(when: 'CONFIG_LSM303DLHC_MAG', if_true: files('lsm303dlhc_mag.c')) system_ss.add(when: 'CONFIG_ISL_PMBUS_VR', if_true: files('isl_pmbus_vr.c')) system_ss.add(when: 'CONFIG_MAX31785', if_true: files('max31785.c')) +system_ss.add(when: 'CONFIG_MAX31790', if_true: files('max31790.c'))
hw/sensor/trace-events +13 -0
@@ -12,3 +12,16 @@ adc128d818_reset(const char *id, const char *source) "%s %s" tmp105_read(uint8_t dev, uint8_t addr) "device: 0x%02x, addr: 0x%02x" tmp105_write(uint8_t dev, uint8_t addr) "device: 0x%02x, addr 0x%02x" tmp105_write_shutdown(uint8_t dev) "device: 0x%02x" + +# max31790.c +max31790_send(uint8_t i2c_addr, uint8_t send) "i2c_addr: 0x%02x, data: 0x%02x" +max31790_recv_return(uint8_t i2c_addr, uint8_t reg_addr, uint8_t data) "i2c_addr: 0x%02x, reg_addr: 0x%02x, returns: 0x%02x" +max31790_realize(uint8_t i2c_addr) "i2c_addr: 0x%02x" +max31790_reset(uint8_t i2c_addr) "i2c_addr: 0x%02x" +max31790_pwm_write(uint8_t i2c_addr, size_t index, uint16_t value) "i2c_addr: 0x%02x, index: %zu, value: 0x%04x" +max31790_rpm_write(uint8_t i2c_addr, size_t index, uint16_t value) "i2c_addr: 0x%02x, index: %zu, value: 0x%04x" +max31790_tach_count_reg(uint8_t i2c_addr, size_t index, uint16_t value) "i2c_addr: 0x%02x, index: %zu, value: 0x%04x" +max31790_fan_dynamics_read(uint8_t i2c_addr, size_t channel, uint8_t value) "i2c_addr: 0x%02x, channel: %zu, value: 0x%02x" +max31790_fan_dynamics_write(uint8_t i2c_addr, size_t channel, uint8_t value) "i2c_addr: 0x%02x, channel: %zu, value: 0x%02x" +max31790_fan_config_read(uint8_t i2c_addr, size_t channel, uint8_t value) "i2c_addr: 0x%02x, channel: %zu, value: 0x%02x" +max31790_fan_config_write(uint8_t i2c_addr, size_t channel, uint8_t value) "i2c_addr: 0x%02x, channel: %zu, value: 0x%02x"
include/hw/sensor/max31790.h new file +7 -0
@@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef QEMU_MAX31790_H +#define QEMU_MAX31790_H + +#define TYPE_MAX31790 "max31790" + +#endif
tests/functional/arm/test_aspeed_fby4.py +47 -0
59 lines not on this page · raw message
Signature · 1 line
2.56.0
Re: [PATCH v8 4/5] hw/sensor: MAX31790 support
Quoted 8 lines · On Tue, 13 Oct 2026 12:46:48 +0000, [email protected] wrote:
From: Alexander Hansen <[email protected]>
Product: [1]
Datasheet: [2]MAX31790 Support:
- fan inputs are reading
- tach reading propertional to pwm setting from linux driver
Nit: Typo: 'proportional'.
Quoted 42 lines
- fans do not show any fault
- 6 PWM registers influence 6 TACH registersThere is intentional stub behavior in some places and various functions of the device are currently unsupported.
MAX31790 currently unsupported:
- slave address restriction
- fan dynamics
- spin-up configuration
- fault state / failure possibility
- rate-of-change control
- tach mode
- mixed layouts where number of fans != number of tachs
- see Figure 5.9 in [2] for example of mixed layoutAnyone could expand it in the future for more accurate emulation.
The reason for adding this device is to support Yosemite V4 emulation.
Tested: on yosemite 4 qemu
root@yosemite4:~# ls /sys/class/hwmon/hwmon2/ device fan2_fault fan3_target fan5_fault fan6_target pwm2 pwm5 fan1_enable fan2_input fan4_enable fan5_input name pwm2_enable pwm5_enable fan1_fault fan2_target fan4_fault fan5_target of_node pwm3 pwm6 fan1_input fan3_enable fan4_input fan6_enable power pwm3_enable pwm6_enable fan1_target fan3_fault fan4_target fan6_fault pwm1 pwm4 subsystem fan2_enable fan3_input fan5_enable fan6_input pwm1_enable pwm4_enable uevent root@yosemite4:~# cat /sys/class/hwmon/hwmon2/fan1_input 4551 root@yosemite4:~# cat /sys/class/hwmon/hwmon2/fan1_enable 1 root@yosemite4:~# cat /sys/class/hwmon/hwmon2/fan1_fault 0 root@yosemite4:~# cat /sys/class/hwmon/hwmon2/fan1_target 2048 root@yosemite4:~# cat /sys/class/hwmon/hwmon2/pwm1 178 root@yosemite4:~# cat /sys/class/hwmon/hwmon2/name max31790
Quoted 9 lines
Trace output:
max31790_realizei2c_addr:0x20max31790_realizei2c_addr:0x2fmax31790_realizei2c_addr:0x20max31790_realizei2c_addr:0x2fmax31790_eventi2c_addr:0x20, event:0x01max31790_sendi2c_addr:0x20, data:0x02max31790_eventi2c_addr:0x20, event:0x00max31790_recvi2c_addr:0x20,reg_addr:0x02
This trace event (max31790_recv) seems to have been renamed (max31790_recv_return)
Quoted 22 lines
max31790_recv_returni2c_addr:0x20, returns:0x08
...References:
[1] https://www.analog.com/en/products/MAX31790.html
[2] https://www.analog.com/media/en/technical-documentation/data-sheets/MAX31790.pdfCc Emmanuel Blot <[email protected]>Cc Titus Rwantare <[email protected]>Cc "Cédric Le Goater" <[email protected]> (maintainer:ASPEED BMCs)Cc Jonathan Cameron <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Peter Maydell <[email protected]>Cc "Philippe Mathieu-Daudé" <[email protected]>Signed-off-by Alexander Hansen <[email protected]>MAINTAINERS +0
-0
MAINTAINERS S: Maintained · line 4122
Quoted 4 lines
MAINTAINERS +1
-0@@ -4119,6 +4119,7 @@ S: Maintained F: hw/i2c/pmbus_device.c F: hw/sensor/adm1272.c F: hw/sensor/isl_pmbus_vr.c +F: hw/sensor/max31790.c
It does not seem to be a PMBus device (vs. max31785)
The .h file is tracked.
I do not know if it is possible to assign a maintainer at this stage.
hw/sensor/max31790.c line 2
Quoted 8 lines
hw/sensor/max31790.c new file +2
-0@@ -0,0 +1,508 @@ +/* +* Maxim MAX31790 PMBus 6-Channel Fan Controller
The MAX31790 is a plain I2C/SMBus device, not PMBus.
Quoted 11 lines
hw/sensor/max31790.c new file +11
-0+ +g_assert (index <MAX31790_NUM_FANS ); + + s->outbuf[0 ] = s->fan_dynamics[index]; +trace_max31790_fan_dynamics_read (s->i2c.address, index, s->outbuf[0 ]); +break ; +case MAX31790_REG_FAN_FAULT_STATUS_1 : +case MAX31790_REG_FAN_FAULT_STATUS_2 : +/* we do not have any fan fault */ + s->outbuf[0 ] =0x00 ; + s->outbuf[1 ] =0x00 ;
hw/sensor/max31790.c line 161
Quoted 10 lines
hw/sensor/max31790.c new file +10
-0+break ; + case MAX31790_REG_TACH_COUNT_MSB(0)... MAX31790_REG_TACH_COUNT_LSB(11): + index =reg16_index (s->pointer,MAX31790_REG_TACH_COUNT_MSB (0 )); + +g_assert (index <MAX31790_NUM_TACHS ); + +set_outbuf_16 (s, even_reg, s->tach_count[index %MAX31790_NUM_TACHS ]); +break ; + + case MAX31790_REG_PWM_DUTY_CYCLE_MSB(0)... MAX31790_REG_PWM_DUTY_CYCLE_LSB(
Nit: Line breaking is weird and a bit hard to read
hw/sensor/max31790.c line 167
Quoted 6 lines
hw/sensor/max31790.c new file +6
-0+ 5): + index =reg16_index (s->pointer,MAX31790_REG_PWM_DUTY_CYCLE_MSB (0 )); + +g_assert (index <MAX31790_NUM_FANS ); + +set_outbuf_16 (s, even_reg, s->pwm[index &MAX31790_NUM_FANS ]);
Is it not '%' rather than '&' here? (repeated below)
Quoted 11 lines
hw/sensor/max31790.c new file +11
-0+break ; + +case MAX31790_REG_TACH_TARGET_COUNT_MSB ( + 0)... MAX31790_REG_TACH_TARGET_COUNT_LSB(5): + index =reg16_index (s->pointer,MAX31790_REG_TACH_TARGET_COUNT_MSB (0 )); + +g_assert (index <MAX31790_NUM_FANS ); + +set_outbuf_16 (s, even_reg, s->tach_target[index]); +break ; +default :
hw/sensor/max31790.c line 198
Quoted 10 lines
hw/sensor/max31790.c new file +10
-0+qemu_log_mask (LOG_UNIMP ,"%s: read of register %d\n" , __func__, + s->pointer); +break ; + } +} + +static uint8_t max31790_get_speed_range (MAX31790State *s,size_t index) +{ +g_assert (index <MAX31790_NUM_FANS ); +const uint16_t value = (s->fan_dynamics[index] >>5 );
Nit: not sure const is useful in C (vs C++), but should be fine
Quoted 11 lines
hw/sensor/max31790.c new file +11
-0+return (value >5 ) ?32 :1 << value; +} + +static void max31790_set_rpm (MAX31790State *s,size_t index,uint16_t rpm) +{ +trace_max31790_rpm_write (s->i2c.address, index, rpm); + +/* +* (see page 11) NP = number of tachometer pulses per revolution. +* Most general-purpose brushless DC fans produce two tachometer +* pulses per revolution.
hw/sensor/max31790.c line 219
Quoted 10 lines
hw/sensor/max31790.c new file +10
-0+*/ +const uint64_t sr =max31790_get_speed_range (s, index); + +/* page 11: tach_count = 60 * SR * 8192 / (NP * RPM) */ + +/* prevent division by 0 */ + rpm = (rpm ==0 ) ?1 : rpm; + +/* (60 * 8192) / 2 */ +const uint64_t tach_count_constant =245760ULL ;
It might be better to use #define for true C constants
Quoted 11 lines
hw/sensor/max31790.c new file +11
-0+ +/* last 7 bits in register are 0 , 9 bits remaining */ +const uint16_t pwm_real = s->pwm[index %MAX31790_NUM_FANS ] >>7 ; + +/* maximum value will be 511 */ + +/* +* This formula has magic values which model the relationship +* of PWM input to a fan. Not derived from datasheet. +*/ +max31790_set_rpm (s, index,100 + pwm_real *20 );
hw/sensor/max31790.c line 264
Quoted 10 lines
hw/sensor/max31790.c new file +10
-0+} + +static void max31790_write_2_byte (MAX31790State *s) +{ +size_t index =0 ; +const uint8_t value0 = s->buf[0 ]; +const uint8_t value1 = s->buf[1 ]; + +switch (s->pointer) { + case MAX31790_REG_FAN_CONFIG(0)... MAX31790_REG_FAN_CONFIG(5):
The datasheet says the register pointer auto-increments. It does not seem the emulation implements this feature. Supporting it might also simplify 2-byte special handling.
Quoted 11 lines
hw/sensor/max31790.c new file +11
-0+size_t index =0 ; +uint16_t pwm =0 ; +const uint8_t value = s->buf[0 ]; +const bool is_msb = s->pointer %2 ==0 ; + +switch (s->pointer) { + case MAX31790_REG_FAN_CONFIG(0)... MAX31790_REG_FAN_CONFIG(5): + index = s->pointer -MAX31790_REG_FAN_CONFIG (0 ); + +g_assert (index <MAX31790_NUM_FANS ); +
hw/sensor/max31790.c line 329
Quoted 10 lines
hw/sensor/max31790.c new file +10
-0+ s->fan_config[index] = value; +trace_max31790_fan_config_write (s->i2c.address, index, value); +break ; + case MAX31790_REG_FAN_DYNAMICS(0)... MAX31790_REG_FAN_DYNAMICS(5): + index = s->pointer -MAX31790_REG_FAN_DYNAMICS (0 ); + +g_assert (index <MAX31790_NUM_FANS ); + + s->fan_dynamics[index] = value; +trace_max31790_fan_dynamics_write (s->i2c.address, index, value);
Should not this update tach_count register as well? or rather, should not tach_count register value computed at read time, based on other values?
hw/sensor/max31790.c line 339
Quoted 10 lines
hw/sensor/max31790.c new file +10
-0+break ; +case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB ( + 0)... MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(5): + index = +reg16_index (s->pointer,MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB (0 )); + +g_assert (index <MAX31790_NUM_FANS ); + + pwm = +reg16_write_byte (s->pwm[index &MAX31790_NUM_FANS ], is_msb, value);
& vs. % issue?
hw/sensor/max31790.c line 352
Quoted 13 lines
hw/sensor/max31790.c new file +13
-0+ +max31790_pwm_write (s, index, pwm); +break ; +case MAX31790_REG_TACH_TARGET_COUNT_MSB ( + 0)... MAX31790_REG_TACH_TARGET_COUNT_LSB(5): + index =reg16_index (s->pointer,MAX31790_REG_TACH_TARGET_COUNT_MSB (0 )); + +g_assert (index <MAX31790_NUM_FANS ); + + s->tach_target[index] = +reg16_write_byte (s->tach_target[index], is_msb, value); +break ; +default :
I think there should be a double error case here:
1. Features that are not supported (such as user registers): LOG_UNIMP + document them in the file header
2. Addresses that are invalid: LOG_GUEST_ERROR
Same remark for the read counterpart.
Quoted 11 lines
hw/sensor/max31790.c new file +11
-0+ +static int max31790_send (I2CSlave *i2c,uint8_t data) +{ +MAX31790State *s =MAX31790 (i2c); + +trace_max31790_send (s->i2c.address, data); + +if (s->len ==0 ) { +/* first byte is the register pointer for a read / write operation */ + s->pointer = data; + s->len++;
hw/sensor/max31790.c line 378
Quoted 10 lines
hw/sensor/max31790.c new file +10
-0+return 0 ; + } + +if (s->len >2 ) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s: write too many bytes\n" , __func__); +return 1 ;/* NAK */ + } + +/* second / third byte is the data to write */ + s->buf[s->len -1 ] = data;
Is is what the HW handles? From the datasheet:
The device’s control registers are organized in rows of 8 bytes. The I2C master can read or write individual bytes, or canread or write multiple bytes. When writing consecutive bytes, all writes are to the same row. When the final byte in therow is reached, the next byte written is the row’s first byte. For example, a write that starts with 02h (Fan 1 Configuration)can write to 02h, 03h, 04h, 05h, 06h, and 07h. If writes continue, the next byte written is 00h, and so on.
I think the issue does not show up with Linux that only uses 1- and 2-byte accesses if I'm not mistaken, but the device should work with other drivers.
Moreover I think that it is valid from the HW device perspective to start a multibyte access on an odd address, but it is not supported here.
Quoted 10 lines
hw/sensor/max31790.c new file +10
-0+ s->len++; + +if (s->len ==2 ) { +max31790_write_1_byte (s); + }else if (s->len ==3 ) { +max31790_write_2_byte (s); + } + +return 0 ; +}
hw/sensor/max31790.c line 398
Quoted 10 lines
hw/sensor/max31790.c new file +10
-0+ +static uint8_t max31790_recv (I2CSlave *i2c) +{ +MAX31790State *s =MAX31790 (i2c); + +max31790_read (s); + s->len =0 ; + +if (s->outlen >=2 ) { +/* error */
From the datasheet:
Consecutive reads are not subject to the single-row limitation. A read can start at any address and can continue throughFFh. If reads continue past FFh, they wrap around to 00h.
Quoted 11 lines
hw/sensor/max31790.c new file +11
-0+VMSTATE_UINT8 (outlen, MAX31790State), +VMSTATE_UINT8_ARRAY (outbuf, MAX31790State,2 ), +VMSTATE_UINT8 (pointer, MAX31790State), + VMSTATE_I2C_SLAVE(i2c, MAX31790State), VMSTATE_END_OF_LIST() } +}; + +static void max31790_reset_enter (MAX31790State *s) +{ +trace_max31790_reset (s->i2c.address); + +for (int i =0 ; i <MAX31790_NUM_FANS ; i++) {
hw/sensor/max31790.c line 460
Quoted 10 lines
hw/sensor/max31790.c new file +10
-0+/* POR-State 0b 0XX0 0000 */ + s->fan_config[i] =0x0 ; + +/* same as POR-State */ + s->tach_target[i] =0x3c00 ; + +/* same as POR-State */ + s->fan_dynamics[i] =0x4c ; + } +
Tach count array is never initialized
hw/sensor/max31790.c line 463
Quoted 3 lines
hw/sensor/max31790.c new file +3
-0+/* this will set both pwm and tach count */ +for (int i =0 ; i <MAX31790_NUM_FANS ; i++) { +max31790_pwm_write (s, i,0x4444 );
Where does 0x4444 come from? It doesn't look like a datasheet POR value. In any case, a #define constant would be useful here.
hw/sensor/max31790.c line 471
Quoted 8 lines
hw/sensor/max31790.c new file +8
-0+ } +} + +static void max31790_reset_hold (Object *obj,ResetType type) +{ +MAX31790State *s =MAX31790 (obj); + +max31790_reset_enter (s);
This is a bit confusing with the Resettable API (enter/hold/exit). If the enter phase is used, why mapping it to the hold phase?
include/hw/sensor/max31790.h line 2
Quoted 8 lines
include/hw/sensor/max31790.h new file +2
-0@@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef QEMU_MAX31790_H
Maybe state the purpose of this file in the header (same as in the C file)
tests/functional/arm/test_aspeed_fby4.py def do_test_arm_aspeed_openbmc_no_network(self, machine, image, uboot, · line 40
Quoted 11 lines
tests/functional/arm/test_aspeed_fby4.py +3
-0@@ -34,6 +35,52 @@ def do_test_arm_aspeed_openbmc_no_network(self, machine, image, uboot, # different from the other machines. self.wait_for_console_pattern('yosemite4 login:') + # perform login + exec_command_and_wait_for_pattern(self, + "root", "Password:");
Python statements don't need trailing semicolons :-)
tests/functional/arm/test_aspeed_fby4.py def do_test_arm_aspeed_openbmc_no_network(self, machine, image, uboot, · line 46
Quoted 6 lines
tests/functional/arm/test_aspeed_fby4.py +6
-0+ + exec_command_and_wait_for_pattern(self, "0penBmc", "#"); + + # MAX31790 test + exec_command_and_wait_for_pattern(self, + "cat /sys/class/hwmon/hwmon3/name", "max31790");
Hardcoding hwmon3 might be fragile: please consider the hwmon directory from the I2C device path
(e.g. /sys/bus/i2c/devices/<bus>-0020/hwmon/hwmon*).
tests/functional/arm/test_aspeed_fby4.py def do_test_arm_aspeed_openbmc_no_network(self, machine, image, uboot, · line 51
Quoted 5 lines
tests/functional/arm/test_aspeed_fby4.py +5
-0+ + # this initial fan reading value is caused by services + # inside the image writing the pwm + exec_command_and_wait_for_pattern(self, + "cat /sys/class/hwmon/hwmon3/fan1_input", "7281");
Maybe stop and sync with the service to ensure the value cannot be modified while this test is running?
tests/functional/arm/test_aspeed_fby4.py def do_test_arm_aspeed_openbmc_no_network(self, machine, image, uboot, · line 53
Quoted 2 lines
tests/functional/arm/test_aspeed_fby4.py +2
-0+ exec_command_and_wait_for_pattern(self, + "cat /sys/class/hwmon/hwmon3/fan1_enable", "1");
The console may echo the command, and the echo contains 'fan1_enable', so the pattern '1' matches before the command runs, in which case this check always passes.
It might be worth testing other channels, to validate s->pwm array management.
Emmanuel.
PATCH v8 5/5 hw/sensor: support MAX11615
In reply to [email protected]From: Alexander Hansen <[email protected]>
Product: [1]
Datasheet: [2]
The ADC reads a pre-defined arbitrary value.
root@yosemite4:~# cat /sys/bus/iio/devices/iio:device2/name max11615 root@yosemite4:~# cat /sys/bus/iio/devices/iio:device2/in_voltage0_raw 722 root@yosemite4:~# cat /sys/bus/iio/devices/iio:device2/in_voltage_scale 0.500000000
trace:
less /tmp/qemu-trace.log | grep -i max116 max11615_realize i2c_addr: 0x33 max11615_realize i2c_addr: 0x33 max11615_event i2c_addr: 0x33, event: 0x01 max11615_write_setup i2c_addr: 0x33, data: 0xd2 max11615_write_config i2c_addr: 0x33, data: 0x0f max11615_event i2c_addr: 0x33, event: 0x03 max11615_event i2c_addr: 0x33, event: 0x01 max11615_write_setup i2c_addr: 0x33, data: 0xd2 max11615_write_config i2c_addr: 0x33, data: 0x0f max11615_event i2c_addr: 0x33, event: 0x03 max11615_event i2c_addr: 0x33, event: 0x01 max11615_write_setup i2c_addr: 0x33, data: 0xd2 max11615_write_config i2c_addr: 0x33, data: 0x61 max11615_event i2c_addr: 0x33, event: 0x03 max11615_event i2c_addr: 0x33, event: 0x00 max11615_recv i2c_addr: 0x33, reg_addr: 0x00 max11615_recv_return i2c_addr: 0x33, returns: 0xfa max11615_recv i2c_addr: 0x33, reg_addr: 0x00 max11615_recv_return i2c_addr: 0x33, returns: 0xd2 max11615_event i2c_addr: 0x33, event: 0x04 max11615_event i2c_addr: 0x33, event: 0x03
References:
[1] https://www.analog.com/en/products/MAX11615.html
[2] https://www.analog.com/media/en/technical-documentation/data-sheets/MAX11612-MAX11617.pdf
--- MAINTAINERS | 1 + hw/arm/Kconfig | 1 + hw/arm/aspeed_ast2600_fby4.c | 3 +- hw/sensor/Kconfig | 4 + hw/sensor/max1161x.c | 314 +++++++++++++++++++++++ hw/sensor/meson.build | 1 + hw/sensor/trace-events | 9 + include/hw/sensor/max1161x.h | 7 + tests/functional/arm/test_aspeed_fby4.py | 9 + 9 files changed, 348 insertions(+), 1 deletion(-) create mode 100644 hw/sensor/max1161x.c create mode 100644 include/hw/sensor/max1161x.h
MAINTAINERS +1 -0
@@ -4119,6 +4119,7 @@ S: Maintained F: hw/i2c/pmbus_device.c F: hw/sensor/adm1272.c F: hw/sensor/isl_pmbus_vr.c +F: hw/sensor/max1161x.c F: hw/sensor/max31790.c F: hw/sensor/max34451.c F: include/hw/i2c/pmbus_device.h
hw/arm/Kconfig +1 -0
@@ -546,6 +546,7 @@ config ASPEED_SOC select MAX31785 select ADC128D818 select MAX31790 + select MAX1161X select FSI_APB2OPB_ASPEED select AT24C select PCI_EXPRESS_ASPEED
hw/arm/aspeed_ast2600_fby4.c +2 -1
@@ -11,6 +11,7 @@#include "hw/arm/aspeed.h" #include "hw/arm/aspeed_soc.h" #include "hw/nvram/eeprom_at24c.h" +#include "hw/sensor/max1161x.h" #include "hw/i2c/i2c_mux_pca954x.h" #include "hw/sensor/max31790.h" #include "hw/gpio/pca9552.h"
@@ -188,7 +189,7 @@ static void fby4_i2c_init_fanboard(I2CSlave *fan_mux, size_t eepromSize)i2c_slave_create_simple (bus,TYPE_MAX31790 ,0x2f );/* maxim,max11615 @ 0x33 (adc) */ -/* TODO */ +i2c_slave_create_simple (bus,TYPE_MAX11615 ,0x33 );at24c_eeprom_init_rom (bus,0x52 , eepromSize, fru_yv4_fanboard_bin, fru_yv4_fanboard_bin_len);
hw/sensor/Kconfig +4 -0
@@ -51,3 +51,7 @@ config MAX31785 config MAX31790 bool depends on I2C + +config MAX1161X + bool + depends on I2C
hw/sensor/max1161x.c new file +314 -0
314 lines not on this page · raw message
hw/sensor/meson.build +1 -0
@@ -10,3 +10,4 @@ system_ss.add(when: 'CONFIG_LSM303DLHC_MAG', if_true: files('lsm303dlhc_mag.c')) system_ss.add(when: 'CONFIG_ISL_PMBUS_VR', if_true: files('isl_pmbus_vr.c')) system_ss.add(when: 'CONFIG_MAX31785', if_true: files('max31785.c')) system_ss.add(when: 'CONFIG_MAX31790', if_true: files('max31790.c')) +system_ss.add(when: 'CONFIG_MAX1161X', if_true: files('max1161x.c'))
hw/sensor/trace-events +9 -0
@@ -25,3 +25,12 @@ max31790_fan_dynamics_read(uint8_t i2c_addr, size_t channel, uint8_t value) "i2c max31790_fan_dynamics_write(uint8_t i2c_addr, size_t channel, uint8_t value) "i2c_addr: 0x%02x, channel: %zu, value: 0x%02x" max31790_fan_config_read(uint8_t i2c_addr, size_t channel, uint8_t value) "i2c_addr: 0x%02x, channel: %zu, value: 0x%02x" max31790_fan_config_write(uint8_t i2c_addr, size_t channel, uint8_t value) "i2c_addr: 0x%02x, channel: %zu, value: 0x%02x" + +# max11615.c +max11615_write_setup(uint8_t i2c_addr, uint8_t send) "i2c_addr: 0x%02x, data: 0x%02x" +max11615_write_config(uint8_t i2c_addr, uint8_t send) "i2c_addr: 0x%02x, data: 0x%02x" +max11615_recv(uint8_t i2c_addr, uint8_t reg_addr) "i2c_addr: 0x%02x, reg_addr: 0x%02x" +max11615_recv_return(uint8_t i2c_addr, uint8_t data) "i2c_addr: 0x%02x, returns: 0x%02x" +max11615_event(uint8_t i2c_addr, uint8_t event) "i2c_addr: 0x%02x, event: 0x%02x" +max11615_realize(uint8_t i2c_addr) "i2c_addr: 0x%02x" +max11615_reset(uint8_t i2c_addr) "i2c_addr: 0x%02x"
include/hw/sensor/max1161x.h new file +7 -0
@@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef QEMU_MAX1161X_H +#define QEMU_MAX1161X_H + +#define TYPE_MAX11615 "max11615" + +#endif
tests/functional/arm/test_aspeed_fby4.py +9 -0
@@ -81,6 +81,15 @@ def do_test_arm_aspeed_openbmc_no_network(self, machine, image, uboot, exec_command_and_wait_for_pattern(self, "cat /sys/class/hwmon/hwmon3/fan1_input", "10347"); + # MAX11615 test + exec_command_and_wait_for_pattern(self, + "cat /sys/bus/i2c/devices/30-0033/iio:device*/name", "max11615"); + # read the value configured in the machine emulation + exec_command_and_wait_for_pattern(self, + "cat /sys/bus/i2c/devices/30-0033/iio:device*/in_voltage0_raw", "722"); + exec_command_and_wait_for_pattern(self, + "cat /sys/bus/i2c/devices/30-0033/iio:device*/in_voltage_scale", "0.500000000"); + def test_arm_ast2600_yosemitev4_openbmc(self): image_path = self.uncompress(self.ASSET_YOSEMITE_V4_FLASH)
Signature · 1 line
2.56.0
Re: [PATCH v8 5/5] hw/sensor: support MAX11615
Quoted 25 lines · On Tue, 13 Oct 2026 12:46:49 +0000, [email protected] wrote:
From: Alexander Hansen <[email protected]>
Product: [1]
Datasheet: [2]The ADC reads a pre-defined arbitrary value.
root@yosemite4:~# cat /sys/bus/iio/devices/iio:device2/name max11615 root@yosemite4:~# cat /sys/bus/iio/devices/iio:device2/in_voltage0_raw 722 root@yosemite4:~# cat /sys/bus/iio/devices/iio:device2/in_voltage_scale 0.500000000trace:
less/tmp/qemu-trace.log| grep -i max116max11615_realizei2c_addr:0x33max11615_realizei2c_addr:0x33max11615_eventi2c_addr:0x33, event:0x01max11615_write_setupi2c_addr:0x33, data:0xd2max11615_write_configi2c_addr:0x33, data:0x0fmax11615_eventi2c_addr:0x33, event:0x03max11615_eventi2c_addr:0x33, event:0x01max11615_write_setupi2c_addr:0x33, data:0xd2max11615_write_configi2c_addr:0x33, data:0x0f
Quoted 8 lines
max11615_eventi2c_addr:0x33, event:0x03max11615_eventi2c_addr:0x33, event:0x01max11615_write_setupi2c_addr:0x33, data:0xd2max11615_write_configi2c_addr:0x33, data:0x61max11615_eventi2c_addr:0x33, event:0x03max11615_eventi2c_addr:0x33, event:0x00max11615_recvi2c_addr:0x33,reg_addr:0x00max11615_recv_returni2c_addr:0x33, returns:0xfa
Nit: is this trace in sync with the code?
Quoted 24 lines
max11615_recvi2c_addr:0x33,reg_addr:0x00max11615_recv_returni2c_addr:0x33, returns:0xd2max11615_eventi2c_addr:0x33, event:0x04max11615_eventi2c_addr:0x33, event:0x03References:
[1] https://www.analog.com/en/products/MAX11615.html
[2] https://www.analog.com/media/en/technical-documentation/data-sheets/MAX11612-MAX11617.pdfCc Emmanuel Blot <[email protected]>Cc Titus Rwantare <[email protected]>Cc "Cédric Le Goater" <[email protected]> (maintainer:ASPEED BMCs)Cc Jonathan Cameron <[email protected]>Cc "Philippe Mathieu-Daudé" <[email protected]> (odd fixer:Overall sensors)Cc Paolo Bonzini <[email protected]> (maintainer:Kconfig)Cc Peter Maydell <[email protected]> (supporter:ARM TCG CPUs)Cc [email protected] (open list:All patches CC here)Cc [email protected] (open list:ARM TCG CPUs)Signed-off-by Alexander Hansen <[email protected]>MAINTAINERS +0
-0
MAINTAINERS S: Maintained · line 4122
Quoted 4 lines
MAINTAINERS +1
-0@@ -4119,6 +4119,7 @@ S: Maintained F: hw/i2c/pmbus_device.c F: hw/sensor/adm1272.c F: hw/sensor/isl_pmbus_vr.c +F: hw/sensor/max1161x.c
The MAX11615 is a plain I2C ADC, not a PMBus device include/hw/sensor/max1161x.h is not listed
I do not know if this new code can be assigned to a maintainer
hw/sensor/max1161x.c line 3
Quoted 9 lines
hw/sensor/max1161x.c new file +3
-0@@ -0,0 +1,314 @@ +/* +* Maxim MAX11615 Low-Power 12 bit ADC +* Models MAX11612,MAX11613,MAX11614,MAX11615,MAX11616,MAX11617
Only MAX11615 is registered, and class_init hardcodes the MAX11615 parameters. The other parts differ.
Maybe only keep 11615 reference for now, and add a note that document the same file could be used to support other variants? IOW, keep the 'x' suffix for function prefixes, filenames and struct names, but only document '5' variant as currently supported.
Quoted 10 lines
hw/sensor/max1161x.c new file +10
-0+* +* Datasheet: +* https://www.analog.com/media/en/technical-documentation/data-sheets/MAX11612-MAX11617.pdf +* +* Copyright 2026 9elements +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h"
hw/sensor/max1161x.c line 23
Quoted 10 lines
hw/sensor/max1161x.c new file +10
-0+#include "hw/sensor/max1161x.h" +#include "hw/i2c/i2c.h" +#include "migration/vmstate.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "trace.h" + +#define MAX11615_NUM_CHANNELS 8 + +struct MAX11615State {
Should be MAX1161xState I believe
hw/sensor/max1161x.c line 36
Quoted 13 lines
hw/sensor/max1161x.c new file +13
-0+I2CSlave i2c; + +/* true: single-ended mode, false: differential mode */ +bool single_ended; + +/* +* Output data coding for the MAX11612–MAX11617 is +* binary in unipolar mode and two’s complement in bipolar mode +*/ +bool bipolar; + +/* The MAX11613/MAX11615/MAX11617 feature a 2.048V internal reference */ +uint16_t vref;
I think you need to specify the unit here: mV
hw/sensor/max1161x.c line 38
Quoted 2 lines
hw/sensor/max1161x.c new file +2
-0+ +uint16_t channels[MAX11615_NUM_CHANNELS ];
What do channels actually store: RAW/output value or the real voltage?
Quoted 11 lines
hw/sensor/max1161x.c new file +11
-0+I2CSlaveClass parent_class; + +uint8_t channel_select_mask; +size_t n_channels; +}; + +OBJECT_DECLARE_TYPE(MAX11615State, MAX1161XClass, MAX11615) + +static void max1161x_reset (MAX11615State *s) +{ +trace_max11615_reset (s->i2c.address);
hw/sensor/max1161x.c line 69
Quoted 10 lines
hw/sensor/max1161x.c new file +10
-0+ + s->single_ended = true; + s->bipolar = false; + s->vref =2048 ; + s->pointer =0 ; + s->outlen =0 ; + +MAX1161XClass *mc =MAX11615_GET_CLASS (s); + +for (int i =0 ; i < mc->n_channels; i++) {
signed int vs. unsigned (long) int comparison
hw/sensor/max1161x.c line 70
Quoted 1 line
hw/sensor/max1161x.c new file +1
-0+ s->channels[i] =0x2d2 ;
Why 0x2d2? I think it should rather be a C #define with some short doc. It would be nice to have dynamic object properties to change the values on the ADC input pins
Quoted 11 lines
hw/sensor/max1161x.c new file +11
-0+ } +} + +static void max11615_set_outbuf (MAX11615State *s,uint16_t value) +{ +uint8_t msb = value >>8 ; +uint8_t lsb = value &0xff ; + s->outbuf[0 ] =0xf0 | (msb &0xf ); + s->outbuf[1 ] = lsb; +} +
hw/sensor/max1161x.c line 91
Quoted 10 lines
hw/sensor/max1161x.c new file +10
-0+static void max11615_read_single_ended (MAX11615State *s) +{ +/* Table 3. Channel Selection in Single-Ended Mode */ +/* read an ADC channel, first 4 bits must be high */ +uint16_t value = s->channels[s->pointer]; +/* +* In single-ended mode, the MAX11612–MAX11617 always +* operates in unipolar mode irrespective of BIP/UNI. +*/ +if (value > s->vref) {
I think raw unit/output code and voltage in mV are mixed here. The actual voltage scaling is ignored: 1 LSB is 0.5 mv so 2048 raw value means ~ 1.024 volts. I would suggest to name the variables/constants (local and in MAX11615 state) to reflect the unit/type of data to avoid this kind of mistake, and help the reader.
It is probably easier to store the actual voltage in mV and perform conversion to output value on read out
Quoted 11 lines
hw/sensor/max1161x.c new file +11
-0+} + +static int16_t max11615_differential_value (const MAX11615State *s) +{ +/* Table 4. Channel Selection in Differential Mode */ +size_t i1 = s->pointer; +size_t i2 = (s->pointer %2 ==0 ) ? s->pointer +1 : s->pointer -1 ; + +const int16_t ch1 = s->channels[i1]; +const int16_t ch2 = s->channels[i2]; +return ch1 - ch2;
hw/sensor/max1161x.c line 115
Quoted 10 lines
hw/sensor/max1161x.c new file +10
-0+} + +static void max11615_read_differential (MAX11615State *s) +{ +const int16_t value =max11615_differential_value (s); +uint16_t vu = value; + +/* full-scale transition: Figure 12, Figure 13 */ +if (s->bipolar) { +const uint16_t fs = s->vref /2 ;
Same unit mismatch here
Quoted 11 lines
hw/sensor/max1161x.c new file +11
-0+ +max11615_set_outbuf (s, vu); +} + +static void max11615_read (MAX11615State *s) +{ +if (s->single_ended) { +max11615_read_single_ended (s); + }else { +max11615_read_differential (s); + }
hw/sensor/max1161x.c line 151
Quoted 10 lines
hw/sensor/max1161x.c new file +10
-0+} + +static void max11615_write_config_byte (MAX11615State *s,uint8_t data) +{ +trace_max11615_write_config (s->i2c.address, data); + +uint8_t scan_select = (data >>5 ) &0x3 ; + +if (scan_select !=0x3 ) { +qemu_log_mask (LOG_UNIMP ,"%s: unimplemented scan select\n" , __func__);
Only SCAN=0b11 is supported here, which means "convert the selected channel" and do not scan, where as the management of 'pointer' makes the opposite and implements channel scanning.
Quoted 10 lines
hw/sensor/max1161x.c new file +10
-0+ } + +const MAX1161XClass *mc =MAX11615_GET_CLASS (s); + +uint8_t channel_select = (data >>1 ) & mc->channel_select_mask; + +/* Table 3. Channel Selection */ +if (channel_select >= mc->n_channels) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid channel select\n" , + __func__);
hw/sensor/max1161x.c line 171
Quoted 10 lines
hw/sensor/max1161x.c new file +10
-0+ channel_select = mc->n_channels -1 ; + } + s->pointer = channel_select; + s->single_ended = data &0x1 ; +} + +static void max11615_write_setup_byte (MAX11615State *s,uint8_t data) +{ +trace_max11615_write_setup (s->i2c.address, data); +/* we ignore the setup byte, not implemented */
This comment is out-of-sync, as the code below does handle RST, BIP/UNI and the reference select.
SEL=00x (VDD as reference) is neither handled nor logged; vref stays at 2048.
hw/sensor/max1161x.c line 174
Quoted 3 lines
hw/sensor/max1161x.c new file +3
-0+ +/* 1 = no action, 0 = resets the configuration register to default */ +const bool rst = ((data >>1 ) &0x1 ) ==0x0 ;
Nit: maybe registerfields.h REG8 macros could help, naming fields and writing if (! (data & R_SETUP_RST) ) or the like
hw/sensor/max1161x.c line 177
Quoted 3 lines
hw/sensor/max1161x.c new file +3
-0+ +if (rst) { +max1161x_reset (s);
RST=0 resets only the configuration register (scan, CS, SGL/DIF) whereas the setup register stays as it is.
max1161x_reset() also resets vref, bipolar and the simulated analog input values in channels[].
The reset feature should be split (config-register reset vs. out of the device reset).
Quoted 11 lines
hw/sensor/max1161x.c new file +11
-0+ +if (msb) { +max11615_write_setup_byte (s, data); + }else { +max11615_write_config_byte (s, data); + } + + s->outlen =0 ; +return 0 ; +} +
hw/sensor/max1161x.c line 214
Quoted 10 lines
hw/sensor/max1161x.c new file +10
-0+static uint8_t max11615_recv (I2CSlave *i2c) +{ +MAX11615State *s =MAX11615 (i2c); +trace_max11615_recv (s->i2c.address, s->pointer); + +MAX1161XClass *mc =MAX11615_GET_CLASS (s); + +if (s->outlen >=2 ) { +/* MAX11615 supports multichannel scan with wraparound */ +/* see datasheet page 17 */
This depends on SCAN mode
Quoted 8 lines
hw/sensor/max1161x.c new file +8
-0+ + s->outlen =0 ; + + s->pointer++; +if (s->pointer >= mc->n_channels) { + s->pointer =0 ; + } + }
hw/sensor/max1161x.c line 232
Quoted 10 lines
hw/sensor/max1161x.c new file +10
-0+ +max11615_read (s); + +const uint8_t data = s->outbuf[s->outlen++]; + +trace_max11615_recv_return (s->i2c.address, data); +return data; +} + +static int max11615_event (I2CSlave *i2c,enum i2c_event event)
There is a mix of max11615_ and max1161x_ prefixes
hw/sensor/max1161x.c line 240
Quoted 8 lines
hw/sensor/max1161x.c new file +8
-0+{ +MAX11615State *s =MAX11615 (i2c); + +trace_max11615_event (s->i2c.address, event); + +switch (event) { +case I2C_START_RECV : + s->outlen =0 ;
outlen is reset but not pointer
After a guest reads 4 bytes, pointer is 1. Every later read transaction then returns AIN1 although CS still selects AIN0. On real hardware each read starts a new conversion of the configured channel(s).
Quoted 4 lines
hw/sensor/max1161x.c new file +4
-0+break ; +default : +break ; + }
hw/sensor/max1161x.c line 254
Quoted 10 lines
hw/sensor/max1161x.c new file +10
-0+ +return 0 ; +} + +static const VMStateDescription vmstate_max11615 = { + .name =TYPE_MAX11615 , + .version_id =0 , + .minimum_version_id =0 , + .fields = + (const VMStateField []){VMSTATE_BOOL (single_ended, MAX11615State),
I'm not sure this matches the usual QEMU format style
Quoted 6 lines
hw/sensor/max1161x.c new file +6
-0+VMSTATE_BOOL (bipolar, MAX11615State), +VMSTATE_UINT16 (vref, MAX11615State), +VMSTATE_UINT16_ARRAY (channels, MAX11615State, +MAX11615_NUM_CHANNELS ), +VMSTATE_UINT8 (outlen, MAX11615State), + VMSTATE_UINT8_ARRAY(outbuf, MAX11615State, 2),
hw/sensor/max1161x.c line 270
Quoted 10 lines
hw/sensor/max1161x.c new file +10
-0+VMSTATE_UINT8 (pointer, MAX11615State), +VMSTATE_I2C_SLAVE (i2c, MAX11615State), + VMSTATE_END_OF_LIST() } +}; + +static void max1161x_reset_hold (Object *obj,ResetType type) +{ +MAX11615State *s =MAX11615 (obj); + +max1161x_reset (s);
At reset, the device uses SEL=0b000, that is VDD as the voltage reference, which is not internal Vref Either warn if a conversion is started without SEL being assigned Vref first, or implement Vref conversion. I would suggest the latter, as it could reveal unit conversion issues with some dedicated unit tests.
hw/sensor/max1161x.c line 275
Quoted 5 lines
hw/sensor/max1161x.c new file +5
-0+} + +static void max11615_realize (DeviceState *dev,Error **errp) +{ +MAX11615State *s =MAX11615 (dev);
Drop this function since it does nothing (anymore?)
hw/sensor/trace-events max31790_fan_dynamics_read(uint8_t i2c_addr, size_t channel, uint8_t value) "i2c · line 29
Quoted 10 lines
hw/sensor/trace-events +2
-0@@ -25,3 +25,12 @@ max31790_fan_dynamics_read(uint8_t i2c_addr, size_t channel, uint8_t value) "i2c max31790_fan_dynamics_write(uint8_t i2c_addr, size_t channel, uint8_t value) "i2c_addr: 0x%02x, channel: %zu, value: 0x%02x" max31790_fan_config_read(uint8_t i2c_addr, size_t channel, uint8_t value) "i2c_addr: 0x%02x, channel: %zu, value: 0x%02x" max31790_fan_config_write(uint8_t i2c_addr, size_t channel, uint8_t value) "i2c_addr: 0x%02x, channel: %zu, value: 0x%02x" + +# max11615.c
The file is named max1161x.c
Quoted 6 lines
tests/functional/arm/test_aspeed_fby4.py +0
-0@@ -81,6 +81,15 @@ def do_test_arm_aspeed_openbmc_no_network(self, machine, image, uboot, exec_command_and_wait_for_pattern(self,
tests/functional/arm/test_aspeed_fby4.py def do_test_arm_aspeed_openbmc_no_network(self, machine, image, uboot, · line 91
Quoted 10 lines
tests/functional/arm/test_aspeed_fby4.py +8
-0"cat /sys/class/hwmon/hwmon3/fan1_input", "10347"); + # MAX11615 test + exec_command_and_wait_for_pattern(self, + "cat /sys/bus/i2c/devices/30-0033/iio:device*/name", "max11615"); + # read the value configured in the machine emulation + exec_command_and_wait_for_pattern(self, + "cat /sys/bus/i2c/devices/30-0033/iio:device*/in_voltage0_raw", "722"); + exec_command_and_wait_for_pattern(self, + "cat /sys/bus/i2c/devices/30-0033/iio:device*/in_voltage_scale", "0.500000000");
Beware of line width, use checkpath.pl for guidance
Emmanuel.
Alexander,
Quoted 38 lines · On 10/13/26 14:46, [email protected] wrote:
From: Alexander Hansen <[email protected]>
compared to v7, there is now also partial support for PCA9544, which was needed since it's apparently in front of the FRU eeproms [1]. Previous versions of this series did not account for that because testing was done with a downstream image which had patches still applied [2].
This updated version should line up with the dts [1] and work with an unmodified yv4 image.
References:
[1] https://github.com/torvalds/linux/blob/24a19b953e2a3d0ea5a8c4951a0ab8f32720c907/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts#L597
[2] https://discordapp.com/channels/775381525260664832/867820390406422538/1541811213988528128Alexander Hansen (5):
hw/i2c: support PCA9544 ast2600: yosemite4 initial support ast2600: yosemite4 functional test hw/sensor: MAX31790 support hw/sensor: support MAX11615MAINTAINERS | 2 + docs/system/arm/aspeed.rst | 5 +- hw/arm/Kconfig | 2 + hw/arm/aspeed_ast2600_fby4.c | 292 +++++++++++++ hw/arm/meson.build | 1 + hw/i2c/i2c_mux_pca954x.c | 88 +++- hw/sensor/Kconfig | 8 + hw/sensor/max1161x.c | 314 ++++++++++++++ hw/sensor/max31790.c | 508 +++++++++++++++++++++++ hw/sensor/meson.build | 2 + hw/sensor/trace-events | 22 + include/hw/i2c/i2c_mux_pca954x.h | 1 + include/hw/sensor/max1161x.h | 7 + include/hw/sensor/max31790.h | 7 + tests/functional/arm/meson.build | 2 + tests/functional/arm/test_aspeed_fby4.py | 101 +++++ 16 files changed, 1349 insertions(+), 13 deletions(-)
Quoted 7 lines
create mode 100644
hw/arm/aspeed_ast2600_fby4.ccreate mode 100644hw/sensor/max1161x.c
create mode 100644hw/sensor/max31790.c
create mode 100644include/hw/sensor/max1161x.hcreate mode 100644include/hw/sensor/max31790.hcreate mode 100755tests/functional/arm/test_aspeed_fby4.py
Since the device modelsare rather complex, please separate the changes in two (or more) series for the reviews :
1 - sensors
2 - machines
There is not much point in adding new machines types (we have tons already) without the sensors and tests. So sensor should be reviewed first.
Thanks,
C.