dw_uart.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* ------------------------------------------
  2. * Copyright (c) 2016, Synopsys, Inc. All rights reserved.
  3. * Redistribution and use in source and binary forms, with or without modification,
  4. * are permitted provided that the following conditions are met:
  5. * 1) Redistributions of source code must retain the above copyright notice, this
  6. * list of conditions and the following disclaimer.
  7. * 2) Redistributions in binary form must reproduce the above copyright notice,
  8. * this list of conditions and the following disclaimer in the documentation and/or
  9. * other materials provided with the distribution.
  10. * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may
  11. * be used to endorse or promote products derived from this software without
  12. * specific prior written permission.
  13. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  14. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  17. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  20. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. *
  24. * \version 2016.05
  25. * \date 2014-06-20
  26. * \author Huaqi Fang(Huaqi.Fang@synopsys.com)
  27. --------------------------------------------- */
  28. /**
  29. * \file
  30. * \ingroup DEVICE_DW_UART
  31. * \brief DesignWare UART driver header file
  32. * \details detailed definitions of designware uart driver
  33. */
  34. #ifndef _DW_UART_H_
  35. #define _DW_UART_H_
  36. #include "device/device_hal/inc/dev_uart.h"
  37. #include "inc/arc/arc_exception.h"
  38. /**
  39. * if this header file is included,
  40. * will indicate that this designware uart device
  41. * is used
  42. */
  43. #define DEVICE_USE_DESIGNWARE_UART
  44. /**
  45. * \name DesignWare UART Register Structure
  46. * \brief contains definitions of DesignWare UART register structure.
  47. * @{
  48. */
  49. /**
  50. * \brief DesignWare UART register structure
  51. * \details Detailed struct description of DesignWare UART
  52. * block register information, implementation of dev_uart_info::uart_regs
  53. */
  54. typedef volatile struct dw_uart_reg {
  55. uint32_t DATA; /*!< data in/out and DLL */
  56. uint32_t IER; /*!< Interrupt enable register and DLH */
  57. uint32_t IIR; /*!< Interrupt Id register and FCR */
  58. uint32_t LCR; /*!< Line control Register */
  59. uint32_t MCR; /*!< Modem control register */
  60. uint32_t LSR; /*!< Line Status Register */
  61. uint32_t MSR; /*!< Modem status Register */
  62. uint32_t SCRATCHPAD; /*!< Uart scratch pad register */
  63. uint32_t LPDLL; /*!< Low Power Divisor Latch (Low) Reg */
  64. uint32_t LPDLH; /*!< Low Power Divisor Latch (High) Reg */
  65. uint32_t RES1[2]; /*!< Reserved */
  66. uint32_t SHR[16]; /*!< Shadow data register(SRBR and STHR) */
  67. uint32_t FAR; /*!< FIFO Access register */
  68. uint32_t TFR; /*!< Transmit FIFO Read */
  69. uint32_t RFW; /*!< Receive FIFO write */
  70. uint32_t USR; /*!< UART status register */
  71. uint32_t TFL; /*!< Transmit FIFO level */
  72. uint32_t RFL; /*!< Receive FIFO level */
  73. uint32_t SRR; /*!< Software reset register */
  74. uint32_t SRTS; /*!< Shadow request to send */
  75. uint32_t SBCR; /*!< Shadow break control */
  76. uint32_t SDMAM; /*!< Shadow DMA mode */
  77. uint32_t SFE; /*!< Shadow FIFO enable */
  78. uint32_t SRT; /*!< Shadow RCVR Trigger */
  79. uint32_t STET; /*!< Shadow TX empty register */
  80. uint32_t HTX; /*!< Halt TX */
  81. uint32_t DMASA; /*!< DMA Software ACK */
  82. uint32_t RES2[18]; /*!< Reserved */
  83. uint32_t CPR; /*!< Camponent parameter register */
  84. uint32_t UCV; /*!< UART Component Version */
  85. uint32_t CTR; /*!< Component typw register */
  86. } DW_UART_REG, *DW_UART_REG_PTR;
  87. /** @} */
  88. #define DW_UART_GINT_DISABLED (0) /*!< designware interrupt disabled for control uart irq/fiq */
  89. #define DW_UART_GINT_ENABLE (1<<0) /*!< designware interrupt enabled for control uart irq/fiq */
  90. #define DW_UART_TXINT_ENABLE (1<<1) /*!< designware interrupt enabled for control transmit process */
  91. #define DW_UART_RXINT_ENABLE (1<<2) /*!< designware interrupt enabled for control transmit process */
  92. /**
  93. * \brief DesignWare UART control structure definition
  94. * \details implement of dev_uart_info::uart_ctrl
  95. */
  96. typedef struct dw_uart_ctrl {
  97. uint32_t dw_uart_regbase; /*!< uart ip register base */
  98. uint32_t dw_apb_bus_freq; /*!< uart ip apb bus frequency */
  99. uint32_t intno; /*!< uart interrupt vector number */
  100. INT_HANDLER dw_uart_int_handler; /*!< uart interrupt handler */
  101. uint32_t tx_fifo_len; /*!< transmit fifo length, set by user in object implementation */
  102. uint32_t rx_fifo_len; /*!< receive fifo length, set by user in object implementation */
  103. uint32_t int_status; /*!< interrupt status for designware uart */
  104. } DW_UART_CTRL, *DW_UART_CTRL_PTR;
  105. #ifdef __cplusplus
  106. extern "C" {
  107. #endif
  108. /**
  109. * \name DesignWare UART Function Declaration
  110. * \brief contains declarations of designware uart functions.
  111. * \details This are only used in uart object implementation source file
  112. * @{
  113. */
  114. extern int32_t dw_uart_open (DEV_UART *uart_obj, uint32_t baud);
  115. extern int32_t dw_uart_close (DEV_UART *uart_obj);
  116. extern int32_t dw_uart_control (DEV_UART *uart_obj, uint32_t ctrl_cmd, void *param);
  117. extern int32_t dw_uart_write (DEV_UART *uart_obj, const void *data, uint32_t len);
  118. extern int32_t dw_uart_read (DEV_UART *uart_obj, void *data, uint32_t len);
  119. extern void dw_uart_isr(DEV_UART *uart_obj, void *ptr);
  120. /** @} */
  121. #ifdef __cplusplus
  122. }
  123. #endif
  124. #endif /* _DW_UART_H_ */