lkml.org 
[lkml]   [2009]   [Feb]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH resend] kgdb: kgdboc console poll hooks for serial_txx9 uart
On Wed, 18 Feb 2009 22:36:41 +0900 (JST)
Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:

> Implement the serial polling hooks for the serial_txx9 uart for use
> with kgdboc.
>
> ...
>
> diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c
> index 8fcb4c5..6f18215 100644
> --- a/drivers/serial/serial_txx9.c
> +++ b/drivers/serial/serial_txx9.c
> @@ -461,6 +461,94 @@ static void serial_txx9_break_ctl(struct uart_port *port, int break_state)
> spin_unlock_irqrestore(&up->port.lock, flags);
> }
>
> +#if defined(CONFIG_SERIAL_TXX9_CONSOLE) || (CONFIG_CONSOLE_POLL)
> +/*
> + * Wait for transmitter & holding register to empty
> + */
> +static void wait_for_xmitr(struct uart_txx9_port *up)
> +{
> + unsigned int tmout = 10000;
> +
> + /* Wait up to 10ms for the character(s) to be sent. */
> + while (--tmout &&
> + !(sio_in(up, TXX9_SICISR) & TXX9_SICISR_TXALS))
> + udelay(1);
> +
> + /* Wait up to 1s for flow control if necessary */
> + if (up->port.flags & UPF_CONS_FLOW) {
> + tmout = 1000000;
> + while (--tmout &&
> + (sio_in(up, TXX9_SICISR) & TXX9_SICISR_CTSS))
> + udelay(1);
> + }
> +}
> +#endif
> +
> +#ifdef CONFIG_CONSOLE_POLL
> +/*
> + * Console polling routines for writing and reading from the uart while
> + * in an interrupt or debug context.
> + */
> +
> +static int serial_txx9_get_poll_char(struct uart_port *port)
> +{
> + unsigned int ier;
> + unsigned char c;
> + struct uart_txx9_port *up = (struct uart_txx9_port *)port;

It's nicer to use container_of() for this operation.

> ...
>
> +static void serial_txx9_put_poll_char(struct uart_port *port, unsigned char c)
> +{
> + unsigned int ier;
> + struct uart_txx9_port *up = (struct uart_txx9_port *)port;

ditto.

> + /*
> + * First save the IER then disable the interrupts
> + */
> + ier = sio_in(up, TXX9_SIDICR);
> + sio_out(up, TXX9_SIDICR, 0);
> +
> + wait_for_xmitr(up);
> + /*
> + * Send the character out.
> + * If a LF, also do CR...
> + */
> + sio_out(up, TXX9_SITFIFO, c);
> + if (c == 10) {
> + wait_for_xmitr(up);
> + sio_out(up, TXX9_SITFIFO, 13);
> + }
> +
> + /*
> + * Finally, wait for transmitter to become empty
> + * and restore the IER
> + */
> + wait_for_xmitr(up);
> + sio_out(up, TXX9_SIDICR, ier);
> +}
> +



\
 
 \ /
  Last update: 2009-02-19 22:21    [W:0.049 / U:0.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site