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:
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 (
/* 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-
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