serial: mtk: add support for using dynamic baud clock souce
authorWeijie Gao <weijie.gao@mediatek.com>
Fri, 9 Sep 2022 11:59:31 +0000 (19:59 +0800)
committerTom Rini <trini@konsulko.com>
Fri, 23 Sep 2022 19:09:15 +0000 (15:09 -0400)
commit3b17f2e2c2a93b5a0809c782c5bb7ed1b3f68ec1
treede07f246f735beac5e7747ea96dfd58a72a06f18
parent29a48bf9ccba45a5e560bb564bbe76e42629325f
serial: mtk: add support for using dynamic baud clock souce

The baud clock on some platform may change due to assigned-clock-parent
set in DT. In current flow the baud clock is only retrieved during probe
stage. If the parent of the source clock changes after probe stage, the
setbrg will set wrong baudrate.

To get the right clock rate, this patch records the baud clk struct to the
driver's priv, and changes the driver's flow to get the clock rate before
calling _mtk_serial_setbrg().

Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
drivers/serial/serial_mtk.c