From 62feab3abe0e748ad045ab1e43f2d7ee9234961d Mon Sep 17 00:00:00 2001 From: Chanh Nguyen Date: Thu, 25 Feb 2021 22:25:53 +0700 Subject: meta-ampere: Support UID button and LED The UID button is used to provide visual identification of the system when pushed. Pressing the UID button toggles the UID LED. The same action can be done via Redfish (by patching IndicatorLED from redfish/v1/Systems/system) or the IPMI chassis identify command. Tested: 1. Press the UID button to toggles the UID on/off 2. Turn on the UID LED via ipmi command $ ipmitool chassis identify 3. Turn Lit/Blinking/Off UID LED via Redfish then check the IndicatorLED values $ curl -X PATCH --user root:0penBmc -H "Content-Type: application/json" \ -H "If-Match: *" --insecure https://BMC_IP/redfish/v1/Systems/system \ -d '{"IndicatorLED": "Lit/Blinking/Off"}' $curl -X GET --user root:0penBmc -H "Content-Type: application/json" \ --insecure https://BMC_IP/redfish/v1/Systems/system The IndicatorLED is "Lit/Blinking/Off" Signed-off-by: Hieu Huynh Signed-off-by: Chanh Nguyen Change-Id: I58eeae7ac22a9d4ddd4acdfbd167095bdc74072c --- .../meta-jade/recipes-phosphor/gpio/id-button.bb | 29 ++++++++++++++ .../gpio/id-button/id-button-pressed.service | 10 +++++ .../gpio/id-button/obmc/gpio/id_button | 5 +++ .../gpio/id-button/toggle_identify_led.sh | 45 ++++++++++++++++++++++ .../leds/mtjade-led-manager-config/led.yaml | 12 ++++++ .../packagegroups/packagegroup-obmc-apps.bbappend | 2 +- 6 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 meta-ampere/meta-jade/recipes-phosphor/gpio/id-button.bb create mode 100644 meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/id-button-pressed.service create mode 100644 meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/obmc/gpio/id_button create mode 100755 meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/toggle_identify_led.sh (limited to 'meta-ampere') diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button.bb b/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button.bb new file mode 100644 index 0000000000..c19cdee18d --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button.bb @@ -0,0 +1,29 @@ +SUMMARY = "MTJade ID Button pressed application" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +inherit obmc-phosphor-systemd + +DEPENDS += "virtual/obmc-gpio-monitor" +RDEPENDS_${PN} += "virtual/obmc-gpio-monitor" + +SRC_URI += "file://toggle_identify_led.sh" + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${WORKDIR}/toggle_identify_led.sh \ + ${D}${bindir}/toggle_identify_led.sh +} + +SYSTEMD_ENVIRONMENT_FILE_${PN} +="obmc/gpio/id_button" + +ID_BUTTON_SERVICE = "id_button" + +TMPL = "phosphor-gpio-monitor@.service" +INSTFMT = "phosphor-gpio-monitor@{0}.service" +TGT = "multi-user.target" +FMT = "../${TMPL}:${TGT}.requires/${INSTFMT}" + +SYSTEMD_SERVICE_${PN} += "id-button-pressed.service" +SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT', 'ID_BUTTON_SERVICE')}" diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/id-button-pressed.service b/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/id-button-pressed.service new file mode 100644 index 0000000000..0a97ed70c7 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/id-button-pressed.service @@ -0,0 +1,10 @@ +[Unit] +Description=ID Button Pressed Service +Wants=mapper-wait@-xyz-openbmc_project-led-groups.service +After=mapper-wait@-xyz-openbmc_project-led-groups.service +StartLimitIntervalSec=0 + +[Service] +Type=oneshot +ExecStart=/usr/bin/toggle_identify_led.sh +SyslogIdentifier=id-button diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/obmc/gpio/id_button b/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/obmc/gpio/id_button new file mode 100644 index 0000000000..70e2b585b2 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/obmc/gpio/id_button @@ -0,0 +1,5 @@ +DEVPATH=/dev/input/by-path/platform-gpio-keys-event +KEY=133 +POLARITY=1 +TARGET=id-button-pressed.service +EXTRA_ARGS=--continue diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/toggle_identify_led.sh b/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/toggle_identify_led.sh new file mode 100755 index 0000000000..d62c84ae16 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/toggle_identify_led.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# +# Copyright (c) 2021 Ampere Computing LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Toggle the state of identify LED Group + +SERVICE="xyz.openbmc_project.LED.GroupManager" +INTERFACE="xyz.openbmc_project.Led.Group" +PROPERTY="Asserted" + +# Get enclosure_identify state +identify_object=$(busctl tree $SERVICE --list | grep -m 1 identify) +identify_state=$(busctl get-property $SERVICE $identify_object $INTERFACE $PROPERTY \ + | awk '{print $NF;}') + +# Get enclosure_identify_blink state +identify_blink_object=$(busctl tree $SERVICE --list | grep identify_blink) +identify_blink_state=$(busctl get-property $SERVICE $identify_blink_object $INTERFACE $PROPERTY \ + | awk '{print $NF;}') + +# Set state +if [[ "$identify_state" == "false" && "$identify_blink_state" == "false" ]]; then + # Turn on the UID LED + busctl set-property $SERVICE $identify_object $INTERFACE $PROPERTY b true +elif [[ "$identify_state" == "false" && "$identify_blink_state" == "true" ]]; then + # Turn off the UID LED when LED is blinking state + busctl set-property $SERVICE $identify_blink_object $INTERFACE $PROPERTY b false +elif [[ "$identify_state" == "true" && "$identify_blink_state" == "false" ]]; then + # Turn off the UID LED + busctl set-property $SERVICE $identify_object $INTERFACE $PROPERTY b false +else + echo "Invalid case! When identify_blink_state is true, the identify_state will set to false" +fi diff --git a/meta-ampere/meta-jade/recipes-phosphor/leds/mtjade-led-manager-config/led.yaml b/meta-ampere/meta-jade/recipes-phosphor/leds/mtjade-led-manager-config/led.yaml index ba21c5860d..3e321ed5c6 100644 --- a/meta-ampere/meta-jade/recipes-phosphor/leds/mtjade-led-manager-config/led.yaml +++ b/meta-ampere/meta-jade/recipes-phosphor/leds/mtjade-led-manager-config/led.yaml @@ -18,3 +18,15 @@ systemFault: DutyOn: 50 Period: 0 Priority: 'Blink' + +enclosure_identify: + identify: + Action: 'On' + DutyOn: 50 + Period: 1000 + +enclosure_identify_blink: + identify: + Action: 'Blink' + DutyOn: 50 + Period: 1000 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 c9538deb4d..980d9261de 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,2 @@ RDEPENDS_${PN}-extras_append_mtjade = " phosphor-webui phosphor-image-signing" -RDEPENDS_${PN}-inventory_append_mtjade = " fault-monitor" +RDEPENDS_${PN}-inventory_append_mtjade = " fault-monitor id-button" -- cgit v1.2.3