summaryrefslogtreecommitdiff
path: root/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.c
blob: b5dfae28d10ab531d9bc7c8dc98bfe5c7ca54ae9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/** @file

  Copyright (c) 2020, ARM Ltd. All rights reserved.

  SPDX-License-Identifier: BSD-2-Clause-Patent

 **/

#include <PiDxe.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/NorFlashPlatformLib.h>
#include <SgiPlatform.h>

STATIC NOR_FLASH_DESCRIPTION mNorFlashDevices[] = {
  {
    FixedPcdGet64 (PcdSmcCs0Base),
    FixedPcdGet64 (PcdSmcCs0Base),
    SIZE_256KB * 256,
    SIZE_256KB,
  },
  {
    FixedPcdGet64 (PcdSmcCs1Base),
    FixedPcdGet64 (PcdSmcCs1Base),
    SIZE_256KB * 256,
    SIZE_256KB,
  },
};

EFI_STATUS
NorFlashPlatformInitialization (
  VOID
  )
{
  UINT64 SysRegFlash;

  SysRegFlash = FixedPcdGet64 (PcdSysPeriphSysRegBase) + SGI_SYSPH_SYS_REG_FLASH;
  MmioOr32 (SysRegFlash, SGI_SYSPH_SYS_REG_FLASH_RWEN);
  return EFI_SUCCESS;
}

EFI_STATUS
NorFlashPlatformGetDevices (
  OUT NOR_FLASH_DESCRIPTION   **NorFlashDevices,
  OUT UINT32                  *Count
  )
{
  if ((NorFlashDevices == NULL) || (Count == NULL)) {
    return EFI_INVALID_PARAMETER;
  }

  *NorFlashDevices = mNorFlashDevices;
  *Count = ARRAY_SIZE (mNorFlashDevices);
  return EFI_SUCCESS;
}