Skip to contentSkip to conversation

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

PATCH New Bin Meng 2 participants 6 messages Feb 3, 2021 – Feb 7, 2021

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/1 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 at gmail.com/

---

 drivers/serial/ns16550.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/serial/ns16550.c +2 -0
index da903c1..a1593a2 100644
@@ -563,6 +563,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;
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 serial: ns16550: Handle zero <clock-frequency> value

Hi Bin,

Quoted 26 lines · Bin Meng

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 at gmail.com/

---

 drivers/serial/ns16550.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/serial/ns16550.c +0 -0
index da903c1..a1593a2 100644

drivers/serial/ns16550.c int ns16550_serial_of_to_plat(struct udevice *dev) · line 567

Quoted 5 lines
drivers/serial/ns16550.c +2 -0
@@ -563,6 +563,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;

This is already done in the line above...does that not work?

Quoted 6 lines
drivers/serial/ns16550.c +0 -1
        if (!plat->clock) {
                debug("ns16550 clock not defined\n");
                return -EINVAL;
--

2.7.4

Regards,
Simon

author
#2 lore raw

PATCH 1/1 serial: ns16550: Handle zero <clock-frequency> value

Hi Simon,

Quoted 25 lines · Simon Glass

Hi Bin,

Quoted 21 lines · Bin Meng

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 at gmail.com/

---

 drivers/serial/ns16550.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 12 lines

drivers/serial/ns16550.c int ns16550_serial_of_to_plat(struct udevice *dev) · line 567

Quoted 10 lines
drivers/serial/ns16550.c +2 -0
index da903c1..a1593a2 100644
@@ -563,6 +563,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;

This is already done in the line above...does that not work?

The line above only works if there is no <clock-frequency> in the device tree. Since the device tree does provide a <clock-frequency>, the default one was never used.

Quoted 4 lines

drivers/serial/ns16550.c int ns16550_serial_of_to_plat(struct udevice *dev) · line 570

Quoted 4 lines
drivers/serial/ns16550.c +0 -0
        if (!plat->clock) {
                debug("ns16550 clock not defined\n");
                return -EINVAL;

Regards,
Bin

#3 lore raw

PATCH 1/1 serial: ns16550: Handle zero <clock-frequency> value

Quoted 42 lines · Bin Meng

Hi Simon,

Quoted 25 lines · Simon Glass

Hi Bin,

Quoted 21 lines · Bin Meng

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 at gmail.com/

---

 drivers/serial/ns16550.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 12 lines

drivers/serial/ns16550.c int ns16550_serial_of_to_plat(struct udevice *dev) · line 567

Quoted 10 lines
drivers/serial/ns16550.c +2 -0
index da903c1..a1593a2 100644
@@ -563,6 +563,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;

This is already done in the line above...does that not work?

Quoted 3 lines

The line above only works if there is no <clock-frequency> in the device tree. Since the device tree does provide a <clock-frequency>, the default one was never used.

Yes you said that in the commit message, but there was 15 minutes between be reading that and the patch :-(

I really don't like adding this sort of thing globally though. Do you think we could make it happen only for qemu?

Quoted 8 lines
Quoted 5 lines

drivers/serial/ns16550.c int ns16550_serial_of_to_plat(struct udevice *dev) · line 570

Quoted 5 lines
drivers/serial/ns16550.c +0 -0
        if (!plat->clock) {
                debug("ns16550 clock not defined\n");
                return -EINVAL;

Regards,
Bin

author
#4 lore raw

PATCH 1/1 serial: ns16550: Handle zero <clock-frequency> value

Hi Simon,

Quoted 48 lines · Simon Glass
Quoted 42 lines · Bin Meng

Hi Simon,

Quoted 25 lines · Simon Glass

Hi Bin,

Quoted 21 lines · Bin Meng

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 at gmail.com/

---

 drivers/serial/ns16550.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 12 lines

drivers/serial/ns16550.c int ns16550_serial_of_to_plat(struct udevice *dev) · line 567

Quoted 10 lines
drivers/serial/ns16550.c +2 -0
index da903c1..a1593a2 100644
@@ -563,6 +563,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;

This is already done in the line above...does that not work?

Quoted 3 lines

The line above only works if there is no <clock-frequency> in the device tree. Since the device tree does provide a <clock-frequency>, the default one was never used.

Quoted 5 lines

Yes you said that in the commit message, but there was 15 minutes between be reading that and the patch :-(

I really don't like adding this sort of thing globally though. Do you think we could make it happen only for qemu?

Correct, that's why I said we should revert this patch once the 2 conditions are met.

I am working on migrating QEMU ppce500 to driver model. Without this patch the U-Boot does not boot.

Quoted 3 lines

Regards,
Bin

#5 lore raw

PATCH 1/1 serial: ns16550: Handle zero <clock-frequency> value

Hi Simon,

Quoted 23 lines · Simon Glass
Quoted 21 lines · Bin Meng

Hi Simon,

Quoted 17 lines · Simon Glass

Hi Bin,

Quoted 13 lines · Bin Meng

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

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

---

 drivers/serial/ns16550.c | 2 ++
 1 file changed, 2 insertions(+)

Applied to u-boot-dm, thanks!