blob: 2f48a124030195786406eb0b4d86bdc1eb50f87e [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
16source /usr/share/gpio-host-pwr/lib.sh || exit
17
18if [[ "${1-}" == "warm" ]]; then
19 rst_txt='WARM' >&2
20 rst_gpio="$HOST_GPIO_WARM_RESET"
21else
22 rst_txt='COLD' >&2
23 rst_gpio="$HOST_GPIO_COLD_RESET"
24fi
25
26gpio_build_cache 10 "$rst_gpio" || exit
27
28# Do a quick push of the button if PGOOD
29echo "Issuing $rst_txt reset" >&2
30rc=0
31gpio_set_value "$rst_gpio" 1 || rc=$?
32sleep 0.1
33gpio_set_value "$rst_gpio" 0 || rc=$?
34
35# Make sure the watchdog is stopped while the host is in reset
36# and can't possibly restart it.
37host_pwr_stop_watchdog || true
38
39exit $rc