Skip to content

Commit 2f50304

Browse files
prabhakarladgregkh
authored andcommitted
serial: sh-sci: Add support for RZ/V2H(P) SoC
Add serial support for RZ/V2H(P) SoC with earlycon. The SCIF interface in the Renesas RZ/V2H(P) is similar to that available in the RZ/G2L (R9A07G044) SoC, with the following differences: - RZ/V2H(P) SoC has three additional interrupts: one for Tx end/Rx ready and two for Rx and Tx buffer full, all of which are edge-triggered. - RZ/V2H(P) supports asynchronous mode, whereas RZ/G2L supports both synchronous and asynchronous modes. - There are differences in the configuration of certain registers such as SCSMR, SCFCR, and SCSPTR between the two SoCs. To handle these differences on RZ/V2H(P) SoC SCIx_RZV2H_SCIF_REGTYPE is added. Signed-off-by: Lad Prabhakar <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 964a80c commit 2f50304

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

drivers/tty/serial/sh-sci.c

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,37 @@ static const struct sci_port_params sci_port_params[SCIx_NR_REGTYPES] = {
317317
.error_clear = SCIF_ERROR_CLEAR,
318318
},
319319

320+
/*
321+
* The "SCIF" that is in RZ/V2H(P) SoC is similar to one found on RZ/G2L SoC
322+
* with below differences,
323+
* - Break out of interrupts are different: ERI, BRI, RXI, TXI, TEI, DRI,
324+
* TEI-DRI, RXI-EDGE and TXI-EDGE.
325+
* - SCSMR register does not have CM bit (BIT(7)) ie it does not support synchronous mode.
326+
* - SCFCR register does not have SCFCR_MCE bit.
327+
* - SCSPTR register has only bits SCSPTR_SPB2DT and SCSPTR_SPB2IO.
328+
*/
329+
[SCIx_RZV2H_SCIF_REGTYPE] = {
330+
.regs = {
331+
[SCSMR] = { 0x00, 16 },
332+
[SCBRR] = { 0x02, 8 },
333+
[SCSCR] = { 0x04, 16 },
334+
[SCxTDR] = { 0x06, 8 },
335+
[SCxSR] = { 0x08, 16 },
336+
[SCxRDR] = { 0x0a, 8 },
337+
[SCFCR] = { 0x0c, 16 },
338+
[SCFDR] = { 0x0e, 16 },
339+
[SCSPTR] = { 0x10, 16 },
340+
[SCLSR] = { 0x12, 16 },
341+
[SEMR] = { 0x14, 8 },
342+
},
343+
.fifosize = 16,
344+
.overrun_reg = SCLSR,
345+
.overrun_mask = SCLSR_ORER,
346+
.sampling_rate_mask = SCI_SR(32),
347+
.error_mask = SCIF_DEFAULT_ERROR_MASK,
348+
.error_clear = SCIF_ERROR_CLEAR,
349+
},
350+
320351
/*
321352
* Common SH-3 SCIF definitions.
322353
*/
@@ -757,7 +788,7 @@ static void sci_init_pins(struct uart_port *port, unsigned int cflag)
757788
}
758789
sci_serial_out(port, SCPDR, data);
759790
sci_serial_out(port, SCPCR, ctrl);
760-
} else if (sci_getreg(port, SCSPTR)->size) {
791+
} else if (sci_getreg(port, SCSPTR)->size && s->cfg->regtype != SCIx_RZV2H_SCIF_REGTYPE) {
761792
u16 status = sci_serial_in(port, SCSPTR);
762793

763794
/* RTS# is always output; and active low, unless autorts */
@@ -2124,8 +2155,9 @@ static void sci_set_mctrl(struct uart_port *port, unsigned int mctrl)
21242155

21252156
if (!(mctrl & TIOCM_RTS)) {
21262157
/* Disable Auto RTS */
2127-
sci_serial_out(port, SCFCR,
2128-
sci_serial_in(port, SCFCR) & ~SCFCR_MCE);
2158+
if (s->cfg->regtype != SCIx_RZV2H_SCIF_REGTYPE)
2159+
sci_serial_out(port, SCFCR,
2160+
sci_serial_in(port, SCFCR) & ~SCFCR_MCE);
21292161

21302162
/* Clear RTS */
21312163
sci_set_rts(port, 0);
@@ -2137,8 +2169,9 @@ static void sci_set_mctrl(struct uart_port *port, unsigned int mctrl)
21372169
}
21382170

21392171
/* Enable Auto RTS */
2140-
sci_serial_out(port, SCFCR,
2141-
sci_serial_in(port, SCFCR) | SCFCR_MCE);
2172+
if (s->cfg->regtype != SCIx_RZV2H_SCIF_REGTYPE)
2173+
sci_serial_out(port, SCFCR,
2174+
sci_serial_in(port, SCFCR) | SCFCR_MCE);
21422175
} else {
21432176
/* Set RTS */
21442177
sci_set_rts(port, 1);
@@ -3225,6 +3258,10 @@ static const struct of_device_id of_sci_match[] __maybe_unused = {
32253258
.compatible = "renesas,scif-r9a07g044",
32263259
.data = SCI_OF_DATA(PORT_SCIF, SCIx_RZ_SCIFA_REGTYPE),
32273260
},
3261+
{
3262+
.compatible = "renesas,scif-r9a09g057",
3263+
.data = SCI_OF_DATA(PORT_SCIF, SCIx_RZV2H_SCIF_REGTYPE),
3264+
},
32283265
/* Family-specific types */
32293266
{
32303267
.compatible = "renesas,rcar-gen1-scif",
@@ -3533,6 +3570,13 @@ static int __init rzscifa_early_console_setup(struct earlycon_device *device,
35333570
return early_console_setup(device, PORT_SCIF);
35343571
}
35353572

3573+
static int __init rzv2hscif_early_console_setup(struct earlycon_device *device,
3574+
const char *opt)
3575+
{
3576+
port_cfg.regtype = SCIx_RZV2H_SCIF_REGTYPE;
3577+
return early_console_setup(device, PORT_SCIF);
3578+
}
3579+
35363580
static int __init scifa_early_console_setup(struct earlycon_device *device,
35373581
const char *opt)
35383582
{
@@ -3553,6 +3597,7 @@ OF_EARLYCON_DECLARE(sci, "renesas,sci", sci_early_console_setup);
35533597
OF_EARLYCON_DECLARE(scif, "renesas,scif", scif_early_console_setup);
35543598
OF_EARLYCON_DECLARE(scif, "renesas,scif-r7s9210", rzscifa_early_console_setup);
35553599
OF_EARLYCON_DECLARE(scif, "renesas,scif-r9a07g044", rzscifa_early_console_setup);
3600+
OF_EARLYCON_DECLARE(scif, "renesas,scif-r9a09g057", rzv2hscif_early_console_setup);
35563601
OF_EARLYCON_DECLARE(scifa, "renesas,scifa", scifa_early_console_setup);
35573602
OF_EARLYCON_DECLARE(scifb, "renesas,scifb", scifb_early_console_setup);
35583603
OF_EARLYCON_DECLARE(hscif, "renesas,hscif", hscif_early_console_setup);

include/linux/serial_sci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum {
3737
SCIx_SH7705_SCIF_REGTYPE,
3838
SCIx_HSCIF_REGTYPE,
3939
SCIx_RZ_SCIFA_REGTYPE,
40+
SCIx_RZV2H_SCIF_REGTYPE,
4041

4142
SCIx_NR_REGTYPES,
4243
};

0 commit comments

Comments
 (0)