Home | History | Annotate | Download | only in HiKey960Lib
      1 /** @file
      2 *
      3 *  Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
      4 *
      5 *  This program and the accompanying materials
      6 *  are licensed and made available under the terms and conditions of the BSD License
      7 *  which accompanies this distribution.  The full text of the license may be found at
      8 *  http://opensource.org/licenses/bsd-license.php
      9 *
     10 *  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     11 *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12 *
     13 **/
     14 
     15 #include <Drivers/PL011Uart.h>
     16 
     17 #include <Library/IoLib.h>
     18 #include <Library/ArmPlatformLib.h>
     19 #include <Library/DebugLib.h>
     20 #include <Library/PcdLib.h>
     21 
     22 #include <Ppi/ArmMpCoreInfo.h>
     23 
     24 ARM_CORE_INFO mHiKey960InfoTable[] = {
     25   {
     26     // Cluster 0, Core 0
     27     0x0, 0x0,
     28 
     29     // MP Core MailBox Set/Get/Clear Addresses and Clear Value
     30     (UINT64)0xFFFFFFFF
     31   },
     32   {
     33     // Cluster 0, Core 1
     34     0x0, 0x1,
     35 
     36     // MP Core MailBox Set/Get/Clear Addresses and Clear Value
     37     (UINT64)0xFFFFFFFF
     38   },
     39   {
     40     // Cluster 0, Core 2
     41     0x0, 0x2,
     42 
     43     // MP Core MailBox Set/Get/Clear Addresses and Clear Value
     44     (UINT64)0xFFFFFFFF
     45   },
     46   {
     47     // Cluster 0, Core 3
     48     0x0, 0x3,
     49 
     50     // MP Core MailBox Set/Get/Clear Addresses and Clear Value
     51     (UINT64)0xFFFFFFFF
     52   },
     53   {
     54     // Cluster 1, Core 0
     55     0x1, 0x0,
     56 
     57     // MP Core MailBox Set/Get/Clear Addresses and Clear Value
     58     (UINT64)0xFFFFFFFF
     59   },
     60   {
     61     // Cluster 1, Core 1
     62     0x1, 0x1,
     63 
     64     // MP Core MailBox Set/Get/Clear Addresses and Clear Value
     65     (UINT64)0xFFFFFFFF
     66   },
     67   {
     68     // Cluster 1, Core 2
     69     0x1, 0x2,
     70 
     71     // MP Core MailBox Set/Get/Clear Addresses and Clear Value
     72     (UINT64)0xFFFFFFFF
     73   },
     74   {
     75     // Cluster 1, Core 3
     76     0x1, 0x3,
     77 
     78     // MP Core MailBox Set/Get/Clear Addresses and Clear Value
     79     (UINT64)0xFFFFFFFF
     80   }
     81 };
     82 
     83 /**
     84   Return the current Boot Mode
     85 
     86   This function returns the boot reason on the platform
     87 
     88   @return   Return the current Boot Mode of the platform
     89 
     90 **/
     91 EFI_BOOT_MODE
     92 ArmPlatformGetBootMode (
     93   VOID
     94   )
     95 {
     96   return BOOT_WITH_FULL_CONFIGURATION;
     97 }
     98 
     99 /**
    100   Initialize controllers that must setup in the normal world
    101 
    102   This function is called by the ArmPlatformPkg/Pei or ArmPlatformPkg/Pei/PlatformPeim
    103   in the PEI phase.
    104 
    105 **/
    106 RETURN_STATUS
    107 ArmPlatformInitialize (
    108   IN  UINTN                     MpId
    109   )
    110 {
    111   RETURN_STATUS       Status;
    112   UINT64              BaudRate;
    113   UINT32              ReceiveFifoDepth;
    114   EFI_PARITY_TYPE     Parity;
    115   UINT8               DataBits;
    116   EFI_STOP_BITS_TYPE  StopBits;
    117 
    118   Status = RETURN_SUCCESS;
    119 
    120   //
    121   // Initialize the Serial Debug UART
    122   //
    123   if (FixedPcdGet64 (PcdSerialDbgRegisterBase)) {
    124     ReceiveFifoDepth = 0; // Use the default value for FIFO depth
    125     Parity = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity);
    126     DataBits = FixedPcdGet8 (PcdUartDefaultDataBits);
    127     StopBits = (EFI_STOP_BITS_TYPE)FixedPcdGet8 (PcdUartDefaultStopBits);
    128 
    129     BaudRate = (UINTN)FixedPcdGet64 (PcdSerialDbgUartBaudRate);
    130     Status = PL011UartInitializePort (
    131                (UINTN)FixedPcdGet64 (PcdSerialDbgRegisterBase),
    132                FixedPcdGet32 (PcdSerialDbgUartClkInHz),
    133                &BaudRate,
    134                &ReceiveFifoDepth,
    135                &Parity,
    136                &DataBits,
    137                &StopBits
    138                );
    139   }
    140 
    141   return Status;
    142 }
    143 
    144 /**
    145   Initialize the system (or sometimes called permanent) memory
    146 
    147   This memory is generally represented by the DRAM.
    148 
    149 **/
    150 VOID
    151 ArmPlatformInitializeSystemMemory (
    152   VOID
    153   )
    154 {
    155 }
    156 
    157 EFI_STATUS
    158 PrePeiCoreGetMpCoreInfo (
    159   OUT UINTN                   *CoreCount,
    160   OUT ARM_CORE_INFO           **ArmCoreTable
    161   )
    162 {
    163   // Only support one cluster
    164   *CoreCount    = sizeof(mHiKey960InfoTable) / sizeof(ARM_CORE_INFO);
    165   *ArmCoreTable = mHiKey960InfoTable;
    166   return EFI_SUCCESS;
    167 }
    168 
    169 // Needs to be declared in the file. Otherwise gArmMpCoreInfoPpiGuid is undefined in the contect of PrePeiCore
    170 EFI_GUID mArmMpCoreInfoPpiGuid = ARM_MP_CORE_INFO_PPI_GUID;
    171 ARM_MP_CORE_INFO_PPI mMpCoreInfoPpi = { PrePeiCoreGetMpCoreInfo };
    172 
    173 EFI_PEI_PPI_DESCRIPTOR      gPlatformPpiTable[] = {
    174   {
    175     EFI_PEI_PPI_DESCRIPTOR_PPI,
    176     &mArmMpCoreInfoPpiGuid,
    177     &mMpCoreInfoPpi
    178   }
    179 };
    180 
    181 VOID
    182 ArmPlatformGetPlatformPpiList (
    183   OUT UINTN                   *PpiListSize,
    184   OUT EFI_PEI_PPI_DESCRIPTOR  **PpiList
    185   )
    186 {
    187   *PpiListSize = sizeof(gPlatformPpiTable);
    188   *PpiList = gPlatformPpiTable;
    189 }
    190