serial: 8250_dw: set clock rate
Subsystems (4)
PATCH 1/1 serial: 8250_dw: set clock rate
If the uart clock provided to the 8250_dw driver is adjustable it may not be set to the desired rate. Therefore if both a uart clock and a clock frequency is specified (e.g. via device tree), try and update the clock to match the frequency.
Unfortunately if the resulting frequency is rounded down (which is the default behaviour of the generic clk-divider), the 8250 core won't allow the highest baud rate to be used, so if an explicit frequency is specified we always report that to the 8250 core.
The device tree bindings document is also updated accordingly.
--- .../bindings/tty/serial/snps-dw-apb-uart.txt | 4 +- drivers/tty/serial/8250/8250_dw.c | 47 +++++++++++++++++----- 2 files changed, 39 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/tty/serial/snps-dw-apb-uart.txt +3 -1
@@ -4,9 +4,11 @@ Required properties: - compatible : "snps,dw-apb-uart" - reg : offset and length of the register set for the device. - interrupts : should contain uart interrupt. -- clock-frequency : the input clock frequency for the UART. Optional properties: +- clock-frequency : the input clock frequency for the UART. If specified in + addition to clocks, the clock rate will be set to this frequency. +- clocks : the input clock specifier for the UART. - reg-shift : quantity to shift the register offsets by. If this property is not present then the register offsets are not shifted. - reg-io-width : the size (in bytes) of the IO accesses that should be
drivers/tty/serial/8250/8250_dw.c +36 -11
80 lines not on this page · raw message
Signature · 1 line
1.8.1.2
Quoted 9 lines · James Hogan
If the uart clock provided to the 8250_dw driver is adjustable it may not be set to the desired rate. Therefore if both a uart clock and a clock frequency is specified (e.g. via device tree), try and update the clock to match the frequency.
Unfortunately if the resulting frequency is rounded down (which is the default behaviour of the generic clk-divider), the 8250 core won't allow the highest baud rate to be used, so if an explicit frequency is specified we always report that to the 8250 core.
Hi,
Sorry, please ignore this patch.
I've realised that a larger (e.g. non-divided) source clock can just be provided directly to the uart and it appears to have enough of an internal divider for the driver to do the right thing without changing the input clock rate, although of course that clock rate still needs setting somewhere. I'm not sure why we didn't do this all along as it gives a closer frequency anyway.
Thanks
James