From 82ec61e9d7a39a11c9b8ed68eb90bd29905439bc Mon Sep 17 00:00:00 2001 From: Maxim Polyakov Date: Sun, 26 Apr 2020 22:12:01 +0300 Subject: util/intelp2m: Add Intel Pad to Macro utility This patch adds a new utility for converting a pad configuration from the inteltool dump to the PAD_CFG_*() macros [1] for coreboot and GPIO config data structures for FSP/sdk2-platforms/slimbootloader [2,3]. Mirror: https://github.com/maxpoliak/pch-pads-parser.git [1] src/soc/intel/common/block/include/intelblocks/gpio_defs.h [2] https://slimbootloader.github.io/tools/index.html#gpio-tool [3] 3rdparty/fsp/CometLakeFspBinPkg/CometLake1/Include/GpioSampleDef.h Change-Id: If3e3b523c4f63dc2f91e9ccd16934e3a1b6e21fa Signed-off-by: Maxim Polyakov Reviewed-on: https://review.coreboot.org/c/coreboot/+/35643 Reviewed-by: Andrey Petrov Reviewed-by: Angel Pons Tested-by: build bot (Jenkins) --- util/intelp2m/Makefile | 11 + util/intelp2m/config/config.go | 121 +++++++++ util/intelp2m/config/gopackages.png | Bin 0 -> 11594 bytes util/intelp2m/description.md | 201 ++++++++++++++ util/intelp2m/fields/cb/cb.go | 171 ++++++++++++ util/intelp2m/fields/fields.go | 20 ++ util/intelp2m/fields/fsp/fsp.go | 171 ++++++++++++ util/intelp2m/fields/raw/raw.go | 28 ++ util/intelp2m/main.go | 159 +++++++++++ util/intelp2m/parser/parser.go | 232 ++++++++++++++++ util/intelp2m/parser/template.go | 132 +++++++++ util/intelp2m/platforms/apl/macro.go | 329 +++++++++++++++++++++++ util/intelp2m/platforms/apl/template.go | 35 +++ util/intelp2m/platforms/common/macro.go | 417 +++++++++++++++++++++++++++++ util/intelp2m/platforms/common/register.go | 262 ++++++++++++++++++ util/intelp2m/platforms/lbg/macro.go | 102 +++++++ util/intelp2m/platforms/lbg/template.go | 22 ++ util/intelp2m/platforms/snr/macro.go | 278 +++++++++++++++++++ util/intelp2m/platforms/snr/template.go | 37 +++ 19 files changed, 2728 insertions(+) create mode 100644 util/intelp2m/Makefile create mode 100644 util/intelp2m/config/config.go create mode 100644 util/intelp2m/config/gopackages.png create mode 100644 util/intelp2m/description.md create mode 100644 util/intelp2m/fields/cb/cb.go create mode 100644 util/intelp2m/fields/fields.go create mode 100644 util/intelp2m/fields/fsp/fsp.go create mode 100644 util/intelp2m/fields/raw/raw.go create mode 100644 util/intelp2m/main.go create mode 100644 util/intelp2m/parser/parser.go create mode 100644 util/intelp2m/parser/template.go create mode 100644 util/intelp2m/platforms/apl/macro.go create mode 100644 util/intelp2m/platforms/apl/template.go create mode 100644 util/intelp2m/platforms/common/macro.go create mode 100644 util/intelp2m/platforms/common/register.go create mode 100644 util/intelp2m/platforms/lbg/macro.go create mode 100644 util/intelp2m/platforms/lbg/template.go create mode 100644 util/intelp2m/platforms/snr/macro.go create mode 100644 util/intelp2m/platforms/snr/template.go (limited to 'util') diff --git a/util/intelp2m/Makefile b/util/intelp2m/Makefile new file mode 100644 index 0000000000..1d9ba70ce3 --- /dev/null +++ b/util/intelp2m/Makefile @@ -0,0 +1,11 @@ +# simple makefile for the project + +OUTPUT_DIR = generate +PROJECT_NAME = intelp2m + +default: + go version + go build -v -o $(PROJECT_NAME) + +clean: + rm -Rf $(PROJECT_NAME) $(OUTPUT_DIR) diff --git a/util/intelp2m/config/config.go b/util/intelp2m/config/config.go new file mode 100644 index 0000000000..9f0b75772c --- /dev/null +++ b/util/intelp2m/config/config.go @@ -0,0 +1,121 @@ +package config + +import "os" + +const ( + TempInteltool int = 0 + TempGpioh int = 1 + TempSpec int = 2 +) + +var template int = 0 + +func TemplateSet(temp int) bool { + if temp > TempSpec { + return false + } else { + template = temp + return true + } +} + +func TemplateGet() int { + return template +} + +const ( + SunriseType uint8 = 0 + LewisburgType uint8 = 1 + ApolloType uint8 = 2 +) + +var key uint8 = SunriseType + +var platform = map[string]uint8{ + "snr": SunriseType, + "lbg": LewisburgType, + "apl": ApolloType} +func PlatformSet(name string) int { + if platformType, valid := platform[name]; valid { + key = platformType + return 0 + } + return -1 +} +func PlatformGet() uint8 { + return key +} +func IsPlatform(platformType uint8) bool { + return platformType == key +} +func IsPlatformApollo() bool { + return IsPlatform(ApolloType) +} +func IsPlatformSunrise() bool { + return IsPlatform(SunriseType) +} +func IsPlatformLewisburg() bool { + return IsPlatform(LewisburgType) +} + +var InputRegDumpFile *os.File = nil +var OutputGenFile *os.File = nil + +var ignoredFieldsFormat bool = false +func IgnoredFieldsFlagSet(flag bool) { + ignoredFieldsFormat = flag +} +func AreFieldsIgnored() bool { + return ignoredFieldsFormat +} + +var nonCheckingFlag bool = false +func NonCheckingFlagSet(flag bool) { + nonCheckingFlag = flag +} +func IsNonCheckingFlagUsed() bool { + return nonCheckingFlag +} + +var infolevel uint8 = 0 +func InfoLevelSet(lvl uint8) { + infolevel = lvl +} +func InfoLevelGet() uint8 { + return infolevel +} + +var fldstyle uint8 = CbFlds +const ( + NoFlds uint8 = 0 + CbFlds uint8 = 1 // coreboot style + FspFlds uint8 = 2 // FSP/edk2 style + RawFlds uint8 = 3 // raw DW0/1 values +) +var fldstylemap = map[string]uint8{ + "none" : NoFlds, + "cb" : CbFlds, + "fsp" : FspFlds, + "raw" : RawFlds} +func FldStyleSet(name string) int { + if style, valid := fldstylemap[name]; valid { + fldstyle = style + return 0 + } + return -1 +} +func FldStyleGet() uint8 { + return fldstyle +} +func IsFieldsMacroUsed() bool { + return FldStyleGet() != NoFlds +} +func IsCbStyleMacro() bool { + return FldStyleGet() == CbFlds +} +func IsFspStyleMacro() bool { + return FldStyleGet() == FspFlds +} +func IsRawFields() bool { + return FldStyleGet() == RawFlds +} diff --git a/util/intelp2m/config/gopackages.png b/util/intelp2m/config/gopackages.png new file mode 100644 index 0000000000..fb81a1ce1f Binary files /dev/null and b/util/intelp2m/config/gopackages.png differ diff --git a/util/intelp2m/description.md b/util/intelp2m/description.md new file mode 100644 index 0000000000..3008c046ab --- /dev/null +++ b/util/intelp2m/description.md @@ -0,0 +1,201 @@ +Intel Pad to Macro (intelp2m) converter +======================================= + +This utility allows to convert the configuration DW0/1 registers value +from [inteltool](../inteltool/description.md) dump to coreboot macros. + +```bash +(shell)$ make +(shell)$ ./intelp2m -h +(shell)$ ./intelp2m -file /path/to/inteltool.log +``` + +### Platforms + +It is possible to use templates for parsing files of excellent inteltool.log. +To specify such a pattern, use the option -t