12 PAD_CFG_DW0_RO_FIELDS
= (0x1 << 27) |
(0x1 << 24) |
(0x3 << 21) |
(0xf << 16) |
0xfc
13 PAD_CFG_DW1_RO_FIELDS
= 0xfffc00ff
17 PAD_CFG_DW0
= common
.PAD_CFG_DW0
18 PAD_CFG_DW1
= common
.PAD_CFG_DW1
19 MAX_DW_NUM
= common
.MAX_DW_NUM
23 PULL_NONE
= 0x0 // 0 000: none
24 PULL_DN_5K
= 0x2 // 0 010: 5k wpd (Only available on SMBus GPIOs)
25 PULL_DN_20K
= 0x4 // 0 100: 20k wpd
26 // PULL_NONE = 0x8 // 1 000: none
27 PULL_UP_1K
= 0x9 // 1 001: 1k wpu (Only available on I2C GPIOs)
28 PULL_UP_2K
= 0xb // 1 011: 2k wpu (Only available on I2C GPIOs)
29 PULL_UP_20K
= 0xc // 1 100: 20k wpu
30 PULL_UP_667
= 0xd // 1 101: 1k & 2k wpu (Only available on I2C GPIOs)
31 PULL_NATIVE
= 0xf // 1 111: (optional) Native controller selected by Pad Mode
34 type PlatformSpecific
struct {}
36 // RemmapRstSrc - remmap Pad Reset Source Config
37 // remmap is not required because it is the same as common.
38 func (PlatformSpecific
) RemmapRstSrc() {}
40 // Adds The Pad Termination (TERM) parameter from DW1 to the macro as a new argument
42 func (PlatformSpecific
) Pull() {
43 macro
:= common
.GetMacro()
44 dw1
:= macro
.Register(PAD_CFG_DW1
)
45 var pull
= map[uint8]string{
48 PULL_DN_20K
: "DN_20K",
51 PULL_UP_20K
: "UP_20K",
52 PULL_UP_667
: "UP_667",
53 PULL_NATIVE
: "NATIVE",
56 terminationFieldValue
:= dw1
.GetTermination()
57 str
, valid
:= pull
[terminationFieldValue
]
59 str
= strconv
.Itoa(int(terminationFieldValue
))
60 fmt
.Println("Error", macro
.PadIdGet(), " invalid TERM value = ", str
)
62 macro
.Separator().Add(str
)
65 // Generate macro to cause peripheral IRQ when configured in GPIO input mode
66 func ioApicRoute() bool {
67 macro
:= common
.GetMacro()
68 dw0
:= macro
.Register(PAD_CFG_DW0
)
69 dw1
:= macro
.Register(PAD_CFG_DW1
)
70 if dw0
.GetGPIOInputRouteIOxAPIC() == 0 {
74 if dw1
.GetIOStandbyState() != 0 || dw1
.GetIOStandbyTermination() != 0 {
75 // e.g. H1_PCH_INT_ODL
76 // PAD_CFG_GPI_APIC_IOS(GPIO_63, NONE, DEEP, LEVEL, INVERT, TxDRxE, DISPUPD),
77 macro
.Add("_IOS(").Id().Pull().Rstsrc().Trig().Invert().IOSstate().IOTerm()
79 // PAD_CFG_GPI_APIC(pad, pull, rst, trig, inv)
80 macro
.Add("(").Id().Pull().Rstsrc().Trig().Invert().Add("),")
86 // Generate macro to cause NMI when configured in GPIO input mode
87 func nmiRoute() bool {
88 macro
:= common
.GetMacro()
89 if macro
.Register(PAD_CFG_DW0
).GetGPIOInputRouteNMI() == 0 {
92 // e.g. PAD_CFG_GPI_NMI(GPIO_24, UP_20K, DEEP, LEVEL, INVERT),
93 macro
.Add("_NMI").Add("(").Id().Pull().Rstsrc().Trig().Invert().Add("),")
97 // Generate macro to cause SCI when configured in GPIO input mode
98 func sciRoute() bool {
99 macro
:= common
.GetMacro()
100 dw0
:= macro
.Register(PAD_CFG_DW0
)
101 dw1
:= macro
.Register(PAD_CFG_DW0
)
102 if dw0
.GetGPIOInputRouteSCI() == 0 {
105 if dw1
.GetIOStandbyState() != 0 || dw1
.GetIOStandbyTermination() != 0 {
106 // PAD_CFG_GPI_SCI_IOS(GPIO_141, NONE, DEEP, EDGE_SINGLE, INVERT, IGNORE, DISPUPD),
107 macro
.Add("_SCI_IOS")
108 macro
.Add("(").Id().Pull().Rstsrc().Trig().Invert().IOSstate().IOTerm()
109 } else if dw0
.GetRXLevelEdgeConfiguration() & 0x1 != 0 {
110 // e.g. PAD_CFG_GPI_ACPI_SCI(GPP_G2, NONE, DEEP, YES),
111 macro
.Add("_ACPI_SCI").Add("(").Id().Pull().Rstsrc().Invert()
113 // e.g. PAD_CFG_GPI_SCI(GPP_B18, UP_20K, PLTRST, LEVEL, INVERT),
114 macro
.Add("_SCI").Add("(").Id().Pull().Rstsrc().Trig().Invert()
120 // Generate macro to cause SMI when configured in GPIO input mode
121 func smiRoute() bool {
122 macro
:= common
.GetMacro()
123 dw0
:= macro
.Register(PAD_CFG_DW0
)
124 dw1
:= macro
.Register(PAD_CFG_DW1
)
125 if dw0
.GetGPIOInputRouteSMI() == 0 {
128 if dw1
.GetIOStandbyState() != 0 || dw1
.GetIOStandbyTermination() != 0 {
129 // PAD_CFG_GPI_SMI_IOS(GPIO_41, UP_20K, DEEP, EDGE_SINGLE, NONE, IGNORE, SAME),
130 macro
.Add("_SMI_IOS")
131 macro
.Add("(").Id().Pull().Rstsrc().Trig().Invert().IOSstate().IOTerm()
132 } else if dw0
.GetRXLevelEdgeConfiguration() & 0x1 != 0 {
133 // e.g. PAD_CFG_GPI_ACPI_SMI(GPP_I3, NONE, DEEP, YES),
134 macro
.Add("_ACPI_SMI").Add("(").Id().Pull().Rstsrc().Invert()
136 // e.g. PAD_CFG_GPI_SMI(GPP_E3, NONE, PLTRST, EDGE_SINGLE, NONE),
137 macro
.Add("_SMI").Add("(").Id().Pull().Rstsrc().Trig().Invert()
143 // Generate macro for GPI port
144 func (PlatformSpecific
) GpiMacroAdd() {
145 macro
:= common
.GetMacro()
147 macro
.Set("PAD_CFG_GPI")
148 for routeid
, isRoute
:= range map[string]func() (bool) {
149 "IOAPIC": ioApicRoute
,
155 ids
= append(ids
, routeid
)
159 switch argc
:= len(ids
); argc
{
161 dw1
:= macro
.Register(PAD_CFG_DW1
)
162 isIOStandbyStateUsed
:= dw1
.GetIOStandbyState() != 0
163 isIOStandbyTerminationUsed
:= dw1
.GetIOStandbyTermination() != 0
164 if isIOStandbyStateUsed
&& !isIOStandbyTerminationUsed
{
165 macro
.Add("_TRIG_IOSSTATE_OWN(")
166 // PAD_CFG_GPI_TRIG_IOSSTATE_OWN(pad, pull, rst, trig, iosstate, own)
167 macro
.Id().Pull().Rstsrc().Trig().IOSstate().Own().Add("),")
168 } else if isIOStandbyTerminationUsed
{
169 macro
.Add("_TRIG_IOS_OWN(")
170 // PAD_CFG_GPI_TRIG_IOS_OWN(pad, pull, rst, trig, iosstate, iosterm, own)
171 macro
.Id().Pull().Rstsrc().Trig().IOSstate().IOTerm().Own().Add("),")
173 // PAD_CFG_GPI_TRIG_OWN(pad, pull, rst, trig, own)
174 macro
.Add("_TRIG_OWN(").Id().Pull().Rstsrc().Trig().Own().Add("),")
177 // GPI with IRQ route
178 if config
.AreFieldsIgnored() {
179 macro
.SetPadOwnership(common
.PAD_OWN_ACPI
)
182 // PAD_CFG_GPI_DUAL_ROUTE(pad, pull, rst, trig, inv, route1, route2)
183 macro
.Set("PAD_CFG_GPI_DUAL_ROUTE(").Id().Pull().Rstsrc().Trig().Invert()
184 macro
.Add(", " + ids
[0] + ", " + ids
[1] + "),")
185 if config
.AreFieldsIgnored() {
186 macro
.SetPadOwnership(common
.PAD_OWN_ACPI
)
189 // Clear the control mask so that the check fails and "Advanced" macro is
191 macro
.Register(PAD_CFG_DW0
).CntrMaskFieldsClear(common
.AllFields
)
196 // Adds PAD_CFG_GPO macro with arguments
197 func (PlatformSpecific
) GpoMacroAdd() {
198 macro
:= common
.GetMacro()
199 dw0
:= macro
.Register(PAD_CFG_DW0
)
200 dw1
:= macro
.Register(PAD_CFG_DW1
)
201 term
:= dw1
.GetTermination()
204 if dw1
.GetIOStandbyState() != 0 || dw1
.GetIOStandbyTermination() != 0 {
205 // PAD_CFG_GPO_IOSSTATE_IOSTERM(GPIO_91, 0, DEEP, NONE, Tx0RxDCRx0, DISPUPD),
206 // PAD_CFG_GPO_IOSSTATE_IOSTERM(pad, val, rst, pull, iosstate, ioterm)
207 macro
.Add("_GPO_IOSSTATE_IOSTERM(").Id().Val().Rstsrc().Pull().IOSstate().IOTerm()
210 // e.g. PAD_CFG_TERM_GPO(GPP_B23, 1, DN_20K, DEEP),
211 // PAD_CFG_TERM_GPO(pad, val, pull, rst)
214 macro
.Add("_GPO(").Id().Val()
222 if dw0
.GetRXLevelEdgeConfiguration() != common
.TRIG_OFF
{
223 // ignore if trig = OFF is not set
224 dw0
.CntrMaskFieldsClear(common
.RxLevelEdgeConfigurationMask
)
228 // Adds PAD_CFG_NF macro with arguments
229 func (PlatformSpecific
) NativeFunctionMacroAdd() {
230 macro
:= common
.GetMacro()
231 dw1
:= macro
.Register(PAD_CFG_DW1
)
232 isIOStandbyStateUsed
:= dw1
.GetIOStandbyState() != 0
233 isIOStandbyTerminationUsed
:= dw1
.GetIOStandbyTermination() != 0
235 macro
.Set("PAD_CFG_NF")
236 if !isIOStandbyTerminationUsed
&& isIOStandbyStateUsed
{
237 if dw1
.GetIOStandbyState() == common
.StandbyIgnore
{
238 // PAD_CFG_NF_IOSTANDBY_IGNORE(PMU_SLP_S0_B, NONE, DEEP, NF1),
239 macro
.Add("_IOSTANDBY_IGNORE(").Id().Pull().Rstsrc().Padfn()
241 // PAD_CFG_NF_IOSSTATE(GPIO_22, UP_20K, DEEP, NF2, TxDRxE),
242 macro
.Add("_IOSSTATE(").Id().Pull().Rstsrc().Padfn().IOSstate()
244 } else if isIOStandbyTerminationUsed
{
245 // PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_103, NATIVE, DEEP, NF1, MASK, SAME),
246 macro
.Add("_IOSSTATE_IOSTERM(").Id().Pull().Rstsrc().Padfn().IOSstate().IOTerm()
248 // e.g. PAD_CFG_NF(GPP_D23, NONE, DEEP, NF1)
249 macro
.Add("(").Id().Pull().Rstsrc().Padfn()
253 if dw0
:= macro
.Register(PAD_CFG_DW0
); dw0
.GetGPIORxTxDisableStatus() != 0 {
254 // Since the bufbis parameter will be ignored for NF, we should clear
255 // the corresponding bits in the control mask.
256 dw0
.CntrMaskFieldsClear(common
.RxTxBufDisableMask
)
261 func (PlatformSpecific
) NoConnMacroAdd() {
262 macro
:= common
.GetMacro()
263 dw1
:= macro
.Register(PAD_CFG_DW1
)
265 if dw1
.GetIOStandbyState() == common
.TxDRxE
{
266 dw0
:= macro
.Register(PAD_CFG_DW0
)
268 // See comments in sunrise/macro.go : NoConnMacroAdd()
269 if dw0
.GetRXLevelEdgeConfiguration() != common
.TRIG_OFF
{
270 dw0
.CntrMaskFieldsClear(common
.RxLevelEdgeConfigurationMask
)
272 if dw0
.GetResetConfig() != 1 { // 1 = RST_DEEP
273 dw0
.CntrMaskFieldsClear(common
.PadRstCfgMask
)
276 // PAD_NC(OSC_CLK_OUT_1, DN_20K)
277 macro
.Set("PAD_NC").Add("(").Id().Pull().Add("),")
280 // PAD_CFG_GPIO_HI_Z(GPIO_81, UP_20K, DEEP, HIZCRx0, DISPUPD),
281 macro
.Set("PAD_CFG_GPIO_")
282 if macro
.IsOwnershipDriver() {
283 // PAD_CFG_GPIO_DRIVER_HI_Z(GPIO_55, UP_20K, DEEP, HIZCRx1, ENPU),
286 macro
.Add("HI_Z(").Id().Pull().Rstsrc().IOSstate().IOTerm().Add("),")
289 // GenMacro - generate pad macro
290 // dw0 : DW0 config register value
291 // dw1 : DW1 config register value
292 // return: string of macro
294 func (PlatformSpecific
) GenMacro(id
string, dw0
uint32, dw1
uint32, ownership
uint8) string {
295 macro
:= common
.GetInstanceMacro(PlatformSpecific
{}, fields
.InterfaceGet())
296 // use platform-specific interface in Macro struct
297 macro
.PadIdSet(id
).SetPadOwnership(ownership
)
298 macro
.Register(PAD_CFG_DW0
).CntrMaskFieldsClear(common
.AllFields
)
299 macro
.Register(PAD_CFG_DW0
).CntrMaskFieldsClear(common
.AllFields
)
300 macro
.Register(PAD_CFG_DW0
).ValueSet(dw0
).ReadOnlyFieldsSet(PAD_CFG_DW0_RO_FIELDS
)
301 macro
.Register(PAD_CFG_DW1
).ValueSet(dw1
).ReadOnlyFieldsSet(PAD_CFG_DW1_RO_FIELDS
)
302 return macro
.Generate()