Debian Codegraph @

util/intelp2m/platforms/common/common.go

raw symbols SCIP
1 package common
2
3 import (
4 "fmt"
5
6 "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common/register"
7 "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common/register/bits"
8 )
9
10 type ResetSources map[uint32]uint32
11
12 type BasePlatform struct {
13 dw0 register.DW0
14 dw1 register.DW1
15 }
16
17 func InitBasePlatform(dw0, dw0Mask uint32, dw1, dw1Mask uint32) BasePlatform {
18 return BasePlatform{
19 register.SetVal[register.DW0](dw0, dw0Mask),
20 register.SetVal[register.DW1](dw1, dw1Mask),
21 }
22 }
23
24 func (p *BasePlatform) GetRegisterDW0() *register.DW0 {
25 return &p.dw0
26 }
27
28 func (p *BasePlatform) GetRegisterDW1() *register.DW1 {
29 return &p.dw1
30 }
31
32 // UpdateResetSource() updates the Pad Reset configuration fields in the DW0 register according
33 // to the ResetSources{} map. Redefine this function for the corresponding platform if it has a
34 // difference in logic or register bits.
35 func (p *BasePlatform) UpdateResetSource(remapping ResetSources) error {
36 dw0 := p.GetRegisterDW0()
37 mask := bits.DW0[bits.DW0PadRstCfg]
38 source, valid := remapping[dw0.GetResetConfig()]
39 if !valid {
40 dw0.CntrMaskFieldsClear(mask)
41 return fmt.Errorf("invalid reset config source value 0b%b", dw0.GetResetConfig())
42 }
43 dw0.Value &= ^mask
44 dw0.Value |= source
45 dw0.CntrMaskFieldsClear(mask)
46 return nil
47 }