serial: 8250: Add 8250 port clock update method
authorSerge Semin <Sergey.Semin@baikalelectronics.ru>
Thu, 23 Jul 2020 00:33:54 +0000 (03:33 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jul 2020 15:14:38 +0000 (17:14 +0200)
commit868f3ee6e452bc2b89e68183a1700fcbbe0807b1
tree700afcd0bd5bb9e28082f9a9245bc498cb464b7d
parent699cc4dfd14071e4843e2fde8ce01f09871eb318
serial: 8250: Add 8250 port clock update method

Some platforms can be designed in a way so the UART port reference clock
might be asynchronously changed at some point. In Baikal-T1 SoC this may
happen due to the reference clock being shared between two UART ports, on
the Allwinner SoC the reference clock is derived from the CPU clock, so
any CPU frequency change should get to be known/reflected by/in the UART
controller as well. But it's not enough to just update the
uart_port->uartclk field of the corresponding UART port, the 8250
controller reference clock divisor should be altered so to preserve
current baud rate setting. All of these things is done in a coherent
way by calling the serial8250_update_uartclk() method provided in this
patch. Though note that it isn't supposed to be called from within the
UART port callbacks because the locks using to the protect the UART port
data are already taken in there.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Link: https://lore.kernel.org/r/20200723003357.26897-2-Sergey.Semin@baikalelectronics.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/8250/8250_port.c
include/linux/serial_8250.h