6 "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common"
7 "review.coreboot.org/coreboot.git/util/intelp2m/config"
8 "review.coreboot.org/coreboot.git/util/intelp2m/fields"
9 "review.coreboot.org/coreboot.git/util/intelp2m/platforms/snr"
13 PAD_CFG_DW0_RO_FIELDS
= (0x1 << 27) |
(0x1 << 24) |
(0x3 << 21) |
(0xf << 16) |
0xfc
14 PAD_CFG_DW1_RO_FIELDS
= 0xfdffc3ff
18 PAD_CFG_DW0
= common
.PAD_CFG_DW0
19 PAD_CFG_DW1
= common
.PAD_CFG_DW1
20 MAX_DW_NUM
= common
.MAX_DW_NUM
23 type InheritanceMacro
interface {
27 NativeFunctionMacroAdd()
31 type PlatformSpecific
struct {
36 // RemmapRstSrc - remmap Pad Reset Source Config
37 func (PlatformSpecific
) RemmapRstSrc() {
38 macro
:= common
.GetMacro()
39 if config
.TemplateGet() != config
.TempInteltool
{
40 // Use reset source remapping only if the input file is inteltool.log dump
43 dw0
:= macro
.Register(PAD_CFG_DW0
)
44 var remapping
= map[uint8]uint32{
45 0: common
.RST_RSMRST
<< common
.PadRstCfgShift
,
46 1: common
.RST_DEEP
<< common
.PadRstCfgShift
,
47 2: common
.RST_PLTRST
<< common
.PadRstCfgShift
,
49 resetsrc
, valid
:= remapping
[dw0
.GetResetConfig()]
51 // dw0.SetResetConfig(resetsrc)
52 ResetConfigFieldVal
:= (dw0
.ValueGet() & 0x3fffffff) | remapping
[dw0
.GetResetConfig()]
53 dw0
.ValueSet(ResetConfigFieldVal
)
55 fmt
.Println("Invalid Pad Reset Config [ 0x", resetsrc
," ] for ", macro
.PadIdGet())
57 dw0
.CntrMaskFieldsClear(common
.PadRstCfgMask
)
60 // Adds The Pad Termination (TERM) parameter from PAD_CFG_DW1 to the macro
62 func (platform PlatformSpecific
) Pull() {
63 platform
.InheritanceMacro
.Pull()
66 // Adds PAD_CFG_GPI macro with arguments
67 func (platform PlatformSpecific
) GpiMacroAdd() {
68 platform
.InheritanceMacro
.GpiMacroAdd()
71 // Adds PAD_CFG_GPO macro with arguments
72 func (platform PlatformSpecific
) GpoMacroAdd() {
73 platform
.InheritanceMacro
.GpoMacroAdd()
76 // Adds PAD_CFG_NF macro with arguments
77 func (platform PlatformSpecific
) NativeFunctionMacroAdd() {
78 platform
.InheritanceMacro
.NativeFunctionMacroAdd()
82 func (platform PlatformSpecific
) NoConnMacroAdd() {
83 platform
.InheritanceMacro
.NoConnMacroAdd()
86 // GenMacro - generate pad macro
87 // dw0 : DW0 config register value
88 // dw1 : DW1 config register value
89 // return: string of macro
91 func (platform PlatformSpecific
) GenMacro(id
string, dw0
uint32, dw1
uint32, ownership
uint8) string {
92 // The GPIO controller architecture in Lewisburg and Sunrise are very similar,
93 // so we will inherit some platform-dependent functions from Sunrise.
94 macro
:= common
.GetInstanceMacro(PlatformSpecific
{InheritanceMacro
: snr
.PlatformSpecific
{}},
95 fields
.InterfaceGet())
97 macro
.Register(PAD_CFG_DW0
).CntrMaskFieldsClear(common
.AllFields
)
98 macro
.Register(PAD_CFG_DW0
).CntrMaskFieldsClear(common
.AllFields
)
99 macro
.PadIdSet(id
).SetPadOwnership(ownership
)
100 macro
.Register(PAD_CFG_DW0
).ValueSet(dw0
).ReadOnlyFieldsSet(PAD_CFG_DW0_RO_FIELDS
)
101 macro
.Register(PAD_CFG_DW1
).ValueSet(dw1
).ReadOnlyFieldsSet(PAD_CFG_DW1_RO_FIELDS
)
102 return macro
.Generate()