xref: /linux-6.15/include/linux/serial_sci.h (revision 878fbb91)
1 #ifndef __LINUX_SERIAL_SCI_H
2 #define __LINUX_SERIAL_SCI_H
3 
4 #include <linux/serial_core.h>
5 #include <linux/sh_dma.h>
6 
7 /*
8  * Generic header for SuperH (H)SCI(F) (used by sh/sh64 and related parts)
9  */
10 
11 #define SCIx_NOT_SUPPORTED	(-1)
12 
13 #define SCSCR_TIE	(1 << 7)
14 #define SCSCR_RIE	(1 << 6)
15 #define SCSCR_TE	(1 << 5)
16 #define SCSCR_RE	(1 << 4)
17 #define SCSCR_REIE	(1 << 3)	/* not supported by all parts */
18 #define SCSCR_TOIE	(1 << 2)	/* not supported by all parts */
19 #define SCSCR_CKE1	(1 << 1)
20 #define SCSCR_CKE0	(1 << 0)
21 
22 /* SCxSR SCI */
23 #define SCI_TDRE  0x80
24 #define SCI_RDRF  0x40
25 #define SCI_ORER  0x20
26 #define SCI_FER   0x10
27 #define SCI_PER   0x08
28 #define SCI_TEND  0x04
29 
30 #define SCI_DEFAULT_ERROR_MASK (SCI_PER | SCI_FER)
31 
32 /* SCxSR SCIF, HSCIF */
33 #define SCIF_ER    0x0080
34 #define SCIF_TEND  0x0040
35 #define SCIF_TDFE  0x0020
36 #define SCIF_BRK   0x0010
37 #define SCIF_FER   0x0008
38 #define SCIF_PER   0x0004
39 #define SCIF_RDF   0x0002
40 #define SCIF_DR    0x0001
41 
42 #define SCIF_DEFAULT_ERROR_MASK (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
43 
44 /* SCSPTR, optional */
45 #define SCSPTR_RTSIO	(1 << 7)
46 #define SCSPTR_CTSIO	(1 << 5)
47 #define SCSPTR_SPB2IO	(1 << 1)
48 #define SCSPTR_SPB2DT	(1 << 0)
49 
50 /* HSSRR HSCIF */
51 #define HSCIF_SRE	0x8000
52 
53 /* Offsets into the sci_port->irqs array */
54 enum {
55 	SCIx_ERI_IRQ,
56 	SCIx_RXI_IRQ,
57 	SCIx_TXI_IRQ,
58 	SCIx_BRI_IRQ,
59 	SCIx_NR_IRQS,
60 
61 	SCIx_MUX_IRQ = SCIx_NR_IRQS,	/* special case */
62 };
63 
64 enum {
65 	SCIx_PROBE_REGTYPE,
66 
67 	SCIx_SCI_REGTYPE,
68 	SCIx_IRDA_REGTYPE,
69 	SCIx_SCIFA_REGTYPE,
70 	SCIx_SCIFB_REGTYPE,
71 	SCIx_SH2_SCIF_FIFODATA_REGTYPE,
72 	SCIx_SH3_SCIF_REGTYPE,
73 	SCIx_SH4_SCIF_REGTYPE,
74 	SCIx_SH4_SCIF_NO_SCSPTR_REGTYPE,
75 	SCIx_SH4_SCIF_FIFODATA_REGTYPE,
76 	SCIx_SH7705_SCIF_REGTYPE,
77 	SCIx_HSCIF_REGTYPE,
78 
79 	SCIx_NR_REGTYPES,
80 };
81 
82 #define SCIx_IRQ_MUXED(irq)		\
83 {					\
84 	[SCIx_ERI_IRQ]	= (irq),	\
85 	[SCIx_RXI_IRQ]	= (irq),	\
86 	[SCIx_TXI_IRQ]	= (irq),	\
87 	[SCIx_BRI_IRQ]	= (irq),	\
88 }
89 
90 #define SCIx_IRQ_IS_MUXED(port)			\
91 	((port)->irqs[SCIx_ERI_IRQ] ==	\
92 	 (port)->irqs[SCIx_RXI_IRQ]) ||	\
93 	((port)->irqs[SCIx_ERI_IRQ] &&	\
94 	 ((port)->irqs[SCIx_RXI_IRQ] < 0))
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 
105 	SCIx_NR_REGS,
106 };
107 
108 struct device;
109 
110 struct plat_sci_port_ops {
111 	void (*init_pins)(struct uart_port *, unsigned int cflag);
112 };
113 
114 /*
115  * Port-specific capabilities
116  */
117 #define SCIx_HAVE_RTSCTS	(1 << 0)
118 
119 /*
120  * Platform device specific platform_data struct
121  */
122 struct plat_sci_port {
123 	unsigned long	mapbase;		/* resource base */
124 	unsigned int	irqs[SCIx_NR_IRQS];	/* ERI, RXI, TXI, BRI */
125 	unsigned int	type;			/* SCI / SCIF / IRDA / HSCIF */
126 	upf_t		flags;			/* UPF_* flags */
127 	unsigned long	capabilities;		/* Port features/capabilities */
128 
129 	unsigned int	sampling_rate;
130 	unsigned int	scscr;			/* SCSCR initialization */
131 
132 	/*
133 	 * Platform overrides if necessary, defaults otherwise.
134 	 */
135 	int		port_reg;
136 	unsigned char	regshift;
137 	unsigned char	regtype;
138 
139 	struct plat_sci_port_ops	*ops;
140 
141 	unsigned int	dma_slave_tx;
142 	unsigned int	dma_slave_rx;
143 };
144 
145 #endif /* __LINUX_SERIAL_SCI_H */
146