apbuart.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef __GRLIB_APBUART_H__
  2. #define __GRLIB_APBUART_H__
  3. #include <asm/io.h>
  4. #define UART_NR 8
  5. static int grlib_apbuart_port_nr;
  6. struct grlib_apbuart_regs_map {
  7. u32 data;
  8. u32 status;
  9. u32 ctrl;
  10. u32 scaler;
  11. };
  12. struct amba_prom_registers {
  13. unsigned int phys_addr;
  14. unsigned int reg_size;
  15. };
  16. /*
  17. * The following defines the bits in the APBUART Status Registers.
  18. */
  19. #define UART_STATUS_DR 0x00000001 /* Data Ready */
  20. #define UART_STATUS_TSE 0x00000002 /* TX Send Register Empty */
  21. #define UART_STATUS_THE 0x00000004 /* TX Hold Register Empty */
  22. #define UART_STATUS_BR 0x00000008 /* Break Error */
  23. #define UART_STATUS_OE 0x00000010 /* RX Overrun Error */
  24. #define UART_STATUS_PE 0x00000020 /* RX Parity Error */
  25. #define UART_STATUS_FE 0x00000040 /* RX Framing Error */
  26. #define UART_STATUS_ERR 0x00000078 /* Error Mask */
  27. /*
  28. * The following defines the bits in the APBUART Ctrl Registers.
  29. */
  30. #define UART_CTRL_RE 0x00000001 /* Receiver enable */
  31. #define UART_CTRL_TE 0x00000002 /* Transmitter enable */
  32. #define UART_CTRL_RI 0x00000004 /* Receiver interrupt enable */
  33. #define UART_CTRL_TI 0x00000008 /* Transmitter irq */
  34. #define UART_CTRL_PS 0x00000010 /* Parity select */
  35. #define UART_CTRL_PE 0x00000020 /* Parity enable */
  36. #define UART_CTRL_FL 0x00000040 /* Flow control enable */
  37. #define UART_CTRL_LB 0x00000080 /* Loopback enable */
  38. #define APBBASE(port) ((struct grlib_apbuart_regs_map *)((port)->membase))
  39. #define APBBASE_DATA_P(port) (&(APBBASE(port)->data))
  40. #define APBBASE_STATUS_P(port) (&(APBBASE(port)->status))
  41. #define APBBASE_CTRL_P(port) (&(APBBASE(port)->ctrl))
  42. #define APBBASE_SCALAR_P(port) (&(APBBASE(port)->scaler))
  43. #define UART_GET_CHAR(port) (__raw_readl(APBBASE_DATA_P(port)))
  44. #define UART_PUT_CHAR(port, v) (__raw_writel(v, APBBASE_DATA_P(port)))
  45. #define UART_GET_STATUS(port) (__raw_readl(APBBASE_STATUS_P(port)))
  46. #define UART_PUT_STATUS(port, v)(__raw_writel(v, APBBASE_STATUS_P(port)))
  47. #define UART_GET_CTRL(port) (__raw_readl(APBBASE_CTRL_P(port)))
  48. #define UART_PUT_CTRL(port, v) (__raw_writel(v, APBBASE_CTRL_P(port)))
  49. #define UART_GET_SCAL(port) (__raw_readl(APBBASE_SCALAR_P(port)))
  50. #define UART_PUT_SCAL(port, v) (__raw_writel(v, APBBASE_SCALAR_P(port)))
  51. #define UART_RX_DATA(s) (((s) & UART_STATUS_DR) != 0)
  52. #define UART_TX_READY(s) (((s) & UART_STATUS_THE) != 0)
  53. #endif /* __GRLIB_APBUART_H__ */