Motherboard Forums

Thread Tools Display Modes

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

Posts: n/a
      09-25-2011, 09:48 AM

I need to use the USART in AT91SAM9260 working under Linux OS (quite
old 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:

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

My first idea is to simply modify the atmel_set_termios function
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:

/* Get current mode register */
/* 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;
} 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? */

I'd appreciate any suggestions regarding the proposed solution.
Is it safe to use c_ispeed==0 as a trigger for setting of synchronous
How should I manage the SCK pin? Is it enough to set its function in
in the board file (arch/arm/mach-at91/board-my-board.c )?
Reply With Quote
Posts: n/a
      09-25-2011, 11:53 AM
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 -

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".

Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
AHCI Driver modification Embedded 0 06-26-2007 02:36 PM
P2B-AE Tualatin modification P2B Asus 0 04-11-2005 05:22 AM
A7N8X Deluxe R2.0 1008 Modification Ben Pope Asus 6 01-27-2005 11:06 PM
Phoenix Bios Modification Mahiuddin Asus 0 07-14-2004 02:47 PM
P2B Modification Guide Updated: Dual Slot-T P2B Asus 0 08-01-2003 03:32 AM

All times are GMT. The time now is 01:49 AM.

Welcome to Motherboard Point