[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/3] hw/arm/aspeed: g220a: Add host-power device
From: |
Jian Zhang |
Subject: |
[PATCH 3/3] hw/arm/aspeed: g220a: Add host-power device |
Date: |
Tue, 20 Sep 2022 01:21:12 +0800 |
Add power-button/power-good gpio connect between g220a BMC machind(soc
gpio) and host.
Tested:
In qemu, use g220a image
~# ipmitool power status
Chassis Power is off
~# ipmitool power on
Chassis Power Control: Up/On
~# ipmitool power status
Chassis Power is on
~# ipmitool power off
Chassis Power Control: Down/Off
~# ipmitool power status
Chassis Power is off
Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com>
---
hw/arm/aspeed.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 952fa11ca2..80a98b8d74 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -28,6 +28,7 @@
#include "hw/qdev-clock.h"
#include "sysemu/sysemu.h"
#include "hw/arm/fby35.h"
+#include "hw/misc/host_power.h"
static struct arm_boot_info aspeed_board_binfo = {
.board_id = -1, /* device-tree-only board */
@@ -723,6 +724,24 @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc)
};
smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 4), 0x57,
eeprom_buf);
+
+ /* Add a host-power device */
+ HostPowerState *power = host_power_create_simple(OBJECT(bmc));
+
+ /*
+ * connect the power button(in) to soc(out)
+ * the power button in g220a is 215
+ */
+ qdev_connect_gpio_out(DEVICE(&bmc->soc.gpio), 215,
+ qdev_get_gpio_in_named(DEVICE(power),
+ "power-button", 0));
+
+ /*
+ * connect the power good signal(out) to soc(in)
+ * the power good in g220a is 209
+ */
+ qdev_connect_gpio_out_named(DEVICE(power), "power-good", 0,
+ qdev_get_gpio_in(DEVICE(&bmc->soc.gpio), 209));
}
static void aspeed_eeprom_init(I2CBus *bus, uint8_t addr, uint32_t rsize)
--
2.25.1