Skip to content

Commit 719f3df

Browse files
prabhakarladgregkh
authored andcommitted
serial: sh-sci: Merge sh-sci.h into sh-sci.c
Inline the contents of sh-sci.h into sh-sci.c and remove the header file. The header only contained register definitions and macros used exclusively by the sh-sci driver, making the separate header unnecessary. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Link: https://patch.msgid.link/20251023104313.210989-3-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8e2c0a9 commit 719f3df

2 files changed

Lines changed: 175 additions & 179 deletions

File tree

drivers/tty/serial/sh-sci.c

Lines changed: 175 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
#undef DEBUG
1919

20+
#include <linux/bitops.h>
2021
#include <linux/clk.h>
2122
#include <linux/console.h>
2223
#include <linux/cpufreq.h>
@@ -28,6 +29,7 @@
2829
#include <linux/errno.h>
2930
#include <linux/init.h>
3031
#include <linux/interrupt.h>
32+
#include <linux/io.h>
3133
#include <linux/ioport.h>
3234
#include <linux/ktime.h>
3335
#include <linux/major.h>
@@ -40,6 +42,7 @@
4042
#include <linux/reset.h>
4143
#include <linux/scatterlist.h>
4244
#include <linux/serial.h>
45+
#include <linux/serial_core.h>
4346
#include <linux/serial_sci.h>
4447
#include <linux/sh_dma.h>
4548
#include <linux/slab.h>
@@ -57,7 +60,178 @@
5760
#include "rsci.h"
5861
#include "serial_mctrl_gpio.h"
5962
#include "sh-sci-common.h"
60-
#include "sh-sci.h"
63+
64+
#define SCI_MAJOR 204
65+
#define SCI_MINOR_START 8
66+
67+
/*
68+
* SCI register subset common for all port types.
69+
* Not all registers will exist on all parts.
70+
*/
71+
enum {
72+
SCSMR, /* Serial Mode Register */
73+
SCBRR, /* Bit Rate Register */
74+
SCSCR, /* Serial Control Register */
75+
SCxSR, /* Serial Status Register */
76+
SCFCR, /* FIFO Control Register */
77+
SCFDR, /* FIFO Data Count Register */
78+
SCxTDR, /* Transmit (FIFO) Data Register */
79+
SCxRDR, /* Receive (FIFO) Data Register */
80+
SCLSR, /* Line Status Register */
81+
SCTFDR, /* Transmit FIFO Data Count Register */
82+
SCRFDR, /* Receive FIFO Data Count Register */
83+
SCSPTR, /* Serial Port Register */
84+
HSSRR, /* Sampling Rate Register */
85+
SCPCR, /* Serial Port Control Register */
86+
SCPDR, /* Serial Port Data Register */
87+
SCDL, /* BRG Frequency Division Register */
88+
SCCKS, /* BRG Clock Select Register */
89+
HSRTRGR, /* Rx FIFO Data Count Trigger Register */
90+
HSTTRGR, /* Tx FIFO Data Count Trigger Register */
91+
SEMR, /* Serial extended mode register */
92+
};
93+
94+
/* SCSMR (Serial Mode Register) */
95+
#define SCSMR_C_A BIT(7) /* Communication Mode */
96+
#define SCSMR_CSYNC BIT(7) /* - Clocked synchronous mode */
97+
#define SCSMR_ASYNC 0 /* - Asynchronous mode */
98+
#define SCSMR_CHR BIT(6) /* 7-bit Character Length */
99+
#define SCSMR_PE BIT(5) /* Parity Enable */
100+
#define SCSMR_ODD BIT(4) /* Odd Parity */
101+
#define SCSMR_STOP BIT(3) /* Stop Bit Length */
102+
#define SCSMR_CKS 0x0003 /* Clock Select */
103+
104+
/* Serial Mode Register, SCIFA/SCIFB only bits */
105+
#define SCSMR_CKEDG BIT(12) /* Transmit/Receive Clock Edge Select */
106+
#define SCSMR_SRC_MASK 0x0700 /* Sampling Control */
107+
#define SCSMR_SRC_16 0x0000 /* Sampling rate 1/16 */
108+
#define SCSMR_SRC_5 0x0100 /* Sampling rate 1/5 */
109+
#define SCSMR_SRC_7 0x0200 /* Sampling rate 1/7 */
110+
#define SCSMR_SRC_11 0x0300 /* Sampling rate 1/11 */
111+
#define SCSMR_SRC_13 0x0400 /* Sampling rate 1/13 */
112+
#define SCSMR_SRC_17 0x0500 /* Sampling rate 1/17 */
113+
#define SCSMR_SRC_19 0x0600 /* Sampling rate 1/19 */
114+
#define SCSMR_SRC_27 0x0700 /* Sampling rate 1/27 */
115+
116+
/* Serial Control Register, SCI only bits */
117+
#define SCSCR_TEIE BIT(2) /* Transmit End Interrupt Enable */
118+
119+
/* Serial Control Register, SCIFA/SCIFB only bits */
120+
#define SCSCR_TDRQE BIT(15) /* Tx Data Transfer Request Enable */
121+
#define SCSCR_RDRQE BIT(14) /* Rx Data Transfer Request Enable */
122+
123+
/* Serial Control Register, HSCIF-only bits */
124+
#define HSSCR_TOT_SHIFT 14
125+
126+
/* SCxSR (Serial Status Register) on SCI */
127+
#define SCI_TDRE BIT(7) /* Transmit Data Register Empty */
128+
#define SCI_RDRF BIT(6) /* Receive Data Register Full */
129+
#define SCI_ORER BIT(5) /* Overrun Error */
130+
#define SCI_FER BIT(4) /* Framing Error */
131+
#define SCI_PER BIT(3) /* Parity Error */
132+
#define SCI_TEND BIT(2) /* Transmit End */
133+
#define SCI_RESERVED 0x03 /* All reserved bits */
134+
135+
#define SCI_DEFAULT_ERROR_MASK (SCI_PER | SCI_FER)
136+
137+
#define SCI_RDxF_CLEAR (u32)(~(SCI_RESERVED | SCI_RDRF))
138+
#define SCI_ERROR_CLEAR (u32)(~(SCI_RESERVED | SCI_PER | SCI_FER | SCI_ORER))
139+
#define SCI_TDxE_CLEAR (u32)(~(SCI_RESERVED | SCI_TEND | SCI_TDRE))
140+
#define SCI_BREAK_CLEAR (u32)(~(SCI_RESERVED | SCI_PER | SCI_FER | SCI_ORER))
141+
142+
/* SCxSR (Serial Status Register) on SCIF, SCIFA, SCIFB, HSCIF */
143+
#define SCIF_ER BIT(7) /* Receive Error */
144+
#define SCIF_TEND BIT(6) /* Transmission End */
145+
#define SCIF_TDFE BIT(5) /* Transmit FIFO Data Empty */
146+
#define SCIF_BRK BIT(4) /* Break Detect */
147+
#define SCIF_FER BIT(3) /* Framing Error */
148+
#define SCIF_PER BIT(2) /* Parity Error */
149+
#define SCIF_RDF BIT(1) /* Receive FIFO Data Full */
150+
#define SCIF_DR BIT(0) /* Receive Data Ready */
151+
/* SCIF only (optional) */
152+
#define SCIF_PERC 0xf000 /* Number of Parity Errors */
153+
#define SCIF_FERC 0x0f00 /* Number of Framing Errors */
154+
/*SCIFA/SCIFB and SCIF on SH7705/SH7720/SH7721 only */
155+
#define SCIFA_ORER BIT(9) /* Overrun Error */
156+
157+
#define SCIF_DEFAULT_ERROR_MASK (SCIF_PER | SCIF_FER | SCIF_BRK | SCIF_ER)
158+
159+
#define SCIF_RDxF_CLEAR (u32)(~(SCIF_DR | SCIF_RDF))
160+
#define SCIF_ERROR_CLEAR (u32)(~(SCIF_PER | SCIF_FER | SCIF_ER))
161+
#define SCIF_TDxE_CLEAR (u32)(~(SCIF_TDFE))
162+
#define SCIF_BREAK_CLEAR (u32)(~(SCIF_PER | SCIF_FER | SCIF_BRK))
163+
164+
/* SCFCR (FIFO Control Register) */
165+
#define SCFCR_RTRG1 BIT(7) /* Receive FIFO Data Count Trigger */
166+
#define SCFCR_RTRG0 BIT(6)
167+
#define SCFCR_TTRG1 BIT(5) /* Transmit FIFO Data Count Trigger */
168+
#define SCFCR_TTRG0 BIT(4)
169+
#define SCFCR_MCE BIT(3) /* Modem Control Enable */
170+
#define SCFCR_TFRST BIT(2) /* Transmit FIFO Data Register Reset */
171+
#define SCFCR_RFRST BIT(1) /* Receive FIFO Data Register Reset */
172+
#define SCFCR_LOOP BIT(0) /* Loopback Test */
173+
174+
/* SCLSR (Line Status Register) on (H)SCIF */
175+
#define SCLSR_TO BIT(2) /* Timeout */
176+
#define SCLSR_ORER BIT(0) /* Overrun Error */
177+
178+
/* SCSPTR (Serial Port Register), optional */
179+
#define SCSPTR_RTSIO BIT(7) /* Serial Port RTS# Pin Input/Output */
180+
#define SCSPTR_RTSDT BIT(6) /* Serial Port RTS# Pin Data */
181+
#define SCSPTR_CTSIO BIT(5) /* Serial Port CTS# Pin Input/Output */
182+
#define SCSPTR_CTSDT BIT(4) /* Serial Port CTS# Pin Data */
183+
#define SCSPTR_SCKIO BIT(3) /* Serial Port Clock Pin Input/Output */
184+
#define SCSPTR_SCKDT BIT(2) /* Serial Port Clock Pin Data */
185+
#define SCSPTR_SPB2IO BIT(1) /* Serial Port Break Input/Output */
186+
#define SCSPTR_SPB2DT BIT(0) /* Serial Port Break Data */
187+
188+
/* HSSRR HSCIF */
189+
#define HSCIF_SRE BIT(15) /* Sampling Rate Register Enable */
190+
#define HSCIF_SRDE BIT(14) /* Sampling Point Register Enable */
191+
192+
#define HSCIF_SRHP_SHIFT 8
193+
#define HSCIF_SRHP_MASK 0x0f00
194+
195+
/* SCPCR (Serial Port Control Register), SCIFA/SCIFB only */
196+
#define SCPCR_RTSC BIT(4) /* Serial Port RTS# Pin / Output Pin */
197+
#define SCPCR_CTSC BIT(3) /* Serial Port CTS# Pin / Input Pin */
198+
#define SCPCR_SCKC BIT(2) /* Serial Port SCK Pin / Output Pin */
199+
#define SCPCR_RXDC BIT(1) /* Serial Port RXD Pin / Input Pin */
200+
#define SCPCR_TXDC BIT(0) /* Serial Port TXD Pin / Output Pin */
201+
202+
/* SCPDR (Serial Port Data Register), SCIFA/SCIFB only */
203+
#define SCPDR_RTSD BIT(4) /* Serial Port RTS# Output Pin Data */
204+
#define SCPDR_CTSD BIT(3) /* Serial Port CTS# Input Pin Data */
205+
#define SCPDR_SCKD BIT(2) /* Serial Port SCK Output Pin Data */
206+
#define SCPDR_RXDD BIT(1) /* Serial Port RXD Input Pin Data */
207+
#define SCPDR_TXDD BIT(0) /* Serial Port TXD Output Pin Data */
208+
209+
/*
210+
* BRG Clock Select Register (Some SCIF and HSCIF)
211+
* The Baud Rate Generator for external clock can provide a clock source for
212+
* the sampling clock. It outputs either its frequency divided clock, or the
213+
* (undivided) (H)SCK external clock.
214+
*/
215+
#define SCCKS_CKS BIT(15) /* Select (H)SCK (1) or divided SC_CLK (0) */
216+
#define SCCKS_XIN BIT(14) /* SC_CLK uses bus clock (1) or SCIF_CLK (0) */
217+
218+
#define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND)
219+
#define SCxSR_RDxF(port) (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_DR | SCIF_RDF)
220+
#define SCxSR_TDxE(port) (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE)
221+
#define SCxSR_FER(port) (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER)
222+
#define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER)
223+
#define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK)
224+
225+
#define SCxSR_ERRORS(port) (to_sci_port(port)->params->error_mask)
226+
227+
#define SCxSR_RDxF_CLEAR(port) \
228+
(((port)->type == PORT_SCI) ? SCI_RDxF_CLEAR : SCIF_RDxF_CLEAR)
229+
#define SCxSR_ERROR_CLEAR(port) \
230+
(to_sci_port(port)->params->error_clear)
231+
#define SCxSR_TDxE_CLEAR(port) \
232+
(((port)->type == PORT_SCI) ? SCI_TDxE_CLEAR : SCIF_TDxE_CLEAR)
233+
#define SCxSR_BREAK_CLEAR(port) \
234+
(((port)->type == PORT_SCI) ? SCI_BREAK_CLEAR : SCIF_BREAK_CLEAR)
61235

62236
#define SCIx_IRQ_IS_MUXED(port) \
63237
((port)->irqs[SCIx_ERI_IRQ] == \

drivers/tty/serial/sh-sci.h

Lines changed: 0 additions & 178 deletions
This file was deleted.

0 commit comments

Comments
 (0)