1 /** @file
2 *
3 * Copyright (c) 2015-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 { 0xf8011000, 0, 8 }, // GPIO0
21 { 0xf8012000, 8, 8 }, // GPIO1
22 { 0xf8013000, 16, 8 }, // GPIO2
23 { 0xf8014000, 24, 8 }, // GPIO3
24 { 0xf7020000, 32, 8 }, // GPIO4
25 { 0xf7021000, 40, 8 }, // GPIO5
26 { 0xf7022000, 48, 8 }, // GPIO6
27 { 0xf7023000, 56, 8 }, // GPIO7
28 { 0xf7024000, 64, 8 }, // GPIO8
29 { 0xf7025000, 72, 8 }, // GPIO9
30 { 0xf7026000, 80, 8 }, // GPIO10
31 { 0xf7027000, 88, 8 }, // GPIO11
32 { 0xf7028000, 96, 8 }, // GPIO12
33 { 0xf7029000, 104, 8 }, // GPIO13
34 { 0xf702a000, 112, 8 }, // GPIO14
35 { 0xf702b000, 120, 8 }, // GPIO15
36 { 0xf702c000, 128, 8 }, // GPIO16
37 { 0xf702d000, 136, 8 }, // GPIO17
38 { 0xf702e000, 144, 8 }, // GPIO18
39 { 0xf702f000, 152, 8 } // GPIO19
40 };
41
42 PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
43 160, 20, gGpioDevice
44 };
45
46 EFI_STATUS
47 EFIAPI
HiKeyGpioEntryPoint(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE * SystemTable)48 HiKeyGpioEntryPoint (
49 IN EFI_HANDLE ImageHandle,
50 IN EFI_SYSTEM_TABLE *SystemTable
51 )
52 {
53 EFI_STATUS Status;
54 EFI_HANDLE Handle;
55
56 // Install the Embedded Platform GPIO Protocol onto a new handle
57 Handle = NULL;
58 Status = gBS->InstallMultipleProtocolInterfaces(
59 &Handle,
60 &gPlatformGpioProtocolGuid, &gPlatformGpioDevice,
61 NULL
62 );
63 if (EFI_ERROR(Status)) {
64 Status = EFI_OUT_OF_RESOURCES;
65 }
66
67 return Status;
68 }
69