Home | History | Annotate | Download | only in DwUfsHcDxe
      1 /** @file
      2   UfsHcDxe driver is used to provide platform-dependent info, mainly UFS host controller
      3   MMIO base, to upper layer UFS drivers.
      4 
      5   Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
      6   This program and the accompanying materials
      7   are licensed and made available under the terms and conditions of the BSD License
      8   which accompanies this distribution.  The full text of the license may be found at
      9   http://opensource.org/licenses/bsd-license.php.
     10 
     11   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     13 
     14 **/
     15 
     16 #ifndef _DW_UFS_HOST_CONTROLLER_H_
     17 #define _DW_UFS_HOST_CONTROLLER_H_
     18 
     19 #include <Uefi.h>
     20 
     21 #include <Protocol/ComponentName.h>
     22 #include <Protocol/ComponentName2.h>
     23 #include <Protocol/DevicePath.h>
     24 #include <Protocol/DriverBinding.h>
     25 #include <Protocol/LoadedImage.h>
     26 #include <Protocol/PciIo.h>
     27 #include <Protocol/UfsHostController.h>
     28 
     29 #include <Library/ArmLib.h>
     30 #include <Library/BaseLib.h>
     31 #include <Library/BaseMemoryLib.h>
     32 #include <Library/DebugLib.h>
     33 #include <Library/DevicePathLib.h>
     34 #include <Library/DmaLib.h>
     35 #include <Library/IoLib.h>
     36 #include <Library/MemoryAllocationLib.h>
     37 #include <Library/UefiBootServicesTableLib.h>
     38 #include <Library/UefiDriverEntryPoint.h>
     39 #include <Library/UefiLib.h>
     40 
     41 //
     42 // Host Capabilities Register Offsets
     43 //
     44 #define UFS_HC_CAP_OFFSET          0x0000  // Controller Capabilities
     45 #define UFS_HC_VER_OFFSET          0x0008  // Version
     46 #define UFS_HC_DDID_OFFSET         0x0010  // Device ID and Device Class
     47 #define UFS_HC_PMID_OFFSET         0x0014  // Product ID and Manufacturer ID
     48 #define UFS_HC_AHIT_OFFSET         0x0018  // Auto-Hibernate Idle Timer
     49 //
     50 // Operation and Runtime Register Offsets
     51 //
     52 #define UFS_HC_IS_OFFSET           0x0020  // Interrupt Status
     53 #define UFS_HC_IE_OFFSET           0x0024  // Interrupt Enable
     54 #define UFS_HC_STATUS_OFFSET       0x0030  // Host Controller Status
     55 #define UFS_HC_ENABLE_OFFSET       0x0034  // Host Controller Enable
     56 #define UFS_HC_UECPA_OFFSET        0x0038  // Host UIC Error Code PHY Adapter Layer
     57 #define UFS_HC_UECDL_OFFSET        0x003c  // Host UIC Error Code Data Link Layer
     58 #define UFS_HC_UECN_OFFSET         0x0040  // Host UIC Error Code Network Layer
     59 #define UFS_HC_UECT_OFFSET         0x0044  // Host UIC Error Code Transport Layer
     60 #define UFS_HC_UECDME_OFFSET       0x0048  // Host UIC Error Code DME
     61 #define UFS_HC_UTRIACR_OFFSET      0x004c  // UTP Transfer Request Interrupt Aggregation Control Register
     62 //
     63 // UTP Transfer Register Offsets
     64 //
     65 #define UFS_HC_UTRLBA_OFFSET       0x0050  // UTP Transfer Request List Base Address
     66 #define UFS_HC_UTRLBAU_OFFSET      0x0054  // UTP Transfer Request List Base Address Upper 32-Bits
     67 #define UFS_HC_UTRLDBR_OFFSET      0x0058  // UTP Transfer Request List Door Bell Register
     68 #define UFS_HC_UTRLCLR_OFFSET      0x005c  // UTP Transfer Request List CLear Register
     69 #define UFS_HC_UTRLRSR_OFFSET      0x0060  // UTP Transfer Request Run-Stop Register
     70 //
     71 // UTP Task Management Register Offsets
     72 //
     73 #define UFS_HC_UTMRLBA_OFFSET      0x0070  // UTP Task Management Request List Base Address
     74 #define UFS_HC_UTMRLBAU_OFFSET     0x0074  // UTP Task Management Request List Base Address Upper 32-Bits
     75 #define UFS_HC_UTMRLDBR_OFFSET     0x0078  // UTP Task Management Request List Door Bell Register
     76 #define UFS_HC_UTMRLCLR_OFFSET     0x007c  // UTP Task Management Request List CLear Register
     77 #define UFS_HC_UTMRLRSR_OFFSET     0x0080  // UTP Task Management Run-Stop Register
     78 //
     79 // UIC Command Register Offsets
     80 //
     81 #define UFS_HC_UIC_CMD_OFFSET      0x0090  // UIC Command Register
     82 #define UFS_HC_UCMD_ARG1_OFFSET    0x0094  // UIC Command Argument 1
     83 #define UFS_HC_UCMD_ARG2_OFFSET    0x0098  // UIC Command Argument 2
     84 #define UFS_HC_UCMD_ARG3_OFFSET    0x009c  // UIC Command Argument 3
     85 //
     86 // UMA Register Offsets
     87 //
     88 #define UFS_HC_UMA_OFFSET          0x00b0  // Reserved for Unified Memory Extension
     89 
     90 #define UFS_HC_HCLKDIV_OFFSET      0x00fc
     91 
     92 #define UFS_HC_HCE_EN              BIT0
     93 #define UFS_HC_HCS_DP              BIT0
     94 #define UFS_HC_HCS_UCRDY           BIT3
     95 #define UFS_HC_IS_UE               BIT2
     96 #define UFS_HC_IS_ULSS             BIT8
     97 #define UFS_HC_IS_UCCS             BIT10
     98 #define UFS_HC_CAP_64ADDR          BIT24
     99 #define UFS_HC_CAP_NUTMRS          (BIT16 | BIT17 | BIT18)
    100 #define UFS_HC_CAP_NUTRS           (BIT0 | BIT1 | BIT2 | BIT3 | BIT4)
    101 #define UFS_HC_UTMRLRSR            BIT0
    102 #define UFS_HC_UTRLRSR             BIT0
    103 
    104 #define UFS_UIC_DME_GET            1
    105 #define UFS_UIC_DME_SET            2
    106 
    107 #define UFS_INT_UPMS               BIT4
    108 
    109 #define HCS_UPMCRS_MASK            (BIT10 | BIT9 | BIT8)
    110 #define HCS_PWR_LOCAL              BIT8
    111 
    112 extern EFI_DRIVER_BINDING_PROTOCOL                gUfsHcDriverBinding;
    113 extern EFI_COMPONENT_NAME_PROTOCOL                gUfsHcComponentName;
    114 extern EFI_COMPONENT_NAME2_PROTOCOL               gUfsHcComponentName2;
    115 
    116 #define UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME	(1 << 0)
    117 
    118 //
    119 // Unique signature for private data structure.
    120 //
    121 #define UFS_HC_PRIVATE_DATA_SIGNATURE             SIGNATURE_32 ('U','F','S','H')
    122 
    123 typedef struct _UFS_HOST_CONTROLLER_PRIVATE_DATA  UFS_HOST_CONTROLLER_PRIVATE_DATA;
    124 
    125 //
    126 // Nvme private data structure.
    127 //
    128 struct _UFS_HOST_CONTROLLER_PRIVATE_DATA {
    129   UINT32                             Signature;
    130   EFI_HANDLE                         Handle;
    131 
    132   EDKII_UFS_HOST_CONTROLLER_PROTOCOL UfsHc;
    133   EFI_PCI_IO_PROTOCOL                *PciIo;
    134   UINT8                              BarIndex;
    135   UINT64                             PciAttributes;
    136 
    137   UINTN                              RegBase;
    138 };
    139 
    140 #define UFS_HOST_CONTROLLER_PRIVATE_DATA_FROM_UFSHC(a) \
    141   CR (a, \
    142       UFS_HOST_CONTROLLER_PRIVATE_DATA, \
    143       UfsHc, \
    144       UFS_HC_PRIVATE_DATA_SIGNATURE \
    145       )
    146 
    147 /**
    148   Retrieves a Unicode string that is the user readable name of the driver.
    149 
    150   This function retrieves the user readable name of a driver in the form of a
    151   Unicode string. If the driver specified by This has a user readable name in
    152   the language specified by Language, then a pointer to the driver name is
    153   returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
    154   by This does not support the language specified by Language,
    155   then EFI_UNSUPPORTED is returned.
    156 
    157   @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
    158                                 EFI_COMPONENT_NAME_PROTOCOL instance.
    159 
    160   @param  Language[in]          A pointer to a Null-terminated ASCII string
    161                                 array indicating the language. This is the
    162                                 language of the driver name that the caller is
    163                                 requesting, and it must match one of the
    164                                 languages specified in SupportedLanguages. The
    165                                 number of languages supported by a driver is up
    166                                 to the driver writer. Language is specified
    167                                 in RFC 4646 or ISO 639-2 language code format.
    168 
    169   @param  DriverName[out]       A pointer to the Unicode string to return.
    170                                 This Unicode string is the name of the
    171                                 driver specified by This in the language
    172                                 specified by Language.
    173 
    174   @retval EFI_SUCCESS           The Unicode string for the Driver specified by
    175                                 This and the language specified by Language was
    176                                 returned in DriverName.
    177 
    178   @retval EFI_INVALID_PARAMETER Language is NULL.
    179 
    180   @retval EFI_INVALID_PARAMETER DriverName is NULL.
    181 
    182   @retval EFI_UNSUPPORTED       The driver specified by This does not support
    183                                 the language specified by Language.
    184 
    185 **/
    186 EFI_STATUS
    187 EFIAPI
    188 UfsHcComponentNameGetDriverName (
    189   IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
    190   IN  CHAR8                        *Language,
    191   OUT CHAR16                       **DriverName
    192   );
    193 
    194 /**
    195   Retrieves a Unicode string that is the user readable name of the controller
    196   that is being managed by a driver.
    197 
    198   This function retrieves the user readable name of the controller specified by
    199   ControllerHandle and ChildHandle in the form of a Unicode string. If the
    200   driver specified by This has a user readable name in the language specified by
    201   Language, then a pointer to the controller name is returned in ControllerName,
    202   and EFI_SUCCESS is returned.  If the driver specified by This is not currently
    203   managing the controller specified by ControllerHandle and ChildHandle,
    204   then EFI_UNSUPPORTED is returned.  If the driver specified by This does not
    205   support the language specified by Language, then EFI_UNSUPPORTED is returned.
    206 
    207   @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
    208                                 EFI_COMPONENT_NAME_PROTOCOL instance.
    209 
    210   @param  ControllerHandle[in]  The handle of a controller that the driver
    211                                 specified by This is managing.  This handle
    212                                 specifies the controller whose name is to be
    213                                 returned.
    214 
    215   @param  ChildHandle[in]       The handle of the child controller to retrieve
    216                                 the name of.  This is an optional parameter that
    217                                 may be NULL.  It will be NULL for device
    218                                 drivers.  It will also be NULL for a bus drivers
    219                                 that wish to retrieve the name of the bus
    220                                 controller.  It will not be NULL for a bus
    221                                 driver that wishes to retrieve the name of a
    222                                 child controller.
    223 
    224   @param  Language[in]          A pointer to a Null-terminated ASCII string
    225                                 array indicating the language.  This is the
    226                                 language of the driver name that the caller is
    227                                 requesting, and it must match one of the
    228                                 languages specified in SupportedLanguages. The
    229                                 number of languages supported by a driver is up
    230                                 to the driver writer. Language is specified in
    231                                 RFC 4646 or ISO 639-2 language code format.
    232 
    233   @param  ControllerName[out]   A pointer to the Unicode string to return.
    234                                 This Unicode string is the name of the
    235                                 controller specified by ControllerHandle and
    236                                 ChildHandle in the language specified by
    237                                 Language from the point of view of the driver
    238                                 specified by This.
    239 
    240   @retval EFI_SUCCESS           The Unicode string for the user readable name in
    241                                 the language specified by Language for the
    242                                 driver specified by This was returned in
    243                                 DriverName.
    244 
    245   @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
    246 
    247   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
    248                                 EFI_HANDLE.
    249 
    250   @retval EFI_INVALID_PARAMETER Language is NULL.
    251 
    252   @retval EFI_INVALID_PARAMETER ControllerName is NULL.
    253 
    254   @retval EFI_UNSUPPORTED       The driver specified by This is not currently
    255                                 managing the controller specified by
    256                                 ControllerHandle and ChildHandle.
    257 
    258   @retval EFI_UNSUPPORTED       The driver specified by This does not support
    259                                 the language specified by Language.
    260 
    261 **/
    262 EFI_STATUS
    263 EFIAPI
    264 UfsHcComponentNameGetControllerName (
    265   IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,
    266   IN  EFI_HANDLE                                      ControllerHandle,
    267   IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,
    268   IN  CHAR8                                           *Language,
    269   OUT CHAR16                                          **ControllerName
    270   );
    271 
    272 /**
    273   Tests to see if this driver supports a given controller. If a child device is provided,
    274   it further tests to see if this driver supports creating a handle for the specified child device.
    275 
    276   This function checks to see if the driver specified by This supports the device specified by
    277   ControllerHandle. Drivers will typically use the device path attached to
    278   ControllerHandle and/or the services from the bus I/O abstraction attached to
    279   ControllerHandle to determine if the driver supports ControllerHandle. This function
    280   may be called many times during platform initialization. In order to reduce boot times, the tests
    281   performed by this function must be very small, and take as little time as possible to execute. This
    282   function must not change the state of any hardware devices, and this function must be aware that the
    283   device specified by ControllerHandle may already be managed by the same driver or a
    284   different driver. This function must match its calls to AllocatePages() with FreePages(),
    285   AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
    286   Since ControllerHandle may have been previously started by the same driver, if a protocol is
    287   already in the opened state, then it must not be closed with CloseProtocol(). This is required
    288   to guarantee the state of ControllerHandle is not modified by this function.
    289 
    290   @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
    291   @param[in]  ControllerHandle     The handle of the controller to test. This handle
    292                                    must support a protocol interface that supplies
    293                                    an I/O abstraction to the driver.
    294   @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This
    295                                    parameter is ignored by device drivers, and is optional for bus
    296                                    drivers. For bus drivers, if this parameter is not NULL, then
    297                                    the bus driver must determine if the bus controller specified
    298                                    by ControllerHandle and the child controller specified
    299                                    by RemainingDevicePath are both supported by this
    300                                    bus driver.
    301 
    302   @retval EFI_SUCCESS              The device specified by ControllerHandle and
    303                                    RemainingDevicePath is supported by the driver specified by This.
    304   @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and
    305                                    RemainingDevicePath is already being managed by the driver
    306                                    specified by This.
    307   @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and
    308                                    RemainingDevicePath is already being managed by a different
    309                                    driver or an application that requires exclusive access.
    310                                    Currently not implemented.
    311   @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and
    312                                    RemainingDevicePath is not supported by the driver specified by This.
    313 **/
    314 EFI_STATUS
    315 EFIAPI
    316 UfsHcDriverBindingSupported (
    317   IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    318   IN EFI_HANDLE                   Controller,
    319   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath
    320   );
    321 
    322 /**
    323   Starts a device controller or a bus controller.
    324 
    325   The Start() function is designed to be invoked from the EFI boot service ConnectController().
    326   As a result, much of the error checking on the parameters to Start() has been moved into this
    327   common boot service. It is legal to call Start() from other locations,
    328   but the following calling restrictions must be followed or the system behavior will not be deterministic.
    329   1. ControllerHandle must be a valid EFI_HANDLE.
    330   2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
    331      EFI_DEVICE_PATH_PROTOCOL.
    332   3. Prior to calling Start(), the Supported() function for the driver specified by This must
    333      have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
    334 
    335   @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
    336   @param[in]  ControllerHandle     The handle of the controller to start. This handle
    337                                    must support a protocol interface that supplies
    338                                    an I/O abstraction to the driver.
    339   @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This
    340                                    parameter is ignored by device drivers, and is optional for bus
    341                                    drivers. For a bus driver, if this parameter is NULL, then handles
    342                                    for all the children of Controller are created by this driver.
    343                                    If this parameter is not NULL and the first Device Path Node is
    344                                    not the End of Device Path Node, then only the handle for the
    345                                    child device specified by the first Device Path Node of
    346                                    RemainingDevicePath is created by this driver.
    347                                    If the first Device Path Node of RemainingDevicePath is
    348                                    the End of Device Path Node, no child handle is created by this
    349                                    driver.
    350 
    351   @retval EFI_SUCCESS              The device was started.
    352   @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.Currently not implemented.
    353   @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.
    354   @retval Others                   The driver failded to start the device.
    355 
    356 **/
    357 EFI_STATUS
    358 EFIAPI
    359 UfsHcDriverBindingStart (
    360   IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    361   IN EFI_HANDLE                   Controller,
    362   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath
    363   );
    364 
    365 /**
    366   Stops a device controller or a bus controller.
    367 
    368   The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
    369   As a result, much of the error checking on the parameters to Stop() has been moved
    370   into this common boot service. It is legal to call Stop() from other locations,
    371   but the following calling restrictions must be followed or the system behavior will not be deterministic.
    372   1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
    373      same driver's Start() function.
    374   2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
    375      EFI_HANDLE. In addition, all of these handles must have been created in this driver's
    376      Start() function, and the Start() function must have called OpenProtocol() on
    377      ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
    378 
    379   @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
    380   @param[in]  ControllerHandle  A handle to the device being stopped. The handle must
    381                                 support a bus specific I/O protocol for the driver
    382                                 to use to stop the device.
    383   @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.
    384   @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL
    385                                 if NumberOfChildren is 0.
    386 
    387   @retval EFI_SUCCESS           The device was stopped.
    388   @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.
    389 
    390 **/
    391 EFI_STATUS
    392 EFIAPI
    393 UfsHcDriverBindingStop (
    394   IN  EFI_DRIVER_BINDING_PROTOCOL     *This,
    395   IN  EFI_HANDLE                      Controller,
    396   IN  UINTN                           NumberOfChildren,
    397   IN  EFI_HANDLE                      *ChildHandleBuffer
    398   );
    399 
    400 /**
    401   Get the MMIO base of the UFS host controller.
    402 
    403   @param[in]   This             A pointer to the EFI_UFS_HOST_CONTROLLER_PROTOCOL instance.
    404   @param[out]  MmioBar          The MMIO base address of UFS host controller.
    405 
    406   @retval EFI_SUCCESS           The operation succeeds.
    407   @retval others                The operation fails.
    408 **/
    409 EFI_STATUS
    410 EFIAPI
    411 UfsHcGetMmioBar (
    412   IN     EDKII_UFS_HOST_CONTROLLER_PROTOCOL *This,
    413      OUT UINTN                              *MmioBar
    414   );
    415 
    416 /**
    417   Provides the UFS controller-specific addresses needed to access system memory.
    418 
    419   @param  This                  A pointer to the EFI_UFS_HOST_CONTROLLER_PROTOCOL instance.
    420   @param  Operation             Indicates if the bus master is going to read or write to system memory.
    421   @param  HostAddress           The system memory address to map to the UFS controller.
    422   @param  NumberOfBytes         On input the number of bytes to map. On output the number of bytes
    423                                 that were mapped.
    424   @param  DeviceAddress         The resulting map address for the bus master UFS controller to use to
    425                                 access the hosts HostAddress.
    426   @param  Mapping               A resulting value to pass to Unmap().
    427 
    428   @retval EFI_SUCCESS           The range was mapped for the returned NumberOfBytes.
    429   @retval EFI_UNSUPPORTED       The HostAddress cannot be mapped as a common buffer.
    430   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
    431   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
    432   @retval EFI_DEVICE_ERROR      The system hardware could not map the requested address.
    433 
    434 **/
    435 EFI_STATUS
    436 EFIAPI
    437 UfsHcMap (
    438   IN     EDKII_UFS_HOST_CONTROLLER_PROTOCOL   *This,
    439   IN     EDKII_UFS_HOST_CONTROLLER_OPERATION  Operation,
    440   IN     VOID                                 *HostAddress,
    441   IN OUT UINTN                                *NumberOfBytes,
    442      OUT EFI_PHYSICAL_ADDRESS                 *DeviceAddress,
    443      OUT VOID                                 **Mapping
    444   );
    445 
    446 /**
    447   Completes the Map() operation and releases any corresponding resources.
    448 
    449   @param  This                  A pointer to the EFI_UFS_HOST_CONTROLLER_PROTOCOL instance.
    450   @param  Mapping               The mapping value returned from Map().
    451 
    452   @retval EFI_SUCCESS           The range was unmapped.
    453   @retval EFI_DEVICE_ERROR      The data was not committed to the target system memory.
    454 
    455 **/
    456 EFI_STATUS
    457 EFIAPI
    458 UfsHcUnmap (
    459   IN  EDKII_UFS_HOST_CONTROLLER_PROTOCOL   *This,
    460   IN  VOID                                 *Mapping
    461   );
    462 
    463 /**
    464   Allocates pages that are suitable for an EfiUfsHcOperationBusMasterCommonBuffer
    465   mapping.
    466 
    467   @param  This                  A pointer to the EFI_UFS_HOST_CONTROLLER_PROTOCOL instance.
    468   @param  Type                  This parameter is not used and must be ignored.
    469   @param  MemoryType            The type of memory to allocate, EfiBootServicesData or
    470                                 EfiRuntimeServicesData.
    471   @param  Pages                 The number of pages to allocate.
    472   @param  HostAddress           A pointer to store the base system memory address of the
    473                                 allocated range.
    474   @param  Attributes            The requested bit mask of attributes for the allocated range.
    475 
    476   @retval EFI_SUCCESS           The requested memory pages were allocated.
    477   @retval EFI_UNSUPPORTED       Attributes is unsupported. The only legal attribute bits are
    478                                 MEMORY_WRITE_COMBINE and MEMORY_CACHED.
    479   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
    480   @retval EFI_OUT_OF_RESOURCES  The memory pages could not be allocated.
    481 
    482 **/
    483 EFI_STATUS
    484 EFIAPI
    485 UfsHcAllocateBuffer (
    486   IN     EDKII_UFS_HOST_CONTROLLER_PROTOCOL *This,
    487   IN     EFI_ALLOCATE_TYPE                  Type,
    488   IN     EFI_MEMORY_TYPE                    MemoryType,
    489   IN     UINTN                              Pages,
    490      OUT VOID                               **HostAddress,
    491   IN     UINT64                             Attributes
    492   );
    493 
    494 /**
    495   Frees memory that was allocated with AllocateBuffer().
    496 
    497   @param  This                  A pointer to the EFI_UFS_HOST_CONTROLLER_PROTOCOL instance.
    498   @param  Pages                 The number of pages to free.
    499   @param  HostAddress           The base system memory address of the allocated range.
    500 
    501   @retval EFI_SUCCESS           The requested memory pages were freed.
    502   @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
    503                                 was not allocated with AllocateBuffer().
    504 
    505 **/
    506 EFI_STATUS
    507 EFIAPI
    508 UfsHcFreeBuffer (
    509   IN  EDKII_UFS_HOST_CONTROLLER_PROTOCOL    *This,
    510   IN  UINTN                                 Pages,
    511   IN  VOID                                  *HostAddress
    512   );
    513 
    514 /**
    515   Flushes all posted write transactions from the UFS bus to attached UFS device.
    516 
    517   @param  This                  A pointer to the EFI_UFS_HOST_CONTROLLER_PROTOCOL instance.
    518 
    519   @retval EFI_SUCCESS           The posted write transactions were flushed from the UFS bus
    520                                 to attached UFS device.
    521   @retval EFI_DEVICE_ERROR      The posted write transactions were not flushed from the UFS
    522                                 bus to attached UFS device due to a hardware error.
    523 
    524 **/
    525 EFI_STATUS
    526 EFIAPI
    527 UfsHcFlush (
    528   IN  EDKII_UFS_HOST_CONTROLLER_PROTOCOL   *This
    529   );
    530 
    531 /**
    532   Enable a UFS bus driver to access UFS MMIO registers in the UFS Host Controller memory space.
    533 
    534   @param  This                  A pointer to the EDKII_UFS_HOST_CONTROLLER_PROTOCOL instance.
    535   @param  Width                 Signifies the width of the memory operations.
    536   @param  Offset                The offset within the UFS Host Controller MMIO space to start the
    537                                 memory operation.
    538   @param  Count                 The number of memory operations to perform.
    539   @param  Buffer                For read operations, the destination buffer to store the results.
    540                                 For write operations, the source buffer to write data from.
    541 
    542   @retval EFI_SUCCESS           The data was read from or written to the UFS host controller.
    543   @retval EFI_UNSUPPORTED       The address range specified by Offset, Width, and Count is not
    544                                 valid for the UFS Host Controller memory space.
    545   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
    546   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
    547 
    548 **/
    549 EFI_STATUS
    550 EFIAPI
    551 UfsHcMmioRead (
    552   IN     EDKII_UFS_HOST_CONTROLLER_PROTOCOL        *This,
    553   IN     EDKII_UFS_HOST_CONTROLLER_PROTOCOL_WIDTH  Width,
    554   IN     UINT64                                    Offset,
    555   IN     UINTN                                     Count,
    556   IN OUT VOID                                      *Buffer
    557   );
    558 
    559 /**
    560   Enable a UFS bus driver to access UFS MMIO registers in the UFS Host Controller memory space.
    561 
    562   @param  This                  A pointer to the EDKII_UFS_HOST_CONTROLLER_PROTOCOL instance.
    563   @param  Width                 Signifies the width of the memory operations.
    564   @param  Offset                The offset within the UFS Host Controller MMIO space to start the
    565                                 memory operation.
    566   @param  Count                 The number of memory operations to perform.
    567   @param  Buffer                For read operations, the destination buffer to store the results.
    568                                 For write operations, the source buffer to write data from.
    569 
    570   @retval EFI_SUCCESS           The data was read from or written to the UFS host controller.
    571   @retval EFI_UNSUPPORTED       The address range specified by Offset, Width, and Count is not
    572                                 valid for the UFS Host Controller memory space.
    573   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
    574   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
    575 
    576 **/
    577 EFI_STATUS
    578 EFIAPI
    579 UfsHcMmioWrite (
    580   IN     EDKII_UFS_HOST_CONTROLLER_PROTOCOL        *This,
    581   IN     EDKII_UFS_HOST_CONTROLLER_PROTOCOL_WIDTH  Width,
    582   IN     UINT64                                    Offset,
    583   IN     UINTN                                     Count,
    584   IN OUT VOID                                      *Buffer
    585   );
    586 
    587 EFI_STATUS
    588 EFIAPI
    589 UfsHcPhyInit (
    590   IN     EDKII_UFS_HOST_CONTROLLER_PROTOCOL        *This
    591   );
    592 
    593 EFI_STATUS
    594 EFIAPI
    595 UfsHcPhySetPowerMode (
    596   IN     EDKII_UFS_HOST_CONTROLLER_PROTOCOL        *This,
    597   IN     UINT32                                    DevQuirks
    598   );
    599 #endif /* _DW_UFS_HOST_CONTROLLER_H_ */
    600