Paul Mundt | 96de1a8 | 2008-02-26 14:52:45 +0900 | [diff] [blame] | 1 | #ifndef __LINUX_SERIAL_SCI_H |
| 2 | #define __LINUX_SERIAL_SCI_H |
Paul Mundt | ecd9561 | 2006-09-27 17:32:30 +0900 | [diff] [blame] | 3 | |
| 4 | #include <linux/serial_core.h> |
Paul Mundt | 14baf9d | 2010-05-24 16:31:08 +0900 | [diff] [blame] | 5 | #include <linux/sh_dma.h> |
Paul Mundt | ecd9561 | 2006-09-27 17:32:30 +0900 | [diff] [blame] | 6 | |
| 7 | /* |
Guenter Roeck | 4b08478 | 2013-08-30 06:01:49 -0700 | [diff] [blame] | 8 | * Generic header for SuperH (H)SCI(F) (used by sh/sh64 and related parts) |
Paul Mundt | ecd9561 | 2006-09-27 17:32:30 +0900 | [diff] [blame] | 9 | */ |
| 10 | |
Paul Mundt | debf950 | 2011-06-08 18:19:37 +0900 | [diff] [blame] | 11 | #define SCIx_NOT_SUPPORTED (-1) |
| 12 | |
Geert Uytterhoeven | 26de4f1 | 2014-03-11 11:11:19 +0100 | [diff] [blame] | 13 | /* SCSMR (Serial Mode Register) */ |
| 14 | #define SCSMR_CHR (1 << 6) /* 7-bit Character Length */ |
| 15 | #define SCSMR_PE (1 << 5) /* Parity Enable */ |
| 16 | #define SCSMR_ODD (1 << 4) /* Odd Parity */ |
| 17 | #define SCSMR_STOP (1 << 3) /* Stop Bit Length */ |
| 18 | #define SCSMR_CKS 0x0003 /* Clock Select */ |
Paul Mundt | 00b9de9 | 2009-06-24 17:53:33 +0900 | [diff] [blame] | 19 | |
Geert Uytterhoeven | 26de4f1 | 2014-03-11 11:11:19 +0100 | [diff] [blame] | 20 | /* Serial Control Register (@ = not supported by all parts) */ |
| 21 | #define SCSCR_TIE (1 << 7) /* Transmit Interrupt Enable */ |
| 22 | #define SCSCR_RIE (1 << 6) /* Receive Interrupt Enable */ |
| 23 | #define SCSCR_TE (1 << 5) /* Transmit Enable */ |
| 24 | #define SCSCR_RE (1 << 4) /* Receive Enable */ |
| 25 | #define SCSCR_REIE (1 << 3) /* Receive Error Interrupt Enable @ */ |
| 26 | #define SCSCR_TOIE (1 << 2) /* Timeout Interrupt Enable @ */ |
| 27 | #define SCSCR_CKE1 (1 << 1) /* Clock Enable 1 */ |
| 28 | #define SCSCR_CKE0 (1 << 0) /* Clock Enable 0 */ |
| 29 | /* SCIFA/SCIFB only */ |
| 30 | #define SCSCR_TDRQE (1 << 15) /* Tx Data Transfer Request Enable */ |
| 31 | #define SCSCR_RDRQE (1 << 14) /* Rx Data Transfer Request Enable */ |
| 32 | |
| 33 | /* SCxSR (Serial Status Register) on SCI */ |
| 34 | #define SCI_TDRE 0x80 /* Transmit Data Register Empty */ |
| 35 | #define SCI_RDRF 0x40 /* Receive Data Register Full */ |
| 36 | #define SCI_ORER 0x20 /* Overrun Error */ |
| 37 | #define SCI_FER 0x10 /* Framing Error */ |
| 38 | #define SCI_PER 0x08 /* Parity Error */ |
| 39 | #define SCI_TEND 0x04 /* Transmit End */ |
Paul Mundt | debf950 | 2011-06-08 18:19:37 +0900 | [diff] [blame] | 40 | |
| 41 | #define SCI_DEFAULT_ERROR_MASK (SCI_PER | SCI_FER) |
| 42 | |
Geert Uytterhoeven | 26de4f1 | 2014-03-11 11:11:19 +0100 | [diff] [blame] | 43 | /* SCxSR (Serial Status Register) on SCIF, HSCIF */ |
| 44 | #define SCIF_ER 0x0080 /* Receive Error */ |
| 45 | #define SCIF_TEND 0x0040 /* Transmission End */ |
| 46 | #define SCIF_TDFE 0x0020 /* Transmit FIFO Data Empty */ |
| 47 | #define SCIF_BRK 0x0010 /* Break Detect */ |
| 48 | #define SCIF_FER 0x0008 /* Framing Error */ |
| 49 | #define SCIF_PER 0x0004 /* Parity Error */ |
| 50 | #define SCIF_RDF 0x0002 /* Receive FIFO Data Full */ |
| 51 | #define SCIF_DR 0x0001 /* Receive Data Ready */ |
Paul Mundt | debf950 | 2011-06-08 18:19:37 +0900 | [diff] [blame] | 52 | |
| 53 | #define SCIF_DEFAULT_ERROR_MASK (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK) |
| 54 | |
Geert Uytterhoeven | 26de4f1 | 2014-03-11 11:11:19 +0100 | [diff] [blame] | 55 | /* SCFCR (FIFO Control Register) */ |
| 56 | #define SCFCR_LOOP (1 << 0) /* Loopback Test */ |
| 57 | |
| 58 | /* SCSPTR (Serial Port Register), optional */ |
| 59 | #define SCSPTR_RTSIO (1 << 7) /* Serial Port RTS Pin Input/Output */ |
| 60 | #define SCSPTR_CTSIO (1 << 5) /* Serial Port CTS Pin Input/Output */ |
| 61 | #define SCSPTR_SPB2IO (1 << 1) /* Serial Port Break Input/Output */ |
| 62 | #define SCSPTR_SPB2DT (1 << 0) /* Serial Port Break Data */ |
Paul Mundt | faf02f8 | 2011-12-02 17:44:50 +0900 | [diff] [blame] | 63 | |
Ulrich Hecht | f303b36 | 2013-05-31 17:57:01 +0200 | [diff] [blame] | 64 | /* HSSRR HSCIF */ |
Geert Uytterhoeven | 26de4f1 | 2014-03-11 11:11:19 +0100 | [diff] [blame] | 65 | #define HSCIF_SRE 0x8000 /* Sampling Rate Register Enable */ |
Ulrich Hecht | f303b36 | 2013-05-31 17:57:01 +0200 | [diff] [blame] | 66 | |
Paul Mundt | 61a6976 | 2011-06-14 12:40:19 +0900 | [diff] [blame] | 67 | enum { |
| 68 | SCIx_PROBE_REGTYPE, |
| 69 | |
| 70 | SCIx_SCI_REGTYPE, |
| 71 | SCIx_IRDA_REGTYPE, |
| 72 | SCIx_SCIFA_REGTYPE, |
| 73 | SCIx_SCIFB_REGTYPE, |
Phil Edworthy | 3af1f8a | 2011-10-03 15:16:47 +0100 | [diff] [blame] | 74 | SCIx_SH2_SCIF_FIFODATA_REGTYPE, |
Paul Mundt | 61a6976 | 2011-06-14 12:40:19 +0900 | [diff] [blame] | 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, |
Ulrich Hecht | f303b36 | 2013-05-31 17:57:01 +0200 | [diff] [blame] | 80 | SCIx_HSCIF_REGTYPE, |
Paul Mundt | 61a6976 | 2011-06-14 12:40:19 +0900 | [diff] [blame] | 81 | |
| 82 | SCIx_NR_REGTYPES, |
| 83 | }; |
| 84 | |
Paul Mundt | 61a6976 | 2011-06-14 12:40:19 +0900 | [diff] [blame] | 85 | /* |
| 86 | * SCI register subset common for all port types. |
| 87 | * Not all registers will exist on all parts. |
| 88 | */ |
| 89 | enum { |
Geert Uytterhoeven | 26de4f1 | 2014-03-11 11:11:19 +0100 | [diff] [blame] | 90 | SCSMR, /* Serial Mode Register */ |
| 91 | SCBRR, /* Bit Rate Register */ |
| 92 | SCSCR, /* Serial Control Register */ |
| 93 | SCxSR, /* Serial Status Register */ |
| 94 | SCFCR, /* FIFO Control Register */ |
| 95 | SCFDR, /* FIFO Data Count Register */ |
| 96 | SCxTDR, /* Transmit (FIFO) Data Register */ |
| 97 | SCxRDR, /* Receive (FIFO) Data Register */ |
| 98 | SCLSR, /* Line Status Register */ |
| 99 | SCTFDR, /* Transmit FIFO Data Count Register */ |
| 100 | SCRFDR, /* Receive FIFO Data Count Register */ |
| 101 | SCSPTR, /* Serial Port Register */ |
| 102 | HSSRR, /* Sampling Rate Register */ |
Paul Mundt | 61a6976 | 2011-06-14 12:40:19 +0900 | [diff] [blame] | 103 | |
| 104 | SCIx_NR_REGS, |
| 105 | }; |
| 106 | |
Guennadi Liakhovetski | 73a19e4 | 2010-03-02 11:39:15 +0900 | [diff] [blame] | 107 | struct device; |
| 108 | |
Paul Mundt | 61a6976 | 2011-06-14 12:40:19 +0900 | [diff] [blame] | 109 | struct plat_sci_port_ops { |
| 110 | void (*init_pins)(struct uart_port *, unsigned int cflag); |
| 111 | }; |
| 112 | |
Paul Mundt | ecd9561 | 2006-09-27 17:32:30 +0900 | [diff] [blame] | 113 | /* |
Paul Mundt | faf02f8 | 2011-12-02 17:44:50 +0900 | [diff] [blame] | 114 | * Port-specific capabilities |
| 115 | */ |
| 116 | #define SCIx_HAVE_RTSCTS (1 << 0) |
| 117 | |
| 118 | /* |
Paul Mundt | ecd9561 | 2006-09-27 17:32:30 +0900 | [diff] [blame] | 119 | * Platform device specific platform_data struct |
| 120 | */ |
| 121 | struct plat_sci_port { |
Ulrich Hecht | f303b36 | 2013-05-31 17:57:01 +0200 | [diff] [blame] | 122 | unsigned int type; /* SCI / SCIF / IRDA / HSCIF */ |
Paul Mundt | ecd9561 | 2006-09-27 17:32:30 +0900 | [diff] [blame] | 123 | upf_t flags; /* UPF_* flags */ |
Paul Mundt | faf02f8 | 2011-12-02 17:44:50 +0900 | [diff] [blame] | 124 | unsigned long capabilities; /* Port features/capabilities */ |
Paul Mundt | 00b9de9 | 2009-06-24 17:53:33 +0900 | [diff] [blame] | 125 | |
Laurent Pinchart | ec09c5e | 2013-12-06 10:59:20 +0100 | [diff] [blame] | 126 | unsigned int sampling_rate; |
Paul Mundt | 00b9de9 | 2009-06-24 17:53:33 +0900 | [diff] [blame] | 127 | unsigned int scscr; /* SCSCR initialization */ |
Paul Mundt | f43dc23 | 2011-01-13 15:06:28 +0900 | [diff] [blame] | 128 | |
Paul Mundt | debf950 | 2011-06-08 18:19:37 +0900 | [diff] [blame] | 129 | /* |
| 130 | * Platform overrides if necessary, defaults otherwise. |
| 131 | */ |
Paul Mundt | 514820e | 2011-06-08 18:51:32 +0900 | [diff] [blame] | 132 | int port_reg; |
Paul Mundt | 61a6976 | 2011-06-14 12:40:19 +0900 | [diff] [blame] | 133 | unsigned char regshift; |
| 134 | unsigned char regtype; |
| 135 | |
| 136 | struct plat_sci_port_ops *ops; |
Paul Mundt | 514820e | 2011-06-08 18:51:32 +0900 | [diff] [blame] | 137 | |
Paul Mundt | 27bd107 | 2011-01-19 15:37:31 +0900 | [diff] [blame] | 138 | unsigned int dma_slave_tx; |
| 139 | unsigned int dma_slave_rx; |
Paul Mundt | ecd9561 | 2006-09-27 17:32:30 +0900 | [diff] [blame] | 140 | }; |
| 141 | |
Paul Mundt | 96de1a8 | 2008-02-26 14:52:45 +0900 | [diff] [blame] | 142 | #endif /* __LINUX_SERIAL_SCI_H */ |