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>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85731
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: David Hendricks <david.hendricks@gmail.com>
This commit is contained in:
Maxim Polyakov 2024-12-22 12:50:47 +03:00 committed by Felix Singer
commit e833b4661d
11 changed files with 107 additions and 147 deletions

View file

@ -14,6 +14,13 @@ const (
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,30 +35,15 @@ func GetPlatform(dw0, dw1 uint32) common.PlatformIf {
return &p
}
// Override BasePlatform.RemapRstSrc()
func (p *BasePlatform) RemapRstSrc(m *common.Macro) {
// Override BasePlatform.RemapResetSource()
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/gpio.c#L21
// 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,
if err := p.UpdateResetSource(remapping); err != nil {
logs.Errorf("remap reset source for %s: %v", m.GetPadId(), err)
}
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)
}

View file

@ -25,8 +25,8 @@ func GetPlatform(dw0, dw1 uint32) common.PlatformIf {
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) {

View file

@ -15,6 +15,12 @@ const (
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,8 +35,8 @@ func GetPlatform(dw0, dw1 uint32) common.PlatformIf {
return &p
}
// Override BasePlatform.RemapRstSrc()
func (p *BasePlatform) RemapRstSrc(m *common.Macro) {
// Override BasePlatform.RemapResetSource()
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") {
@ -39,23 +45,9 @@ func (p *BasePlatform) RemapRstSrc(m *common.Macro) {
// 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 err := p.UpdateResetSource(remapping); err != nil {
logs.Errorf("remap reset source for %s: %v", m.GetPadId(), err)
}
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)
}
// Override BasePlatform.Pull()

View file

@ -1,9 +1,14 @@
package common
import (
"fmt"
"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 +28,20 @@ func (p *BasePlatform) GetRegisterDW0() *register.DW0 {
func (p *BasePlatform) GetRegisterDW1() *register.DW1 {
return &p.dw1
}
// UpdateResetSource() updates the Pad Reset configuration fields in the DW0 register according
// to the ResetSources{} map. Redefine this function for the corresponding platform if it has a
// difference in logic or register bits.
func (p *BasePlatform) UpdateResetSource(remapping ResetSources) error {
dw0 := p.GetRegisterDW0()
mask := bits.DW0[bits.DW0PadRstCfg]
source, valid := remapping[dw0.GetResetConfig()]
if !valid {
dw0.CntrMaskFieldsClear(mask)
return fmt.Errorf("invalid reset config source value 0b%b", dw0.GetResetConfig())
}
dw0.Value &= ^mask
dw0.Value |= source
dw0.CntrMaskFieldsClear(mask)
return nil
}

View file

@ -22,7 +22,7 @@ type FieldsIf interface {
}
type PlatformIf interface {
RemapRstSrc(*Macro)
RemapResetSource(*Macro)
Pull(*Macro)
AddGpiMacro(*Macro)
AddGpoMacro(*Macro)
@ -352,7 +352,7 @@ func (m *Macro) Bidirection() {
// 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

View file

@ -12,6 +12,12 @@ const (
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,22 +32,9 @@ func GetPlatform(dw0, dw1 uint32) common.PlatformIf {
return &p
}
// Override BasePlatform.RemapRstSrc()
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,
// Override BasePlatform.RemapResetSource()
func (p *BasePlatform) RemapResetSource(m *common.Macro) {
if err := p.UpdateResetSource(remapping); err != nil {
logs.Errorf("remap reset source for %s: %v", m.GetPadId(), err)
}
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)
}

View file

@ -14,6 +14,12 @@ const (
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,8 +34,8 @@ func GetPlatform(dw0, dw1 uint32) common.PlatformIf {
return &p
}
// Override the base platform method
func (p *BasePlatform) RemapRstSrc(m *common.Macro) {
// Override BasePlatform.RemapResetSource()
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") ||
@ -40,21 +46,7 @@ func (p *BasePlatform) RemapRstSrc(m *common.Macro) {
// 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,
if err := p.UpdateResetSource(remapping); err != nil {
logs.Errorf("remap reset source for %s: %v", m.GetPadId(), err)
}
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)
}

View file

@ -12,6 +12,12 @@ const (
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,23 +32,9 @@ func GetPlatform(dw0, dw1 uint32) common.PlatformIf {
return &p
}
// Override the base platform method
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,
// Override BasePlatform.RemapResetSource()
func (p *BasePlatform) RemapResetSource(m *common.Macro) {
if err := p.UpdateResetSource(remapping); err != nil {
logs.Errorf("remap reset source for %s: %v", m.GetPadId(), err)
}
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)
}

View file

@ -14,6 +14,13 @@ const (
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,30 +35,15 @@ func GetPlatform(dw0, dw1 uint32) common.PlatformIf {
return &p
}
// Override the base platform method
func (p *BasePlatform) RemapRstSrc(m *common.Macro) {
// Override BasePlatform.RemapResetSource()
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/gpio.c#L10
// 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,
if err := p.UpdateResetSource(remapping); err != nil {
logs.Errorf("remap reset source for %s: %v", m.GetPadId(), err)
}
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)
}

View file

@ -14,6 +14,12 @@ const (
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,16 @@ func GetPlatform(dw0, dw1 uint32) common.PlatformIf {
}
// 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.c#L15
// 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 err := p.UpdateResetSource(remapping); err != nil {
logs.Errorf("remap reset source for %s: %v", m.GetPadId(), err)
}
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])
}
// Pull() adds The Pad Termination (TERM) parameter from PAD_CFG_DW1 to the macro

View file

@ -14,6 +14,12 @@ const (
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,29 +34,15 @@ func GetPlatform(dw0, dw1 uint32) common.PlatformIf {
return &p
}
// Override BasePlatform.RemapRstSrc()
func (p *BasePlatform) RemapRstSrc(m *common.Macro) {
// Override BasePlatform.RemapResetSource()
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/gpio.c#L21
// 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,
if err := p.UpdateResetSource(remapping); err != nil {
logs.Errorf("remap reset source for %s: %v", m.GetPadId(), err)
}
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)
}