diff --git a/scripts/coreboot-gpio.sh b/scripts/coreboot-gpio.sh new file mode 100755 index 0000000..3fb3863 --- /dev/null +++ b/scripts/coreboot-gpio.sh @@ -0,0 +1,119 @@ +#!/usr/bin/env bash + +set -e + +if [ ! -e "$1" ] +then + echo "$0 [coreboot-collector output]" + exit 1 +fi + +cat <<"EOF" +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 System76 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + */ + +#ifndef MAINBOARD_GPIO_H +#define MAINBOARD_GPIO_H + +#include +#include + +#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]} & 0xffffff00))")" + + 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?4000000 | 0x?4000200) + echo -e "\t\tPAD_CFG_TERM_GPO(${parts[0]}, 0, ${term}, ${reset})," + ;; + 0x?4000001 | 0x?4000201) + echo -e "\t\tPAD_CFG_TERM_GPO(${parts[0]}, 1, ${term}, ${reset})," + ;; + 0x?4000100) + echo -e "\t\tPAD_CFG_GPI(${parts[0]}, ${term}, ${reset})," + ;; + 0x44000300) + echo -e "\t\tPAD_NC(${parts[0]}, ${term})," + ;; + 0x?4000400 | 0x?4000500 | 0x?4000600 | 0x?4000700) + echo -e "\t\tPAD_CFG_NF(${parts[0]}, ${term}, ${reset}, NF1)," + ;; + 0x?4000800 | 0x?4000900 | 0x?4000a00 | 0x?4000b00) + echo -e "\t\tPAD_CFG_NF(${parts[0]}, ${term}, ${reset}, NF2)," + ;; + 0x?4000c00 | 0x?4000d00 | 0x?4000e00 | 0x?4000f00) + echo -e "\t\tPAD_CFG_NF(${parts[0]}, ${term}, ${reset}, NF3)," + ;; + *) + echo -e "\t\t_PAD_CFG_STRUCT(${parts[0]}, ${parts[1]}, ${parts[2]})," + ;; + esac +done + +cat <<"EOF" +}; + +#endif + +#endif +EOF diff --git a/scripts/coreboot-hda.sh b/scripts/coreboot-hda.sh new file mode 100755 index 0000000..d8f3201 --- /dev/null +++ b/scripts/coreboot-hda.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +set -e + +if [ ! -e "$1" ] +then + echo "$0 [coreboot-collector output]" + exit 1 +fi + +cat <<"EOF" +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 System76 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + */ + +#ifndef HDA_VERB_H +#define HDA_VERB_H + +#include + +const u32 cim_verb_data[] = { +EOF + +grep "^hdaudio" "$1" | \ +while read line +do + data="$(sed -n "/^$line/,/^hdaudio/p" "$1" | grep -v "^hdaudio" | tr -d " ")" + index="$(cut -d 'D' -f2 <<< "$line")" + vendor_name="$(grep "^vendor_name:" <<< "$data" | cut -d ':' -f2)" + chip_name="$(grep "^chip_name:" <<< "$data" | cut -d ':' -f2)" + vendor_id="$(grep "^vendor_id:" <<< "$data" | cut -d ':' -f2)" + subsystem_id="$(grep "^subsystem_id:" <<< "$data" | cut -d ':' -f2)" + + widgets="$(grep "^0x" <<< "$data")" + + echo -e "\t/* $vendor_name, $chip_name */" + echo -e "\t$vendor_id, /* Vendor ID */" + echo -e "\t$subsystem_id, /* Subsystem ID */" + echo -e "\t$(($(wc -l <<<"$widgets") + 1)), /* Number of entries */" + + echo -e "\tAZALIA_SUBVENDOR($index, $subsystem_id)," + + cat <<< "$widgets" | \ + while read line + do + nid="$(cut -d ':' -f1 <<< "$line")" + pin_cfg="$(cut -d ':' -f2 <<< "$line")" + echo -e "\tAZALIA_PIN_CFG($index, $nid, $pin_cfg)," + done +done + +cat <<"EOF" +}; + +const u32 pc_beep_verbs[] = {}; + +AZALIA_ARRAY_SIZES; + +#endif +EOF