Skip to contentSkip to conversation

DCC(JTAG) serial and the console emulation support(revised#2)

PATCH In review Hyok S. Choi 2 participants 6 messages Apr 3, 2006 – Apr 4, 2006 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 DCC(JTAG) serial and the console emulation support(revised#2)

From: Hyok S. Choi <[email protected]>

Many of JTAG debuggers for ARM support DCC protocol over JTAG connection, which is very useful to debug hardwares which has no serial port. This patch adds DCC serial emulation and the console support. System timer based polling method is used for the emulation of serial input interrupt handling.

---

 drivers/serial/Kconfig      |   31 +++
 drivers/serial/Makefile     |    1 
 drivers/serial/dcc.c        |  450 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/serial_core.h |    3 
 4 files changed, 485 insertions(+), 0 deletions(-)
drivers/serial/Kconfig +31 -0
index 7d22dc0..dd67aab 100644
@@ -352,6 +352,37 @@ config SERIAL_CLPS711X_CONSOLE
 	  your boot loader (lilo or loadlin) about how to pass options to the
 	  kernel at boot time.)
 
+config SERIAL_DCC
+	bool "JTAG ICE/ICD DCC serial port emulation support"
+	depends on ARM
+	select SERIAL_CORE
+	help
+	  This selects serial port emulation driver for ICE/ICD JTAG debugger
+	  (e.g. Trace32) for ARM architecture. You should make an terminal with
+	  DCC(JTAG1) protocol.
+
+	  if unsure, say N.
+ 
+config SERIAL_DCC_CONSOLE
+	bool "Support for console on JTAG ICE/ICD DCC"
+	depends on SERIAL_DCC
+	select SERIAL_CORE_CONSOLE
+	help
+	  Say Y here if you wish to use ICE/ICD JTAG DCC serial port emulation
+	  as the system console.
+
+	  if unsure, say N.
+
+config SERIAL_DCC_STDSERIAL
+	bool "Install JTAG ICE/ICD DCC as standard serial"
+	default y
+	depends on !SERIAL_8250 && SERIAL_DCC
+	help
+	  Say Y here if you want to install DCC driver as a normal serial port
+	  /dev/ttyS0 (major 4, minor 64). Otherwise, it appears as /dev/ttyJ0
+	  (major 4, minor 128) and can co-exist with other UARTs, such as
+	  8250/16C550 compatibles.
+
 config SERIAL_S3C2410
 	tristate "Samsung S3C2410 Serial port support"
 	depends on ARM && ARCH_S3C2410
drivers/serial/Makefile +1 -0
index 0a71bf6..63f2462 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_SERIAL_8250_AU1X00) += 8250
 obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o
 obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o
 obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o
+obj-$(CONFIG_SERIAL_DCC) += dcc.o
 obj-$(CONFIG_SERIAL_PXA) += pxa.o
 obj-$(CONFIG_SERIAL_SA1100) += sa1100.o
 obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o
drivers/serial/dcc.c new file +450 -0

450 lines not on this page · raw message

include/linux/serial_core.h +3 -0
index c32e60e..561bc6a 100644
@@ -130,6 +130,9 @@
 /* SUN4V Hypervisor Console */
 #define PORT_SUNHV	72
 
+/* DCC(JTAG) emulation port types */
+#define PORT_DCC_JTAG1	73
+
 #ifdef __KERNEL__
 
 #include <linux/config.h>
#1 lore raw

On Mon, Apr 03, 2006 at 08:24:10PM +0900, Hyok S. Choi wrote:

The number of comments is getting smaller. Only two remaining.

drivers/serial/Kconfig config SERIAL_CLPS711X_CONSOLE · line 384

Quoted 5 lines
drivers/serial/Kconfig +5 -0
+	help
+	  Say Y here if you want to install DCC driver as a normal serial port
+	  /dev/ttyS0 (major 4, minor 64). Otherwise, it appears as /dev/ttyJ0
+	  (major 4, minor 128) and can co-exist with other UARTs, such as
+	  8250/16C550 compatibles.

Help doesn't match code.

drivers/serial/dcc.c line 246

Quoted 7 lines
drivers/serial/dcc.c new file +7 -0
+static void dcc_shutdown(struct uart_port *port)
+{
+#ifdef DCC_IRQ_USED /* real IRQ used */
+	free_irq(port->irq, port);
+#else
+	spin_lock(&port->lock);
+	cancel_rearming_delayed_work(&dcc_poll_task);

cancel_rearming_delayed_work() might sleep due to it calling flush_workqueue. Therefore, you must not be holding a spinlock.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#2 lore raw
Quoted 12 lines · Russell King

drivers/serial/dcc.c line 246

Quoted 7 lines · Hyok S. Choi
drivers/serial/dcc.c new file +7 -0
+static void dcc_shutdown(struct uart_port *port)
+{
+#ifdef DCC_IRQ_USED /* real IRQ used */
+	free_irq(port->irq, port);
+#else
+	spin_lock(&port->lock);
+	cancel_rearming_delayed_work(&dcc_poll_task);

cancel_rearming_delayed_work() might sleep due to it calling flush_workqueue. Therefore, you must not be holding a spinlock.

Thus, I've just revised the code to lock around a counter variable operation, which is used for life control of the polling task. I've just posted the revised #3. :-)

Signature · 2 lines
Hyok
ARM Linux 2.6 MPU/noMMU Project http://opensrc.sec.samsung.com/
#3 lore raw
Quoted 14 lines · Hyok S. Choi
Quoted 12 lines · Russell King

drivers/serial/dcc.c line 246

Quoted 7 lines · Hyok S. Choi
drivers/serial/dcc.c new file +7 -0
+static void dcc_shutdown(struct uart_port *port)
+{
+#ifdef DCC_IRQ_USED /* real IRQ used */
+	free_irq(port->irq, port);
+#else
+	spin_lock(&port->lock);
+	cancel_rearming_delayed_work(&dcc_poll_task);

cancel_rearming_delayed_work() might sleep due to it calling flush_workqueue. Therefore, you must not be holding a spinlock.

Quoted 3 lines

Thus, I've just revised the code to lock around a counter variable operation, which is used for life control of the polling task. I've just posted the revised #3. :-)

Why do you think you need such complexity?

cancel_rearming_delayed_work() will wait until the poll task has completed and has been removed from the system. It's explicitly designed for work handlers which self-rearm.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#4 lore raw
Quoted 19 lines · Russell King
Quoted 14 lines · Hyok S. Choi
Quoted 12 lines · Russell King

drivers/serial/dcc.c line 246

Quoted 7 lines · Hyok S. Choi
drivers/serial/dcc.c new file +7 -0
+static void dcc_shutdown(struct uart_port *port)
+{
+#ifdef DCC_IRQ_USED /* real IRQ used */
+	free_irq(port->irq, port);
+#else
+	spin_lock(&port->lock);
+	cancel_rearming_delayed_work(&dcc_poll_task);

cancel_rearming_delayed_work() might sleep due to it calling flush_workqueue. Therefore, you must not be holding a spinlock.

Quoted 3 lines

Thus, I've just revised the code to lock around a counter variable operation, which is used for life control of the polling task. I've just posted the revised #3. :-)

Quoted 5 lines

Why do you think you need such complexity?

cancel_rearming_delayed_work() will wait until the poll task has completed and has been removed from the system. It's explicitly designed for work handlers which self-rearm.

Hmm.. Maybe you're right, because dcc_shutdown and dcc_startup, which are the only functions that initiate or stop the work, will never be called concurrently by different callers?

Signature · 2 lines
Hyok
ARM Linux 2.6 MPU/noMMU Project http://opensrc.sec.samsung.com/
#5 lore raw
Quoted 10 lines · Hyok S. Choi
Quoted 5 lines · Russell King

Why do you think you need such complexity?

cancel_rearming_delayed_work() will wait until the poll task has completed and has been removed from the system. It's explicitly designed for work handlers which self-rearm.

Hmm.. Maybe you're right, because dcc_shutdown and dcc_startup, which are the only functions that initiate or stop the work, will never be called concurrently by different callers?

RTFD. This behaviour _is_ documented. Documentation/serial/driver:

startup(port)
Grab any interrupt resources and initialise any low level driver state. Enable the port for reception. It should not activate RTS nor DTR; this will be done via a separate call to set_mctrl.

Locking: port_sem taken.
Interrupts: globally disabled.

shutdown(port)
Disable the port, disable any break condition that may be in effect, and free any interrupt resources. It should not disable RTS nor DTR; this will have already been done via a separate call to set_mctrl.

Locking: port_sem taken.
Interrupts: caller dependent.

If the port semaphore is taken prior to calling either function...

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core