blob: d935a410cb11fa3fe3670e33e7c5b4db591d58ef [file] [log] [blame]
Tom Tung48ea66b2021-08-06 14:19:14 +08001#!/bin/bash
2# Copyright 2021 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
William A. Kennington IIIc17e6442023-06-02 16:29:54 -070016# shellcheck source=meta-google/recipes-google/gpio/gpio-ctrl/lib.sh
Tom Tung48ea66b2021-08-06 14:19:14 +080017source /usr/share/gpio-host-pwr/lib.sh || exit
18
19if [[ "${1-}" == "warm" ]]; then
20 rst_txt='WARM' >&2
21 rst_gpio="$HOST_GPIO_WARM_RESET"
22else
23 rst_txt='COLD' >&2
24 rst_gpio="$HOST_GPIO_COLD_RESET"
25fi
26
27gpio_build_cache 10 "$rst_gpio" || exit
28
29# Do a quick push of the button if PGOOD
30echo "Issuing $rst_txt reset" >&2
31rc=0
32gpio_set_value "$rst_gpio" 1 || rc=$?
33sleep 0.1
34gpio_set_value "$rst_gpio" 0 || rc=$?
35
36# Make sure the watchdog is stopped while the host is in reset
37# and can't possibly restart it.
38host_pwr_stop_watchdog || true
39
40exit $rc