[EHL] Add GPIO payload selection configuration

This patch added payload selection GPIO configuration
hardcoded GPIO pin for payload selection.

It also fixed #1196.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
Co-authored-by: Lean Sheng Tan <lean.sheng.tan@intel.com>
Signed-off-by: Maurice Ma <maurice.ma@intel.com>
This commit is contained in:
Maurice Ma
2021-09-20 21:35:01 -07:00
parent 1177ad3a1d
commit b61baa5a8d
5 changed files with 400 additions and 305 deletions
@@ -22,27 +22,25 @@ template:
GPIO_TMPL: >
- $ACTION :
page : GIO_$(1):GIO:"GPIO $(1)"
- $ACTION :
page : GIO_$(1)
- GpioPinConfig0_$(1) :
page : GIO_$(1)$(2):GIO_$(1):"$(1)$(2)"
- GpioPinConfig0_$(1)$(2) :
- $STRUCT :
name : GPIO $(1) PIN Config0
name : GPIO $(1)$(2) PIN Config0
type : EditNum, HEX, (0x00000000,0xFFFFFFFF)
help : >
GPIO $(1) PIN Configuration
GPIO $(1)$(2) PIN Configuration
length : 0x04
value : $(2)
- GPIOPADMode_$(1) :
value : $(3)
- GPIOPADMode_$(1)$(2) :
name : PadMode
type : Combo
option : 0x0:Hardware Default, 0x1:GPIO control of the pad, 0x3:Native function 1, 0x5:Native function 2, 0x7:Native function 3, 0x9:Native function 4, 0xB:Native function 5, 0xD:Native function 6, 0xF:Native function 7, 0x11:Native function 8
help : >
GPIO PAD Mode. If GPIO is set to one of NativeX modes then following settings are not applicable and can be skipped:-
Interrupt related settings, Host Software Ownership, Output/Input enabling/disabling, Output lock
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1).GPIOSkip_$(1) == 0
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1)$(2).GPIOSkip_$(1)$(2) == 0
length : 5b
- GPIOHostSoftPadOwn_$(1) :
- GPIOHostSoftPadOwn_$(1)$(2) :
name : HostSoftPadOwn
type : Combo
option : 0x0:Host Ownership Default(Leave ownership value unmodified), 0x1:Host ownership to ACPI, 0x3:Host ownership to GPIO Driver mode
@@ -53,9 +51,9 @@ template:
If GPIO is configured to generate SCI/SMI/NMI then this setting must be used for interrupts to work.
- HOST ownership to GPIO Driver mode - Use this setting only if GPIO pad should be controlled by GPIO OS Driver.
GPIO OS Driver will be able to control the pad if appropriate entry in ACPI exists.
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1).GPIOSkip_$(1) == 0
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1)$(2).GPIOSkip_$(1)$(2) == 0
length : 2b
- GPIODirection_$(1) :
- GPIODirection_$(1)$(2) :
name : Direction
type : Combo
option : 0x0:DirDefault, 0x9:DirInOut, 0x19:DirInInvOut, 0xB:DirIn, 0x1B:DirInInv, 0x5:DirOut, 0x7:DirNone
@@ -65,18 +63,18 @@ template:
- DirInInvOut = Set pad for both output and input with inversion, - DirIn = Set pad for input only,
- DirInInv = Set pad for input with inversion, - DirOut = Set pad for output only,
- DirNone = Disable both output and input.
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1).GPIOSkip_$(1) == 0
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1)$(2).GPIOSkip_$(1)$(2) == 0
length : 6b
- GPIOOutputState_$(1) :
- GPIOOutputState_$(1)$(2) :
name : OutputState
type : Combo
option : 0x0:OutDefault, 0x1:OutLow, 0x3:OutHigh
help : >
GPIO Output State.This field is relevant only if output is enabled:-
- OutDefault = Leave output value unmodified, - OutLow = Set output to low, - OutHigh = Set output to high
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1).GPIOSkip_$(1) == 0
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1)$(2).GPIOSkip_$(1)$(2) == 0
length : 2b
- GPIOInterruptConfig_$(1) :
- GPIOInterruptConfig_$(1)$(2) :
name : InterruptConfig
type : Combo
option : >
@@ -97,9 +95,9 @@ template:
- IntDefault = Leave value of interrupt routing unmodified, - IntDisable = Disable IOxAPIC/SCI/SMI/NMI interrupt generation,
- IntNmi = Enable NMI interrupt only, - IntSmi = Enable SMI interrupt only, - IntSci = Enable SCI interrupt only, - IntApic = Enable IOxAPIC interrupt only,
- IntLevel = Set interrupt as level triggered, - IntEdge = Set interrupt as edge triggered, - IntLvlEdgDis = Disable interrupt trigger, - IntBothEdge = Set interrupt as both edge triggered
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1).GPIOSkip_$(1) == 0
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1)$(2).GPIOSkip_$(1)$(2) == 0
length : 9b
- GPIOResetConfig_$(1) :
- GPIOResetConfig_$(1)$(2) :
name : Power/ResetConfig
type : Combo
option : 0x0:ResetDefault, 0x1:ResetResume, 0x3:HostDeepReset, 0x5:PlatformReset, 0x7:DswReset
@@ -109,17 +107,17 @@ template:
- HostDeepReset = Pad settings will reset on:Warm/Cold/Global reset,DeepSx transition,G3,
- PlatformReset = Pad settings will reset on:S3/S4/S5 transition, Warm/Cold/Global reset, DeepSx transition, G3
- DswReset = Pad settings will reset on G3
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1).GPIOSkip_$(1) == 0
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1)$(2).GPIOSkip_$(1)$(2) == 0
length : 8b
- GpioPinConfig1_$(1) :
- GpioPinConfig1_$(1)$(2) :
- $STRUCT :
name : GPIO $(1) PIN Config1
name : GPIO $(1)$(2) PIN Config1
type : EditNum, HEX, (0x00000000,0xFFFFFFFF)
help : >
GPIO $(1) PIN Configuration
GPIO $(1)$(2) PIN Configuration
length : 0x04
value : $(3)
- GPIOElectricalCfg_$(1) :
value : $(4)
- GPIOElectricalCfg_$(1)$(2) :
name : GPIO ElectricalCfg
type : Combo
option : 0x0:TermDefault, 0x1:TermNone, 0x5:TermNone, 0x9:TermWpd20K, 0x13:TermWpu1K, 0x17:TermWpu2K, 0x15:TermWpu5K, 0x19:TermWpu20K, 0x1B:TermWpu1K2K, 0x1F:TermNative, 0x20:NoTolerance1v8, 0x60:Tolerance1v8
@@ -129,9 +127,9 @@ template:
- TermWpu1K = 1kOhm weak pull-up, - TermWpu2K = 2kOhm weak pull-up, - TermWpu5K = 5kOhm weak pull-up, - TermWpu20K = 20kOhm weak pull-up, - TermWpu1K2K = 1kOhm & 2kOhm weak pull-up,
- TermNative = Native function. This setting is applicable only to some native modes,
- NoTolerance1v8 = Disable 1.8V pad tolerance, Tolerance1v8 = Enable 1.8V pad tolerance
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1).GPIOSkip_$(1) == 0
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1)$(2).GPIOSkip_$(1)$(2) == 0
length : 9b
- GPIOLockConfig_$(1) :
- GPIOLockConfig_$(1)$(2) :
name : LockConfig
type : Combo
option : 0x0:LockDefault, 0x1:PadConfigLock, 0x3:PadConfigUnlock, 0x5:PadLock , 0xC:OutputStateUnlock, 0xF:PadUnlock
@@ -140,29 +138,29 @@ template:
- LockDefault = Leave value of pad as-is, - PadConfigLock = Lock Pad configuration,
- PadConfigUnlock = Leave Pad configuration unlocked, - PadLock = Lock both Pad configuration and output control,
- OutputStateUnlock = Leave Pad output control unlocked, PadUnlock = Leave both Pad configuration and output control unlocked
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1).GPIOSkip_$(1) == 0
condition : $GPIO_CFG_DATA.GpioPinConfig1_$(1)$(2).GPIOSkip_$(1)$(2) == 0
length : 4b
- Reserved1_$(1) :
- Reserved1_$(1)$(2) :
name : Reserved1
type : Reserved
length : 3b
- PadNum_$(1) :
- PadNum_$(1)$(2) :
name : PadNum
type : Reserved
length : 8b
- GrpIdx_$(1) :
- GrpIdx_$(1)$(2) :
name : GrpIdx
type : Reserved
length : 5b
- Reserved2_$(1) :
- Reserved2_$(1)$(2) :
name : Reserved2
type : Reserved
length : 1b
- Hide_$(1) :
- Hide_$(1)$(2) :
name : Hide
type : Reserved
length : 1b
- GPIOSkip_$(1) :
- GPIOSkip_$(1)$(2) :
name : GPIO Skip
type : Combo
option : $EN_DIS
@@ -263,6 +261,52 @@ configs:
value : 0x0
- $ACTION :
page : PIDSEL:PLT:"Payload Selection GPIO"
- PLATFORM_CFG_DATA :
- !expand { CFGHDR_TMPL : [ PLATFORM_CFG_DATA, 0x280, 0, 0 ] }
- PayloadSelGpio :
- $STRUCT :
name : GPIO pin for switching payload
struct : PAYLOAD_SEL_GPIO_PIN
length : 0x02
- PinGroup :
name : Pin Group
type : Combo
option : >
0x0B:GPP_A, 0x00:GPP_B, 0x0D:GPP_C, 0x05:GPP_D, 0x10:GPP_E, 0x0E:GPP_F, 0x02:GPP_G, 0x04:GPP_H,
0x12:GPP_R, 0x0A:GPP_S, 0x01:GPP_T, 0x06:GPP_U, 0x03:GPP_V, 0x08:GPD
condition : ($PLATFORM_CFG_DATA.PayloadSelGpio.Enable > 0)
help : >
Specify GPIO Group Number
length : 7bW
value : 0
- Enable :
name : Payload Selection Pin Enable
type : Combo
option : $EN_DIS
help : >
Enable/Disable this pin for payload selection between OsLoader and UEFI.
order : 0000.0000
length : 1bW
value : 0
- PinNumber :
name : Pin Number
type : Combo
option : >
0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9,
10:10, 11:11, 12:12, 13:13, 14:14, 15:15, 16:16, 17:17,
18:18, 19:19, 20:20, 21:21, 22:22, 23:23
length : 8bW
value : 0
condition : ($PLATFORM_CFG_DATA.PayloadSelGpio.Enable > 0)
help : >
Specify GPIO Pin Number
- Dummy :
length : 0x02
value : 0x0
- !include CfgData_GpuConfig.yaml
@@ -20,6 +20,12 @@ MEMORY_CFG_DATA.MemorySpdPtr10 | {FILE: Spd_Lpddr4_8G.bin}
# GPIO for payload selection pin J2E1 pins 2-4
GEN_CFG_DATA.PayloadId | 'AUTO'
# GPIO_VER3_H_GPP_D13 for payload selection pin
PLATFORM_CFG_DATA.PayloadSelGpio.Enable | 1
PLATFORM_CFG_DATA.PayloadSelGpio.PinGroup | 5
PLATFORM_CFG_DATA.PayloadSelGpio.PinNumber | 13
GPIO_CFG_DATA.GpioPinConfig0_GPP_D13.GPIODirection_GPP_D13 | 0xB
GPIO_CFG_DATA.GpioPinConfig1_GPP_D13.GPIOSkip_GPP_D13 | 0
File diff suppressed because it is too large Load Diff
@@ -600,10 +600,11 @@ UpdatePayloadId (
VOID
)
{
EFI_STATUS Status;
UINT32 PayloadSelGpioData;
UINT32 PayloadSelGpioPad;
GEN_CFG_DATA *GenCfgData;
EFI_STATUS Status;
UINT32 PayloadSelGpioData;
UINT32 PayloadSelGpioPad;
GEN_CFG_DATA *GenCfgData;
PLATFORM_CFG_DATA *PlatCfgData;
GenCfgData = (GEN_CFG_DATA *)FindConfigDataByTag (CDATA_GEN_TAG);
if (GenCfgData == NULL) {
@@ -616,11 +617,12 @@ UpdatePayloadId (
return;
}
//
// Switch payloads based on configured GPIO pin
//
if (GetPlatformId () == 0x5) {
PayloadSelGpioPad = GPIO_VER3_GPP_D13;
PlatCfgData = (PLATFORM_CFG_DATA *)FindConfigDataByTag (CDATA_PLATFORM_TAG);
if ((PlatCfgData != NULL) && (PlatCfgData->PayloadSelGpio.Enable != 0)) {
// Calculate the GPIO pad
PayloadSelGpioPad = GPIO_VER3_GPP_B0 + (PlatCfgData->PayloadSelGpio.PinGroup << 16) + PlatCfgData->PayloadSelGpio.PinNumber;
// Switch payloads based on configured GPIO pin
Status = GpioGetInputValue (PayloadSelGpioPad, &PayloadSelGpioData);
if (!EFI_ERROR (Status)) {
if (PayloadSelGpioData == 1) {
@@ -630,9 +632,9 @@ UpdatePayloadId (
SetPayloadId (UEFI_PAYLOAD_ID_SIGNATURE);
DEBUG ((DEBUG_INFO, "Update PayloadId to UEFI\n"));
}
} else {
DEBUG ((DEBUG_ERROR, "Invalid GPIO pin for Payload Select\n"));
}
} else {
DEBUG ((DEBUG_INFO, "AUTO PayloadId is not supported on this platform.\n"));
}
}
@@ -39,6 +39,7 @@
/// require GpioPad as argument. Encoding used here
/// has all information required by library functions
///
#define GPIO_VER3_GPP_B0 0x0B000000
#define GPIO_VER3_GPP_B1 0x0B000001
#define GPIO_VER3_GPP_B2 0x0B000002
#define GPIO_VER3_GPP_B14 0x0B00000E