diff options
author | ThuBaNguyen <thu@os.amperecomputing.com> | 2021-07-08 10:20:43 +0300 |
---|---|---|
committer | Thang Q. Nguyen <thang@os.amperecomputing.com> | 2021-08-04 11:03:33 +0300 |
commit | fb214784edbc1da7ba155a1cddf7b3f6d0bbfb66 (patch) | |
tree | 6f5f53085fdf7b83d043926b2bbefc4a50ac33a3 | |
parent | 2f952142e9ed8b436a0e702a0f46ac88842dd51e (diff) | |
download | openbmc-fb214784edbc1da7ba155a1cddf7b3f6d0bbfb66.tar.xz |
meta-ampere: power control: restructure source code
ampere-hostctrl package includes the generic codes and the platform
specific codes. The generic sources are applied for all of the Ampere
platforms, they are the service files and the scripts to setting the
GPIO pins. The platform specific sources are the GPIO pin config file
and the gpio monitor config files.
This commit moves the platform specific files to the platform code.
Tested:
1. Do the power control actions use ipmitool, BMC web and Redfish.
2. Make sure the server states are changed as expected.
Signed-off-by: ThuBaNguyen <thu@os.amperecomputing.com>
Change-Id: Ic0e261109f7a5dfaf38c883bff0afedab763a0b6
10 files changed, 88 insertions, 27 deletions
diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb index 4a44d1b2f..cfefa8d94 100644 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb +++ b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb @@ -7,41 +7,21 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7ca inherit systemd inherit obmc-phosphor-systemd -# For now, monitoring shutdown_ack and reboot_ack are the only usecases -OBMC_HOST_MONITOR_INSTANCES = "shutdown_ack reboot_ack" -SYSTEMD_ENVIRONMENT_FILE_${PN} +="obmc/gpio/shutdown_ack obmc/gpio/reboot_ack" - S = "${WORKDIR}" SRC_URI = " \ - file://ampere_power_util.sh \ file://ampere-host-force-reset@.service \ - file://ampere-host-shutdown-ack@.service \ " -DEPENDS = "systemd virtual/obmc-gpio-monitor" -RDEPENDS_${PN} = "bash virtual/obmc-gpio-monitor" - SYSTEMD_PACKAGES = "${PN}" SYSTEMD_SERVICE_${PN} = " \ ampere-host-force-reset@.service \ - ampere-host-shutdown-ack@.service \ " -# overwrite force reboot +# append force reboot HOST_WARM_REBOOT_FORCE_TGT = "ampere-host-force-reset@.service" +HOST_WARM_REBOOT_FORCE_INSTMPL = "ampere-host-force-reset@{0}.service" HOST_WARM_REBOOT_FORCE_TGTFMT = "obmc-host-force-warm-reboot@{0}.target" -HOST_WARM_REBOOT_FORCE_TARGET_FMT = "../${HOST_WARM_REBOOT_FORCE_TGT}:${HOST_WARM_REBOOT_FORCE_TGTFMT}.requires/${HOST_WARM_REBOOT_FORCE_TGT}" +HOST_WARM_REBOOT_FORCE_TARGET_FMT = "../${HOST_WARM_REBOOT_FORCE_TGT}:${HOST_WARM_REBOOT_FORCE_TGTFMT}.requires/${HOST_WARM_REBOOT_FORCE_INSTMPL}" SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'HOST_WARM_REBOOT_FORCE_TARGET_FMT', 'OBMC_HOST_INSTANCES')}" -TMPL = "phosphor-gpio-monitor@.service" -INSTFMT = "phosphor-gpio-monitor@{0}.service" -TGT = "multi-user.target" -FMT = "../${TMPL}:${TGT}.requires/${INSTFMT}" -SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT', 'OBMC_HOST_MONITOR_INSTANCES')}" - -do_install() { - install -d ${D}/usr/sbin - install -m 0755 ${WORKDIR}/ampere_power_util.sh ${D}/${sbindir}/ampere_power_util.sh -} - diff --git a/meta-ampere/meta-jade/conf/machine/mtjade.conf b/meta-ampere/meta-jade/conf/machine/mtjade.conf index e749af6de..558a6f404 100644 --- a/meta-ampere/meta-jade/conf/machine/mtjade.conf +++ b/meta-ampere/meta-jade/conf/machine/mtjade.conf @@ -29,6 +29,7 @@ OBMC_MACHINE_FEATURES += "\ VOLATILE_LOG_DIR = "no" OBMC_IMAGE_EXTRA_INSTALL_append = "\ + mtjade-utils \ ampere-usbnet \ ampere-flash-utils \ ampere-mac-update \ diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb new file mode 100644 index 000000000..184d643f6 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb @@ -0,0 +1,18 @@ +SUMMARY = "Ampere Platform Environment Definitions" +DESCRIPTION = "Ampere Platform Environment Definitions" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +SRC_URI = " \ + file://gpio-defs.sh \ + file://ampere_power_util.sh \ + " + +RDEPENDS_${PN} = "bash" + +do_install() { + install -d ${D}/usr/sbin + install -m 0755 ${WORKDIR}/gpio-defs.sh ${D}/${sbindir}/ + install -m 0755 ${WORKDIR}/ampere_power_util.sh ${D}/${sbindir}/ +}
\ No newline at end of file diff --git a/meta-ampere/meta-common/recipes-ac01/host/files/ampere_power_util.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_power_util.sh index aa742104f..4ad07a68f 100644 --- a/meta-ampere/meta-common/recipes-ac01/host/files/ampere_power_util.sh +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_power_util.sh @@ -1,4 +1,7 @@ #!/bin/bash +#ampere_platform_config.sh is platform configuration file +source /usr/sbin/gpio-defs.sh + # Usage of this utility function usage() { echo "usage: power-util mb [on|status|cycle|reset|graceful_reset|force_reset|soft_off]"; @@ -43,9 +46,9 @@ graceful_shutdown() { soft_off() { # Trigger shutdown_req touch /run/openbmc/host@0-softpoweroff - gpioset -l 0 49=1 + gpioset -l $GPIO_CHIP0_IDX $S0_SHD_REQ_L=1 sleep 1s - gpioset -l 0 49=0 + gpioset -l $GPIO_CHIP0_IDX $S0_SHD_REQ_L=0 # Wait for shutdown_ack from the host in 30 seconds cnt=30 @@ -89,9 +92,9 @@ force_reset() { fi fi echo "Triggering sysreset pin" - gpioset -l 0 91=1 + gpioset -l $GPIO_CHIP0_IDX $S0_SYSRESET_L=1 sleep 1 - gpioset -l 0 91=0 + gpioset -l $GPIO_CHIP0_IDX $S0_SYSRESET_L=0 } if [ $# -lt 2 ]; then diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh new file mode 100644 index 000000000..fce59d581 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh @@ -0,0 +1,32 @@ +# Index of GPIO device in gpioget/gpioset +GPIO_CHIP0_IDX=0 +GPIO_CHIP1_IDX=1 + +# Base of GPIO chip in /sys/class/gpio +GPIO_CHIP0_BASE=792 +GPIO_CHIP1_BASE=780 + +### Power control configuration +# Power control gpios +S0_SHD_REQ_L=49 +S0_SHD_ACK_L=50 +S0_REBOOT_ACK_L=75 +S0_SYSRESET_L=91 + + +### Table 1: GPIO Assignments +S0_CPU_FW_BOOT_OK=48 +CPU_BMC_OVERTEMP_L=51 +CPU_BMC_HIGHTEMP_L=72 +CPU_FAULT_ALERT=73 +S1_CPU_FW_BOOT_OK=202 + +### Table 2: Alert and Additional Miscellaneous Signals +S0_SCP_AUTH_FAILURE=74 +S1_SCP_AUTH_FAILURE=205 +BMC_OK=228 +SLAVE_PRESENT_L=230 + +### Common GPIOs +SYS_PSON_L=42 +BMC_READY=229 diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling.bb b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling.bb new file mode 100644 index 000000000..4358b1242 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling.bb @@ -0,0 +1,23 @@ +SUMMARY = "Ampere Computing LLC Host Gpio Handling" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +inherit obmc-phosphor-systemd + +DEPENDS += "virtual/obmc-gpio-monitor" +RDEPENDS_${PN} += "virtual/obmc-gpio-monitor" + +OBMC_HOST_ACK_MONITOR_INSTANCES = "reboot_ack shutdown_ack" + +SYSTEMD_ENVIRONMENT_FILE_${PN} +="obmc/gpio/reboot_ack \ + obmc/gpio/shutdown_ack \ + " + +TMPL = "phosphor-gpio-monitor@.service" +INSTFMT = "phosphor-gpio-monitor@{0}.service" +TGT = "multi-user.target" +FMT = "../${TMPL}:${TGT}.requires/${INSTFMT}" + +SYSTEMD_SERVICE_${PN} += "ampere-host-shutdown-ack@.service" +SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT', 'OBMC_HOST_ACK_MONITOR_INSTANCES')}" diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-shutdown-ack@.service b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/ampere-host-shutdown-ack@.service index 6588191aa..6588191aa 100644 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-shutdown-ack@.service +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/ampere-host-shutdown-ack@.service diff --git a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/reboot_ack b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/reboot_ack index a8ad98ee7..a8ad98ee7 100644 --- a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/reboot_ack +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/reboot_ack diff --git a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/shutdown_ack b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/shutdown_ack index 18cc87246..18cc87246 100644 --- a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/shutdown_ack +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/shutdown_ack diff --git a/meta-ampere/meta-jade/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend b/meta-ampere/meta-jade/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend index 3af702292..ca86a4a21 100644 --- a/meta-ampere/meta-jade/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend +++ b/meta-ampere/meta-jade/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend @@ -1,2 +1,6 @@ RDEPENDS_${PN}-extras_append_mtjade = " webui-vue phosphor-image-signing phosphor-virtual-sensor" RDEPENDS_${PN}-inventory_append_mtjade = " fault-monitor id-button psu-hotswap-reset" + +RDEPENDS_${PN}-inventory_append_mtjade = " \ + host-gpio-handling \ + " |