linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: renesas: r9a06g032: Fix UART34567 clock rate
@ 2018-08-31 11:26 Phil Edworthy
  2018-09-10 13:11 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Edworthy @ 2018-08-31 11:26 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Michael Turquette, Stephen Boyd, linux-renesas-soc, linux-clk,
	linux-kernel, Phil Edworthy

The clock for UARTs 0 through 2 is UART012, the clock for UARTs 3 through
7 is UART34567.
For UART012, we stop the clock driver from changing the clock rate. This
is because the Synopsys UART driver simply sets the reference clock to 16x
the baud rate, but doesn't check if the actual rate is within the required
tolerance. The RZ/N1 clock divider can't provide this (we have to rely on
the UART's internal divider to set the correct clock rate), so you end up
with a clock rate that is way off what you wanted.

In addition, since the clock is shared between multiple UARTs, you don't
want the driver trying to change the clock rate as it may affect the other
UARTs (which may not have been configured yet, so you don't know what baud
rate they will use). Normally, the clock rate is set early on before Linux
to some very high rate that supports all of the clock rates you want.

This change stops the UART34567 clock rate from changing for the same
reasons.

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
---
 drivers/clk/renesas/r9a06g032-clocks.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/renesas/r9a06g032-clocks.c b/drivers/clk/renesas/r9a06g032-clocks.c
index a0b6ecd..6d2b568 100644
--- a/drivers/clk/renesas/r9a06g032-clocks.c
+++ b/drivers/clk/renesas/r9a06g032-clocks.c
@@ -539,7 +539,8 @@ r9a06g032_div_round_rate(struct clk_hw *hw,
 	 * several uarts attached to this divider, and changing this impacts
 	 * everyone.
 	 */
-	if (clk->index == R9A06G032_DIV_UART) {
+	if (clk->index == R9A06G032_DIV_UART ||
+	    clk->index == R9A06G032_DIV_P2_PG) {
 		pr_devel("%s div uart hack!\n", __func__);
 		return clk_get_rate(hw->clk);
 	}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] clk: renesas: r9a06g032: Fix UART34567 clock rate
  2018-08-31 11:26 [PATCH] clk: renesas: r9a06g032: Fix UART34567 clock rate Phil Edworthy
@ 2018-09-10 13:11 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2018-09-10 13:11 UTC (permalink / raw)
  To: Phil Edworthy
  Cc: Michael Turquette, Stephen Boyd, Linux-Renesas, linux-clk,
	Linux Kernel Mailing List

Hi Phil,

On Fri, Aug 31, 2018 at 1:26 PM Phil Edworthy <phil.edworthy@renesas.com> wrote:
> The clock for UARTs 0 through 2 is UART012, the clock for UARTs 3 through
> 7 is UART34567.
> For UART012, we stop the clock driver from changing the clock rate. This
> is because the Synopsys UART driver simply sets the reference clock to 16x
> the baud rate, but doesn't check if the actual rate is within the required
> tolerance. The RZ/N1 clock divider can't provide this (we have to rely on
> the UART's internal divider to set the correct clock rate), so you end up
> with a clock rate that is way off what you wanted.
>
> In addition, since the clock is shared between multiple UARTs, you don't
> want the driver trying to change the clock rate as it may affect the other
> UARTs (which may not have been configured yet, so you don't know what baud
> rate they will use). Normally, the clock rate is set early on before Linux
> to some very high rate that supports all of the clock rates you want.
>
> This change stops the UART34567 clock rate from changing for the same
> reasons.
>
> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
i.e. will queue in clk-renesas-for-v4.20.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-10 13:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-31 11:26 [PATCH] clk: renesas: r9a06g032: Fix UART34567 clock rate Phil Edworthy
2018-09-10 13:11 ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).