Tom Tung | 48ea66b | 2021-08-06 14:19:14 +0800 | [diff] [blame] | 1 | #!/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 III | c17e644 | 2023-06-02 16:29:54 -0700 | [diff] [blame] | 16 | # shellcheck source=meta-google/recipes-google/gpio/gpio-ctrl/lib.sh |
Tom Tung | 48ea66b | 2021-08-06 14:19:14 +0800 | [diff] [blame] | 17 | source /usr/share/gpio-host-pwr/lib.sh || exit |
| 18 | |
| 19 | if [[ "${1-}" == "warm" ]]; then |
| 20 | rst_txt='WARM' >&2 |
| 21 | rst_gpio="$HOST_GPIO_WARM_RESET" |
| 22 | else |
| 23 | rst_txt='COLD' >&2 |
| 24 | rst_gpio="$HOST_GPIO_COLD_RESET" |
| 25 | fi |
| 26 | |
| 27 | gpio_build_cache 10 "$rst_gpio" || exit |
| 28 | |
| 29 | # Do a quick push of the button if PGOOD |
| 30 | echo "Issuing $rst_txt reset" >&2 |
| 31 | rc=0 |
| 32 | gpio_set_value "$rst_gpio" 1 || rc=$? |
| 33 | sleep 0.1 |
| 34 | gpio_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. |
| 38 | host_pwr_stop_watchdog || true |
| 39 | |
| 40 | exit $rc |