1 /** @file
2 *
3 *  Copyright (c) 2015, Linaro Ltd. All rights reserved.
4 *  Copyright (c) 2015, Hisilicon Ltd. All rights reserved.
5 *
6 *  This program and the accompanying materials
7 *  are licensed and made available under the terms and conditions of the BSD License
8 *  which accompanies this distribution.  The full text of the license may be found at
9 *  http://opensource.org/licenses/bsd-license.php
10 *
11 *  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 *
14 **/
15 
16 #include <Library/UefiBootServicesTableLib.h>
17 
18 #include <Protocol/EmbeddedGpio.h>
19 
20 GPIO_CONTROLLER gGpioDevice[]= {
21   { 0xf8011000, 0, 8 },    // GPIO0
22   { 0xf8012000, 8, 8 },    // GPIO1
23   { 0xf8013000, 16, 8 },   // GPIO2
24   { 0xf8014000, 24, 8 },   // GPIO3
25   { 0xf7020000, 32, 8 },   // GPIO4
26   { 0xf7021000, 40, 8 },   // GPIO5
27   { 0xf7022000, 48, 8 },   // GPIO6
28   { 0xf7023000, 56, 8 },   // GPIO7
29   { 0xf7024000, 64, 8 },   // GPIO8
30   { 0xf7025000, 72, 8 },   // GPIO9
31   { 0xf7026000, 80, 8 },   // GPIO10
32   { 0xf7027000, 88, 8 },   // GPIO11
33   { 0xf7028000, 96, 8 },   // GPIO12
34   { 0xf7029000, 104, 8 },  // GPIO13
35   { 0xf702a000, 112, 8 },  // GPIO14
36   { 0xf702b000, 120, 8 },  // GPIO15
37   { 0xf702c000, 128, 8 },  // GPIO16
38   { 0xf702d000, 136, 8 },  // GPIO17
39   { 0xf702e000, 144, 8 },  // GPIO18
40   { 0xf702f000, 152, 8 }   // GPIO19
41 };
42 
43 PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
44   160, 20, gGpioDevice
45 };
46 
47 EFI_STATUS
48 EFIAPI
HiKeyGpioEntryPoint(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE * SystemTable)49 HiKeyGpioEntryPoint (
50   IN EFI_HANDLE         ImageHandle,
51   IN EFI_SYSTEM_TABLE   *SystemTable
52   )
53 {
54   EFI_STATUS  Status;
55   EFI_HANDLE  Handle;
56 
57   // Install the Embedded Platform GPIO Protocol onto a new handle
58   Handle = NULL;
59   Status = gBS->InstallMultipleProtocolInterfaces(
60                   &Handle,
61                   &gPlatformGpioProtocolGuid, &gPlatformGpioDevice,
62                   NULL
63                  );
64   if (EFI_ERROR(Status)) {
65     Status = EFI_OUT_OF_RESOURCES;
66   }
67 
68   return Status;
69 }
70