Fabian Meyer | 92e372b | 2024-05-06 16:54:48 +0200 | [diff] [blame^] | 1 | package ebg |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 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" |
| 11 | ) |
| 12 | |
| 13 | const ( |
| 14 | PAD_CFG_DW0_RO_FIELDS = (0x1 << 27) | (0x1 << 24) | (0x3 << 21) | (0xf << 16) | 0xfc |
| 15 | PAD_CFG_DW1_RO_FIELDS = 0xfdffc3ff |
| 16 | ) |
| 17 | |
| 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 |
| 22 | ) |
| 23 | |
| 24 | type InheritanceMacro interface { |
| 25 | Pull() |
| 26 | GpiMacroAdd() |
| 27 | GpoMacroAdd() |
| 28 | NativeFunctionMacroAdd() |
| 29 | NoConnMacroAdd() |
| 30 | } |
| 31 | |
| 32 | type PlatformSpecific struct { |
| 33 | InheritanceMacro |
| 34 | InheritanceTemplate |
| 35 | } |
| 36 | |
| 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 |
| 43 | } |
| 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, |
| 49 | } |
| 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()) |
| 57 | } |
| 58 | dw0.CntrMaskFieldsClear(common.PadRstCfgMask) |
| 59 | } |
| 60 | |
| 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() |
| 65 | } |
| 66 | |
| 67 | // Adds PAD_CFG_GPI macro with arguments |
| 68 | func (platform PlatformSpecific) GpiMacroAdd() { |
| 69 | platform.InheritanceMacro.GpiMacroAdd() |
| 70 | } |
| 71 | |
| 72 | // Adds PAD_CFG_GPO macro with arguments |
| 73 | func (platform PlatformSpecific) GpoMacroAdd() { |
| 74 | platform.InheritanceMacro.GpoMacroAdd() |
| 75 | } |
| 76 | |
| 77 | // Adds PAD_CFG_NF macro with arguments |
| 78 | func (platform PlatformSpecific) NativeFunctionMacroAdd() { |
| 79 | platform.InheritanceMacro.NativeFunctionMacroAdd() |
| 80 | } |
| 81 | |
| 82 | // Adds PAD_NC macro |
| 83 | func (platform PlatformSpecific) NoConnMacroAdd() { |
| 84 | platform.InheritanceMacro.NoConnMacroAdd() |
| 85 | } |
| 86 | |
| 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{}, |
| 97 | }, |
| 98 | }, |
| 99 | fields.InterfaceGet(), |
| 100 | ) |
| 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() |
| 108 | } |