omapuart.h 3.8 KB

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