* [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver
@ 2025-03-19 10:16 Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 01/12] dt-bindings: serial: renesas,scif: Move ref for serial.yaml at the end Tommaso Merciai
` (13 more replies)
0 siblings, 14 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:16 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
Dear All,
This series add support for RZ/G3E SCIF interface to linux-6.1.y-cip kernel.
SCIF interface in Renesas RZ/G3E is similar to the one available in RZ/G2L.
This series add also some fixes found during SoC bring up stage.
All patches are cherry-picked from mainline kernel.
base commit: 8da62141b20b (tag: v6.1.129-cip38, linux-cip/linux-6.1.y-cip)
Thanks & Regards,
Tommaso
Biju Das (1):
dt-bindings: serial: renesas: Document RZ/G3E (r9a09g047) scif
Claudiu Beznea (4):
serial: sh-sci: Check if TX data was written to device in .tx_empty()
serial: sh-sci: Move runtime PM enable to sci_probe_single()
serial: sh-sci: Clean sci_ports[0] after at earlycon exit
serial: sh-sci: Increment the runtime usage counter for the earlycon
device
Geert Uytterhoeven (1):
serial: sh-sci: Use plain struct copy in early_console_setup()
Lad Prabhakar (5):
dt-bindings: serial: renesas,scif: Move ref for serial.yaml at the end
dt-bindings: serial: renesas,scif: Validate 'interrupts' and
'interrupt-names'
dt-bindings: serial: renesas,scif: Make 'interrupt-names' property as
required
dt-bindings: serial: Add documentation for Renesas RZ/V2H(P)
(R9A09G057) SCIF support
serial: sh-sci: Add support for RZ/V2H(P) SoC
Wolfram Sang (1):
serial: sh-sci: describe locking requirements for invalidating RXDMA
.../bindings/serial/renesas,scif.yaml | 141 +++++++++++----
drivers/tty/serial/sh-sci.c | 160 +++++++++++++++---
include/linux/serial_sci.h | 1 +
3 files changed, 242 insertions(+), 60 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip v2 01/12] dt-bindings: serial: renesas,scif: Move ref for serial.yaml at the end
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
@ 2025-03-19 10:16 ` Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 02/12] dt-bindings: serial: renesas,scif: Validate 'interrupts' and 'interrupt-names' Tommaso Merciai
` (12 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:16 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
commit 220fb8ff6d326d91fed8a0a44e3ac0a2f34d3f9c upstream.
In preparation for adding more validation checks move the ref for
'serial.yaml' to the end and also move reset check in 'allOf' block.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240604170513.522631-2-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
Changes Since v1:
- Added missing Signed-off-by
.../bindings/serial/renesas,scif.yaml | 30 +++++++++----------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/Documentation/devicetree/bindings/serial/renesas,scif.yaml b/Documentation/devicetree/bindings/serial/renesas,scif.yaml
index 1b5b6ce6de0d..77587b0c8642 100644
--- a/Documentation/devicetree/bindings/serial/renesas,scif.yaml
+++ b/Documentation/devicetree/bindings/serial/renesas,scif.yaml
@@ -9,9 +9,6 @@ title: Renesas Serial Communication Interface with FIFO (SCIF)
maintainers:
- Geert Uytterhoeven <geert+renesas@glider.be>
-allOf:
- - $ref: serial.yaml#
-
properties:
compatible:
oneOf:
@@ -159,18 +156,21 @@ required:
- clock-names
- power-domains
-if:
- properties:
- compatible:
- contains:
- enum:
- - renesas,rcar-gen2-scif
- - renesas,rcar-gen3-scif
- - renesas,rcar-gen4-scif
- - renesas,scif-r9a07g044
-then:
- required:
- - resets
+allOf:
+ - $ref: serial.yaml#
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - renesas,rcar-gen2-scif
+ - renesas,rcar-gen3-scif
+ - renesas,rcar-gen4-scif
+ - renesas,scif-r9a07g044
+ then:
+ required:
+ - resets
unevaluatedProperties: false
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip v2 02/12] dt-bindings: serial: renesas,scif: Validate 'interrupts' and 'interrupt-names'
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 01/12] dt-bindings: serial: renesas,scif: Move ref for serial.yaml at the end Tommaso Merciai
@ 2025-03-19 10:16 ` Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 03/12] dt-bindings: serial: renesas,scif: Make 'interrupt-names' property as required Tommaso Merciai
` (11 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:16 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
commit d057a1e3e475c6d9e24ce2e79c3f3daf367e33d8 upstream.
This commit adds support to validate the 'interrupts' and 'interrupt-names'
properties for every supported SoC. This ensures proper handling and
configuration of interrupt-related properties across supported platforms.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20240604170513.522631-3-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
Changes Since v1:
- Added missing Signed-off-by
.../bindings/serial/renesas,scif.yaml | 73 ++++++++++++++-----
1 file changed, 55 insertions(+), 18 deletions(-)
diff --git a/Documentation/devicetree/bindings/serial/renesas,scif.yaml b/Documentation/devicetree/bindings/serial/renesas,scif.yaml
index 77587b0c8642..20132a3202fd 100644
--- a/Documentation/devicetree/bindings/serial/renesas,scif.yaml
+++ b/Documentation/devicetree/bindings/serial/renesas,scif.yaml
@@ -85,11 +85,6 @@ properties:
oneOf:
- items:
- description: A combined interrupt
- - items:
- - description: Error interrupt
- - description: Receive buffer full interrupt
- - description: Transmit buffer empty interrupt
- - description: Break interrupt
- items:
- description: Error interrupt
- description: Receive buffer full interrupt
@@ -97,21 +92,17 @@ properties:
- description: Break interrupt
- description: Data Ready interrupt
- description: Transmit End interrupt
+ minItems: 4
interrupt-names:
- oneOf:
- - items:
- - const: eri
- - const: rxi
- - const: txi
- - const: bri
- - items:
- - const: eri
- - const: rxi
- - const: txi
- - const: bri
- - const: dri
- - const: tei
+ minItems: 4
+ items:
+ - const: eri
+ - const: rxi
+ - const: txi
+ - const: bri
+ - const: dri
+ - const: tei
clocks:
minItems: 1
@@ -172,6 +163,52 @@ allOf:
required:
- resets
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - renesas,rcar-gen1-scif
+ - renesas,rcar-gen2-scif
+ - renesas,rcar-gen3-scif
+ - renesas,rcar-gen4-scif
+ then:
+ properties:
+ interrupts:
+ maxItems: 1
+
+ interrupt-names: false
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - renesas,scif-r7s72100
+ then:
+ properties:
+ interrupts:
+ minItems: 4
+ maxItems: 4
+
+ interrupt-names:
+ maxItems: 4
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - renesas,scif-r7s9210
+ - renesas,scif-r9a07g044
+ then:
+ properties:
+ interrupts:
+ minItems: 6
+
+ interrupt-names:
+ minItems: 6
+
unevaluatedProperties: false
examples:
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip v2 03/12] dt-bindings: serial: renesas,scif: Make 'interrupt-names' property as required
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 01/12] dt-bindings: serial: renesas,scif: Move ref for serial.yaml at the end Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 02/12] dt-bindings: serial: renesas,scif: Validate 'interrupts' and 'interrupt-names' Tommaso Merciai
@ 2025-03-19 10:16 ` Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 04/12] dt-bindings: serial: Add documentation for Renesas RZ/V2H(P) (R9A09G057) SCIF support Tommaso Merciai
` (10 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:16 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
commit 034e4422ddb5ec9075d550f4668be0a3e85e6a3e upstream.
As all the SoCs having multiple interrupts have 'interrupt-names' property
in their respective DTSIs, make 'interrupt-names' property as required
so that we can validate them using dtbs_check.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20240604170513.522631-4-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
Changes Since v1:
- Added missing Signed-off-by
Documentation/devicetree/bindings/serial/renesas,scif.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/serial/renesas,scif.yaml b/Documentation/devicetree/bindings/serial/renesas,scif.yaml
index 20132a3202fd..252c1e6102a9 100644
--- a/Documentation/devicetree/bindings/serial/renesas,scif.yaml
+++ b/Documentation/devicetree/bindings/serial/renesas,scif.yaml
@@ -178,6 +178,9 @@ allOf:
maxItems: 1
interrupt-names: false
+ else:
+ required:
+ - interrupt-names
- if:
properties:
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip v2 04/12] dt-bindings: serial: Add documentation for Renesas RZ/V2H(P) (R9A09G057) SCIF support
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
` (2 preceding siblings ...)
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 03/12] dt-bindings: serial: renesas,scif: Make 'interrupt-names' property as required Tommaso Merciai
@ 2025-03-19 10:16 ` Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 05/12] dt-bindings: serial: renesas: Document RZ/G3E (r9a09g047) scif Tommaso Merciai
` (9 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:16 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
commit 964a80cfbf56f5fa88f09d704c311ed6db0a361f upstream.
Document support for the Serial Communication Interface with FIFO (SCIF)
available in the Renesas RZ/V2H(P) (R9A09G057) SoC. 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 in the driver, a new SoC-specific compatible
string is added, ensuring proper handling of the unique features and
register configurations of the RZ/V2H(P) SoC.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20240604170513.522631-5-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
Changes Since v1:
- Added missing Signed-off-by
.../bindings/serial/renesas,scif.yaml | 30 +++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/Documentation/devicetree/bindings/serial/renesas,scif.yaml b/Documentation/devicetree/bindings/serial/renesas,scif.yaml
index 252c1e6102a9..7b997adec92f 100644
--- a/Documentation/devicetree/bindings/serial/renesas,scif.yaml
+++ b/Documentation/devicetree/bindings/serial/renesas,scif.yaml
@@ -78,6 +78,8 @@ properties:
- renesas,scif-r9a08g045 # RZ/G3S
- const: renesas,scif-r9a07g044 # RZ/G2{L,LC} fallback
+ - const: renesas,scif-r9a09g057 # RZ/V2H(P)
+
reg:
maxItems: 1
@@ -92,6 +94,9 @@ properties:
- description: Break interrupt
- description: Data Ready interrupt
- description: Transmit End interrupt
+ - description: Transmit End/Data Ready interrupt
+ - description: Receive buffer full interrupt (EDGE trigger)
+ - description: Transmit buffer empty interrupt (EDGE trigger)
minItems: 4
interrupt-names:
@@ -103,6 +108,9 @@ properties:
- const: bri
- const: dri
- const: tei
+ - const: tei-dri
+ - const: rxi-edge
+ - const: txi-edge
clocks:
minItems: 1
@@ -159,6 +167,7 @@ allOf:
- renesas,rcar-gen3-scif
- renesas,rcar-gen4-scif
- renesas,scif-r9a07g044
+ - renesas,scif-r9a09g057
then:
required:
- resets
@@ -208,9 +217,30 @@ allOf:
properties:
interrupts:
minItems: 6
+ maxItems: 6
interrupt-names:
minItems: 6
+ maxItems: 6
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: renesas,scif-r9a09g057
+ then:
+ properties:
+ clocks:
+ maxItems: 1
+
+ clock-names:
+ maxItems: 1
+
+ interrupts:
+ minItems: 9
+
+ interrupt-names:
+ minItems: 9
unevaluatedProperties: false
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip v2 05/12] dt-bindings: serial: renesas: Document RZ/G3E (r9a09g047) scif
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
` (3 preceding siblings ...)
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 04/12] dt-bindings: serial: Add documentation for Renesas RZ/V2H(P) (R9A09G057) SCIF support Tommaso Merciai
@ 2025-03-19 10:16 ` Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 06/12] serial: sh-sci: describe locking requirements for invalidating RXDMA Tommaso Merciai
` (8 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:16 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Biju Das <biju.das.jz@bp.renesas.com>
commit d828c6726fe5642d1c71e9edbc4799c959b471cf upstream.
Document scif bindings for the Renesas RZ/G3E (a.k.a r9a09g047) SoC.
SCIF interface in Renesas RZ/G3E is similar to the one available in
RZ/V2H.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20241122124558.149827-2-biju.das.jz@bp.renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
Changes Since v1:
- Added missing Signed-off-by
Documentation/devicetree/bindings/serial/renesas,scif.yaml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/serial/renesas,scif.yaml b/Documentation/devicetree/bindings/serial/renesas,scif.yaml
index 7b997adec92f..8fb7fcc99720 100644
--- a/Documentation/devicetree/bindings/serial/renesas,scif.yaml
+++ b/Documentation/devicetree/bindings/serial/renesas,scif.yaml
@@ -80,6 +80,11 @@ properties:
- const: renesas,scif-r9a09g057 # RZ/V2H(P)
+ - items:
+ - enum:
+ - renesas,scif-r9a09g047 # RZ/G3E
+ - const: renesas,scif-r9a09g057 # RZ/V2H fallback
+
reg:
maxItems: 1
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip v2 06/12] serial: sh-sci: describe locking requirements for invalidating RXDMA
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
` (4 preceding siblings ...)
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 05/12] dt-bindings: serial: renesas: Document RZ/G3E (r9a09g047) scif Tommaso Merciai
@ 2025-03-19 10:16 ` Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 07/12] serial: sh-sci: Add support for RZ/V2H(P) SoC Tommaso Merciai
` (7 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:16 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
commit 8efc440549087de41abadf62f4bde1d827135338 upstream.
Make sure everyone knows that calling this function needs protection.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20240506114016.30498-8-wsa+renesas@sang-engineering.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
Changes Since v1:
- Added missing Signed-off-by
drivers/tty/serial/sh-sci.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 69f8ac561513..7c93c9a1079b 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1264,6 +1264,7 @@ static int sci_dma_rx_find_active(struct sci_port *s)
return -1;
}
+/* Must only be called with uart_port_lock taken */
static void sci_dma_rx_chan_invalidate(struct sci_port *s)
{
unsigned int i;
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip v2 07/12] serial: sh-sci: Add support for RZ/V2H(P) SoC
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
` (5 preceding siblings ...)
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 06/12] serial: sh-sci: describe locking requirements for invalidating RXDMA Tommaso Merciai
@ 2025-03-19 10:16 ` Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 08/12] serial: sh-sci: Use plain struct copy in early_console_setup() Tommaso Merciai
` (6 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:16 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
commit 2f50304e9efb69604040feadc13f9590be8cd391 upstream.
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 <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20240604170513.522631-6-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
Changes Since v1:
- Added missing Signed-off-by
drivers/tty/serial/sh-sci.c | 61 ++++++++++++++++++++++++++++++++-----
include/linux/serial_sci.h | 1 +
2 files changed, 54 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 7c93c9a1079b..ff69124e5336 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -319,6 +319,37 @@ static const struct sci_port_params sci_port_params[SCIx_NR_REGTYPES] = {
.error_clear = SCIF_ERROR_CLEAR,
},
+ /*
+ * The "SCIF" that is in RZ/V2H(P) SoC is similar to one found on RZ/G2L SoC
+ * with below differences,
+ * - Break out of interrupts are different: ERI, BRI, RXI, TXI, TEI, DRI,
+ * TEI-DRI, RXI-EDGE and TXI-EDGE.
+ * - SCSMR register does not have CM bit (BIT(7)) ie it does not support synchronous mode.
+ * - SCFCR register does not have SCFCR_MCE bit.
+ * - SCSPTR register has only bits SCSPTR_SPB2DT and SCSPTR_SPB2IO.
+ */
+ [SCIx_RZV2H_SCIF_REGTYPE] = {
+ .regs = {
+ [SCSMR] = { 0x00, 16 },
+ [SCBRR] = { 0x02, 8 },
+ [SCSCR] = { 0x04, 16 },
+ [SCxTDR] = { 0x06, 8 },
+ [SCxSR] = { 0x08, 16 },
+ [SCxRDR] = { 0x0a, 8 },
+ [SCFCR] = { 0x0c, 16 },
+ [SCFDR] = { 0x0e, 16 },
+ [SCSPTR] = { 0x10, 16 },
+ [SCLSR] = { 0x12, 16 },
+ [SEMR] = { 0x14, 8 },
+ },
+ .fifosize = 16,
+ .overrun_reg = SCLSR,
+ .overrun_mask = SCLSR_ORER,
+ .sampling_rate_mask = SCI_SR(32),
+ .error_mask = SCIF_DEFAULT_ERROR_MASK,
+ .error_clear = SCIF_ERROR_CLEAR,
+ },
+
/*
* Common SH-3 SCIF definitions.
*/
@@ -758,10 +789,10 @@ static void sci_init_pins(struct uart_port *port, unsigned int cflag)
/* Enable CTS# pin function */
ctrl &= ~SCPCR_CTSC;
}
- serial_port_out(port, SCPDR, data);
- serial_port_out(port, SCPCR, ctrl);
- } else if (sci_getreg(port, SCSPTR)->size) {
- u16 status = serial_port_in(port, SCSPTR);
+ sci_serial_out(port, SCPDR, data);
+ sci_serial_out(port, SCPCR, ctrl);
+ } else if (sci_getreg(port, SCSPTR)->size && s->cfg->regtype != SCIx_RZV2H_SCIF_REGTYPE) {
+ u16 status = sci_serial_in(port, SCSPTR);
/* RTS# is always output; and active low, unless autorts */
status |= SCSPTR_RTSIO;
@@ -2132,8 +2163,9 @@ static void sci_set_mctrl(struct uart_port *port, unsigned int mctrl)
if (!(mctrl & TIOCM_RTS)) {
/* Disable Auto RTS */
- serial_port_out(port, SCFCR,
- serial_port_in(port, SCFCR) & ~SCFCR_MCE);
+ if (s->cfg->regtype != SCIx_RZV2H_SCIF_REGTYPE)
+ sci_serial_out(port, SCFCR,
+ sci_serial_in(port, SCFCR) & ~SCFCR_MCE);
/* Clear RTS */
sci_set_rts(port, 0);
@@ -2145,8 +2177,9 @@ static void sci_set_mctrl(struct uart_port *port, unsigned int mctrl)
}
/* Enable Auto RTS */
- serial_port_out(port, SCFCR,
- serial_port_in(port, SCFCR) | SCFCR_MCE);
+ if (s->cfg->regtype != SCIx_RZV2H_SCIF_REGTYPE)
+ sci_serial_out(port, SCFCR,
+ sci_serial_in(port, SCFCR) | SCFCR_MCE);
} else {
/* Set RTS */
sci_set_rts(port, 1);
@@ -3226,6 +3259,10 @@ static const struct of_device_id of_sci_match[] = {
.compatible = "renesas,scif-r9a07g044",
.data = SCI_OF_DATA(PORT_SCIF, SCIx_RZ_SCIFA_REGTYPE),
},
+ {
+ .compatible = "renesas,scif-r9a09g057",
+ .data = SCI_OF_DATA(PORT_SCIF, SCIx_RZV2H_SCIF_REGTYPE),
+ },
/* Family-specific types */
{
.compatible = "renesas,rcar-gen1-scif",
@@ -3558,6 +3595,13 @@ static int __init rzscifa_early_console_setup(struct earlycon_device *device,
return early_console_setup(device, PORT_SCIF);
}
+static int __init rzv2hscif_early_console_setup(struct earlycon_device *device,
+ const char *opt)
+{
+ port_cfg.regtype = SCIx_RZV2H_SCIF_REGTYPE;
+ return early_console_setup(device, PORT_SCIF);
+}
+
static int __init scifa_early_console_setup(struct earlycon_device *device,
const char *opt)
{
@@ -3578,6 +3622,7 @@ OF_EARLYCON_DECLARE(sci, "renesas,sci", sci_early_console_setup);
OF_EARLYCON_DECLARE(scif, "renesas,scif", scif_early_console_setup);
OF_EARLYCON_DECLARE(scif, "renesas,scif-r7s9210", rzscifa_early_console_setup);
OF_EARLYCON_DECLARE(scif, "renesas,scif-r9a07g044", rzscifa_early_console_setup);
+OF_EARLYCON_DECLARE(scif, "renesas,scif-r9a09g057", rzv2hscif_early_console_setup);
OF_EARLYCON_DECLARE(scifa, "renesas,scifa", scifa_early_console_setup);
OF_EARLYCON_DECLARE(scifb, "renesas,scifb", scifb_early_console_setup);
OF_EARLYCON_DECLARE(hscif, "renesas,hscif", hscif_early_console_setup);
diff --git a/include/linux/serial_sci.h b/include/linux/serial_sci.h
index 1c89611e0e06..0f2f50b8d28e 100644
--- a/include/linux/serial_sci.h
+++ b/include/linux/serial_sci.h
@@ -37,6 +37,7 @@ enum {
SCIx_SH7705_SCIF_REGTYPE,
SCIx_HSCIF_REGTYPE,
SCIx_RZ_SCIFA_REGTYPE,
+ SCIx_RZV2H_SCIF_REGTYPE,
SCIx_NR_REGTYPES,
};
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip v2 08/12] serial: sh-sci: Use plain struct copy in early_console_setup()
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
` (6 preceding siblings ...)
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 07/12] serial: sh-sci: Add support for RZ/V2H(P) SoC Tommaso Merciai
@ 2025-03-19 10:16 ` Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 09/12] serial: sh-sci: Check if TX data was written to device in .tx_empty() Tommaso Merciai
` (5 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:16 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Geert Uytterhoeven <geert+renesas@glider.be>
commit c1117a2fefbcce30cced3a180585e0adebc0fa89 upstream.
Using memcpy() prevents the compiler from doing any checking on the
types of the passed pointer parameters. Copy the structure using struct
assignment instead, to increase type-safety.
No change in generated code on all relevant architectures
(arm/arm64/riscv/sh).
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://lore.kernel.org/r/e097e5c11afe5bd4c01135779c9a40e707ef6374.1733243287.git.geert+renesas@glider.be
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
Changes Since v1:
- Added missing Signed-off-by
drivers/tty/serial/sh-sci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index ff69124e5336..d1140fec861b 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -3566,7 +3566,7 @@ static int __init early_console_setup(struct earlycon_device *device,
device->port.serial_in = sci_serial_in;
device->port.serial_out = sci_serial_out;
device->port.type = type;
- memcpy(&sci_ports[0].port, &device->port, sizeof(struct uart_port));
+ sci_ports[0].port = device->port;
port_cfg.type = type;
sci_ports[0].cfg = &port_cfg;
sci_ports[0].params = sci_probe_regmap(&port_cfg);
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip v2 09/12] serial: sh-sci: Check if TX data was written to device in .tx_empty()
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
` (7 preceding siblings ...)
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 08/12] serial: sh-sci: Use plain struct copy in early_console_setup() Tommaso Merciai
@ 2025-03-19 10:16 ` Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 10/12] serial: sh-sci: Move runtime PM enable to sci_probe_single() Tommaso Merciai
` (4 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:16 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 7cc0e0a43a91052477c2921f924a37d9c3891f0c upstream.
On the Renesas RZ/G3S, when doing suspend to RAM, the uart_suspend_port()
is called. The uart_suspend_port() calls 3 times the
struct uart_port::ops::tx_empty() before shutting down the port.
According to the documentation, the struct uart_port::ops::tx_empty()
API tests whether the transmitter FIFO and shifter for the port is
empty.
The Renesas RZ/G3S SCIFA IP reports the number of data units stored in the
transmit FIFO through the FDR (FIFO Data Count Register). The data units
in the FIFOs are written in the shift register and transmitted from there.
The TEND bit in the Serial Status Register reports if the data was
transmitted from the shift register.
In the previous code, in the tx_empty() API implemented by the sh-sci
driver, it is considered that the TX is empty if the hardware reports the
TEND bit set and the number of data units in the FIFO is zero.
According to the HW manual, the TEND bit has the following meaning:
0: Transmission is in the waiting state or in progress.
1: Transmission is completed.
It has been noticed that when opening the serial device w/o using it and
then switch to a power saving mode, the tx_empty() call in the
uart_port_suspend() function fails, leading to the "Unable to drain
transmitter" message being printed on the console. This is because the
TEND=0 if nothing has been transmitted and the FIFOs are empty. As the
TEND=0 has double meaning (waiting state, in progress) we can't
determined the scenario described above.
Add a software workaround for this. This sets a variable if any data has
been sent on the serial console (when using PIO) or if the DMA callback has
been called (meaning something has been transmitted). In the tx_empty()
API the status of the DMA transaction is also checked and if it is
completed or in progress the code falls back in checking the hardware
registers instead of relying on the software variable.
Fixes: 73a19e4c0301 ("serial: sh-sci: Add DMA support.")
Cc: stable@vger.kernel.org
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://lore.kernel.org/r/20241125115856.513642-1-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
Changes Since v1:
- Added missing Signed-off-by
drivers/tty/serial/sh-sci.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index d1140fec861b..19fa3f8f4a6d 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -158,6 +158,7 @@ struct sci_port {
bool has_rtscts;
bool autorts;
+ bool tx_occurred;
};
#define SCI_NPORTS CONFIG_SERIAL_SH_SCI_NR_UARTS
@@ -853,6 +854,7 @@ static void sci_transmit_chars(struct uart_port *port)
{
struct circ_buf *xmit = &port->state->xmit;
unsigned int stopped = uart_tx_stopped(port);
+ struct sci_port *s = to_sci_port(port);
unsigned short status;
unsigned short ctrl;
int count;
@@ -889,6 +891,7 @@ static void sci_transmit_chars(struct uart_port *port)
}
serial_port_out(port, SCxTDR, c);
+ s->tx_occurred = true;
port->icount.tx++;
} while (--count > 0);
@@ -1249,6 +1252,7 @@ static void sci_dma_tx_complete(void *arg)
uart_write_wakeup(port);
if (!uart_circ_empty(xmit)) {
+ s->tx_occurred = true;
s->cookie_tx = 0;
schedule_work(&s->work_tx);
} else {
@@ -1738,6 +1742,19 @@ static void sci_flush_buffer(struct uart_port *port)
s->cookie_tx = -EINVAL;
}
}
+
+static void sci_dma_check_tx_occurred(struct sci_port *s)
+{
+ struct dma_tx_state state;
+ enum dma_status status;
+
+ if (!s->chan_tx)
+ return;
+
+ status = dmaengine_tx_status(s->chan_tx, s->cookie_tx, &state);
+ if (status == DMA_COMPLETE || status == DMA_IN_PROGRESS)
+ s->tx_occurred = true;
+}
#else /* !CONFIG_SERIAL_SH_SCI_DMA */
static inline void sci_request_dma(struct uart_port *port)
{
@@ -1747,6 +1764,10 @@ static inline void sci_free_dma(struct uart_port *port)
{
}
+static void sci_dma_check_tx_occurred(struct sci_port *s)
+{
+}
+
#define sci_flush_buffer NULL
#endif /* !CONFIG_SERIAL_SH_SCI_DMA */
@@ -2083,6 +2104,12 @@ static unsigned int sci_tx_empty(struct uart_port *port)
{
unsigned short status = serial_port_in(port, SCxSR);
unsigned short in_tx_fifo = sci_txfill(port);
+ struct sci_port *s = to_sci_port(port);
+
+ sci_dma_check_tx_occurred(s);
+
+ if (!s->tx_occurred)
+ return TIOCSER_TEMT;
return (status & SCxSR_TEND(port)) && !in_tx_fifo ? TIOCSER_TEMT : 0;
}
@@ -2255,6 +2282,7 @@ static int sci_startup(struct uart_port *port)
dev_dbg(port->dev, "%s(%d)\n", __func__, port->line);
+ s->tx_occurred = false;
sci_request_dma(port);
ret = sci_request_irq(s);
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip v2 10/12] serial: sh-sci: Move runtime PM enable to sci_probe_single()
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
` (8 preceding siblings ...)
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 09/12] serial: sh-sci: Check if TX data was written to device in .tx_empty() Tommaso Merciai
@ 2025-03-19 10:16 ` Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 11/12] serial: sh-sci: Clean sci_ports[0] after at earlycon exit Tommaso Merciai
` (3 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:16 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 239f11209e5f282e16f5241b99256e25dd0614b6 upstream.
Relocate the runtime PM enable operation to sci_probe_single(). This change
prepares the codebase for upcoming fixes.
While at it, replace the existing logic with a direct call to
devm_pm_runtime_enable() and remove sci_cleanup_single(). The
devm_pm_runtime_enable() function automatically handles disabling runtime
PM during driver removal.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://lore.kernel.org/r/20250116182249.3828577-3-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
Changes Since v1:
- Added missing Signed-off-by
drivers/tty/serial/sh-sci.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 19fa3f8f4a6d..9aa1db20c700 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -3063,10 +3063,6 @@ static int sci_init_single(struct platform_device *dev,
ret = sci_init_clocks(sci_port, &dev->dev);
if (ret < 0)
return ret;
-
- port->dev = &dev->dev;
-
- pm_runtime_enable(&dev->dev);
}
port->type = p->type;
@@ -3096,11 +3092,6 @@ static int sci_init_single(struct platform_device *dev,
return 0;
}
-static void sci_cleanup_single(struct sci_port *port)
-{
- pm_runtime_disable(port->port.dev);
-}
-
#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) || \
defined(CONFIG_SERIAL_SH_SCI_EARLYCON)
static void serial_console_putchar(struct uart_port *port, unsigned char ch)
@@ -3258,8 +3249,6 @@ static int sci_remove(struct platform_device *dev)
sci_ports_in_use &= ~BIT(port->port.line);
uart_remove_one_port(&sci_uart_driver, &port->port);
- sci_cleanup_single(port);
-
if (port->port.fifosize > 1)
device_remove_file(&dev->dev, &dev_attr_rx_fifo_trigger);
if (type == PORT_SCIFA || type == PORT_SCIFB || type == PORT_HSCIF)
@@ -3425,6 +3414,11 @@ static int sci_probe_single(struct platform_device *dev,
if (ret)
return ret;
+ sciport->port.dev = &dev->dev;
+ ret = devm_pm_runtime_enable(&dev->dev);
+ if (ret)
+ return ret;
+
sciport->gpios = mctrl_gpio_init(&sciport->port, 0);
if (IS_ERR(sciport->gpios))
return PTR_ERR(sciport->gpios);
@@ -3438,13 +3432,7 @@ static int sci_probe_single(struct platform_device *dev,
sciport->port.flags |= UPF_HARD_FLOW;
}
- ret = uart_add_one_port(&sci_uart_driver, &sciport->port);
- if (ret) {
- sci_cleanup_single(sciport);
- return ret;
- }
-
- return 0;
+ return uart_add_one_port(&sci_uart_driver, &sciport->port);
}
static int sci_probe(struct platform_device *dev)
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip v2 11/12] serial: sh-sci: Clean sci_ports[0] after at earlycon exit
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
` (9 preceding siblings ...)
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 10/12] serial: sh-sci: Move runtime PM enable to sci_probe_single() Tommaso Merciai
@ 2025-03-19 10:16 ` Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 12/12] serial: sh-sci: Increment the runtime usage counter for the earlycon device Tommaso Merciai
` (2 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:16 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 5f1017069933489add0c08659673443c9905659e upstream.
The early_console_setup() function initializes sci_ports[0].port with an
object of type struct uart_port obtained from the struct earlycon_device
passed as an argument to early_console_setup().
Later, during serial port probing, the serial port used as earlycon
(e.g., port A) might be remapped to a different position in the sci_ports[]
array, and a different serial port (e.g., port B) might be assigned to slot
0. For example:
sci_ports[0] = port B
sci_ports[X] = port A
In this scenario, the new port mapped at index zero (port B) retains the
data associated with the earlycon configuration. Consequently, after the
Linux boot process, any access to the serial port now mapped to
sci_ports[0] (port B) will block the original earlycon port (port A).
To address this, introduce an early_console_exit() function to clean up
sci_ports[0] when earlycon is exited.
To prevent the cleanup of sci_ports[0] while the serial device is still
being used by earlycon, introduce the struct sci_port::probing flag and
account for it in early_console_exit().
Fixes: 0b0cced19ab1 ("serial: sh-sci: Add CONFIG_SERIAL_EARLYCON support")
Cc: stable@vger.kernel.org
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://lore.kernel.org/r/20250116182249.3828577-5-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
Changes Since v1:
- Added missing Signed-off-by
drivers/tty/serial/sh-sci.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 9aa1db20c700..f8e4062d9b4c 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -167,6 +167,7 @@ static struct sci_port sci_ports[SCI_NPORTS];
static unsigned long sci_ports_in_use;
static struct uart_driver sci_uart_driver;
static bool sci_uart_earlycon;
+static bool sci_uart_earlycon_dev_probing;
static inline struct sci_port *
to_sci_port(struct uart_port *uart)
@@ -3385,7 +3386,8 @@ static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev,
static int sci_probe_single(struct platform_device *dev,
unsigned int index,
struct plat_sci_port *p,
- struct sci_port *sciport)
+ struct sci_port *sciport,
+ struct resource *sci_res)
{
int ret;
@@ -3432,6 +3434,14 @@ static int sci_probe_single(struct platform_device *dev,
sciport->port.flags |= UPF_HARD_FLOW;
}
+ if (sci_uart_earlycon && sci_ports[0].port.mapbase == sci_res->start) {
+ /*
+ * Skip cleanup the sci_port[0] in early_console_exit(), this
+ * port is the same as the earlycon one.
+ */
+ sci_uart_earlycon_dev_probing = true;
+ }
+
return uart_add_one_port(&sci_uart_driver, &sciport->port);
}
@@ -3490,7 +3500,7 @@ static int sci_probe(struct platform_device *dev)
platform_set_drvdata(dev, sp);
- ret = sci_probe_single(dev, dev_id, p, sp);
+ ret = sci_probe_single(dev, dev_id, p, sp, res);
if (ret)
return ret;
@@ -3573,6 +3583,22 @@ sh_early_platform_init_buffer("earlyprintk", &sci_driver,
#ifdef CONFIG_SERIAL_SH_SCI_EARLYCON
static struct plat_sci_port port_cfg;
+static int early_console_exit(struct console *co)
+{
+ struct sci_port *sci_port = &sci_ports[0];
+
+ /*
+ * Clean the slot used by earlycon. A new SCI device might
+ * map to this slot.
+ */
+ if (!sci_uart_earlycon_dev_probing) {
+ memset(sci_port, 0, sizeof(*sci_port));
+ sci_uart_earlycon = false;
+ }
+
+ return 0;
+}
+
static int __init early_console_setup(struct earlycon_device *device,
int type)
{
@@ -3592,6 +3618,8 @@ static int __init early_console_setup(struct earlycon_device *device,
SCSCR_RE | SCSCR_TE | port_cfg.scscr);
device->con->write = serial_console_write;
+ device->con->exit = early_console_exit;
+
return 0;
}
static int __init sci_early_console_setup(struct earlycon_device *device,
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip v2 12/12] serial: sh-sci: Increment the runtime usage counter for the earlycon device
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
` (10 preceding siblings ...)
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 11/12] serial: sh-sci: Clean sci_ports[0] after at earlycon exit Tommaso Merciai
@ 2025-03-19 10:16 ` Tommaso Merciai
2025-03-19 10:25 ` [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Pavel Machek
[not found] ` <182E2D5440856AF6.20726@lists.cip-project.org>
13 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:16 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 651dee03696e1dfde6d9a7e8664bbdcd9a10ea7f upstream.
In the sh-sci driver, serial ports are mapped to the sci_ports[] array,
with earlycon mapped at index zero.
The uart_add_one_port() function eventually calls __device_attach(),
which, in turn, calls pm_request_idle(). The identified code path is as
follows:
uart_add_one_port() ->
serial_ctrl_register_port() ->
serial_core_register_port() ->
serial_core_port_device_add() ->
serial_base_port_add() ->
device_add() ->
bus_probe_device() ->
device_initial_probe() ->
__device_attach() ->
// ...
if (dev->p->dead) {
// ...
} else if (dev->driver) {
// ...
} else {
// ...
pm_request_idle(dev);
// ...
}
The earlycon device clocks are enabled by the bootloader. However, the
pm_request_idle() call in __device_attach() disables the SCI port clocks
while earlycon is still active.
The earlycon write function, serial_console_write(), calls
sci_poll_put_char() via serial_console_putchar(). If the SCI port clocks
are disabled, writing to earlycon may sometimes cause the SR.TDFE bit to
remain unset indefinitely, causing the while loop in sci_poll_put_char()
to never exit. On single-core SoCs, this can result in the system being
blocked during boot when this issue occurs.
To resolve this, increment the runtime PM usage counter for the earlycon
SCI device before registering the UART port.
Fixes: 0b0cced19ab1 ("serial: sh-sci: Add CONFIG_SERIAL_EARLYCON support")
Cc: stable@vger.kernel.org
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://lore.kernel.org/r/20250116182249.3828577-6-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
Changes Since v1:
- Added missing Signed-off-by
drivers/tty/serial/sh-sci.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index f8e4062d9b4c..3f5c319215d2 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -3435,6 +3435,22 @@ static int sci_probe_single(struct platform_device *dev,
}
if (sci_uart_earlycon && sci_ports[0].port.mapbase == sci_res->start) {
+ /*
+ * In case:
+ * - this is the earlycon port (mapped on index 0 in sci_ports[]) and
+ * - it now maps to an alias other than zero and
+ * - the earlycon is still alive (e.g., "earlycon keep_bootcon" is
+ * available in bootargs)
+ *
+ * we need to avoid disabling clocks and PM domains through the runtime
+ * PM APIs called in __device_attach(). For this, increment the runtime
+ * PM reference counter (the clocks and PM domains were already enabled
+ * by the bootloader). Otherwise the earlycon may access the HW when it
+ * has no clocks enabled leading to failures (infinite loop in
+ * sci_poll_put_char()).
+ */
+ pm_runtime_get_noresume(&dev->dev);
+
/*
* Skip cleanup the sci_port[0] in early_console_exit(), this
* port is the same as the earlycon one.
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
` (11 preceding siblings ...)
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 12/12] serial: sh-sci: Increment the runtime usage counter for the earlycon device Tommaso Merciai
@ 2025-03-19 10:25 ` Pavel Machek
[not found] ` <182E2D5440856AF6.20726@lists.cip-project.org>
13 siblings, 0 replies; 21+ messages in thread
From: Pavel Machek @ 2025-03-19 10:25 UTC (permalink / raw)
To: Tommaso Merciai
Cc: cip-dev, Nobuhiro Iwamatsu, Pavel Machek, Biju Das, Lad Prabhakar,
tomm.merciai
[-- Attachment #1: Type: text/plain, Size: 695 bytes --]
Hi!
> This series add support for RZ/G3E SCIF interface to linux-6.1.y-cip kernel.
> SCIF interface in Renesas RZ/G3E is similar to the one available in RZ/G2L.
> This series add also some fixes found during SoC bring up stage.
>
> All patches are cherry-picked from mainline kernel.
Okay, so I just reviewed v1 of this, and was ready to say that I'll
apply it provided there are no other comments and it passes testing.
Now you'll also have to tell me what is the difference between v1 and
v2 :-).
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [cip-dev] [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver
[not found] ` <182E2D5440856AF6.20726@lists.cip-project.org>
@ 2025-03-19 10:28 ` Pavel Machek
2025-03-19 10:32 ` Tommaso Merciai
0 siblings, 1 reply; 21+ messages in thread
From: Pavel Machek @ 2025-03-19 10:28 UTC (permalink / raw)
To: cip-dev
Cc: Tommaso Merciai, Nobuhiro Iwamatsu, Pavel Machek, Biju Das,
Lad Prabhakar, tomm.merciai
[-- Attachment #1: Type: text/plain, Size: 828 bytes --]
Hi!
> > This series add support for RZ/G3E SCIF interface to linux-6.1.y-cip kernel.
> > SCIF interface in Renesas RZ/G3E is similar to the one available in RZ/G2L.
> > This series add also some fixes found during SoC bring up stage.
> >
> > All patches are cherry-picked from mainline kernel.
>
> Okay, so I just reviewed v1 of this, and was ready to say that I'll
> apply it provided there are no other comments and it passes testing.
>
> Now you'll also have to tell me what is the difference between v1 and
> v2 :-).
Aha, missing SoB. I'd expect that information in 0/ of the series, but
you wrote it elsewhere. Still good.
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [cip-dev] [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver
2025-03-19 10:28 ` [cip-dev] " Pavel Machek
@ 2025-03-19 10:32 ` Tommaso Merciai
2025-03-20 10:02 ` Pavel Machek
0 siblings, 1 reply; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-19 10:32 UTC (permalink / raw)
To: Pavel Machek
Cc: cip-dev, Nobuhiro Iwamatsu, Biju Das, Lad Prabhakar, tomm.merciai
Hi Pavel,
Thanks for your comment.
On Wed, Mar 19, 2025 at 11:28:20AM +0100, Pavel Machek wrote:
> Hi!
>
> > > This series add support for RZ/G3E SCIF interface to linux-6.1.y-cip kernel.
> > > SCIF interface in Renesas RZ/G3E is similar to the one available in RZ/G2L.
> > > This series add also some fixes found during SoC bring up stage.
> > >
> > > All patches are cherry-picked from mainline kernel.
> >
> > Okay, so I just reviewed v1 of this, and was ready to say that I'll
> > apply it provided there are no other comments and it passes testing.
> >
> > Now you'll also have to tell me what is the difference between v1 and
> > v2 :-).
>
> Aha, missing SoB. I'd expect that information in 0/ of the series, but
> you wrote it elsewhere. Still good.
Yup sorry, I forgot to update the cover letter :'(
Basically on v1 I missed my SOB.
>
> Best regards,
> Pavel
> --
> DENX Software Engineering GmbH, Managing Director: Erika Unter
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Thanks & Regards,
Tommaso
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [cip-dev] [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver
2025-03-19 10:32 ` Tommaso Merciai
@ 2025-03-20 10:02 ` Pavel Machek
2025-03-20 10:12 ` Tommaso Merciai
2025-03-20 10:26 ` Chris Paterson
0 siblings, 2 replies; 21+ messages in thread
From: Pavel Machek @ 2025-03-20 10:02 UTC (permalink / raw)
To: Tommaso Merciai
Cc: Pavel Machek, cip-dev, Nobuhiro Iwamatsu, Biju Das, Lad Prabhakar,
tomm.merciai
[-- Attachment #1: Type: text/plain, Size: 423 bytes --]
Hi!
> Yup sorry, I forgot to update the cover letter :'(
> Basically on v1 I missed my SOB.
No problem.
For some reason, your patches don't seem to hit the cip-dev mailing
list (?).
It passed the testing so I applied the series.
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [cip-dev] [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver
2025-03-20 10:02 ` Pavel Machek
@ 2025-03-20 10:12 ` Tommaso Merciai
2025-03-20 11:50 ` Pavel Machek
2025-03-20 10:26 ` Chris Paterson
1 sibling, 1 reply; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-20 10:12 UTC (permalink / raw)
To: Pavel Machek
Cc: cip-dev, Nobuhiro Iwamatsu, Biju Das, Lad Prabhakar, tomm.merciai
Hi Pavel,
Thanks for your work.
On Thu, Mar 20, 2025 at 11:02:27AM +0100, Pavel Machek wrote:
> Hi!
>
> > Yup sorry, I forgot to update the cover letter :'(
> > Basically on v1 I missed my SOB.
>
> No problem.
>
> For some reason, your patches don't seem to hit the cip-dev mailing
> list (?).
Thanks for let me know.
Mmmm I'm seeing that on [1].
>
> It passed the testing so I applied the series.
Thanks for this.
I'm going to prepare next series with a minimal support for RZ/G3E then.
>
> Best regards,
> Pavel
> --
> DENX Software Engineering GmbH, Managing Director: Erika Unter
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[1] https://patchwork.kernel.org/project/cip-dev/list/?series=945527
Thanks & Regards,
Tommaso
^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: [cip-dev] [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver
2025-03-20 10:02 ` Pavel Machek
2025-03-20 10:12 ` Tommaso Merciai
@ 2025-03-20 10:26 ` Chris Paterson
1 sibling, 0 replies; 21+ messages in thread
From: Chris Paterson @ 2025-03-20 10:26 UTC (permalink / raw)
To: cip-dev@lists.cip-project.org, Tommaso Merciai
Cc: Pavel Machek, Nobuhiro Iwamatsu, Biju Das, Prabhakar Mahadev Lad,
Tommaso Merciai
Hi Pavel,
> From: cip-dev@lists.cip-project.org <cip-dev@lists.cip-project.org> On
> Behalf Of Pavel Machek via lists.cip-project.org
> Sent: 20 March 2025 10:02
>
> Hi!
>
> > Yup sorry, I forgot to update the cover letter :'(
> > Basically on v1 I missed my SOB.
>
> No problem.
>
> For some reason, your patches don't seem to hit the cip-dev mailing
> list (?).
If it helps, I got the patches emailed via the list and they are in the online archives:
https://lore.kernel.org/cip-dev/
Kind regards, Chris
>
> It passed the testing so I applied the series.
>
> Best regards,
> Pavel
> --
> DENX Software Engineering GmbH, Managing Director: Erika Unter
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [cip-dev] [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver
2025-03-20 10:12 ` Tommaso Merciai
@ 2025-03-20 11:50 ` Pavel Machek
2025-03-20 13:14 ` Tommaso Merciai
0 siblings, 1 reply; 21+ messages in thread
From: Pavel Machek @ 2025-03-20 11:50 UTC (permalink / raw)
To: Tommaso Merciai
Cc: Pavel Machek, cip-dev, Nobuhiro Iwamatsu, Biju Das, Lad Prabhakar,
tomm.merciai
[-- Attachment #1: Type: text/plain, Size: 353 bytes --]
Hi!
> Thanks for this.
> I'm going to prepare next series with a minimal support for RZ/G3E then.
Ok, thanks. Please note we'll need 6.12 version at this point, too.
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [cip-dev] [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver
2025-03-20 11:50 ` Pavel Machek
@ 2025-03-20 13:14 ` Tommaso Merciai
0 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-03-20 13:14 UTC (permalink / raw)
To: Pavel Machek
Cc: cip-dev, Nobuhiro Iwamatsu, Biju Das, Lad Prabhakar, tomm.merciai
Hi Pavel,
On Thu, Mar 20, 2025 at 12:50:02PM +0100, Pavel Machek wrote:
> Hi!
>
> > Thanks for this.
> > I'm going to prepare next series with a minimal support for RZ/G3E then.
>
> Ok, thanks. Please note we'll need 6.12 version at this point, too.
Perfect, thanks for the reminder.
>
> Best regards,
> Pavel
> --
> DENX Software Engineering GmbH, Managing Director: Erika Unter
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Regards,
Tommaso
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2025-03-20 13:14 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19 10:16 [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 01/12] dt-bindings: serial: renesas,scif: Move ref for serial.yaml at the end Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 02/12] dt-bindings: serial: renesas,scif: Validate 'interrupts' and 'interrupt-names' Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 03/12] dt-bindings: serial: renesas,scif: Make 'interrupt-names' property as required Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 04/12] dt-bindings: serial: Add documentation for Renesas RZ/V2H(P) (R9A09G057) SCIF support Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 05/12] dt-bindings: serial: renesas: Document RZ/G3E (r9a09g047) scif Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 06/12] serial: sh-sci: describe locking requirements for invalidating RXDMA Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 07/12] serial: sh-sci: Add support for RZ/V2H(P) SoC Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 08/12] serial: sh-sci: Use plain struct copy in early_console_setup() Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 09/12] serial: sh-sci: Check if TX data was written to device in .tx_empty() Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 10/12] serial: sh-sci: Move runtime PM enable to sci_probe_single() Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 11/12] serial: sh-sci: Clean sci_ports[0] after at earlycon exit Tommaso Merciai
2025-03-19 10:16 ` [PATCH 6.1.y-cip v2 12/12] serial: sh-sci: Increment the runtime usage counter for the earlycon device Tommaso Merciai
2025-03-19 10:25 ` [PATCH 6.1.y-cip v2 00/12] serial: sh-sci: Add support for RZ/G3E serial driver Pavel Machek
[not found] ` <182E2D5440856AF6.20726@lists.cip-project.org>
2025-03-19 10:28 ` [cip-dev] " Pavel Machek
2025-03-19 10:32 ` Tommaso Merciai
2025-03-20 10:02 ` Pavel Machek
2025-03-20 10:12 ` Tommaso Merciai
2025-03-20 11:50 ` Pavel Machek
2025-03-20 13:14 ` Tommaso Merciai
2025-03-20 10:26 ` Chris Paterson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox