* [PATCH resend] kgdb: kgdboc console poll hooks for serial_txx9 uart
@ 2009-02-18 13:36 Atsushi Nemoto
2009-02-19 21:17 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Atsushi Nemoto @ 2009-02-18 13:36 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm, ralf, jason.wessel
Implement the serial polling hooks for the serial_txx9 uart for use
with kgdboc.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Acked-by: Jason Wessel <jason.wessel@windriver.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
---
This patch once got SOB from Jason on Jul 2008 and (perhaps) merged
into kgdb-next branch, but lost somewhere then.
I resend it now with Jason's Acked-by.
drivers/serial/serial_txx9.c | 113 ++++++++++++++++++++++++++++++++++--------
1 files changed, 92 insertions(+), 21 deletions(-)
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;
+
+ /*
+ * First save the IER then disable the interrupts
+ */
+ ier = sio_in(up, TXX9_SIDICR);
+ sio_out(up, TXX9_SIDICR, 0);
+
+ while (sio_in(up, TXX9_SIDISR) & TXX9_SIDISR_UVALID)
+ ;
+
+ c = sio_in(up, TXX9_SIRFIFO);
+
+ /*
+ * Finally, clear RX interrupt status
+ * and restore the IER
+ */
+ sio_mask(up, TXX9_SIDISR, TXX9_SIDISR_RDIS);
+ sio_out(up, TXX9_SIDICR, ier);
+ return c;
+}
+
+
+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;
+
+ /*
+ * 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);
+}
+
+#endif /* CONFIG_CONSOLE_POLL */
+
static int serial_txx9_startup(struct uart_port *port)
{
struct uart_txx9_port *up = (struct uart_txx9_port *)port;
@@ -781,6 +869,10 @@ static struct uart_ops serial_txx9_pops = {
.release_port = serial_txx9_release_port,
.request_port = serial_txx9_request_port,
.config_port = serial_txx9_config_port,
+#ifdef CONFIG_CONSOLE_POLL
+ .poll_get_char = serial_txx9_get_poll_char,
+ .poll_put_char = serial_txx9_put_poll_char,
+#endif
};
static struct uart_txx9_port serial_txx9_ports[UART_NR];
@@ -803,27 +895,6 @@ static void __init serial_txx9_register_ports(struct uart_driver *drv,
#ifdef CONFIG_SERIAL_TXX9_CONSOLE
-/*
- * Wait for transmitter & holding register to empty
- */
-static inline 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);
- }
-}
-
static void serial_txx9_console_putchar(struct uart_port *port, int ch)
{
struct uart_txx9_port *up = (struct uart_txx9_port *)port;
--
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH resend] kgdb: kgdboc console poll hooks for serial_txx9 uart
2009-02-18 13:36 [PATCH resend] kgdb: kgdboc console poll hooks for serial_txx9 uart Atsushi Nemoto
@ 2009-02-19 21:17 ` Andrew Morton
2009-02-20 15:27 ` Atsushi Nemoto
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2009-02-19 21:17 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: linux-kernel, ralf, jason.wessel
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);
> +}
> +
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH resend] kgdb: kgdboc console poll hooks for serial_txx9 uart
2009-02-19 21:17 ` Andrew Morton
@ 2009-02-20 15:27 ` Atsushi Nemoto
0 siblings, 0 replies; 3+ messages in thread
From: Atsushi Nemoto @ 2009-02-20 15:27 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, ralf, jason.wessel
On Thu, 19 Feb 2009 13:17:58 -0800, Andrew Morton <akpm@linux-foundation.org> wrote:
> > + struct uart_txx9_port *up = (struct uart_txx9_port *)port;
>
> It's nicer to use container_of() for this operation.
While there are same casts in the driver already, I will send another
patch to convert them at once.
Thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-02-20 15:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-18 13:36 [PATCH resend] kgdb: kgdboc console poll hooks for serial_txx9 uart Atsushi Nemoto
2009-02-19 21:17 ` Andrew Morton
2009-02-20 15:27 ` Atsushi Nemoto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox