1
0

omapuart.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. omapuart.h
  9. Abstract:
  10. This header contains library definitions for the serial UART found on
  11. Texas Instruments OMAP3 and OMAP4 SoCs.
  12. Author:
  13. Evan Green 27-Feb-2014
  14. --*/
  15. //
  16. // ------------------------------------------------------------------- Includes
  17. //
  18. //
  19. // ---------------------------------------------------------------- Definitions
  20. //
  21. //
  22. // ------------------------------------------------------ Data Type Definitions
  23. //
  24. /*++
  25. Structure Description:
  26. This structure defines the context for an OMAP UART controller. Upon
  27. initialization, the consumer of the library is responsible for initializing
  28. some of these values.
  29. Members:
  30. UartBase - Stores the base address of the UART. The consumer of the library
  31. should have initialized this value before calling the library
  32. initialize function.
  33. BaudRateRegister - Stores the value to put in the baud rate register. The
  34. consumer of this library should have initialized this value before
  35. calling the library initialize function.
  36. --*/
  37. typedef struct _OMAP_UART_CONTEXT {
  38. VOID *UartBase;
  39. UINT16 BaudRateRegister;
  40. } OMAP_UART_CONTEXT, *POMAP_UART_CONTEXT;
  41. //
  42. // -------------------------------------------------------------------- Globals
  43. //
  44. //
  45. // -------------------------------------------------------- Function Prototypes
  46. //
  47. EFI_STATUS
  48. EfipUartOmapComputeDivisor (
  49. UINTN BaudRate,
  50. UINT16 *Divisor
  51. );
  52. /*++
  53. Routine Description:
  54. This routine computes the divisor for the given baud rate.
  55. Arguments:
  56. BaudRate - Supplies the desired baud rate.
  57. Divisor - Supplies a pointer where the divisor will be returned on success.
  58. Return Value:
  59. EFI_SUCCESS on success.
  60. EFI_UNSUPPORTED if the baud rate cannot be achieved.
  61. --*/
  62. EFI_STATUS
  63. EfipUartOmapInitialize (
  64. POMAP_UART_CONTEXT Context
  65. );
  66. /*++
  67. Routine Description:
  68. This routine initializes the OMAP UART controller.
  69. Arguments:
  70. Context - Supplies the pointer to the port's context. The caller should
  71. have initialized some of these members.
  72. Return Value:
  73. EFI status code.
  74. --*/
  75. EFI_STATUS
  76. EfipUartOmapTransmit (
  77. POMAP_UART_CONTEXT Context,
  78. VOID *Data,
  79. UINTN Size
  80. );
  81. /*++
  82. Routine Description:
  83. This routine writes data out the serial port. This routine should busily
  84. spin if the previously sent byte has not finished transmitting.
  85. Arguments:
  86. Context - Supplies the pointer to the port context.
  87. Data - Supplies a pointer to the data to write.
  88. Size - Supplies the size to write, in bytes.
  89. Return Value:
  90. EFI_SUCCESS on success.
  91. EFI_DEVICE_ERROR if a device error occurred.
  92. --*/
  93. EFI_STATUS
  94. EfipUartOmapReceive (
  95. POMAP_UART_CONTEXT Context,
  96. VOID *Data,
  97. UINTN *Size
  98. );
  99. /*++
  100. Routine Description:
  101. This routine reads bytes from the serial port.
  102. Arguments:
  103. Context - Supplies the pointer to the port context.
  104. Data - Supplies a pointer where the read data will be returned on success.
  105. Size - Supplies a pointer that on input contains the size of the receive
  106. buffer. On output, returns the number of bytes read.
  107. Return Value:
  108. EFI_SUCCESS on success.
  109. EFI_NOT_READY if there was no data to be read at the current time.
  110. EFI_DEVICE_ERROR if a device error occurred.
  111. --*/
  112. EFI_STATUS
  113. EfipUartOmapGetStatus (
  114. POMAP_UART_CONTEXT Context,
  115. BOOLEAN *ReceiveDataAvailable
  116. );
  117. /*++
  118. Routine Description:
  119. This routine returns the current device status.
  120. Arguments:
  121. Context - Supplies a pointer to the serial port context.
  122. ReceiveDataAvailable - Supplies a pointer where a boolean will be returned
  123. indicating whether or not receive data is available.
  124. Return Value:
  125. EFI_SUCCESS on success.
  126. EFI_DEVICE_ERROR if a device error occurred.
  127. --*/