From nobody Tue Feb 10 01:35:26 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3987D315D2C for ; Fri, 14 Nov 2025 10:52:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763117538; cv=none; b=roi8+o+CoaLmbpAXlY4vLlVXEzYmdcdEmEIBmAB5iQ3IruBQl4kMrHtPT4lR4WDfguVFeFNFPa12qxFWfunzXNBgBbX4Ay67zf9wznxJkLP7t6PjG4fAMIeva+YB2XTwp0Nqvd1AD/lNhFkJRkW2wKrNP8kiSQ0lW5jSnuJnIuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763117538; c=relaxed/simple; bh=6O3doIFr9IR4S2kx1M6uldVyjIjXurTG0Y9yc4WTdAQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g0vq7Wa59y4WH1faBcVnK/NplrNcZKNPeS8V+R5CmBbFSSMfqMfpBwsTi0bb1QvwRqbwes+uqtbGpuZ6Lxtps/L6hGn7DfoCeLaakVBCAvp7oK8pyLUd4K9w4S129B6ZivpKSms0bYQEXA1AqruJv9jDe5hVJCzauuY5G2gpcJQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Dbag8zqM; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Dbag8zqM" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-47775fb6c56so20485255e9.1 for ; Fri, 14 Nov 2025 02:52:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763117533; x=1763722333; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ATfnSc/33FwJ+wue2neEbqFM/q6MAl95n5pgQFg9uxw=; b=Dbag8zqM2hgs798YIf3xt4zw2mUO89SFiIfrZCt9vxg0SiCO9RS1nR0zSSvsp0HV+k L7UxiYdRZfLNmvRkcbn/IQllDk881c33Qvl3PH4Gwj46KLJMYiP+e4s5hO4dCmLJlY92 +XapvLSUXUjtK9ld6DWLtEDRB+vrqqjSiwRqnoOvuqij3iRrxnHBXpbNTukixvafjqH5 RWqTFW62agAXZlgV8hN1lGoobBjwguONcRCVw5W+lUpH1WzRx3Irvc+wFWPgjdsTW7rZ hclU3+PbROovElufxqfX7w/1j7mHDQEmLso7vpjsdjuJOqO4Z+JX7UXoUoDs2nJXMHt7 zRpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763117533; x=1763722333; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ATfnSc/33FwJ+wue2neEbqFM/q6MAl95n5pgQFg9uxw=; b=anM7AEw0IGnr4Ndqe49lOzL7HEayRR+nKIRfrGfQ7KKDOrsqAAwHBbOHbsjq1nBr6F nMTwNbmSmq1CmeIcrslFMQ8nrY93ZGLU/E/uTkK4kzMxv0kBp2mutezzC3fPUOCjNUVz 5XqATg4QtjSM9whHjU9vHd5+r5Ra/PGlq+KWOH2wSQr2AOvHWR6/8zMdnwHpF6LoNAqE YZEVAeStlBVh5d+WS4mpCuApVmAfwlmAMh3VKP1IQMwl65qd6Z7rA8KTWOTCB39NwjHC 1xqHGuGk/3fD27U+/WgIxsdI9Xaor86LVPdyUbfeTUYYpr1uHR9z3a2Z8ptX/KT9RqD+ 7gXA== X-Forwarded-Encrypted: i=1; AJvYcCX5N9RIxxZJl6lB7FtanbKT9XgGUWQVOWNtpjTsmy/vo/UQwln3Umrp7M5yf/OlcHDieaVNTWHdFPotrn4=@vger.kernel.org X-Gm-Message-State: AOJu0YxgM+GxHZzCW3xCkqHBJfsCyYYAVaBVJxd05ed3roMS3Zt6IylC TsxVPEIHChA1NJ0WEpAkixc329iXv86uNna8GAmfzreH2J3Gq6SXw4ck1qT70Q== X-Gm-Gg: ASbGncvDsuL5BbsUVdgbhg6pOtNypEwxLAzmnA0anj98mmiZ3uoAzTVxEyHATKkHMcY GLCIdfIl0o4VTwLE4LdNE/VEzeBsOsQlkVvz6V7sAT1FMX88DdXIrlwVVaBxtyjWHc/B+P2LTmF McZlVA3GqHZfxSPiKC1doEF+ZxXranHjyHoKg22I8XvCUyX54R0+cYSqWht6pZjYJApB//jqoaB jI3LzcZtf8el24tacvEenpFP3TiC6ulQjrrOmM4iffsKQAOl04E20IQisoKeYZCathPbxndqRGL cIEfs8dn8yakFm4uVLVW8311UuR7oFE2HqOVSrgxmV0pzqPygOG6fxzhU4JyMdQDmSnxcwx6ajh 8GttYENeOIV+2ACr7jnRgtSF/ihQsV0ijOTjbgmVNaQCZjvXp1697hQ4o3/kUQoEvpAk618fEwt sS+CCF/vJc6KZSkpC8klZaq6Q221HDVknUwbTOGHBXARpCqsHtI0KQ5ly9BRaCUcR4wd1VzqxzL TaaL6PoUCmxCxUR X-Google-Smtp-Source: AGHT+IEl0rijUjBj5KTVPuwgJ52eLtySyACZ+02OvsE0VUgnXG69c8DNIvntukmMZa1vwSgobwIWIg== X-Received: by 2002:a05:600c:8b22:b0:475:dd89:abc with SMTP id 5b1f17b1804b1-4778fe583f0mr22856285e9.11.1763117532866; Fri, 14 Nov 2025 02:52:12 -0800 (PST) Received: from localhost.localdomain (host86-162-200-138.range86-162.btcentralplus.com. [86.162.200.138]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42b53f17cbfsm9031255f8f.35.2025.11.14.02.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Nov 2025 02:52:12 -0800 (PST) From: Biju X-Google-Original-From: Biju To: Greg Kroah-Hartman , Jiri Slaby , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm Cc: Biju Das , Wolfram Sang , Lad Prabhakar , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Biju Das Subject: [PATCH v3 13/13] serial: sh-sci: Add support for RZ/G3E RSCI SCI Date: Fri, 14 Nov 2025 10:51:22 +0000 Message-ID: <20251114105201.107406-14-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251114105201.107406-1-biju.das.jz@bp.renesas.com> References: <20251114105201.107406-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Biju Das Add support for RZ/G3E RSCI SCI(a.k.a non FIFO mode). Signed-off-by: Biju Das --- v2->v3: * No change. v1->v2: * No change. --- drivers/tty/serial/rsci.c | 138 +++++++++++++++++++++++++----------- drivers/tty/serial/rsci.h | 1 + drivers/tty/serial/sh-sci.c | 4 ++ 3 files changed, 103 insertions(+), 40 deletions(-) diff --git a/drivers/tty/serial/rsci.c b/drivers/tty/serial/rsci.c index 43b2e5588d4d..39960e7c60ac 100644 --- a/drivers/tty/serial/rsci.c +++ b/drivers/tty/serial/rsci.c @@ -161,8 +161,11 @@ static void rsci_serial_out(struct uart_port *p, int o= ffset, int value) =20 static void rsci_clear_DRxC(struct uart_port *port) { + struct sci_port *s =3D to_sci_port(port); + rsci_serial_out(port, CFCLR, CFCLR_RDRFC); - rsci_serial_out(port, FFCLR, FFCLR_DRC); + if (s->type !=3D RSCI_PORT_SCI) + rsci_serial_out(port, FFCLR, FFCLR_DRC); } =20 static void rsci_clear_SCxSR(struct uart_port *port, unsigned int mask) @@ -229,7 +232,6 @@ static void rsci_set_termios(struct uart_port *port, st= ruct ktermios *termios, unsigned long max_freq =3D 0; unsigned int baud, i; unsigned long flags; - unsigned int ctrl; int best_clk =3D -1; =20 if ((termios->c_cflag & CSIZE) =3D=3D CS7) { @@ -294,7 +296,11 @@ static void rsci_set_termios(struct uart_port *port, s= truct ktermios *termios, =20 rsci_serial_out(port, CCR0, ccr0_val); =20 - ccr3_val |=3D CCR3_FM; + if (s->type =3D=3D RSCI_PORT_SCI) + ccr3_val |=3D CCR3_RXDESEL; + else + ccr3_val |=3D CCR3_FM; + rsci_serial_out(port, CCR3, ccr3_val); =20 ccr2_val |=3D (cks << 20) | (brr << 8); @@ -303,12 +309,16 @@ static void rsci_set_termios(struct uart_port *port, = struct ktermios *termios, rsci_serial_out(port, CCR1, ccr1_val); rsci_serial_out(port, CCR4, ccr4_val); =20 - ctrl =3D rsci_serial_in(port, FCR); - ctrl |=3D (FCR_RFRST | FCR_TFRST); - rsci_serial_out(port, FCR, ctrl); + if (s->type !=3D RSCI_PORT_SCI) { + unsigned int ctrl; =20 - if (s->rx_trigger > 1) - rsci_scif_set_rtrg(port, s->rx_trigger); + ctrl =3D rsci_serial_in(port, FCR); + ctrl |=3D (FCR_RFRST | FCR_TFRST); + rsci_serial_out(port, FCR, ctrl); + + if (s->rx_trigger > 1) + rsci_scif_set_rtrg(port, s->rx_trigger); + } =20 port->status &=3D ~UPSTAT_AUTOCTS; s->autorts =3D false; @@ -320,7 +330,8 @@ static void rsci_set_termios(struct uart_port *port, st= ruct ktermios *termios, =20 rsci_init_pins(port, termios->c_cflag); rsci_serial_out(port, CFCLR, CFCLR_CLRFLAG); - rsci_serial_out(port, FFCLR, FFCLR_DRC); + if (s->type !=3D RSCI_PORT_SCI) + rsci_serial_out(port, FFCLR, FFCLR_DRC); =20 ccr0_val |=3D CCR0_RE; rsci_serial_out(port, CCR0, ccr0_val); @@ -337,12 +348,23 @@ static void rsci_set_termios(struct uart_port *port, = struct ktermios *termios, =20 static int rsci_txfill(struct uart_port *port) { - return rsci_serial_in(port, FTSR); + struct sci_port *s =3D to_sci_port(port); + + if (s->type =3D=3D RSCI_PORT_SCI) + return !(rsci_serial_in(port, CSR) & CSR_TDRE); + else + return rsci_serial_in(port, FTSR); } =20 static int rsci_rxfill(struct uart_port *port) { - u32 val =3D rsci_serial_in(port, FRSR); + struct sci_port *s =3D to_sci_port(port); + u32 val; + + if (s->type =3D=3D RSCI_PORT_SCI) + return (rsci_serial_in(port, CSR) & CSR_RDRF) !=3D 0; + + val =3D rsci_serial_in(port, FRSR); =20 return FIELD_GET(FRSR_R5_0, val); } @@ -357,7 +379,9 @@ static unsigned int rsci_tx_empty(struct uart_port *por= t) =20 static void rsci_set_mctrl(struct uart_port *port, unsigned int mctrl) { - if (mctrl & TIOCM_LOOP) { + struct sci_port *s =3D to_sci_port(port); + + if ((mctrl & TIOCM_LOOP) && s->type !=3D RSCI_PORT_SCI) { /* Standard loopback mode */ rsci_serial_out(port, CCR1, rsci_serial_in(port, CCR1) | CCR1_SPLP); } @@ -478,12 +502,13 @@ static void rsci_transmit_chars(struct uart_port *por= t) static void rsci_receive_chars(struct uart_port *port) { struct tty_port *tport =3D &port->state->port; + struct sci_port *s =3D to_sci_port(port); u32 rdat, status, frsr_status =3D 0; int i, count, copied =3D 0; unsigned char flag; =20 status =3D rsci_serial_in(port, CSR); - frsr_status =3D rsci_serial_in(port, FRSR); + frsr_status =3D (s->type =3D=3D RSCI_PORT_SCI) ? 0 : rsci_serial_in(port,= FRSR); =20 if (!(status & CSR_RDRF) && !(frsr_status & FRSR_DR)) return; @@ -496,34 +521,40 @@ static void rsci_receive_chars(struct uart_port *port) if (count =3D=3D 0) break; =20 - for (i =3D 0; i < count; i++) { - char c; - - rdat =3D rsci_serial_in(port, RDR); - /* 9-bits data is not supported yet */ - c =3D rdat & RDR_RDAT_MSK; - - if (uart_handle_sysrq_char(port, c)) { - count--; - i--; - continue; - } - - /* - * Store data and status. - * Non FIFO mode is not supported - */ - if (rdat & RDR_FFER) { - flag =3D TTY_FRAME; - port->icount.frame++; - } else if (rdat & RDR_FPER) { - flag =3D TTY_PARITY; - port->icount.parity++; - } else { - flag =3D TTY_NORMAL; + if (s->type =3D=3D RSCI_PORT_SCI) { + char c =3D rsci_serial_in(port, RDR) & RDR_RDAT_MSK; + + if (uart_handle_sysrq_char(port, c)) + count =3D 0; + else + tty_insert_flip_char(tport, c, TTY_NORMAL); + } else { + for (i =3D 0; i < count; i++) { + char c; + + rdat =3D rsci_serial_in(port, RDR); + /* 9-bits data is not supported yet */ + c =3D rdat & RDR_RDAT_MSK; + + if (uart_handle_sysrq_char(port, c)) { + count--; + i--; + continue; + } + + /* Store data and status */ + if (rdat & RDR_FFER) { + flag =3D TTY_FRAME; + port->icount.frame++; + } else if (rdat & RDR_FPER) { + flag =3D TTY_PARITY; + port->icount.parity++; + } else { + flag =3D TTY_NORMAL; + } + + tty_insert_flip_char(tport, c, flag); } - - tty_insert_flip_char(tport, c, flag); } =20 rsci_serial_in(port, CSR); /* dummy read */ @@ -607,6 +638,8 @@ static const char *rsci_type(struct uart_port *port) struct sci_port *s =3D to_sci_port(port); =20 switch (s->type) { + case RSCI_PORT_SCI: + return "sci"; case RSCI_PORT_SCIF: return "scif"; } @@ -649,6 +682,17 @@ static const struct sci_port_params rsci_port_params = =3D { .common_regs =3D &rsci_common_regs, }; =20 +static const struct sci_port_params rsci_rzg3e_sci_port_params =3D { + .fifosize =3D 1, + .overrun_reg =3D CSR, + .overrun_mask =3D CSR_ORER, + .sampling_rate_mask =3D SCI_SR(32), + .error_mask =3D RSCI_DEFAULT_ERROR_MASK, + .error_clear =3D RSCI_ERROR_CLEAR, + .param_bits =3D &rsci_port_param_bits, + .common_regs =3D &rsci_common_regs, +}; + static const struct sci_port_params rsci_rzg3e_scif_port_params =3D { .fifosize =3D 32, .overrun_reg =3D CSR, @@ -700,6 +744,13 @@ struct sci_of_data of_sci_rsci_data =3D { .params =3D &rsci_port_params, }; =20 +struct sci_of_data of_rsci_sci_data =3D { + .type =3D RSCI_PORT_SCI, + .ops =3D &rsci_port_ops, + .uart_ops =3D &rsci_uart_ops, + .params =3D &rsci_rzg3e_sci_port_params, +}; + struct sci_of_data of_rsci_scif_data =3D { .type =3D RSCI_PORT_SCIF, .ops =3D &rsci_port_ops, @@ -715,12 +766,19 @@ static int __init rsci_early_console_setup(struct ear= lycon_device *device, return scix_early_console_setup(device, &of_sci_rsci_data); } =20 +static int __init rsci_rzg3e_sci_early_console_setup(struct earlycon_devic= e *device, + const char *opt) +{ + return scix_early_console_setup(device, &of_rsci_sci_data); +} + static int __init rsci_rzg3e_scif_early_console_setup(struct earlycon_devi= ce *device, const char *opt) { return scix_early_console_setup(device, &of_rsci_scif_data); } =20 +OF_EARLYCON_DECLARE(rsci, "renesas,r9a09g047-rsci", rsci_rzg3e_sci_early_c= onsole_setup); OF_EARLYCON_DECLARE(rsci, "renesas,r9a09g047-rscif", rsci_rzg3e_scif_early= _console_setup); OF_EARLYCON_DECLARE(rsci, "renesas,r9a09g077-rsci", rsci_early_console_set= up); =20 diff --git a/drivers/tty/serial/rsci.h b/drivers/tty/serial/rsci.h index ba255f58c088..df7a7edad7d4 100644 --- a/drivers/tty/serial/rsci.h +++ b/drivers/tty/serial/rsci.h @@ -6,6 +6,7 @@ #include "sh-sci-common.h" =20 extern struct sci_of_data of_sci_rsci_data; +extern struct sci_of_data of_rsci_sci_data; extern struct sci_of_data of_rsci_scif_data; =20 #endif /* __RSCI_H__ */ diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 7c3d25a6138c..82e472957913 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -3674,6 +3674,10 @@ static const struct of_device_id of_sci_match[] __ma= ybe_unused =3D { .data =3D &of_sci_scif_rzv2h, }, #ifdef CONFIG_SERIAL_RSCI + { + .compatible =3D "renesas,r9a09g047-rsci", + .data =3D &of_rsci_sci_data, + }, { .compatible =3D "renesas,r9a09g047-rscif", .data =3D &of_rsci_scif_data, --=20 2.43.0