HiKeyGpioDxe.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /** @file
  2. *
  3. * Copyright (c) 2018, Linaro. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause-Patent
  6. *
  7. **/
  8. #include <Library/UefiBootServicesTableLib.h>
  9. #include <Protocol/EmbeddedGpio.h>
  10. GPIO_CONTROLLER gGpioDevice[] = {
  11. //
  12. // { base address, gpio index, gpio count }
  13. //
  14. { 0xf8011000, 0, 8 }, // GPIO0
  15. { 0xf8012000, 8, 8 }, // GPIO1
  16. { 0xf8013000, 16, 8 }, // GPIO2
  17. { 0xf8014000, 24, 8 }, // GPIO3
  18. { 0xf7020000, 32, 8 }, // GPIO4
  19. { 0xf7021000, 40, 8 }, // GPIO5
  20. { 0xf7022000, 48, 8 }, // GPIO6
  21. { 0xf7023000, 56, 8 }, // GPIO7
  22. { 0xf7024000, 64, 8 }, // GPIO8
  23. { 0xf7025000, 72, 8 }, // GPIO9
  24. { 0xf7026000, 80, 8 }, // GPIO10
  25. { 0xf7027000, 88, 8 }, // GPIO11
  26. { 0xf7028000, 96, 8 }, // GPIO12
  27. { 0xf7029000, 104, 8 }, // GPIO13
  28. { 0xf702a000, 112, 8 }, // GPIO14
  29. { 0xf702b000, 120, 8 }, // GPIO15
  30. { 0xf702c000, 128, 8 }, // GPIO16
  31. { 0xf702d000, 136, 8 }, // GPIO17
  32. { 0xf702e000, 144, 8 }, // GPIO18
  33. { 0xf702f000, 152, 8 } // GPIO19
  34. };
  35. PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
  36. //
  37. // { global gpio count, gpio controller counter, GPIO_CONTROLLER }
  38. //
  39. 160, 20, gGpioDevice
  40. };
  41. EFI_STATUS
  42. EFIAPI
  43. HiKeyGpioEntryPoint (
  44. IN EFI_HANDLE ImageHandle,
  45. IN EFI_SYSTEM_TABLE *SystemTable
  46. )
  47. {
  48. EFI_STATUS Status;
  49. EFI_HANDLE Handle;
  50. // Install the Embedded Platform GPIO Protocol onto a new handle
  51. Handle = NULL;
  52. Status = gBS->InstallMultipleProtocolInterfaces(
  53. &Handle,
  54. &gPlatformGpioProtocolGuid, &gPlatformGpioDevice,
  55. NULL
  56. );
  57. if (EFI_ERROR(Status)) {
  58. Status = EFI_OUT_OF_RESOURCES;
  59. }
  60. return Status;
  61. }