Home | History | Annotate | Download | only in PchPlatformLib
      1 /**
      2 
      3 Copyright (c) 2012  - 2014, Intel Corporation. All rights reserved
      4 
      5   This program and the accompanying materials are licensed and made available under
      7   the terms and conditions of the BSD License that accompanies this distribution.
      9   The full text of the license may be found at
     11   http://opensource.org/licenses/bsd-license.php.
     13 
     15   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     17   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     19 
     21 
     23   @file
     24   PchPlatformLib.c
     25 
     26   @brief
     27   PCH Platform Lib implementation.
     28 
     29 **/
     30 
     31 #include "PchPlatformLibrary.h"
     32 
     33 //
     34 // Silicon Steppings
     35 //
     36 /**
     37   Return Pch stepping type
     38 
     39   @param[in] None
     40 
     41   @retval PCH_STEPPING            Pch stepping type
     42 
     43 **/
     44 PCH_STEPPING
     45 EFIAPI
     46 PchStepping (
     47   VOID
     48   )
     49 {
     50   UINT8 RevId;
     51 
     52   RevId = MmioRead8 (
     53           MmPciAddress (0,
     54             DEFAULT_PCI_BUS_NUMBER_PCH,
     55             PCI_DEVICE_NUMBER_PCH_LPC,
     56             PCI_FUNCTION_NUMBER_PCH_LPC,
     57             R_PCH_LPC_RID_CC)
     58           );
     59 
     60   switch (RevId) {
     61     case V_PCH_LPC_RID_0:
     62     case V_PCH_LPC_RID_1:
     63       return PchA0;
     64       break;
     65 
     66     case V_PCH_LPC_RID_2:
     67     case V_PCH_LPC_RID_3:
     68       return PchA1;
     69       break;
     70 
     71     case V_PCH_LPC_RID_4:
     72     case V_PCH_LPC_RID_5:
     73       return PchB0;
     74       break;
     75 
     76     case V_PCH_LPC_RID_6:
     77     case V_PCH_LPC_RID_7:
     78       return PchB1;
     79       break;
     80 
     81     case V_PCH_LPC_RID_8:
     82     case V_PCH_LPC_RID_9:
     83       return PchB2;
     84       break;
     85 
     86     case V_PCH_LPC_RID_A:
     87     case V_PCH_LPC_RID_B:
     88       return PchB3;
     89       break;
     90 
     91     case V_PCH_LPC_RID_C:
     92     case V_PCH_LPC_RID_D:
     93       return PchC0;
     94       break;
     95 
     96     case V_PCH_LPC_RID_E:
     97     case V_PCH_LPC_RID_F:
     98       return PchD0;
     99       break;
    100 
    101     default:
    102       return PchSteppingMax;
    103       break;
    104 
    105   }
    106 }
    107 
    108 /**
    109   Determine if PCH is supported
    110 
    111   @param[in] None
    112 
    113   @retval TRUE                    PCH is supported
    114   @retval FALSE                   PCH is not supported
    115 
    116 **/
    117 BOOLEAN
    118 IsPchSupported (
    119   VOID
    120   )
    121 {
    122   UINT32  Identifiers;
    123   UINT16  PcuVendorId;
    124   UINT16  PcuDeviceId;
    125 
    126   Identifiers = MmioRead32 (
    127                   MmPciAddress (0,
    128                   DEFAULT_PCI_BUS_NUMBER_PCH,
    129                   PCI_DEVICE_NUMBER_PCH_LPC,
    130                   PCI_FUNCTION_NUMBER_PCH_LPC,
    131                   R_PCH_LPC_REG_ID)
    132                 );
    133 
    134   PcuDeviceId = (UINT16) ((Identifiers & B_PCH_LPC_DEVICE_ID) >> 16);
    135   PcuVendorId = (UINT16) (Identifiers & B_PCH_LPC_VENDOR_ID);
    136 
    137   //
    138   // Verify that this is a supported chipset
    139   //
    140   if (PcuVendorId != (UINT16) V_PCH_LPC_VENDOR_ID || !IS_PCH_VLV_LPC_DEVICE_ID (PcuDeviceId)) {
    141     DEBUG ((EFI_D_ERROR, "VLV SC code doesn't support the PcuDeviceId: 0x%04x!\n", PcuDeviceId));
    142     return FALSE;
    143   }
    144   return TRUE;
    145 }
    146