omap-serial.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Driver for OMAP-UART controller.
  3. * Based on drivers/serial/8250.c
  4. *
  5. * Copyright (C) 2010 Texas Instruments.
  6. *
  7. * Authors:
  8. * Govindraj R <govindraj.raja@ti.com>
  9. * Thara Gopinath <thara@ti.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. */
  16. #ifndef __OMAP_SERIAL_H__
  17. #define __OMAP_SERIAL_H__
  18. #include <linux/serial_core.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/pm_qos.h>
  21. #include <plat/mux.h>
  22. #define DRIVER_NAME "omap_uart"
  23. /*
  24. * Use tty device name as ttyO, [O -> OMAP]
  25. * in bootargs we specify as console=ttyO0 if uart1
  26. * is used as console uart.
  27. */
  28. #define OMAP_SERIAL_NAME "ttyO"
  29. #define OMAP_MODE13X_SPEED 230400
  30. #define OMAP_UART_SCR_TX_EMPTY 0x08
  31. /* WER = 0x7F
  32. * Enable module level wakeup in WER reg
  33. */
  34. #define OMAP_UART_WER_MOD_WKUP 0X7F
  35. /* Enable XON/XOFF flow control on output */
  36. #define OMAP_UART_SW_TX 0x04
  37. /* Enable XON/XOFF flow control on input */
  38. #define OMAP_UART_SW_RX 0x04
  39. #define OMAP_UART_SYSC_RESET 0X07
  40. #define OMAP_UART_TCR_TRIG 0X0F
  41. #define OMAP_UART_SW_CLR 0XF0
  42. #define OMAP_UART_FIFO_CLR 0X06
  43. #define OMAP_UART_DMA_CH_FREE -1
  44. #define OMAP_MAX_HSUART_PORTS 4
  45. #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
  46. #define UART_ERRATA_i202_MDR1_ACCESS BIT(0)
  47. #define UART_ERRATA_i291_DMA_FORCEIDLE BIT(1)
  48. struct omap_uart_port_info {
  49. bool dma_enabled; /* To specify DMA Mode */
  50. unsigned int uartclk; /* UART clock rate */
  51. upf_t flags; /* UPF_* flags */
  52. u32 errata;
  53. unsigned int dma_rx_buf_size;
  54. unsigned int dma_rx_timeout;
  55. unsigned int autosuspend_timeout;
  56. unsigned int dma_rx_poll_rate;
  57. int (*get_context_loss_count)(struct device *);
  58. void (*set_forceidle)(struct platform_device *);
  59. void (*set_noidle)(struct platform_device *);
  60. void (*enable_wakeup)(struct platform_device *, bool);
  61. };
  62. struct uart_omap_dma {
  63. u8 uart_dma_tx;
  64. u8 uart_dma_rx;
  65. int rx_dma_channel;
  66. int tx_dma_channel;
  67. dma_addr_t rx_buf_dma_phys;
  68. dma_addr_t tx_buf_dma_phys;
  69. unsigned int uart_base;
  70. /*
  71. * Buffer for rx dma.It is not required for tx because the buffer
  72. * comes from port structure.
  73. */
  74. unsigned char *rx_buf;
  75. unsigned int prev_rx_dma_pos;
  76. int tx_buf_size;
  77. int tx_dma_used;
  78. int rx_dma_used;
  79. spinlock_t tx_lock;
  80. spinlock_t rx_lock;
  81. /* timer to poll activity on rx dma */
  82. struct timer_list rx_timer;
  83. unsigned int rx_buf_size;
  84. unsigned int rx_poll_rate;
  85. unsigned int rx_timeout;
  86. };
  87. struct uart_omap_port {
  88. struct uart_port port;
  89. struct uart_omap_dma uart_dma;
  90. struct platform_device *pdev;
  91. unsigned char ier;
  92. unsigned char lcr;
  93. unsigned char mcr;
  94. unsigned char fcr;
  95. unsigned char efr;
  96. unsigned char dll;
  97. unsigned char dlh;
  98. unsigned char mdr1;
  99. unsigned char scr;
  100. int use_dma;
  101. /*
  102. * Some bits in registers are cleared on a read, so they must
  103. * be saved whenever the register is read but the bits will not
  104. * be immediately processed.
  105. */
  106. unsigned int lsr_break_flag;
  107. unsigned char msr_saved_flags;
  108. char name[20];
  109. unsigned long port_activity;
  110. u32 context_loss_cnt;
  111. u32 errata;
  112. u8 wakeups_enabled;
  113. struct pm_qos_request pm_qos_request;
  114. u32 latency;
  115. u32 calc_latency;
  116. struct work_struct qos_work;
  117. };
  118. #endif /* __OMAP_SERIAL_H__ */