1 /** @file
2 *
3 * Copyright (c) 2017, Linaro. All rights reserved.
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 <Library/UefiBootServicesTableLib.h>
16
17 #include <Protocol/EmbeddedGpio.h>
18
19 GPIO_CONTROLLER gGpioDevice[]= {
20 { 0xe8a0b000, 0, 8 }, // GPIO0
21 { 0xe8a0c000, 8, 8 }, // GPIO1
22 { 0xe8a0d000, 16, 8 }, // GPIO2
23 { 0xe8a0e000, 24, 8 }, // GPIO3
24 { 0xe8a0f000, 32, 8 }, // GPIO4
25 { 0xe8a10000, 40, 8 }, // GPIO5
26 { 0xe8a11000, 48, 8 }, // GPIO6
27 { 0xe8a12000, 56, 8 }, // GPIO7
28 { 0xe8a13000, 64, 8 }, // GPIO8
29 { 0xe8a14000, 72, 8 }, // GPIO9
30 { 0xe8a15000, 80, 8 }, // GPIO10
31 { 0xe8a16000, 88, 8 }, // GPIO11
32 { 0xe8a17000, 96, 8 }, // GPIO12
33 { 0xe8a18000, 104, 8 }, // GPIO13
34 { 0xe8a19000, 112, 8 }, // GPIO14
35 { 0xe8a1a000, 120, 8 }, // GPIO15
36 { 0xe8a1b000, 128, 8 }, // GPIO16
37 { 0xe8a1c000, 136, 8 }, // GPIO17
38 { 0xff3b4000, 144, 8 }, // GPIO18
39 { 0xff3b5000, 152, 8 }, // GPIO19
40 { 0xe8a1f000, 160, 8 }, // GPIO20
41 { 0xe8a20000, 168, 8 }, // GPIO21
42 { 0xfff0b000, 176, 8 }, // GPIO22
43 { 0xfff0c000, 184, 8 }, // GPIO23
44 { 0xfff0d000, 192, 8 }, // GPIO24
45 { 0xfff0e000, 200, 8 }, // GPIO25
46 { 0xfff0f000, 208, 8 }, // GPIO26
47 { 0xfff10000, 216, 8 }, // GPIO27
48 { 0xfff1d000, 224, 8 }, // GPIO28
49 };
50
51 PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
52 232, 29, gGpioDevice
53 };
54
55 EFI_STATUS
56 EFIAPI
HiKey960GpioEntryPoint(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE * SystemTable)57 HiKey960GpioEntryPoint (
58 IN EFI_HANDLE ImageHandle,
59 IN EFI_SYSTEM_TABLE *SystemTable
60 )
61 {
62 EFI_STATUS Status;
63 EFI_HANDLE Handle;
64
65 // Install the Embedded Platform GPIO Protocol onto a new handle
66 Handle = NULL;
67 Status = gBS->InstallMultipleProtocolInterfaces(
68 &Handle,
69 &gPlatformGpioProtocolGuid, &gPlatformGpioDevice,
70 NULL
71 );
72 if (EFI_ERROR(Status)) {
73 Status = EFI_OUT_OF_RESOURCES;
74 }
75
76 return Status;
77 }
78