Skip to contentSkip to conversation

initial support for yosemite4

PATCH Superseded [email protected] 3 participants 12 messages Jun 19 – Jul 8

Subsystems (2)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v7 cover initial support for yosemite4

From: Alexander Hansen <[email protected]>

Thanks to Cedric and Emmanuel for reviewing.

Summary of changes from v6:

machine:
- fix underline in doc

functional test:
- no changes

max31790:
- considered defining "max31790" string in header,
but it would only provide a single string, so meh.
- wrap macro arguments in parentheses, thanks :)
- use switch case ranges to make code more compact..
- use hexadecimal literals instead of binary literals.
- define an explicit constant for the tach count
- use modulo arithmetic for indexing into 'pwm' array to prevent out of bounds
- use modulo arithmetic for indexing into 'tach_count' array to prevent out of bounds
- use g_assert to check for index inside bounds for the arrays:
- 'pwm'
- 'tach_count'
- 'tach_target'
- 'fan_config'
- 'fan_dynamics'
- fix format string in trace events to match the width of data passed, thanks
- functional test: fix spacing between imports and test class (2 newlines)
- implemented new Resettable API instead of legacy reset

max11615:
- implement new Resettable API
- replace binary literals with hex

Alexander Hansen (4):
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             | 266 +++++++++++
 hw/arm/meson.build                       |   1 +
 hw/sensor/Kconfig                        |   8 +
 hw/sensor/max11615.c                     | 320 +++++++++++++
 hw/sensor/max31790.c                     | 584 +++++++++++++++++++++++
 hw/sensor/meson.build                    |   2 +
 hw/sensor/trace-events                   |  22 +
 include/hw/sensor/max11615.h             |  19 +
 tests/functional/arm/meson.build         |   2 +
 tests/functional/arm/test_aspeed_fby4.py | 101 ++++
 13 files changed, 1332 insertions(+), 2 deletions(-)
 create mode 100644 hw/arm/aspeed_ast2600_fby4.c
 create mode 100644 hw/sensor/max11615.c
 create mode 100644 hw/sensor/max31790.c
 create mode 100644 include/hw/sensor/max11615.h
 create mode 100755 tests/functional/arm/test_aspeed_fby4.py
Cc Emmanuel Blot <[email protected]>
Cc Titus Rwantare <[email protected]>
Cc "Cédric Le Goater" <[email protected]> (maintainer:ASPEED BMCs)
Signature · 1 line
2.54.0
#1 lore raw

PATCH v7 1/4 ast2600: yosemite4 initial support

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

Cc Emmanuel Blot <[email protected]>
Cc Titus Rwantare <[email protected]>
Cc "Cédric Le Goater" <[email protected]> (maintainer:ASPEED BMCs)
Cc Peter Maydell <[email protected]> (maintainer:ASPEED BMCs)
Cc Steven Lee <[email protected]> (reviewer:ASPEED BMCs)
Cc Troy Lee <[email protected]> (reviewer:ASPEED BMCs)
Cc Jamin Lin <[email protected]> (reviewer:ASPEED BMCs)
Cc Kane Chen <[email protected]> (reviewer:ASPEED BMCs)
Cc Andrew Jeffery <[email protected]> (reviewer:ASPEED BMCs)
Cc Joel Stanley <[email protected]> (reviewer:ASPEED BMCs)
Cc [email protected] (open list:ASPEED BMCs)
Cc [email protected] (open list:All patches CC here)
---
 docs/system/arm/aspeed.rst   |   5 +-
 hw/arm/aspeed_ast2600_fby4.c | 260 +++++++++++++++++++++++++++++++++++
 hw/arm/meson.build           |   1 +
 3 files changed, 264 insertions(+), 2 deletions(-)
 create mode 100644 hw/arm/aspeed_ast2600_fby4.c
docs/system/arm/aspeed.rst +3 -2
index 2d51ceeb84..f719a5cebb 100644
@@ -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 +260 -0

260 lines not on this page · raw message

hw/arm/meson.build +1 -0
index 4233a800be..64c399c0e8 100644
@@ -62,6 +62,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.54.0
#2 lore raw

PATCH v7 2/4 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.

Cc Emmanuel Blot <[email protected]>
Cc Titus Rwantare <[email protected]>
Cc "Cédric Le Goater" <[email protected]> (maintainer:ASPEED BMCs)
Cc Peter Maydell <[email protected]> (maintainer:ASPEED BMCs)
Cc Steven Lee <[email protected]> (reviewer:ASPEED BMCs)
Cc Troy Lee <[email protected]> (reviewer:ASPEED BMCs)
Cc Jamin Lin <[email protected]> (reviewer:ASPEED BMCs)
Cc Kane Chen <[email protected]> (reviewer:ASPEED BMCs)
Cc Andrew Jeffery <[email protected]> (reviewer:ASPEED BMCs)
Cc Joel Stanley <[email protected]> (reviewer:ASPEED BMCs)
Cc [email protected] (open list:ASPEED BMCs)
Cc [email protected] (open list:All patches CC here)
---
 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
index 61b00932db..19331b3f16 100644
@@ -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.54.0
#3 lore raw

Re: [PATCH v7 2/4] ast2600: yosemite4 functional test

Hi Cedric,

sorry to ping, since the
- (ast2600: yosemite4 initial support) and
- (ast2600: yosemite4 functional test)

also work by themselves, would you consider those two as ready or is there something i need to fix there.
Alternatively, do all patches of a series need to go in together? Would it help if I pushed those 2 again separately.

Thanks again for taking the time reviewing those patches :)

Alexander

Am Fr., 19. Juni 2026 um 13:55 Uhr schrieb <[email protected]>:

Quoted 104 lines

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.

Cc Emmanuel Blot <[email protected]>
Cc Titus Rwantare <[email protected]>
Cc "Cédric Le Goater" <[email protected]> (maintainer:ASPEED BMCs)
Cc Peter Maydell <[email protected]> (maintainer:ASPEED BMCs)
Cc Steven Lee <[email protected]> (reviewer:ASPEED BMCs)
Cc Troy Lee <[email protected]> (reviewer:ASPEED BMCs)
Cc Jamin Lin <[email protected]> (reviewer:ASPEED BMCs)
Cc Kane Chen <[email protected]> (reviewer:ASPEED BMCs)
Cc Andrew Jeffery <[email protected]> (reviewer:ASPEED BMCs)
Cc Joel Stanley <[email protected]> (reviewer:ASPEED BMCs)
Cc [email protected] (open list:ASPEED BMCs)
Cc [email protected] (open list:All patches CC here)
---
 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
index 61b00932db..19331b3f16 100644
@@ -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 -1
new file mode 100755
index 0000000000..a521834f79
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots the ASPEED machines
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import Asset
+from qemu_test import wait_for_console_pattern
+from aspeed import AspeedTest
+
+
+class YosemiteV4Machine(AspeedTest):
+
+    ASSET_YOSEMITE_V4_FLASH = Asset(
+        'https://github.com/legoater/qemu-aspeed-boot/raw/refs/heads/master/images/yosemite4-bmc/openbmc-20260505132843/obmc-phosphor-image-yosemite4-20260505132843.static.mtd.xz',
+        'dff6946363b41f952b15cfc3156482b89fcfc1b0ecfc3ec8b3ed496a5f001ef9')
+
+    def do_test_arm_aspeed_openbmc_no_network(self, machine, image, uboot,
+                                   cpu_id, soc):
+
+        self.set_machine(machine)
+        self.vm.set_console()
+        self.vm.add_args('-drive', f'file={image},if=mtd,format=raw',
+                         '-snapshot')
+        self.vm.launch()
+
+        self.wait_for_console_pattern(f'U-Boot {uboot}')
+        self.wait_for_console_pattern('## Loading kernel from FIT Image')
+        self.wait_for_console_pattern('Starting kernel ...')
+        self.wait_for_console_pattern(f'Booting Linux on physical CPU {cpu_id}')
+        self.wait_for_console_pattern(f'ASPEED {soc}')
+        self.wait_for_console_pattern('/init as init process')
+        # yosemite v4 does not emit the hostname log which is
+        # different from the other machines.
+        self.wait_for_console_pattern('yosemite4 login:')
+
+    def test_arm_ast2600_yosemitev4_openbmc(self):
+        image_path = self.uncompress(self.ASSET_YOSEMITE_V4_FLASH)
+
+        self.do_test_arm_aspeed_openbmc_no_network('fby4-bmc', image=image_path,
+                                        uboot='2019.04', cpu_id='0xf00',
+                                        soc='AST2600 rev A3')
+
+if __name__ == '__main__':
+    AspeedTest.main()
--

2.54.0

#4 lore raw

Re: [PATCH v7 2/4] ast2600: yosemite4 functional test

Hello,

Quoted 8 lines · Alexander Hansen

Hi Cedric,

sorry to ping, since the
- (ast2600: yosemite4 initial support) and
- (ast2600: yosemite4 functional test)

also work by themselves, would you consider those two as ready or is there something i need to fix there.

These 2 patches are fine AFAIR.

Quoted 2 lines

Alternatively, do all patches of a series need to go in together? Would it help if I pushed those 2 again separately.

The Yosemite V4 machine is of limited interest without the sensor models required by the board. For the current use case, a user might as well use the ast2600-evb machine instead.

More broadly, we should avoid adding with machine types that offer little functional differences. Each additional machine increases maintenance burden, so new machines should provide capabilities that cannot already be achieved with existing ones. That rationale has its limits, since devices can also be created from the command line. However, I'm fine with adding a standalone machine, provided it comes with the required device models and functional tests.

I sent a few comments on the MAX* sensor models that should be addressed. Before I take the series through the Aspeed queue, I'd greatly appreciate an Ack from one of the sensor maintainers or a review from a developer familiar with those models.

The same applies to the ADC128D818 model. It has already received a review. The merge is primarily gated by the review of the test cases.

We have now reached the QEMU 11.1 soft freeze, so only bug fixes should be merged from this point onward.

Quoted 2 lines

Thanks again for taking the time reviewing those patches :)

Let's make it happen in QEMU 11.2.

Thanks,

C.

Quoted 108 lines

Alexander

Am Fr., 19. Juni 2026 um 13:55 Uhr schrieb <[email protected]>:

Quoted 104 lines

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.

Cc Emmanuel Blot <[email protected]>
Cc Titus Rwantare <[email protected]>
Cc "Cédric Le Goater" <[email protected]> (maintainer:ASPEED BMCs)
Cc Peter Maydell <[email protected]> (maintainer:ASPEED BMCs)
Cc Steven Lee <[email protected]> (reviewer:ASPEED BMCs)
Cc Troy Lee <[email protected]> (reviewer:ASPEED BMCs)
Cc Jamin Lin <[email protected]> (reviewer:ASPEED BMCs)
Cc Kane Chen <[email protected]> (reviewer:ASPEED BMCs)
Cc Andrew Jeffery <[email protected]> (reviewer:ASPEED BMCs)
Cc Joel Stanley <[email protected]> (reviewer:ASPEED BMCs)
Cc [email protected] (open list:ASPEED BMCs)
Cc [email protected] (open list:All patches CC here)
---
  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
index 61b00932db..19331b3f16 100644
@@ -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 -1
new file mode 100755
index 0000000000..a521834f79
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots the ASPEED machines
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import Asset
+from qemu_test import wait_for_console_pattern
+from aspeed import AspeedTest
+
+
+class YosemiteV4Machine(AspeedTest):
+
+    ASSET_YOSEMITE_V4_FLASH = Asset(
+        'https://github.com/legoater/qemu-aspeed-boot/raw/refs/heads/master/images/yosemite4-bmc/openbmc-20260505132843/obmc-phosphor-image-yosemite4-20260505132843.static.mtd.xz',
+        'dff6946363b41f952b15cfc3156482b89fcfc1b0ecfc3ec8b3ed496a5f001ef9')
+
+    def do_test_arm_aspeed_openbmc_no_network(self, machine, image, uboot,
+                                   cpu_id, soc):
+
+        self.set_machine(machine)
+        self.vm.set_console()
+        self.vm.add_args('-drive', f'file={image},if=mtd,format=raw',
+                         '-snapshot')
+        self.vm.launch()
+
+        self.wait_for_console_pattern(f'U-Boot {uboot}')
+        self.wait_for_console_pattern('## Loading kernel from FIT Image')
+        self.wait_for_console_pattern('Starting kernel ...')
+        self.wait_for_console_pattern(f'Booting Linux on physical CPU {cpu_id}')
+        self.wait_for_console_pattern(f'ASPEED {soc}')
+        self.wait_for_console_pattern('/init as init process')
+        # yosemite v4 does not emit the hostname log which is
+        # different from the other machines.
+        self.wait_for_console_pattern('yosemite4 login:')
+
+    def test_arm_ast2600_yosemitev4_openbmc(self):
+        image_path = self.uncompress(self.ASSET_YOSEMITE_V4_FLASH)
+
+        self.do_test_arm_aspeed_openbmc_no_network('fby4-bmc', image=image_path,
+                                        uboot='2019.04', cpu_id='0xf00',
+                                        soc='AST2600 rev A3')
+
+if __name__ == '__main__':
+    AspeedTest.main()
--

2.54.0

#5 lore raw

PATCH v7 3/4 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

Cc 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]>
---
 MAINTAINERS                              |   1 +
 hw/arm/Kconfig                           |   1 +
 hw/arm/aspeed_ast2600_fby4.c             |   4 +-
 hw/sensor/Kconfig                        |   4 +
 hw/sensor/max31790.c                     | 584 +++++++++++++++++++++++
 hw/sensor/meson.build                    |   1 +
 hw/sensor/trace-events                   |  13 +
 tests/functional/arm/test_aspeed_fby4.py |  47 ++
 8 files changed, 653 insertions(+), 2 deletions(-)
 create mode 100644 hw/sensor/max31790.c
MAINTAINERS +1 -0
index 93df53d87f..e3df75f7bb 100644
@@ -3993,6 +3993,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
index 500bfdfe2a..43e96a671b 100644
@@ -553,6 +553,7 @@ config ASPEED_SOC
     select LED
     select PMBUS
     select MAX31785
+    select MAX31790
     select FSI_APB2OPB_ASPEED
     select AT24C
     select PCI_EXPRESS
hw/arm/aspeed_ast2600_fby4.c +2 -2
index 03f54d4393..8feb31bc44 100644
@@ -164,7 +164,7 @@ static void fby4_i2c_init_fanboard(I2CSlave *fan_mux, size_t eepromSize)
         /* TODO */
 
         /* maxim,max31790 @ 0x20   (pwm) */
-        /* TODO */
+        i2c_slave_create_simple(bus, "max31790", 0x20);
 
         /*
          * ti,tca6424 @ 0x22       (gpio)
@@ -182,7 +182,7 @@ static void fby4_i2c_init_fanboard(I2CSlave *fan_mux, size_t eepromSize)
          */
 
         /* maxim,max31790 @ 0x2f   (pwm) */
-        /* TODO */
+        i2c_slave_create_simple(bus, "max31790", 0x2f);
 
         /* maxim,max11615 @ 0x33   (adc) */
         /* TODO */
hw/sensor/Kconfig +4 -0
index bc6331b4ab..767f198e92 100644
@@ -43,3 +43,7 @@ config ISL_PMBUS_VR
 config MAX31785
     bool
     depends on PMBUS
+
+config MAX31790
+    bool
+    depends on I2C
hw/sensor/max31790.c new file +584 -0

584 lines not on this page · raw message

hw/sensor/meson.build +1 -0
index 420fdc3359..4987c3b253 100644
@@ -8,3 +8,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
index a3fe54fa6d..35c30b985c 100644
@@ -4,3 +4,16 @@
 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"
tests/functional/arm/test_aspeed_fby4.py +47 -0

59 lines not on this page · raw message

Signature · 1 line
2.54.0
#6 lore raw

Re: [PATCH v7 3/4] hw/sensor: MAX31790 support

Hello,

Could the sensors Maintainers take a look please ?

Thanks,

C.

Quoted 831 lines · On 6/19/26 13:55, [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
- 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

Cc 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]>
---
  MAINTAINERS                              |   1 +
  hw/arm/Kconfig                           |   1 +
  hw/arm/aspeed_ast2600_fby4.c             |   4 +-
  hw/sensor/Kconfig                        |   4 +
  hw/sensor/max31790.c                     | 584 +++++++++++++++++++++++
  hw/sensor/meson.build                    |   1 +
  hw/sensor/trace-events                   |  13 +
  tests/functional/arm/test_aspeed_fby4.py |  47 ++
  8 files changed, 653 insertions(+), 2 deletions(-)

create mode 100644 hw/sensor/max31790.c

MAINTAINERS +1 -0
index 93df53d87f..e3df75f7bb 100644
@@ -3993,6 +3993,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
index 500bfdfe2a..43e96a671b 100644
@@ -553,6 +553,7 @@ config ASPEED_SOC
      select LED
      select PMBUS
      select MAX31785
+    select MAX31790
      select FSI_APB2OPB_ASPEED
      select AT24C
      select PCI_EXPRESS
hw/arm/aspeed_ast2600_fby4.c +2 -2
index 03f54d4393..8feb31bc44 100644
@@ -164,7 +164,7 @@ static void fby4_i2c_init_fanboard(I2CSlave *fan_mux, size_t eepromSize)
          /* TODO */
 
          /* maxim,max31790 @ 0x20   (pwm) */
-        /* TODO */
+        i2c_slave_create_simple(bus, "max31790", 0x20);
 
          /*
           * ti,tca6424 @ 0x22       (gpio)
@@ -182,7 +182,7 @@ static void fby4_i2c_init_fanboard(I2CSlave *fan_mux, size_t eepromSize)
           */
 
          /* maxim,max31790 @ 0x2f   (pwm) */
-        /* TODO */
+        i2c_slave_create_simple(bus, "max31790", 0x2f);
 
          /* maxim,max11615 @ 0x33   (adc) */
          /* TODO */
hw/sensor/Kconfig +4 -0
index bc6331b4ab..767f198e92 100644
@@ -43,3 +43,7 @@ config ISL_PMBUS_VR
  config MAX31785
      bool
      depends on PMBUS
+
+config MAX31790
+    bool
+    depends on I2C
hw/sensor/max31790.c new file +584 -0
new file mode 100644
index 0000000000..af610376d1
@@ -0,0 +1,584 @@
+/*
+ * Maxim MAX31790 PMBus 6-Channel Fan Controller
+ *
+ * Datasheet:
+ * https://www.analog.com/media/en/technical-documentation/data-sheets/MAX31790.pdf
+ *
+ * Copyright 2026 9elements
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/log.h"
+#include "hw/i2c/i2c.h"
+#include "qapi/error.h"
+#include "qapi/visitor.h"
+#include "migration/vmstate.h"
+#include "qemu/module.h"
+#include "qom/object.h"
+#include "trace.h"
+
+#define TYPE_MAX31790 "max31790"
+
+#define MAX31790_NUM_FANS 6
+#define MAX31790_NUM_TACHS 12
+
+#define MAX31790_REG_GLOBAL_CONFIG 0x00
+#define MAX31790_REG_PWM_FREQ 0x01
+
+/* 0x02 to 0x07: N = 0 .. 5 */
+#define MAX31790_REG_FAN_CONFIG(N) (0x02 + (N))
+
+/* 0x08 to 0x0d: N = 0 .. 5 */
+#define MAX31790_REG_FAN_DYNAMICS(N) (0x08 + (N))
+
+#define MAX31790_REG_FAN_FAULT_STATUS_2 0x10
+#define MAX31790_REG_FAN_FAULT_STATUS_1 0x11
+#define MAX31790_REG_FAN_FAULT_MASK_2 0x12
+#define MAX31790_REG_FAN_FAULT_MASK_1 0x13
+#define MAX31790_REG_FAILED_FAN_OPT 0x14
+
+/* 0x18 to 0x2f: N = 0 .. 11 */
+#define MAX31790_REG_TACH_COUNT_MSB(N) (0x18 + 2 * (N))
+#define MAX31790_REG_TACH_COUNT_LSB(N) (0x19 + 2 * (N))
+
+/* 0x30 to 0x3b: N = 0 .. 5 */
+#define MAX31790_REG_PWM_DUTY_CYCLE_MSB(N) (0x30 + 2 * (N))
+#define MAX31790_REG_PWM_DUTY_CYCLE_LSB(N) (0x31 + 2 * (N))
+
+/* .. reserved registers ... */
+
+/* 0x40 to 0x4b: N = 0 .. 5 */
+#define MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(N) (0x40 + 2 * (N))
+#define MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(N) (0x41 + 2 * (N))
+
+/* ... 'User Byte' registers ... */
+
+/* 0x50 to 0x5b: N = 0 .. 5 */
+#define MAX31790_REG_TACH_TARGET_COUNT_MSB(N) (0x50 + 2 * (N))
+#define MAX31790_REG_TACH_TARGET_COUNT_LSB(N) (0x51 + 2 * (N))
+
+struct MAX31790State {
+    I2CSlave i2c;
+
+    uint8_t fan_config[MAX31790_NUM_FANS];
+    uint8_t fan_dynamics[MAX31790_NUM_FANS];
+
+    uint16_t pwm[MAX31790_NUM_FANS];
+    uint16_t tach_target[MAX31790_NUM_FANS];
+
+    /*
+     * Fan speed is measured by counting the number of internal 8192Hz
+     * (fTOSC/4) clock cycles that take place during a select-
+     * able number of tachometer periods. The number of clock
+     * cycles counted (11-bit value) is stored in the associated
+     * TACH Count registers and the desired number of cycles
+     * is stored in the TACH Target Count registers.
+     */
+    uint16_t tach_count[MAX31790_NUM_TACHS];
+
+    /* command buffer */
+    uint8_t len;
+    uint8_t buf[2];
+
+    /* output buffer */
+    uint8_t outlen;
+    uint8_t outbuf[2];
+
+    /* selected register for read/write operation */
+    uint8_t pointer;
+};
+
+struct MAX31790Class {
+    I2CSlaveClass parent_class;
+};
+
+OBJECT_DECLARE_TYPE(MAX31790State, MAX31790Class, MAX31790)
+
+static void max31790_read(MAX31790State *s)
+{
+    size_t index = 0;
+    uint8_t out0 = 0;
+    uint8_t out1 = 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);
+
+        out0 = s->fan_config[index];
+        trace_max31790_fan_config_read(s->i2c.address, index, out0);
+        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);
+
+        out0 = s->fan_dynamics[index];
+        trace_max31790_fan_dynamics_read(s->i2c.address, index, out0);
+        break;
+    case MAX31790_REG_FAN_FAULT_STATUS_1:
+    case MAX31790_REG_FAN_FAULT_STATUS_2:
+        /* we do not have any fan fault */
+        out0 = 0x00;
+        out1 = 0x00;
+        break;
+    case MAX31790_REG_TACH_COUNT_MSB(0):
+    case MAX31790_REG_TACH_COUNT_MSB(1):
+    case MAX31790_REG_TACH_COUNT_MSB(2):
+    case MAX31790_REG_TACH_COUNT_MSB(3):
+    case MAX31790_REG_TACH_COUNT_MSB(4):
+    case MAX31790_REG_TACH_COUNT_MSB(5):
+    case MAX31790_REG_TACH_COUNT_MSB(6):
+    case MAX31790_REG_TACH_COUNT_MSB(7):
+    case MAX31790_REG_TACH_COUNT_MSB(8):
+    case MAX31790_REG_TACH_COUNT_MSB(9):
+    case MAX31790_REG_TACH_COUNT_MSB(10):
+    case MAX31790_REG_TACH_COUNT_MSB(11):
+        index = (s->pointer - MAX31790_REG_TACH_COUNT_MSB(0)) / 2;
+
+        g_assert(index < MAX31790_NUM_TACHS);
+
+        out0 = (s->tach_count[index % MAX31790_NUM_TACHS] >> 8) & 0xff;
+        out1 = s->tach_count[index % MAX31790_NUM_TACHS] & 0xff;
+        break;
+
+    case MAX31790_REG_TACH_COUNT_LSB(0):
+    case MAX31790_REG_TACH_COUNT_LSB(1):
+    case MAX31790_REG_TACH_COUNT_LSB(2):
+    case MAX31790_REG_TACH_COUNT_LSB(3):
+    case MAX31790_REG_TACH_COUNT_LSB(4):
+    case MAX31790_REG_TACH_COUNT_LSB(5):
+    case MAX31790_REG_TACH_COUNT_LSB(6):
+    case MAX31790_REG_TACH_COUNT_LSB(7):
+    case MAX31790_REG_TACH_COUNT_LSB(8):
+    case MAX31790_REG_TACH_COUNT_LSB(9):
+    case MAX31790_REG_TACH_COUNT_LSB(10):
+    case MAX31790_REG_TACH_COUNT_LSB(11):
+        index = (s->pointer - MAX31790_REG_TACH_COUNT_LSB(0)) / 2;
+
+        g_assert(index < MAX31790_NUM_TACHS);
+
+        out0 = s->tach_count[index % MAX31790_NUM_TACHS] & 0xff;
+        break;
+
+    case MAX31790_REG_PWM_DUTY_CYCLE_MSB(0):
+    case MAX31790_REG_PWM_DUTY_CYCLE_MSB(1):
+    case MAX31790_REG_PWM_DUTY_CYCLE_MSB(2):
+    case MAX31790_REG_PWM_DUTY_CYCLE_MSB(3):
+    case MAX31790_REG_PWM_DUTY_CYCLE_MSB(4):
+    case MAX31790_REG_PWM_DUTY_CYCLE_MSB(5):
+        index = (s->pointer - MAX31790_REG_PWM_DUTY_CYCLE_MSB(0)) / 2;
+
+        g_assert(index < MAX31790_NUM_FANS);
+
+        out0 = (s->pwm[index % MAX31790_NUM_FANS] >> 8) & 0xff;
+        out1 = s->pwm[index % MAX31790_NUM_FANS] & 0xff;
+        break;
+    case MAX31790_REG_PWM_DUTY_CYCLE_LSB(0):
+    case MAX31790_REG_PWM_DUTY_CYCLE_LSB(1):
+    case MAX31790_REG_PWM_DUTY_CYCLE_LSB(2):
+    case MAX31790_REG_PWM_DUTY_CYCLE_LSB(3):
+    case MAX31790_REG_PWM_DUTY_CYCLE_LSB(4):
+    case MAX31790_REG_PWM_DUTY_CYCLE_LSB(5):
+        index = (s->pointer - MAX31790_REG_PWM_DUTY_CYCLE_LSB(0)) / 2;
+
+        g_assert(index < MAX31790_NUM_FANS);
+
+        out0 = s->pwm[index % MAX31790_NUM_FANS] & 0xff;
+        break;
+
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(0):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(1):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(2):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(3):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(4):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(5):
+        index = (s->pointer - MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(0)) / 2;
+
+        g_assert(index < MAX31790_NUM_FANS);
+
+        out0 = (s->pwm[index % MAX31790_NUM_FANS] >> 8) & 0xff;
+        out1 = s->pwm[index % MAX31790_NUM_FANS] & 0xff;
+        break;
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(0):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(1):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(2):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(3):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(4):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(5):
+        index = (s->pointer - MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(0)) / 2;
+
+        g_assert(index < MAX31790_NUM_FANS);
+
+        out0 = s->pwm[index % MAX31790_NUM_FANS] & 0xff;
+        break;
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(0):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(1):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(2):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(3):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(4):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(5):
+        index = (s->pointer - MAX31790_REG_TACH_TARGET_COUNT_MSB(0)) / 2;
+
+        g_assert(index < MAX31790_NUM_FANS);
+
+        out0 = (s->tach_target[index] >> 8) & 0xff;
+        out1 = s->tach_target[index] & 0xff;
+        break;
+    case MAX31790_REG_TACH_TARGET_COUNT_LSB(0):
+    case MAX31790_REG_TACH_TARGET_COUNT_LSB(1):
+    case MAX31790_REG_TACH_TARGET_COUNT_LSB(2):
+    case MAX31790_REG_TACH_TARGET_COUNT_LSB(3):
+    case MAX31790_REG_TACH_TARGET_COUNT_LSB(4):
+    case MAX31790_REG_TACH_TARGET_COUNT_LSB(5):
+        index = (s->pointer - MAX31790_REG_TACH_TARGET_COUNT_LSB(0)) / 2;
+
+        g_assert(index < MAX31790_NUM_FANS);
+
+        out0 = s->tach_target[index] & 0xff;
+        break;
+    default:
+        qemu_log_mask(LOG_UNIMP, "%s: read of register %d\n", __func__,
+                      s->pointer);
+        break;
+    }
+
+    s->outbuf[0] = out0;
+    s->outbuf[1] = out1;
+}
+
+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);
+    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.
+     */
+    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;
+
+    /* simplified, assuming NP = 2 */
+    uint64_t tach_count = (tach_count_constant * sr) / (uint64_t)rpm;
+
+    /* in case of overflow, clamp to the maximum value */
+    if (tach_count > 0x7ff) {
+        tach_count = 0x7ff;
+    }
+
+    g_assert(index < MAX31790_NUM_TACHS);
+
+    /* datasheet: lowest 5 bits are 0 */
+    s->tach_count[index] = (uint16_t)(tach_count << 5);
+
+    trace_max31790_tach_count_reg(s->i2c.address, index, s->tach_count[index]);
+}
+
+static void max31790_pwm_write(MAX31790State *s, size_t index, uint16_t value)
+{
+    trace_max31790_pwm_write(s->i2c.address, index, value);
+
+    g_assert(index < MAX31790_NUM_FANS);
+
+    s->pwm[index % MAX31790_NUM_FANS] = value;
+
+    /* 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);
+}
+
+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):
+        break; /* handled by one byte write */
+    case MAX31790_REG_FAN_DYNAMICS(0)... MAX31790_REG_FAN_DYNAMICS(5):
+        break; /* handled by one byte write */
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(0):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(1):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(2):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(3):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(4):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(5):
+        index = (s->pointer - MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(0)) / 2;
+        max31790_pwm_write(s, index, value0 << 8 | value1);
+        break;
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(0):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(1):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(2):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(3):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(4):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(5):
+        index = (s->pointer - MAX31790_REG_TACH_TARGET_COUNT_MSB(0)) / 2;
+
+        g_assert(index < MAX31790_NUM_FANS);
+
+        s->tach_target[index] = (value0 << 8) | value1;
+        break;
+    default:
+        qemu_log_mask(LOG_UNIMP, "%s: write to register %d\n", __func__,
+                      s->pointer);
+        break;
+    }
+}
+
+static void max31790_write_1_byte(MAX31790State *s)
+{
+    size_t index = 0;
+    uint16_t pwm = 0;
+    const uint8_t value = s->buf[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);
+
+        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);
+        break;
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(0):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(1):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(2):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(3):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(4):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(5):
+        index = (s->pointer - MAX31790_REG_PWM_TARGET_DUTY_CYCLE_MSB(0)) / 2;
+
+        g_assert(index < MAX31790_NUM_FANS);
+
+        pwm = (value << 8) | (s->pwm[index % MAX31790_NUM_FANS] & 0x00ff);
+        max31790_pwm_write(s, index, pwm);
+        break;
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(0):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(1):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(2):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(3):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(4):
+    case MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(5):
+        index = (s->pointer - MAX31790_REG_PWM_TARGET_DUTY_CYCLE_LSB(0)) / 2;
+
+        g_assert(index < MAX31790_NUM_FANS);
+
+        pwm = (s->pwm[index % MAX31790_NUM_FANS] & 0xff00) | (value & 0x00ff);
+        max31790_pwm_write(s, index, pwm);
+        break;
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(0):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(1):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(2):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(3):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(4):
+    case MAX31790_REG_TACH_TARGET_COUNT_MSB(5):
+        index = (s->pointer - MAX31790_REG_TACH_TARGET_COUNT_MSB(0)) / 2;
+
+        g_assert(index < MAX31790_NUM_FANS);
+
+        s->tach_target[index] = (s->tach_target[index] & 0x00ff) | (value << 8);
+        break;
+    case MAX31790_REG_TACH_TARGET_COUNT_LSB(0):
+    case MAX31790_REG_TACH_TARGET_COUNT_LSB(1):
+    case MAX31790_REG_TACH_TARGET_COUNT_LSB(2):
+    case MAX31790_REG_TACH_TARGET_COUNT_LSB(3):
+    case MAX31790_REG_TACH_TARGET_COUNT_LSB(4):
+    case MAX31790_REG_TACH_TARGET_COUNT_LSB(5):
+        index = (s->pointer - MAX31790_REG_TACH_TARGET_COUNT_LSB(0)) / 2;
+
+        g_assert(index < MAX31790_NUM_FANS);
+
+        s->tach_target[index] = (s->tach_target[index] & 0xff00) | value;
+        break;
+    default:
+        qemu_log_mask(LOG_UNIMP, "%s: write to register %d\n", __func__,
+                      s->pointer);
+        break;
+    }
+}
+
+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++;
+        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;
+    s->len++;
+
+    if (s->len == 2) {
+        max31790_write_1_byte(s);
+    } else if (s->len == 3) {
+        max31790_write_2_byte(s);
+    }
+
+    return 0;
+}
+
+static uint8_t max31790_recv(I2CSlave *i2c)
+{
+    MAX31790State *s = MAX31790(i2c);
+
+    max31790_read(s);
+    s->len = 0;
+
+    if (s->outlen >= 2) {
+        /* error */
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: guest over read\n", __func__);
+        s->outlen = 0;
+    }
+
+    const uint8_t data = s->outbuf[s->outlen++];
+
+    trace_max31790_recv_return(s->i2c.address, s->pointer, data);
+    return data;
+}
+
+static int max31790_event(I2CSlave *i2c, enum i2c_event event)
+{
+    MAX31790State *s = MAX31790(i2c);
+
+    switch (event) {
+    case I2C_START_RECV:
+        s->outlen = 0;
+        break;
+    case I2C_START_SEND:
+        s->len = 0;
+        break;
+    default:
+        break;
+    }
+
+    return 0;
+}
+
+static const VMStateDescription vmstate_max31790 = {
+    .name = TYPE_MAX31790,
+    .version_id = 0,
+    .minimum_version_id = 0,
+    .fields =
+        (const VMStateField[]){
+            VMSTATE_UINT8(len, MAX31790State),
+            VMSTATE_UINT8_ARRAY(fan_config, MAX31790State, MAX31790_NUM_FANS),
+            VMSTATE_UINT8_ARRAY(fan_dynamics, MAX31790State, MAX31790_NUM_FANS),
+            VMSTATE_UINT16_ARRAY(pwm, MAX31790State, MAX31790_NUM_FANS),
+            VMSTATE_UINT16_ARRAY(tach_target, MAX31790State, MAX31790_NUM_FANS),
+            VMSTATE_UINT16_ARRAY(tach_count, MAX31790State, MAX31790_NUM_TACHS),
+            VMSTATE_UINT8_ARRAY(buf, MAX31790State, 2),
+            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++) {
+        /* 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;
+    }
+
+    /* this will set both pwm and tach count */
+    for (int i = 0; i < MAX31790_NUM_FANS; i++) {
+        max31790_pwm_write(s, i, 0x4444);
+    }
+}
+
+static void max31790_reset_hold(Object *obj, ResetType type)
+{
+    MAX31790State *s = MAX31790(obj);
+
+    max31790_reset_enter(s);
+}
+
+static void max31790_realize(DeviceState *dev, Error **errp)
+{
+    MAX31790State *s = MAX31790(dev);
+
+    trace_max31790_realize(s->i2c.address);
+}
+
+static void max31790_class_init(ObjectClass *klass, const void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
+
+    dc->realize = max31790_realize;
+    dc->desc = "Maxim MAX31790 6-Channel Fan Controller";
+    dc->vmsd = &vmstate_max31790;
+    rc->phases.hold = max31790_reset_hold;
+    k->event = max31790_event;
+    k->recv = max31790_recv;
+    k->send = max31790_send;
+}
+
+static const TypeInfo max31790_info = {
+    .name = TYPE_MAX31790,
+    .parent = TYPE_I2C_SLAVE,
+    .instance_size = sizeof(MAX31790State),
+    .class_size = sizeof(MAX31790Class),
+    .class_init = max31790_class_init,
+};
+
+static void max31790_register_types(void)
+{
+    type_register_static(&max31790_info);
+}
+
+type_init(max31790_register_types)
hw/sensor/meson.build +1 -0
index 420fdc3359..4987c3b253 100644
@@ -8,3 +8,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
index a3fe54fa6d..35c30b985c 100644
@@ -4,3 +4,16 @@
  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"
tests/functional/arm/test_aspeed_fby4.py +47 -0
index a521834f79..f344413fe4 100755
@@ -7,6 +7,7 @@
  from qemu_test import Asset
  from qemu_test import wait_for_console_pattern
  from aspeed import AspeedTest
+from qemu_test import exec_command_and_wait_for_pattern
 
 
  class YosemiteV4Machine(AspeedTest):
@@ -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:");
+
+        exec_command_and_wait_for_pattern(self, "0penBmc", "#");
+
+        # MAX31790 test
+        exec_command_and_wait_for_pattern(self,
+            "cat /sys/class/hwmon/hwmon2/name", "max31790");
+
+        # 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/hwmon2/fan1_input", "7281");
+        exec_command_and_wait_for_pattern(self,
+            "cat /sys/class/hwmon/hwmon2/fan1_enable", "1");
+        exec_command_and_wait_for_pattern(self,
+            "cat /sys/class/hwmon/hwmon2/fan1_fault", "0");
+
+        exec_command_and_wait_for_pattern(self,
+            "echo 1 > /sys/class/hwmon/hwmon2/pwm1", "root@yosemite4");
+        exec_command_and_wait_for_pattern(self,
+            "cat /sys/class/hwmon/hwmon2/fan1_input", "0");
+
+        # linux driver pwm write:
+        # >>> hex(int((11 * 511) / 255) << 7)
+        # '0xb00'
+        exec_command_and_wait_for_pattern(self,
+            "echo 11 > /sys/class/hwmon/hwmon2/pwm1", "root@yosemite4");
+        # device emulation logic:
+        # >>> hex(100 + (0xb00 >> 7) * 20)
+        # '0x21c'
+        # register reading value:
+        # >>> hex(int((245760 * 4) / 0x21c) << 5)
+        # '0xe380'
+        # linux driver calculation:
+        # >>> int((60 * 4 * 8192) / (0xe380 >> 4))
+        # 540
+        exec_command_and_wait_for_pattern(self,
+            "cat /sys/class/hwmon/hwmon2/fan1_input", "540");
+
+        exec_command_and_wait_for_pattern(self,
+            "echo 255 > /sys/class/hwmon/hwmon2/pwm1", "root@yosemite4");
+        exec_command_and_wait_for_pattern(self,
+            "cat /sys/class/hwmon/hwmon2/fan1_input", "10347");
+
      def test_arm_ast2600_yosemitev4_openbmc(self):
          image_path = self.uncompress(self.ASSET_YOSEMITE_V4_FLASH)
 
#7 lore raw

Re: [PATCH v7 3/4] hw/sensor: MAX31790 support

In reply to [email protected]

hw/sensor/max31790.c line 16

Quoted 10 lines · On 19 Jun 2026, at 13:55, [email protected] wrote:

From: Alexander Hansen <[email protected]>

hw/sensor/max31790.c new file +2 -0
new file mode 100644
index 0000000000..af610376d1
@@ -0,0 +1,584 @@
 
+#include "qapi/error.h"
+#include "qapi/visitor.h"

I do not think error.h nor visitor.h APIs are used in this file

hw/sensor/max31790.c line 97

Quoted 5 lines
hw/sensor/max31790.c new file +5 -0
+struct MAX31790Class {
+    I2CSlaveClass parent_class;
+};
+
+OBJECT_DECLARE_TYPE(MAX31790State, MAX31790Class, MAX31790)

Maybe stick with the I2CSlaveClass as no feature is added here, with OBJECT_DECLARE_TYPED_SIMPLE(MAX31790State, MAX31790)

#8 lore raw

PATCH v7 4/4 hw/sensor: support MAX11615

In reply to [email protected]

From: Alexander Hansen <[email protected]>

Product: [1]
Datasheet: [2]

Sensor readings can be provided upon creation of the device. In case no readings are provided 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
1922
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

Cc 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)
---
 MAINTAINERS                              |   1 +
 hw/arm/Kconfig                           |   1 +
 hw/arm/aspeed_ast2600_fby4.c             |   8 +-
 hw/sensor/Kconfig                        |   4 +
 hw/sensor/max11615.c                     | 320 +++++++++++++++++++++++
 hw/sensor/meson.build                    |   1 +
 hw/sensor/trace-events                   |   9 +
 include/hw/sensor/max11615.h             |  19 ++
 tests/functional/arm/test_aspeed_fby4.py |   9 +
 9 files changed, 371 insertions(+), 1 deletion(-)
 create mode 100644 hw/sensor/max11615.c
 create mode 100644 include/hw/sensor/max11615.h
MAINTAINERS +1 -0
index e3df75f7bb..4b5c8cc65a 100644
@@ -3993,6 +3993,7 @@ S: Maintained
 F: hw/i2c/pmbus_device.c
 F: hw/sensor/adm1272.c
 F: hw/sensor/isl_pmbus_vr.c
+F: hw/sensor/max11615.c
 F: hw/sensor/max31790.c
 F: hw/sensor/max34451.c
 F: include/hw/i2c/pmbus_device.h
hw/arm/Kconfig +1 -0
index 43e96a671b..19259bc2e2 100644
@@ -554,6 +554,7 @@ config ASPEED_SOC
     select PMBUS
     select MAX31785
     select MAX31790
+    select MAX11615
     select FSI_APB2OPB_ASPEED
     select AT24C
     select PCI_EXPRESS
hw/arm/aspeed_ast2600_fby4.c +7 -1
index 8feb31bc44..dd84839c65 100644
@@ -11,6 +11,7 @@
 #include "hw/arm/aspeed.h"
 #include "hw/arm/aspeed_soc.h"
 #include "hw/nvram/eeprom_at24c.h"
+#include "hw/sensor/max11615.h"
 #include "hw/i2c/i2c_mux_pca954x.h"
 #include "hw/gpio/pca9552.h"
 
@@ -185,7 +186,12 @@ static void fby4_i2c_init_fanboard(I2CSlave *fan_mux, size_t eepromSize)
         i2c_slave_create_simple(bus, "max31790", 0x2f);
 
         /* maxim,max11615 @ 0x33   (adc) */
-        /* TODO */
+        static const uint16_t adc_values[8] = {
+            1922, 1000,
+            1922, 1000,
+            1922, 1000,
+            1922, 1000};
+        max11615_init_with_values(bus, 0x33, adc_values, 8);
 
         at24c_eeprom_init_rom(
             bus, 0x52, eepromSize,
hw/sensor/Kconfig +4 -0
index 767f198e92..441bee7604 100644
@@ -47,3 +47,7 @@ config MAX31785
 config MAX31790
     bool
     depends on I2C
+
+config MAX11615
+    bool
+    depends on I2C
hw/sensor/max11615.c new file +320 -0

320 lines not on this page · raw message

hw/sensor/meson.build +1 -0
index 4987c3b253..a1e26604fa 100644
@@ -9,3 +9,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_MAX11615', if_true: files('max11615.c'))
hw/sensor/trace-events +9 -0
index 35c30b985c..1512819354 100644
@@ -17,3 +17,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_enter(uint8_t i2c_addr) "i2c_addr: 0x%02x"
include/hw/sensor/max11615.h new file +19 -0
new file mode 100644
index 0000000000..647ef62ef1
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef QEMU_MAX11615_H
+#define QEMU_MAX11615_H
+
+#include "hw/i2c/i2c.h"
+
+#define TYPE_MAX11615 "max11615"
+
+/*
+ * Create and realize a MAX11615 ADC with constant caller-supplied readings
+ * @bus: I2C bus to put it on
+ * @address: I2C address
+ * @init_values: array of readings for each ADC channel
+ * @init_values_size: Size of @init_values, can be less than the number of channels
+ */
+I2CSlave *max11615_init_with_values(I2CBus *bus, uint8_t address,
+                                    const uint16_t *init_values, uint32_t init_values_size);
+
+#endif
tests/functional/arm/test_aspeed_fby4.py +9 -0
index f344413fe4..98223e3ab1 100755
@@ -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/hwmon2/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", "1922");
+        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.54.0
#9 lore raw

Re: [PATCH v7 4/4] hw/sensor: support MAX11615

Hello,

Could the sensors Maintainers take a look please ?

Thanks,

C.

Quoted 526 lines · On 6/19/26 13:55, [email protected] wrote:

From: Alexander Hansen <[email protected]>

Product: [1]
Datasheet: [2]

Sensor readings can be provided upon creation of the device. In case no readings are provided 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
1922
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

Cc 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)
---
  MAINTAINERS                              |   1 +
  hw/arm/Kconfig                           |   1 +
  hw/arm/aspeed_ast2600_fby4.c             |   8 +-
  hw/sensor/Kconfig                        |   4 +
  hw/sensor/max11615.c                     | 320 +++++++++++++++++++++++
  hw/sensor/meson.build                    |   1 +
  hw/sensor/trace-events                   |   9 +
  include/hw/sensor/max11615.h             |  19 ++
  tests/functional/arm/test_aspeed_fby4.py |   9 +
  9 files changed, 371 insertions(+), 1 deletion(-)

create mode 100644 hw/sensor/max11615.c
create mode 100644 include/hw/sensor/max11615.h

MAINTAINERS +1 -0
index e3df75f7bb..4b5c8cc65a 100644
@@ -3993,6 +3993,7 @@ S: Maintained
  F: hw/i2c/pmbus_device.c
  F: hw/sensor/adm1272.c
  F: hw/sensor/isl_pmbus_vr.c
+F: hw/sensor/max11615.c
  F: hw/sensor/max31790.c
  F: hw/sensor/max34451.c
  F: include/hw/i2c/pmbus_device.h
hw/arm/Kconfig +1 -0
index 43e96a671b..19259bc2e2 100644
@@ -554,6 +554,7 @@ config ASPEED_SOC
      select PMBUS
      select MAX31785
      select MAX31790
+    select MAX11615
      select FSI_APB2OPB_ASPEED
      select AT24C
      select PCI_EXPRESS
hw/arm/aspeed_ast2600_fby4.c +7 -1
index 8feb31bc44..dd84839c65 100644
@@ -11,6 +11,7 @@
  #include "hw/arm/aspeed.h"
  #include "hw/arm/aspeed_soc.h"
  #include "hw/nvram/eeprom_at24c.h"
+#include "hw/sensor/max11615.h"
  #include "hw/i2c/i2c_mux_pca954x.h"
  #include "hw/gpio/pca9552.h"
 
@@ -185,7 +186,12 @@ static void fby4_i2c_init_fanboard(I2CSlave *fan_mux, size_t eepromSize)
          i2c_slave_create_simple(bus, "max31790", 0x2f);
 
          /* maxim,max11615 @ 0x33   (adc) */
-        /* TODO */
+        static const uint16_t adc_values[8] = {
+            1922, 1000,
+            1922, 1000,
+            1922, 1000,
+            1922, 1000};
+        max11615_init_with_values(bus, 0x33, adc_values, 8);
 
          at24c_eeprom_init_rom(
              bus, 0x52, eepromSize,
hw/sensor/Kconfig +4 -0
index 767f198e92..441bee7604 100644
@@ -47,3 +47,7 @@ config MAX31785
  config MAX31790
      bool
      depends on I2C
+
+config MAX11615
+    bool
+    depends on I2C
hw/sensor/max11615.c new file +320 -0
new file mode 100644
index 0000000000..ac2ccda4fa
@@ -0,0 +1,320 @@
+/*
+ * Maxim MAX11615 Low-Power 12 bit ADC
+ * Models MAX11612,MAX11613,MAX11614,MAX11615,MAX11616,MAX11617
+ *
+ * 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"
+#include "hw/sensor/max11615.h"
+#include "hw/i2c/i2c.h"
+#include "migration/vmstate.h"
+#include "qapi/error.h"
+#include "qapi/visitor.h"
+#include "qemu/log.h"
+#include "qemu/module.h"
+#include "trace.h"
+
+#define MAX11615_NUM_CHANNELS 8
+
+struct MAX11615State {
+    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;
+
+    uint16_t channels[MAX11615_NUM_CHANNELS];
+
+    /* output buffer */
+    uint8_t outlen;
+    uint8_t outbuf[2];
+
+    /* selected channel for read/write operation */
+    uint8_t pointer;
+};
+
+struct MAX11615Class {
+    I2CSlaveClass parent_class;
+};
+
+OBJECT_DECLARE_TYPE(MAX11615State, MAX11615Class, MAX11615)
+
+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;
+}
+
+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) {
+        value = 0xfff;
+    }
+    max11615_set_outbuf(s, value);
+}
+
+static int16_t max11615_differential_value(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;
+}
+
+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;
+        if (value < -fs) {
+            vu = 0x800;
+        }
+        if (value > fs) {
+            vu = 0x7ff;
+        }
+    } else {
+        /*
+         * A negative differential analog input in unipolar mode causes the
+         * digital output code to be zero
+         */
+        if (value < 0) {
+            vu = 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);
+    }
+}
+
+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__);
+    }
+
+    uint8_t channel_select = (data >> 1) & 0xf;
+
+    /* Table 3. Channel Selection */
+    if (channel_select >= MAX11615_NUM_CHANNELS) {
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid channel select\n",
+                      __func__);
+        channel_select = MAX11615_NUM_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 */
+
+    /* 1 = no action, 0 = resets the configuration register to default */
+    const bool rst = ((data >> 1) & 0x1) == 0x0;
+
+    if (rst) {
+        s->single_ended = true;
+        s->pointer = 0;
+    }
+
+    s->bipolar = ((data >> 2) & 0x1) == 0x1;
+
+    /* Table 6. Reference Voltage */
+    const uint8_t sel = (data >> 4) & 0x7;
+
+    if (sel == 0x2 || sel == 0x3) {
+        qemu_log_mask(LOG_UNIMP, "%s: unsupported: external vref\n", __func__);
+    }
+}
+
+static int max11615_send(I2CSlave *i2c, uint8_t data)
+{
+    MAX11615State *s = MAX11615(i2c);
+    const uint8_t msb = (data >> 7) & 0x1;
+
+    if (msb) {
+        max11615_write_setup_byte(s, data);
+    } else {
+        max11615_write_config_byte(s, data);
+    }
+
+    s->outlen = 0;
+    return 0;
+}
+
+static uint8_t max11615_recv(I2CSlave *i2c)
+{
+    MAX11615State *s = MAX11615(i2c);
+    trace_max11615_recv(s->i2c.address, s->pointer);
+
+    if (s->outlen >= 2) {
+        /* MAX11615 supports multichannel scan with wraparound */
+        /* see datasheet page 17 */
+
+        s->outlen = 0;
+
+        s->pointer++;
+        if (s->pointer >= MAX11615_NUM_CHANNELS) {
+            s->pointer = 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)
+{
+    MAX11615State *s = MAX11615(i2c);
+
+    trace_max11615_event(s->i2c.address, event);
+
+    switch (event) {
+    case I2C_START_RECV:
+        s->outlen = 0;
+        break;
+    default:
+        break;
+    }
+
+    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),
+                                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),
+                                VMSTATE_UINT8(pointer, MAX11615State),
+                                VMSTATE_I2C_SLAVE(i2c, MAX11615State),
+                                VMSTATE_END_OF_LIST() }
+};
+
+I2CSlave *max11615_init_with_values(I2CBus *bus, uint8_t address,
+                                    const uint16_t *init_values,
+                                    uint32_t init_values_size)
+{
+    MAX11615State *s;
+
+    s = MAX11615(i2c_slave_new(TYPE_MAX11615, address));
+
+    i2c_slave_realize_and_unref(I2C_SLAVE(s), bus, &error_abort);
+
+    for (int i = 0; i < MAX11615_NUM_CHANNELS; i++) {
+        /* arbitrary value if there is no data*/
+        s->channels[i] = i < init_values_size ? init_values[i] : 0x2d2;
+    }
+
+    return I2C_SLAVE(s);
+}
+
+static void max11615_reset_enter(MAX11615State *s)
+{
+    trace_max11615_reset_enter(s->i2c.address);
+
+    s->single_ended = true;
+    s->bipolar = false;
+    s->vref = 2048;
+    s->pointer = 0;
+    s->outlen = 0;
+
+    for (int i = 0; i < MAX11615_NUM_CHANNELS; i++) {
+        s->channels[i] = 0x2d2;
+    }
+}
+
+static void max11615_reset(Object *obj, ResetType type)
+{
+    MAX11615State *s = MAX11615(obj);
+
+    max11615_reset_enter(s);
+}
+
+static void max11615_realize(DeviceState *dev, Error **errp)
+{
+    MAX11615State *s = MAX11615(dev);
+
+    trace_max11615_realize(s->i2c.address);
+}
+
+static void max11615_class_init(ObjectClass *klass, const void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
+
+    dc->realize = max11615_realize;
+    dc->desc = "Maxim MAX11615 12-bit ADC";
+    dc->vmsd = &vmstate_max11615;
+    rc->phases.hold = max11615_reset;
+    k->event = max11615_event;
+    k->recv = max11615_recv;
+    k->send = max11615_send;
+}
+
+static const TypeInfo max11615_info = {
+    .name = TYPE_MAX11615,
+    .parent = TYPE_I2C_SLAVE,
+    .instance_size = sizeof(MAX11615State),
+    .class_size = sizeof(MAX11615Class),
+    .class_init = max11615_class_init,
+};
+
+static void max11615_register_types(void)
+{
+    type_register_static(&max11615_info);
+}
+
+type_init(max11615_register_types)
hw/sensor/meson.build +1 -0
index 4987c3b253..a1e26604fa 100644
@@ -9,3 +9,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_MAX11615', if_true: files('max11615.c'))
hw/sensor/trace-events +9 -0
index 35c30b985c..1512819354 100644
@@ -17,3 +17,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_enter(uint8_t i2c_addr) "i2c_addr: 0x%02x"
include/hw/sensor/max11615.h new file +19 -0
new file mode 100644
index 0000000000..647ef62ef1
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef QEMU_MAX11615_H
+#define QEMU_MAX11615_H
+
+#include "hw/i2c/i2c.h"
+
+#define TYPE_MAX11615 "max11615"
+
+/*
+ * Create and realize a MAX11615 ADC with constant caller-supplied readings
+ * @bus: I2C bus to put it on
+ * @address: I2C address
+ * @init_values: array of readings for each ADC channel
+ * @init_values_size: Size of @init_values, can be less than the number of channels
+ */
+I2CSlave *max11615_init_with_values(I2CBus *bus, uint8_t address,
+                                    const uint16_t *init_values, uint32_t init_values_size);
+
+#endif
tests/functional/arm/test_aspeed_fby4.py +9 -0
index f344413fe4..98223e3ab1 100755
@@ -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/hwmon2/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", "1922");
+        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)
 
#10 lore raw

Re: [PATCH v7 4/4] hw/sensor: support MAX11615

In reply to [email protected]

hw/sensor/max11615.c

Quoted 7 lines · On 19 Jun 2026, at 13:55, [email protected] wrote:

From: Alexander Hansen <[email protected]>

hw/sensor/max11615.c new file +0 -0
new file mode 100644
index 0000000000..ac2ccda4fa

Would it make sense to call it max1161x.c and create a specific version for the 8-channel version?
It seems Analog Devices produces MAX 11612 .. 11617 which mostly vary with the input channel count, so your driver could later be extended to support the 4- and 12- channel version. This would avoid being stuck with a specific model in its name, as it is unfortunately the case with several I2C emulated device in QEMU such as PCA9552, PCA9554, …

Quoted 1 line

+#include "qapi/visitor.h"

I think this file inclusion is not needed.

hw/sensor/max11615.c line 54

Quoted 5 lines
hw/sensor/max11615.c new file +5 -0
+struct MAX11615Class {
+    I2CSlaveClass parent_class;
+};
+
+OBJECT_DECLARE_TYPE(MAX11615State, MAX11615Class, MAX11615)

Maybe stick with the I2CSlaveClass as no feature is added here, with OBJECT_DECLARE_TYPED_SIMPLE(MAX11615State, MAX11615)

If you opt-in for a multi-channel implementation (MAX1161x), this does not apply, as the class should contain the number of ADC channels, initialized for the MAX11615 version with MAX11615_NUM_CHANNELS.

hw/sensor/max11615.c line 88

Quoted 11 lines
hw/sensor/max11615.c new file +5 -0
+static int16_t max11615_differential_value(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;

hw/sensor/max11615.c new file +5 -0
+
+    const int16_t ch1 = s->channels[i1];
+    const int16_t ch2 = s->channels[i2];
+    return ch1 - ch2;
+}

Maybe const MAX11615State *s

Quoted 18 lines

+static void max11615_write_config_byte(MAX11615State *s, uint8_t data)

hw/sensor/max11615.c new file +7 -0
+{
+    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__);

hw/sensor/max11615.c new file +7 -0
+    }
+
+    uint8_t channel_select = (data >> 1) & 0xf;
+
+    /* Table 3. Channel Selection */
+    if (channel_select >= MAX11615_NUM_CHANNELS) {
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid channel 

select\n",

hw/sensor/max11615.c line 146

Quoted 6 lines
hw/sensor/max11615.c new file +6 -0
+                      __func__);
+        channel_select = MAX11615_NUM_CHANNELS - 1;
+    }
+    s->pointer = channel_select;
+    s->single_ended = data & 0x1;
+}

I’m not sure about the invalid channel management. The datasheet specifies:
“For the MAX11615, CS3 is internally set to 0”.
My understanding is that channel_select is therefore masked with MAX11615_NUM_CHANNELS - 1 here, not 0xf; the actual selected channel is wrapped rather than been maxed.

BTW a nice addition - for a future update, I do not think it is worth changing it now - would be to use the registerfields.h macros, it would make the code more readable as hardcoded mask & shift would be managed.

Quoted 14 lines
hw/sensor/max11615.c new file +13 -0
+I2CSlave *max11615_init_with_values(I2CBus *bus, uint8_t address,
+                                    const uint16_t *init_values,
+                                    uint32_t init_values_size)
+{
+    MAX11615State *s;
+
+    s = MAX11615(i2c_slave_new(TYPE_MAX11615, address));
+
+    i2c_slave_realize_and_unref(I2C_SLAVE(s), bus, &error_abort);
+
+    for (int i = 0; i < MAX11615_NUM_CHANNELS; i++) {
+        /* arbitrary value if there is no data*/
+        s->channels[i] = i < init_values_size ? init_values[i] : 

0x2d2;

hw/sensor/max11615.c line 261

Quoted 4 lines
hw/sensor/max11615.c new file +4 -0
+    }
+
+    return I2C_SLAVE(s);
+}

max11615_reset_enter is called once the device is realized, overriding those values with the default reset ones. I’m not sure to understand how this function can be used. I think it would be more flexible to use QOM properties rather than a custom dedicated function to initialize default values.

Quoted 12 lines
hw/sensor/max11615.c new file +12 -0
+
+static void max11615_reset_enter(MAX11615State *s)
+{
+    trace_max11615_reset_enter(s->i2c.address);
+
+    s->single_ended = true;
+    s->bipolar = false;
+    s->vref = 2048;
+    s->pointer = 0;
+    s->outlen = 0;
+
+    for (int i = 0; i < MAX11615_NUM_CHANNELS; i++) {

hw/sensor/max11615.c line 283

Quoted 10 lines
hw/sensor/max11615.c new file +10 -0
+        s->channels[i] = 0x2d2;
+    }
+}
+
+static void max11615_reset(Object *obj, ResetType type)
+{
+    MAX11615State *s = MAX11615(obj);
+
+    max11615_reset_enter(s);
+}

I tend to think it should be the opposite call logic:
- max11615_reset should be called max11615_reset_hold as per
rc->phases.hold = max11615_reset;
- max11615_reset_hold should call max11615_reset
- max11615_reset should initialize the default values
- max11615_reset should also be called from write to SETUP./rst (hence the need for two reset functions)

#11 lore raw

Re: [PATCH v7 4/4] hw/sensor: support MAX11615

In reply to [email protected]
Quoted 516 lines · On 6/19/26 13:55, [email protected] wrote:

From: Alexander Hansen <[email protected]>

Product: [1]
Datasheet: [2]

Sensor readings can be provided upon creation of the device. In case no readings are provided 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
1922
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

Cc 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)
---
  MAINTAINERS                              |   1 +
  hw/arm/Kconfig                           |   1 +
  hw/arm/aspeed_ast2600_fby4.c             |   8 +-
  hw/sensor/Kconfig                        |   4 +
  hw/sensor/max11615.c                     | 320 +++++++++++++++++++++++
  hw/sensor/meson.build                    |   1 +
  hw/sensor/trace-events                   |   9 +
  include/hw/sensor/max11615.h             |  19 ++
  tests/functional/arm/test_aspeed_fby4.py |   9 +
  9 files changed, 371 insertions(+), 1 deletion(-)

create mode 100644 hw/sensor/max11615.c
create mode 100644 include/hw/sensor/max11615.h

MAINTAINERS +1 -0
index e3df75f7bb..4b5c8cc65a 100644
@@ -3993,6 +3993,7 @@ S: Maintained
  F: hw/i2c/pmbus_device.c
  F: hw/sensor/adm1272.c
  F: hw/sensor/isl_pmbus_vr.c
+F: hw/sensor/max11615.c
  F: hw/sensor/max31790.c
  F: hw/sensor/max34451.c
  F: include/hw/i2c/pmbus_device.h
hw/arm/Kconfig +1 -0
index 43e96a671b..19259bc2e2 100644
@@ -554,6 +554,7 @@ config ASPEED_SOC
      select PMBUS
      select MAX31785
      select MAX31790
+    select MAX11615
      select FSI_APB2OPB_ASPEED
      select AT24C
      select PCI_EXPRESS
hw/arm/aspeed_ast2600_fby4.c +7 -1
index 8feb31bc44..dd84839c65 100644
@@ -11,6 +11,7 @@
  #include "hw/arm/aspeed.h"
  #include "hw/arm/aspeed_soc.h"
  #include "hw/nvram/eeprom_at24c.h"
+#include "hw/sensor/max11615.h"
  #include "hw/i2c/i2c_mux_pca954x.h"
  #include "hw/gpio/pca9552.h"
 
@@ -185,7 +186,12 @@ static void fby4_i2c_init_fanboard(I2CSlave *fan_mux, size_t eepromSize)
          i2c_slave_create_simple(bus, "max31790", 0x2f);
 
          /* maxim,max11615 @ 0x33   (adc) */
-        /* TODO */
+        static const uint16_t adc_values[8] = {
+            1922, 1000,
+            1922, 1000,
+            1922, 1000,
+            1922, 1000};
+        max11615_init_with_values(bus, 0x33, adc_values, 8);
 
          at24c_eeprom_init_rom(
              bus, 0x52, eepromSize,
hw/sensor/Kconfig +4 -0
index 767f198e92..441bee7604 100644
@@ -47,3 +47,7 @@ config MAX31785
  config MAX31790
      bool
      depends on I2C
+
+config MAX11615
+    bool
+    depends on I2C
hw/sensor/max11615.c new file +320 -0
new file mode 100644
index 0000000000..ac2ccda4fa
@@ -0,0 +1,320 @@
+/*
+ * Maxim MAX11615 Low-Power 12 bit ADC
+ * Models MAX11612,MAX11613,MAX11614,MAX11615,MAX11616,MAX11617
+ *
+ * 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"
+#include "hw/sensor/max11615.h"
+#include "hw/i2c/i2c.h"
+#include "migration/vmstate.h"
+#include "qapi/error.h"
+#include "qapi/visitor.h"
+#include "qemu/log.h"
+#include "qemu/module.h"
+#include "trace.h"
+
+#define MAX11615_NUM_CHANNELS 8
+
+struct MAX11615State {
+    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;
+
+    uint16_t channels[MAX11615_NUM_CHANNELS];
+
+    /* output buffer */
+    uint8_t outlen;
+    uint8_t outbuf[2];
+
+    /* selected channel for read/write operation */
+    uint8_t pointer;
+};
+
+struct MAX11615Class {
+    I2CSlaveClass parent_class;
+};
+
+OBJECT_DECLARE_TYPE(MAX11615State, MAX11615Class, MAX11615)
+
+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;
+}
+
+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) {
+        value = 0xfff;
+    }
+    max11615_set_outbuf(s, value);
+}
+
+static int16_t max11615_differential_value(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;
+}
+
+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;
+        if (value < -fs) {
+            vu = 0x800;
+        }
+        if (value > fs) {
+            vu = 0x7ff;
+        }
+    } else {
+        /*
+         * A negative differential analog input in unipolar mode causes the
+         * digital output code to be zero
+         */
+        if (value < 0) {
+            vu = 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);
+    }
+}
+
+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__);
+    }
+
+    uint8_t channel_select = (data >> 1) & 0xf;
+
+    /* Table 3. Channel Selection */
+    if (channel_select >= MAX11615_NUM_CHANNELS) {
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid channel select\n",
+                      __func__);
+        channel_select = MAX11615_NUM_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 */
+
+    /* 1 = no action, 0 = resets the configuration register to default */
+    const bool rst = ((data >> 1) & 0x1) == 0x0;
+
+    if (rst) {
+        s->single_ended = true;
+        s->pointer = 0;
+    }
+
+    s->bipolar = ((data >> 2) & 0x1) == 0x1;
+
+    /* Table 6. Reference Voltage */
+    const uint8_t sel = (data >> 4) & 0x7;
+
+    if (sel == 0x2 || sel == 0x3) {
+        qemu_log_mask(LOG_UNIMP, "%s: unsupported: external vref\n", __func__);
+    }
+}
+
+static int max11615_send(I2CSlave *i2c, uint8_t data)
+{
+    MAX11615State *s = MAX11615(i2c);
+    const uint8_t msb = (data >> 7) & 0x1;
+
+    if (msb) {
+        max11615_write_setup_byte(s, data);
+    } else {
+        max11615_write_config_byte(s, data);
+    }
+
+    s->outlen = 0;
+    return 0;
+}
+
+static uint8_t max11615_recv(I2CSlave *i2c)
+{
+    MAX11615State *s = MAX11615(i2c);
+    trace_max11615_recv(s->i2c.address, s->pointer);
+
+    if (s->outlen >= 2) {
+        /* MAX11615 supports multichannel scan with wraparound */
+        /* see datasheet page 17 */
+
+        s->outlen = 0;
+
+        s->pointer++;
+        if (s->pointer >= MAX11615_NUM_CHANNELS) {
+            s->pointer = 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)
+{
+    MAX11615State *s = MAX11615(i2c);
+
+    trace_max11615_event(s->i2c.address, event);
+
+    switch (event) {
+    case I2C_START_RECV:
+        s->outlen = 0;
+        break;
+    default:
+        break;
+    }
+
+    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),
+                                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),
+                                VMSTATE_UINT8(pointer, MAX11615State),
+                                VMSTATE_I2C_SLAVE(i2c, MAX11615State),
+                                VMSTATE_END_OF_LIST() }
+};
+
+I2CSlave *max11615_init_with_values(I2CBus *bus, uint8_t address,
+                                    const uint16_t *init_values,
+                                    uint32_t init_values_size)
+{
+    MAX11615State *s;
+
+    s = MAX11615(i2c_slave_new(TYPE_MAX11615, address));
+
+    i2c_slave_realize_and_unref(I2C_SLAVE(s), bus, &error_abort);
+
+    for (int i = 0; i < MAX11615_NUM_CHANNELS; i++) {
+        /* arbitrary value if there is no data*/
+        s->channels[i] = i < init_values_size ? init_values[i] : 0x2d2;
+    }
+
+    return I2C_SLAVE(s);
+}
+
+static void max11615_reset_enter(MAX11615State *s)
+{
+    trace_max11615_reset_enter(s->i2c.address);
+
+    s->single_ended = true;
+    s->bipolar = false;
+    s->vref = 2048;
+    s->pointer = 0;
+    s->outlen = 0;
+
+    for (int i = 0; i < MAX11615_NUM_CHANNELS; i++) {
+        s->channels[i] = 0x2d2;
+    }
+}
+
+static void max11615_reset(Object *obj, ResetType type)
+{
+    MAX11615State *s = MAX11615(obj);
+
+    max11615_reset_enter(s);
+}
+
+static void max11615_realize(DeviceState *dev, Error **errp)
+{
+    MAX11615State *s = MAX11615(dev);
+
+    trace_max11615_realize(s->i2c.address);
+}
+
+static void max11615_class_init(ObjectClass *klass, const void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
+
+    dc->realize = max11615_realize;
+    dc->desc = "Maxim MAX11615 12-bit ADC";
+    dc->vmsd = &vmstate_max11615;
+    rc->phases.hold = max11615_reset;
+    k->event = max11615_event;
+    k->recv = max11615_recv;
+    k->send = max11615_send;
+}
+
+static const TypeInfo max11615_info = {
+    .name = TYPE_MAX11615,
+    .parent = TYPE_I2C_SLAVE,
+    .instance_size = sizeof(MAX11615State),
+    .class_size = sizeof(MAX11615Class),
+    .class_init = max11615_class_init,
+};
+
+static void max11615_register_types(void)
+{
+    type_register_static(&max11615_info);
+}
+
+type_init(max11615_register_types)
hw/sensor/meson.build +1 -0
index 4987c3b253..a1e26604fa 100644
@@ -9,3 +9,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_MAX11615', if_true: files('max11615.c'))
hw/sensor/trace-events +9 -0
index 35c30b985c..1512819354 100644
@@ -17,3 +17,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_enter(uint8_t i2c_addr) "i2c_addr: 0x%02x"
include/hw/sensor/max11615.h new file +19 -0
new file mode 100644
index 0000000000..647ef62ef1
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef QEMU_MAX11615_H
+#define QEMU_MAX11615_H
+
+#include "hw/i2c/i2c.h"
+
+#define TYPE_MAX11615 "max11615"
+
+/*
+ * Create and realize a MAX11615 ADC with constant caller-supplied readings
+ * @bus: I2C bus to put it on
+ * @address: I2C address
+ * @init_values: array of readings for each ADC channel
+ * @init_values_size: Size of @init_values, can be less than the number of channels
+ */
+I2CSlave *max11615_init_with_values(I2CBus *bus, uint8_t address,
+                                    const uint16_t *init_values, uint32_t init_values_size);
+
+#endif
tests/functional/arm/test_aspeed_fby4.py +2 -0
index f344413fe4..98223e3ab1 100755
@@ -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/hwmon2/fan1_input", "10347");
 
+        # MAX11615 test
+        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 95

Quoted 10 lines
tests/functional/arm/test_aspeed_fby4.py +7 -0
+            "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", "1922");
+        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)
 

Functional test fails :

  $ ./pyvenv/bin/meson test --suite thorough func-arm-aspeed_fby4
  ninja: Entering directory `/home/legoater/work/qemu/qemu-aspeed.git/build'
  [1/6] Generating qemu-version.h with a custom command (wrapped by meson to capture output)
  1/1 qemu:func-thorough+func-arm-thorough+thorough / func-arm-aspeed_fby4        TIMEOUT        480.01s   killed by signal 15 SIGTERM
  $ tail -2   tests/functional/arm/test_aspeed_fby4.YosemiteV4Machine.test_arm_ast2600_yosemitev4_openbmc/base.log
  '026-07-08 11:16:18,174 - DEBUG: qemu-test._console_interaction Console interaction: success_msg='max11615' failure_msg='None' send_string='cat /sys/bus/i2c/devices/30-0033/iio:device*/name
  '026-07-08 11:16:18,196 - DEBUG: qemu-test._console_interaction Console interaction: success_msg='1922' failure_msg='None' send_string='cat /sys/bus/i2c/devices/30-0033/iio:device*/in_voltage0_raw
  $ tail  -2 tests/functional/arm/test_aspeed_fby4.YosemiteV4Machine.test_arm_ast2600_yosemitev4_openbmc/console.log
  2026-07-08 11:16:18,225: root@yosemite4:~# cat /sys/bus/i2c/devices/30-0033/iio:device*/in_voltage0_raw
  2026-07-08 11:16:18,262: 722

Thanks,

C.