From: Bin Meng <bmeng.cn@gmail.com>
Date: Wed, 3 Feb 2021 14:42:25 +0000 (+0800)
Subject: serial: ns16550: Handle zero <clock-frequency> value
X-Git-Tag: v2025.01-rc5-pxa1908~1975^2
X-Git-Url: http://git.dujemihanovic.xyz/html/static/git-logo.png?a=commitdiff_plain;h=384b62c073f3aaccba0c917a8da7701a82441aec;p=u-boot.git

serial: ns16550: Handle zero <clock-frequency> value

A working device tree node of ns16550 should never be populated
with value zero for the <clock-frequency> property. Unfortunately
this is the case for the QEMU ppce500 target.

Let's try to assign plat->clock to CONFIG_SYS_NS16550_CLK as the
last resort to handle such case.

This commit should be reverted when:

- The following QEMU patch [1] is merged, and
- U-Boot CI has upgraded its QEMU version that contains the fix

[1] http://patchwork.ozlabs.org/project/qemu-devel/patch/1612362288-22216-2-git-send-email-bmeng.cn@gmail.com/

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 1377c9a0e1..cc121eee27 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -564,6 +564,8 @@ int ns16550_serial_of_to_plat(struct udevice *dev)
 	if (!plat->clock)
 		plat->clock = dev_read_u32_default(dev, "clock-frequency",
 						   CONFIG_SYS_NS16550_CLK);
+	if (!plat->clock)
+		plat->clock = CONFIG_SYS_NS16550_CLK;
 	if (!plat->clock) {
 		debug("ns16550 clock not defined\n");
 		return -EINVAL;