soc/intel/ptl: Update ME specification version to 21
[coreboot.git] / util / intelp2m / platforms / jsl / macro.go
blob89cf2f0cc7f118803c68124c8e9b176645ba06ac
1 package jsl
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 << 18) | (0x3f << 11) | (0x3f << 2) | (0x1 << 1)
16 PAD_CFG_DW1_RO_FIELDS = 0xdfffc3ff
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(), "GPP_F") ||
45 strings.Contains(macro.PadIdGet(), "GPP_B") ||
46 strings.Contains(macro.PadIdGet(), "GPP_A") ||
47 strings.Contains(macro.PadIdGet(), "GPP_S") ||
48 strings.Contains(macro.PadIdGet(), "GPP_R") {
49 // See reset map for the Jasper Lake Community 0:
50 // https://github.com/coreboot/coreboot/blob/master/src/soc/intel/jasperlake/gpio.c#L21
51 // remmap is not required because it is the same as common.
52 return
55 dw0 := macro.Register(PAD_CFG_DW0)
56 var remapping = map[uint8]uint32{
57 0: common.RST_RSMRST << common.PadRstCfgShift,
58 1: common.RST_DEEP << common.PadRstCfgShift,
59 2: common.RST_PLTRST << common.PadRstCfgShift,
61 resetsrc, valid := remapping[dw0.GetResetConfig()]
62 if valid {
63 // dw0.SetResetConfig(resetsrc)
64 ResetConfigFieldVal := (dw0.ValueGet() & 0x3fffffff) | remapping[dw0.GetResetConfig()]
65 dw0.ValueSet(ResetConfigFieldVal)
66 } else {
67 fmt.Println("Invalid Pad Reset Config [ 0x", resetsrc ," ] for ", macro.PadIdGet())
69 dw0.CntrMaskFieldsClear(common.PadRstCfgMask)
72 // Adds The Pad Termination (TERM) parameter from PAD_CFG_DW1 to the macro
73 // as a new argument
74 func (platform PlatformSpecific) Pull() {
75 platform.InheritanceMacro.Pull()
78 // Adds PAD_CFG_GPI macro with arguments
79 func (platform PlatformSpecific) GpiMacroAdd() {
80 platform.InheritanceMacro.GpiMacroAdd()
83 // Adds PAD_CFG_GPO macro with arguments
84 func (platform PlatformSpecific) GpoMacroAdd() {
85 platform.InheritanceMacro.GpoMacroAdd()
88 // Adds PAD_CFG_NF macro with arguments
89 func (platform PlatformSpecific) NativeFunctionMacroAdd() {
90 platform.InheritanceMacro.NativeFunctionMacroAdd()
93 // Adds PAD_NC macro
94 func (platform PlatformSpecific) NoConnMacroAdd() {
95 platform.InheritanceMacro.NoConnMacroAdd()
98 // GenMacro - generate pad macro
99 // dw0 : DW0 config register value
100 // dw1 : DW1 config register value
101 // return: string of macro
102 // error
103 func (PlatformSpecific) GenMacro(id string, dw0 uint32, dw1 uint32, ownership uint8) string {
104 macro := common.GetInstanceMacro(
105 PlatformSpecific{
106 InheritanceMacro: cnl.PlatformSpecific{
107 InheritanceMacro: snr.PlatformSpecific{},
110 fields.InterfaceGet(),
112 macro.Clear()
113 macro.Register(PAD_CFG_DW0).CntrMaskFieldsClear(common.AllFields)
114 macro.Register(PAD_CFG_DW1).CntrMaskFieldsClear(common.AllFields)
115 macro.PadIdSet(id).SetPadOwnership(ownership)
116 macro.Register(PAD_CFG_DW0).ValueSet(dw0).ReadOnlyFieldsSet(PAD_CFG_DW0_RO_FIELDS)
117 macro.Register(PAD_CFG_DW1).ValueSet(dw1).ReadOnlyFieldsSet(PAD_CFG_DW1_RO_FIELDS)
118 return macro.Generate()