[PATCH 12/19] serial: sh-sci: Add support for RZ/G3E RSCI clks

Biju Das posted 19 patches 3 months, 2 weeks ago
There is a newer version of this series
[PATCH 12/19] serial: sh-sci: Add support for RZ/G3E RSCI clks
Posted by Biju Das 3 months, 2 weeks ago
RZ/G3E RSCI has 5 module clocks. Add support for these clocks.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/tty/serial/sh-sci-common.h |  3 +++
 drivers/tty/serial/sh-sci.c        | 14 ++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/drivers/tty/serial/sh-sci-common.h b/drivers/tty/serial/sh-sci-common.h
index ef1d94ae8b5c..f730ff9add60 100644
--- a/drivers/tty/serial/sh-sci-common.h
+++ b/drivers/tty/serial/sh-sci-common.h
@@ -17,6 +17,9 @@ enum SCI_CLKS {
 	SCI_SCK,		/* Optional External Clock */
 	SCI_BRG_INT,		/* Optional BRG Internal Clock Source */
 	SCI_SCIF_CLK,		/* Optional BRG External Clock Source */
+	SCI_FCK_DIV64,		/* Optional Functional Clock frequency-divided by 64 */
+	SCI_FCK_DIV16,		/* Optional Functional Clock frequency-divided by 16 */
+	SCI_FCK_DIV4,		/* Optional Functional Clock frequency-divided by 4 */
 	SCI_NUM_CLKS
 };
 
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 5f5913410df9..d45bdda2b6c1 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -2994,6 +2994,9 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)
 		[SCI_SCK] = "sck",
 		[SCI_BRG_INT] = "brg_int",
 		[SCI_SCIF_CLK] = "scif_clk",
+		[SCI_FCK_DIV64] = "tclk_div64",
+		[SCI_FCK_DIV16] = "tclk_div16",
+		[SCI_FCK_DIV4] = "tclk_div4",
 	};
 	struct clk *clk;
 	unsigned int i;
@@ -3003,6 +3006,9 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)
 	} else if (sci_port->type == SCI_PORT_RSCI) {
 		clk_names[SCI_FCK] = "operation";
 		clk_names[SCI_BRG_INT] = "bus";
+	} else if (sci_port->type == RSCI_PORT_SCI || sci_port->type == RSCI_PORT_SCIF) {
+		clk_names[SCI_FCK] = "tclk";
+		clk_names[SCI_BRG_INT] = "bus";
 	}
 
 	for (i = 0; i < SCI_NUM_CLKS; i++) {
@@ -3018,6 +3024,14 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)
 					     name);
 		}
 
+		if (!clk && (sci_port->type == RSCI_PORT_SCI ||
+			     sci_port->type == RSCI_PORT_SCIF) &&
+		    (i == SCI_FCK || i == SCI_BRG_INT || i == SCI_FCK_DIV64 ||
+		     i == SCI_FCK_DIV16 || i == SCI_FCK_DIV4)) {
+			return dev_err_probe(dev, -ENODEV, "failed to get %s\n",
+					     name);
+		}
+
 		if (!clk && i == SCI_FCK) {
 			/*
 			 * Not all SH platforms declare a clock lookup entry
-- 
2.43.0
Re: [PATCH 12/19] serial: sh-sci: Add support for RZ/G3E RSCI clks
Posted by Hugo Villeneuve 3 months, 2 weeks ago
Hi Biju,

On Mon, 27 Oct 2025 15:45:59 +0000
Biju Das <biju.das.jz@bp.renesas.com> wrote:

> RZ/G3E RSCI has 5 module clocks. Add support for these clocks.

In "[PATCH 03/19] dt-bindings: serial: renesas,rsci: Document RZ/G3E
support", you mention that "...RZ/G3E has 6 clocks...", and here 5?

 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/tty/serial/sh-sci-common.h |  3 +++
>  drivers/tty/serial/sh-sci.c        | 14 ++++++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/drivers/tty/serial/sh-sci-common.h b/drivers/tty/serial/sh-sci-common.h
> index ef1d94ae8b5c..f730ff9add60 100644
> --- a/drivers/tty/serial/sh-sci-common.h
> +++ b/drivers/tty/serial/sh-sci-common.h
> @@ -17,6 +17,9 @@ enum SCI_CLKS {
>  	SCI_SCK,		/* Optional External Clock */
>  	SCI_BRG_INT,		/* Optional BRG Internal Clock Source */
>  	SCI_SCIF_CLK,		/* Optional BRG External Clock Source */
> +	SCI_FCK_DIV64,		/* Optional Functional Clock frequency-divided by 64 */
> +	SCI_FCK_DIV16,		/* Optional Functional Clock frequency-divided by 16 */
> +	SCI_FCK_DIV4,		/* Optional Functional Clock frequency-divided by 4 */

I see 6 clocks here?

>  	SCI_NUM_CLKS
>  };
>  
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 5f5913410df9..d45bdda2b6c1 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -2994,6 +2994,9 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)
>  		[SCI_SCK] = "sck",
>  		[SCI_BRG_INT] = "brg_int",
>  		[SCI_SCIF_CLK] = "scif_clk",
> +		[SCI_FCK_DIV64] = "tclk_div64",
> +		[SCI_FCK_DIV16] = "tclk_div16",
> +		[SCI_FCK_DIV4] = "tclk_div4",
>  	};
>  	struct clk *clk;
>  	unsigned int i;
> @@ -3003,6 +3006,9 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)
>  	} else if (sci_port->type == SCI_PORT_RSCI) {
>  		clk_names[SCI_FCK] = "operation";
>  		clk_names[SCI_BRG_INT] = "bus";
> +	} else if (sci_port->type == RSCI_PORT_SCI || sci_port->type == RSCI_PORT_SCIF) {
> +		clk_names[SCI_FCK] = "tclk";
> +		clk_names[SCI_BRG_INT] = "bus";
>  	}
>  
>  	for (i = 0; i < SCI_NUM_CLKS; i++) {
> @@ -3018,6 +3024,14 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)
>  					     name);
>  		}
>  
> +		if (!clk && (sci_port->type == RSCI_PORT_SCI ||
> +			     sci_port->type == RSCI_PORT_SCIF) &&
> +		    (i == SCI_FCK || i == SCI_BRG_INT || i == SCI_FCK_DIV64 ||
> +		     i == SCI_FCK_DIV16 || i == SCI_FCK_DIV4)) {
> +			return dev_err_probe(dev, -ENODEV, "failed to get %s\n",
> +					     name);
> +		}
> +
>  		if (!clk && i == SCI_FCK) {
>  			/*
>  			 * Not all SH platforms declare a clock lookup entry
> -- 
> 2.43.0
> 
> 

-- 
Hugo Villeneuve