Changeset aea3134e in rtems


Ignore:
Timestamp:
Jun 15, 2018, 6:49:31 AM (11 months ago)
Author:
Daniel Hellstrom <daniel@…>
Branches:
master
Children:
408fad3
Parents:
243ddb5
git-author:
Daniel Hellstrom <daniel@…> (06/15/18 06:49:31)
git-committer:
Daniel Hellstrom <daniel@…> (08/24/18 13:51:39)
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bsps/sparc/shared/uart/apbuart_cons.c

    r243ddb5 raea3134e  
    516516}
    517517
    518 
    519 struct apbuart_baud {
    520         unsigned int num;
    521         unsigned int baud;
    522 };
    523 static struct apbuart_baud apbuart_baud_table[] = {
    524         {B50, 50},
    525         {B75, 75},
    526         {B110, 110},
    527         {B134, 134},
    528         {B150, 150},
    529         {B200, 200},
    530         {B300, 300},
    531         {B600, 600},
    532         {B1200, 1200},
    533         {B1800, 1800},
    534         {B2400, 2400},
    535         {B4800, 4800},
    536         {B9600, 9600},
    537         {B19200, 19200},
    538         {B38400, 38400},
    539         {B57600, 57600},
    540         {B115200, 115200},
    541         {B230400, 230400},
    542         {B460800, 460800},
    543 };
    544 #define BAUD_NUM (sizeof(apbuart_baud_table)/sizeof(struct apbuart_baud))
    545 
    546 static int apbuart_baud_num2baud(unsigned int num)
    547 {
    548         int i;
    549 
    550         for(i=0; i<BAUD_NUM; i++)
    551                 if (apbuart_baud_table[i].num == num)
    552                         return apbuart_baud_table[i].baud;
    553         return -1;
    554 }
    555 
    556 static struct apbuart_baud *apbuart_baud_find_closest(unsigned int baud)
    557 {
    558         int i, diff;
    559 
    560         for(i=0; i<BAUD_NUM-1; i++) {
    561                 diff = apbuart_baud_table[i+1].baud -
    562                         apbuart_baud_table[i].baud;
    563                 if (baud < (apbuart_baud_table[i].baud + diff/2))
    564                         return &apbuart_baud_table[i];
    565         }
    566         return &apbuart_baud_table[BAUD_NUM-1];
    567 }
    568 
    569518int apbuart_get_baud(struct apbuart_priv *uart)
    570519{
     
    580529        /* Calculate baud rate from generator "scaler" number */
    581530        return core_clk_hz / ((scaler + 1) * 8);
    582 }
    583 
    584 static struct apbuart_baud *apbuart_get_baud_closest(struct apbuart_priv *uart)
    585 {
    586         return apbuart_baud_find_closest(apbuart_get_baud(uart));
    587531}
    588532
     
    645589
    646590        /* Baud rate */
    647   baud = apbuart_baud_num2baud(t->c_ospeed);
     591        baud = rtems_termios_baud_to_number(t->c_ospeed);
    648592        if (baud > 0){
    649593                /* Get APBUART core frequency */
     
    667611        struct apbuart_priv *uart = base_get_priv(base);
    668612        unsigned int ctrl;
    669         struct apbuart_baud *baud;
    670 
    671   t->c_cflag = t->c_cflag & ~(CSIZE|PARENB|PARODD|CLOCAL);
     613
     614        t->c_cflag = t->c_cflag & ~(CSIZE|PARENB|PARODD|CLOCAL);
    672615
    673616        /* Hardware support only CS8 */
     
    686629                t->c_cflag |= CLOCAL;
    687630
    688         baud = apbuart_get_baud_closest(uart);
    689         t->c_cflag |= baud->num;
     631        rtems_termios_set_best_baud(t, apbuart_get_baud(uart));
    690632}
    691633
Note: See TracChangeset for help on using the changeset viewer.