Home | History | Annotate | Download | only in NorFlashJunoLib
      1 /** @file
      2 
      3  Copyright (c) 2011-2014, ARM Ltd. All rights reserved.<BR>
      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 <PiDxe.h>
     16 #include <Library/DebugLib.h>
     17 #include <Library/IoLib.h>
     18 #include <Library/NorFlashPlatformLib.h>
     19 #include <ArmPlatform.h>
     20 
     21 NOR_FLASH_DESCRIPTION mNorFlashDevices[] = {
     22   {
     23     ARM_VE_SMB_NOR0_BASE,
     24     ARM_VE_SMB_NOR0_BASE,
     25     SIZE_256KB * 255,
     26     SIZE_256KB,
     27     {0xE7223039, 0x5836, 0x41E1, { 0xB5, 0x42, 0xD7, 0xEC, 0x73, 0x6C, 0x5E, 0x59} }
     28   },
     29   {
     30     ARM_VE_SMB_NOR0_BASE,
     31     ARM_VE_SMB_NOR0_BASE + SIZE_256KB * 255,
     32     SIZE_64KB * 4,
     33     SIZE_64KB,
     34     {0x02118005, 0x9DA7, 0x443A, { 0x92, 0xD5, 0x78, 0x1F, 0x02, 0x2A, 0xED, 0xBB } }
     35   },
     36 };
     37 
     38 EFI_STATUS
     39 NorFlashPlatformInitialization (
     40   VOID
     41   )
     42 {
     43   // Everything seems ok so far, so now we need to disable the platform-specific
     44   // flash write protection for Versatile Express
     45   if ((MmioRead32 (ARM_VE_SYS_FLASH) & 0x1) == 0) {
     46     // Writing to NOR FLASH is disabled, so enable it
     47     MmioWrite32 (ARM_VE_SYS_FLASH, 1);
     48     DEBUG((DEBUG_BLKIO, "NorFlashPlatformInitialization: informational - Had to enable HSYS_FLASH flag.\n" ));
     49   }
     50 
     51   return EFI_SUCCESS;
     52 }
     53 
     54 EFI_STATUS
     55 NorFlashPlatformGetDevices (
     56   OUT NOR_FLASH_DESCRIPTION   **NorFlashDevices,
     57   OUT UINT32                  *Count
     58   )
     59 {
     60   if ((NorFlashDevices == NULL) || (Count == NULL)) {
     61     return EFI_INVALID_PARAMETER;
     62   }
     63 
     64   *NorFlashDevices = mNorFlashDevices;
     65   *Count = sizeof (mNorFlashDevices) / sizeof (NOR_FLASH_DESCRIPTION);
     66 
     67   return EFI_SUCCESS;
     68 }
     69