Home | History | Annotate | Download | only in CpldIoLib
      1 /** @file
      2 *
      3 *  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
      4 *  Copyright (c) 2015, Linaro Limited. All rights reserved.
      5 *
      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 #include <Uefi.h>
     17 #include <Library/IoLib.h>
     18 #include <Library/DebugLib.h>
     19 #include <Library/TimerLib.h>
     20 #include <Library/CpldIoLib.h>
     21 
     22 
     23 VOID WriteCpldReg(UINTN ulRegAddr, UINT8 ulValue)
     24 {
     25     MmioWrite8 (ulRegAddr + PcdGet64(PcdCpldBaseAddress), ulValue);
     26 }
     27 
     28 
     29 UINT8 ReadCpldReg(UINTN ulRegAddr)
     30 {
     31     return MmioRead8 (ulRegAddr + PcdGet64(PcdCpldBaseAddress));
     32 }
     33 
     34 
     35 VOID ReadCpldBytes(UINT16 Addr, UINT8 *Data, UINT8 Bytes)
     36 {
     37     UINT8 i;
     38 
     39     for(i = 0;i < Bytes; i++)
     40     {
     41         *(Data + i) = ReadCpldReg(Addr + i);
     42     }
     43 }
     44 
     45 VOID WriteCpldBytes(UINT16 Addr, UINT8 *Data, UINT8 Bytes)
     46 {
     47     UINT8 i;
     48 
     49     for(i = 0; i < Bytes; i++)
     50     {
     51         WriteCpldReg(Addr + i, *(Data + i));
     52     }
     53 }
     54