serial_sci.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #ifndef __LINUX_SERIAL_SCI_H
  2. #define __LINUX_SERIAL_SCI_H
  3. #include <linux/serial_core.h>
  4. #include <linux/sh_dma.h>
  5. /*
  6. * Generic header for SuperH (H)SCI(F) (used by sh/sh64 and related parts)
  7. */
  8. #define SCIx_NOT_SUPPORTED (-1)
  9. enum {
  10. SCBRR_ALGO_NONE, /* Compute sampling rate in the driver */
  11. SCBRR_ALGO_1, /* clk / (16 * bps) */
  12. SCBRR_ALGO_2, /* DIV_ROUND_CLOSEST(clk, 32 * bps) - 1 */
  13. SCBRR_ALGO_3, /* clk / (8 * bps) */
  14. SCBRR_ALGO_4, /* DIV_ROUND_CLOSEST(clk, 16 * bps) - 1 */
  15. SCBRR_ALGO_6, /* HSCIF variable sample rate algorithm */
  16. };
  17. #define SCSCR_TIE (1 << 7)
  18. #define SCSCR_RIE (1 << 6)
  19. #define SCSCR_TE (1 << 5)
  20. #define SCSCR_RE (1 << 4)
  21. #define SCSCR_REIE (1 << 3) /* not supported by all parts */
  22. #define SCSCR_TOIE (1 << 2) /* not supported by all parts */
  23. #define SCSCR_CKE1 (1 << 1)
  24. #define SCSCR_CKE0 (1 << 0)
  25. /* SCxSR SCI */
  26. #define SCI_TDRE 0x80
  27. #define SCI_RDRF 0x40
  28. #define SCI_ORER 0x20
  29. #define SCI_FER 0x10
  30. #define SCI_PER 0x08
  31. #define SCI_TEND 0x04
  32. #define SCI_DEFAULT_ERROR_MASK (SCI_PER | SCI_FER)
  33. /* SCxSR SCIF, HSCIF */
  34. #define SCIF_ER 0x0080
  35. #define SCIF_TEND 0x0040
  36. #define SCIF_TDFE 0x0020
  37. #define SCIF_BRK 0x0010
  38. #define SCIF_FER 0x0008
  39. #define SCIF_PER 0x0004
  40. #define SCIF_RDF 0x0002
  41. #define SCIF_DR 0x0001
  42. #define SCIF_DEFAULT_ERROR_MASK (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
  43. /* SCSPTR, optional */
  44. #define SCSPTR_RTSIO (1 << 7)
  45. #define SCSPTR_CTSIO (1 << 5)
  46. #define SCSPTR_SPB2IO (1 << 1)
  47. #define SCSPTR_SPB2DT (1 << 0)
  48. /* HSSRR HSCIF */
  49. #define HSCIF_SRE 0x8000
  50. /* Offsets into the sci_port->irqs array */
  51. enum {
  52. SCIx_ERI_IRQ,
  53. SCIx_RXI_IRQ,
  54. SCIx_TXI_IRQ,
  55. SCIx_BRI_IRQ,
  56. SCIx_NR_IRQS,
  57. SCIx_MUX_IRQ = SCIx_NR_IRQS, /* special case */
  58. };
  59. enum {
  60. SCIx_PROBE_REGTYPE,
  61. SCIx_SCI_REGTYPE,
  62. SCIx_IRDA_REGTYPE,
  63. SCIx_SCIFA_REGTYPE,
  64. SCIx_SCIFB_REGTYPE,
  65. SCIx_SH2_SCIF_FIFODATA_REGTYPE,
  66. SCIx_SH3_SCIF_REGTYPE,
  67. SCIx_SH4_SCIF_REGTYPE,
  68. SCIx_SH4_SCIF_NO_SCSPTR_REGTYPE,
  69. SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  70. SCIx_SH7705_SCIF_REGTYPE,
  71. SCIx_HSCIF_REGTYPE,
  72. SCIx_NR_REGTYPES,
  73. };
  74. #define SCIx_IRQ_MUXED(irq) \
  75. { \
  76. [SCIx_ERI_IRQ] = (irq), \
  77. [SCIx_RXI_IRQ] = (irq), \
  78. [SCIx_TXI_IRQ] = (irq), \
  79. [SCIx_BRI_IRQ] = (irq), \
  80. }
  81. #define SCIx_IRQ_IS_MUXED(port) \
  82. ((port)->irqs[SCIx_ERI_IRQ] == \
  83. (port)->irqs[SCIx_RXI_IRQ]) || \
  84. ((port)->irqs[SCIx_ERI_IRQ] && \
  85. ((port)->irqs[SCIx_RXI_IRQ] < 0))
  86. /*
  87. * SCI register subset common for all port types.
  88. * Not all registers will exist on all parts.
  89. */
  90. enum {
  91. SCSMR, SCBRR, SCSCR, SCxSR,
  92. SCFCR, SCFDR, SCxTDR, SCxRDR,
  93. SCLSR, SCTFDR, SCRFDR, SCSPTR,
  94. HSSRR,
  95. SCIx_NR_REGS,
  96. };
  97. struct device;
  98. struct plat_sci_port_ops {
  99. void (*init_pins)(struct uart_port *, unsigned int cflag);
  100. };
  101. /*
  102. * Port-specific capabilities
  103. */
  104. #define SCIx_HAVE_RTSCTS (1 << 0)
  105. /*
  106. * Platform device specific platform_data struct
  107. */
  108. struct plat_sci_port {
  109. unsigned long mapbase; /* resource base */
  110. unsigned int irqs[SCIx_NR_IRQS]; /* ERI, RXI, TXI, BRI */
  111. unsigned int type; /* SCI / SCIF / IRDA / HSCIF */
  112. upf_t flags; /* UPF_* flags */
  113. unsigned long capabilities; /* Port features/capabilities */
  114. unsigned int sampling_rate;
  115. unsigned int scbrr_algo_id; /* SCBRR calculation algo */
  116. unsigned int scscr; /* SCSCR initialization */
  117. /*
  118. * Platform overrides if necessary, defaults otherwise.
  119. */
  120. int port_reg;
  121. unsigned char regshift;
  122. unsigned char regtype;
  123. struct plat_sci_port_ops *ops;
  124. unsigned int dma_slave_tx;
  125. unsigned int dma_slave_rx;
  126. };
  127. #endif /* __LINUX_SERIAL_SCI_H */