1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Modification of Linux driver atmel_serial.c to use it in synchronousmode with external clock?

Discussion in 'Embedded' started by wzab, Sep 25, 2011.

  1. wzab

    wzab Guest

    Hi,

    I need to use the USART in AT91SAM9260 working under Linux OS (quite
    old 2.6.29.3 version, due to compatibility with some parts of the
    system) to communicate with peripheral sending data in synchronous
    mode with clock 6MHz. The peripheral provides clock.

    The standard atmel_serial.c driver does not seem to support operation
    with external clock neither the synchronous mode. (In fact it is still
    valid for the newest version: http://lxr.linux.no/linux v3.0.4/drivers/tty/serial/atmel_serial.c#L1106
    ).

    As the driver is quite complicated (especially considering the fact,
    that I need to use DMA to leave CPU power for data processing), I'd
    rather prefer modifying of the atmel_serial.c, than writing my own
    driver.

    My first idea is to simply modify the atmel_set_termios function
    ( http://lxr.linux.no/linux v2.6.29.3/drivers/serial/atmel_serial.c#L1015
    ).
    E.g. I can use the special value of c_ispeed, equal to zero to switch
    the synchronous mode with external clock.
    Below is the proposed modification, original code starts here:
    http://lxr.linux.no/linux v2.6.29.3/drivers/serial/atmel_serial.c#L1022

    /* Get current mode register */
    mode = UART_GET_MR(port) & ~(ATMEL_US_USCLKS | ATMEL_US_CHRL
    | ATMEL_US_NBSTOP |
    ATMEL_US_PAR | ATMEL_US_SYNC );
    /* Added clearing of ATMEL_US_SYNC, not present before, as this
    bit was never set
    in the original driver */
    if(termios->c_ispeed) {
    /* original code */
    baud = uart_get_baud_rate(port, termios, old, 0, port-
    >uartclk / 16);

    quot = uart_get_divisor(port, baud);
    if (quot > 65535) { /* BRGR is 16-bit, so switch to
    slower clock */
    quot /= 8;
    mode |= ATMEL_US_USCLKS_MCK_DIV8;
    }
    } else { /* my code, executed when c_ispeed==0 */
    baud = 6000000 ; /* known in advance, set e.g. for
    calculation of timeouts */
    /* may be it would be wise to allow
    setting of baud via c_ospeed? */
    mode |= ATMEL_US_USCLKS_SCK | ATMEL_US_SYNC ;
    }

    I'd appreciate any suggestions regarding the proposed solution.
    Is it safe to use c_ispeed==0 as a trigger for setting of synchronous
    mode?
    How should I manage the SCK pin? Is it enough to set its function in
    direction
    in the board file (arch/arm/mach-at91/board-my-board.c )?
    --
    Regards,
    Wojtek
     
    wzab, Sep 25, 2011
    #1
    1. Advertising

  2. wzab

    wzab Guest

    Re: Modification of Linux driver atmel_serial.c to use it insynchronous mode with external clock?

    Ok. Using of c_ispeed equal to 0 was not a good idea, as it has
    already a special meaning (the same i_speed and o_speed).
    Also use of other arbitary taken value is not good, as it may be not
    supported by other tools.
    Therefore I've finally decided to steal one of standard values -
    B460800.

    Unfortunately this value is not passed to the atmel_set_termios
    function - instead I get the baud value itself.
    So the user program should pass B460800 in the termios structure,
    while my version of atmel_set_termios should detect
    the integer value "460800".
     
    wzab, Sep 25, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. P2B
    Replies:
    0
    Views:
    341
  2. Mahiuddin

    Phoenix Bios Modification

    Mahiuddin, Jul 14, 2004, in forum: Asus
    Replies:
    0
    Views:
    342
    Mahiuddin
    Jul 14, 2004
  3. ftran999
    Replies:
    2
    Views:
    601
    Inglo
    Aug 6, 2004
  4. AHCI Driver modification

    , Jun 26, 2007, in forum: Embedded
    Replies:
    0
    Views:
    317
  5. wzab
    Replies:
    14
    Views:
    1,054
Loading...

Share This Page