aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm2708/patches-4.9/950-0195-amba_pl011-Round-input-clock-up.patch
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2017-03-22 21:09:00 +0100
committerRafał Miłecki <rafal@milecki.pl>2017-03-24 08:06:35 +0100
commitfce21ae4ccfcee0c28fb18f5507e145fb0b02dec (patch)
tree6c29b7c1f65945991d0cae13af012e6c14adc713 /target/linux/brcm2708/patches-4.9/950-0195-amba_pl011-Round-input-clock-up.patch
parent46e390322a58bdc632ee43fdf9d14115dac26e7a (diff)
downloadupstream-fce21ae4ccfcee0c28fb18f5507e145fb0b02dec.tar.gz
upstream-fce21ae4ccfcee0c28fb18f5507e145fb0b02dec.tar.bz2
upstream-fce21ae4ccfcee0c28fb18f5507e145fb0b02dec.zip
brcm2708: rename all patches from raspberrypi git tree to use 950 prefix
Right now all brcm2708 patches are extracted from the non-mainline raspberrypi/linux git tree. Many of them are hacks and/or are unneeded in LEDE. Raspberry Pi is getting better and better mainline support so it would be nice to finally start maintaining patches in a cleaner way: 1) Backport patches accepted in upstream tree 2) Start using upstream drivers 3) Pick only these patches that are needed for more complete support Handling above tasks requires grouping patches - ideally using the same prefixes as generic ones. It means we should rename existing patches to use some high prefix. This will allow e.g. use 0xx for backported code. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Stijn Tintel <stijn@linux-ipv6.be>
Diffstat (limited to 'target/linux/brcm2708/patches-4.9/950-0195-amba_pl011-Round-input-clock-up.patch')
-rw-r--r--target/linux/brcm2708/patches-4.9/950-0195-amba_pl011-Round-input-clock-up.patch86
1 files changed, 86 insertions, 0 deletions
diff --git a/target/linux/brcm2708/patches-4.9/950-0195-amba_pl011-Round-input-clock-up.patch b/target/linux/brcm2708/patches-4.9/950-0195-amba_pl011-Round-input-clock-up.patch
new file mode 100644
index 0000000000..2bd501d8db
--- /dev/null
+++ b/target/linux/brcm2708/patches-4.9/950-0195-amba_pl011-Round-input-clock-up.patch
@@ -0,0 +1,86 @@
+From 0360d687752df3c5546dd1534904a6e0168b6360 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
+@@ -1646,6 +1646,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 =
+@@ -1662,7 +1679,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 |
+@@ -2300,7 +2317,7 @@ static int __init pl011_console_setup(st
+ 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;
+@@ -2372,6 +2389,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;
+@@ -2403,6 +2421,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)