tty: serial: lpuart: add a more accurate baud rate calculation method
authorDong Aisheng <aisheng.dong@nxp.com>
Tue, 13 Jun 2017 02:55:54 +0000 (10:55 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Jun 2017 15:12:34 +0000 (17:12 +0200)
commita6d7514b14a6ea2a3868bdcb2fca7b2410738595
tree3918fd8bdc99cec55f3e144fc66584a853bbd5ad
parent97d6f353dafa42281dc70a67006c9e40d395796a
tty: serial: lpuart: add a more accurate baud rate calculation method

On new LPUART versions, the oversampling ratio for the receiver can be
changed from 4x (00011) to 32x (11111) which could help us get a more
accurate baud rate divider.

The idea is to use the best OSR (over-sampling rate) possible.
Note, OSR is typically hard-set to 16 in other LPUART instantiations.
Loop to find the best OSR value possible, one that generates minimum
baud diff iterate through the rest of the supported values of OSR.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Mingkai Hu <Mingkai.Hu@nxp.com>
Cc: Yangbo Lu <yangbo.lu@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/fsl_lpuart.c