From aea3134ea99dc7870c2d787c248189a004c2e66a Mon Sep 17 00:00:00 2001 From: Daniel Hellstrom Date: Fri, 15 Jun 2018 08:49:31 +0200 Subject: leon,apbuart: replace termios c_cflag & CBAUD with c_{i,o}speed ince some time RTEMS started to use the termios c_ispeed and c_ospeed variables in the termios struct to hold the UART baudrate. However the APBUART driver still uses the old c_cflag sometimes causing other UART parameters to get overwritten, for example the partiy setting no mapped to the same bits as the old CBAUD mask. At the same time the RTEMS primitievs for setting/reading c_{i,o}speed is now used. --- bsps/sparc/shared/uart/apbuart_cons.c | 64 ++--------------------------------- 1 file changed, 3 insertions(+), 61 deletions(-) diff --git a/bsps/sparc/shared/uart/apbuart_cons.c b/bsps/sparc/shared/uart/apbuart_cons.c index ac8a4369b2..a54c222935 100644 --- a/bsps/sparc/shared/uart/apbuart_cons.c +++ b/bsps/sparc/shared/uart/apbuart_cons.c @@ -515,57 +515,6 @@ static int read_task(rtems_termios_device_context *base) return EOF; } - -struct apbuart_baud { - unsigned int num; - unsigned int baud; -}; -static struct apbuart_baud apbuart_baud_table[] = { - {B50, 50}, - {B75, 75}, - {B110, 110}, - {B134, 134}, - {B150, 150}, - {B200, 200}, - {B300, 300}, - {B600, 600}, - {B1200, 1200}, - {B1800, 1800}, - {B2400, 2400}, - {B4800, 4800}, - {B9600, 9600}, - {B19200, 19200}, - {B38400, 38400}, - {B57600, 57600}, - {B115200, 115200}, - {B230400, 230400}, - {B460800, 460800}, -}; -#define BAUD_NUM (sizeof(apbuart_baud_table)/sizeof(struct apbuart_baud)) - -static int apbuart_baud_num2baud(unsigned int num) -{ - int i; - - for(i=0; ic_ospeed); + baud = rtems_termios_baud_to_number(t->c_ospeed); if (baud > 0){ /* Get APBUART core frequency */ drvmgr_freq_get(uart->dev, DEV_APB_SLV, &core_clk_hz); @@ -666,9 +610,8 @@ static void get_attributes( { struct apbuart_priv *uart = base_get_priv(base); unsigned int ctrl; - struct apbuart_baud *baud; - t->c_cflag = t->c_cflag & ~(CSIZE|PARENB|PARODD|CLOCAL); + t->c_cflag = t->c_cflag & ~(CSIZE|PARENB|PARODD|CLOCAL); /* Hardware support only CS8 */ t->c_cflag |= CS8; @@ -685,8 +628,7 @@ static void get_attributes( if ((ctrl & LEON_REG_UART_CTRL_FL) == 0) t->c_cflag |= CLOCAL; - baud = apbuart_get_baud_closest(uart); - t->c_cflag |= baud->num; + rtems_termios_set_best_baud(t, apbuart_get_baud(uart)); } static void write_polled( -- cgit v1.2.3