Maxim has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/85731?usp=email )
Change subject: util/intelp2m: Move remapping reset source to common ......................................................................
util/intelp2m: Move remapping reset source to common
TEST: 'make test' = PASS
Change-Id: I315541b12f5f1fdf7c97c2ff8ddd305e30a447cc Signed-off-by: Maxim Polyakov max.senia.poliak@gmail.com --- M util/intelp2m/platforms/adl/macro.go M util/intelp2m/platforms/apl/macro.go M util/intelp2m/platforms/cnl/macro.go M util/intelp2m/platforms/common/common.go M util/intelp2m/platforms/common/macro.go M util/intelp2m/platforms/ebg/macro.go M util/intelp2m/platforms/jsl/macro.go M util/intelp2m/platforms/lbg/macro.go M util/intelp2m/platforms/mtl/macro.go M util/intelp2m/platforms/snr/macro.go M util/intelp2m/platforms/tgl/macro.go 11 files changed, 90 insertions(+), 155 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/31/85731/1
diff --git a/util/intelp2m/platforms/adl/macro.go b/util/intelp2m/platforms/adl/macro.go index c4a04ed..b53eecb 100644 --- a/util/intelp2m/platforms/adl/macro.go +++ b/util/intelp2m/platforms/adl/macro.go @@ -3,7 +3,6 @@ import ( "strings"
- "review.coreboot.org/coreboot.git/util/intelp2m/logs" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/cnl" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common/register/bits" @@ -14,6 +13,13 @@ DW1Mask uint32 = 0b11111101111111111100001111111111 )
+var remapping = common.ResetSources{ + 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, + 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, + 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, + 0b11: bits.RstCfgPWROK << bits.DW0PadRstCfg, +} + type BasePlatform struct { // based on the Cannon Lake platform cnl.BasePlatform @@ -28,32 +34,15 @@ return &p }
-// RemapRstSrc() remaps Pad Reset Source Config -func (p *BasePlatform) RemapRstSrc(m *common.Macro) { +// RemapResetSource() remaps Pad Reset Source Config +func (p *BasePlatform) RemapResetSource(m *common.Macro) { if strings.Contains(m.GetPadId(), "GPD") { // See reset map for the Alderlake GPD Group in the Community 2: // https://github.com/coreboot/coreboot/blob/master/src/soc/intel/alderlake/gpi... // remmap is not required because it is the same as common. return } - - remapping := map[uint32]uint32{ - 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, - 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, - 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, - 0b11: bits.RstCfgPWROK << bits.DW0PadRstCfg, - } - dw0 := p.GetRegisterDW0() - source, valid := remapping[dw0.GetResetConfig()] - if valid { - dw0.Value &= 0x3fffffff - dw0.Value |= source - } else { - logs.Errorf("%s: skip re-mapping: DW0 %s: invalid reset config source value 0b%b", - m.GetPadId(), dw0, dw0.GetResetConfig()) - } - mask := bits.DW0[bits.DW0PadRstCfg] - dw0.CntrMaskFieldsClear(mask) + p.BasePlatform.UpdateResetSource(m.GetPadId(), remapping) }
func (p *BasePlatform) Pull(m *common.Macro) { diff --git a/util/intelp2m/platforms/apl/macro.go b/util/intelp2m/platforms/apl/macro.go index f20acc4..614d0be 100644 --- a/util/intelp2m/platforms/apl/macro.go +++ b/util/intelp2m/platforms/apl/macro.go @@ -25,8 +25,8 @@ return &p }
-// RemapRstSrc() remaps Pad Reset Source Config -func (p *BasePlatform) RemapRstSrc(m *common.Macro) {} +// RemapResetSource() remaps Pad Reset Source Config +func (p *BasePlatform) RemapResetSource(m *common.Macro) {}
// Pull() adds The Pad Termination (TERM) parameter from PAD_CFG_DW1 to the macro func (p *BasePlatform) Pull(m *common.Macro) { diff --git a/util/intelp2m/platforms/cnl/macro.go b/util/intelp2m/platforms/cnl/macro.go index de9bfc7..654fc66 100644 --- a/util/intelp2m/platforms/cnl/macro.go +++ b/util/intelp2m/platforms/cnl/macro.go @@ -15,6 +15,12 @@ DW1Mask uint32 = 0b11111101111111111100001111111111 )
+var remapping = common.ResetSources{ + 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, + 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, + 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, +} + type BasePlatform struct { // based on the Sunrise platform snr.BasePlatform @@ -29,7 +35,7 @@ return &p }
-func (p *BasePlatform) RemapRstSrc(m *common.Macro) { +func (p *BasePlatform) RemapResetSource(m *common.Macro) { if strings.Contains(m.GetPadId(), "GPP_A") || strings.Contains(m.GetPadId(), "GPP_B") || strings.Contains(m.GetPadId(), "GPP_G") { @@ -38,23 +44,7 @@ // remmap is not required because it is the same as common. return } - - dw0 := p.GetRegisterDW0() - remapping := map[uint32]uint32{ - 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, - 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, - 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, - } - source, valid := remapping[dw0.GetResetConfig()] - if valid { - dw0.Value &= 0x3fffffff - dw0.Value |= source - } else { - logs.Errorf("%s: skip re-mapping: DW0 %s: invalid reset config source value 0b%b", - m.GetPadId(), dw0, dw0.GetResetConfig()) - } - mask := bits.DW0[bits.DW0PadRstCfg] - dw0.CntrMaskFieldsClear(mask) + p.BasePlatform.UpdateResetSource(m.GetPadId(), remapping) }
func (p *BasePlatform) Pull(m *common.Macro) { diff --git a/util/intelp2m/platforms/common/common.go b/util/intelp2m/platforms/common/common.go index 5771984..3a7512b 100644 --- a/util/intelp2m/platforms/common/common.go +++ b/util/intelp2m/platforms/common/common.go @@ -1,9 +1,13 @@ package common
import ( + "review.coreboot.org/coreboot.git/util/intelp2m/logs" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common/register" + "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common/register/bits" )
+type ResetSources map[uint32]uint32 + type BasePlatform struct { dw0 register.DW0 dw1 register.DW1 @@ -23,3 +27,18 @@ func (p *BasePlatform) GetRegisterDW1() *register.DW1 { return &p.dw1 } + +// UpdateResetSource() remaps the Pad Reset configuration. +// This function can be redefined in each platform based on the current one. +func (p *BasePlatform) UpdateResetSource(pad string, remapping ResetSources) { + dw0 := p.GetRegisterDW0() + mask := bits.DW0[bits.DW0PadRstCfg] + if source, valid := remapping[dw0.GetResetConfig()]; !valid { + logs.Errorf("%s: skip re-mapping: DW0 %s: invalid reset config source value 0b%b", + pad, dw0, dw0.GetResetConfig()) + } else { + dw0.Value &= ^mask + dw0.Value |= source + } + dw0.CntrMaskFieldsClear(mask) +} diff --git a/util/intelp2m/platforms/common/macro.go b/util/intelp2m/platforms/common/macro.go index 0f544ac..76e76e8 100644 --- a/util/intelp2m/platforms/common/macro.go +++ b/util/intelp2m/platforms/common/macro.go @@ -22,7 +22,7 @@ }
type PlatformIf interface { - RemapRstSrc(*Macro) + RemapResetSource(*Macro) Pull(*Macro) AddGpiMacro(*Macro) AddGpoMacro(*Macro) @@ -352,7 +352,7 @@
// Generate() generates string of macro func (m *Macro) Generate() string { - m.Platform.RemapRstSrc(m) + m.Platform.RemapResetSource(m) if dw0 := m.Platform.GetRegisterDW0(); dw0.GetPadMode() == 0 { const txDisable uint32 = 0b01 const rxDisable uint32 = 0b10 diff --git a/util/intelp2m/platforms/ebg/macro.go b/util/intelp2m/platforms/ebg/macro.go index 9d3d93e..fa03eae 100644 --- a/util/intelp2m/platforms/ebg/macro.go +++ b/util/intelp2m/platforms/ebg/macro.go @@ -1,7 +1,6 @@ package ebg
import ( - "review.coreboot.org/coreboot.git/util/intelp2m/logs" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/cnl" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common/register/bits" @@ -12,6 +11,12 @@ DW1Mask = 0b11111101111111111100001111111111 )
+var remapping = common.ResetSources{ + 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, + 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, + 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, +} + type BasePlatform struct { // based on the Cannon Lake platform cnl.BasePlatform @@ -26,23 +31,8 @@ return &p }
-func (p *BasePlatform) RemapRstSrc(m *common.Macro) { - remapping := map[uint32]uint32{ - 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, - 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, - 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, - } - dw0 := p.GetRegisterDW0() - source, valid := remapping[dw0.GetResetConfig()] - if valid { - dw0.Value &= 0x3fffffff - dw0.Value |= source - } else { - logs.Errorf("%s: skip re-mapping: DW0 %s: invalid reset config source value 0b%b", - m.GetPadId(), dw0, dw0.GetResetConfig()) - } - mask := bits.DW0[bits.DW0PadRstCfg] - dw0.CntrMaskFieldsClear(mask) +func (p *BasePlatform) RemapResetSource(m *common.Macro) { + p.BasePlatform.UpdateResetSource(m.GetPadId(), remapping) }
func (p *BasePlatform) Pull(m *common.Macro) { diff --git a/util/intelp2m/platforms/jsl/macro.go b/util/intelp2m/platforms/jsl/macro.go index 88e2d97..3a0e7d1b 100644 --- a/util/intelp2m/platforms/jsl/macro.go +++ b/util/intelp2m/platforms/jsl/macro.go @@ -3,7 +3,6 @@ import ( "strings"
- "review.coreboot.org/coreboot.git/util/intelp2m/logs" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/cnl" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common/register/bits" @@ -14,6 +13,12 @@ DW1Mask = 0b11111101111111111100001111111111 )
+var remapping = common.ResetSources{ + 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, + 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, + 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, +} + type BasePlatform struct { // based on the Cannon Lake platform cnl.BasePlatform @@ -28,7 +33,7 @@ return &p }
-func (p *BasePlatform) RemapRstSrc(m *common.Macro) { +func (p *BasePlatform) RemapResetSource(m *common.Macro) { if strings.Contains(m.GetPadId(), "GPP_F") || strings.Contains(m.GetPadId(), "GPP_B") || strings.Contains(m.GetPadId(), "GPP_A") || @@ -39,23 +44,7 @@ // remmap is not required because it is the same as common. return } - - remapping := map[uint32]uint32{ - 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, - 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, - 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, - } - dw0 := p.GetRegisterDW0() - source, valid := remapping[dw0.GetResetConfig()] - if valid { - dw0.Value &= 0x3fffffff - dw0.Value |= source - } else { - logs.Errorf("%s: skip re-mapping: DW0 %s: invalid reset config source value 0b%b", - m.GetPadId(), dw0, dw0.GetResetConfig()) - } - mask := bits.DW0[bits.DW0PadRstCfg] - dw0.CntrMaskFieldsClear(mask) + p.BasePlatform.UpdateResetSource(m.GetPadId(), remapping) }
func (p *BasePlatform) Pull(m *common.Macro) { diff --git a/util/intelp2m/platforms/lbg/macro.go b/util/intelp2m/platforms/lbg/macro.go index ffb1572..9720470 100644 --- a/util/intelp2m/platforms/lbg/macro.go +++ b/util/intelp2m/platforms/lbg/macro.go @@ -1,7 +1,6 @@ package lbg
import ( - "review.coreboot.org/coreboot.git/util/intelp2m/logs" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common/register/bits" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/snr" @@ -12,6 +11,12 @@ DW1Mask uint32 = 0b11111101111111111100001111111111 )
+var remapping = common.ResetSources{ + 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, + 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, + 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, +} + type BasePlatform struct { // based on the Sunrise Point platform snr.BasePlatform @@ -26,24 +31,8 @@ return &p }
-func (p *BasePlatform) RemapRstSrc(m *common.Macro) { - dw0 := p.GetRegisterDW0() - remapping := map[uint32]uint32{ - 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, - 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, - 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, - } - source, valid := remapping[dw0.GetResetConfig()] - if valid { - // dw0.SetResetConfig(resetsrc) - dw0.Value &= 0x3fffffff - dw0.Value |= source - } else { - logs.Errorf("%s: skip re-mapping: DW0 %s: invalid reset config source value 0b%b", - m.GetPadId(), dw0, dw0.GetResetConfig()) - } - mask := bits.DW0[bits.DW0PadRstCfg] - dw0.CntrMaskFieldsClear(mask) +func (p *BasePlatform) RemapResetSource(m *common.Macro) { + p.BasePlatform.UpdateResetSource(m.GetPadId(), remapping) }
func (p *BasePlatform) Pull(m *common.Macro) { diff --git a/util/intelp2m/platforms/mtl/macro.go b/util/intelp2m/platforms/mtl/macro.go index 0060f53..705f1ea 100644 --- a/util/intelp2m/platforms/mtl/macro.go +++ b/util/intelp2m/platforms/mtl/macro.go @@ -3,7 +3,6 @@ import ( "strings"
- "review.coreboot.org/coreboot.git/util/intelp2m/logs" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/cnl" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common/register/bits" @@ -14,6 +13,13 @@ DW1Mask = 0b11111101111111111100001111111111 )
+var remapping = common.ResetSources{ + 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, + 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, + 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, + 0b11: bits.RstCfgPWROK << bits.RstCfgPWROK, +} + type BasePlatform struct { // based on the Cannon Lake platform cnl.BasePlatform @@ -28,31 +34,14 @@ return &p }
-func (p *BasePlatform) RemapRstSrc(m *common.Macro) { +func (p *BasePlatform) RemapResetSource(m *common.Macro) { if strings.Contains(m.GetPadId(), "GPD") { // See reset map for the MeteorLake GPD group at // https://github.com/coreboot/coreboot/blob/master/src/soc/intel/meteorlake/gp... // remmap is not required because it is the same as common. return } - - remapping := map[uint32]uint32{ - 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, - 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, - 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, - 0b11: bits.RstCfgPWROK << bits.RstCfgPWROK, - } - dw0 := p.GetRegisterDW0() - source, valid := remapping[dw0.GetResetConfig()] - if valid { - dw0.Value &= 0x3fffffff - dw0.Value |= source - } else { - logs.Errorf("%s: skip re-mapping: DW0 %s: invalid reset config source value 0b%b", - m.GetPadId(), dw0, dw0.GetResetConfig()) - } - mask := bits.DW0[bits.DW0PadRstCfg] - dw0.CntrMaskFieldsClear(mask) + p.BasePlatform.UpdateResetSource(m.GetPadId(), remapping) }
func (p *BasePlatform) Pull(m *common.Macro) { diff --git a/util/intelp2m/platforms/snr/macro.go b/util/intelp2m/platforms/snr/macro.go index 9a4ace4..fb9471c 100644 --- a/util/intelp2m/platforms/snr/macro.go +++ b/util/intelp2m/platforms/snr/macro.go @@ -14,6 +14,12 @@ DW1Mask uint32 = 0b11111101111111111100001111111111 )
+var remapping = common.ResetSources{ + 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, + 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, + 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, +} + type BasePlatform struct { common.BasePlatform } @@ -28,29 +34,14 @@ }
// RemmapRstSrc() remaps Pad Reset Source Config -func (p *BasePlatform) RemapRstSrc(m *common.Macro) { +func (p *BasePlatform) RemapResetSource(m *common.Macro) { if strings.Contains(m.GetPadId(), "GPD") { // See reset map for the Sunrise GPD Group in the Community 2: // https://github.com/coreboot/coreboot/blob/master/src/soc/intel/skylake/gpio.... // remmap is not required because it is the same as common. return } - - dw0 := p.GetRegisterDW0() - remapping := map[uint32]uint32{ - 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, - 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, - 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, - } - - if source, valid := remapping[dw0.GetResetConfig()]; valid { - dw0.Value &= 0x3fffffff - dw0.Value |= source - } else { - logs.Errorf("%s: skip re-mapping: DW0 %s: invalid reset config source value 0b%b", - m.GetPadId(), dw0, dw0.GetResetConfig()) - } - dw0.CntrMaskFieldsClear(bits.DW0[bits.DW0PadRstCfg]) + p.BasePlatform.UpdateResetSource(m.GetPadId(), remapping) }
// Pull() adds The Pad Termination (TERM) parameter from PAD_CFG_DW1 to the macro diff --git a/util/intelp2m/platforms/tgl/macro.go b/util/intelp2m/platforms/tgl/macro.go index f316444..ddc7c86 100644 --- a/util/intelp2m/platforms/tgl/macro.go +++ b/util/intelp2m/platforms/tgl/macro.go @@ -3,7 +3,6 @@ import ( "strings"
- "review.coreboot.org/coreboot.git/util/intelp2m/logs" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/cnl" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common/register/bits" @@ -14,6 +13,12 @@ DW1Mask = 0b11111101111111111100001111111111 )
+var remapping = common.ResetSources{ + 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, + 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, + 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, +} + type BasePlatform struct { // based on the Cannon Lake platform cnl.BasePlatform @@ -28,30 +33,14 @@ return &p }
-func (p *BasePlatform) RemapRstSrc(m *common.Macro) { +func (p *BasePlatform) RemapResetSource(m *common.Macro) { if strings.Contains(m.GetPadId(), "GPD") { // See reset map for the TigerLake Community 2: // https://github.com/coreboot/coreboot/blob/master/src/soc/intel/tigerlake/gpi... // remmap is not required because it is the same as common. return } - - remapping := map[uint32]uint32{ - 0b00: bits.RstCfgRSMRST << bits.DW0PadRstCfg, - 0b01: bits.RstCfgDEEP << bits.DW0PadRstCfg, - 0b10: bits.RstCfgPLTRST << bits.DW0PadRstCfg, - } - dw0 := p.GetRegisterDW0() - source, valid := remapping[dw0.GetResetConfig()] - if valid { - dw0.Value &= 0x3fffffff - dw0.Value |= source - } else { - logs.Errorf("%s: skip re-mapping: DW0 %s: invalid reset config source value 0b%b", - m.GetPadId(), dw0, dw0.GetResetConfig()) - } - mask := bits.DW0[bits.DW0PadRstCfg] - dw0.CntrMaskFieldsClear(mask) + p.BasePlatform.UpdateResetSource(m.GetPadId(), remapping) }
func (p *BasePlatform) Pull(m *common.Macro) {