Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115648019
D47076.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D47076.diff
View Options
diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c
--- a/sys/dev/uart/uart_dev_ns8250.c
+++ b/sys/dev/uart/uart_dev_ns8250.c
@@ -294,8 +294,8 @@
lcr |= LCR_STOPB;
lcr |= parity << 3;
- /* Set baudrate. */
- if (baudrate > 0) {
+ /* Set baudrate if we know a rclk and both are not 0. */
+ if (baudrate > 0 && bas->rclk > 0) {
divisor = ns8250_divisor(bas->rclk, baudrate);
if (divisor == 0)
return (EINVAL);
@@ -369,8 +369,28 @@
uart_setreg(bas, REG_IER, ier);
uart_barrier(bas);
- if (bas->rclk == 0)
+ /*
+ * Loader tells us to infer the rclk when it sets xo to 0 in
+ * hw.uart.console. We know the baudrate was set by the firmware, so
+ * calculate rclk from baudrate and the divisor register. If 'div' is
+ * actually 0, the resulting 0 value will have us fall back to other
+ * rclk methods.
+ */
+ if (bas->rclk_guess && bas->rclk == 0 && baudrate != 0) {
+ uint32_t div;
+
+ div = ns8250_get_divisor(bas);
+ bas->rclk = baudrate * div * 16;
+ }
+
+ /*
+ * Pick a default because we just don't know. This likely needs future
+ * refinement, but that's hard outside of consoles to know what to use.
+ * But defer as long as possible if there's no defined baud rate.
+ */
+ if (bas->rclk == 0 && baudrate != 0)
bas->rclk = DEFAULT_RCLK;
+
ns8250_param(bas, baudrate, databits, stopbits, parity);
/* Disable the FIFO (if present). */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 27, 12:59 PM (15 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17817918
Default Alt Text
D47076.diff (1 KB)
Attached To
Mode
D47076: uart/ns8250: Add support for computing rclk
Attached
Detach File
Event Timeline
Log In to Comment