aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Izard <romain.izard.pro@gmail.com>2017-02-10 10:24:46 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-02-14 13:12:21 -0500
commit2867af2dcf4093d5617172c030ff449e5d5c5935 (patch)
tree8f98576d6cbaeba9017b34a197a000ad89df4b6b
parent6d35b131caea3e41f06625e391833e183f9042c0 (diff)
atmel_serial: Use the fractional divider when possible
The fractional baud rate generator is available when using the asynchronous mode of Atmel USART controllers. It makes it possible to use higher baudrates, in exchange for a less precise clock with a variable duty cycle. The existing code restricts its use to the normal mode of the USART controller, following the recommendation from the datasheet for the first chip embedding this type of controller. This recommendation has been removed from the documentation for the newer chips. After verification, all revisions of this controller should be able to use the fractional baud rate generator with the different asynchronous modes. Removing the condition on ATMEL_US_USMODE makes it possible to get correct baudrates at high speed in more cases. This was tested with a board using an Atmel SAMA5D2 chip and a TI WL1831 WiFi/Bluetooth combo chip at 3 Mbauds, with hardware flow control enabled. Signed-off-by: Romain Izard <romain.izard.pro@gmail.com> Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com> Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/atmel_serial.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 8d2cec0f03c2..dcebb28ffbc4 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -1769,7 +1769,9 @@ static void atmel_get_ip_name(struct uart_port *port)
1769 1769
1770 /* 1770 /*
1771 * Only USART devices from at91sam9260 SOC implement fractional 1771 * Only USART devices from at91sam9260 SOC implement fractional
1772 * baudrate. 1772 * baudrate. It is available for all asynchronous modes, with the
1773 * following restriction: the sampling clock's duty cycle is not
1774 * constant.
1773 */ 1775 */
1774 atmel_port->has_frac_baudrate = false; 1776 atmel_port->has_frac_baudrate = false;
1775 atmel_port->has_hw_timer = false; 1777 atmel_port->has_hw_timer = false;
@@ -2213,8 +2215,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
2213 * then 2215 * then
2214 * 8 CD + FP = selected clock / (2 * baudrate) 2216 * 8 CD + FP = selected clock / (2 * baudrate)
2215 */ 2217 */
2216 if (atmel_port->has_frac_baudrate && 2218 if (atmel_port->has_frac_baudrate) {
2217 (mode & ATMEL_US_USMODE) == ATMEL_US_USMODE_NORMAL) {
2218 div = DIV_ROUND_CLOSEST(port->uartclk, baud * 2); 2219 div = DIV_ROUND_CLOSEST(port->uartclk, baud * 2);
2219 cd = div >> 3; 2220 cd = div >> 3;
2220 fp = div & ATMEL_US_FP_MASK; 2221 fp = div & ATMEL_US_FP_MASK;