From a4f4dc57691f1e46ec5270b614ce25776c2cd3d5 Mon Sep 17 00:00:00 2001 From: Maxim Polyakov Date: Wed, 25 Dec 2024 22:08:31 +0300 Subject: [PATCH] util/intelp2m: Provide GPP group slice from each platform Instead of a pointer to a function for analyzing the pad name, provide GPP group slice with pad names to the parser. This will get rid of some functions and files and make the code cleaner. TEST: - 'make test' = PASS; - 'intelp2m -file parser/testlog/inteltool_test.log' = no errors. Change-Id: I0d7818d3892450a37bffbf1ffd9524888e4675bf Signed-off-by: Maxim Polyakov Reviewed-on: https://review.coreboot.org/c/coreboot/+/85769 Tested-by: build bot (Jenkins) Reviewed-by: David Hendricks --- util/intelp2m/parser/parser.go | 18 +++++++-- util/intelp2m/platforms/adl/macro.go | 5 +++ util/intelp2m/platforms/adl/template.go | 13 ------- util/intelp2m/platforms/apl/macro.go | 12 ++++++ util/intelp2m/platforms/apl/template.go | 19 ---------- util/intelp2m/platforms/cnl/macro.go | 20 ++++++++++ util/intelp2m/platforms/cnl/template.go | 25 ------------- util/intelp2m/platforms/common/template.go | 15 -------- util/intelp2m/platforms/ebg/macro.go | 4 ++ util/intelp2m/platforms/ebg/template.go | 14 ------- util/intelp2m/platforms/jsl/macro.go | 4 ++ util/intelp2m/platforms/jsl/template.go | 14 ------- util/intelp2m/platforms/lbg/macro.go | 4 ++ util/intelp2m/platforms/lbg/template.go | 12 ------ util/intelp2m/platforms/mtl/macro.go | 4 ++ util/intelp2m/platforms/mtl/template.go | 14 ------- util/intelp2m/platforms/platforms.go | 43 +++++++++++----------- util/intelp2m/platforms/snr/macro.go | 4 ++ util/intelp2m/platforms/snr/template.go | 12 ------ util/intelp2m/platforms/tgl/macro.go | 4 ++ util/intelp2m/platforms/tgl/template.go | 14 ------- 21 files changed, 96 insertions(+), 178 deletions(-) delete mode 100644 util/intelp2m/platforms/adl/template.go delete mode 100644 util/intelp2m/platforms/apl/template.go delete mode 100644 util/intelp2m/platforms/cnl/template.go delete mode 100644 util/intelp2m/platforms/common/template.go delete mode 100644 util/intelp2m/platforms/ebg/template.go delete mode 100644 util/intelp2m/platforms/jsl/template.go delete mode 100644 util/intelp2m/platforms/lbg/template.go delete mode 100644 util/intelp2m/platforms/mtl/template.go delete mode 100644 util/intelp2m/platforms/snr/template.go delete mode 100644 util/intelp2m/platforms/tgl/template.go diff --git a/util/intelp2m/parser/parser.go b/util/intelp2m/parser/parser.go index 91428f83de..35273e5ad7 100644 --- a/util/intelp2m/parser/parser.go +++ b/util/intelp2m/parser/parser.go @@ -82,15 +82,25 @@ func extractGroup(line string) Entry { return group } +// checkGPPG() checks whether the desired group is present in the string +func checkKeywords(line string, slice []string) bool { + for _, key := range slice { + if strings.Contains(line, key) { + return true + } + } + return false +} + // Extract() extracts pad information from a string func Extract(line string) Entry { - if included, _ := common.KeywordsCheck(line, "GPIO Community", "GPIO Group"); included { + if checkKeywords(line, []string{"GPIO Community", "GPIO Group"}) { return extractGroup(line) } - if checkKeyword := platforms.GetKeywordChekingAction(); checkKeyword == nil { - logs.Errorf("information extraction error: skip line <%s>", line) + if gppg, err := platforms.GetGPPGroups(); err != nil { + logs.Errorf("extract error: %v: skip line <%s>", err, line) return Entry{EType: EntryEmpty} - } else if checkKeyword(line) { + } else if checkKeywords(line, gppg) { pad, err := extractPad(line) if err != nil { logs.Errorf("extract pad info from %s: %v", line, err) diff --git a/util/intelp2m/platforms/adl/macro.go b/util/intelp2m/platforms/adl/macro.go index 63104d0ce8..d17795bf32 100644 --- a/util/intelp2m/platforms/adl/macro.go +++ b/util/intelp2m/platforms/adl/macro.go @@ -14,6 +14,11 @@ const ( DW1Mask uint32 = 0b11111101111111111100001111111111 ) +// "GPP_A", "GPP_B", "GPP_C", "GPP_D", "GPP_E", "GPP_F", "GPP_G", +// "GPP_H", "GPP_I", "GPP_J", "GPP_K", "GPP_R", "GPP_S", "GPP_T", +// "GPD", "VGPIO_USB", "VGPIO_PCIE" +var GPPGroups = []string{"GPP_", "GPD", "VGPIO"} + var remapping = common.ResetSources{ 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, diff --git a/util/intelp2m/platforms/adl/template.go b/util/intelp2m/platforms/adl/template.go deleted file mode 100644 index 4af499dbab..0000000000 --- a/util/intelp2m/platforms/adl/template.go +++ /dev/null @@ -1,13 +0,0 @@ -package adl - -import "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" - -// CheckKeyword() parses lines of the configuration file and returns true if the keyword is -// contained in the line -// "GPP_A", "GPP_B", "GPP_C", "GPP_D", "GPP_E", "GPP_F", "GPP_G", -// "GPP_H", "GPP_I", "GPP_J", "GPP_K", "GPP_R", "GPP_S", "GPP_T", -// "GPD", "VGPIO_USB", "VGPIO_PCIE" -func CheckKeyword(line string) bool { - isIncluded, _ := common.KeywordsCheck(line, "GPP_", "GPD", "VGPIO") - return isIncluded -} diff --git a/util/intelp2m/platforms/apl/macro.go b/util/intelp2m/platforms/apl/macro.go index 614d0bebd6..103d602927 100644 --- a/util/intelp2m/platforms/apl/macro.go +++ b/util/intelp2m/platforms/apl/macro.go @@ -12,6 +12,18 @@ const ( DW1Mask uint32 = 0b11111111111111000000000011111111 ) +var GPPGroups = []string{ + "GPIO_", "TCK", "TRST_B", "TMS", "TDI", "CX_PMODE", "CX_PREQ_B", "JTAGX", "CX_PRDY_B", + "TDO", "CNV_BRI_DT", "CNV_BRI_RSP", "CNV_RGI_DT", "CNV_RGI_RSP", "SVID0_ALERT_B", + "SVID0_DATA", "SVID0_CLK", "PMC_SPI_FS", "PMC_SPI_RXD", "PMC_SPI_TXD", "PMC_SPI_CLK", + "PMIC_PWRGOOD", "PMIC_RESET_B", "PMIC_THERMTRIP_B", "PMIC_STDBY", "PROCHOT_B", + "PMIC_I2C_SCL", "PMIC_I2C_SDA", "FST_SPI_CLK_FB", "OSC_CLK_OUT_", "PMU_AC_PRESENT", + "PMU_BATLOW_B", "PMU_PLTRST_B", "PMU_PWRBTN_B", "PMU_RESETBUTTON_B", "PMU_SLP_S0_B", + "PMU_SLP_S3_B", "PMU_SLP_S4_B", "PMU_SUSCLK", "PMU_WAKE_B", "SUS_STAT_B", "SUSPWRDNACK", + "SMB_ALERTB", "SMB_CLK", "SMB_DATA", "LPC_ILB_SERIRQ", "LPC_CLKOUT", "LPC_AD", "LPC_CLKRUNB", + "LPC_FRAMEB", +} + type BasePlatform struct { common.BasePlatform } diff --git a/util/intelp2m/platforms/apl/template.go b/util/intelp2m/platforms/apl/template.go deleted file mode 100644 index 014431d18a..0000000000 --- a/util/intelp2m/platforms/apl/template.go +++ /dev/null @@ -1,19 +0,0 @@ -package apl - -import "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" - -// CheckKeyword() parses lines of the configuration file and returns true if the keyword is -// contained in the line -func CheckKeyword(line string) bool { - isIncluded, _ := common.KeywordsCheck(line, - "GPIO_", "TCK", "TRST_B", "TMS", "TDI", "CX_PMODE", "CX_PREQ_B", "JTAGX", "CX_PRDY_B", - "TDO", "CNV_BRI_DT", "CNV_BRI_RSP", "CNV_RGI_DT", "CNV_RGI_RSP", "SVID0_ALERT_B", - "SVID0_DATA", "SVID0_CLK", "PMC_SPI_FS", "PMC_SPI_RXD", "PMC_SPI_TXD", "PMC_SPI_CLK", - "PMIC_PWRGOOD", "PMIC_RESET_B", "PMIC_THERMTRIP_B", "PMIC_STDBY", "PROCHOT_B", - "PMIC_I2C_SCL", "PMIC_I2C_SDA", "FST_SPI_CLK_FB", "OSC_CLK_OUT_", "PMU_AC_PRESENT", - "PMU_BATLOW_B", "PMU_PLTRST_B", "PMU_PWRBTN_B", "PMU_RESETBUTTON_B", "PMU_SLP_S0_B", - "PMU_SLP_S3_B", "PMU_SLP_S4_B", "PMU_SUSCLK", "PMU_WAKE_B", "SUS_STAT_B", "SUSPWRDNACK", - "SMB_ALERTB", "SMB_CLK", "SMB_DATA", "LPC_ILB_SERIRQ", "LPC_CLKOUT", "LPC_AD", "LPC_CLKRUNB", - "LPC_FRAMEB") - return isIncluded -} diff --git a/util/intelp2m/platforms/cnl/macro.go b/util/intelp2m/platforms/cnl/macro.go index 625df0aa5f..9cb8765a1f 100644 --- a/util/intelp2m/platforms/cnl/macro.go +++ b/util/intelp2m/platforms/cnl/macro.go @@ -15,6 +15,26 @@ const ( DW1Mask uint32 = 0b11111101111111111100001111111111 ) +var GPPGroups = []string{ + "GPP_", "GPD", // "GPP_A", "GPP_B", "GPP_G", "GPP_D", "GPP_F", "GPP_H", "GPP_C", "GPP_E" + "I2S1_TXD", "CNV_BTEN", "CNV_GNEN", "CNV_WFEN", "CNV_WCEN", "vCNV_GNSS_HOST_WAKE_B", + "vSD3_CD_B", "CNV_BT_HOST_WAKE_B", "CNV_BT_IF_SELECT", "vCNV_BT_UART_TXD", + "vCNV_BT_UART_RXD", "vCNV_BT_UART_CTS_B", "vCNV_BT_UART_RTS_B", "vCNV_MFUART1_TXD", + "vCNV_MFUART1_RXD", "vCNV_MFUART1_CTS_B", "vCNV_MFUART1_RTS_B", "vCNV_GNSS_UART_TXD", + "vCNV_GNSS_UART_RXD", "vCNV_GNSS_UART_CTS_B", "vCNV_GNSS_UART_RTS_B", "vUART0_TXD", + "vUART0_RXD", "vUART0_CTS_B", "vUART0_RTS_B", "vISH_UART0_TXD", "vISH_UART0_RXD", + "vISH_UART0_CTS_B", "vISH_UART0_RTS_B", "vISH_UART1_TXD", "vISH_UART1_RXD", + "vISH_UART1_CTS_B", "vISH_UART1_RTS_B", "vCNV_BT_I2S_BCLK", "vCNV_BT_I2S_WS_SYNC", + "vCNV_BT_I2S_SDO", "vCNV_BT_I2S_SDI", "vSSP2_SCLK", "vSSP2_SFRM", "vSSP2_TXD", + "vSSP2_RXD", "SLP_LAN_B", "SLP_SUS_B", "WAKE_B", "DRAM_RESET_B", "SPI0_IO_2", + "SPI0_IO_3", "SPI0_MISO", "SPI0_MOSI", "SPI0_CS2_B", "SPI0_CS0_B", "SPI0_CS1_B", + "SPI0_CLK", "SPI0_CLK_LOOPBK", "HDACPU_SDI", "HDACPU_SDO", "HDACPU_SCLK", "PM_SYNC", + "PECI", "CPUPWRGD", "THRMTRIP_B", "PLTRST_CPU_B", "PM_DOWN", "TRIGGER_IN", + "TRIGGER_OUT", "PCH_TDO", "PCH_JTAGX", "PROC_PRDY_B", "PROC_PREQ_B", "CPU_TRST_B", + "PCH_TDI", "PCH_TMS", "PCH_TCK", "ITP_PMODE", "SYS_PWROK", "SYS_RESET_B", "CL_RST_B", + "HDA_BCLK", "HDA_RST_B", "HDA_SYNC", "HDA_SDO", "HDA_SDI0", "HDA_SDI1", "I2S1_SFRM", +} + var remapping = common.ResetSources{ 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, diff --git a/util/intelp2m/platforms/cnl/template.go b/util/intelp2m/platforms/cnl/template.go deleted file mode 100644 index f1bb525a6d..0000000000 --- a/util/intelp2m/platforms/cnl/template.go +++ /dev/null @@ -1,25 +0,0 @@ -package cnl - -import "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" - -func CheckKeyword(line string) bool { - // "GPP_" : "GPP_A", "GPP_B", "GPP_G", "GPP_D", "GPP_F", "GPP_H", "GPP_C", "GPP_E" - included, _ := common.KeywordsCheck(line, "GPP_", "GPD", - "I2S1_TXD", "CNV_BTEN", "CNV_GNEN", "CNV_WFEN", "CNV_WCEN", "vCNV_GNSS_HOST_WAKE_B", - "vSD3_CD_B", "CNV_BT_HOST_WAKE_B", "CNV_BT_IF_SELECT", "vCNV_BT_UART_TXD", - "vCNV_BT_UART_RXD", "vCNV_BT_UART_CTS_B", "vCNV_BT_UART_RTS_B", "vCNV_MFUART1_TXD", - "vCNV_MFUART1_RXD", "vCNV_MFUART1_CTS_B", "vCNV_MFUART1_RTS_B", "vCNV_GNSS_UART_TXD", - "vCNV_GNSS_UART_RXD", "vCNV_GNSS_UART_CTS_B", "vCNV_GNSS_UART_RTS_B", "vUART0_TXD", - "vUART0_RXD", "vUART0_CTS_B", "vUART0_RTS_B", "vISH_UART0_TXD", "vISH_UART0_RXD", - "vISH_UART0_CTS_B", "vISH_UART0_RTS_B", "vISH_UART1_TXD", "vISH_UART1_RXD", - "vISH_UART1_CTS_B", "vISH_UART1_RTS_B", "vCNV_BT_I2S_BCLK", "vCNV_BT_I2S_WS_SYNC", - "vCNV_BT_I2S_SDO", "vCNV_BT_I2S_SDI", "vSSP2_SCLK", "vSSP2_SFRM", "vSSP2_TXD", - "vSSP2_RXD", "SLP_LAN_B", "SLP_SUS_B", "WAKE_B", "DRAM_RESET_B", "SPI0_IO_2", - "SPI0_IO_3", "SPI0_MISO", "SPI0_MOSI", "SPI0_CS2_B", "SPI0_CS0_B", "SPI0_CS1_B", - "SPI0_CLK", "SPI0_CLK_LOOPBK", "HDACPU_SDI", "HDACPU_SDO", "HDACPU_SCLK", "PM_SYNC", - "PECI", "CPUPWRGD", "THRMTRIP_B", "PLTRST_CPU_B", "PM_DOWN", "TRIGGER_IN", - "TRIGGER_OUT", "PCH_TDO", "PCH_JTAGX", "PROC_PRDY_B", "PROC_PREQ_B", "CPU_TRST_B", - "PCH_TDI", "PCH_TMS", "PCH_TCK", "ITP_PMODE", "SYS_PWROK", "SYS_RESET_B", "CL_RST_B", - "HDA_BCLK", "HDA_RST_B", "HDA_SYNC", "HDA_SDO", "HDA_SDI0", "HDA_SDI1", "I2S1_SFRM") - return included -} diff --git a/util/intelp2m/platforms/common/template.go b/util/intelp2m/platforms/common/template.go deleted file mode 100644 index 296f169fb3..0000000000 --- a/util/intelp2m/platforms/common/template.go +++ /dev/null @@ -1,15 +0,0 @@ -package common - -import "strings" - -// KeywordsCheck - check if one of the keyword from the group is included in the -// string. Returns false if no word was found, or true otherwise and also this word -// itself -func KeywordsCheck(line string, keywords ...string) (bool, string) { - for _, key := range keywords { - if strings.Contains(line, key) { - return true, key - } - } - return false, "" -} diff --git a/util/intelp2m/platforms/ebg/macro.go b/util/intelp2m/platforms/ebg/macro.go index f1a967ece4..da2eeac123 100644 --- a/util/intelp2m/platforms/ebg/macro.go +++ b/util/intelp2m/platforms/ebg/macro.go @@ -12,6 +12,10 @@ const ( DW1Mask = 0b11111101111111111100001111111111 ) +// "GPPC_A", "GPPC_B", "GPPC_S", "GPPC_C", "GPP_D", "GPP_E", "GPPC_H", "GPP_J", "GPP_I", +// "GPP_L", "GPP_M", "GPP_N" +var GPPGroups = []string{"GPP_", "GPPC_"} + var remapping = common.ResetSources{ 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, diff --git a/util/intelp2m/platforms/ebg/template.go b/util/intelp2m/platforms/ebg/template.go deleted file mode 100644 index 451bd5dfdc..0000000000 --- a/util/intelp2m/platforms/ebg/template.go +++ /dev/null @@ -1,14 +0,0 @@ -package ebg - -import "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" - -// Group : "GPPC_A", "GPPC_B", "GPPC_S", "GPPC_C", "GPP_D", "GPP_E", "GPPC_H", "GPP_J", -// "GPP_I", "GPP_L", "GPP_M", "GPP_N" - -// CheckKeyword - This function is used to filter parsed lines of the configuration file and -// returns true if the keyword is contained in the line. -// line : string from the configuration file -func CheckKeyword(line string) bool { - isIncluded, _ := common.KeywordsCheck(line, "GPP_", "GPPC_") - return isIncluded -} diff --git a/util/intelp2m/platforms/jsl/macro.go b/util/intelp2m/platforms/jsl/macro.go index 92cb66cf33..e249662601 100644 --- a/util/intelp2m/platforms/jsl/macro.go +++ b/util/intelp2m/platforms/jsl/macro.go @@ -14,6 +14,10 @@ const ( DW1Mask = 0b11111101111111111100001111111111 ) +// "GPP_A", "GPP_B", "GPP_C", "GPP_D", "GPP_E", "GPP_F", "GPP_G", "GPP_H", "GPP_R", "GPP_S", +// "GPP_T", "GPD", "HVMOS", "VGPIO5" +var GPPGroups = []string{"GPP_", "GPD", "VGPIO"} + var remapping = common.ResetSources{ 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, diff --git a/util/intelp2m/platforms/jsl/template.go b/util/intelp2m/platforms/jsl/template.go deleted file mode 100644 index acf6a5ab70..0000000000 --- a/util/intelp2m/platforms/jsl/template.go +++ /dev/null @@ -1,14 +0,0 @@ -package jsl - -import "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" - -// Group : "GPP_A", "GPP_B", "GPP_C", "GPP_D", "GPP_E", "GPP_F", "GPP_G", "GPP_H", "GPP_R", -// "GPP_S", "GPP_T", "GPD", "HVMOS", "VGPIO5" - -// CheckKeyword - This function is used to filter parsed lines of the configuration file and -// returns true if the keyword is contained in the line. -// line : string from the configuration file -func CheckKeyword(line string) bool { - isIncluded, _ := common.KeywordsCheck(line, "GPP_", "GPD", "VGPIO") - return isIncluded -} diff --git a/util/intelp2m/platforms/lbg/macro.go b/util/intelp2m/platforms/lbg/macro.go index b58c8a956a..cf40429a9d 100644 --- a/util/intelp2m/platforms/lbg/macro.go +++ b/util/intelp2m/platforms/lbg/macro.go @@ -12,6 +12,10 @@ const ( DW1Mask uint32 = 0b11111101111111111100001111111111 ) +// "GPP_A", "GPP_B", "GPP_F", "GPP_C", "GPP_D", "GPP_E", "GPD", "GPP_I", "GPP_J", "GPP_K", +// "GPP_G", "GPP_H", "GPP_L" +var GPPGroups = []string{"GPP_", "GPD"} + var remapping = common.ResetSources{ 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, diff --git a/util/intelp2m/platforms/lbg/template.go b/util/intelp2m/platforms/lbg/template.go deleted file mode 100644 index f4600850df..0000000000 --- a/util/intelp2m/platforms/lbg/template.go +++ /dev/null @@ -1,12 +0,0 @@ -package lbg - -import "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" - -// CheckKeyword() parses lines of the configuration file and returns true if the keyword is -// contained in the line -// "GPP_A", "GPP_B", "GPP_F", "GPP_C", "GPP_D", "GPP_E", "GPD", "GPP_I", "GPP_J", -// "GPP_K", "GPP_G", "GPP_H", "GPP_L" -func CheckKeyword(line string) bool { - included, _ := common.KeywordsCheck(line, "GPP_", "GPD") - return included -} diff --git a/util/intelp2m/platforms/mtl/macro.go b/util/intelp2m/platforms/mtl/macro.go index 8740f5f783..25083bc045 100644 --- a/util/intelp2m/platforms/mtl/macro.go +++ b/util/intelp2m/platforms/mtl/macro.go @@ -14,6 +14,10 @@ const ( DW1Mask = 0b11111101111111111100001111111111 ) +// "GPP_V", "GPP_C", "GPP_A", "GPP_E", "GPP_H", "GPP_F", "GPP_S", "GPP_B", "GPP_D", "GPD", +// "VGPIO_USB", "VGPIO_PCIE" +var GPPGroups = []string{"GPP_", "GPD", "VGPIO"} + var remapping = common.ResetSources{ 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, diff --git a/util/intelp2m/platforms/mtl/template.go b/util/intelp2m/platforms/mtl/template.go deleted file mode 100644 index 27951fefb5..0000000000 --- a/util/intelp2m/platforms/mtl/template.go +++ /dev/null @@ -1,14 +0,0 @@ -package mtl - -import "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" - -// Group : "GPP_V", "GPP_C", "GPP_A", "GPP_E", "GPP_H", "GPP_F", "GPP_S", "GPP_B", "GPP_D", -// "GPD", "VGPIO_USB", "VGPIO_PCIE" - -// CheckKeyword - This function is used to filter parsed lines of the configuration file and -// returns true if the keyword is contained in the line. -// line : string from the configuration file -func CheckKeyword(line string) bool { - isIncluded, _ := common.KeywordsCheck(line, "GPP_", "GPD", "VGPIO") - return isIncluded -} diff --git a/util/intelp2m/platforms/platforms.go b/util/intelp2m/platforms/platforms.go index cb65903e8b..22f2d9d881 100644 --- a/util/intelp2m/platforms/platforms.go +++ b/util/intelp2m/platforms/platforms.go @@ -4,7 +4,6 @@ import ( "fmt" "review.coreboot.org/coreboot.git/util/intelp2m/config/p2m" - "review.coreboot.org/coreboot.git/util/intelp2m/logs" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/adl" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/apl" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/cnl" @@ -17,10 +16,10 @@ import ( "review.coreboot.org/coreboot.git/util/intelp2m/platforms/tgl" ) -type KeywordAction func(line string) bool - type Constructor func(dw0, dw1 uint32) common.PlatformIf +var ErrUnregisteredPlatform = fmt.Errorf("unregistered platform type %d", p2m.Config.Platform) + var platformConstructorMap = map[p2m.PlatformType]Constructor{ p2m.Alder: adl.GetPlatform, p2m.Apollo: apl.GetPlatform, @@ -33,30 +32,30 @@ var platformConstructorMap = map[p2m.PlatformType]Constructor{ p2m.Lewisburg: lbg.GetPlatform, } -func GetKeywordChekingAction() KeywordAction { - actions := map[p2m.PlatformType]KeywordAction{ - p2m.Alder: adl.CheckKeyword, - p2m.Apollo: apl.CheckKeyword, - p2m.Cannon: cnl.CheckKeyword, - p2m.Sunrise: snr.CheckKeyword, - p2m.Tiger: tgl.CheckKeyword, - p2m.Jasper: jsl.CheckKeyword, - p2m.Meteor: mtl.CheckKeyword, - p2m.Emmitsburg: ebg.CheckKeyword, - p2m.Lewisburg: lbg.CheckKeyword, - } - action, exist := actions[p2m.Config.Platform] - if !exist { - logs.Errorf("unregistered platform type %d", p2m.Config.Platform) - return nil - } - return action +var GppMap = map[p2m.PlatformType][]string{ + p2m.Alder: adl.GPPGroups, + p2m.Apollo: apl.GPPGroups, + p2m.Cannon: cnl.GPPGroups, + p2m.Sunrise: snr.GPPGroups, + p2m.Tiger: tgl.GPPGroups, + p2m.Jasper: jsl.GPPGroups, + p2m.Meteor: mtl.GPPGroups, + p2m.Emmitsburg: ebg.GPPGroups, + p2m.Lewisburg: lbg.GPPGroups, } func GetConstructor() (Constructor, error) { constructor, exist := platformConstructorMap[p2m.Config.Platform] if !exist { - return nil, fmt.Errorf("unregistered platform type %d", p2m.Config.Platform) + return nil, ErrUnregisteredPlatform } return constructor, nil } + +func GetGPPGroups() ([]string, error) { + groups, exist := GppMap[p2m.Config.Platform] + if !exist { + return nil, ErrUnregisteredPlatform + } + return groups, nil +} diff --git a/util/intelp2m/platforms/snr/macro.go b/util/intelp2m/platforms/snr/macro.go index 7250608374..3550177976 100644 --- a/util/intelp2m/platforms/snr/macro.go +++ b/util/intelp2m/platforms/snr/macro.go @@ -14,6 +14,10 @@ const ( DW1Mask uint32 = 0b11111101111111111100001111111111 ) +// "GPP_A", "GPP_B", "GPP_F", "GPP_C", "GPP_D", "GPP_E", "GPD", "GPP_I", "GPP_J", "GPP_G", +// "GPP_H", "GPP_L" +var GPPGroups = []string{"GPP_", "GPD"} + var remapping = common.ResetSources{ 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, diff --git a/util/intelp2m/platforms/snr/template.go b/util/intelp2m/platforms/snr/template.go deleted file mode 100644 index 22f477e62c..0000000000 --- a/util/intelp2m/platforms/snr/template.go +++ /dev/null @@ -1,12 +0,0 @@ -package snr - -import "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" - -// CheckKeyword() parses lines of the configuration file and returns true if the keyword is -// contained in the line -// "GPP_A", "GPP_B", "GPP_F", "GPP_C", "GPP_D", "GPP_E", "GPD", "GPP_I", "GPP_J", -// "GPP_K", "GPP_G", "GPP_H", "GPP_L" -func CheckKeyword(line string) bool { - included, _ := common.KeywordsCheck(line, "GPP_", "GPD") - return included -} diff --git a/util/intelp2m/platforms/tgl/macro.go b/util/intelp2m/platforms/tgl/macro.go index 6e63167b2a..7bd49a87bd 100644 --- a/util/intelp2m/platforms/tgl/macro.go +++ b/util/intelp2m/platforms/tgl/macro.go @@ -14,6 +14,10 @@ const ( DW1Mask = 0b11111101111111111100001111111111 ) +// "GPP_A", "GPP_R", "GPP_B", "GPP_D", "GPP_C", "GPP_S", "GPP_G", "GPD", "GPP_E", "GPP_F", +// "GPP_H", "GPP_J", "GPP_K", "GPP_I", "VGPIO_USB", "VGPIO_PCIE" +var GPPGroups = []string{"GPP_", "GPD", "VGPIO"} + var remapping = common.ResetSources{ 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, diff --git a/util/intelp2m/platforms/tgl/template.go b/util/intelp2m/platforms/tgl/template.go deleted file mode 100644 index f6a0bcd4d0..0000000000 --- a/util/intelp2m/platforms/tgl/template.go +++ /dev/null @@ -1,14 +0,0 @@ -package tgl - -import "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" - -// Group : "GPP_A", "GPP_R", "GPP_B", "GPP_D", "GPP_C", "GPP_S", "GPP_G", "GPD", "GPP_E", -// "GPP_F", "GPP_H", "GPP_J", "GPP_K", "GPP_I", "VGPIO_USB", "VGPIO_PCIE" - -// CheckKeyword - This function is used to filter parsed lines of the configuration file -// and returns true if the keyword is contained in the line. -// line : string from the configuration file -func CheckKeyword(line string) bool { - isIncluded, _ := common.KeywordsCheck(line, "GPP_", "GPD", "VGPIO") - return isIncluded -}