summaryrefslogtreecommitdiff
path: root/meta-facebook
diff options
context:
space:
mode:
authorPotin Lai <potin.lai@quantatw.com>2023-02-23 14:12:32 +0300
committerPatrick Williams <patrick@stwcx.xyz>2023-02-24 15:37:25 +0300
commitd2e7f202365be8f9a181458f8e670eaab264c636 (patch)
tree1045c19287b48c3008509d344659d610ae3b221c /meta-facebook
parentec3d3aecf5364c1776641f90646c0b1815dc55dd (diff)
downloadopenbmc-d2e7f202365be8f9a181458f8e670eaab264c636.tar.xz
meta-bletchley: use gpiomon instead of polling gpio value
Remove gpio polling of switch detect pin in power-ctrl and motor-init. Use gpiomon and timeout commands instead to improve performance and timing issue. Signed-off-by: Potin Lai <potin.lai@quantatw.com> Change-Id: I9e1eb26b070a57f424b341890733dc63c170bf79
Diffstat (limited to 'meta-facebook')
-rwxr-xr-xmeta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-init13
-rwxr-xr-xmeta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl27
-rw-r--r--meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/files/bletchley-common-functions14
3 files changed, 22 insertions, 32 deletions
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-init b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-init
index 87b3a17ee2..7c250f4cf2 100755
--- a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-init
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-init
@@ -90,25 +90,18 @@ DETECT_PIN1="SLED${SLED_NUM}_MS_DETECT1"
INIT_POS=$(get_gpio "$DETECT_PIN1")
if [ "$INIT_POS" -eq 1 ];then
- time_count=0
echo "Making motor back to initial position..."
motor-ctrl "$SLED" r >/dev/null
- while [ "$INIT_POS" -eq 1 ] ;do
- INIT_POS=$(get_gpio "$DETECT_PIN1")
- sleep 0.1
- time_count=$(( time_count + 1 ))
- if [ $time_count -gt $CALIBRATE_TIMEOUT ];then
- echo "Error: Step motor run over 1 cycle but switch never triggered"
- break
- fi
- done
+ wait_gpio_falling "$DETECT_PIN1" "$CALIBRATE_TIMEOUT"
motor-ctrl "$SLED" s >/dev/null
fi
+INIT_POS=$(get_gpio "$DETECT_PIN1")
if [ "$INIT_POS" -eq 0 ];then
echo "Motor calibrated to initial position."
exit 0
else
+ echo "Error: Step motor run over 1 cycle but switch never triggered"
echo "Find motor initial position failed"
exit 1
fi
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl
index 8de9e5afa7..232b6f3039 100755
--- a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl
@@ -12,7 +12,7 @@ source /usr/libexec/bletchley-common-functions
DELAY_POWER_ON="0.5"
DELAY_POWER_OFF="5"
DELAY_POWER_RECOVERY_MODE="10"
-POWER_BTN_TIMEOUT_CNT=60
+POWER_BTN_TIMEOUT_SEC=10
REV_EVT="EVT"
REV_DVT="DVT"
@@ -98,23 +98,6 @@ function get_board_rev()
return 0
}
-#Switch pull low while it be touched
-function wait_for_switch()
-{
- TARGET_PIN=$1
- TARGET_SWITCH=1
- TIME_CNT=0
- while [ "$TARGET_SWITCH" -eq 1 ] ;do
- TARGET_SWITCH=$(get_gpio "$TARGET_PIN")
- sleep 0.1
- TIME_CNT=$(( TIME_CNT +1))
- if [ $TIME_CNT -gt $POWER_BTN_TIMEOUT_CNT ];then
- echo "Error: Too long to get target switch, force exit" >&2
- break
- fi
- done
-}
-
function trigger_power_button()
{
local sled_num=$1
@@ -127,7 +110,7 @@ function trigger_power_button()
echo "Motor go forward to press Power key"
motor-ctrl "sled${sled_num}" f >/dev/null
- wait_for_switch "${GPIO_DETECT_PIN0}"
+ wait_gpio_falling "${GPIO_DETECT_PIN0}" "$POWER_BTN_TIMEOUT_SEC"
motor-ctrl "sled${sled_num}" s >/dev/null
if [ "$(get_gpio "$GPIO_DETECT_PIN0")" -eq 0 ];then
@@ -139,7 +122,7 @@ function trigger_power_button()
fi
motor-ctrl "sled${sled_num}" r >/dev/null
- wait_for_switch "${GPIO_DETECT_PIN1}"
+ wait_gpio_falling "${GPIO_DETECT_PIN1}" "$POWER_BTN_TIMEOUT_SEC"
motor-ctrl "sled${sled_num}" s >/dev/null
if [ "$(get_gpio "$GPIO_DETECT_PIN1")" -eq 0 ];then
echo "Motor reverse to initial position successful"
@@ -159,7 +142,7 @@ function release_power_button()
fi
motor-ctrl "sled${sled_num}" r >/dev/null
- wait_for_switch "${GPIO_DETECT_PIN1}"
+ wait_gpio_falling "${GPIO_DETECT_PIN1}" "$POWER_BTN_TIMEOUT_SEC"
motor-ctrl "sled${sled_num}" s >/dev/null
if [ "$(get_gpio "$GPIO_DETECT_PIN1")" -eq 0 ];then
echo "Motor reverse to initial position successful"
@@ -178,7 +161,7 @@ function press_power_button()
echo "Motor go forward to press Power button"
motor-ctrl "sled${sled_num}" f >/dev/null
- wait_for_switch "${GPIO_DETECT_PIN0}"
+ wait_gpio_falling "${GPIO_DETECT_PIN0}" "$POWER_BTN_TIMEOUT_SEC"
motor-ctrl "sled${sled_num}" s >/dev/null
if [ "$(get_gpio "$GPIO_DETECT_PIN0")" -eq 0 ];then
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/files/bletchley-common-functions b/meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/files/bletchley-common-functions
index 68d0c62f29..49bca93f80 100644
--- a/meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/files/bletchley-common-functions
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/plat-tools/files/bletchley-common-functions
@@ -38,6 +38,20 @@ set_gpio()
return 0
}
+wait_gpio_falling()
+{
+ local NET_NAME=$1
+ local TIMEOUT_SEC=$2
+
+ mapfile -t -d " " GPIO_INFO < <(gpiofind "$NET_NAME")
+ if [ "${#GPIO_INFO[@]}" -ne 2 ]; then
+ echo "wait_gpio_falling: can not find gpio, $NET_NAME"
+ return 1
+ fi
+
+ timeout "$TIMEOUT_SEC" gpiomon --falling-edge --num-events=1 "${GPIO_INFO[0]}" "${GPIO_INFO[1]%$'\n'}"
+}
+
set_fan()
{
FAN_ID=$1