Page MenuHomeFreeBSD

uart: Honour clock-frequency in FDT for UART_FDT_CLASS if present
ClosedPublic

Authored by jrtc27 on May 11 2024, 12:34 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 19, 9:57 AM
Unknown Object (File)
Fri, Nov 1, 11:10 PM
Unknown Object (File)
Oct 16 2024, 4:54 AM
Unknown Object (File)
Oct 14 2024, 7:14 AM
Unknown Object (File)
Oct 12 2024, 6:04 PM
Unknown Object (File)
Oct 11 2024, 3:31 PM
Unknown Object (File)
Oct 10 2024, 1:38 AM
Unknown Object (File)
Oct 8 2024, 11:49 PM
Subscribers

Details

Summary

The StarFive VisionFive 2 has a Synopsys DesignWare ABP UART, whose
driver uses UART_FDT_CLASS rather than UART_FDT_CLASS_AND_DEVICE as it
has its own separate newbus driver. This UART is driven by a 24MHz clock
as specified in the FDT, but we don't currently look at the property
here, instead passing down 0 and letting the default value be used in
the 8250 driver (~1.8MHz). As a result the divisor is misconfigured for
the current baud rate for the entire kernel boot process. Once the
newbus driver attaches the correct frequency is saved in the softc, but
that does not take effect until the next time ns8250_param is called and
the divisor is recalculated, namely when userspace runs and /dev/console
is opened (note that ns8250_init does not get called when the newbus
device corresponding to the current console attaches).

Fix this issue by attemmpting to get the current clock frequency as for
the UART_FDT_CLASS_AND_DEVICE_CASE, but falling back to 0 rather than
failing on error.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jrtc27 created this revision.

It's hard to tell if this was a deliberate design choice or just not thought to be needed when the current UART_FDT_CLASS(_AND_DEVICE) framework was added, but I don't see a good alternative to this. Note that snps and tegra_uart are the only in-tree UART_FDT_CLASS users, and both wrap ns8250.

This revision is now accepted and ready to land.May 11 2024, 8:42 PM

Thank you for finding the proper fix! Working fine on my end.