Skip to contentSkip to conversation

serial: imx: add console polling routines for kgdboc

PATCH In review Atsuo Igarashi 3 participants 3 messages Aug 13, 2008 – Aug 15, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: imx: add console polling routines for kgdboc

Add console polling routines for the imx uart with kgdboc.

Signed-off-by Atsuo Igarashi <[email protected]>

drivers/serial/imx.c +27 -0
@@ -646,6 +646,29 @@ static void imx_shutdown(struct uart_por
 	writel(temp, sport->port.membase + UCR1);
 }
 
+#ifdef CONFIG_CONSOLE_POLL
+
+static int imx_get_poll_char(struct uart_port *port)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+
+	while (!(readl(sport->port.membase + USR2) & USR2_RDR));
+
+	return readl(sport->port.membase + URXD0);
+}
+
+static void imx_put_poll_char(struct uart_port *port, unsigned char ch)
+{
+	struct imx_port *sport = (struct imx_port *)port;
+
+	while (readl(sport->port.membase + UTS) & UTS_TXFULL)
+		barrier();
+
+	writel(ch, sport->port.membase + URTX0);
+}
+
+#endif /* CONFIG_CONSOLE_POLL */
+
 static void
 imx_set_termios(struct uart_port *port, struct ktermios *termios,
 		   struct ktermios *old)
@@ -892,6 +915,10 @@ static struct uart_ops imx_pops = {
 	.request_port	= imx_request_port,
 	.config_port	= imx_config_port,
 	.verify_port	= imx_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+	.poll_get_char	= imx_get_poll_char,
+	.poll_put_char	= imx_put_poll_char,
+#endif
 };
 
 static struct imx_port *imx_ports[UART_NR];
maintainer
#1 lore raw
Quoted 1 line · Atsuo Igarashi

Add console polling routines for the imx uart with kgdboc.

Thanks very much. I've never tried kgdb, so I cannot say if this patch does the right thing, but it looks like it does ;)
I added it to our git tree.

Sascha

Signature · 4 lines
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hannoversche Str. 2, 31134 Hildesheim, Germany
   Phone: +49-5121-206917-0 |  Fax: +49-5121-206917-9
#2 lore raw
In reply to Atsuo Igarashi
Quoted 4 lines · Atsuo Igarashi

Add console polling routines for the imx uart with kgdboc.

Signed-off-by Atsuo Igarashi <[email protected]>

In imx_get_poll_char() the code returns the result of reading the urxd register. That register has the 8 bits of receive data in it, but in the next byte up also has 4 bits of error flags (overrun, frame, break, parity) and an error summary bit which are being ignored. Maybe something like this?

static int imx_get_poll_char(struct uart_port *port)

{
	struct imx_port *sport = (struct imx_port *)port;
	int ch;

	while (1) {
                while (!(readl(sport->port.membase + USR2) & USR2_RDR));

	        ch = readl(sport->port.membase + URXD0);

                if (!(ch & URXD_ERR))
                        return(ch & 0xff);
                /* else throw away the char with the error and try
again (or return an error value?) */
        }
}
Signature · 2 lines
Hardware, n.:
 The parts of a computer system that can be kicked.