[edk2-devel] [PATCH edk2-platforms 10/12] Platform/NXP: Add Platform driver for LS1043 RDB board

Leif Lindholm leif.lindholm at linaro.org
Thu Oct 10 15:12:42 UTC 2019


On Wed, Oct 09, 2019 at 10:19:16PM +0530, Meenakshi Aggarwal wrote:
> Platform driver will be used for platform specific work.
> At present, it populate i2c driver structure with platform
> specific information and install RTC on i2c.
> 
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal at nxp.com>

Reviewed-by: Leif Lindholm <leif.lindholm at linaro.org>

> ---
>  .../Drivers/PlatformDxe/PlatformDxe.c              | 114 +++++++++++++++++++++
>  .../Drivers/PlatformDxe/PlatformDxe.inf            |  52 ++++++++++
>  2 files changed, 166 insertions(+)
>  create mode 100644 Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c
>  create mode 100644 Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
> 
> diff --git a/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c
> new file mode 100644
> index 0000000..f89dcde
> --- /dev/null
> +++ b/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c
> @@ -0,0 +1,114 @@
> +/** @file
> +  LS1043 DXE platform driver.
> +
> +  Copyright 2018-2019 NXP
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiLib.h>
> +
> +#include <Protocol/NonDiscoverableDevice.h>
> +
> +typedef struct {
> +  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR StartDesc;
> +  UINT8 EndDesc;
> +} ADDRESS_SPACE_DESCRIPTOR;
> +
> +STATIC ADDRESS_SPACE_DESCRIPTOR mI2cDesc[FixedPcdGet64 (PcdNumI2cController)];
> +
> +STATIC
> +EFI_STATUS
> +RegisterDevice (
> +  IN  EFI_GUID                        *TypeGuid,
> +  IN  ADDRESS_SPACE_DESCRIPTOR        *Desc,
> +  OUT EFI_HANDLE                      *Handle
> +  )
> +{
> +  NON_DISCOVERABLE_DEVICE             *Device;
> +  EFI_STATUS                          Status;
> +
> +  Device = (NON_DISCOVERABLE_DEVICE *)AllocateZeroPool (sizeof (*Device));
> +  if (Device == NULL) {
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  Device->Type = TypeGuid;
> +  Device->DmaType = NonDiscoverableDeviceDmaTypeNonCoherent;
> +  Device->Resources = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Desc;
> +
> +  Status = gBS->InstallMultipleProtocolInterfaces (Handle,
> +                  &gEdkiiNonDiscoverableDeviceProtocolGuid, Device,
> +                  NULL);
> +  if (EFI_ERROR (Status)) {
> +    goto FreeDevice;
> +  }
> +  return EFI_SUCCESS;
> +
> +FreeDevice:
> +  FreePool (Device);
> +
> +  return Status;
> +}
> +
> +VOID
> +PopulateI2cInformation (
> +  IN VOID
> +  )
> +{
> +  UINT32 Index;
> +
> +  for (Index = 0; Index < FixedPcdGet32 (PcdNumI2cController); Index++) {
> +    mI2cDesc[Index].StartDesc.Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
> +    mI2cDesc[Index].StartDesc.Len = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3;
> +    mI2cDesc[Index].StartDesc.ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;
> +    mI2cDesc[Index].StartDesc.GenFlag = 0;
> +    mI2cDesc[Index].StartDesc.SpecificFlag = 0;
> +    mI2cDesc[Index].StartDesc.AddrSpaceGranularity = 32;
> +    mI2cDesc[Index].StartDesc.AddrRangeMin = FixedPcdGet64 (PcdI2c0BaseAddr) +
> +                                             (Index * FixedPcdGet32 (PcdI2cSize));
> +    mI2cDesc[Index].StartDesc.AddrRangeMax = mI2cDesc[Index].StartDesc.AddrRangeMin +
> +                                             FixedPcdGet32 (PcdI2cSize) - 1;
> +    mI2cDesc[Index].StartDesc.AddrTranslationOffset = 0;
> +    mI2cDesc[Index].StartDesc.AddrLen = FixedPcdGet32 (PcdI2cSize);
> +
> +    mI2cDesc[Index].EndDesc = ACPI_END_TAG_DESCRIPTOR;
> +  }
> +}
> +
> +EFI_STATUS
> +EFIAPI
> +PlatformDxeEntryPoint (
> +  IN EFI_HANDLE         ImageHandle,
> +  IN EFI_SYSTEM_TABLE   *SystemTable
> +  )
> +{
> +  EFI_STATUS                      Status;
> +  EFI_HANDLE                      Handle;
> +
> +  Handle = NULL;
> +
> +  PopulateI2cInformation ();
> +
> +  Status = RegisterDevice (&gNxpNonDiscoverableI2cMasterGuid,
> +             &mI2cDesc[0], &Handle);
> +  ASSERT_EFI_ERROR (Status);
> +
> +  //
> +  // Install the DS1307 I2C Master protocol on this handle so the RTC driver
> +  // can identify it as the I2C master it can invoke directly.
> +  //
> +  Status = gBS->InstallProtocolInterface (&Handle,
> +                  &gDs1307RealTimeClockLibI2cMasterProtocolGuid,
> +                  EFI_NATIVE_INTERFACE, NULL);
> +  ASSERT_EFI_ERROR (Status);
> +
> +  return EFI_SUCCESS;
> +}
> diff --git a/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
> new file mode 100644
> index 0000000..d689cf4
> --- /dev/null
> +++ b/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
> @@ -0,0 +1,52 @@
> +## @file
> +#
> +#  Component description file for LS1043 DXE platform driver.
> +#
> +#  Copyright 2018-2019 NXP
> +#
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION                    = 0x0001001A
> +  BASE_NAME                      = PlatformDxe
> +  FILE_GUID                      = 21108101-adcd-4123-930e-a2354a554db7
> +  MODULE_TYPE                    = DXE_DRIVER
> +  VERSION_STRING                 = 1.0
> +  ENTRY_POINT                    = PlatformDxeEntryPoint
> +
> +[Sources]
> +  PlatformDxe.c
> +
> +[Packages]
> +  ArmPkg/ArmPkg.dec
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.dec
> +  Silicon/NXP/NxpQoriqLs.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  BaseMemoryLib
> +  DebugLib
> +  MemoryAllocationLib
> +  PcdLib
> +  UefiBootServicesTableLib
> +  UefiDriverEntryPoint
> +  UefiLib
> +
> +[Guids]
> +  gNxpNonDiscoverableI2cMasterGuid
> +
> +[Protocols]
> +  gEdkiiNonDiscoverableDeviceProtocolGuid        ## PRODUCES
> +  gDs1307RealTimeClockLibI2cMasterProtocolGuid   ## PRODUCES
> +
> +[FixedPcd]
> +  gNxpQoriqLsTokenSpaceGuid.PcdI2c0BaseAddr
> +  gNxpQoriqLsTokenSpaceGuid.PcdI2cSize
> +  gNxpQoriqLsTokenSpaceGuid.PcdNumI2cController
> +
> +[Depex]
> +  TRUE
> -- 
> 1.9.1
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#48734): https://edk2.groups.io/g/devel/message/48734
Mute This Topic: https://groups.io/mt/34476008/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list