arch/arm64: Support FEAT_CCIDX
[coreboot2.git] / util / intelp2m / platforms / lbg / macro.go
blobdb34f8e6cfc8c3fceecd2e092fce6e132e1b2202
1 package lbg
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"
12 const (
13 PAD_CFG_DW0_RO_FIELDS = (0x1 << 27) | (0x1 << 24) | (0x3 << 21) | (0xf << 16) | 0xfc
14 PAD_CFG_DW1_RO_FIELDS = 0xfdffc3ff
17 const (
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 {
24 Pull()
25 GpiMacroAdd()
26 GpoMacroAdd()
27 NativeFunctionMacroAdd()
28 NoConnMacroAdd()
31 type PlatformSpecific struct {
32 InheritanceMacro
33 InheritanceTemplate
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
41 return
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()]
50 if valid {
51 // dw0.SetResetConfig(resetsrc)
52 ResetConfigFieldVal := (dw0.ValueGet() & 0x3fffffff) | remapping[dw0.GetResetConfig()]
53 dw0.ValueSet(ResetConfigFieldVal)
54 } else {
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
61 // as a new argument
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()
81 // Adds PAD_NC macro
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
90 // error
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())
96 macro.Clear()
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()