CorebootPayloadPkg/PlatformBdsLib: Pass more serial parameters

Pass the serial port baudrate, register stride, input clock rate and
ID from coreboot to CorebootPayloadPkg.

Change-Id: I37111d23216e4effa2909337af7e8a6de36b61f7
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Lee Leahy <leroy.p.leahy@intel.com>
Reviewed-by: Prince Agyeman <prince.agyeman@intel.com>
This commit is contained in:
Leahy, Leroy P 2016-05-09 10:57:55 -07:00 committed by Prince Agyeman
parent deac23ab96
commit 24ca2f3507
7 changed files with 128 additions and 23 deletions

View File

@ -165,6 +165,21 @@ struct cb_serial {
UINT32 type; UINT32 type;
UINT32 baseaddr; UINT32 baseaddr;
UINT32 baud; UINT32 baud;
UINT32 regwidth;
// Crystal or input frequency to the chip containing the UART.
// Provide the board specific details to allow the payload to
// initialize the chip containing the UART and make independent
// decisions as to which dividers to select and their values
// to eventually arrive at the desired console baud-rate.
UINT32 input_hertz;
// UART PCI address: bus, device, function
// 1 << 31 - Valid bit, PCI UART in use
// Bus << 20
// Device << 15
// Function << 12
UINT32 uart_pci_addr;
}; };
#define CB_TAG_CONSOLE 0x00010 #define CB_TAG_CONSOLE 0x00010

View File

@ -113,7 +113,10 @@ CbParseFadtInfo (
@param pRegBase Pointer to the base address of serial port registers @param pRegBase Pointer to the base address of serial port registers
@param pRegAccessType Pointer to the access type of serial port registers @param pRegAccessType Pointer to the access type of serial port registers
@param pRegWidth Pointer to the register width in bytes
@param pBaudrate Pointer to the serial port baudrate @param pBaudrate Pointer to the serial port baudrate
@param pInputHertz Pointer to the input clock frequency
@param pUartPciAddr Pointer to the UART PCI bus, dev and func address
@retval RETURN_SUCCESS Successfully find the serial port information. @retval RETURN_SUCCESS Successfully find the serial port information.
@retval RETURN_NOT_FOUND Failed to find the serial port information . @retval RETURN_NOT_FOUND Failed to find the serial port information .
@ -121,9 +124,12 @@ CbParseFadtInfo (
**/ **/
RETURN_STATUS RETURN_STATUS
CbParseSerialInfo ( CbParseSerialInfo (
IN UINT32* pRegBase, OUT UINT32 *pRegBase,
IN UINT32* pRegAccessType, OUT UINT32 *pRegAccessType,
IN UINT32* pBaudrate OUT UINT32 *pRegWidth,
OUT UINT32 *pBaudrate,
OUT UINT32 *pInputHertz,
OUT UINT32 *pUartPciAddr
); );
/** /**

View File

@ -541,7 +541,10 @@ CbParseFadtInfo (
@param pRegBase Pointer to the base address of serial port registers @param pRegBase Pointer to the base address of serial port registers
@param pRegAccessType Pointer to the access type of serial port registers @param pRegAccessType Pointer to the access type of serial port registers
@param pRegWidth Pointer to the register width in bytes
@param pBaudrate Pointer to the serial port baudrate @param pBaudrate Pointer to the serial port baudrate
@param pInputHertz Pointer to the input clock frequency
@param pUartPciAddr Pointer to the UART PCI bus, dev and func address
@retval RETURN_SUCCESS Successfully find the serial port information. @retval RETURN_SUCCESS Successfully find the serial port information.
@retval RETURN_NOT_FOUND Failed to find the serial port information . @retval RETURN_NOT_FOUND Failed to find the serial port information .
@ -551,7 +554,10 @@ RETURN_STATUS
CbParseSerialInfo ( CbParseSerialInfo (
OUT UINT32 *pRegBase, OUT UINT32 *pRegBase,
OUT UINT32 *pRegAccessType, OUT UINT32 *pRegAccessType,
OUT UINT32 *pBaudrate OUT UINT32 *pRegWidth,
OUT UINT32 *pBaudrate,
OUT UINT32 *pInputHertz,
OUT UINT32 *pUartPciAddr
) )
{ {
struct cb_serial *CbSerial; struct cb_serial *CbSerial;
@ -569,6 +575,10 @@ CbParseSerialInfo (
*pRegBase = CbSerial->baseaddr; *pRegBase = CbSerial->baseaddr;
} }
if (pRegWidth != NULL) {
*pRegWidth = CbSerial->regwidth;
}
if (pRegAccessType != NULL) { if (pRegAccessType != NULL) {
*pRegAccessType = CbSerial->type; *pRegAccessType = CbSerial->type;
} }
@ -577,6 +587,14 @@ CbParseSerialInfo (
*pBaudrate = CbSerial->baud; *pBaudrate = CbSerial->baud;
} }
if (pInputHertz != NULL) {
*pInputHertz = CbSerial->input_hertz;
}
if (pUartPciAddr != NULL) {
*pUartPciAddr = CbSerial->uart_pci_addr;
}
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -78,6 +78,10 @@ PlatformBdsInit (
VOID VOID
) )
{ {
gUartDeviceNode.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);
gUartDeviceNode.DataBits = PcdGet8 (PcdUartDefaultDataBits);
gUartDeviceNode.Parity = PcdGet8 (PcdUartDefaultParity);
gUartDeviceNode.StopBits = PcdGet8 (PcdUartDefaultStopBits);
} }
@ -786,6 +790,7 @@ PlatformBdsPolicyBehavior (
DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior\n")); DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior\n"));
PlatformBdsInit();
ConnectRootBridge (); ConnectRootBridge ();
// //

View File

@ -45,6 +45,12 @@
DebugLib DebugLib
PcdLib PcdLib
GenericBdsLib GenericBdsLib
PlatformHookLib
[Pcd] [Pcd]
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits

View File

@ -14,10 +14,23 @@
#include <Base.h> #include <Base.h>
#include <Uefi/UefiBaseType.h> #include <Uefi/UefiBaseType.h>
#include <Library/PciLib.h>
#include <Library/PlatformHookLib.h> #include <Library/PlatformHookLib.h>
#include <Library/CbParseLib.h> #include <Library/CbParseLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
typedef struct {
UINT16 VendorId; ///< Vendor ID to match the PCI device. The value 0xFFFF terminates the list of entries.
UINT16 DeviceId; ///< Device ID to match the PCI device
UINT32 ClockRate; ///< UART clock rate. Set to 0 for default clock rate of 1843200 Hz
UINT64 Offset; ///< The byte offset into to the BAR
UINT8 BarIndex; ///< Which BAR to get the UART base address
UINT8 RegisterStride; ///< UART register stride in bytes. Set to 0 for default register stride of 1 byte.
UINT16 ReceiveFifoDepth; ///< UART receive FIFO depth in bytes. Set to 0 for a default FIFO depth of 16 bytes.
UINT16 TransmitFifoDepth; ///< UART transmit FIFO depth in bytes. Set to 0 for a default FIFO depth of 16 bytes.
UINT8 Reserved[2];
} PCI_SERIAL_PARAMETER;
/** /**
Performs platform specific initialization required for the CPU to access Performs platform specific initialization required for the CPU to access
the hardware associated with a SerialPortLib instance. This function does the hardware associated with a SerialPortLib instance. This function does
@ -38,8 +51,16 @@ PlatformHookSerialPortInitialize (
RETURN_STATUS Status; RETURN_STATUS Status;
UINT32 SerialRegBase; UINT32 SerialRegBase;
UINT32 SerialRegAccessType; UINT32 SerialRegAccessType;
UINT32 BaudRate;
UINT32 RegWidth;
UINT32 InputHertz;
UINT32 PayloadParam;
UINT32 DeviceVendor;
PCI_SERIAL_PARAMETER *SerialParam;
Status = CbParseSerialInfo (&SerialRegBase, &SerialRegAccessType, NULL); Status = CbParseSerialInfo (&SerialRegBase, &SerialRegAccessType,
&RegWidth, &BaudRate, &InputHertz,
&PayloadParam);
if (RETURN_ERROR (Status)) { if (RETURN_ERROR (Status)) {
return Status; return Status;
} }
@ -57,6 +78,34 @@ PlatformHookSerialPortInitialize (
return Status; return Status;
} }
Status = PcdSet32S (PcdSerialRegisterStride, RegWidth);
if (RETURN_ERROR (Status)) {
return Status;
}
Status = PcdSet32S (PcdSerialBaudRate, BaudRate);
if (RETURN_ERROR (Status)) {
return Status;
}
Status = PcdSet64S (PcdUartDefaultBaudRate, BaudRate);
if (RETURN_ERROR (Status)) {
return Status;
}
Status = PcdSet32S (PcdSerialClockRate, InputHertz);
if (RETURN_ERROR (Status)) {
return Status;
}
if (PayloadParam >= 0x80000000) {
DeviceVendor = PciRead32 (PayloadParam & 0x0ffff000);
SerialParam = PcdGetPtr(PcdPciSerialParameters);
SerialParam->VendorId = (UINT16)DeviceVendor;
SerialParam->DeviceId = DeviceVendor >> 16;
SerialParam->ClockRate = InputHertz;
SerialParam->RegisterStride = (UINT8)RegWidth;
}
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -19,6 +19,7 @@
MODULE_TYPE = BASE MODULE_TYPE = BASE
VERSION_STRING = 1.0 VERSION_STRING = 1.0
LIBRARY_CLASS = PlatformHookLib LIBRARY_CLASS = PlatformHookLib
CONSTRUCTOR = PlatformHookSerialPortInitialize
[Sources] [Sources]
PlatformHookLib.c PlatformHookLib.c
@ -26,6 +27,7 @@
[LibraryClasses] [LibraryClasses]
CbParseLib CbParseLib
PcdLib PcdLib
PciLib
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
@ -35,4 +37,8 @@
[Pcd] [Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## PRODUCES gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## PRODUCES
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase ## PRODUCES gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase ## PRODUCES
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate ## PRODUCES
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride ## PRODUCES
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate ## PRODUCES
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate ## PRODUCES
gEfiMdeModulePkgTokenSpaceGuid.PcdPciSerialParameters ## PRODUCES