[PATCH v3 1/1] serial: omap-serial: Add support for kernel debugger

2010-12-05 Thread Cosmin Cojocar
The kgdb invokes the poll_put_char and poll_get_char when communicating
with the host. This patch also changes the initialization order because the
kgdb will check at the very beginning, if there is a valid serial
driver.

Signed-off-by: Cosmin Cojocar 
---

I fixed the conflicts from Makefile when applying it to the linux-next
tree. This patch is against the linux-next tree.

 drivers/serial/Makefile  |2 +-
 drivers/serial/omap-serial.c |   38 --
 2 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index f9b26df..8ea92e9 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -80,6 +80,7 @@ obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
 obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o
 obj-$(CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL) += nwpserial.o
 obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o
+obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
 obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o
 obj-$(CONFIG_SERIAL_QE) += ucc_uart.o
 obj-$(CONFIG_SERIAL_TIMBERDALE)+= timbuart.o
@@ -89,6 +90,5 @@ obj-$(CONFIG_SERIAL_ALTERA_UART) += altera_uart.o
 obj-$(CONFIG_SERIAL_VT8500) += vt8500_serial.o
 obj-$(CONFIG_SERIAL_MRST_MAX3110)  += mrst_max3110.o
 obj-$(CONFIG_SERIAL_MFD_HSU)   += mfd.o
-obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
 obj-$(CONFIG_SERIAL_IFX6X60)   += ifx6x60.o
 obj-$(CONFIG_SERIAL_PCH_UART)  += pch_uart.o
diff --git a/drivers/serial/omap-serial.c b/drivers/serial/omap-serial.c
index 1201eff..7f2f010 100644
--- a/drivers/serial/omap-serial.c
+++ b/drivers/serial/omap-serial.c
@@ -866,12 +866,6 @@ serial_omap_type(struct uart_port *port)
return up->name;
 }
 
-#ifdef CONFIG_SERIAL_OMAP_CONSOLE
-
-static struct uart_omap_port *serial_omap_console_ports[4];
-
-static struct uart_driver serial_omap_reg;
-
 #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
 
 static inline void wait_for_xmitr(struct uart_omap_port *up)
@@ -905,6 +899,34 @@ static inline void wait_for_xmitr(struct uart_omap_port 
*up)
}
 }
 
+#ifdef CONFIG_CONSOLE_POLL
+
+static void serial_omap_poll_put_char(struct uart_port *port, unsigned char ch)
+{
+   struct uart_omap_port *up = (struct uart_omap_port *)port;
+   wait_for_xmitr(up);
+   serial_out(up, UART_TX, ch);
+}
+
+static int serial_omap_poll_get_char(struct uart_port *port)
+{
+   struct uart_omap_port *up = (struct uart_omap_port *)port;
+   unsigned int status = serial_in(up, UART_LSR);
+
+   if (!(status & UART_LSR_DR))
+   return NO_POLL_CHAR;
+
+   return serial_in(up, UART_RX);
+}
+
+#endif /* CONFIG_CONSOLE_POLL */
+
+#ifdef CONFIG_SERIAL_OMAP_CONSOLE
+
+static struct uart_omap_port *serial_omap_console_ports[4];
+
+static struct uart_driver serial_omap_reg;
+
 static void serial_omap_console_putchar(struct uart_port *port, int ch)
 {
struct uart_omap_port *up = (struct uart_omap_port *)port;
@@ -1022,6 +1044,10 @@ static struct uart_ops serial_omap_pops = {
.request_port   = serial_omap_request_port,
.config_port= serial_omap_config_port,
.verify_port= serial_omap_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+   .poll_put_char  = serial_omap_poll_put_char,
+   .poll_get_char  = serial_omap_poll_get_char,
+#endif
 };
 
 static struct uart_driver serial_omap_reg = {
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 1/1] serial: omap-serial: Add support for kernel debugger

2010-11-22 Thread Cosmin Cojocar
The v2 was a intermediate testing version which I sent it out by
mistake. The difference between the tow is that the v2 uses a
infinite loop to wait for data to be transfered out form buffer, whereas
the v3 relies on existing wait_form_xmitr function.

Regards,
Cosmin

Greg KH wrote:
> On Tue, Nov 23, 2010 at 12:24:12AM +0100, Cosmin Cojocar wrote:
>> The kgdb invokes the poll_put_char and poll_get_char when communicating
>> with the host. This patch also changes the initialization order because the
>> kgdb will check at the very beginning, if there is a valid serial
>> driver.
> 
> What was the difference between v2 and v3?
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/1] serial: omap-serial: Add support for kernel debugger

2010-11-22 Thread Cosmin Cojocar
The kgdb invokes the poll_put_char and poll_get_char when communicating
with the host. This patch also changes the initialization order because the
kgdb will check at the very beginning, if there is a valid serial
driver.

Signed-off-by: Cosmin Cojocar 
---
 drivers/serial/Makefile  |2 +-
 drivers/serial/omap-serial.c |   38 --
 2 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index c570576..ad86113 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -80,6 +80,7 @@ obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
 obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o
 obj-$(CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL) += nwpserial.o
 obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o
+obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
 obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o
 obj-$(CONFIG_SERIAL_QE) += ucc_uart.o
 obj-$(CONFIG_SERIAL_TIMBERDALE)+= timbuart.o
@@ -88,4 +89,3 @@ obj-$(CONFIG_SERIAL_ALTERA_JTAGUART) += altera_jtaguart.o
 obj-$(CONFIG_SERIAL_ALTERA_UART) += altera_uart.o
 obj-$(CONFIG_SERIAL_MRST_MAX3110)  += mrst_max3110.o
 obj-$(CONFIG_SERIAL_MFD_HSU)   += mfd.o
-obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
diff --git a/drivers/serial/omap-serial.c b/drivers/serial/omap-serial.c
index 03a96db..552759e 100644
--- a/drivers/serial/omap-serial.c
+++ b/drivers/serial/omap-serial.c
@@ -866,12 +866,6 @@ serial_omap_type(struct uart_port *port)
return up->name;
 }
 
-#ifdef CONFIG_SERIAL_OMAP_CONSOLE
-
-static struct uart_omap_port *serial_omap_console_ports[4];
-
-static struct uart_driver serial_omap_reg;
-
 #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
 
 static inline void wait_for_xmitr(struct uart_omap_port *up)
@@ -905,6 +899,34 @@ static inline void wait_for_xmitr(struct uart_omap_port 
*up)
}
 }
 
+#ifdef CONFIG_CONSOLE_POLL
+
+static void serial_omap_poll_put_char(struct uart_port *port, unsigned char ch)
+{
+   struct uart_omap_port *up = (struct uart_omap_port *)port;
+   wait_for_xmitr(up);
+   serial_out(up, UART_TX, ch);
+}
+
+static int serial_omap_poll_get_char(struct uart_port *port)
+{
+   struct uart_omap_port *up = (struct uart_omap_port *)port;
+   unsigned int status = serial_in(up, UART_LSR);
+
+   if (!(status & UART_LSR_DR))
+   return NO_POLL_CHAR;
+
+   return serial_in(up, UART_RX);
+}
+
+#endif /* CONFIG_CONSOLE_POLL */
+
+#ifdef CONFIG_SERIAL_OMAP_CONSOLE
+
+static struct uart_omap_port *serial_omap_console_ports[4];
+
+static struct uart_driver serial_omap_reg;
+
 static void serial_omap_console_putchar(struct uart_port *port, int ch)
 {
struct uart_omap_port *up = (struct uart_omap_port *)port;
@@ -1022,6 +1044,10 @@ static struct uart_ops serial_omap_pops = {
.request_port   = serial_omap_request_port,
.config_port= serial_omap_config_port,
.verify_port= serial_omap_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+   .poll_put_char  = serial_omap_poll_put_char,
+   .poll_get_char  = serial_omap_poll_get_char,
+#endif
 };
 
 static struct uart_driver serial_omap_reg = {
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/1] serial: omap-serial: Add support for kernel debugger

2010-11-22 Thread Cosmin Cojocar
The kgdb invokes the poll_put_char and poll_get_char when communicating
with the host. This patch also changes the initialization order because the
kgdb will check at the very beginning, if there is a valid serial
driver.

Signed-off-by: Cosmin Cojocar 
---
 drivers/serial/Makefile  |2 +-
 drivers/serial/omap-serial.c |   44 -
 2 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index c570576..ad86113 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -80,6 +80,7 @@ obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
 obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o
 obj-$(CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL) += nwpserial.o
 obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o
+obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
 obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o
 obj-$(CONFIG_SERIAL_QE) += ucc_uart.o
 obj-$(CONFIG_SERIAL_TIMBERDALE)+= timbuart.o
@@ -88,4 +89,3 @@ obj-$(CONFIG_SERIAL_ALTERA_JTAGUART) += altera_jtaguart.o
 obj-$(CONFIG_SERIAL_ALTERA_UART) += altera_uart.o
 obj-$(CONFIG_SERIAL_MRST_MAX3110)  += mrst_max3110.o
 obj-$(CONFIG_SERIAL_MFD_HSU)   += mfd.o
-obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
diff --git a/drivers/serial/omap-serial.c b/drivers/serial/omap-serial.c
index 03a96db..f18b73d 100644
--- a/drivers/serial/omap-serial.c
+++ b/drivers/serial/omap-serial.c
@@ -866,12 +866,6 @@ serial_omap_type(struct uart_port *port)
return up->name;
 }
 
-#ifdef CONFIG_SERIAL_OMAP_CONSOLE
-
-static struct uart_omap_port *serial_omap_console_ports[4];
-
-static struct uart_driver serial_omap_reg;
-
 #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
 
 static inline void wait_for_xmitr(struct uart_omap_port *up)
@@ -905,6 +899,40 @@ static inline void wait_for_xmitr(struct uart_omap_port 
*up)
}
 }
 
+#ifdef CONFIG_CONSOLE_POLL
+
+static void serial_omap_poll_put_char(struct uart_port *port, unsigned char ch)
+{
+   struct uart_omap_port *up = (struct uart_omap_port *)port;
+   unsigned int status;
+
+   do {
+   status = serial_in(up, UART_LSR);
+   udelay(1);
+   } while ((status & BOTH_EMPTY) != BOTH_EMPTY);
+
+   serial_out(up, UART_TX, ch);
+}
+
+static int serial_omap_poll_get_char(struct uart_port *port)
+{
+   struct uart_omap_port *up = (struct uart_omap_port *)port;
+   unsigned int status = serial_in(up, UART_LSR);
+
+   if (!(status & UART_LSR_DR))
+   return NO_POLL_CHAR;
+
+   return serial_in(up, UART_RX);
+}
+
+#endif /* CONFIG_CONSOLE_POLL */
+
+#ifdef CONFIG_SERIAL_OMAP_CONSOLE
+
+static struct uart_omap_port *serial_omap_console_ports[4];
+
+static struct uart_driver serial_omap_reg;
+
 static void serial_omap_console_putchar(struct uart_port *port, int ch)
 {
struct uart_omap_port *up = (struct uart_omap_port *)port;
@@ -1022,6 +1050,10 @@ static struct uart_ops serial_omap_pops = {
.request_port   = serial_omap_request_port,
.config_port= serial_omap_config_port,
.verify_port= serial_omap_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+   .poll_put_char  = serial_omap_poll_put_char,
+   .poll_get_char  = serial_omap_poll_get_char,
+#endif
 };
 
 static struct uart_driver serial_omap_reg = {
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] serial: omap-serial: Add support for kernel debugger

2010-11-21 Thread Cosmin Cojocar
Hi Ionut,

Ionut Nicu wrote:
> Hi Cosmin,
> 
> On Sat, 2010-11-20 at 21:51 +0100, Cosmin Cojocar wrote:
>> The kgdb invokes the poll_put_char and poll_get_char when communicating
>> with the host. This patch also changes the initialization order because the
>> kgdb will check at the very beginning, if there is a valid serial
>> driver.
>>
>> Signed-off-by: Cosmin Cojocar 
>> ---
>>  drivers/serial/Makefile  |2 +-
>>  drivers/serial/omap-serial.c |   38 --
>>  2 files changed, 37 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
>> index c570576..ad86113 100644
>> --- a/drivers/serial/Makefile
>> +++ b/drivers/serial/Makefile
>> @@ -80,6 +80,7 @@ obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
>>  obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o
>>  obj-$(CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL) += nwpserial.o
>>  obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o
>> +obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
>>  obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o
>>  obj-$(CONFIG_SERIAL_QE) += ucc_uart.o
>>  obj-$(CONFIG_SERIAL_TIMBERDALE) += timbuart.o
>> @@ -88,4 +89,3 @@ obj-$(CONFIG_SERIAL_ALTERA_JTAGUART) += altera_jtaguart.o
>>  obj-$(CONFIG_SERIAL_ALTERA_UART) += altera_uart.o
>>  obj-$(CONFIG_SERIAL_MRST_MAX3110)   += mrst_max3110.o
>>  obj-$(CONFIG_SERIAL_MFD_HSU)+= mfd.o
>> -obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
>> diff --git a/drivers/serial/omap-serial.c b/drivers/serial/omap-serial.c
>> index 03a96db..df6ba03 100644
>> --- a/drivers/serial/omap-serial.c
>> +++ b/drivers/serial/omap-serial.c
>> @@ -866,14 +866,44 @@ serial_omap_type(struct uart_port *port)
>>  return up->name;
>>  }
>>  
>> +#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
>> +
>> +#ifdef CONFIG_CONSOLE_POLL
>> +static void serial_omap_poll_put_char(struct uart_port *port, unsigned char 
>> ch)
>> +{
>> +struct uart_omap_port *up = (struct uart_omap_port *)port;
>> +unsigned int status;
>> +
>> +do {
>> +status = serial_in(up, UART_LSR);
>> +udelay(1);
>> +} while ((status & BOTH_EMPTY) != BOTH_EMPTY);
>> +
> 
> Shouldn't you use wait_for_xmitr() instead? If you do that, then you
> don't need to move the BOTH_EMPTY macro anymore.
> 
Initially, I had used the wait_for_xmitr, but the gdb couldn't establish
a connection. I will retest it.

>> +serial_out(up, UART_TX, ch);
>> +}
>> +
>> +static int serial_omap_poll_get_char(struct uart_port *port)
>> +{
>> +struct uart_omap_port *up = (struct uart_omap_port *)port;
>> +unsigned int status;
>> +int ch;
>> +
>> +do {
>> +status = serial_in(up, UART_LSR);
>> +udelay(1);
>> +} while ((status & UART_LSR_DR) != UART_LSR_DR);
>> +
> 
> I think you should be returning NO_POLL_CHAR if the condition is false,
> instead of busy looping.
> 
>> +ch = (int)serial_in(up, UART_RX);
>> +return ch;
>> +}
> 
> I don't think you need the extra ch variable. Just return serial_in(up,
> UART_RX).
> 
Here, I agree with your comments.

> Cheers,
> Ionut.
> 
> 

Regards,
Cosmin
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] serial: omap-serial: Add support for kernel debugger

2010-11-20 Thread Cosmin Cojocar
The kgdb invokes the poll_put_char and poll_get_char when communicating
with the host. This patch also changes the initialization order because the
kgdb will check at the very beginning, if there is a valid serial
driver.

Signed-off-by: Cosmin Cojocar 
---
 drivers/serial/Makefile  |2 +-
 drivers/serial/omap-serial.c |   38 --
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index c570576..ad86113 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -80,6 +80,7 @@ obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
 obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o
 obj-$(CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL) += nwpserial.o
 obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o
+obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
 obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o
 obj-$(CONFIG_SERIAL_QE) += ucc_uart.o
 obj-$(CONFIG_SERIAL_TIMBERDALE)+= timbuart.o
@@ -88,4 +89,3 @@ obj-$(CONFIG_SERIAL_ALTERA_JTAGUART) += altera_jtaguart.o
 obj-$(CONFIG_SERIAL_ALTERA_UART) += altera_uart.o
 obj-$(CONFIG_SERIAL_MRST_MAX3110)  += mrst_max3110.o
 obj-$(CONFIG_SERIAL_MFD_HSU)   += mfd.o
-obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
diff --git a/drivers/serial/omap-serial.c b/drivers/serial/omap-serial.c
index 03a96db..df6ba03 100644
--- a/drivers/serial/omap-serial.c
+++ b/drivers/serial/omap-serial.c
@@ -866,14 +866,44 @@ serial_omap_type(struct uart_port *port)
return up->name;
 }
 
+#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
+
+#ifdef CONFIG_CONSOLE_POLL
+static void serial_omap_poll_put_char(struct uart_port *port, unsigned char ch)
+{
+   struct uart_omap_port *up = (struct uart_omap_port *)port;
+   unsigned int status;
+
+   do {
+   status = serial_in(up, UART_LSR);
+   udelay(1);
+   } while ((status & BOTH_EMPTY) != BOTH_EMPTY);
+
+   serial_out(up, UART_TX, ch);
+}
+
+static int serial_omap_poll_get_char(struct uart_port *port)
+{
+   struct uart_omap_port *up = (struct uart_omap_port *)port;
+   unsigned int status;
+   int ch;
+
+   do {
+   status = serial_in(up, UART_LSR);
+   udelay(1);
+   } while ((status & UART_LSR_DR) != UART_LSR_DR);
+
+   ch = (int)serial_in(up, UART_RX);
+   return ch;
+}
+#endif
+
 #ifdef CONFIG_SERIAL_OMAP_CONSOLE
 
 static struct uart_omap_port *serial_omap_console_ports[4];
 
 static struct uart_driver serial_omap_reg;
 
-#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
-
 static inline void wait_for_xmitr(struct uart_omap_port *up)
 {
unsigned int status, tmout = 1;
@@ -1022,6 +1052,10 @@ static struct uart_ops serial_omap_pops = {
.request_port   = serial_omap_request_port,
.config_port= serial_omap_config_port,
.verify_port= serial_omap_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+   .poll_put_char  = serial_omap_poll_put_char,
+   .poll_get_char  = serial_omap_poll_get_char,
+#endif
 };
 
 static struct uart_driver serial_omap_reg = {
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html