pl110.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*++
  2. Copyright (c) 2014 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. pl110.c
  9. Abstract:
  10. This module implements support for ARM PL110 and PL111 LCD controller.
  11. Author:
  12. Evan Green 7-Apr-2014
  13. Environment:
  14. Firmware
  15. --*/
  16. //
  17. // ------------------------------------------------------------------- Includes
  18. //
  19. #include <uefifw.h>
  20. //
  21. // --------------------------------------------------------------------- Macros
  22. //
  23. //
  24. // ---------------------------------------------------------------- Definitions
  25. //
  26. #define PL110_PART_NUMBER 0x10
  27. #define PL111_PART_NUMBER 0x11
  28. //
  29. // ------------------------------------------------------ Data Type Definitions
  30. //
  31. //
  32. // Define the registers for the PL110. This also works for the PL111, except
  33. // notice how the control register is at a different offset.
  34. //
  35. typedef enum _PL110_DISPLAY_REGISTERS {
  36. Pl110RegisterLcdTiming0 = 0x000,
  37. Pl110RegisterLcdTiming1 = 0x004,
  38. Pl110RegisterLcdTiming2 = 0x008,
  39. Pl110RegisterLcdTiming3 = 0x00C,
  40. Pl110RegisterUpperPanelFrameBase = 0x010,
  41. Pl110RegisterLowerPanelFrameBase = 0x014,
  42. Pl111RegisterControl = 0x018,
  43. Pl110RegisterControl = 0x01C,
  44. Pl110RegisterId = 0xFE0
  45. } PL110_DISPLAY_REGISTERS, *PPL110_DISPLAY_REGISTERS;
  46. //
  47. // ----------------------------------------------- Internal Function Prototypes
  48. //
  49. //
  50. // -------------------------------------------------------------------- Globals
  51. //
  52. //
  53. // ------------------------------------------------------------------ Functions
  54. //
  55. EFI_STATUS
  56. EfipPl110Initialize (
  57. EFI_PHYSICAL_ADDRESS Controller,
  58. EFI_PHYSICAL_ADDRESS FrameBufferBase,
  59. UINT32 FrameBufferWidth,
  60. UINT32 FrameBufferHeight
  61. )
  62. /*++
  63. Routine Description:
  64. This routine initialize the PrimeCell PL110 display controller found in
  65. the Integrator/CP.
  66. Arguments:
  67. Controller - Supplies the physical address of the PL110 registers.
  68. FrameBufferBase - Supplies the base of the frame buffer memory to set.
  69. FrameBufferWidth - Supplies the desired width.
  70. FrameBufferHeight - Supplies the desired height.
  71. Return Value:
  72. EFI status code.
  73. --*/
  74. {
  75. VOID *ControlRegister;
  76. VOID *Display;
  77. UINT8 Identifier;
  78. Display = (VOID *)(UINTN)Controller;
  79. Identifier = EfiReadRegister8(Display + Pl110RegisterId);
  80. if (Identifier == PL111_PART_NUMBER) {
  81. ControlRegister = Display + Pl111RegisterControl;
  82. } else {
  83. ControlRegister = Display + Pl110RegisterControl;
  84. }
  85. //
  86. // Currently only one resolution is supported.
  87. //
  88. if ((FrameBufferWidth != 1024) || (FrameBufferHeight != 768)) {
  89. return EFI_UNSUPPORTED;
  90. }
  91. //
  92. // Set the horizontal timing value.
  93. //
  94. EfiWriteRegister32(Display + Pl110RegisterLcdTiming0, 0x3F1F3FFC);
  95. //
  96. // Set the vertical timing value.
  97. //
  98. EfiWriteRegister32(Display + Pl110RegisterLcdTiming1, 0x080B62FF);
  99. //
  100. // Set the other timing value.
  101. //
  102. EfiWriteRegister32(Display + Pl110RegisterLcdTiming2, 0x067F3800);
  103. //
  104. // Set the frame buffer base.
  105. //
  106. EfiWriteRegister32(Display + Pl110RegisterUpperPanelFrameBase,
  107. FrameBufferBase);
  108. //
  109. // Set to 24 bits per pixel and enable the controller.
  110. //
  111. EfiWriteRegister32(ControlRegister, 0x192B);
  112. return EFI_SUCCESS;
  113. }
  114. //
  115. // --------------------------------------------------------- Internal Functions
  116. //