public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Re: [PATCH edk2-platforms 1/2] Silicon/NXP: Add SATA controller initialization driver
  2020-06-05 16:02 ` [PATCH edk2-platforms 1/2] Silicon/NXP: Add SATA controller initialization driver Meenakshi Aggarwal
@ 2020-06-05 13:00   ` Ard Biesheuvel
  2020-06-08 11:44     ` Meenakshi Aggarwal
  0 siblings, 1 reply; 12+ messages in thread
From: Ard Biesheuvel @ 2020-06-05 13:00 UTC (permalink / raw)
  To: Meenakshi Aggarwal, leif, michael.d.kinney, devel
  Cc: v.sethi, Meenakshi Aggarwal

On 6/5/20 6:02 PM, Meenakshi Aggarwal wrote:
> Add support of SATA controller driver which performs
> controller initialization and register itself as NonDiscoverableMmioDevice
> 
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> ---
>   Silicon/NXP/NxpQoriqLs.dec                      |   6 +
>   Silicon/NXP/NxpQoriqLs.dsc.inc                  |  10 ++
>   Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf |  46 ++++++++
>   Silicon/NXP/Drivers/SataInitDxe/SataInit.h      |  27 +++++
>   Silicon/NXP/Drivers/SataInitDxe/SataInit.c      | 116 ++++++++++++++++++++
>   5 files changed, 205 insertions(+)
> 
> diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec
> index 72c1744fc934..e83f282ace4e 100644
> --- a/Silicon/NXP/NxpQoriqLs.dec
> +++ b/Silicon/NXP/NxpQoriqLs.dec
> @@ -28,6 +28,7 @@ [PcdsFeatureFlag]
>     gNxpQoriqLsTokenSpaceGuid.PcdI2cErratumA009203|FALSE|BOOLEAN|0x00000315
>     gNxpQoriqLsTokenSpaceGuid.PcdDcfgBigEndian|FALSE|BOOLEAN|0x00000316
>     gNxpQoriqLsTokenSpaceGuid.PcdPciLutBigEndian|FALSE|BOOLEAN|0x00000317
> +  gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185|FALSE|BOOLEAN|0x00000318
>   
>   [PcdsFixedAtBuild.common]
>     # Pcds for PCI Express
> @@ -41,6 +42,11 @@ [PcdsFixedAtBuild.common]
>     gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x0|UINT32|0x00000511
>     gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|0|UINT32|0x00000512
>   
> +  # Pcds for SATA
> +  gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr|0x0|UINT64|0x00000350
> +  gNxpQoriqLsTokenSpaceGuid.PcdSataSize|0x0|UINT32|0x00000351
> +  gNxpQoriqLsTokenSpaceGuid.PcdNumSataController|0x0|UINT32|0x00000352
> +
>   [PcdsDynamic.common]
>     gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable|FALSE|BOOLEAN|0x00000600
>     gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl|FALSE|BOOLEAN|0x00000601
> diff --git a/Silicon/NXP/NxpQoriqLs.dsc.inc b/Silicon/NXP/NxpQoriqLs.dsc.inc
> index 1f0f272da6c7..399ac5de9176 100644
> --- a/Silicon/NXP/NxpQoriqLs.dsc.inc
> +++ b/Silicon/NXP/NxpQoriqLs.dsc.inc
> @@ -101,6 +101,7 @@ [LibraryClasses.common]
>   
>     PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
>     MemoryInitPeiLib|Silicon/NXP/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf
> +  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
>   
>   [LibraryClasses.common.SEC]
>     PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> @@ -378,6 +379,15 @@ [Components.common]
>     MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
>   
>     #
> +  # AHCI Support
> +  #
> +  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> +  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
> +  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
> +  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
> +  MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
> +
> +  #
>     # Bds
>     #
>     MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
> diff --git a/Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf b/Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
> new file mode 100644
> index 000000000000..06b6c2ac6ff9
> --- /dev/null
> +++ b/Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
> @@ -0,0 +1,46 @@
> +## @file
> +#  Component description file for the Sata Controller initialization driver
> +#
> +#  Copyright 2017 NXP
> +#
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION                    = 0x0001001A
> +  BASE_NAME                      = SataInit
> +  FILE_GUID                      = 021722D8-522B-4079-852A-FE44C2C13F49

Please don't reuse file GUIDs  but generate your own.

> +  MODULE_TYPE                    = DXE_DRIVER
> +  VERSION_STRING                 = 1.0
> +  ENTRY_POINT                    = InitializeSataController
> +
> +[Sources]
> +  SataInit.c
> +  SataInit.h
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  Silicon/NXP/NxpQoriqLs.dec
> +
> +[LibraryClasses]
> +  DebugLib
> +  NonDiscoverableDeviceRegistrationLib
> +  UefiBootServicesTableLib
> +  UefiDriverEntryPoint
> +  UefiLib
> +
> +[FixedPcd]
> +  gNxpQoriqLsTokenSpaceGuid.PcdNumSataController
> +  gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr
> +  gNxpQoriqLsTokenSpaceGuid.PcdSataSize
> +
> +[FeaturePcd]
> +  gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185
> +
> +[Guids]
> +  gEfiEndOfDxeEventGroupGuid
> +
> +[Depex]
> +  TRUE
> diff --git a/Silicon/NXP/Drivers/SataInitDxe/SataInit.h b/Silicon/NXP/Drivers/SataInitDxe/SataInit.h
> new file mode 100644
> index 000000000000..edaf0bdda72c
> --- /dev/null
> +++ b/Silicon/NXP/Drivers/SataInitDxe/SataInit.h
> @@ -0,0 +1,27 @@
> +/** @file
> +  Header file for Sata Controller initialization driver.
> +
> +  Copyright 2017-2018, 2020 NXP
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> + **/
> +
> +#ifndef SATA_INIT_H_
> +#define SATA_INIT_H_
> +
> +//
> +// Offset for AHCI base address in PCI Header
> +//
> +#define PCI_AHCI_BASE_ADDRESS  0x24

Where is this used?

> +
> +#define SATA_PPCFG             0xA8
> +#define SATA_PTC               0xC8
> +#define SATA_PAXIC             0xC0
> +
> +#define PORT_PHYSICAL          0xA003FFFE
> +#define PORT_TRANSPORT         0x08000025
> +#define PORT_RXWM              0x08000029
> +#define ENABLE_NONZERO_4MB_PRD 0x10000000
> +

Do these really need a separate local header?

> +#endif
> diff --git a/Silicon/NXP/Drivers/SataInitDxe/SataInit.c b/Silicon/NXP/Drivers/SataInitDxe/SataInit.c
> new file mode 100644
> index 000000000000..c678b63652e7
> --- /dev/null
> +++ b/Silicon/NXP/Drivers/SataInitDxe/SataInit.c
> @@ -0,0 +1,116 @@
> +/** @file
> +  This driver module adds SATA controller support.
> +
> +  Copyright 2017-2018, 2020 NXP
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> + **/
> +

No need to #include <PiDxe.h> here?

> +#include <Library/DebugLib.h>
> +#include <Library/IoLib.h>
> +#include <Library/NonDiscoverableDeviceRegistrationLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +
> +#include "SataInit.h"
> +
> +/**
> +  This function gets registered as a callback to perform USB controller intialization
> +
> +  @param  Event         Event whose notification function is being invoked.
> +  @param  Context       Pointer to the notification function's context.
> +
> +**/

STATIC

> +VOID
> +EFIAPI
> +SataEndOfDxeCallback (
> +  IN EFI_EVENT  Event,
> +  IN VOID       *Context
> +  )
> +{
> +  EFI_STATUS               Status;
> +  UINT32                   NumSataController;
> +  UINT32                   Index;
> +  UINT32                   Data;
> +  UINTN                    ControllerAddr;
> +
> +  NumSataController = PcdGet32 (PcdNumSataController);
> +
> +  for (Index = 0; Index < NumSataController; Index++) {
> +    ControllerAddr = PcdGet64 (PcdSataBaseAddr) +
> +                     (Index * PcdGet32 (PcdSataSize));
> +
> +    //
> +    // configuring Physical Control Layer parameters for Port 0
> +    //
> +    MmioWrite32 ((UINTN)(ControllerAddr + SATA_PPCFG), PORT_PHYSICAL);
> +
> +    //
> +    // This register controls the configuration of the
> +    // Transport Layer for  Port 0
> +    // Errata Description : The default Rx watermark value may be insufficient
> +    // for some hard drives and result in a false CRC or internal errors.
> +    // Workaround: Change PTC[RXWM] field at offset 0xC8 to 0x29. Do not change
> +    // the other reserved fields of the register.
> +    //
> +
> +    Data = MmioRead32 ((UINTN)(ControllerAddr + SATA_PTC));
> +    if (PcdGetBool (PcdSataErratumA009185)) {
> +      Data |= PORT_RXWM;
> +    } else {
> +      Data |= PORT_TRANSPORT;
> +    }
> +    MmioWrite32 ((UINTN)(ControllerAddr + SATA_PTC), Data);
> +
> +    //
> +    // Enable Non-Zero 4 MB PRD entries.
> +    //
> +    MmioOr32 ((UINTN)(ControllerAddr + SATA_PAXIC), ENABLE_NONZERO_4MB_PRD);
> +
> +    Status = RegisterNonDiscoverableMmioDevice (
> +               NonDiscoverableDeviceTypeAhci,
> +               NonDiscoverableDeviceDmaTypeNonCoherent,
> +               NULL,
> +               NULL,
> +               1,
> +               ControllerAddr, PcdGet32 (PcdSataSize)
> +               );
> +
> +    if (EFI_ERROR (Status)) {
> +      DEBUG ((DEBUG_ERROR, "Failed to register SATA device 0x%x, error 0x%r \n",
> +        ControllerAddr, Status));
> +    }
> +  }
> +}
> +
> +/**
> +  The Entry Point of module. It follows the standard UEFI driver model.
> +
> +  @param[in] ImageHandle       The firmware allocated handle for the EFI image.
> +  @param[in] SystemTable       A pointer to the EFI System Table.
> +
> +  @retval EFI_SUCCESS          The entry point is executed successfully.
> +  @retval Other                Some error occurs when executing this entry point
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +InitializeSataController (
> +  IN EFI_HANDLE            ImageHandle,
> +  IN EFI_SYSTEM_TABLE      *SystemTable
> +  )
> +{
> +  EFI_STATUS               Status;
> +  EFI_EVENT                EndOfDxeEvent;
> +
> +  Status = gBS->CreateEventEx (
> +                  EVT_NOTIFY_SIGNAL,
> +                  TPL_CALLBACK,
> +                  SataEndOfDxeCallback,
> +                  NULL,
> +                  &gEfiEndOfDxeEventGroupGuid,
> +                  &EndOfDxeEvent
> +                  );
> +
> +  return Status;
> +}
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH edk2-platforms 2/2] Platform/NXP:LX2160: Enable support of SATA controller
  2020-06-05 16:02 ` [PATCH edk2-platforms 2/2] Platform/NXP:LX2160: Enable support of SATA controller Meenakshi Aggarwal
@ 2020-06-05 13:01   ` Ard Biesheuvel
  2020-06-05 13:09     ` Leif Lindholm
  0 siblings, 1 reply; 12+ messages in thread
From: Ard Biesheuvel @ 2020-06-05 13:01 UTC (permalink / raw)
  To: Meenakshi Aggarwal, leif, michael.d.kinney, devel
  Cc: v.sethi, Meenakshi Aggarwal

On 6/5/20 6:02 PM, Meenakshi Aggarwal wrote:
> Enable support of SATA  drives on lx2160 RDB board.
> 
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> ---
>   Silicon/NXP/LX2160A/LX2160A.dsc.inc          |  5 +++++
>   Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc |  2 ++
>   Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf | 18 +++++++++++++++---
>   3 files changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/Silicon/NXP/LX2160A/LX2160A.dsc.inc b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
> index 55dd3b5442eb..6bd08d527aed 100644
> --- a/Silicon/NXP/LX2160A/LX2160A.dsc.inc
> +++ b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
> @@ -40,8 +40,13 @@ [PcdsFixedAtBuild.common]
>     gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x10000
>     gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|2
>   
> +  gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr|0x3200000
> +  gNxpQoriqLsTokenSpaceGuid.PcdSataSize|0x10000
> +  gNxpQoriqLsTokenSpaceGuid.PcdNumSataController|0x4
> +
>   [PcdsFeatureFlag]
>     gNxpQoriqLsTokenSpaceGuid.PcdI2cErratumA009203|TRUE
> +  gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185|TRUE
>   
>   ################################################################################
>   #
> diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
> index ec27a1a219a5..2c65577eceab 100644
> --- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
> +++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
> @@ -44,4 +44,6 @@ [Components.common]
>     }
>   
>     Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
> +
> +  Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
>    ##
> diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
> index 5cb809e8b3a0..e8ac7658c011 100644
> --- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
> +++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
> @@ -23,10 +23,10 @@
>   
>   [FD.LX2160ARDB_EFI]
>   BaseAddress   = 0x82000000|gArmTokenSpaceGuid.PcdFdBaseAddress  #The base address of the FLASH Device.
> -Size          = 0x00160000|gArmTokenSpaceGuid.PcdFdSize         #The size in bytes of the FLASH Device
> +Size          = 0x00180000|gArmTokenSpaceGuid.PcdFdSize         #The size in bytes of the FLASH Device
>   ErasePolarity = 1
>   BlockSize     = 0x10000
> -NumBlocks     = 0x16
> +NumBlocks     = 0x18
>   
>   ################################################################################
>   #
> @@ -43,7 +43,7 @@ [FD.LX2160ARDB_EFI]
>   # RegionType <FV, DATA, or FILE>
>   #
>   ################################################################################
> -0x00000000|0x00160000
> +0x00000000|0x00180000
>   gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
>   FV = FVMAIN_COMPACT
>   

I don't mind these unrelated changes (but Leif might) but you should 
make a note of them in the commit log.


> @@ -132,6 +132,18 @@ [FV.FvMain]
>     INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
>   
>     INF Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
> +
> +  #
> +  # AHCI Support
> +  #
> +  INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> +  INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
> +  INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
> +  INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
> +  INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
> +
> +  INF Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
> +
>     #
>     # UEFI application (Shell Embedded Boot Loader)
>     #
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH edk2-platforms 2/2] Platform/NXP:LX2160: Enable support of SATA controller
  2020-06-05 13:01   ` Ard Biesheuvel
@ 2020-06-05 13:09     ` Leif Lindholm
  0 siblings, 0 replies; 12+ messages in thread
From: Leif Lindholm @ 2020-06-05 13:09 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Meenakshi Aggarwal, michael.d.kinney, devel, v.sethi,
	Meenakshi Aggarwal

On Fri, Jun 05, 2020 at 15:01:36 +0200, Ard Biesheuvel wrote:
> On 6/5/20 6:02 PM, Meenakshi Aggarwal wrote:
> > Enable support of SATA  drives on lx2160 RDB board.
> > 
> > Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> > ---
> >   Silicon/NXP/LX2160A/LX2160A.dsc.inc          |  5 +++++
> >   Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc |  2 ++
> >   Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf | 18 +++++++++++++++---
> >   3 files changed, 22 insertions(+), 3 deletions(-)
> > 
> > diff --git a/Silicon/NXP/LX2160A/LX2160A.dsc.inc b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
> > index 55dd3b5442eb..6bd08d527aed 100644
> > --- a/Silicon/NXP/LX2160A/LX2160A.dsc.inc
> > +++ b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
> > @@ -40,8 +40,13 @@ [PcdsFixedAtBuild.common]
> >     gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x10000
> >     gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|2
> > +  gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr|0x3200000
> > +  gNxpQoriqLsTokenSpaceGuid.PcdSataSize|0x10000
> > +  gNxpQoriqLsTokenSpaceGuid.PcdNumSataController|0x4
> > +
> >   [PcdsFeatureFlag]
> >     gNxpQoriqLsTokenSpaceGuid.PcdI2cErratumA009203|TRUE
> > +  gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185|TRUE
> >   ################################################################################
> >   #
> > diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
> > index ec27a1a219a5..2c65577eceab 100644
> > --- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
> > +++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
> > @@ -44,4 +44,6 @@ [Components.common]
> >     }
> >     Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
> > +
> > +  Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
> >    ##
> > diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
> > index 5cb809e8b3a0..e8ac7658c011 100644
> > --- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
> > +++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
> > @@ -23,10 +23,10 @@
> >   [FD.LX2160ARDB_EFI]
> >   BaseAddress   = 0x82000000|gArmTokenSpaceGuid.PcdFdBaseAddress  #The base address of the FLASH Device.
> > -Size          = 0x00160000|gArmTokenSpaceGuid.PcdFdSize         #The size in bytes of the FLASH Device
> > +Size          = 0x00180000|gArmTokenSpaceGuid.PcdFdSize         #The size in bytes of the FLASH Device
> >   ErasePolarity = 1
> >   BlockSize     = 0x10000
> > -NumBlocks     = 0x16
> > +NumBlocks     = 0x18
> >   ################################################################################
> >   #
> > @@ -43,7 +43,7 @@ [FD.LX2160ARDB_EFI]
> >   # RegionType <FV, DATA, or FILE>
> >   #
> >   ################################################################################
> > -0x00000000|0x00160000
> > +0x00000000|0x00180000
> >   gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
> >   FV = FVMAIN_COMPACT
> 
> I don't mind these unrelated changes (but Leif might) but you should make a
> note of them in the commit log.

If the change is to accommodate the added drivers, they're not
unrelated. But yes, they should still be explicitly called out in
commit message.

/
    Leif

> > @@ -132,6 +132,18 @@ [FV.FvMain]
> >     INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
> >     INF Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
> > +
> > +  #
> > +  # AHCI Support
> > +  #
> > +  INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> > +  INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
> > +  INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
> > +  INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
> > +  INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
> > +
> > +  INF Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
> > +
> >     #
> >     # UEFI application (Shell Embedded Boot Loader)
> >     #
> > 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH edk2-platforms 0/2] Add SATA driver support
@ 2020-06-05 16:02 Meenakshi Aggarwal
  2020-06-05 16:02 ` [PATCH edk2-platforms 1/2] Silicon/NXP: Add SATA controller initialization driver Meenakshi Aggarwal
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Meenakshi Aggarwal @ 2020-06-05 16:02 UTC (permalink / raw)
  To: ard.biesheuvel, leif, michael.d.kinney, devel; +Cc: v.sethi, Meenakshi Aggarwal

This patchset implement SATA driver for NXP Platforms enable
SATA for LX2160A Platform.

Meenakshi Aggarwal (2):
  Silicon/NXP: Add SATA controller initialization driver
  Platform/NXP:LX2160: Enable support of SATA controller

 Silicon/NXP/NxpQoriqLs.dec                      |   6 +
 Silicon/NXP/LX2160A/LX2160A.dsc.inc             |   5 +
 Silicon/NXP/NxpQoriqLs.dsc.inc                  |  10 ++
 Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc    |   2 +
 Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf    |  18 ++-
 Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf |  46 ++++++++
 Silicon/NXP/Drivers/SataInitDxe/SataInit.h      |  27 +++++
 Silicon/NXP/Drivers/SataInitDxe/SataInit.c      | 116 ++++++++++++++++++++
 8 files changed, 227 insertions(+), 3 deletions(-)
 create mode 100644 Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
 create mode 100644 Silicon/NXP/Drivers/SataInitDxe/SataInit.h
 create mode 100644 Silicon/NXP/Drivers/SataInitDxe/SataInit.c

-- 
1.9.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH edk2-platforms 1/2] Silicon/NXP: Add SATA controller initialization driver
  2020-06-05 16:02 [PATCH edk2-platforms 0/2] Add SATA driver support Meenakshi Aggarwal
@ 2020-06-05 16:02 ` Meenakshi Aggarwal
  2020-06-05 13:00   ` Ard Biesheuvel
  2020-06-05 16:02 ` [PATCH edk2-platforms 2/2] Platform/NXP:LX2160: Enable support of SATA controller Meenakshi Aggarwal
  2020-06-09 14:31 ` [PATCH edk2-platforms V2 0/2] Add SATA driver support Meenakshi Aggarwal
  2 siblings, 1 reply; 12+ messages in thread
From: Meenakshi Aggarwal @ 2020-06-05 16:02 UTC (permalink / raw)
  To: ard.biesheuvel, leif, michael.d.kinney, devel
  Cc: v.sethi, Meenakshi Aggarwal, Meenakshi Aggarwal

Add support of SATA controller driver which performs
controller initialization and register itself as NonDiscoverableMmioDevice

Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
 Silicon/NXP/NxpQoriqLs.dec                      |   6 +
 Silicon/NXP/NxpQoriqLs.dsc.inc                  |  10 ++
 Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf |  46 ++++++++
 Silicon/NXP/Drivers/SataInitDxe/SataInit.h      |  27 +++++
 Silicon/NXP/Drivers/SataInitDxe/SataInit.c      | 116 ++++++++++++++++++++
 5 files changed, 205 insertions(+)

diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec
index 72c1744fc934..e83f282ace4e 100644
--- a/Silicon/NXP/NxpQoriqLs.dec
+++ b/Silicon/NXP/NxpQoriqLs.dec
@@ -28,6 +28,7 @@ [PcdsFeatureFlag]
   gNxpQoriqLsTokenSpaceGuid.PcdI2cErratumA009203|FALSE|BOOLEAN|0x00000315
   gNxpQoriqLsTokenSpaceGuid.PcdDcfgBigEndian|FALSE|BOOLEAN|0x00000316
   gNxpQoriqLsTokenSpaceGuid.PcdPciLutBigEndian|FALSE|BOOLEAN|0x00000317
+  gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185|FALSE|BOOLEAN|0x00000318
 
 [PcdsFixedAtBuild.common]
   # Pcds for PCI Express
@@ -41,6 +42,11 @@ [PcdsFixedAtBuild.common]
   gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x0|UINT32|0x00000511
   gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|0|UINT32|0x00000512
 
+  # Pcds for SATA
+  gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr|0x0|UINT64|0x00000350
+  gNxpQoriqLsTokenSpaceGuid.PcdSataSize|0x0|UINT32|0x00000351
+  gNxpQoriqLsTokenSpaceGuid.PcdNumSataController|0x0|UINT32|0x00000352
+
 [PcdsDynamic.common]
   gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable|FALSE|BOOLEAN|0x00000600
   gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl|FALSE|BOOLEAN|0x00000601
diff --git a/Silicon/NXP/NxpQoriqLs.dsc.inc b/Silicon/NXP/NxpQoriqLs.dsc.inc
index 1f0f272da6c7..399ac5de9176 100644
--- a/Silicon/NXP/NxpQoriqLs.dsc.inc
+++ b/Silicon/NXP/NxpQoriqLs.dsc.inc
@@ -101,6 +101,7 @@ [LibraryClasses.common]
 
   PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
   MemoryInitPeiLib|Silicon/NXP/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf
+  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
 
 [LibraryClasses.common.SEC]
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
@@ -378,6 +379,15 @@ [Components.common]
   MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
 
   #
+  # AHCI Support
+  #
+  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
+  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+  MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
+
+  #
   # Bds
   #
   MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
diff --git a/Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf b/Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
new file mode 100644
index 000000000000..06b6c2ac6ff9
--- /dev/null
+++ b/Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
@@ -0,0 +1,46 @@
+## @file
+#  Component description file for the Sata Controller initialization driver
+#
+#  Copyright 2017 NXP
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001A
+  BASE_NAME                      = SataInit
+  FILE_GUID                      = 021722D8-522B-4079-852A-FE44C2C13F49
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = InitializeSataController
+
+[Sources]
+  SataInit.c
+  SataInit.h
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  Silicon/NXP/NxpQoriqLs.dec
+
+[LibraryClasses]
+  DebugLib
+  NonDiscoverableDeviceRegistrationLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  UefiLib
+
+[FixedPcd]
+  gNxpQoriqLsTokenSpaceGuid.PcdNumSataController
+  gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr
+  gNxpQoriqLsTokenSpaceGuid.PcdSataSize
+
+[FeaturePcd]
+  gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185
+
+[Guids]
+  gEfiEndOfDxeEventGroupGuid
+
+[Depex]
+  TRUE
diff --git a/Silicon/NXP/Drivers/SataInitDxe/SataInit.h b/Silicon/NXP/Drivers/SataInitDxe/SataInit.h
new file mode 100644
index 000000000000..edaf0bdda72c
--- /dev/null
+++ b/Silicon/NXP/Drivers/SataInitDxe/SataInit.h
@@ -0,0 +1,27 @@
+/** @file
+  Header file for Sata Controller initialization driver.
+
+  Copyright 2017-2018, 2020 NXP
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ **/
+
+#ifndef SATA_INIT_H_
+#define SATA_INIT_H_
+
+//
+// Offset for AHCI base address in PCI Header
+//
+#define PCI_AHCI_BASE_ADDRESS  0x24
+
+#define SATA_PPCFG             0xA8
+#define SATA_PTC               0xC8
+#define SATA_PAXIC             0xC0
+
+#define PORT_PHYSICAL          0xA003FFFE
+#define PORT_TRANSPORT         0x08000025
+#define PORT_RXWM              0x08000029
+#define ENABLE_NONZERO_4MB_PRD 0x10000000
+
+#endif
diff --git a/Silicon/NXP/Drivers/SataInitDxe/SataInit.c b/Silicon/NXP/Drivers/SataInitDxe/SataInit.c
new file mode 100644
index 000000000000..c678b63652e7
--- /dev/null
+++ b/Silicon/NXP/Drivers/SataInitDxe/SataInit.c
@@ -0,0 +1,116 @@
+/** @file
+  This driver module adds SATA controller support.
+
+  Copyright 2017-2018, 2020 NXP
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ **/
+
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+#include <Library/NonDiscoverableDeviceRegistrationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#include "SataInit.h"
+
+/**
+  This function gets registered as a callback to perform USB controller intialization
+
+  @param  Event         Event whose notification function is being invoked.
+  @param  Context       Pointer to the notification function's context.
+
+**/
+VOID
+EFIAPI
+SataEndOfDxeCallback (
+  IN EFI_EVENT  Event,
+  IN VOID       *Context
+  )
+{
+  EFI_STATUS               Status;
+  UINT32                   NumSataController;
+  UINT32                   Index;
+  UINT32                   Data;
+  UINTN                    ControllerAddr;
+
+  NumSataController = PcdGet32 (PcdNumSataController);
+
+  for (Index = 0; Index < NumSataController; Index++) {
+    ControllerAddr = PcdGet64 (PcdSataBaseAddr) +
+                     (Index * PcdGet32 (PcdSataSize));
+
+    //
+    // configuring Physical Control Layer parameters for Port 0
+    //
+    MmioWrite32 ((UINTN)(ControllerAddr + SATA_PPCFG), PORT_PHYSICAL);
+
+    //
+    // This register controls the configuration of the
+    // Transport Layer for  Port 0
+    // Errata Description : The default Rx watermark value may be insufficient
+    // for some hard drives and result in a false CRC or internal errors.
+    // Workaround: Change PTC[RXWM] field at offset 0xC8 to 0x29. Do not change
+    // the other reserved fields of the register.
+    //
+
+    Data = MmioRead32 ((UINTN)(ControllerAddr + SATA_PTC));
+    if (PcdGetBool (PcdSataErratumA009185)) {
+      Data |= PORT_RXWM;
+    } else {
+      Data |= PORT_TRANSPORT;
+    }
+    MmioWrite32 ((UINTN)(ControllerAddr + SATA_PTC), Data);
+
+    //
+    // Enable Non-Zero 4 MB PRD entries.
+    //
+    MmioOr32 ((UINTN)(ControllerAddr + SATA_PAXIC), ENABLE_NONZERO_4MB_PRD);
+
+    Status = RegisterNonDiscoverableMmioDevice (
+               NonDiscoverableDeviceTypeAhci,
+               NonDiscoverableDeviceDmaTypeNonCoherent,
+               NULL,
+               NULL,
+               1,
+               ControllerAddr, PcdGet32 (PcdSataSize)
+               );
+
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed to register SATA device 0x%x, error 0x%r \n",
+        ControllerAddr, Status));
+    }
+  }
+}
+
+/**
+  The Entry Point of module. It follows the standard UEFI driver model.
+
+  @param[in] ImageHandle       The firmware allocated handle for the EFI image.
+  @param[in] SystemTable       A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS          The entry point is executed successfully.
+  @retval Other                Some error occurs when executing this entry point
+
+**/
+EFI_STATUS
+EFIAPI
+InitializeSataController (
+  IN EFI_HANDLE            ImageHandle,
+  IN EFI_SYSTEM_TABLE      *SystemTable
+  )
+{
+  EFI_STATUS               Status;
+  EFI_EVENT                EndOfDxeEvent;
+
+  Status = gBS->CreateEventEx (
+                  EVT_NOTIFY_SIGNAL,
+                  TPL_CALLBACK,
+                  SataEndOfDxeCallback,
+                  NULL,
+                  &gEfiEndOfDxeEventGroupGuid,
+                  &EndOfDxeEvent
+                  );
+
+  return Status;
+}
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH edk2-platforms 2/2] Platform/NXP:LX2160: Enable support of SATA controller
  2020-06-05 16:02 [PATCH edk2-platforms 0/2] Add SATA driver support Meenakshi Aggarwal
  2020-06-05 16:02 ` [PATCH edk2-platforms 1/2] Silicon/NXP: Add SATA controller initialization driver Meenakshi Aggarwal
@ 2020-06-05 16:02 ` Meenakshi Aggarwal
  2020-06-05 13:01   ` Ard Biesheuvel
  2020-06-09 14:31 ` [PATCH edk2-platforms V2 0/2] Add SATA driver support Meenakshi Aggarwal
  2 siblings, 1 reply; 12+ messages in thread
From: Meenakshi Aggarwal @ 2020-06-05 16:02 UTC (permalink / raw)
  To: ard.biesheuvel, leif, michael.d.kinney, devel
  Cc: v.sethi, Meenakshi Aggarwal, Meenakshi Aggarwal

Enable support of SATA  drives on lx2160 RDB board.

Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
 Silicon/NXP/LX2160A/LX2160A.dsc.inc          |  5 +++++
 Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc |  2 ++
 Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf | 18 +++++++++++++++---
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/Silicon/NXP/LX2160A/LX2160A.dsc.inc b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
index 55dd3b5442eb..6bd08d527aed 100644
--- a/Silicon/NXP/LX2160A/LX2160A.dsc.inc
+++ b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
@@ -40,8 +40,13 @@ [PcdsFixedAtBuild.common]
   gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x10000
   gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|2
 
+  gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr|0x3200000
+  gNxpQoriqLsTokenSpaceGuid.PcdSataSize|0x10000
+  gNxpQoriqLsTokenSpaceGuid.PcdNumSataController|0x4
+
 [PcdsFeatureFlag]
   gNxpQoriqLsTokenSpaceGuid.PcdI2cErratumA009203|TRUE
+  gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185|TRUE
 
 ################################################################################
 #
diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
index ec27a1a219a5..2c65577eceab 100644
--- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
+++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
@@ -44,4 +44,6 @@ [Components.common]
   }
 
   Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
+
+  Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
  ##
diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
index 5cb809e8b3a0..e8ac7658c011 100644
--- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
+++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
@@ -23,10 +23,10 @@
 
 [FD.LX2160ARDB_EFI]
 BaseAddress   = 0x82000000|gArmTokenSpaceGuid.PcdFdBaseAddress  #The base address of the FLASH Device.
-Size          = 0x00160000|gArmTokenSpaceGuid.PcdFdSize         #The size in bytes of the FLASH Device
+Size          = 0x00180000|gArmTokenSpaceGuid.PcdFdSize         #The size in bytes of the FLASH Device
 ErasePolarity = 1
 BlockSize     = 0x10000
-NumBlocks     = 0x16
+NumBlocks     = 0x18
 
 ################################################################################
 #
@@ -43,7 +43,7 @@ [FD.LX2160ARDB_EFI]
 # RegionType <FV, DATA, or FILE>
 #
 ################################################################################
-0x00000000|0x00160000
+0x00000000|0x00180000
 gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
 FV = FVMAIN_COMPACT
 
@@ -132,6 +132,18 @@ [FV.FvMain]
   INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
 
   INF Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
+
+  #
+  # AHCI Support
+  #
+  INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
+  INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+  INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+  INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+  INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
+
+  INF Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
+
   #
   # UEFI application (Shell Embedded Boot Loader)
   #
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH edk2-platforms 1/2] Silicon/NXP: Add SATA controller initialization driver
  2020-06-05 13:00   ` Ard Biesheuvel
@ 2020-06-08 11:44     ` Meenakshi Aggarwal
  0 siblings, 0 replies; 12+ messages in thread
From: Meenakshi Aggarwal @ 2020-06-08 11:44 UTC (permalink / raw)
  To: Ard Biesheuvel, Meenakshi Aggarwal (OSS), leif@nuviainc.com,
	michael.d.kinney@intel.com, devel@edk2.groups.io
  Cc: Varun Sethi

Hi Ard,

Reply inline.

> -----Original Message-----
> From: Ard Biesheuvel <ard.biesheuvel@arm.com>
> Sent: Friday, June 5, 2020 6:30 PM
> To: Meenakshi Aggarwal (OSS) <meenakshi.aggarwal@oss.nxp.com>;
> leif@nuviainc.com; michael.d.kinney@intel.com; devel@edk2.groups.io
> Cc: Varun Sethi <V.Sethi@nxp.com>; Meenakshi Aggarwal
> <meenakshi.aggarwal@nxp.com>
> Subject: Re: [PATCH edk2-platforms 1/2] Silicon/NXP: Add SATA controller
> initialization driver
> 
> On 6/5/20 6:02 PM, Meenakshi Aggarwal wrote:
> > Add support of SATA controller driver which performs controller
> > initialization and register itself as NonDiscoverableMmioDevice
> >
> > Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> > ---
> >   Silicon/NXP/NxpQoriqLs.dec                      |   6 +
> >   Silicon/NXP/NxpQoriqLs.dsc.inc                  |  10 ++
> >   Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf |  46 ++++++++
> >   Silicon/NXP/Drivers/SataInitDxe/SataInit.h      |  27 +++++
> >   Silicon/NXP/Drivers/SataInitDxe/SataInit.c      | 116 ++++++++++++++++++++
> >   5 files changed, 205 insertions(+)
> >
> > diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec
> > index 72c1744fc934..e83f282ace4e 100644
> > --- a/Silicon/NXP/NxpQoriqLs.dec
> > +++ b/Silicon/NXP/NxpQoriqLs.dec
> > @@ -28,6 +28,7 @@ [PcdsFeatureFlag]
> >
> gNxpQoriqLsTokenSpaceGuid.PcdI2cErratumA009203|FALSE|BOOLEAN|0x0000
> 0315
> >
> gNxpQoriqLsTokenSpaceGuid.PcdDcfgBigEndian|FALSE|BOOLEAN|0x00000316
> >
> >
> gNxpQoriqLsTokenSpaceGuid.PcdPciLutBigEndian|FALSE|BOOLEAN|0x0000031
> 7
> > +
> > +
> gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185|FALSE|BOOLEAN|0x000
> 0
> > + 0318
> >
> >   [PcdsFixedAtBuild.common]
> >     # Pcds for PCI Express
> > @@ -41,6 +42,11 @@ [PcdsFixedAtBuild.common]
> >     gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x0|UINT32|0x00000511
> >
> gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|0|UINT32|0x00000512
> >
> > +  # Pcds for SATA
> > +  gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr|0x0|UINT64|0x00000350
> > +  gNxpQoriqLsTokenSpaceGuid.PcdSataSize|0x0|UINT32|0x00000351
> > +
> > +
> gNxpQoriqLsTokenSpaceGuid.PcdNumSataController|0x0|UINT32|0x00000352
> > +
> >   [PcdsDynamic.common]
> >
> gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable|FALSE|BOOLEAN|0x000006
> 00
> >
> > gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl|FALSE|BOOLEAN|0x00000601
> > diff --git a/Silicon/NXP/NxpQoriqLs.dsc.inc
> > b/Silicon/NXP/NxpQoriqLs.dsc.inc index 1f0f272da6c7..399ac5de9176
> > 100644
> > --- a/Silicon/NXP/NxpQoriqLs.dsc.inc
> > +++ b/Silicon/NXP/NxpQoriqLs.dsc.inc
> > @@ -101,6 +101,7 @@ [LibraryClasses.common]
> >
> >     PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
> >
> > MemoryInitPeiLib|Silicon/NXP/Library/MemoryInitPeiLib/MemoryInitPeiLib
> > .inf
> > +  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
> >
> >   [LibraryClasses.common.SEC]
> >     PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> > @@ -378,6 +379,15 @@ [Components.common]
> >
> >
> MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDev
> > iceDxe.inf
> >
> >     #
> > +  # AHCI Support
> > +  #
> > +  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> > +  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
> > +  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
> > +  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
> > +  MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
> > +
> > +  #
> >     # Bds
> >     #
> >     MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
> > diff --git a/Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
> > b/Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
> > new file mode 100644
> > index 000000000000..06b6c2ac6ff9
> > --- /dev/null
> > +++ b/Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
> > @@ -0,0 +1,46 @@
> > +## @file
> > +#  Component description file for the Sata Controller initialization
> > +driver # #  Copyright 2017 NXP # #  SPDX-License-Identifier:
> > +BSD-2-Clause-Patent # ##
> > +
> > +[Defines]
> > +  INF_VERSION                    = 0x0001001A
> > +  BASE_NAME                      = SataInit
> > +  FILE_GUID                      = 021722D8-522B-4079-852A-FE44C2C13F49
> 
> Please don't reuse file GUIDs  but generate your own.
> 
Missed it, will replace

> > +  MODULE_TYPE                    = DXE_DRIVER
> > +  VERSION_STRING                 = 1.0
> > +  ENTRY_POINT                    = InitializeSataController
> > +
> > +[Sources]
> > +  SataInit.c
> > +  SataInit.h
> > +
> > +[Packages]
> > +  MdePkg/MdePkg.dec
> > +  MdeModulePkg/MdeModulePkg.dec
> > +  Silicon/NXP/NxpQoriqLs.dec
> > +
> > +[LibraryClasses]
> > +  DebugLib
> > +  NonDiscoverableDeviceRegistrationLib
> > +  UefiBootServicesTableLib
> > +  UefiDriverEntryPoint
> > +  UefiLib
> > +
> > +[FixedPcd]
> > +  gNxpQoriqLsTokenSpaceGuid.PcdNumSataController
> > +  gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr
> > +  gNxpQoriqLsTokenSpaceGuid.PcdSataSize
> > +
> > +[FeaturePcd]
> > +  gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185
> > +
> > +[Guids]
> > +  gEfiEndOfDxeEventGroupGuid
> > +
> > +[Depex]
> > +  TRUE
> > diff --git a/Silicon/NXP/Drivers/SataInitDxe/SataInit.h
> > b/Silicon/NXP/Drivers/SataInitDxe/SataInit.h
> > new file mode 100644
> > index 000000000000..edaf0bdda72c
> > --- /dev/null
> > +++ b/Silicon/NXP/Drivers/SataInitDxe/SataInit.h
> > @@ -0,0 +1,27 @@
> > +/** @file
> > +  Header file for Sata Controller initialization driver.
> > +
> > +  Copyright 2017-2018, 2020 NXP
> > +
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > + **/
> > +
> > +#ifndef SATA_INIT_H_
> > +#define SATA_INIT_H_
> > +
> > +//
> > +// Offset for AHCI base address in PCI Header // #define
> > +PCI_AHCI_BASE_ADDRESS  0x24
> 
> Where is this used?
Missed during cleanup, will delete
> 
> > +
> > +#define SATA_PPCFG             0xA8
> > +#define SATA_PTC               0xC8
> > +#define SATA_PAXIC             0xC0
> > +
> > +#define PORT_PHYSICAL          0xA003FFFE
> > +#define PORT_TRANSPORT         0x08000025
> > +#define PORT_RXWM              0x08000029
> > +#define ENABLE_NONZERO_4MB_PRD 0x10000000
> > +
> 
> Do these really need a separate local header?
Hmm, we can keep in ".c" file
> 
> > +#endif
> > diff --git a/Silicon/NXP/Drivers/SataInitDxe/SataInit.c
> > b/Silicon/NXP/Drivers/SataInitDxe/SataInit.c
> > new file mode 100644
> > index 000000000000..c678b63652e7
> > --- /dev/null
> > +++ b/Silicon/NXP/Drivers/SataInitDxe/SataInit.c
> > @@ -0,0 +1,116 @@
> > +/** @file
> > +  This driver module adds SATA controller support.
> > +
> > +  Copyright 2017-2018, 2020 NXP
> > +
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > + **/
> > +
> 
> No need to #include <PiDxe.h> here?
I am not seeing  any error without this
> 
> > +#include <Library/DebugLib.h>
> > +#include <Library/IoLib.h>
> > +#include <Library/NonDiscoverableDeviceRegistrationLib.h>
> > +#include <Library/UefiBootServicesTableLib.h>
> > +
> > +#include "SataInit.h"
> > +
> > +/**
> > +  This function gets registered as a callback to perform USB
> > +controller intialization
> > +
> > +  @param  Event         Event whose notification function is being invoked.
> > +  @param  Context       Pointer to the notification function's context.
> > +
> > +**/
> 
> STATIC
ok
> 
> > +VOID
> > +EFIAPI
> > +SataEndOfDxeCallback (
> > +  IN EFI_EVENT  Event,
> > +  IN VOID       *Context
> > +  )
> > +{
> > +  EFI_STATUS               Status;
> > +  UINT32                   NumSataController;
> > +  UINT32                   Index;
> > +  UINT32                   Data;
> > +  UINTN                    ControllerAddr;
> > +
> > +  NumSataController = PcdGet32 (PcdNumSataController);
> > +
> > +  for (Index = 0; Index < NumSataController; Index++) {
> > +    ControllerAddr = PcdGet64 (PcdSataBaseAddr) +
> > +                     (Index * PcdGet32 (PcdSataSize));
> > +
> > +    //
> > +    // configuring Physical Control Layer parameters for Port 0
> > +    //
> > +    MmioWrite32 ((UINTN)(ControllerAddr + SATA_PPCFG),
> > + PORT_PHYSICAL);
> > +
> > +    //
> > +    // This register controls the configuration of the
> > +    // Transport Layer for  Port 0
> > +    // Errata Description : The default Rx watermark value may be insufficient
> > +    // for some hard drives and result in a false CRC or internal errors.
> > +    // Workaround: Change PTC[RXWM] field at offset 0xC8 to 0x29. Do not
> change
> > +    // the other reserved fields of the register.
> > +    //
> > +
> > +    Data = MmioRead32 ((UINTN)(ControllerAddr + SATA_PTC));
> > +    if (PcdGetBool (PcdSataErratumA009185)) {
> > +      Data |= PORT_RXWM;
> > +    } else {
> > +      Data |= PORT_TRANSPORT;
> > +    }
> > +    MmioWrite32 ((UINTN)(ControllerAddr + SATA_PTC), Data);
> > +
> > +    //
> > +    // Enable Non-Zero 4 MB PRD entries.
> > +    //
> > +    MmioOr32 ((UINTN)(ControllerAddr + SATA_PAXIC),
> > + ENABLE_NONZERO_4MB_PRD);
> > +
> > +    Status = RegisterNonDiscoverableMmioDevice (
> > +               NonDiscoverableDeviceTypeAhci,
> > +               NonDiscoverableDeviceDmaTypeNonCoherent,
> > +               NULL,
> > +               NULL,
> > +               1,
> > +               ControllerAddr, PcdGet32 (PcdSataSize)
> > +               );
> > +
> > +    if (EFI_ERROR (Status)) {
> > +      DEBUG ((DEBUG_ERROR, "Failed to register SATA device 0x%x, error 0x%r
> \n",
> > +        ControllerAddr, Status));
> > +    }
> > +  }
> > +}
> > +
> > +/**
> > +  The Entry Point of module. It follows the standard UEFI driver model.
> > +
> > +  @param[in] ImageHandle       The firmware allocated handle for the EFI
> image.
> > +  @param[in] SystemTable       A pointer to the EFI System Table.
> > +
> > +  @retval EFI_SUCCESS          The entry point is executed successfully.
> > +  @retval Other                Some error occurs when executing this entry point
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +InitializeSataController (
> > +  IN EFI_HANDLE            ImageHandle,
> > +  IN EFI_SYSTEM_TABLE      *SystemTable
> > +  )
> > +{
> > +  EFI_STATUS               Status;
> > +  EFI_EVENT                EndOfDxeEvent;
> > +
> > +  Status = gBS->CreateEventEx (
> > +                  EVT_NOTIFY_SIGNAL,
> > +                  TPL_CALLBACK,
> > +                  SataEndOfDxeCallback,
> > +                  NULL,
> > +                  &gEfiEndOfDxeEventGroupGuid,
> > +                  &EndOfDxeEvent
> > +                  );
> > +
> > +  return Status;
> > +}
> >


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH edk2-platforms V2 0/2] Add SATA driver support
  2020-06-05 16:02 [PATCH edk2-platforms 0/2] Add SATA driver support Meenakshi Aggarwal
  2020-06-05 16:02 ` [PATCH edk2-platforms 1/2] Silicon/NXP: Add SATA controller initialization driver Meenakshi Aggarwal
  2020-06-05 16:02 ` [PATCH edk2-platforms 2/2] Platform/NXP:LX2160: Enable support of SATA controller Meenakshi Aggarwal
@ 2020-06-09 14:31 ` Meenakshi Aggarwal
  2020-06-09 14:31   ` [PATCH edk2-platforms V2 1/2] Silicon/NXP: Add SATA controller initialization driver Meenakshi Aggarwal
                     ` (2 more replies)
  2 siblings, 3 replies; 12+ messages in thread
From: Meenakshi Aggarwal @ 2020-06-09 14:31 UTC (permalink / raw)
  To: ard.biesheuvel, leif, michael.d.kinney, devel; +Cc: v.sethi, Meenakshi Aggarwal

This patchset implement SATA driver for NXP Platforms enable
SATA for LX2160A Platform.

Changes in v2:
	- Incorporated review comments
	- Removed header file and define macro in .c file

Meenakshi Aggarwal (2):
  Silicon/NXP: Add SATA controller initialization driver
  Platform/NXP:LX2160: Enable support of SATA controller

 Silicon/NXP/NxpQoriqLs.dec                      |   6 +
 Silicon/NXP/LX2160A/LX2160A.dsc.inc             |   5 +
 Silicon/NXP/NxpQoriqLs.dsc.inc                  |  10 ++
 Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc    |   2 +
 Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf    |  18 ++-
 Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf |  45 +++++++
 Silicon/NXP/Drivers/SataInitDxe/SataInit.c      | 124 ++++++++++++++++++++
 7 files changed, 207 insertions(+), 3 deletions(-)
 create mode 100644 Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
 create mode 100644 Silicon/NXP/Drivers/SataInitDxe/SataInit.c

-- 
1.9.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH edk2-platforms V2 1/2] Silicon/NXP: Add SATA controller initialization driver
  2020-06-09 14:31 ` [PATCH edk2-platforms V2 0/2] Add SATA driver support Meenakshi Aggarwal
@ 2020-06-09 14:31   ` Meenakshi Aggarwal
  2020-06-09 14:31   ` [PATCH edk2-platforms V2 2/2] Platform/NXP:LX2160: Enable support of SATA controller Meenakshi Aggarwal
  2020-06-17 11:55   ` [PATCH edk2-platforms V2 0/2] Add SATA driver support Leif Lindholm
  2 siblings, 0 replies; 12+ messages in thread
From: Meenakshi Aggarwal @ 2020-06-09 14:31 UTC (permalink / raw)
  To: ard.biesheuvel, leif, michael.d.kinney, devel
  Cc: v.sethi, Meenakshi Aggarwal, Meenakshi Aggarwal

Add support of SATA controller driver which performs
controller initialization and register itself as NonDiscoverableMmioDevice

Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
 Silicon/NXP/NxpQoriqLs.dec                      |   6 +
 Silicon/NXP/NxpQoriqLs.dsc.inc                  |  10 ++
 Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf |  45 +++++++
 Silicon/NXP/Drivers/SataInitDxe/SataInit.c      | 124 ++++++++++++++++++++
 4 files changed, 185 insertions(+)

diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec
index 72c1744fc934..e83f282ace4e 100644
--- a/Silicon/NXP/NxpQoriqLs.dec
+++ b/Silicon/NXP/NxpQoriqLs.dec
@@ -28,6 +28,7 @@ [PcdsFeatureFlag]
   gNxpQoriqLsTokenSpaceGuid.PcdI2cErratumA009203|FALSE|BOOLEAN|0x00000315
   gNxpQoriqLsTokenSpaceGuid.PcdDcfgBigEndian|FALSE|BOOLEAN|0x00000316
   gNxpQoriqLsTokenSpaceGuid.PcdPciLutBigEndian|FALSE|BOOLEAN|0x00000317
+  gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185|FALSE|BOOLEAN|0x00000318
 
 [PcdsFixedAtBuild.common]
   # Pcds for PCI Express
@@ -41,6 +42,11 @@ [PcdsFixedAtBuild.common]
   gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x0|UINT32|0x00000511
   gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|0|UINT32|0x00000512
 
+  # Pcds for SATA
+  gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr|0x0|UINT64|0x00000350
+  gNxpQoriqLsTokenSpaceGuid.PcdSataSize|0x0|UINT32|0x00000351
+  gNxpQoriqLsTokenSpaceGuid.PcdNumSataController|0x0|UINT32|0x00000352
+
 [PcdsDynamic.common]
   gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable|FALSE|BOOLEAN|0x00000600
   gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl|FALSE|BOOLEAN|0x00000601
diff --git a/Silicon/NXP/NxpQoriqLs.dsc.inc b/Silicon/NXP/NxpQoriqLs.dsc.inc
index 1f0f272da6c7..399ac5de9176 100644
--- a/Silicon/NXP/NxpQoriqLs.dsc.inc
+++ b/Silicon/NXP/NxpQoriqLs.dsc.inc
@@ -101,6 +101,7 @@ [LibraryClasses.common]
 
   PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
   MemoryInitPeiLib|Silicon/NXP/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf
+  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
 
 [LibraryClasses.common.SEC]
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
@@ -378,6 +379,15 @@ [Components.common]
   MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
 
   #
+  # AHCI Support
+  #
+  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
+  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+  MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
+
+  #
   # Bds
   #
   MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
diff --git a/Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf b/Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
new file mode 100644
index 000000000000..e7d6b72bb8df
--- /dev/null
+++ b/Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
@@ -0,0 +1,45 @@
+## @file
+#  Component description file for the Sata Controller initialization driver
+#
+#  Copyright 2017, 2020 NXP
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001A
+  BASE_NAME                      = SataInit
+  FILE_GUID                      = d1f98a9c-87d1-4322-8473-0ea3a91986f1
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = InitializeSataController
+
+[Sources]
+  SataInit.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  Silicon/NXP/NxpQoriqLs.dec
+
+[LibraryClasses]
+  DebugLib
+  NonDiscoverableDeviceRegistrationLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  UefiLib
+
+[FixedPcd]
+  gNxpQoriqLsTokenSpaceGuid.PcdNumSataController
+  gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr
+  gNxpQoriqLsTokenSpaceGuid.PcdSataSize
+
+[FeaturePcd]
+  gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185
+
+[Guids]
+  gEfiEndOfDxeEventGroupGuid
+
+[Depex]
+  TRUE
diff --git a/Silicon/NXP/Drivers/SataInitDxe/SataInit.c b/Silicon/NXP/Drivers/SataInitDxe/SataInit.c
new file mode 100644
index 000000000000..4493299e6222
--- /dev/null
+++ b/Silicon/NXP/Drivers/SataInitDxe/SataInit.c
@@ -0,0 +1,124 @@
+/** @file
+  This driver module adds SATA controller support.
+
+  Copyright 2017-2018, 2020 NXP
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ **/
+
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+#include <Library/NonDiscoverableDeviceRegistrationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#define SATA_PPCFG             0xA8
+#define SATA_PTC               0xC8
+#define SATA_PAXIC             0xC0
+
+#define PORT_PHYSICAL          0xA003FFFE
+#define PORT_TRANSPORT         0x08000025
+#define PORT_RXWM              0x08000029
+#define ENABLE_NONZERO_4MB_PRD 0x10000000
+
+/**
+  This function gets registered as a callback to perform USB controller intialization
+
+  @param  Event         Event whose notification function is being invoked.
+  @param  Context       Pointer to the notification function's context.
+
+**/
+STATIC
+VOID
+EFIAPI
+SataEndOfDxeCallback (
+  IN EFI_EVENT  Event,
+  IN VOID       *Context
+  )
+{
+  EFI_STATUS               Status;
+  UINT32                   NumSataController;
+  UINT32                   Index;
+  UINT32                   Data;
+  UINTN                    ControllerAddr;
+
+  NumSataController = PcdGet32 (PcdNumSataController);
+
+  for (Index = 0; Index < NumSataController; Index++) {
+    ControllerAddr = PcdGet64 (PcdSataBaseAddr) +
+                     (Index * PcdGet32 (PcdSataSize));
+
+    //
+    // configuring Physical Control Layer parameters for Port 0
+    //
+    MmioWrite32 ((UINTN)(ControllerAddr + SATA_PPCFG), PORT_PHYSICAL);
+
+    //
+    // This register controls the configuration of the
+    // Transport Layer for  Port 0
+    // Errata Description : The default Rx watermark value may be insufficient
+    // for some hard drives and result in a false CRC or internal errors.
+    // Workaround: Change PTC[RXWM] field at offset 0xC8 to 0x29. Do not change
+    // the other reserved fields of the register.
+    //
+
+    Data = MmioRead32 ((UINTN)(ControllerAddr + SATA_PTC));
+    if (PcdGetBool (PcdSataErratumA009185)) {
+      Data |= PORT_RXWM;
+    } else {
+      Data |= PORT_TRANSPORT;
+    }
+    MmioWrite32 ((UINTN)(ControllerAddr + SATA_PTC), Data);
+
+    //
+    // Enable Non-Zero 4 MB PRD entries.
+    //
+    MmioOr32 ((UINTN)(ControllerAddr + SATA_PAXIC), ENABLE_NONZERO_4MB_PRD);
+
+    Status = RegisterNonDiscoverableMmioDevice (
+               NonDiscoverableDeviceTypeAhci,
+               NonDiscoverableDeviceDmaTypeNonCoherent,
+               NULL,
+               NULL,
+               1,
+               ControllerAddr, PcdGet32 (PcdSataSize)
+               );
+
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed to register SATA device 0x%x, error 0x%r \n",
+        ControllerAddr, Status));
+    }
+  }
+}
+
+/**
+  The Entry Point of module. It follows the standard UEFI driver model.
+
+  @param[in] ImageHandle       The firmware allocated handle for the EFI image.
+  @param[in] SystemTable       A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS          The entry point is executed successfully.
+  @retval Other                Some error occurs when executing this entry point
+
+**/
+EFI_STATUS
+EFIAPI
+InitializeSataController (
+  IN EFI_HANDLE            ImageHandle,
+  IN EFI_SYSTEM_TABLE      *SystemTable
+  )
+{
+  EFI_STATUS               Status;
+  EFI_EVENT                EndOfDxeEvent;
+
+  Status = gBS->CreateEventEx (
+                  EVT_NOTIFY_SIGNAL,
+                  TPL_CALLBACK,
+                  SataEndOfDxeCallback,
+                  NULL,
+                  &gEfiEndOfDxeEventGroupGuid,
+                  &EndOfDxeEvent
+                  );
+
+  return Status;
+}
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH edk2-platforms V2 2/2] Platform/NXP:LX2160: Enable support of SATA controller
  2020-06-09 14:31 ` [PATCH edk2-platforms V2 0/2] Add SATA driver support Meenakshi Aggarwal
  2020-06-09 14:31   ` [PATCH edk2-platforms V2 1/2] Silicon/NXP: Add SATA controller initialization driver Meenakshi Aggarwal
@ 2020-06-09 14:31   ` Meenakshi Aggarwal
  2020-06-17 11:55   ` [PATCH edk2-platforms V2 0/2] Add SATA driver support Leif Lindholm
  2 siblings, 0 replies; 12+ messages in thread
From: Meenakshi Aggarwal @ 2020-06-09 14:31 UTC (permalink / raw)
  To: ard.biesheuvel, leif, michael.d.kinney, devel
  Cc: v.sethi, Meenakshi Aggarwal, Meenakshi Aggarwal

- Enable support of SATA  drives on lx2160 RDB board.
- Increase FD size to accomodate SATA driver.

Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
 Silicon/NXP/LX2160A/LX2160A.dsc.inc          |  5 +++++
 Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc |  2 ++
 Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf | 18 +++++++++++++++---
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/Silicon/NXP/LX2160A/LX2160A.dsc.inc b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
index 55dd3b5442eb..6bd08d527aed 100644
--- a/Silicon/NXP/LX2160A/LX2160A.dsc.inc
+++ b/Silicon/NXP/LX2160A/LX2160A.dsc.inc
@@ -40,8 +40,13 @@ [PcdsFixedAtBuild.common]
   gNxpQoriqLsTokenSpaceGuid.PcdUsbSize|0x10000
   gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController|2
 
+  gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr|0x3200000
+  gNxpQoriqLsTokenSpaceGuid.PcdSataSize|0x10000
+  gNxpQoriqLsTokenSpaceGuid.PcdNumSataController|0x4
+
 [PcdsFeatureFlag]
   gNxpQoriqLsTokenSpaceGuid.PcdI2cErratumA009203|TRUE
+  gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185|TRUE
 
 ################################################################################
 #
diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
index ec27a1a219a5..2c65577eceab 100644
--- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
+++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
@@ -44,4 +44,6 @@ [Components.common]
   }
 
   Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
+
+  Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
  ##
diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
index 5cb809e8b3a0..e8ac7658c011 100644
--- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
+++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf
@@ -23,10 +23,10 @@
 
 [FD.LX2160ARDB_EFI]
 BaseAddress   = 0x82000000|gArmTokenSpaceGuid.PcdFdBaseAddress  #The base address of the FLASH Device.
-Size          = 0x00160000|gArmTokenSpaceGuid.PcdFdSize         #The size in bytes of the FLASH Device
+Size          = 0x00180000|gArmTokenSpaceGuid.PcdFdSize         #The size in bytes of the FLASH Device
 ErasePolarity = 1
 BlockSize     = 0x10000
-NumBlocks     = 0x16
+NumBlocks     = 0x18
 
 ################################################################################
 #
@@ -43,7 +43,7 @@ [FD.LX2160ARDB_EFI]
 # RegionType <FV, DATA, or FILE>
 #
 ################################################################################
-0x00000000|0x00160000
+0x00000000|0x00180000
 gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
 FV = FVMAIN_COMPACT
 
@@ -132,6 +132,18 @@ [FV.FvMain]
   INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
 
   INF Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
+
+  #
+  # AHCI Support
+  #
+  INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
+  INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+  INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+  INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+  INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
+
+  INF Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
+
   #
   # UEFI application (Shell Embedded Boot Loader)
   #
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH edk2-platforms V2 0/2] Add SATA driver support
  2020-06-09 14:31 ` [PATCH edk2-platforms V2 0/2] Add SATA driver support Meenakshi Aggarwal
  2020-06-09 14:31   ` [PATCH edk2-platforms V2 1/2] Silicon/NXP: Add SATA controller initialization driver Meenakshi Aggarwal
  2020-06-09 14:31   ` [PATCH edk2-platforms V2 2/2] Platform/NXP:LX2160: Enable support of SATA controller Meenakshi Aggarwal
@ 2020-06-17 11:55   ` Leif Lindholm
  2020-06-23 19:08     ` Meenakshi Aggarwal (OSS)
  2 siblings, 1 reply; 12+ messages in thread
From: Leif Lindholm @ 2020-06-17 11:55 UTC (permalink / raw)
  To: Meenakshi Aggarwal; +Cc: ard.biesheuvel, michael.d.kinney, devel, v.sethi

On Tue, Jun 09, 2020 at 20:01:03 +0530, Meenakshi Aggarwal wrote:
> This patchset implement SATA driver for NXP Platforms enable
> SATA for LX2160A Platform.
> 
> Changes in v2:
> 	- Incorporated review comments
> 	- Removed header file and define macro in .c file

For this set:
Reviewed-by: Leif Lindholm <leif@nuviainc.com>

*However*, this set does not apply cleanly without the "Add USB driver
 support" set, and that set has an outstanding question from Ard in
https://edk2.groups.io/g/devel/message/61211.

I'll leave it up to you whether we get that set merged first, or
whether you can rebase this one.

/
    Leif

> Meenakshi Aggarwal (2):
>   Silicon/NXP: Add SATA controller initialization driver
>   Platform/NXP:LX2160: Enable support of SATA controller
> 
>  Silicon/NXP/NxpQoriqLs.dec                      |   6 +
>  Silicon/NXP/LX2160A/LX2160A.dsc.inc             |   5 +
>  Silicon/NXP/NxpQoriqLs.dsc.inc                  |  10 ++
>  Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc    |   2 +
>  Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf    |  18 ++-
>  Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf |  45 +++++++
>  Silicon/NXP/Drivers/SataInitDxe/SataInit.c      | 124 ++++++++++++++++++++
>  7 files changed, 207 insertions(+), 3 deletions(-)
>  create mode 100644 Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
>  create mode 100644 Silicon/NXP/Drivers/SataInitDxe/SataInit.c
> 
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH edk2-platforms V2 0/2] Add SATA driver support
  2020-06-17 11:55   ` [PATCH edk2-platforms V2 0/2] Add SATA driver support Leif Lindholm
@ 2020-06-23 19:08     ` Meenakshi Aggarwal (OSS)
  0 siblings, 0 replies; 12+ messages in thread
From: Meenakshi Aggarwal (OSS) @ 2020-06-23 19:08 UTC (permalink / raw)
  To: Leif Lindholm, Meenakshi Aggarwal (OSS)
  Cc: ard.biesheuvel@arm.com, michael.d.kinney@intel.com,
	devel@edk2.groups.io, Varun Sethi

Hi Leif,

I am working on USB patch.

Thanks,
Meenakshi

> -----Original Message----
> From: Leif Lindholm <leif@nuviainc.com>
> Sent: Wednesday, June 17, 2020 5:25 PM
> To: Meenakshi Aggarwal (OSS) <meenakshi.aggarwal@oss.nxp.com>
> Cc: ard.biesheuvel@arm.com; michael.d.kinney@intel.com;
> devel@edk2.groups.io; Varun Sethi <V.Sethi@nxp.com>
> Subject: Re: [PATCH edk2-platforms V2 0/2] Add SATA driver support
> 
> On Tue, Jun 09, 2020 at 20:01:03 +0530, Meenakshi Aggarwal wrote:
> > This patchset implement SATA driver for NXP Platforms enable SATA for
> > LX2160A Platform.
> >
> > Changes in v2:
> > 	- Incorporated review comments
> > 	- Removed header file and define macro in .c file
> 
> For this set:
> Reviewed-by: Leif Lindholm <leif@nuviainc.com>
> 
> *However*, this set does not apply cleanly without the "Add USB driver
> support" set, and that set has an outstanding question from Ard in
> https://edk2.groups.io/g/devel/message/61211.
> 
> I'll leave it up to you whether we get that set merged first, or whether you can
> rebase this one.
> 
> /
>     Leif
> 
> > Meenakshi Aggarwal (2):
> >   Silicon/NXP: Add SATA controller initialization driver
> >   Platform/NXP:LX2160: Enable support of SATA controller
> >
> >  Silicon/NXP/NxpQoriqLs.dec                      |   6 +
> >  Silicon/NXP/LX2160A/LX2160A.dsc.inc             |   5 +
> >  Silicon/NXP/NxpQoriqLs.dsc.inc                  |  10 ++
> >  Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc    |   2 +
> >  Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.fdf    |  18 ++-
> >  Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf |  45 +++++++
> >  Silicon/NXP/Drivers/SataInitDxe/SataInit.c      | 124 ++++++++++++++++++++
> >  7 files changed, 207 insertions(+), 3 deletions(-)  create mode
> > 100644 Silicon/NXP/Drivers/SataInitDxe/SataInitDxe.inf
> >  create mode 100644 Silicon/NXP/Drivers/SataInitDxe/SataInit.c
> >
> > --
> > 1.9.1
> >

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-06-23 19:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-05 16:02 [PATCH edk2-platforms 0/2] Add SATA driver support Meenakshi Aggarwal
2020-06-05 16:02 ` [PATCH edk2-platforms 1/2] Silicon/NXP: Add SATA controller initialization driver Meenakshi Aggarwal
2020-06-05 13:00   ` Ard Biesheuvel
2020-06-08 11:44     ` Meenakshi Aggarwal
2020-06-05 16:02 ` [PATCH edk2-platforms 2/2] Platform/NXP:LX2160: Enable support of SATA controller Meenakshi Aggarwal
2020-06-05 13:01   ` Ard Biesheuvel
2020-06-05 13:09     ` Leif Lindholm
2020-06-09 14:31 ` [PATCH edk2-platforms V2 0/2] Add SATA driver support Meenakshi Aggarwal
2020-06-09 14:31   ` [PATCH edk2-platforms V2 1/2] Silicon/NXP: Add SATA controller initialization driver Meenakshi Aggarwal
2020-06-09 14:31   ` [PATCH edk2-platforms V2 2/2] Platform/NXP:LX2160: Enable support of SATA controller Meenakshi Aggarwal
2020-06-17 11:55   ` [PATCH edk2-platforms V2 0/2] Add SATA driver support Leif Lindholm
2020-06-23 19:08     ` Meenakshi Aggarwal (OSS)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox