arch/arm64: Support FEAT_CCIDX
[coreboot2.git] / util / intelp2m / platforms / tgl / macro.go
blob3b436ee3bbf115325013462c60d77d98912f5f3b
1 package tgl
3 import (
4 "strings"
5 "fmt"
7 "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common"
8 "review.coreboot.org/coreboot.git/util/intelp2m/platforms/snr"
9 "review.coreboot.org/coreboot.git/util/intelp2m/platforms/cnl"
10 "review.coreboot.org/coreboot.git/util/intelp2m/config"
11 "review.coreboot.org/coreboot.git/util/intelp2m/fields"
14 const (
15 PAD_CFG_DW0_RO_FIELDS = (0x1 << 27) | (0x1 << 24) | (0x3 << 21) | (0xf << 16) | 0xfc
16 PAD_CFG_DW1_RO_FIELDS = 0xfdffc3ff
19 const (
20 PAD_CFG_DW0 = common.PAD_CFG_DW0
21 PAD_CFG_DW1 = common.PAD_CFG_DW1
22 MAX_DW_NUM = common.MAX_DW_NUM
25 type InheritanceMacro interface {
26 Pull()
27 GpiMacroAdd()
28 GpoMacroAdd()
29 NativeFunctionMacroAdd()
30 NoConnMacroAdd()
33 type PlatformSpecific struct {
34 InheritanceMacro
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 if strings.Contains(macro.PadIdGet(), "GPD") {
45 // See reset map for the TigerLake Community 2:
46 // https://github.com/coreboot/coreboot/blob/master/src/soc/intel/tigerlake/gpio.c#L21
47 // remmap is not required because it is the same as common.
48 return
51 dw0 := macro.Register(PAD_CFG_DW0)
52 var remapping = map[uint8]uint32{
53 0: common.RST_RSMRST << common.PadRstCfgShift,
54 1: common.RST_DEEP << common.PadRstCfgShift,
55 2: common.RST_PLTRST << common.PadRstCfgShift,
57 resetsrc, valid := remapping[dw0.GetResetConfig()]
58 if valid {
59 // dw0.SetResetConfig(resetsrc)
60 ResetConfigFieldVal := (dw0.ValueGet() & 0x3fffffff) | remapping[dw0.GetResetConfig()]
61 dw0.ValueSet(ResetConfigFieldVal)
62 } else {
63 fmt.Println("Invalid Pad Reset Config [ 0x", resetsrc ," ] for ", macro.PadIdGet())
65 dw0.CntrMaskFieldsClear(common.PadRstCfgMask)
68 // Adds The Pad Termination (TERM) parameter from PAD_CFG_DW1 to the macro
69 // as a new argument
70 func (platform PlatformSpecific) Pull() {
71 platform.InheritanceMacro.Pull()
74 // Adds PAD_CFG_GPI macro with arguments
75 func (platform PlatformSpecific) GpiMacroAdd() {
76 platform.InheritanceMacro.GpiMacroAdd()
79 // Adds PAD_CFG_GPO macro with arguments
80 func (platform PlatformSpecific) GpoMacroAdd() {
81 platform.InheritanceMacro.GpoMacroAdd()
84 // Adds PAD_CFG_NF macro with arguments
85 func (platform PlatformSpecific) NativeFunctionMacroAdd() {
86 platform.InheritanceMacro.NativeFunctionMacroAdd()
89 // Adds PAD_NC macro
90 func (platform PlatformSpecific) NoConnMacroAdd() {
91 platform.InheritanceMacro.NoConnMacroAdd()
94 // GenMacro - generate pad macro
95 // dw0 : DW0 config register value
96 // dw1 : DW1 config register value
97 // return: string of macro
98 // error
99 func (PlatformSpecific) GenMacro(id string, dw0 uint32, dw1 uint32, ownership uint8) string {
100 macro := common.GetInstanceMacro(
101 PlatformSpecific{
102 InheritanceMacro: cnl.PlatformSpecific{
103 InheritanceMacro: snr.PlatformSpecific{},
106 fields.InterfaceGet(),
108 macro.Clear()
109 macro.Register(PAD_CFG_DW0).CntrMaskFieldsClear(common.AllFields)
110 macro.Register(PAD_CFG_DW1).CntrMaskFieldsClear(common.AllFields)
111 macro.PadIdSet(id).SetPadOwnership(ownership)
112 macro.Register(PAD_CFG_DW0).ValueSet(dw0).ReadOnlyFieldsSet(PAD_CFG_DW0_RO_FIELDS)
113 macro.Register(PAD_CFG_DW1).ValueSet(dw1).ReadOnlyFieldsSet(PAD_CFG_DW1_RO_FIELDS)
114 return macro.Generate()