meta-facebook: ventura: Use fb-common-functions for GPIO reads The debugfs fallback used by smc-event-logger now lives in fb-common-functions as get_gpio_val_by_name(), so the ventura copy in plat-svc is redundant. Source the common helper instead and drop gpio_util along with its recipe entries. Change-Id: I3d5c9910ec32e96d772fd3bc39cb7bcf0a014bac Signed-off-by: Kyle Hsieh <Kyle.Hsieh@quantatw.com>
diff --git a/meta-facebook/meta-ventura/recipes-phosphor/gpio/phosphor-gpio-monitor/smc-event-logger b/meta-facebook/meta-ventura/recipes-phosphor/gpio/phosphor-gpio-monitor/smc-event-logger index 7c33612..2e42792 100644 --- a/meta-facebook/meta-ventura/recipes-phosphor/gpio/phosphor-gpio-monitor/smc-event-logger +++ b/meta-facebook/meta-ventura/recipes-phosphor/gpio/phosphor-gpio-monitor/smc-event-logger
@@ -12,8 +12,8 @@ gpio_name="$2" stash_file="/var/lib/phosphor-gpio-monitor/${gpio_name}.log_entry" -# shellcheck source=meta-facebook/meta-ventura/recipes-ventura/plat-svc/files/gpio_util -source "/usr/libexec/ventura/gpio_util" +# shellcheck source=meta-facebook/recipes-fb/obmc_functions/files/fb-common-functions +source /usr/libexec/fb-common-functions # For VT cooling systems, AALC-related signals should be ignored. if [[ "$gpio_name" == *RPU* || "$gpio_name" == *PUMP* ]] &&
diff --git a/meta-facebook/meta-ventura/recipes-ventura/plat-svc/files/gpio_util b/meta-facebook/meta-ventura/recipes-ventura/plat-svc/files/gpio_util deleted file mode 100644 index 13e1496..0000000 --- a/meta-facebook/meta-ventura/recipes-ventura/plat-svc/files/gpio_util +++ /dev/null
@@ -1,73 +0,0 @@ -#!/bin/bash - -# Get GPIO chip and line number by GPIO name -# Args: $1 = GPIO name -# Echo: "<chip> <line>" -get_gpio_by_name() { - local name="${1:0:31}" # match kernel's 31-char limit - gpioinfo 2>/dev/null | awk -v name="$name" ' - /^gpiochip/ {chip=$1} - /^[ \t]*line/ && $0 ~ name { - sub(/:$/, "", $2) - print chip, $2 - exit - } - ' -} - -# Get GPIO logic level (0/1) by GPIO name (first 31 chars match kernel limit) -# Args: $1 = GPIO name -get_gpio_val_by_name(){ - local name="${1:0:31}" - local chip line gpio_val - read -r chip line < <(get_gpio_by_name "$name") - - # primary: gpioget - if ! gpio_val="$(gpioget "$chip" "$line" 2>/dev/null)"; then - : # nop - # fallback: debugfs - if ! gpio_val=$(get_gpio_val_from_debugfs "$chip" "$line"); then - : # nop - fi - fi - [ -z "$gpio_val" ] && return 1 - printf '%s\n' "$gpio_val" -} - -# Get GPIO logic level (0/1) from /sys/kernel/debug/gpio by chip and line offset -# Args: $1 = chip number/name, $2 = line offset -get_gpio_val_from_debugfs() { - if [[ $chip =~ ^[0-9]+$ ]]; then - local chip="gpiochip$1" - else - local chip=$1 - fi - - local line=$2 - local gpio_base gpio_id gpio_val - - local want_name="$1" - [ -n "$want_name" ] || return 1 - [ -r /sys/kernel/debug/gpio ] || return 1 - - gpio_base=$(grep -w "$chip" /sys/kernel/debug/gpio | sed -n 's/.*GPIOs \([0-9]\+\)-.*/\1/p') - gpio_id=$(("$gpio_base" + "$line")) - gpio_val=$(awk -v gpio_id="$gpio_id" ' - $1 == "gpio-"gpio_id { - for (i = 1; i <= NF; i++) { - if ($i == "hi") { - print "1" - exit - } - else if ($i == "lo") { - print "0" - exit - } - } - print "unknown" - } - ' /sys/kernel/debug/gpio) - - [[ $gpio_val =~ ^[0-9]+$ ]] || return 1 - printf '%s\n' "$gpio_val" -}
diff --git a/meta-facebook/meta-ventura/recipes-ventura/plat-svc/plat-svc_0.1.bb b/meta-facebook/meta-ventura/recipes-ventura/plat-svc/plat-svc_0.1.bb index b4e43df..5cd5a24 100644 --- a/meta-facebook/meta-ventura/recipes-ventura/plat-svc/plat-svc_0.1.bb +++ b/meta-facebook/meta-ventura/recipes-ventura/plat-svc/plat-svc_0.1.bb
@@ -11,7 +11,6 @@ RDEPENDS:${PN} += "fb-common-functions" SRC_URI += " \ - file://gpio_util \ file://ventura-sys-init.service \ file://ventura-early-sys-init \ file://ventura-schematic-init \ @@ -32,7 +31,6 @@ do_install() { VENTURA_LIBEXECDIR="${D}${libexecdir}/ventura" install -d ${VENTURA_LIBEXECDIR} - install -m 0755 ${UNPACKDIR}/gpio_util ${VENTURA_LIBEXECDIR} install -m 0755 ${UNPACKDIR}/ventura-early-sys-init ${VENTURA_LIBEXECDIR} install -m 0755 ${UNPACKDIR}/ventura-schematic-init ${VENTURA_LIBEXECDIR} install -m 0755 ${UNPACKDIR}/ventura-fan-status-monitor ${D}${libexecdir}