1
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2024-10-20 14:38:20 +02:00
openwrt/target/linux/bcm27xx/patches-5.10/950-0032-amba_pl011-Round-input-clock-up.patch
Rui Salvaterra 1343acc8cd kernel: bump 5.10 to 5.10.94
Deleted (upstreamed):
bcm27xx/patches-5.10/950-0669-drm-vc4-hdmi-Make-sure-the-device-is-powered-with-CE.patch [1]
bcm27xx/patches-5.10/950-0672-drm-vc4-hdmi-Move-initial-register-read-after-pm_run.patch [1]
gemini/patches-5.10/0003-ARM-dts-gemini-NAS4220-B-fis-index-block-with-128-Ki.patch [2]

Manually rebased:
bcm27xx/patches-5.10/950-0675-drm-vc4-hdmi-Drop-devm-interrupt-handler-for-CEC-int.patch

Manually reverted:
generic/pending-5.10/860-Revert-ASoC-mediatek-Check-for-error-clk-pointer.patch [3]

[1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.10.94&id=55b10b88ac8654fc2f31518aa349a2e643b37f18
[2] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.10.94&id=958a8819d41420d7a74ed922a09cacc0ba3a4218
[3] https://lore.kernel.org/all/trinity-2a727d96-0335-4d03-8f30-e22a0e10112d-1643363480085@3c-app-gmx-bap33/

Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2022-02-01 23:34:07 +00:00

87 lines
2.5 KiB
Diff

From e3f28ae66fd94f4a7a10099a96d6dd5273904943 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.org>
Date: Wed, 1 Mar 2017 16:07:39 +0000
Subject: [PATCH] amba_pl011: Round input clock up
The UART clock is initialised to be as close to the requested
frequency as possible without exceeding it. Now that there is a
clock manager that returns the actual frequencies, an expected
48MHz clock is reported as 47999625. If the requested baudrate
== requested clock/16, there is no headroom and the slight
reduction in actual clock rate results in failure.
Detect cases where it looks like a "round" clock was chosen and
adjust the reported clock to match that "round" value. As the
code comment says:
/*
* If increasing a clock by less than 0.1% changes it
* from ..999.. to ..000.., round up.
*/
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
---
drivers/tty/serial/amba-pl011.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1642,6 +1642,23 @@ static void pl011_put_poll_char(struct u
#endif /* CONFIG_CONSOLE_POLL */
+unsigned long pl011_clk_round(unsigned long clk)
+{
+ unsigned long scaler;
+
+ /*
+ * If increasing a clock by less than 0.1% changes it
+ * from ..999.. to ..000.., round up.
+ */
+ scaler = 1;
+ while (scaler * 100000 < clk)
+ scaler *= 10;
+ if ((clk + scaler - 1)/scaler % 1000 == 0)
+ clk = (clk/scaler + 1) * scaler;
+
+ return clk;
+}
+
static int pl011_hwinit(struct uart_port *port)
{
struct uart_amba_port *uap =
@@ -1658,7 +1675,7 @@ static int pl011_hwinit(struct uart_port
if (retval)
return retval;
- uap->port.uartclk = clk_get_rate(uap->clk);
+ uap->port.uartclk = pl011_clk_round(clk_get_rate(uap->clk));
/* Clear pending error and receive interrupts */
pl011_write(UART011_OEIS | UART011_BEIS | UART011_PEIS |
@@ -2292,7 +2309,7 @@ static int pl011_console_setup(struct co
plat->init();
}
- uap->port.uartclk = clk_get_rate(uap->clk);
+ uap->port.uartclk = pl011_clk_round(clk_get_rate(uap->clk));
if (uap->vendor->fixed_options) {
baud = uap->fixed_baud;
@@ -2509,6 +2526,7 @@ static struct uart_driver amba_reg = {
.cons = AMBA_CONSOLE,
};
+#if 0
static int pl011_probe_dt_alias(int index, struct device *dev)
{
struct device_node *np;
@@ -2540,6 +2558,7 @@ static int pl011_probe_dt_alias(int inde
return ret;
}
+#endif
/* unregisters the driver also if no more ports are left */
static void pl011_unregister_port(struct uart_amba_port *uap)