The MediaTek UART is a 16550 with 32-bit spaced registers and a
fractional baud rate generator. The driver gives that generator to the
ns8250 code through its set_baudrate, get_baudrate and get_divisor
functions, and uses the ns8250 code for everything else. The low-level
console uses the ns8250 code too, so it keeps the rate the firmware set.
For the 30 MHz clock of Table 2-6 of the reference manual [1], the
divisor, SAMPLE_COUNT, SAMPLE_POINT and the number of extended bits are
the table's, except at 7200 baud, where one extended bit is closer than
the table's two. Rates that need fewer than 8 samples per bit are
rejected: below that, the manual requires guard time from the sender.
Probe enables the clocks while it runs, attach applies the assigned
clocks and enables them, and detach releases them. The console is
probed on the clocks the firmware left running and keeps its clocks on
detach. Until there is an MT7986 pinctrl driver, UART1 and UART2 rely
on the firmware's pin setup.
[1] MT7986A Reference Manual for BPI-R3, v1.0, section 2.6, Tables 2-5 and 2-6.
Distributed by Banana Pi: https://wiki.banana-pi.org/Banana_Pi_BPI-R3
Sponsored by: Alchemilla Ventures Private Limited