Skip to content

Commit 514820e

Browse files
committed
serial: sh-sci: Consolidate RXD pin handling.
Non-SCI parts do not have the special port reg necessary for cases where the RX and SCI pins are muxed and need to be manually polled, so these like always fall back on the normal FIFO processing paths. SH7760 is in a class in and of itself with regards to mapping its SIM card interface via the SCI port class despite not having any of the RXD lines wired up and so implicitly behaving more like a SCIF in this regard. Out of the other CPUs, some support the port check via the same block while others do it through an external SuperI/O, so it's not even possible to perform the check relative to the ioremapped cookie offset, so the separate read semantics are preserved here, too. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent debf950 commit 514820e

5 files changed

Lines changed: 17 additions & 29 deletions

File tree

‎arch/sh/kernel/cpu/sh3/setup-sh770x.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ static struct platform_device rtc_device = {
108108

109109
static struct plat_sci_port scif0_platform_data = {
110110
.mapbase = 0xfffffe80,
111+
.port_reg = 0xa4000136,
111112
.flags = UPF_BOOT_AUTOCONF,
112113
.scscr = SCSCR_TE | SCSCR_RE,
113114
.scbrr_algo_id = SCBRR_ALGO_2,

‎arch/sh/kernel/cpu/sh4/setup-sh7750.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static struct platform_device rtc_device = {
3838

3939
static struct plat_sci_port sci_platform_data = {
4040
.mapbase = 0xffe00000,
41+
.port_reg = 0xffe0001C
4142
.flags = UPF_BOOT_AUTOCONF,
4243
.scscr = SCSCR_TE | SCSCR_RE,
4344
.scbrr_algo_id = SCBRR_ALGO_2,

‎drivers/tty/serial/sh-sci.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,19 @@ static int sci_rxfill(struct uart_port *port)
363363
return (sci_in(port, SCxSR) & SCxSR_RDxF(port)) != 0;
364364
}
365365

366+
/*
367+
* SCI helper for checking the state of the muxed port/RXD pins.
368+
*/
369+
static inline int sci_rxd_in(struct uart_port *port)
370+
{
371+
struct sci_port *s = to_sci_port(port);
372+
373+
if (s->cfg->port_reg <= 0)
374+
return 1;
375+
376+
return !!__raw_readb(s->cfg->port_reg);
377+
}
378+
366379
/* ********************************************************************** *
367380
* the interrupt related routines *
368381
* ********************************************************************** */

‎drivers/tty/serial/sh-sci.h‎

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -287,32 +287,3 @@ SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
287287
#endif
288288
#define sci_in(port, reg) sci_##reg##_in(port)
289289
#define sci_out(port, reg, value) sci_##reg##_out(port, value)
290-
291-
#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
292-
defined(CONFIG_CPU_SUBTYPE_SH7707) || \
293-
defined(CONFIG_CPU_SUBTYPE_SH7708) || \
294-
defined(CONFIG_CPU_SUBTYPE_SH7709)
295-
static inline int sci_rxd_in(struct uart_port *port)
296-
{
297-
if (port->mapbase == 0xfffffe80)
298-
return __raw_readb(SCPDR)&0x01 ? 1 : 0; /* SCI */
299-
return 1;
300-
}
301-
#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \
302-
defined(CONFIG_CPU_SUBTYPE_SH7751) || \
303-
defined(CONFIG_CPU_SUBTYPE_SH7751R) || \
304-
defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
305-
defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
306-
defined(CONFIG_CPU_SUBTYPE_SH7091)
307-
static inline int sci_rxd_in(struct uart_port *port)
308-
{
309-
if (port->mapbase == 0xffe00000)
310-
return __raw_readb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
311-
return 1;
312-
}
313-
#else /* default case for non-SCI processors */
314-
static inline int sci_rxd_in(struct uart_port *port)
315-
{
316-
return 1;
317-
}
318-
#endif

‎include/linux/serial_sci.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ struct plat_sci_port {
8686
int overrun_bit;
8787
unsigned int error_mask;
8888

89+
int port_reg;
90+
8991
struct device *dma_dev;
9092

9193
unsigned int dma_slave_tx;

0 commit comments

Comments
 (0)