serial_pl01x_internal.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2003, 2004
  4. * ARM Ltd.
  5. * Philippe Robin, <philippe.robin@arm.com>
  6. */
  7. /*
  8. * ARM PrimeCell UART's (PL010 & PL011)
  9. * ------------------------------------
  10. *
  11. * Definitions common to both PL010 & PL011
  12. *
  13. */
  14. #ifndef __ASSEMBLY__
  15. /*
  16. * We can use a combined structure for PL010 and PL011, because they overlap
  17. * only in common registers.
  18. */
  19. struct pl01x_regs {
  20. u32 dr; /* 0x00 Data register */
  21. u32 ecr; /* 0x04 Error clear register (Write) */
  22. u32 pl010_lcrh; /* 0x08 Line control register, high byte */
  23. u32 pl010_lcrm; /* 0x0C Line control register, middle byte */
  24. u32 pl010_lcrl; /* 0x10 Line control register, low byte */
  25. u32 pl010_cr; /* 0x14 Control register */
  26. u32 fr; /* 0x18 Flag register (Read only) */
  27. #ifdef CONFIG_PL011_SERIAL_RLCR
  28. u32 pl011_rlcr; /* 0x1c Receive line control register */
  29. #else
  30. u32 reserved;
  31. #endif
  32. u32 ilpr; /* 0x20 IrDA low-power counter register */
  33. u32 pl011_ibrd; /* 0x24 Integer baud rate register */
  34. u32 pl011_fbrd; /* 0x28 Fractional baud rate register */
  35. u32 pl011_lcrh; /* 0x2C Line control register */
  36. u32 pl011_cr; /* 0x30 Control register */
  37. };
  38. #ifdef CONFIG_DM_SERIAL
  39. int pl01x_serial_ofdata_to_platdata(struct udevice *dev);
  40. int pl01x_serial_probe(struct udevice *dev);
  41. /* Needed for external pl01x_serial_ops drivers */
  42. int pl01x_serial_putc(struct udevice *dev, const char ch);
  43. int pl01x_serial_pending(struct udevice *dev, bool input);
  44. int pl01x_serial_getc(struct udevice *dev);
  45. int pl01x_serial_setbrg(struct udevice *dev, int baudrate);
  46. struct pl01x_priv {
  47. struct pl01x_regs *regs;
  48. enum pl01x_type type;
  49. };
  50. #endif /* CONFIG_DM_SERIAL */
  51. #endif /* !__ASSEMBLY__ */
  52. #define UART_PL01x_RSR_OE 0x08
  53. #define UART_PL01x_RSR_BE 0x04
  54. #define UART_PL01x_RSR_PE 0x02
  55. #define UART_PL01x_RSR_FE 0x01
  56. #define UART_PL01x_FR_TXFE 0x80
  57. #define UART_PL01x_FR_RXFF 0x40
  58. #define UART_PL01x_FR_TXFF 0x20
  59. #define UART_PL01x_FR_RXFE 0x10
  60. #define UART_PL01x_FR_BUSY 0x08
  61. #define UART_PL01x_FR_TMSK (UART_PL01x_FR_TXFF + UART_PL01x_FR_BUSY)
  62. /*
  63. * PL010 definitions
  64. *
  65. */
  66. #define UART_PL010_CR_LPE (1 << 7)
  67. #define UART_PL010_CR_RTIE (1 << 6)
  68. #define UART_PL010_CR_TIE (1 << 5)
  69. #define UART_PL010_CR_RIE (1 << 4)
  70. #define UART_PL010_CR_MSIE (1 << 3)
  71. #define UART_PL010_CR_IIRLP (1 << 2)
  72. #define UART_PL010_CR_SIREN (1 << 1)
  73. #define UART_PL010_CR_UARTEN (1 << 0)
  74. #define UART_PL010_LCRH_WLEN_8 (3 << 5)
  75. #define UART_PL010_LCRH_WLEN_7 (2 << 5)
  76. #define UART_PL010_LCRH_WLEN_6 (1 << 5)
  77. #define UART_PL010_LCRH_WLEN_5 (0 << 5)
  78. #define UART_PL010_LCRH_FEN (1 << 4)
  79. #define UART_PL010_LCRH_STP2 (1 << 3)
  80. #define UART_PL010_LCRH_EPS (1 << 2)
  81. #define UART_PL010_LCRH_PEN (1 << 1)
  82. #define UART_PL010_LCRH_BRK (1 << 0)
  83. #define UART_PL010_BAUD_460800 1
  84. #define UART_PL010_BAUD_230400 3
  85. #define UART_PL010_BAUD_115200 7
  86. #define UART_PL010_BAUD_57600 15
  87. #define UART_PL010_BAUD_38400 23
  88. #define UART_PL010_BAUD_19200 47
  89. #define UART_PL010_BAUD_14400 63
  90. #define UART_PL010_BAUD_9600 95
  91. #define UART_PL010_BAUD_4800 191
  92. #define UART_PL010_BAUD_2400 383
  93. #define UART_PL010_BAUD_1200 767
  94. /*
  95. * PL011 definitions
  96. *
  97. */
  98. #define UART_PL011_LCRH_SPS (1 << 7)
  99. #define UART_PL011_LCRH_WLEN_8 (3 << 5)
  100. #define UART_PL011_LCRH_WLEN_7 (2 << 5)
  101. #define UART_PL011_LCRH_WLEN_6 (1 << 5)
  102. #define UART_PL011_LCRH_WLEN_5 (0 << 5)
  103. #define UART_PL011_LCRH_FEN (1 << 4)
  104. #define UART_PL011_LCRH_STP2 (1 << 3)
  105. #define UART_PL011_LCRH_EPS (1 << 2)
  106. #define UART_PL011_LCRH_PEN (1 << 1)
  107. #define UART_PL011_LCRH_BRK (1 << 0)
  108. #define UART_PL011_CR_CTSEN (1 << 15)
  109. #define UART_PL011_CR_RTSEN (1 << 14)
  110. #define UART_PL011_CR_OUT2 (1 << 13)
  111. #define UART_PL011_CR_OUT1 (1 << 12)
  112. #define UART_PL011_CR_RTS (1 << 11)
  113. #define UART_PL011_CR_DTR (1 << 10)
  114. #define UART_PL011_CR_RXE (1 << 9)
  115. #define UART_PL011_CR_TXE (1 << 8)
  116. #define UART_PL011_CR_LPE (1 << 7)
  117. #define UART_PL011_CR_IIRLP (1 << 2)
  118. #define UART_PL011_CR_SIREN (1 << 1)
  119. #define UART_PL011_CR_UARTEN (1 << 0)
  120. #define UART_PL011_IMSC_OEIM (1 << 10)
  121. #define UART_PL011_IMSC_BEIM (1 << 9)
  122. #define UART_PL011_IMSC_PEIM (1 << 8)
  123. #define UART_PL011_IMSC_FEIM (1 << 7)
  124. #define UART_PL011_IMSC_RTIM (1 << 6)
  125. #define UART_PL011_IMSC_TXIM (1 << 5)
  126. #define UART_PL011_IMSC_RXIM (1 << 4)
  127. #define UART_PL011_IMSC_DSRMIM (1 << 3)
  128. #define UART_PL011_IMSC_DCDMIM (1 << 2)
  129. #define UART_PL011_IMSC_CTSMIM (1 << 1)
  130. #define UART_PL011_IMSC_RIMIM (1 << 0)