cbfs: Remove remnants of ext-win-*
[coreboot2.git] / util / intelp2m / platforms / ebg / macro.go
blob64d6f324090d2cefb9b3deda8d8f5c742d1b66c5
1 package ebg
3 import (
4 "fmt"
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"
10 "review.coreboot.org/coreboot.git/util/intelp2m/platforms/cnl"
13 const (
14 PAD_CFG_DW0_RO_FIELDS = (0x1 << 27) | (0x1 << 24) | (0x3 << 21) | (0xf << 16) | 0xfc
15 PAD_CFG_DW1_RO_FIELDS = 0xfdffc3ff
18 const (
19 PAD_CFG_DW0 = common.PAD_CFG_DW0
20 PAD_CFG_DW1 = common.PAD_CFG_DW1
21 MAX_DW_NUM = common.MAX_DW_NUM
24 type InheritanceMacro interface {
25 Pull()
26 GpiMacroAdd()
27 GpoMacroAdd()
28 NativeFunctionMacroAdd()
29 NoConnMacroAdd()
32 type PlatformSpecific struct {
33 InheritanceMacro
34 InheritanceTemplate
37 // RemmapRstSrc - remmap Pad Reset Source Config
38 func (PlatformSpecific) RemmapRstSrc() {
39 macro := common.GetMacro()
40 if config.TemplateGet() != config.TempInteltool {
41 // Use reset source remapping only if the input file is inteltool.log dump
42 return
44 dw0 := macro.Register(PAD_CFG_DW0)
45 var remapping = map[uint8]uint32{
46 0: common.RST_RSMRST << common.PadRstCfgShift,
47 1: common.RST_DEEP << common.PadRstCfgShift,
48 2: common.RST_PLTRST << common.PadRstCfgShift,
50 resetsrc, valid := remapping[dw0.GetResetConfig()]
51 if valid {
52 // dw0.SetResetConfig(resetsrc)
53 ResetConfigFieldVal := (dw0.ValueGet() & 0x3fffffff) | remapping[dw0.GetResetConfig()]
54 dw0.ValueSet(ResetConfigFieldVal)
55 } else {
56 fmt.Println("Invalid Pad Reset Config [ 0x", resetsrc ," ] for ", macro.PadIdGet())
58 dw0.CntrMaskFieldsClear(common.PadRstCfgMask)
61 // Adds The Pad Termination (TERM) parameter from PAD_CFG_DW1 to the macro
62 // as a new argument
63 func (platform PlatformSpecific) Pull() {
64 platform.InheritanceMacro.Pull()
67 // Adds PAD_CFG_GPI macro with arguments
68 func (platform PlatformSpecific) GpiMacroAdd() {
69 platform.InheritanceMacro.GpiMacroAdd()
72 // Adds PAD_CFG_GPO macro with arguments
73 func (platform PlatformSpecific) GpoMacroAdd() {
74 platform.InheritanceMacro.GpoMacroAdd()
77 // Adds PAD_CFG_NF macro with arguments
78 func (platform PlatformSpecific) NativeFunctionMacroAdd() {
79 platform.InheritanceMacro.NativeFunctionMacroAdd()
82 // Adds PAD_NC macro
83 func (platform PlatformSpecific) NoConnMacroAdd() {
84 platform.InheritanceMacro.NoConnMacroAdd()
87 // GenMacro - generate pad macro
88 // dw0 : DW0 config register value
89 // dw1 : DW1 config register value
90 // return: string of macro
91 // error
92 func (platform PlatformSpecific) GenMacro(id string, dw0 uint32, dw1 uint32, ownership uint8) string {
93 macro := common.GetInstanceMacro(
94 PlatformSpecific{
95 InheritanceMacro : cnl.PlatformSpecific{
96 InheritanceMacro : snr.PlatformSpecific{},
99 fields.InterfaceGet(),
101 macro.Clear()
102 macro.Register(PAD_CFG_DW0).CntrMaskFieldsClear(common.AllFields)
103 macro.Register(PAD_CFG_DW1).CntrMaskFieldsClear(common.AllFields)
104 macro.PadIdSet(id).SetPadOwnership(ownership)
105 macro.Register(PAD_CFG_DW0).ValueSet(dw0).ReadOnlyFieldsSet(PAD_CFG_DW0_RO_FIELDS)
106 macro.Register(PAD_CFG_DW1).ValueSet(dw1).ReadOnlyFieldsSet(PAD_CFG_DW1_RO_FIELDS)
107 return macro.Generate()