diff options
| author | Adrian Chadd <adrian@FreeBSD.org> | 2015-11-18 06:24:21 +0000 |
|---|---|---|
| committer | Adrian Chadd <adrian@FreeBSD.org> | 2015-11-18 06:24:21 +0000 |
| commit | e0fe7c958fb972df1553ac26c78e103cc414122a (patch) | |
| tree | 98c66a1b581d674b5d059e5b0cf58a1c18b7ab01 /sys/dev/uart | |
| parent | 23a91f45618f1d5c6262c49b56c6a6cbda33df91 (diff) | |
Notes
Diffstat (limited to 'sys/dev/uart')
| -rw-r--r-- | sys/dev/uart/uart_dev_ns8250.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c index b2810a097273..ee0b37badb08 100644 --- a/sys/dev/uart/uart_dev_ns8250.c +++ b/sys/dev/uart/uart_dev_ns8250.c @@ -25,6 +25,7 @@ */ #include "opt_platform.h" +#include "opt_uart.h" #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -57,6 +58,16 @@ __FBSDID("$FreeBSD$"); #define DEFAULT_RCLK 1843200 +/* + * Set the default baudrate tolerance to 3.0%. + * + * Some embedded boards have odd reference clocks (eg 25MHz) + * and we need to handle higher variances in the target baud rate. + */ +#ifndef UART_DEV_TOLERANCE_PCT +#define UART_DEV_TOLERANCE_PCT 30 +#endif /* UART_DEV_TOLERANCE_PCT */ + static int broken_txfifo = 0; SYSCTL_INT(_hw, OID_AUTO, broken_txfifo, CTLFLAG_RWTUN, &broken_txfifo, 0, "UART FIFO has QEMU emulation bug"); @@ -123,8 +134,8 @@ ns8250_divisor(int rclk, int baudrate) /* 10 times error in percent: */ error = ((actual_baud - baudrate) * 2000 / baudrate + 1) >> 1; - /* 3.0% maximum error tolerance: */ - if (error < -30 || error > 30) + /* enforce maximum error tolerance: */ + if (error < -UART_DEV_TOLERANCE_PCT || error > UART_DEV_TOLERANCE_PCT) return (0); return (divisor); |
