Report issues by shell files with: git ls-files '*.sh' | xargs shellcheck --exclude=SC2162 Address the following: - SC1087: Use braces when expanding arrays - SC1091: Not following - SC2004: `$`/`${}` is unnecessary on arithmetic variables - SC2024: `sudo` doesn't affect redirects - SC2034: foo appears unused. Verify it or export it - SC2086: Double quote to prevent globbing and word splitting - SC2087: Quote `EOF` - SC2115: Use `"${var:?}"` to ensure this never expands to `/*` - SC2148: Add a shebang Addresses (at least partially) some POSIX/dash issues: - SC2113: `function` keyword is non-standard - SC3010: In POSIX sh, `[[` `]]` is undefined - SC3014: In POSIX sh, `==` in place of `=` is undefined - SC3020: In POSIX sh, `&>` is undefined - SC3046: In POSIX sh, `source` in place of `.` is undefined Does not address: - SC2162: `read` without `-r` will mangle backslashes - Any other POSIX/dash-specific issues Signed-off-by: Tim Crawford <tcrawford@system76.com>
115 lines
2.6 KiB
Bash
Executable File
115 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
if [ ! -e "$1" ]
|
|
then
|
|
echo "$0 [coreboot-collector output]"
|
|
exit 1
|
|
fi
|
|
|
|
cat <<"EOF"
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
#ifndef MAINBOARD_GPIO_H
|
|
#define MAINBOARD_GPIO_H
|
|
|
|
#include <soc/gpe.h>
|
|
#include <soc/gpio.h>
|
|
|
|
#ifndef __ACPI__
|
|
|
|
/* Pad configuration in ramstage. */
|
|
static const struct pad_config gpio_table[] = {
|
|
EOF
|
|
|
|
grep ^GP "$1" | \
|
|
cut -d ' ' -f1,3,4 | \
|
|
sort -V | \
|
|
while read line
|
|
do
|
|
parts=()
|
|
for part in $line
|
|
do
|
|
parts+=("$part")
|
|
done
|
|
parts[1]="$(printf '0x%08x' "$((parts[1] & 0xfffffffd))")"
|
|
parts[2]="$(printf '0x%04x' "$((parts[2] & 0x00003c00))")"
|
|
|
|
case "${parts[1]}" in
|
|
0x0???????)
|
|
reset="PWROK" # RSMRST?
|
|
;;
|
|
0x4???????)
|
|
reset="DEEP"
|
|
;;
|
|
0x8???????)
|
|
reset="PLTRST"
|
|
;;
|
|
*)
|
|
reset="TODO_${parts[1]}"
|
|
;;
|
|
esac
|
|
|
|
case "${parts[2]}" in
|
|
0x0000)
|
|
term="NONE"
|
|
;;
|
|
0x1000)
|
|
term="DN_20K"
|
|
;;
|
|
0x3000)
|
|
term="UP_20K"
|
|
;;
|
|
0x3c00)
|
|
term="NATIVE"
|
|
;;
|
|
*)
|
|
term="TODO_${parts[2]}"
|
|
;;
|
|
esac
|
|
|
|
case "${parts[1]}" in
|
|
0x??000000 | 0x??000200)
|
|
if [ "${term}" = "NONE" ]; then
|
|
echo -e "\tPAD_CFG_GPO(${parts[0]}, 0, ${reset}),"
|
|
else
|
|
echo -e "\tPAD_CFG_TERM_GPO(${parts[0]}, 0, ${term}, ${reset}),"
|
|
fi
|
|
;;
|
|
0x??000001 | 0x??000201)
|
|
if [ "${term}" = "NONE" ]; then
|
|
echo -e "\tPAD_CFG_GPO(${parts[0]}, 1, ${reset}),"
|
|
else
|
|
echo -e "\tPAD_CFG_TERM_GPO(${parts[0]}, 1, ${term}, ${reset}),"
|
|
fi
|
|
;;
|
|
0x??000100)
|
|
echo -e "\tPAD_CFG_GPI(${parts[0]}, ${term}, ${reset}),"
|
|
;;
|
|
0x4?000300)
|
|
echo -e "\tPAD_NC(${parts[0]}, ${term}),"
|
|
;;
|
|
0x??000400 | 0x??000500 | 0x??000600 | 0x??000700)
|
|
echo -e "\tPAD_CFG_NF(${parts[0]}, ${term}, ${reset}, NF1),"
|
|
;;
|
|
0x??000800 | 0x??000900 | 0x??000a00 | 0x??000b00)
|
|
echo -e "\tPAD_CFG_NF(${parts[0]}, ${term}, ${reset}, NF2),"
|
|
;;
|
|
0x??000c00 | 0x??000d00 | 0x??000e00 | 0x??000f00)
|
|
echo -e "\tPAD_CFG_NF(${parts[0]}, ${term}, ${reset}, NF3),"
|
|
;;
|
|
*)
|
|
echo -e "\t_PAD_CFG_STRUCT(${parts[0]}, ${parts[1]}, ${parts[2]}),"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
cat <<"EOF"
|
|
};
|
|
|
|
#endif
|
|
|
|
#endif
|
|
EOF
|