pl011.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef PL011_H
  7. #define PL011_H
  8. #include <drivers/console.h>
  9. /* PL011 Registers */
  10. #define UARTDR 0x000
  11. #define UARTRSR 0x004
  12. #define UARTECR 0x004
  13. #define UARTFR 0x018
  14. #define UARTIMSC 0x038
  15. #define UARTRIS 0x03C
  16. #define UARTICR 0x044
  17. /* PL011 registers (out of the SBSA specification) */
  18. #if !PL011_GENERIC_UART
  19. #define UARTILPR 0x020
  20. #define UARTIBRD 0x024
  21. #define UARTFBRD 0x028
  22. #define UARTLCR_H 0x02C
  23. #define UARTCR 0x030
  24. #define UARTIFLS 0x034
  25. #define UARTMIS 0x040
  26. #define UARTDMACR 0x048
  27. #endif /* !PL011_GENERIC_UART */
  28. /* Data status bits */
  29. #define UART_DATA_ERROR_MASK 0x0F00
  30. /* Status reg bits */
  31. #define UART_STATUS_ERROR_MASK 0x0F
  32. /* Flag reg bits */
  33. #define PL011_UARTFR_RI (1 << 8) /* Ring indicator */
  34. #define PL011_UARTFR_TXFE (1 << 7) /* Transmit FIFO empty */
  35. #define PL011_UARTFR_RXFF (1 << 6) /* Receive FIFO full */
  36. #define PL011_UARTFR_TXFF (1 << 5) /* Transmit FIFO full */
  37. #define PL011_UARTFR_RXFE (1 << 4) /* Receive FIFO empty */
  38. #define PL011_UARTFR_BUSY (1 << 3) /* UART busy */
  39. #define PL011_UARTFR_DCD (1 << 2) /* Data carrier detect */
  40. #define PL011_UARTFR_DSR (1 << 1) /* Data set ready */
  41. #define PL011_UARTFR_CTS (1 << 0) /* Clear to send */
  42. #define PL011_UARTFR_TXFF_BIT 5 /* Transmit FIFO full bit in UARTFR register */
  43. #define PL011_UARTFR_RXFE_BIT 4 /* Receive FIFO empty bit in UARTFR register */
  44. #define PL011_UARTFR_BUSY_BIT 3 /* UART busy bit in UARTFR register */
  45. /* Control reg bits */
  46. #if !PL011_GENERIC_UART
  47. #define PL011_UARTCR_CTSEN (1 << 15) /* CTS hardware flow control enable */
  48. #define PL011_UARTCR_RTSEN (1 << 14) /* RTS hardware flow control enable */
  49. #define PL011_UARTCR_RTS (1 << 11) /* Request to send */
  50. #define PL011_UARTCR_DTR (1 << 10) /* Data transmit ready. */
  51. #define PL011_UARTCR_RXE (1 << 9) /* Receive enable */
  52. #define PL011_UARTCR_TXE (1 << 8) /* Transmit enable */
  53. #define PL011_UARTCR_LBE (1 << 7) /* Loopback enable */
  54. #define PL011_UARTCR_UARTEN (1 << 0) /* UART Enable */
  55. #if !defined(PL011_LINE_CONTROL)
  56. /* FIFO Enabled / No Parity / 8 Data bit / One Stop Bit */
  57. #define PL011_LINE_CONTROL (PL011_UARTLCR_H_FEN | PL011_UARTLCR_H_WLEN_8)
  58. #endif
  59. /* Line Control Register Bits */
  60. #define PL011_UARTLCR_H_SPS (1 << 7) /* Stick parity select */
  61. #define PL011_UARTLCR_H_WLEN_8 (3 << 5)
  62. #define PL011_UARTLCR_H_WLEN_7 (2 << 5)
  63. #define PL011_UARTLCR_H_WLEN_6 (1 << 5)
  64. #define PL011_UARTLCR_H_WLEN_5 (0 << 5)
  65. #define PL011_UARTLCR_H_FEN (1 << 4) /* FIFOs Enable */
  66. #define PL011_UARTLCR_H_STP2 (1 << 3) /* Two stop bits select */
  67. #define PL011_UARTLCR_H_EPS (1 << 2) /* Even parity select */
  68. #define PL011_UARTLCR_H_PEN (1 << 1) /* Parity Enable */
  69. #define PL011_UARTLCR_H_BRK (1 << 0) /* Send break */
  70. #endif /* !PL011_GENERIC_UART */
  71. #ifndef __ASSEMBLER__
  72. #include <stdint.h>
  73. /*
  74. * Initialize a new PL011 console instance and register it with the console
  75. * framework. The |console| pointer must point to storage that will be valid
  76. * for the lifetime of the console, such as a global or static local variable.
  77. * Its contents will be reinitialized from scratch.
  78. */
  79. int console_pl011_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud,
  80. console_t *console);
  81. #endif /*__ASSEMBLER__*/
  82. #endif /* PL011_H */