Re: [PATCH] Add poll_get_char and poll_put_char uart_ops toatmel_serial.

From: Haavard Skinnemoen
Date: Mon Jul 27 2009 - 10:23:33 EST


[added AT91 maintainers to Cc]

Albin Tonnerre wrote:
> +#ifdef CONFIG_CONSOLE_POLL
> +static int atmel_poll_get_char(struct uart_port *port)
> +{
> + struct atmel_uart_port *aup = to_atmel_uart_port(port);
> +
> + while (!(readb(aup->uart.membase + ATMEL_US_CSR) & ATMEL_US_RXRDY))
> + barrier();
> +
> + return readb(aup->uart.membase + ATMEL_US_RHR);
> +}
> +
> +static void atmel_poll_put_char(struct uart_port *port, unsigned char ch)
> +{
> + struct atmel_uart_port *aup = to_atmel_uart_port(port);
> + unsigned int status;
> +
> + while (!(readb(aup->uart.membase + ATMEL_US_CSR) & ATMEL_US_TXRDY))
> + barrier();
> +
> + writeb(ch, aup->uart.membase + ATMEL_US_THR);
> +}
> +#endif

All the registers are 32 bits wide, so you should use __raw_readl() and
__raw_writel() to avoid any endianness issues (AT91 is little endian
and AVR32 is big endian).

Haavard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/