Skip to contentSkip to conversation

initial support for yosemite v4

PATCH Superseded Alexander Hansen 3 participants 8 messages May 4 – May 5

Subsystems (2)

v1 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

cover initial support for yosemite v4

Add initial and incomplete support for yosemite v4 BMC-side emulation.

As part of this effort 3 new sensor ICs are added.

Alexander Hansen (4):
hw/sensor: MAX31790 support
hw/sensor: support MAX11615
hw/sensor: support Texas Instruments ADC128D818
ast2600: yosemite4 initial support

 hw/arm/Kconfig                 |   3 +
 hw/arm/aspeed_ast2600_fby4.c   | 298 ++++++++++++++++++++
 hw/arm/meson.build             |   1 +
 hw/sensor/Kconfig              |  12 +
 hw/sensor/adc128d818.c         | 414 +++++++++++++++++++++++++++
 hw/sensor/max11615.c           | 200 +++++++++++++
 hw/sensor/max31790.c           | 497 +++++++++++++++++++++++++++++++++
 hw/sensor/meson.build          |   3 +
 hw/sensor/trace-events         |  24 ++
 include/hw/sensor/adc128d818.h |  20 ++
 include/hw/sensor/max11615.h   |  20 ++
 include/hw/sensor/max31790.h   |   7 +
 12 files changed, 1499 insertions(+)
 create mode 100644 hw/arm/aspeed_ast2600_fby4.c
 create mode 100644 hw/sensor/adc128d818.c
 create mode 100644 hw/sensor/max11615.c
 create mode 100644 hw/sensor/max31790.c
 create mode 100644 include/hw/sensor/adc128d818.h
 create mode 100644 include/hw/sensor/max11615.h
 create mode 100644 include/hw/sensor/max31790.h
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/4 hw/sensor: MAX31790 support

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 Paolo Bonzini <[email protected]>
Cc Peter Maydell <[email protected]>
Cc "Philippe Mathieu-Daudé" <[email protected]>
---
 hw/arm/Kconfig               |   1 +
 hw/sensor/Kconfig            |   4 +
 hw/sensor/max31790.c         | 497 +++++++++++++++++++++++++++++++++++
 hw/sensor/meson.build        |   1 +
 hw/sensor/trace-events       |   8 +
 include/hw/sensor/max31790.h |   7 +
 6 files changed, 518 insertions(+)
 create mode 100644 hw/sensor/max31790.c
 create mode 100644 include/hw/sensor/max31790.h
hw/arm/Kconfig +1 -0
index c31752e83a..c62db7e609 100644
@@ -551,6 +551,7 @@ config ASPEED_SOC
     select LED
     select PMBUS
     select MAX31785
+    select MAX31790
     select FSI_APB2OPB_ASPEED
     select AT24C
     select PCI_EXPRESS
hw/sensor/Kconfig +4 -0
index bc6331b4ab..ece2f2b167 100644
@@ -43,3 +43,7 @@ config ISL_PMBUS_VR
 config MAX31785
     bool
     depends on PMBUS
+
+config MAX31790
+    bool
+    depends on PMBUS
hw/sensor/max31790.c new file +497 -0

497 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 +8 -0
index a3fe54fa6d..c15c0a7e93 100644
@@ -4,3 +4,11 @@
 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(uint8_t i2c_addr, uint8_t reg_addr) "i2c_addr: 0x%02x, reg_addr: 0x%02x"
+max31790_recv_return(uint8_t i2c_addr, uint8_t data) "i2c_addr: 0x%02x, returns: 0x%02x"
+max31790_event(uint8_t i2c_addr, uint8_t event) "i2c_addr: 0x%02x, event: 0x%02x"
+max31790_realize(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"
include/hw/sensor/max31790.h new file +7 -0
new file mode 100644
index 0000000000..7ead420926
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#ifndef QEMU_MAX31790_H
+#define QEMU_MAX31790_H
+
+#define TYPE_MAX31790 "max31790"
+
+#endif
Signature · 1 line
2.54.0
#2 lore raw

PATCH 2/4 hw/sensor: support MAX11615

In reply to Alexander Hansen

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-deviced arbitrary value.

```
root@yosemite4:~# cat /sys/bus/iio/devices/iio:device2/in_voltage0_raw
2770
```

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 "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)
---
 hw/arm/Kconfig               |   1 +
 hw/sensor/Kconfig            |   4 +
 hw/sensor/max11615.c         | 200 +++++++++++++++++++++++++++++++++++
 hw/sensor/meson.build        |   1 +
 hw/sensor/trace-events       |   8 ++
 include/hw/sensor/max11615.h |  20 ++++
 6 files changed, 234 insertions(+)
 create mode 100644 hw/sensor/max11615.c
 create mode 100644 include/hw/sensor/max11615.h
hw/arm/Kconfig +1 -0
index c62db7e609..decbc8b0d8 100644
@@ -552,6 +552,7 @@ config ASPEED_SOC
     select PMBUS
     select MAX31785
     select MAX31790
+    select MAX11615
     select FSI_APB2OPB_ASPEED
     select AT24C
     select PCI_EXPRESS
hw/sensor/Kconfig +4 -0
index ece2f2b167..84eede9d84 100644
@@ -47,3 +47,7 @@ config MAX31785
 config MAX31790
     bool
     depends on PMBUS
+
+config MAX11615
+    bool
+    depends on I2C
hw/sensor/max11615.c new file +200 -0

200 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 +8 -0
index c15c0a7e93..3fed979e85 100644
@@ -12,3 +12,11 @@ max31790_recv_return(uint8_t i2c_addr, uint8_t data) "i2c_addr: 0x%02x, returns:
 max31790_event(uint8_t i2c_addr, uint8_t event) "i2c_addr: 0x%02x, event: 0x%02x"
 max31790_realize(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"
+
+# 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"
include/hw/sensor/max11615.h new file +20 -0
new file mode 100644
index 0000000000..ccc0c9bc2e
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#ifndef QEMU_MAX11615_H
+#define QEMU_MAX11615_H
+
+#include <stdint.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
Signature · 1 line
2.54.0
#3 lore raw

PATCH 3/4 hw/sensor: support Texas Instruments ADC128D818

In reply to Alexander Hansen

Product: [1]
Datasheet: [2]

ADC128D818 Support:
- channel readings from pre-set values
- driver can read and write most configuration registers

ADC128D818 currently unsupported:
- slave address restriction
- startup sequence and realistic busy register emulation
- external VREF
- conversion rate
- interrupts
- deep shutdown mode
- individual channel shutdown
- selection between Mode 0,1,2,3
- pseudo-differential input

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 v4 qemu

initialize the device:

```
// ti,adc128d818 @ 0x1f    (adc)
// the driver will throw away the last 4 bits, set them 0
uint16_t adc_values1[8] = {
    0b011110000000, 0b010100010000,
    0b001000110000, 0b100000100000,
    0b011110000000, 0b010100010000,
    0b001000110000, 0b100000100000};
adc128d818_init_with_values(bus, 0x1f, adc_values1, 8);
```

Trace outputs directly after initialization:

```
adc128d818_realize i2c_addr: 0x1f
adc128d818_realize i2c_addr: 0x1f
adc128d818_event i2c_addr: 0x1f, event: 0x01
adc128d818_send i2c_addr: 0x1f, data: 0x00
adc128d818_send i2c_addr: 0x1f, data: 0x80
adc128d818_write i2c_addr: 0x1f, reg: 0x00 data: 0x80
adc128d818_event i2c_addr: 0x1f, event: 0x03
adc128d818_event i2c_addr: 0x1f, event: 0x01
...
```

read the values

```
root@yosemite4:/sys/bus/i2c/devices/30-001f# cat hwmon/hwmon0/in0_min
0
root@yosemite4:/sys/bus/i2c/devices/30-001f# cat hwmon/hwmon0/in0_max
0
root@yosemite4:/sys/bus/i2c/devices/30-001f# cat hwmon/hwmon0/in0_input
75
root@yosemite4:/sys/bus/i2c/devices/30-001f# cat hwmon/hwmon0/name
adc128d818
```

We initially configured 0b011110000000 for the first channel. The driver throws away the last 4 bits and does calculation similar to below:

```
val = DIV_ROUND_CLOSEST(data->in[index][nr] * data->vref, 4095);
```
We can check that the calculation is as expected given our configured
value.
```
((0b011110000000 >> 4) * 2560) / 4095
75.01831501831502
```

References:
[1] https://www.ti.com/product/ADC128D818
[2] https://www.ti.com/lit/gpn/adc128d818

Cc Paolo Bonzini <[email protected]> (maintainer:Kconfig)
Cc Peter Maydell <[email protected]> (supporter:ARM TCG CPUs)
Cc "Philippe Mathieu-Daudé" <[email protected]> (odd fixer:Overall sensors)
Cc [email protected] (open list:ARM TCG CPUs)
Cc [email protected] (open list:All patches CC here)
---
 hw/arm/Kconfig                 |   1 +
 hw/sensor/Kconfig              |   4 +
 hw/sensor/adc128d818.c         | 414 +++++++++++++++++++++++++++++++++
 hw/sensor/meson.build          |   1 +
 hw/sensor/trace-events         |   8 +
 include/hw/sensor/adc128d818.h |  20 ++
 6 files changed, 448 insertions(+)
 create mode 100644 hw/sensor/adc128d818.c
 create mode 100644 include/hw/sensor/adc128d818.h
hw/arm/Kconfig +1 -0
index decbc8b0d8..c1693325a1 100644
@@ -553,6 +553,7 @@ config ASPEED_SOC
     select MAX31785
     select MAX31790
     select MAX11615
+    select ADC128D818
     select FSI_APB2OPB_ASPEED
     select AT24C
     select PCI_EXPRESS
hw/sensor/Kconfig +4 -0
index 84eede9d84..c9190ff780 100644
@@ -51,3 +51,7 @@ config MAX31790
 config MAX11615
     bool
     depends on I2C
+
+config ADC128D818
+    bool
+    depends on I2C
hw/sensor/adc128d818.c new file +414 -0

414 lines not on this page · raw message

hw/sensor/meson.build +1 -0
index a1e26604fa..defd7647e7 100644
@@ -10,3 +10,4 @@ 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'))
+system_ss.add(when: 'CONFIG_ADC128D818', if_true: files('adc128d818.c'))
hw/sensor/trace-events +8 -0
index 3fed979e85..4853f1944d 100644
@@ -20,3 +20,11 @@ max11615_recv(uint8_t i2c_addr, uint8_t reg_addr) "i2c_addr: 0x%02x, reg_addr: 0
 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"
+
+# adc128d818.c
+adc128d818_send(uint8_t i2c_addr, uint8_t data) "i2c_addr: 0x%02x, data: 0x%02x"
+adc128d818_write(uint8_t i2c_addr, uint8_t reg, uint8_t data) "i2c_addr: 0x%02x, reg: 0x%02x data: 0x%02x"
+adc128d818_recv(uint8_t i2c_addr, uint8_t reg) "i2c_addr: 0x%02x, reg: 0x%02x"
+adc128d818_recv_return(uint8_t i2c_addr, uint8_t data) "i2c_addr: 0x%02x, returns: 0x%02x"
+adc128d818_event(uint8_t i2c_addr, uint8_t event) "i2c_addr: 0x%02x, event: 0x%02x"
+adc128d818_realize(uint8_t i2c_addr) "i2c_addr: 0x%02x"
include/hw/sensor/adc128d818.h new file +20 -0
new file mode 100644
index 0000000000..e2bdc47590
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#ifndef QEMU_ADC128D818_H
+#define QEMU_ADC128D818_H
+
+#include <stdint.h>
+#include "hw/i2c/i2c.h"
+
+#define TYPE_ADC128D818 "adc128d818"
+
+/*
+ * Create and realize a adc128d818 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 *adc128d818_init_with_values(I2CBus *bus, uint8_t address,
+                                    const uint16_t *init_values, uint32_t init_values_size);
+
+#endif
Signature · 1 line
2.54.0
#4 lore raw

PATCH 4/4 ast2600: yosemite4 initial support

In reply to Alexander Hansen

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

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)
---
 hw/arm/aspeed_ast2600_fby4.c | 298 +++++++++++++++++++++++++++++++++++
 hw/arm/meson.build           |   1 +
 2 files changed, 299 insertions(+)
 create mode 100644 hw/arm/aspeed_ast2600_fby4.c
hw/arm/aspeed_ast2600_fby4.c new file +298 -0
new file mode 100644
index 0000000000..84cd372838
@@ -0,0 +1,298 @@
+#include <inttypes.h>
+#include <stdbool.h>
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "hw/arm/machines-qom.h"
+#include "hw/arm/aspeed.h"
+#include "hw/arm/aspeed_soc.h"
+#include "hw/nvram/eeprom_at24c.h"
+#include "hw/sensor/tmp105.h"
+#include "hw/sensor/max31790.h"
+#include "hw/sensor/max11615.h"
+#include "hw/sensor/adc128d818.h"
+#include "hw/i2c/i2c_mux_pca954x.h"
+#include "hw/gpio/pca9552.h"
+#include "system/reset.h"
+
+#define FBY4_BMC_RAM_SIZE ASPEED_RAM_SIZE(2 * GiB)
+
+/* START OF EEPROM CONTENTS */
+
+/*
+./frugen -s board.mfg="Wiwynn" \
+  --set board.pname="Fan Board FSC-MAX ADC-TI LED-NXP EFUSE-MAX" \
+  --set text:board.pn="BRD-PN-345" \
+  --board-date "10/1/2017 12:58:00" \
+  --set board.serial="123456" \
+  --set product.pname="Yosemite V4" \
+  --set product.mfg="Wiwynn" \
+  --set product.ver="v1.1" \
+  --set product.serial="123456" \
+  --set product.atag="PLACEHOLDER" \
+  --set product.custom="Fanboard Custom1" \
+  --set product.custom.1="Fanboard Custom2" \
+  --set text:product.pn="PN-345" \
+  fru-yv4-fanboard.bin
+*/
+/* EM Config: yosemite4_fanboard_fsc_max_adc_ti_led_nxp_ons_efuse_max.json */
+/* Yosemite4 fan board */
+unsigned char fru_yv4_fanboard_bin[] = {
+  0x01, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0xf3, 0x01, 0x0a, 0x19, 0xce,
+  0xc2, 0xa8, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xea, 0x46, 0x61,
+  0x6e, 0x20, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x46, 0x53, 0x43, 0x2d,
+  0x4d, 0x41, 0x58, 0x20, 0x41, 0x44, 0x43, 0x2d, 0x54, 0x49, 0x20, 0x4c,
+  0x45, 0x44, 0x2d, 0x4e, 0x58, 0x50, 0x20, 0x45, 0x46, 0x55, 0x53, 0x45,
+  0x2d, 0x4d, 0x41, 0x58, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05, 0xca, 0x42,
+  0x52, 0x44, 0x2d, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc0, 0xc1, 0x00,
+  0x00, 0x00, 0x00, 0xdb, 0x01, 0x09, 0x19, 0xc6, 0x57, 0x69, 0x77, 0x79,
+  0x6e, 0x6e, 0xcb, 0x59, 0x6f, 0x73, 0x65, 0x6d, 0x69, 0x74, 0x65, 0x20,
+  0x56, 0x34, 0xc6, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc4, 0x76, 0x31,
+  0x2e, 0x31, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05, 0x89, 0x30, 0x1b, 0x8e,
+  0x25, 0xfa, 0xb2, 0x64, 0x29, 0x03, 0xc0, 0xd0, 0x46, 0x61, 0x6e, 0x62,
+  0x6f, 0x61, 0x72, 0x64, 0x20, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x32,
+  0xc1, 0x00, 0x00, 0x9d
+};
+unsigned int fru_yv4_fanboard_bin_len = 160;
+
+/*
+./frugen -s board.mfg="Wiwynn" \
+  --set board.pname="Sentinel Dome without Retimer" \
+  --set text:board.pn="BRD-PN-345" \
+  --board-date "10/1/2017 12:58:00" \
+  --set board.serial="123456" \
+  --set product.pname="Yosemite V4" \
+  --set product.mfg="Wiwynn" \
+  --set product.ver="v1.1" \
+  --set product.serial="123456" \
+  --set product.atag="PLACEHOLDER" \
+  --set product.custom="Yosemite V4 T1" \
+  --set product.custom.1="Yosemite V4 T1" \
+  --set text:product.pn="PN-345" \
+  fru-yv4-sentineldome-board.bin
+*/
+/* product.cust maps to PRODUCT_INFO_AM2 */
+/* EM Config: yosemite4_sentineldome_t1.json */
+/* Yosemite4 Sentinel Dome without Retimer Boards */
+unsigned char fru_yv4_sentineldome_board_bin[] = {
+  0x01, 0x00, 0x00, 0x01, 0x09, 0x00, 0x00, 0xf5, 0x01, 0x08, 0x19, 0xce,
+  0xc2, 0xa8, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xdd, 0x53, 0x65,
+  0x6e, 0x74, 0x69, 0x6e, 0x65, 0x6c, 0x20, 0x44, 0x6f, 0x6d, 0x65, 0x20,
+  0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20, 0x52, 0x65, 0x74, 0x69,
+  0x6d, 0x65, 0x72, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05, 0xca, 0x42, 0x52,
+  0x44, 0x2d, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc0, 0xc1, 0x00, 0x78,
+  0x01, 0x09, 0x19, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xcb, 0x59,
+  0x6f, 0x73, 0x65, 0x6d, 0x69, 0x74, 0x65, 0x20, 0x56, 0x34, 0xc6, 0x50,
+  0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc4, 0x76, 0x31, 0x2e, 0x31, 0x85, 0x91,
+  0x34, 0x51, 0x95, 0x05, 0x89, 0x30, 0x1b, 0x8e, 0x25, 0xfa, 0xb2, 0x64,
+  0x29, 0x03, 0xc0, 0xce, 0x59, 0x6f, 0x73, 0x65, 0x6d, 0x69, 0x74, 0x65,
+  0x20, 0x56, 0x34, 0x20, 0x54, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0xeb
+};
+unsigned int fru_yv4_sentineldome_board_bin_len = 144;
+
+/*
+./frugen -s board.mfg="Wiwynn" \
+        --set board.pname="Sentinel Dome" \
+        --set text:board.pn="BRD-PN-345" \
+        --board-date "10/1/2017 12:58:00" \
+        --set board.serial="123456" \
+        --set product.pname="Yosemite V4" \
+        --set product.mfg="Wiwynn" \
+        --set product.ver="v1.1" \
+        --set product.serial="123456" \
+        --set product.atag="PLACEHOLDER" \
+        --set text:product.pn="PN-345" \
+        fru-yv4-sentineldome-chassis.bin
+*/
+/* EM Config: yosemite4_sentineldome_chassis.json */
+/* Yosemite 4 Sentinel Dome Chassis FRU */
+unsigned char fru_yv4_sentineldome_chassis_bin[] = {
+  0x01, 0x00, 0x00, 0x01, 0x07, 0x00, 0x00, 0xf7, 0x01, 0x06, 0x19, 0xce,
+  0xc2, 0xa8, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xcd, 0x53, 0x65,
+  0x6e, 0x74, 0x69, 0x6e, 0x65, 0x6c, 0x20, 0x44, 0x6f, 0x6d, 0x65, 0x85,
+  0x91, 0x34, 0x51, 0x95, 0x05, 0xca, 0x42, 0x52, 0x44, 0x2d, 0x50, 0x4e,
+  0x2d, 0x33, 0x34, 0x35, 0xc0, 0xc1, 0x00, 0xb6, 0x01, 0x07, 0x19, 0xc6,
+  0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xcb, 0x59, 0x6f, 0x73, 0x65, 0x6d,
+  0x69, 0x74, 0x65, 0x20, 0x56, 0x34, 0xc6, 0x50, 0x4e, 0x2d, 0x33, 0x34,
+  0x35, 0xc4, 0x76, 0x31, 0x2e, 0x31, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05,
+  0x89, 0x30, 0x1b, 0x8e, 0x25, 0xfa, 0xb2, 0x64, 0x29, 0x03, 0xc0, 0xc1,
+  0x00, 0x00, 0x00, 0x59
+};
+unsigned int fru_yv4_sentineldome_chassis_bin_len = 112;
+
+/*
+./frugen -s board.mfg="Wiwynn" \
+      --set board.pname="Management Board wBMC" \
+      --set text:board.pn="BRD-PN-345" \
+      --board-date "10/1/2017 12:58:00" \
+      --set board.serial="123456" \
+      --set product.pname="Yosemite V4" \
+      --set product.mfg="Wiwynn" \
+      --set product.ver="v1.1" \
+      --set product.serial="123456" \
+      --set product.atag="PLACEHOLDER" \
+      --set text:product.pn="PN-345" \
+      fru-yv4-eclosure.bin
+*/
+/* EM Config: yosemite4_chassis.json, yosemite4.json */
+/* Yosemite 4 Sentinel Dome Enclosure FRU */
+unsigned char fru_yv4_eclosure_bin[] = {
+  0x01, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0xf6, 0x01, 0x07, 0x19, 0xce,
+  0xc2, 0xa8, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xd5, 0x4d, 0x61,
+  0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x42, 0x6f, 0x61,
+  0x72, 0x64, 0x20, 0x77, 0x42, 0x4d, 0x43, 0x85, 0x91, 0x34, 0x51, 0x95,
+  0x05, 0xca, 0x42, 0x52, 0x44, 0x2d, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35,
+  0xc0, 0xc1, 0x00, 0x26, 0x01, 0x07, 0x19, 0xc6, 0x57, 0x69, 0x77, 0x79,
+  0x6e, 0x6e, 0xcb, 0x59, 0x6f, 0x73, 0x65, 0x6d, 0x69, 0x74, 0x65, 0x20,
+  0x56, 0x34, 0xc6, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc4, 0x76, 0x31,
+  0x2e, 0x31, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05, 0x89, 0x30, 0x1b, 0x8e,
+  0x25, 0xfa, 0xb2, 0x64, 0x29, 0x03, 0xc0, 0xc1, 0x00, 0x00, 0x00, 0x59
+};
+unsigned int fru_yv4_eclosure_bin_len = 120;
+
+/* END OF EEPROM CONTENTS */
+
+static void fby4_i2c_init_fanboard(I2CSlave *fan_mux, size_t eepromSize)
+{
+
+    /* 2 fan boards */
+    for (int i = 0; i <= 1; i++) {
+        /* downstream bus */
+        I2CBus *bus = pca954x_i2c_get_bus(fan_mux, i);
+
+        /* ti,adc128d818 @ 0x1f    (adc) */
+        /* the driver will throw away the last 4 bits, set them 0 */
+        uint16_t adc_values1[8] = {
+            0b011110000000, 0b010100010000,
+            0b001000110000, 0b100000100000,
+            0b011110000000, 0b010100010000,
+            0b001000110000, 0b100000100000};
+        adc128d818_init_with_values(bus,
+                              0x1f, adc_values1, 8);
+
+        /* maxim,max31790 @ 0x20   (pwm) */
+        i2c_slave_create_simple(bus,
+                              TYPE_MAX31790, 0x20);
+
+        /*
+         * ti,tca6424 @ 0x22       (gpio)
+         * linux handles tca6424 with PCA953X_TYPE, same as pca9535
+         * { "pca9535", 16 | PCA953X_TYPE | PCA_INT, },
+         * { "tca6424", 24 | PCA953X_TYPE | PCA_INT, },
+         * so we _could_ be fine here unless more than 16 gpios are used
+         */
+        i2c_slave_create_simple(bus,
+                              TYPE_PCA9535, 0x22);
+        /*
+         * NOTE: above works and could use for gpio presence:
+         * $ gpioget gpiochip2 2
+         * 1
+         */
+
+        /* maxim,max31790 @ 0x2f   (pwm) */
+        i2c_slave_create_simple(bus,
+                              TYPE_MAX31790, 0x2f);
+
+        /* maxim,max11615 @ 0x33   (adc) */
+        uint16_t adc_values[8] = {
+            0b011110000010, 0b010100011000,
+            0b001000110100, 0b100000101001,
+            0b011110000010, 0b010100011000,
+            0b001000110100, 0b100000101001};
+        max11615_init_with_values(bus,
+                              0x33, adc_values, 8);
+
+        at24c_eeprom_init_rom(
+            bus, 0x52, eepromSize,
+            fru_yv4_fanboard_bin,
+            fru_yv4_fanboard_bin_len);
+
+        /* LED blink driver / gpio expander */
+        /* nxp,pca9552 @ 0x61   (gpio) */
+        i2c_slave_create_simple(bus,
+                              TYPE_PCA9552, 0x61);
+    }
+}
+
+static void fby4_i2c_init_blade_chassis(I2CBus *bus, size_t eepromSize)
+{
+
+    /* Sentinel Dome Board EEPROMS */
+    const uint8_t board_addr = 0x54;
+    const uint8_t chassis_addr = 0x55;
+
+    /* Board */
+    at24c_eeprom_init_rom(bus, board_addr, eepromSize,
+        fru_yv4_sentineldome_board_bin, fru_yv4_sentineldome_board_bin_len);
+
+    /* Chassis */
+   at24c_eeprom_init_rom(bus, chassis_addr, eepromSize,
+       fru_yv4_sentineldome_chassis_bin, fru_yv4_sentineldome_chassis_bin_len);
+}
+
+static void fby4_i2c_init_multiple_blade_chassis(I2CBus **i2c,
+    size_t eepromSize)
+{
+
+    /* there is 8 blade chassis, but we only emulate 2 for performance reason */
+    for (int bus = 1; bus <= (8 / 4); bus++) {
+
+        fby4_i2c_init_blade_chassis(i2c[bus], eepromSize);
+    }
+}
+
+static void fby4_i2c_init(AspeedMachineState *bmc)
+{
+    AspeedSoCState *soc = bmc->soc;
+    I2CBus *i2c[16];
+
+    for (int i = 0; i < 16; i++) {
+        i2c[i] = aspeed_i2c_get_bus(&soc->i2c, i);
+    }
+
+    const size_t eepromSize = 128 * KiB;
+
+    const uint8_t enclosure_addr = 0x51;
+
+    /* Enclosure (EM Config: yosemite4_chassis.json, yosemite4.json) */
+    at24c_eeprom_init_rom(i2c[1], enclosure_addr, eepromSize,
+        fru_yv4_eclosure_bin, fru_yv4_eclosure_bin_len);
+
+    fby4_i2c_init_multiple_blade_chassis(i2c, eepromSize);
+
+    /* Yv4 fanboard connection */
+    I2CSlave *fan_mux = i2c_slave_create_simple(i2c[14], TYPE_PCA9546, 0x74);
+
+    fby4_i2c_init_fanboard(fan_mux, eepromSize);
+}
+
+static void fby4_reset(MachineState *state, ResetType type)
+{
+    qemu_devices_reset(type);
+}
+
+static void aspeed_machine_fby4_class_init(ObjectClass *oc, const void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+    AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
+
+    mc->desc       = "Facebook fby4 BMC (Cortex-A7)";
+    mc->reset      = fby4_reset;
+    amc->fmc_model = "mx66l1g45g";
+    amc->num_cs    = 2;
+    amc->macs_mask = ASPEED_MAC3_ON;
+    amc->i2c_init  = fby4_i2c_init;
+    mc->default_ram_size = FBY4_BMC_RAM_SIZE;
+    aspeed_machine_class_init_cpus_defaults(mc);
+}
+
+static const TypeInfo aspeed_ast2600_fby4_types[] = {
+    {
+        .name          = MACHINE_TYPE_NAME("fby4-bmc"),
+        .parent        = MACHINE_TYPE_NAME("ast2600-evb"),
+        .class_init    = aspeed_machine_fby4_class_init,
+        .interfaces    = arm_machine_interfaces,
+    }
+};
+
+DEFINE_TYPES(aspeed_ast2600_fby4_types)
hw/arm/meson.build +1 -0
index 84b8ec5fb5..ccbc23e549 100644
@@ -60,6 +60,7 @@ arm_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_qcom-dc-scm-v1.c',
Signature · 1 line
2.54.0
#5 lore raw

Re: [PATCH 4/4] ast2600: yosemite4 initial support

Hello,

Quoted 15 lines · Alexander Hansen

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
Quoted 7 lines

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.

A functional test would be greatly appreciated. This is especially true since the other patches add new sensors.

hw/arm/aspeed_ast2600_fby4.c

Quoted 27 lines

References:
[1] https://github.com/9elements/qemu/commit/32139f913c2bd0ebe4bd26c46765861f6f9f2d49
[2] arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts

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)
---
  hw/arm/aspeed_ast2600_fby4.c | 298 +++++++++++++++++++++++++++++++++++
  hw/arm/meson.build           |   1 +
  2 files changed, 299 insertions(+)

create mode 100644 hw/arm/aspeed_ast2600_fby4.c

hw/arm/aspeed_ast2600_fby4.c new file +0 -0
new file mode 100644
index 0000000000..84cd372838
@@ -0,0 +1,298 @@

This lacks a SPDX-License-Identifier and Copyright.

Did you run './scripts/checkpatch.pl' ?

hw/arm/aspeed_ast2600_fby4.c line 2

Quoted 2 lines
hw/arm/aspeed_ast2600_fby4.c new file +2 -0
+#include <inttypes.h>
+#include <stdbool.h>

Please remove

Quoted 27 lines
hw/arm/aspeed_ast2600_fby4.c new file +27 -0
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "hw/arm/machines-qom.h"
+#include "hw/arm/aspeed.h"
+#include "hw/arm/aspeed_soc.h"
+#include "hw/nvram/eeprom_at24c.h"
+#include "hw/sensor/tmp105.h"
+#include "hw/sensor/max31790.h"
+#include "hw/sensor/max11615.h"
+#include "hw/sensor/adc128d818.h"
+#include "hw/i2c/i2c_mux_pca954x.h"
+#include "hw/gpio/pca9552.h"
+#include "system/reset.h"
+
+#define FBY4_BMC_RAM_SIZE ASPEED_RAM_SIZE(2 * GiB)
+
+/* START OF EEPROM CONTENTS */
+
+/*
+./frugen -s board.mfg="Wiwynn" \
+  --set board.pname="Fan Board FSC-MAX ADC-TI LED-NXP EFUSE-MAX" \
+  --set text:board.pn="BRD-PN-345" \
+  --board-date "10/1/2017 12:58:00" \
+  --set board.serial="123456" \
+  --set product.pname="Yosemite V4" \
+  --set product.mfg="Wiwynn" \
+  --set product.ver="v1.1" \

hw/arm/aspeed_ast2600_fby4.c line 40

Quoted 10 lines
hw/arm/aspeed_ast2600_fby4.c new file +10 -0
+  --set product.serial="123456" \
+  --set product.atag="PLACEHOLDER" \
+  --set product.custom="Fanboard Custom1" \
+  --set product.custom.1="Fanboard Custom2" \
+  --set text:product.pn="PN-345" \
+  fru-yv4-fanboard.bin
+*/
+/* EM Config: yosemite4_fanboard_fsc_max_adc_ti_led_nxp_ons_efuse_max.json */
+/* Yosemite4 fan board */
+unsigned char fru_yv4_fanboard_bin[] = {

this should be a "static const uint8_t'

Quoted 6 lines
hw/arm/aspeed_ast2600_fby4.c new file +6 -0
+  0x01, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0xf3, 0x01, 0x0a, 0x19, 0xce,
+  0xc2, 0xa8, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xea, 0x46, 0x61,
+  0x6e, 0x20, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x46, 0x53, 0x43, 0x2d,
+  0x4d, 0x41, 0x58, 0x20, 0x41, 0x44, 0x43, 0x2d, 0x54, 0x49, 0x20, 0x4c,
+  0x45, 0x44, 0x2d, 0x4e, 0x58, 0x50, 0x20, 0x45, 0x46, 0x55, 0x53, 0x45,
+  0x2d, 0x4d, 0x41, 0x58, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05, 0xca, 0x42,

hw/arm/aspeed_ast2600_fby4.c line 56

Quoted 10 lines
hw/arm/aspeed_ast2600_fby4.c new file +10 -0
+  0x52, 0x44, 0x2d, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc0, 0xc1, 0x00,
+  0x00, 0x00, 0x00, 0xdb, 0x01, 0x09, 0x19, 0xc6, 0x57, 0x69, 0x77, 0x79,
+  0x6e, 0x6e, 0xcb, 0x59, 0x6f, 0x73, 0x65, 0x6d, 0x69, 0x74, 0x65, 0x20,
+  0x56, 0x34, 0xc6, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc4, 0x76, 0x31,
+  0x2e, 0x31, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05, 0x89, 0x30, 0x1b, 0x8e,
+  0x25, 0xfa, 0xb2, 0x64, 0x29, 0x03, 0xc0, 0xd0, 0x46, 0x61, 0x6e, 0x62,
+  0x6f, 0x61, 0x72, 0x64, 0x20, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x32,
+  0xc1, 0x00, 0x00, 0x9d
+};
+unsigned int fru_yv4_fanboard_bin_len = 160;

static const size_t fru_yv4_fanboard_bin_len = sizeof(fru_yv4_fanboard_bin);

Quoted 91 lines
hw/arm/aspeed_ast2600_fby4.c new file +91 -0
+
+/*
+./frugen -s board.mfg="Wiwynn" \
+  --set board.pname="Sentinel Dome without Retimer" \
+  --set text:board.pn="BRD-PN-345" \
+  --board-date "10/1/2017 12:58:00" \
+  --set board.serial="123456" \
+  --set product.pname="Yosemite V4" \
+  --set product.mfg="Wiwynn" \
+  --set product.ver="v1.1" \
+  --set product.serial="123456" \
+  --set product.atag="PLACEHOLDER" \
+  --set product.custom="Yosemite V4 T1" \
+  --set product.custom.1="Yosemite V4 T1" \
+  --set text:product.pn="PN-345" \
+  fru-yv4-sentineldome-board.bin
+*/
+/* product.cust maps to PRODUCT_INFO_AM2 */
+/* EM Config: yosemite4_sentineldome_t1.json */
+/* Yosemite4 Sentinel Dome without Retimer Boards */
+unsigned char fru_yv4_sentineldome_board_bin[] = {
+  0x01, 0x00, 0x00, 0x01, 0x09, 0x00, 0x00, 0xf5, 0x01, 0x08, 0x19, 0xce,
+  0xc2, 0xa8, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xdd, 0x53, 0x65,
+  0x6e, 0x74, 0x69, 0x6e, 0x65, 0x6c, 0x20, 0x44, 0x6f, 0x6d, 0x65, 0x20,
+  0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20, 0x52, 0x65, 0x74, 0x69,
+  0x6d, 0x65, 0x72, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05, 0xca, 0x42, 0x52,
+  0x44, 0x2d, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc0, 0xc1, 0x00, 0x78,
+  0x01, 0x09, 0x19, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xcb, 0x59,
+  0x6f, 0x73, 0x65, 0x6d, 0x69, 0x74, 0x65, 0x20, 0x56, 0x34, 0xc6, 0x50,
+  0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc4, 0x76, 0x31, 0x2e, 0x31, 0x85, 0x91,
+  0x34, 0x51, 0x95, 0x05, 0x89, 0x30, 0x1b, 0x8e, 0x25, 0xfa, 0xb2, 0x64,
+  0x29, 0x03, 0xc0, 0xce, 0x59, 0x6f, 0x73, 0x65, 0x6d, 0x69, 0x74, 0x65,
+  0x20, 0x56, 0x34, 0x20, 0x54, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0xeb
+};
+unsigned int fru_yv4_sentineldome_board_bin_len = 144;
+
+/*
+./frugen -s board.mfg="Wiwynn" \
+        --set board.pname="Sentinel Dome" \
+        --set text:board.pn="BRD-PN-345" \
+        --board-date "10/1/2017 12:58:00" \
+        --set board.serial="123456" \
+        --set product.pname="Yosemite V4" \
+        --set product.mfg="Wiwynn" \
+        --set product.ver="v1.1" \
+        --set product.serial="123456" \
+        --set product.atag="PLACEHOLDER" \
+        --set text:product.pn="PN-345" \
+        fru-yv4-sentineldome-chassis.bin
+*/
+/* EM Config: yosemite4_sentineldome_chassis.json */
+/* Yosemite 4 Sentinel Dome Chassis FRU */
+unsigned char fru_yv4_sentineldome_chassis_bin[] = {
+  0x01, 0x00, 0x00, 0x01, 0x07, 0x00, 0x00, 0xf7, 0x01, 0x06, 0x19, 0xce,
+  0xc2, 0xa8, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xcd, 0x53, 0x65,
+  0x6e, 0x74, 0x69, 0x6e, 0x65, 0x6c, 0x20, 0x44, 0x6f, 0x6d, 0x65, 0x85,
+  0x91, 0x34, 0x51, 0x95, 0x05, 0xca, 0x42, 0x52, 0x44, 0x2d, 0x50, 0x4e,
+  0x2d, 0x33, 0x34, 0x35, 0xc0, 0xc1, 0x00, 0xb6, 0x01, 0x07, 0x19, 0xc6,
+  0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xcb, 0x59, 0x6f, 0x73, 0x65, 0x6d,
+  0x69, 0x74, 0x65, 0x20, 0x56, 0x34, 0xc6, 0x50, 0x4e, 0x2d, 0x33, 0x34,
+  0x35, 0xc4, 0x76, 0x31, 0x2e, 0x31, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05,
+  0x89, 0x30, 0x1b, 0x8e, 0x25, 0xfa, 0xb2, 0x64, 0x29, 0x03, 0xc0, 0xc1,
+  0x00, 0x00, 0x00, 0x59
+};
+unsigned int fru_yv4_sentineldome_chassis_bin_len = 112;
+
+/*
+./frugen -s board.mfg="Wiwynn" \
+      --set board.pname="Management Board wBMC" \
+      --set text:board.pn="BRD-PN-345" \
+      --board-date "10/1/2017 12:58:00" \
+      --set board.serial="123456" \
+      --set product.pname="Yosemite V4" \
+      --set product.mfg="Wiwynn" \
+      --set product.ver="v1.1" \
+      --set product.serial="123456" \
+      --set product.atag="PLACEHOLDER" \
+      --set text:product.pn="PN-345" \
+      fru-yv4-eclosure.bin
+*/
+/* EM Config: yosemite4_chassis.json, yosemite4.json */
+/* Yosemite 4 Sentinel Dome Enclosure FRU */
+unsigned char fru_yv4_eclosure_bin[] = {
+  0x01, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0xf6, 0x01, 0x07, 0x19, 0xce,
+  0xc2, 0xa8, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xd5, 0x4d, 0x61,
+  0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x42, 0x6f, 0x61,
+  0x72, 0x64, 0x20, 0x77, 0x42, 0x4d, 0x43, 0x85, 0x91, 0x34, 0x51, 0x95,
+  0x05, 0xca, 0x42, 0x52, 0x44, 0x2d, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35,
+  0xc0, 0xc1, 0x00, 0x26, 0x01, 0x07, 0x19, 0xc6, 0x57, 0x69, 0x77, 0x79,
+  0x6e, 0x6e, 0xcb, 0x59, 0x6f, 0x73, 0x65, 0x6d, 0x69, 0x74, 0x65, 0x20,
+  0x56, 0x34, 0xc6, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc4, 0x76, 0x31,

hw/arm/aspeed_ast2600_fby4.c line 157

Quoted 10 lines
hw/arm/aspeed_ast2600_fby4.c new file +10 -0
+  0x2e, 0x31, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05, 0x89, 0x30, 0x1b, 0x8e,
+  0x25, 0xfa, 0xb2, 0x64, 0x29, 0x03, 0xc0, 0xc1, 0x00, 0x00, 0x00, 0x59
+};
+unsigned int fru_yv4_eclosure_bin_len = 120;
+
+/* END OF EEPROM CONTENTS */
+
+static void fby4_i2c_init_fanboard(I2CSlave *fan_mux, size_t eepromSize)
+{
+

extra white line

hw/arm/aspeed_ast2600_fby4.c line 165

Quoted 8 lines
hw/arm/aspeed_ast2600_fby4.c new file +8 -0
+    /* 2 fan boards */
+    for (int i = 0; i <= 1; i++) {
+        /* downstream bus */
+        I2CBus *bus = pca954x_i2c_get_bus(fan_mux, i);
+
+        /* ti,adc128d818 @ 0x1f    (adc) */
+        /* the driver will throw away the last 4 bits, set them 0 */
+        uint16_t adc_values1[8] = {

I would define these arrays as read only data.

hw/arm/aspeed_ast2600_fby4.c line 171

Quoted 6 lines
hw/arm/aspeed_ast2600_fby4.c new file +6 -0
+            0b011110000000, 0b010100010000,
+            0b001000110000, 0b100000100000,
+            0b011110000000, 0b010100010000,
+            0b001000110000, 0b100000100000};
+        adc128d818_init_with_values(bus,
+                              0x1f, adc_values1, 8);

This could be on one line.

hw/arm/aspeed_ast2600_fby4.c line 175

Quoted 4 lines
hw/arm/aspeed_ast2600_fby4.c new file +4 -0
+
+        /* maxim,max31790 @ 0x20   (pwm) */
+        i2c_slave_create_simple(bus,
+                              TYPE_MAX31790, 0x20);

same here.

Quoted 33 lines
hw/arm/aspeed_ast2600_fby4.c new file +33 -0
+
+        /*
+         * ti,tca6424 @ 0x22       (gpio)
+         * linux handles tca6424 with PCA953X_TYPE, same as pca9535
+         * { "pca9535", 16 | PCA953X_TYPE | PCA_INT, },
+         * { "tca6424", 24 | PCA953X_TYPE | PCA_INT, },
+         * so we _could_ be fine here unless more than 16 gpios are used
+         */
+        i2c_slave_create_simple(bus,
+                              TYPE_PCA9535, 0x22);
+        /*
+         * NOTE: above works and could use for gpio presence:
+         * $ gpioget gpiochip2 2
+         * 1
+         */
+
+        /* maxim,max31790 @ 0x2f   (pwm) */
+        i2c_slave_create_simple(bus,
+                              TYPE_MAX31790, 0x2f);
+
+        /* maxim,max11615 @ 0x33   (adc) */
+        uint16_t adc_values[8] = {
+            0b011110000010, 0b010100011000,
+            0b001000110100, 0b100000101001,
+            0b011110000010, 0b010100011000,
+            0b001000110100, 0b100000101001};
+        max11615_init_with_values(bus,
+                              0x33, adc_values, 8);
+> +        at24c_eeprom_init_rom(
+            bus, 0x52, eepromSize,
+            fru_yv4_fanboard_bin,
+            fru_yv4_fanboard_bin_len);
+

hw/arm/aspeed_ast2600_fby4.c line 219

Quoted 10 lines
hw/arm/aspeed_ast2600_fby4.c new file +10 -0
+        /* LED blink driver / gpio expander */
+        /* nxp,pca9552 @ 0x61   (gpio) */
+        i2c_slave_create_simple(bus,
+                              TYPE_PCA9552, 0x61);
+    }
+}
+
+static void fby4_i2c_init_blade_chassis(I2CBus *bus, size_t eepromSize)
+{
+

Extra white line.

hw/arm/aspeed_ast2600_fby4.c line 222

Quoted 3 lines
hw/arm/aspeed_ast2600_fby4.c new file +3 -0
+    /* Sentinel Dome Board EEPROMS */
+    const uint8_t board_addr = 0x54;
+    const uint8_t chassis_addr = 0x55;

These variables look unnecessary.

Quoted 4 lines
hw/arm/aspeed_ast2600_fby4.c new file +4 -0
+
+    /* Board */
+    at24c_eeprom_init_rom(bus, board_addr, eepromSize,
+        fru_yv4_sentineldome_board_bin, fru_yv4_sentineldome_board_bin_len);

hw/arm/aspeed_ast2600_fby4.c line 236

Quoted 10 lines
hw/arm/aspeed_ast2600_fby4.c new file +10 -0
+
+    /* Chassis */
+   at24c_eeprom_init_rom(bus, chassis_addr, eepromSize,
+       fru_yv4_sentineldome_chassis_bin, fru_yv4_sentineldome_chassis_bin_len);
+}
+
+static void fby4_i2c_init_multiple_blade_chassis(I2CBus **i2c,
+    size_t eepromSize)
+{
+

Extra white line.

Quoted 26 lines
hw/arm/aspeed_ast2600_fby4.c new file +26 -0
+    /* there is 8 blade chassis, but we only emulate 2 for performance reason */
+    for (int bus = 1; bus <= (8 / 4); bus++) {
+
+        fby4_i2c_init_blade_chassis(i2c[bus], eepromSize);
+    }
+}
+
+static void fby4_i2c_init(AspeedMachineState *bmc)
+{
+    AspeedSoCState *soc = bmc->soc;
+    I2CBus *i2c[16];
+
+    for (int i = 0; i < 16; i++) {
+        i2c[i] = aspeed_i2c_get_bus(&soc->i2c, i);
+    }
+
+    const size_t eepromSize = 128 * KiB;
+
+    const uint8_t enclosure_addr = 0x51;
+
+    /* Enclosure (EM Config: yosemite4_chassis.json, yosemite4.json) */
+    at24c_eeprom_init_rom(i2c[1], enclosure_addr, eepromSize,
+        fru_yv4_eclosure_bin, fru_yv4_eclosure_bin_len);
+
+    fby4_i2c_init_multiple_blade_chassis(i2c, eepromSize);
+

hw/arm/aspeed_ast2600_fby4.c line 272

Quoted 10 lines
hw/arm/aspeed_ast2600_fby4.c new file +10 -0
+    /* Yv4 fanboard connection */
+    I2CSlave *fan_mux = i2c_slave_create_simple(i2c[14], TYPE_PCA9546, 0x74);
+
+    fby4_i2c_init_fanboard(fan_mux, eepromSize);
+}
+
+static void fby4_reset(MachineState *state, ResetType type)
+{
+    qemu_devices_reset(type);
+}

not needed

Quoted 29 lines
hw/arm/aspeed_ast2600_fby4.c new file +24 -0
+static void aspeed_machine_fby4_class_init(ObjectClass *oc, const void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+    AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
+
+    mc->desc       = "Facebook fby4 BMC (Cortex-A7)";
+    mc->reset      = fby4_reset;
+    amc->fmc_model = "mx66l1g45g";
+    amc->num_cs    = 2;
+    amc->macs_mask = ASPEED_MAC3_ON;
+    amc->i2c_init  = fby4_i2c_init;
+    mc->default_ram_size = FBY4_BMC_RAM_SIZE;
+    aspeed_machine_class_init_cpus_defaults(mc);
+}> +
+static const TypeInfo aspeed_ast2600_fby4_types[] = {
+    {
+        .name          = MACHINE_TYPE_NAME("fby4-bmc"),
+        .parent        = MACHINE_TYPE_NAME("ast2600-evb"),
+        .class_init    = aspeed_machine_fby4_class_init,
+        .interfaces    = arm_machine_interfaces,
+    }
+};
+
+DEFINE_TYPES(aspeed_ast2600_fby4_types)
hw/arm/meson.build +0 -0
index 84b8ec5fb5..ccbc23e549 100644

hw/arm/meson.build arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( · line 66

Quoted 7 lines
hw/arm/meson.build +1 -0
@@ -60,6 +60,7 @@ arm_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_qcom-dc-scm-v1.c',

Thanks,

C.

#6 lore raw

Re: [PATCH 4/4] ast2600: yosemite4 initial support

Hi Cedric, thanks for taking a look so quickly!

Quoted 1 line

A functional test would be greatly appreciated. This is especially  true since the other patches add new sensors.

I sent a v2 which includes a functional test, i agree that would be quite helpful to confirm that the new sensors do not crash anything :) The functional test is currently pointing to my fork of qemu-aspeed-boot (so you can run it already) but a PR to your tree has been opened.

The new functional test has a single issue which is that one line from the expected logs (hostname) is not emitted. I am not sure if it's due to differences in the image or simply due to timeouts being hit on userspace services.

Networking however is functional and i can ssh into the qemu machine. For now i simply dropped that assertion from the function test and instead asserted on the login prompt.

I hope to have addressed all your comments,  looking forward to your next review :p

Thank you,
Alexander

Quoted 460 lines · Cédric Le Goater

Hello,

Quoted 15 lines · Alexander Hansen

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

Quoted 7 lines

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.

A functional test would be greatly appreciated. This is especially true since the other patches add new sensors.

hw/arm/aspeed_ast2600_fby4.c

Quoted 27 lines

References:
[1] https://github.com/9elements/qemu/commit/32139f913c2bd0ebe4bd26c46765861f6f9f2d49
[2] arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts

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)

---
  hw/arm/aspeed_ast2600_fby4.c | 298 +++++++++++++++++++++++++++++++++++ hw/arm/meson.build           |   1 +

  2 files changed, 299 insertions(+)

  create mode 100644 hw/arm/aspeed_ast2600_fby4.c

hw/arm/aspeed_ast2600_fby4.c new file +0 -0
new file mode 100644
index 0000000000..84cd372838
@@ -0,0 +1,298 @@

This lacks a SPDX-License-Identifier and Copyright.

Did you run './scripts/checkpatch.pl' ?

hw/arm/aspeed_ast2600_fby4.c line 2

Quoted 2 lines
hw/arm/aspeed_ast2600_fby4.c new file +2 -0
+#include <inttypes.h>
+#include <stdbool.h>

Please remove

Quoted 36 lines
hw/arm/aspeed_ast2600_fby4.c new file +35 -0
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "hw/arm/machines-qom.h"
+#include "hw/arm/aspeed.h"
+#include "hw/arm/aspeed_soc.h"
+#include "hw/nvram/eeprom_at24c.h"
+#include "hw/sensor/tmp105.h"
+#include "hw/sensor/max31790.h"
+#include "hw/sensor/max11615.h"
+#include "hw/sensor/adc128d818.h"
+#include "hw/i2c/i2c_mux_pca954x.h"
+#include "hw/gpio/pca9552.h"
+#include "system/reset.h"
+
+#define FBY4_BMC_RAM_SIZE ASPEED_RAM_SIZE(2 * GiB)
+
+/* START OF EEPROM CONTENTS */
+
+/*
+./frugen -s board.mfg="Wiwynn" \
+  --set board.pname="Fan Board FSC-MAX ADC-TI LED-NXP EFUSE-MAX" \
+  --set text:board.pn="BRD-PN-345" \
+  --board-date "10/1/2017 12:58:00" \
+  --set board.serial="123456" \
+  --set product.pname="Yosemite V4" \
+  --set product.mfg="Wiwynn" \
+  --set product.ver="v1.1" \
+  --set product.serial="123456" \
+  --set product.atag="PLACEHOLDER" \
+  --set product.custom="Fanboard Custom1" \
+  --set product.custom.1="Fanboard Custom2" \
+  --set text:product.pn="PN-345" \
+  fru-yv4-fanboard.bin
+*/
+/* EM Config: 

yosemite4_fanboard_fsc_max_adc_ti_led_nxp_ons_efuse_max.json */

hw/arm/aspeed_ast2600_fby4.c line 40

Quoted 2 lines
hw/arm/aspeed_ast2600_fby4.c new file +2 -0
+/* Yosemite4 fan board */
+unsigned char fru_yv4_fanboard_bin[] = {

this should be a "static const uint8_t'

Quoted 27 lines

+  0x01, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0xf3, 0x01, 0x0a, 0x19, 0xce,
+  0xc2, 0xa8, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xea, 0x46, 0x61,
+  0x6e, 0x20, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x46, 0x53, 0x43, 0x2d,
+  0x4d, 0x41, 0x58, 0x20, 0x41, 0x44, 0x43, 0x2d, 0x54, 0x49, 0x20, 0x4c,
+  0x45, 0x44, 0x2d, 0x4e, 0x58, 0x50, 0x20, 0x45, 0x46, 0x55, 0x53, 0x45,
+  0x2d, 0x4d, 0x41, 0x58, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05, 0xca, 0x42,
+  0x52, 0x44, 0x2d, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc0, 0xc1, 0x00,
+  0x00, 0x00, 0x00, 0xdb, 0x01, 0x09, 0x19, 0xc6, 0x57, 0x69, 0x77, 0x79,
+  0x6e, 0x6e, 0xcb, 0x59, 0x6f, 0x73, 0x65, 0x6d, 0x69, 0x74, 0x65, 0x20,
+  0x56, 0x34, 0xc6, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc4, 0x76, 0x31,
+  0x2e, 0x31, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05, 0x89, 0x30, 0x1b, 0x8e,
+  0x25, 0xfa, 0xb2, 0x64, 0x29, 0x03, 0xc0, 0xd0, 0x46, 0x61, 0x6e, 0x62,
+  0x6f, 0x61, 0x72, 0x64, 0x20, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x32,
+  0xc1, 0x00, 0x00, 0x9d

hw/arm/aspeed_ast2600_fby4.c line 56

Quoted 2 lines
hw/arm/aspeed_ast2600_fby4.c new file +2 -0
+};
+unsigned int fru_yv4_fanboard_bin_len = 160;

static const size_t fru_yv4_fanboard_bin_len = sizeof(fru_yv4_fanboard_bin);

Quoted 131 lines
hw/arm/aspeed_ast2600_fby4.c new file +22 -0
+
+/*
+./frugen -s board.mfg="Wiwynn" \
+  --set board.pname="Sentinel Dome without Retimer" \
+  --set text:board.pn="BRD-PN-345" \
+  --board-date "10/1/2017 12:58:00" \
+  --set board.serial="123456" \
+  --set product.pname="Yosemite V4" \
+  --set product.mfg="Wiwynn" \
+  --set product.ver="v1.1" \
+  --set product.serial="123456" \
+  --set product.atag="PLACEHOLDER" \
+  --set product.custom="Yosemite V4 T1" \
+  --set product.custom.1="Yosemite V4 T1" \
+  --set text:product.pn="PN-345" \
+  fru-yv4-sentineldome-board.bin
+*/
+/* product.cust maps to PRODUCT_INFO_AM2 */
+/* EM Config: yosemite4_sentineldome_t1.json */
+/* Yosemite4 Sentinel Dome without Retimer Boards */
+unsigned char fru_yv4_sentineldome_board_bin[] = {
+  0x01, 0x00, 0x00, 0x01, 0x09, 0x00, 0x00, 0xf5, 0x01, 0x08, 0x19, 

0xce,
+  0xc2, 0xa8, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xdd, 0x53, 0x65,
+  0x6e, 0x74, 0x69, 0x6e, 0x65, 0x6c, 0x20, 0x44, 0x6f, 0x6d, 0x65, 0x20,
+  0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20, 0x52, 0x65, 0x74, 0x69,
+  0x6d, 0x65, 0x72, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05, 0xca, 0x42, 0x52,
+  0x44, 0x2d, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc0, 0xc1, 0x00, 0x78,
+  0x01, 0x09, 0x19, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xcb, 0x59,
+  0x6f, 0x73, 0x65, 0x6d, 0x69, 0x74, 0x65, 0x20, 0x56, 0x34, 0xc6, 0x50,
+  0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc4, 0x76, 0x31, 0x2e, 0x31, 0x85, 0x91,
+  0x34, 0x51, 0x95, 0x05, 0x89, 0x30, 0x1b, 0x8e, 0x25, 0xfa, 0xb2, 0x64,
+  0x29, 0x03, 0xc0, 0xce, 0x59, 0x6f, 0x73, 0x65, 0x6d, 0x69, 0x74, 0x65,
+  0x20, 0x56, 0x34, 0x20, 0x54, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0xeb

hw/arm/aspeed_ast2600_fby4.c new file +21 -0
+};
+unsigned int fru_yv4_sentineldome_board_bin_len = 144;
+
+/*
+./frugen -s board.mfg="Wiwynn" \
+        --set board.pname="Sentinel Dome" \
+        --set text:board.pn="BRD-PN-345" \
+        --board-date "10/1/2017 12:58:00" \
+        --set board.serial="123456" \
+        --set product.pname="Yosemite V4" \
+        --set product.mfg="Wiwynn" \
+        --set product.ver="v1.1" \
+        --set product.serial="123456" \
+        --set product.atag="PLACEHOLDER" \
+        --set text:product.pn="PN-345" \
+        fru-yv4-sentineldome-chassis.bin
+*/
+/* EM Config: yosemite4_sentineldome_chassis.json */
+/* Yosemite 4 Sentinel Dome Chassis FRU */
+unsigned char fru_yv4_sentineldome_chassis_bin[] = {
+  0x01, 0x00, 0x00, 0x01, 0x07, 0x00, 0x00, 0xf7, 0x01, 0x06, 0x19, 

0xce,
+  0xc2, 0xa8, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xcd, 0x53, 0x65,
+  0x6e, 0x74, 0x69, 0x6e, 0x65, 0x6c, 0x20, 0x44, 0x6f, 0x6d, 0x65, 0x85,
+  0x91, 0x34, 0x51, 0x95, 0x05, 0xca, 0x42, 0x52, 0x44, 0x2d, 0x50, 0x4e,
+  0x2d, 0x33, 0x34, 0x35, 0xc0, 0xc1, 0x00, 0xb6, 0x01, 0x07, 0x19, 0xc6,
+  0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xcb, 0x59, 0x6f, 0x73, 0x65, 0x6d,
+  0x69, 0x74, 0x65, 0x20, 0x56, 0x34, 0xc6, 0x50, 0x4e, 0x2d, 0x33, 0x34,
+  0x35, 0xc4, 0x76, 0x31, 0x2e, 0x31, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05,
+  0x89, 0x30, 0x1b, 0x8e, 0x25, 0xfa, 0xb2, 0x64, 0x29, 0x03, 0xc0, 0xc1,
+  0x00, 0x00, 0x00, 0x59

hw/arm/aspeed_ast2600_fby4.c new file +21 -0
+};
+unsigned int fru_yv4_sentineldome_chassis_bin_len = 112;
+
+/*
+./frugen -s board.mfg="Wiwynn" \
+      --set board.pname="Management Board wBMC" \
+      --set text:board.pn="BRD-PN-345" \
+      --board-date "10/1/2017 12:58:00" \
+      --set board.serial="123456" \
+      --set product.pname="Yosemite V4" \
+      --set product.mfg="Wiwynn" \
+      --set product.ver="v1.1" \
+      --set product.serial="123456" \
+      --set product.atag="PLACEHOLDER" \
+      --set text:product.pn="PN-345" \
+      fru-yv4-eclosure.bin
+*/
+/* EM Config: yosemite4_chassis.json, yosemite4.json */
+/* Yosemite 4 Sentinel Dome Enclosure FRU */
+unsigned char fru_yv4_eclosure_bin[] = {
+  0x01, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0xf6, 0x01, 0x07, 0x19, 

0xce,
+  0xc2, 0xa8, 0xc6, 0x57, 0x69, 0x77, 0x79, 0x6e, 0x6e, 0xd5, 0x4d, 0x61,
+  0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x42, 0x6f, 0x61,
+  0x72, 0x64, 0x20, 0x77, 0x42, 0x4d, 0x43, 0x85, 0x91, 0x34, 0x51, 0x95,
+  0x05, 0xca, 0x42, 0x52, 0x44, 0x2d, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35,
+  0xc0, 0xc1, 0x00, 0x26, 0x01, 0x07, 0x19, 0xc6, 0x57, 0x69, 0x77, 0x79,
+  0x6e, 0x6e, 0xcb, 0x59, 0x6f, 0x73, 0x65, 0x6d, 0x69, 0x74, 0x65, 0x20,
+  0x56, 0x34, 0xc6, 0x50, 0x4e, 0x2d, 0x33, 0x34, 0x35, 0xc4, 0x76, 0x31,
+  0x2e, 0x31, 0x85, 0x91, 0x34, 0x51, 0x95, 0x05, 0x89, 0x30, 0x1b, 0x8e,
+  0x25, 0xfa, 0xb2, 0x64, 0x29, 0x03, 0xc0, 0xc1, 0x00, 0x00, 0x00, 0x59

hw/arm/aspeed_ast2600_fby4.c new file +6 -0
+};
+unsigned int fru_yv4_eclosure_bin_len = 120;
+
+/* END OF EEPROM CONTENTS */
+
+static void fby4_i2c_init_fanboard(I2CSlave *fan_mux, size_t 

eepromSize)

hw/arm/aspeed_ast2600_fby4.c

Quoted 2 lines
hw/arm/aspeed_ast2600_fby4.c new file +2 -0
+{
+

extra white line

Quoted 8 lines

+    /* 2 fan boards */
+    for (int i = 0; i <= 1; i++) {
+        /* downstream bus */
+        I2CBus *bus = pca954x_i2c_get_bus(fan_mux, i);
+
+        /* ti,adc128d818 @ 0x1f    (adc) */
+        /* the driver will throw away the last 4 bits, set them 0 */ +        uint16_t adc_values1[8] = {

I would define these arrays as read only data.

Quoted 6 lines

+            0b011110000000, 0b010100010000, +            0b001000110000, 0b100000100000, +            0b011110000000, 0b010100010000, +            0b001000110000, 0b100000100000}; +        adc128d818_init_with_values(bus,
+                              0x1f, adc_values1, 8);

This could be on one line.

Quoted 4 lines

+
+        /* maxim,max31790 @ 0x20   (pwm) */ +        i2c_slave_create_simple(bus,
+                              TYPE_MAX31790, 0x20);

same here.

Quoted 34 lines

+
+        /*
+         * ti,tca6424 @ 0x22       (gpio)
+         * linux handles tca6424 with PCA953X_TYPE, same as pca9535

+         * { "pca9535", 16 | PCA953X_TYPE | PCA_INT, },
+         * { "tca6424", 24 | PCA953X_TYPE | PCA_INT, },

+         * so we _could_ be fine here unless more than 16 gpios are used
+         */
+        i2c_slave_create_simple(bus,
+                              TYPE_PCA9535, 0x22);
+        /*
+         * NOTE: above works and could use for gpio presence:
+         * $ gpioget gpiochip2 2
+         * 1
+         */

hw/arm/aspeed_ast2600_fby4.c new file +18 -0
+
+        /* maxim,max31790 @ 0x2f   (pwm) */
+        i2c_slave_create_simple(bus,
+                              TYPE_MAX31790, 0x2f);
+
+        /* maxim,max11615 @ 0x33   (adc) */
+        uint16_t adc_values[8] = {
+            0b011110000010, 0b010100011000,
+            0b001000110100, 0b100000101001,
+            0b011110000010, 0b010100011000,
+            0b001000110100, 0b100000101001};
+        max11615_init_with_values(bus,
+                              0x33, adc_values, 8);
+> +        at24c_eeprom_init_rom(
+            bus, 0x52, eepromSize,
+            fru_yv4_fanboard_bin,
+            fru_yv4_fanboard_bin_len);
+

hw/arm/aspeed_ast2600_fby4.c line 219

Quoted 10 lines
hw/arm/aspeed_ast2600_fby4.c new file +10 -0
+        /* LED blink driver / gpio expander */
+        /* nxp,pca9552 @ 0x61   (gpio) */
+        i2c_slave_create_simple(bus,
+                              TYPE_PCA9552, 0x61);
+    }
+}
+
+static void fby4_i2c_init_blade_chassis(I2CBus *bus, size_t eepromSize)
+{
+

Extra white line.

Quoted 3 lines

+    /* Sentinel Dome Board EEPROMS */
+    const uint8_t board_addr = 0x54;
+    const uint8_t chassis_addr = 0x55;

These variables look unnecessary.

Quoted 10 lines

+
+    /* Board */
+    at24c_eeprom_init_rom(bus, board_addr, eepromSize, +        fru_yv4_sentineldome_board_bin, fru_yv4_sentineldome_board_bin_len);
+
+    /* Chassis */
+   at24c_eeprom_init_rom(bus, chassis_addr, eepromSize, +       fru_yv4_sentineldome_chassis_bin, fru_yv4_sentineldome_chassis_bin_len);

hw/arm/aspeed_ast2600_fby4.c line 236

Quoted 6 lines
hw/arm/aspeed_ast2600_fby4.c new file +6 -0
+}
+
+static void fby4_i2c_init_multiple_blade_chassis(I2CBus **i2c,
+    size_t eepromSize)
+{
+

Extra white line.

Quoted 30 lines

+    /* there is 8 blade chassis, but we only emulate 2 for performance reason */
+    for (int bus = 1; bus <= (8 / 4); bus++) {

hw/arm/aspeed_ast2600_fby4.c new file +26 -0
+
+        fby4_i2c_init_blade_chassis(i2c[bus], eepromSize);
+    }
+}
+
+static void fby4_i2c_init(AspeedMachineState *bmc)
+{
+    AspeedSoCState *soc = bmc->soc;
+    I2CBus *i2c[16];
+
+    for (int i = 0; i < 16; i++) {
+        i2c[i] = aspeed_i2c_get_bus(&soc->i2c, i);
+    }
+
+    const size_t eepromSize = 128 * KiB;
+
+    const uint8_t enclosure_addr = 0x51;
+
+    /* Enclosure (EM Config: yosemite4_chassis.json, yosemite4.json) */
+    at24c_eeprom_init_rom(i2c[1], enclosure_addr, eepromSize,
+        fru_yv4_eclosure_bin, fru_yv4_eclosure_bin_len);
+
+    fby4_i2c_init_multiple_blade_chassis(i2c, eepromSize);
+
+    /* Yv4 fanboard connection */
+    I2CSlave *fan_mux = i2c_slave_create_simple(i2c[14], 

TYPE_PCA9546, 0x74);

hw/arm/aspeed_ast2600_fby4.c line 272

Quoted 8 lines
hw/arm/aspeed_ast2600_fby4.c new file +8 -0
+
+    fby4_i2c_init_fanboard(fan_mux, eepromSize);
+}
+
+static void fby4_reset(MachineState *state, ResetType type)
+{
+    qemu_devices_reset(type);
+}

not needed

Quoted 30 lines

+static void aspeed_machine_fby4_class_init(ObjectClass *oc, const void *data)

hw/arm/aspeed_ast2600_fby4.c new file +23 -0
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+    AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
+
+    mc->desc       = "Facebook fby4 BMC (Cortex-A7)";
+    mc->reset      = fby4_reset;
+    amc->fmc_model = "mx66l1g45g";
+    amc->num_cs    = 2;
+    amc->macs_mask = ASPEED_MAC3_ON;
+    amc->i2c_init  = fby4_i2c_init;
+    mc->default_ram_size = FBY4_BMC_RAM_SIZE;
+    aspeed_machine_class_init_cpus_defaults(mc);
+}> +
+static const TypeInfo aspeed_ast2600_fby4_types[] = {
+    {
+        .name          = MACHINE_TYPE_NAME("fby4-bmc"),
+        .parent        = MACHINE_TYPE_NAME("ast2600-evb"),
+        .class_init    = aspeed_machine_fby4_class_init,
+        .interfaces    = arm_machine_interfaces,
+    }
+};
+
+DEFINE_TYPES(aspeed_ast2600_fby4_types)
hw/arm/meson.build +0 -0
index 84b8ec5fb5..ccbc23e549 100644

hw/arm/meson.build arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( · line 66

Quoted 7 lines
hw/arm/meson.build +1 -0
@@ -60,6 +60,7 @@ arm_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_qcom-dc-scm-v1.c',

Thanks,

C.

#7 lore raw
In reply to Alexander Hansen

Cc'ing the aspeed maintainers as this is a new aspeed board.

Quoted 32 lines · Alexander Hansen

Add initial and incomplete support for yosemite v4 BMC-side emulation.

As part of this effort 3 new sensor ICs are added.

Alexander Hansen (4):
hw/sensor: MAX31790 support
hw/sensor: support MAX11615
hw/sensor: support Texas Instruments ADC128D818
ast2600: yosemite4 initial support

 hw/arm/Kconfig                 |   3 +
 hw/arm/aspeed_ast2600_fby4.c   | 298 ++++++++++++++++++++
 hw/arm/meson.build             |   1 +
 hw/sensor/Kconfig              |  12 +
 hw/sensor/adc128d818.c         | 414 +++++++++++++++++++++++++++
 hw/sensor/max11615.c           | 200 +++++++++++++
 hw/sensor/max31790.c           | 497 +++++++++++++++++++++++++++++++++
 hw/sensor/meson.build          |   3 +
 hw/sensor/trace-events         |  24 ++
 include/hw/sensor/adc128d818.h |  20 ++
 include/hw/sensor/max11615.h   |  20 ++
 include/hw/sensor/max31790.h   |   7 +
 12 files changed, 1499 insertions(+)
 create mode 100644 hw/arm/aspeed_ast2600_fby4.c
 create mode 100644 hw/sensor/adc128d818.c
 create mode 100644 hw/sensor/max11615.c
 create mode 100644 hw/sensor/max31790.c
 create mode 100644 include/hw/sensor/adc128d818.h
 create mode 100644 include/hw/sensor/max11615.h
 create mode 100644 include/hw/sensor/max31790.h
Quoted 2 lines

--
2.54.0

thanks
-- PMM