Maxim has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/85607?usp=email )
Change subject: intelp2m/patform/tgl: Add unit tests ......................................................................
intelp2m/patform/tgl: Add unit tests
1) Siding one in nibble: DW = 0001 0001 0001 0001 <- <- <- <- 2) Siding zero in nibble: DW = 1110 1110 1110 1110 <- <- <- <- 3) Siding one one in nibble: DW = 0011 0011 0011 0011 <- <- <- <-
Change-Id: I637ee4769b13199edadd10afbbd12f9fc37fec81 Signed-off-by: Maxim Polyakov max.senia.poliak@gmail.com --- M util/intelp2m/platforms/tgl/template.go A util/intelp2m/platforms/tgl/tgl_test.go 2 files changed, 115 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/07/85607/1
diff --git a/util/intelp2m/platforms/tgl/template.go b/util/intelp2m/platforms/tgl/template.go index f98272a..5a93aee 100644 --- a/util/intelp2m/platforms/tgl/template.go +++ b/util/intelp2m/platforms/tgl/template.go @@ -5,8 +5,9 @@ // GroupNameExtract - This function extracts the group ID, if it exists in a row // line : string from the configuration file // return -// bool : true if the string contains a group identifier -// string : group identifier +// +// bool : true if the string contains a group identifier +// string : group identifier func (PlatformSpecific) GroupNameExtract(line string) (bool, string) { return common.KeywordsCheck(line, "GPP_A", "GPP_R", "GPP_B", "GPP_D", "GPP_C", "GPP_S", "GPP_G", @@ -16,8 +17,8 @@ }
// KeywordCheck - 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 +// returns true if the keyword is contained in the line. +// line : string from the configuration file func (PlatformSpecific) KeywordCheck(line string) bool { isIncluded, _ := common.KeywordsCheck(line, "GPP_", "GPD", "VGPIO") return isIncluded diff --git a/util/intelp2m/platforms/tgl/tgl_test.go b/util/intelp2m/platforms/tgl/tgl_test.go new file mode 100644 index 0000000..e37567e --- /dev/null +++ b/util/intelp2m/platforms/tgl/tgl_test.go @@ -0,0 +1,110 @@ +package tgl_test + +import ( + "testing" + + "review.coreboot.org/coreboot.git/util/intelp2m/platforms/cnl" + "review.coreboot.org/coreboot.git/util/intelp2m/platforms/snr" + "review.coreboot.org/coreboot.git/util/intelp2m/platforms/test" + "review.coreboot.org/coreboot.git/util/intelp2m/platforms/tgl" +) + +func TestGenMacro(t *testing.T) { + tigerlake := tgl.PlatformSpecific{ + InheritanceMacro: cnl.PlatformSpecific{ + InheritanceMacro: snr.PlatformSpecific{}, + }, + } + test.Suite{ + { + Pad: test.Pad{ID: "GPP_A1", DW0: 0x11111111, DW1: 0x11111111, Ownership: 1}, + Macro: test.Macro{ + Short: "PAD_CFG_NF(GPP_A1, DN_20K, RSMRST, NF4),", + Long: "_PAD_CFG_STRUCT(GPP_A1, PAD_FUNC(NF4) | PAD_RESET(RSMRST) | PAD_IRQ_ROUTE(IOAPIC) | PAD_BUF(TX_DISABLE) | (1 << 28) | 1, PAD_PULL(DN_20K) | PAD_IOSSTATE(Tx1RxDCRx1) | PAD_IOSTERM(DISPUPD) | PAD_CFG_OWN_GPIO(DRIVER)),", + }, + }, + { + Pad: test.Pad{ID: "GPP_R2", DW0: 0x22222222, DW1: 0x22222222, Ownership: 0}, + Macro: test.Macro{ + Short: "PAD_CFG_TERM_GPO(GPP_R2, 0, INVALID, RSMRST),", + Long: "_PAD_CFG_STRUCT(GPP_R2, PAD_FUNC(GPIO) | PAD_RESET(RSMRST) | PAD_TRIG(EDGE_SINGLE) | PAD_IRQ_ROUTE(NMI) | PAD_BUF(RX_DISABLE) | (1 << 29) | (1 << 1), PAD_CFG1_TOL_1V8PAD_PULL(INVALID) | PAD_IOSSTATE(HIZCRx1) | PAD_IOSTERM(ENPD)),", + }, + }, + { + Pad: test.Pad{ID: "GPP_B3", DW0: 0x44444444, DW1: 0x44444444, Ownership: 1}, + Macro: test.Macro{ + Short: "PAD_CFG_NF(GPP_B3, INVALID, DEEP, NF1),", + Long: "_PAD_CFG_STRUCT(GPP_B3, PAD_FUNC(NF1) | PAD_RESET(DEEP) | PAD_TRIG(OFF) | PAD_IRQ_ROUTE(SMI), PAD_PULL(INVALID) | PAD_IOSSTATE(Tx0RxDCRx0) | PAD_CFG_OWN_GPIO(DRIVER)),", + }, + }, + { + Pad: test.Pad{ID: "GPP_D4", DW0: 0x88888888, DW1: 0x88888888, Ownership: 0}, + Macro: test.Macro{ + Short: "PAD_CFG_NF(GPP_D4, DN_5K, PLTRST, NF2),", + Long: "_PAD_CFG_STRUCT(GPP_D4, PAD_FUNC(NF2) | PAD_RESET(PLTRST) | PAD_IRQ_ROUTE(SCI) | PAD_RX_POL(INVERT), PAD_PULL(DN_5K) | PAD_IOSSTATE(Tx0RxDCRx1)),", + }, + }, + }.Run(t, "INTEL-TIGER-LAKE-PCH/SLIDING-ONE-IN-NIBBLE-TEST", tigerlake) + + test.Suite{ + { + Pad: test.Pad{ID: "GPP_C5", DW0: 0xEEEEEEEE, DW1: 0xEEEEEEEE, Ownership: 1}, + Macro: test.Macro{ + Short: "PAD_CFG_NF_1V8(GPP_C5, UP_2K, RSMRST, NF3),", + Long: "_PAD_CFG_STRUCT(GPP_C5, PAD_FUNC(NF3) | PAD_RESET(RSMRST) | PAD_TRIG(EDGE_BOTH) | PAD_IRQ_ROUTE(SCI) | PAD_IRQ_ROUTE(SMI) | PAD_IRQ_ROUTE(NMI) | PAD_RX_POL(INVERT) | PAD_BUF(RX_DISABLE) | (1 << 29) | (1 << 1), PAD_CFG1_TOL_1V8PAD_PULL(UP_2K) | PAD_IOSSTATE(IGNORE) | PAD_IOSTERM(ENPD) | PAD_CFG_OWN_GPIO(DRIVER)),", + }, + }, + { + Pad: test.Pad{ID: "GPP_S6", DW0: 0xDDDDDDDD, DW1: 0xDDDDDDDD, Ownership: 0}, + Macro: test.Macro{ + Short: "PAD_CFG_NF(GPP_S6, INVALID, RSMRST, NF7),", + Long: "_PAD_CFG_STRUCT(GPP_S6, PAD_FUNC(NF7) | PAD_RESET(RSMRST) | PAD_TRIG(OFF) | PAD_IRQ_ROUTE(IOAPIC) | PAD_IRQ_ROUTE(SCI) | PAD_IRQ_ROUTE(SMI) | PAD_RX_POL(INVERT) | PAD_BUF(TX_DISABLE) | (1 << 28) | 1, PAD_PULL(INVALID) | PAD_IOSSTATE(HIZCRx0) | PAD_IOSTERM(DISPUPD)),", + }, + }, + { + Pad: test.Pad{ID: "GPP_G7", DW0: 0xBBBBBBBB, DW1: 0xBBBBBBBB, Ownership: 1}, + Macro: test.Macro{ + Short: "PAD_CFG_NF_1V8(GPP_G7, INVALID, PLTRST, NF6),", + Long: "_PAD_CFG_STRUCT(GPP_G7, PAD_FUNC(NF6) | PAD_RESET(PLTRST) | PAD_TRIG(EDGE_SINGLE) | PAD_IRQ_ROUTE(IOAPIC) | PAD_IRQ_ROUTE(SCI) | PAD_IRQ_ROUTE(NMI) | PAD_RX_POL(INVERT) | PAD_BUF(TX_RX_DISABLE) | (1 << 29) | (1 << 28) | (1 << 1) | 1, PAD_CFG1_TOL_1V8PAD_PULL(INVALID) | PAD_IOSSTATE(IGNORE) | PAD_IOSTERM(ENPU) | PAD_CFG_OWN_GPIO(DRIVER)),", + }, + }, + { + Pad: test.Pad{ID: "GPD8", DW0: 0x77777777, DW1: 0x77777777, Ownership: 0}, + Macro: test.Macro{ + Short: "PAD_CFG_NF_1V8(GPD8, UP_667, DEEP, NF5),", + Long: "_PAD_CFG_STRUCT(GPD8, PAD_FUNC(NF5) | PAD_RESET(DEEP) | PAD_TRIG(EDGE_BOTH) | PAD_IRQ_ROUTE(IOAPIC) | PAD_IRQ_ROUTE(SMI) | PAD_IRQ_ROUTE(NMI) | PAD_BUF(TX_RX_DISABLE) | (1 << 29) | (1 << 28) | (1 << 1) | 1, PAD_CFG1_TOL_1V8PAD_PULL(UP_667) | PAD_IOSSTATE(IGNORE) | PAD_IOSTERM(ENPU)),", + }, + }, + }.Run(t, "INTEL-TIGER-LAKE-PCH/SLIDING-ZERO-IN-NIBBLE-TEST", tigerlake) + + test.Suite{ + { + Pad: test.Pad{ID: "GPP_E9", DW0: 0x33333333, DW1: 0x33333333, Ownership: 1}, + Macro: test.Macro{ + Short: "PAD_CFG_NF_1V8(GPP_E9, UP_20K, RSMRST, NF4),", + Long: "_PAD_CFG_STRUCT(GPP_E9, PAD_FUNC(NF4) | PAD_RESET(RSMRST) | PAD_TRIG(EDGE_SINGLE) | PAD_IRQ_ROUTE(IOAPIC) | PAD_IRQ_ROUTE(NMI) | PAD_BUF(TX_RX_DISABLE) | (1 << 29) | (1 << 28) | (1 << 1) | 1, PAD_CFG1_TOL_1V8PAD_PULL(UP_20K) | PAD_IOSSTATE(IGNORE) | PAD_IOSTERM(ENPU) | PAD_CFG_OWN_GPIO(DRIVER)),", + }, + }, + { + Pad: test.Pad{ID: "GPP_F10", DW0: 0x66666666, DW1: 0x66666666, Ownership: 0}, + Macro: test.Macro{ + Short: "PAD_CFG_NF_1V8(GPP_F10, UP_1K, DEEP, NF1),", + Long: "_PAD_CFG_STRUCT(GPP_F10, PAD_FUNC(NF1) | PAD_RESET(DEEP) | PAD_TRIG(EDGE_BOTH) | PAD_IRQ_ROUTE(SMI) | PAD_IRQ_ROUTE(NMI) | PAD_BUF(RX_DISABLE) | (1 << 29) | (1 << 1), PAD_CFG1_TOL_1V8PAD_PULL(UP_1K) | PAD_IOSSTATE(TxDRxE) | PAD_IOSTERM(ENPD)),", + }, + }, + { + Pad: test.Pad{ID: "GPP_H11", DW0: 0xCCCCCCCC, DW1: 0xCCCCCCCC, Ownership: 1}, + Macro: test.Macro{ + Short: "PAD_CFG_NF(GPP_H11, INVALID, RSMRST, NF3),", + Long: "_PAD_CFG_STRUCT(GPP_H11, PAD_FUNC(NF3) | PAD_RESET(RSMRST) | PAD_TRIG(OFF) | PAD_IRQ_ROUTE(SCI) | PAD_IRQ_ROUTE(SMI) | PAD_RX_POL(INVERT), PAD_PULL(INVALID) | PAD_IOSSTATE(Tx1RxDCRx0) | PAD_CFG_OWN_GPIO(DRIVER)),", + }, + }, + { + Pad: test.Pad{ID: "GPP_J12", DW0: 0x99999999, DW1: 0x99999999, Ownership: 0}, + Macro: test.Macro{ + Short: "PAD_CFG_NF(GPP_J12, INVALID, PLTRST, NF6),", + Long: "_PAD_CFG_STRUCT(GPP_J12, PAD_FUNC(NF6) | PAD_RESET(PLTRST) | PAD_IRQ_ROUTE(IOAPIC) | PAD_IRQ_ROUTE(SCI) | PAD_RX_POL(INVERT) | PAD_BUF(TX_DISABLE) | (1 << 28) | 1, PAD_PULL(INVALID) | PAD_IOSSTATE(Tx1RxE) | PAD_IOSTERM(DISPUPD)),", + }, + }, + }.Run(t, "INTEL-TIGER-LAKE-PCH/SLIDING-ONE-ONE-IN-NIBBLE-TEST", tigerlake) +}