Adds DCC(JTAG) serial and the console emulation support (revised)
PATCH 1/1 Adds DCC(JTAG) serial and the console emulation support (revised)
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 | 493 +++++++++++++++++++++++++++++++++++++++++++ include/linux/serial_core.h | 3 4 files changed, 528 insertions(+), 0 deletions(-)
drivers/serial/Kconfig +31 -0
@@ -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
@@ -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 +493 -0
493 lines not on this page · raw message
include/linux/serial_core.h +3 -0
@@ -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>
On Mon, Apr 03, 2006 at 05:20:02PM +0900, Hyok S. Choi wrote:
Thanks for looking at the previous points, this driver is much better. However, there's still some bits which could be even better.
drivers/serial/dcc.c line 66
Quoted 5 lines
drivers/serial/dcc.c new file +5
-0+/* use ttyJ0(128) */ +#define SERIAL_DCC_NAME "ttyJ" +#define SERIAL_DCC_MINOR (64 + 64) +#endif +#define SERIAL_DCC_MAJOR TTY_MAJOR
Why not just get a proper legal allocation from LANANA ?
drivers/serial/dcc.c line 73
Quoted 2 lines
drivers/serial/dcc.c new file +2
-0+static inline u32 +__dcc_getstatus (void )
Column space is not at a premium.
static inline u32 __dcc_getstatus(void)
will do just as well. Does the double underscore here serve any purpose?
drivers/serial/dcc.c line 75
Quoted 2 lines
drivers/serial/dcc.c new file +2
-0+{ +u32 __ret;
The double underscore here serves no purpose.
drivers/serial/dcc.c line 86
Quoted 11 lines
drivers/serial/dcc.c new file +11
-0+ + asm("mrc p14, 0, %0, c0, c0 @ read comms ctrl reg" + :"=r" (__ret)); + +return __ret; +} + +static inline char +__dcc_getchar (void ) +{ +char __c;
Ditto.
Quoted 11 lines
drivers/serial/dcc.c new file +11
-0+ + asm("mrc p14, 0, %0, c1, c0 @ read comms data reg" + :"=r" (__c)); + +return __c; +} + +static inline void +__dcc_putchar (char c) +{ + asm("mcr p14, 0, %0, c1, c0 @ write a char"
drivers/serial/dcc.c line 107
Quoted 10 lines
drivers/serial/dcc.c new file +10
-0+ : /* no output register */ + : "r" (c)); +} + +static void +dcc_putchar (struct uart_port *port,int ch) +{ +while (__dcc_getstatus () &DCC_STATUS_TX ) +cpu_relax (); +__dcc_putchar ((char )(ch &0xFF ));
Since this is the only place __dcc_putchar is used, might be an idea to move it into this function?
Quoted 7 lines
drivers/serial/dcc.c new file +7
-0+} + +static inline void +xmit_string (struct uart_port *port,char *p,int len) +{ +for ( ; len; len--, p++) +dcc_putchar (port, *p);
drivers/serial/dcc.c line 124
Quoted 10 lines
drivers/serial/dcc.c new file +10
-0+} + +static inline void +dcc_transmit_buffer (struct uart_port *port) +{ +struct circ_buf *xmit = &port->info->xmit; +int pendings =uart_circ_chars_pending (xmit); + +if (pendings + xmit->tail >UART_XMIT_SIZE ) + {
Mixture of bracing styles, and there should be a space between if and (.
if (pendings + xmit->tail > UART_XMIT_SIZE) {Quoted 13 lines
drivers/serial/dcc.c new file +12
-0+xmit_string (port, &(xmit->buf[xmit->tail]), +UART_XMIT_SIZE - xmit->tail); +xmit_string (port, &(xmit->buf[0 ]), xmit->head); + }else +xmit_string (port, &(xmit->buf[xmit->tail]), pendings); + + xmit->tail = (xmit->tail + pendings) & (UART_XMIT_SIZE -1 ); + port->icount.tx += pendings; +} +dcc_rx_chars(struct uart_port *port) +{ +unsigned char ch;
drivers/serial/dcc.c line 162
Quoted 10 lines
drivers/serial/dcc.c new file +10
-0+struct tty_struct *tty = port->info->tty; + +/* +* check input. +* checking JTAG flag is better to resolve the status test. +* incount is NOT used for JTAG1 protocol. +*/ + +if (__dcc_getstatus () &DCC_STATUS_RX ) + {
Mixture of bracing styles again. Either always place the { at the end of the previous line (preferred) or separately on the next line, but don't do both in the same file.
Quoted 6 lines
drivers/serial/dcc.c new file +6
-0+/* for JTAG 1 protocol, incount is always 1. */ + ch =__dcc_getchar (); + +if (tty) { +tty_insert_flip_char (tty, ch,TTY_NORMAL ); + port->icount.rx++;
drivers/serial/dcc.c line 178
Quoted 10 lines
drivers/serial/dcc.c new file +10
-0+tty_flip_buffer_push (tty); + } + } +} + +static inline void +dcc_overrun_chars (struct uart_port *port) +{ + port->icount.overrun++; +}
This doesn't seem to be used anywhere.
Quoted 9 lines
drivers/serial/dcc.c new file +9
-0+static int +dcc_startup (struct uart_port *port) +{ +#ifdef DCC_IRQ_USED /* real IRQ used */ +int retval; + +/* Allocate the IRQ */ + retval =request_irq (port->irq, dcc_int,SA_INTERRUPT , +"serial_dcc" , port);
drivers/serial/dcc.c line 269
Quoted 10 lines
drivers/serial/dcc.c new file +10
-0+if (retval) +return retval; +#else /* emulation */ +/* Initialize the work, and shcedule it. */ +INIT_WORK (&dcc_poll_task, dcc_poll, port); +spin_lock (&port->lock); +if (dcc_poll_state !=DCC_POLL_RUN ) + dcc_poll_state =DCC_POLL_RUN ; +schedule_delayed_work (&dcc_poll_task,1 ); +spin_unlock (&port->lock);
Hmm, this looks over complex:
if (dcc_poll_state != DCC_POLL_RUN) dcc_poll_state = DCC_POLL_RUN;
and unnecessary (see dcc_shutdown comments.)
Secondly, wouldn't it be better to have INIT_WORK() in the driver initialisation?
Quoted 4 lines
drivers/serial/dcc.c new file +4
-0+#endif + +return 0 ; +}
drivers/serial/dcc.c line 283
Quoted 10 lines
drivers/serial/dcc.c new file +10
-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); + dcc_poll_state =DCC_POLL_STOP ; +spin_unlock (&port->lock);
Rather than having this dcc_poll_state, wouldn't the use of:
cancel_rearming_delayed_work(&dcc_poll_task);
suffice?
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Quoted 4 lines · Russell King
On Mon, Apr 03, 2006 at 05:20:02PM +0900, Hyok S. Choi wrote:
Thanks for looking at the previous points, this driver is much better. However, there's still some bits which could be even better.
Okay.
Quoted 7 lines
drivers/serial/dcc.c line 66
Quoted 5 lines
drivers/serial/dcc.c new file +5
-0+/* use ttyJ0(128) */ +#define SERIAL_DCC_NAME "ttyJ" +#define SERIAL_DCC_MINOR (64 + 64) +#endif +#define SERIAL_DCC_MAJOR TTY_MAJORWhy not just get a proper legal allocation from LANANA ?
I've just requested for an allocation of minor # for major# 204.
Quoted 8 lines
drivers/serial/dcc.c line 73
Quoted 2 lines
drivers/serial/dcc.c new file +2
-0+static inline u32 +__dcc_getstatus (void )Column space is not at a premium.
static inline u32
__dcc_getstatus(void)will do just as well. Does the double underscore here serve any purpose?
__* naming is used for assembly based primitive functions, that have dependencies
on JTAG1 protocol. Actually, I'd like to extend to support JTAG4 in a mean while.
Quoted 4 lines
drivers/serial/dcc.c line 75
Quoted 2 lines
drivers/serial/dcc.c new file +2
-0+{ +u32 __ret;The double underscore here serves no purpose.
got it.
Quoted 9 lines
Quoted 9 lines
drivers/serial/dcc.c new file +9
-0+static inline void +__dcc_putchar (char c) +{ + asm("mcr p14, 0, %0, c1, c0 @ write a char" + :/* no output register */ + :"r" (c)); +} + +static void
Quoted 8 lines
drivers/serial/dcc.c line 107
Quoted 5 lines
drivers/serial/dcc.c new file +5
-0+dcc_putchar(struct uart_port *port, int ch) +{ +while (__dcc_getstatus () &DCC_STATUS_TX ) +cpu_relax (); +__dcc_putchar ((char )(ch &0xFF ));Since this is the only place
__dcc_putcharis used, might be an idea to move it into this function?
You're right.
But, as I mentioned above, I wanted to split JTAG1 dependencies. If you strongly want to move into there, I will.
Quoted 19 lines
Quoted 7 lines
drivers/serial/dcc.c new file +7
-0+} + +static inline void +xmit_string (struct uart_port *port,char *p,int len) +{ +for ( ; len; len--, p++) +dcc_putchar (port, *p);drivers/serial/dcc.c line 124
Quoted 10 lines
drivers/serial/dcc.c new file +10
-0+} + +static inline void +dcc_transmit_buffer (struct uart_port *port) +{ +struct circ_buf *xmit = &port->info->xmit; +int pendings =uart_circ_chars_pending (xmit); + +if (pendings + xmit->tail >UART_XMIT_SIZE ) + {Mixture of bracing styles, and there should be a space between if and (.
Quoted 2 lines
if (pendings + xmit->tail > UART_XMIT_SIZE) {Fixed.
Quoted 10 lines
Quoted 10 lines
drivers/serial/dcc.c new file +10
-0+/* for JTAG 1 protocol, incount is always 1. */ + ch =__dcc_getchar (); + +if (tty) { +tty_insert_flip_char (tty, ch,TTY_NORMAL ); + port->icount.rx++; +tty_flip_buffer_push (tty); + } + } +}
Quoted 8 lines
drivers/serial/dcc.c line 178
Quoted 6 lines
drivers/serial/dcc.c new file +6
-0+ +static inline void +dcc_overrun_chars (struct uart_port *port) +{ + port->icount.overrun++; +}This doesn't seem to be used anywhere.
Removed.
Quoted 47 lines
Quoted 9 lines
drivers/serial/dcc.c new file +9
-0+static int +dcc_startup (struct uart_port *port) +{ +#ifdef DCC_IRQ_USED /* real IRQ used */ +int retval; + +/* Allocate the IRQ */ + retval =request_irq (port->irq, dcc_int,SA_INTERRUPT , +"serial_dcc" , port);drivers/serial/dcc.c line 269
Quoted 10 lines
drivers/serial/dcc.c new file +10
-0+if (retval) +return retval; +#else /* emulation */ +/* Initialize the work, and shcedule it. */ +INIT_WORK (&dcc_poll_task, dcc_poll, port); +spin_lock (&port->lock); +if (dcc_poll_state !=DCC_POLL_RUN ) + dcc_poll_state =DCC_POLL_RUN ; +schedule_delayed_work (&dcc_poll_task,1 ); +spin_unlock (&port->lock);Hmm, this looks over complex:
if (dcc_poll_state != DCC_POLL_RUN) dcc_poll_state = DCC_POLL_RUN;and unnecessary (see
dcc_shutdowncomments.)Secondly, wouldn't it be better to have
INIT_WORK()in the driver initialisation?Quoted 4 lines
drivers/serial/dcc.c new file +4
-0+#endif + +return 0 ; +}drivers/serial/dcc.c line 283
Quoted 10 lines
drivers/serial/dcc.c new file +10
-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); + dcc_poll_state =DCC_POLL_STOP ; +spin_unlock (&port->lock);Rather than having this
dcc_poll_state, wouldn't the use of:
Quoted 3 lines
cancel_rearming_delayed_work(&dcc_poll_task);suffice?
Good. Hmm, the lock protections are still needed. Otherwise, it may have some race condition.
Signature · 2 lines
Hyok ARM Linux 2.6 MPU/noMMU Project http://opensrc.sec.samsung.com/