serial_sci.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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/h8300 and related parts)
  7. */
  8. #define SCIx_NOT_SUPPORTED (-1)
  9. enum {
  10. SCBRR_ALGO_1, /* ((clk + 16 * bps) / (16 * bps) - 1) */
  11. SCBRR_ALGO_2, /* ((clk + 16 * bps) / (32 * bps) - 1) */
  12. SCBRR_ALGO_3, /* (((clk * 2) + 16 * bps) / (16 * bps) - 1) */
  13. SCBRR_ALGO_4, /* (((clk * 2) + 16 * bps) / (32 * bps) - 1) */
  14. SCBRR_ALGO_5, /* (((clk * 1000 / 32) / 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. /* Offsets into the sci_port->gpios array */
  60. enum {
  61. SCIx_SCK,
  62. SCIx_RXD,
  63. SCIx_TXD,
  64. SCIx_CTS,
  65. SCIx_RTS,
  66. SCIx_NR_FNS,
  67. };
  68. enum {
  69. SCIx_PROBE_REGTYPE,
  70. SCIx_SCI_REGTYPE,
  71. SCIx_IRDA_REGTYPE,
  72. SCIx_SCIFA_REGTYPE,
  73. SCIx_SCIFB_REGTYPE,
  74. SCIx_SH2_SCIF_FIFODATA_REGTYPE,
  75. SCIx_SH3_SCIF_REGTYPE,
  76. SCIx_SH4_SCIF_REGTYPE,
  77. SCIx_SH4_SCIF_NO_SCSPTR_REGTYPE,
  78. SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  79. SCIx_SH7705_SCIF_REGTYPE,
  80. SCIx_HSCIF_REGTYPE,
  81. SCIx_NR_REGTYPES,
  82. };
  83. #define SCIx_IRQ_MUXED(irq) \
  84. { \
  85. [SCIx_ERI_IRQ] = (irq), \
  86. [SCIx_RXI_IRQ] = (irq), \
  87. [SCIx_TXI_IRQ] = (irq), \
  88. [SCIx_BRI_IRQ] = (irq), \
  89. }
  90. #define SCIx_IRQ_IS_MUXED(port) \
  91. ((port)->cfg->irqs[SCIx_ERI_IRQ] == \
  92. (port)->cfg->irqs[SCIx_RXI_IRQ]) || \
  93. ((port)->cfg->irqs[SCIx_ERI_IRQ] && \
  94. !(port)->cfg->irqs[SCIx_RXI_IRQ])
  95. /*
  96. * SCI register subset common for all port types.
  97. * Not all registers will exist on all parts.
  98. */
  99. enum {
  100. SCSMR, SCBRR, SCSCR, SCxSR,
  101. SCFCR, SCFDR, SCxTDR, SCxRDR,
  102. SCLSR, SCTFDR, SCRFDR, SCSPTR,
  103. HSSRR,
  104. SCIx_NR_REGS,
  105. };
  106. struct device;
  107. struct plat_sci_port_ops {
  108. void (*init_pins)(struct uart_port *, unsigned int cflag);
  109. };
  110. /*
  111. * Port-specific capabilities
  112. */
  113. #define SCIx_HAVE_RTSCTS (1 << 0)
  114. /*
  115. * Platform device specific platform_data struct
  116. */
  117. struct plat_sci_port {
  118. unsigned long mapbase; /* resource base */
  119. unsigned int irqs[SCIx_NR_IRQS]; /* ERI, RXI, TXI, BRI */
  120. unsigned int gpios[SCIx_NR_FNS]; /* SCK, RXD, TXD, CTS, RTS */
  121. unsigned int type; /* SCI / SCIF / IRDA / HSCIF */
  122. upf_t flags; /* UPF_* flags */
  123. unsigned long capabilities; /* Port features/capabilities */
  124. unsigned int scbrr_algo_id; /* SCBRR calculation algo */
  125. unsigned int scscr; /* SCSCR initialization */
  126. /*
  127. * Platform overrides if necessary, defaults otherwise.
  128. */
  129. int overrun_bit;
  130. unsigned int error_mask;
  131. int port_reg;
  132. unsigned char regshift;
  133. unsigned char regtype;
  134. struct plat_sci_port_ops *ops;
  135. unsigned int dma_slave_tx;
  136. unsigned int dma_slave_rx;
  137. };
  138. #endif /* __LINUX_SERIAL_SCI_H */