hc
2024-03-25 edb30157bad0c0001c32b854271ace01d3b9a16a
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
/** @file
*
*  Copyright (c) 2018, Linaro. All rights reserved.
*
*  SPDX-License-Identifier: BSD-2-Clause-Patent
*
**/
 
#include <Library/UefiBootServicesTableLib.h>
 
#include <Protocol/EmbeddedGpio.h>
 
GPIO_CONTROLLER gGpioDevice[] = {
  //
  // { base address, gpio index, gpio count }
  //
  { 0xFDD60000, 0, 32 },    // GPIO0
  { 0xFE740000, 32, 32 },    // GPIO1
  { 0xFE750000, 64, 32 },   // GPIO2
  { 0xFE760000, 96, 32 },   // GPIO3
  { 0xFE770000, 128, 32 },   // GPIO3
};
 
PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
  //
  // { global gpio count, gpio controller counter, GPIO_CONTROLLER }
  //
  160, 20, gGpioDevice
};
 
EFI_STATUS
EFIAPI
RK3588GpioEntryPoint (
  IN EFI_HANDLE         ImageHandle,
  IN EFI_SYSTEM_TABLE   *SystemTable
  )
{
  EFI_STATUS  Status;
  EFI_HANDLE  Handle;
 
  // Install the Embedded Platform GPIO Protocol onto a new handle
  Handle = NULL;
  Status = gBS->InstallMultipleProtocolInterfaces(
                  &Handle,
                  &gPlatformGpioProtocolGuid, &gPlatformGpioDevice,
                  NULL
                 );
  if (EFI_ERROR(Status)) {
    Status = EFI_OUT_OF_RESOURCES;
  }
 
  return Status;
}