2022-05-16 21:40:32 +00:00
|
|
|
From 307744a359bddf354711e54836e4757788c9dfc4 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
|
kernel: bump 5.15 to 5.15.145
Changelog: https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.15.145
No patches needed a rebase.
23.05 backport:
Rebased patch mediatek/100-dts-update-mt7622-rfb1.patch due to
changes introduced in commit e37aa926447f ("arm64: dts: mediatek:
mt7622: fix memory node warning check") in version v5.15.143 and we
jumped over from v5.15.139 directly to v5.15.145.
Build system: x86_64
Build-tested: ramips/tplink_archer-a6-v3
Run-tested: ramips/tplink_archer-a6-v3
23.05 backport:
Stijn:
Compile-tested: ath79/generic, ipq40xx/generic, mvebu/cortexa72, ramips/mt{7621,7620,76x8}, realtek/rtl{838x,930x}, 86/64.
Run-tested: cortexa72 (RB5009UG+S+IN), mt7621 (EAP615-Wall v1), rtl838x (GS1900-10HP, GS1900-8HP, GS108T v3).
Petr:
Compile-tested: ipq807x, mvebu/cortexa9
Run-tested: turris-omnia, prpl-haze
Tested-by: Stijn Segers <foss@volatilesystems.org> [23.05 testing]
Signed-off-by: John Audia <therealgraysky@proton.me>
Signed-off-by: Petr Štetiar <ynezz@true.cz> [23.05 refresh]
(cherry picked from commit 8de4cc77a6d5c25e48566d0203f159287ac7f3fe)
2023-12-23 11:52:06 +00:00
|
|
|
@@ -1726,6 +1726,23 @@ static void pl011_put_poll_char(struct u
|
2022-05-16 21:40:32 +00:00
|
|
|
|
|
|
|
#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 =
|
kernel: bump 5.15 to 5.15.145
Changelog: https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.15.145
No patches needed a rebase.
23.05 backport:
Rebased patch mediatek/100-dts-update-mt7622-rfb1.patch due to
changes introduced in commit e37aa926447f ("arm64: dts: mediatek:
mt7622: fix memory node warning check") in version v5.15.143 and we
jumped over from v5.15.139 directly to v5.15.145.
Build system: x86_64
Build-tested: ramips/tplink_archer-a6-v3
Run-tested: ramips/tplink_archer-a6-v3
23.05 backport:
Stijn:
Compile-tested: ath79/generic, ipq40xx/generic, mvebu/cortexa72, ramips/mt{7621,7620,76x8}, realtek/rtl{838x,930x}, 86/64.
Run-tested: cortexa72 (RB5009UG+S+IN), mt7621 (EAP615-Wall v1), rtl838x (GS1900-10HP, GS1900-8HP, GS108T v3).
Petr:
Compile-tested: ipq807x, mvebu/cortexa9
Run-tested: turris-omnia, prpl-haze
Tested-by: Stijn Segers <foss@volatilesystems.org> [23.05 testing]
Signed-off-by: John Audia <therealgraysky@proton.me>
Signed-off-by: Petr Štetiar <ynezz@true.cz> [23.05 refresh]
(cherry picked from commit 8de4cc77a6d5c25e48566d0203f159287ac7f3fe)
2023-12-23 11:52:06 +00:00
|
|
|
@@ -1742,7 +1759,7 @@ static int pl011_hwinit(struct uart_port
|
2022-05-16 21:40:32 +00:00
|
|
|
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 |
|
kernel: bump 5.15 to 5.15.145
Changelog: https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.15.145
No patches needed a rebase.
23.05 backport:
Rebased patch mediatek/100-dts-update-mt7622-rfb1.patch due to
changes introduced in commit e37aa926447f ("arm64: dts: mediatek:
mt7622: fix memory node warning check") in version v5.15.143 and we
jumped over from v5.15.139 directly to v5.15.145.
Build system: x86_64
Build-tested: ramips/tplink_archer-a6-v3
Run-tested: ramips/tplink_archer-a6-v3
23.05 backport:
Stijn:
Compile-tested: ath79/generic, ipq40xx/generic, mvebu/cortexa72, ramips/mt{7621,7620,76x8}, realtek/rtl{838x,930x}, 86/64.
Run-tested: cortexa72 (RB5009UG+S+IN), mt7621 (EAP615-Wall v1), rtl838x (GS1900-10HP, GS1900-8HP, GS108T v3).
Petr:
Compile-tested: ipq807x, mvebu/cortexa9
Run-tested: turris-omnia, prpl-haze
Tested-by: Stijn Segers <foss@volatilesystems.org> [23.05 testing]
Signed-off-by: John Audia <therealgraysky@proton.me>
Signed-off-by: Petr Štetiar <ynezz@true.cz> [23.05 refresh]
(cherry picked from commit 8de4cc77a6d5c25e48566d0203f159287ac7f3fe)
2023-12-23 11:52:06 +00:00
|
|
|
@@ -2448,7 +2465,7 @@ static int pl011_console_setup(struct co
|
2022-05-16 21:40:32 +00:00
|
|
|
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;
|
kernel: bump 5.15 to 5.15.145
Changelog: https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.15.145
No patches needed a rebase.
23.05 backport:
Rebased patch mediatek/100-dts-update-mt7622-rfb1.patch due to
changes introduced in commit e37aa926447f ("arm64: dts: mediatek:
mt7622: fix memory node warning check") in version v5.15.143 and we
jumped over from v5.15.139 directly to v5.15.145.
Build system: x86_64
Build-tested: ramips/tplink_archer-a6-v3
Run-tested: ramips/tplink_archer-a6-v3
23.05 backport:
Stijn:
Compile-tested: ath79/generic, ipq40xx/generic, mvebu/cortexa72, ramips/mt{7621,7620,76x8}, realtek/rtl{838x,930x}, 86/64.
Run-tested: cortexa72 (RB5009UG+S+IN), mt7621 (EAP615-Wall v1), rtl838x (GS1900-10HP, GS1900-8HP, GS108T v3).
Petr:
Compile-tested: ipq807x, mvebu/cortexa9
Run-tested: turris-omnia, prpl-haze
Tested-by: Stijn Segers <foss@volatilesystems.org> [23.05 testing]
Signed-off-by: John Audia <therealgraysky@proton.me>
Signed-off-by: Petr Štetiar <ynezz@true.cz> [23.05 refresh]
(cherry picked from commit 8de4cc77a6d5c25e48566d0203f159287ac7f3fe)
2023-12-23 11:52:06 +00:00
|
|
|
@@ -2665,6 +2682,7 @@ static struct uart_driver amba_reg = {
|
2022-05-16 21:40:32 +00:00
|
|
|
.cons = AMBA_CONSOLE,
|
|
|
|
};
|
|
|
|
|
|
|
|
+#if 0
|
|
|
|
static int pl011_probe_dt_alias(int index, struct device *dev)
|
|
|
|
{
|
|
|
|
struct device_node *np;
|
kernel: bump 5.15 to 5.15.145
Changelog: https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.15.145
No patches needed a rebase.
23.05 backport:
Rebased patch mediatek/100-dts-update-mt7622-rfb1.patch due to
changes introduced in commit e37aa926447f ("arm64: dts: mediatek:
mt7622: fix memory node warning check") in version v5.15.143 and we
jumped over from v5.15.139 directly to v5.15.145.
Build system: x86_64
Build-tested: ramips/tplink_archer-a6-v3
Run-tested: ramips/tplink_archer-a6-v3
23.05 backport:
Stijn:
Compile-tested: ath79/generic, ipq40xx/generic, mvebu/cortexa72, ramips/mt{7621,7620,76x8}, realtek/rtl{838x,930x}, 86/64.
Run-tested: cortexa72 (RB5009UG+S+IN), mt7621 (EAP615-Wall v1), rtl838x (GS1900-10HP, GS1900-8HP, GS108T v3).
Petr:
Compile-tested: ipq807x, mvebu/cortexa9
Run-tested: turris-omnia, prpl-haze
Tested-by: Stijn Segers <foss@volatilesystems.org> [23.05 testing]
Signed-off-by: John Audia <therealgraysky@proton.me>
Signed-off-by: Petr Štetiar <ynezz@true.cz> [23.05 refresh]
(cherry picked from commit 8de4cc77a6d5c25e48566d0203f159287ac7f3fe)
2023-12-23 11:52:06 +00:00
|
|
|
@@ -2696,6 +2714,7 @@ static int pl011_probe_dt_alias(int inde
|
2022-05-16 21:40:32 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
/* unregisters the driver also if no more ports are left */
|
|
|
|
static void pl011_unregister_port(struct uart_amba_port *uap)
|