Skip to contentSkip to conversation

serial: DCC(JTAG) serial and console emulation support

PATCH New Daniel Walker 5 participants 45 messages Oct 5, 2010 – Oct 13, 2010

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

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

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.

Most of the code was taken from Hyok S. Choi original work, but the inline assmebly needed some work and updating. It now supports ARMv7. Also the description above is from Hyok also.

---
 drivers/serial/Kconfig      |   31 +++
 drivers/serial/Makefile     |    1 +
 drivers/serial/dcc.c        |  467 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/serial_core.h |    3 +
 4 files changed, 502 insertions(+), 0 deletions(-)
 create mode 100644 drivers/serial/dcc.c
drivers/serial/Kconfig +31 -0
index 12900f7..24ead62 100644
@@ -495,6 +495,37 @@ config SERIAL_S3C2400
 	help
 	  Serial port support for the Samsung S3C2400 SoC
 
+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 SERIAL_SAMSUNG && CPU_S3C2410
drivers/serial/Makefile +1 -0
index 1ca4fd5..896c3f6 100644
@@ -31,6 +31,7 @@ obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o
 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_PNX8XXX) += pnx8xxx_uart.o
 obj-$(CONFIG_SERIAL_SA1100) += sa1100.o
drivers/serial/dcc.c new file +467 -0

467 lines not on this page · raw message

include/linux/serial_core.h +3 -0
index 563e234..a360c3a 100644
@@ -196,6 +196,9 @@
 /* High Speed UART for Medfield */
 #define PORT_MFD	95
 
+/* DCC(JTAG) emulation port types */
+#define PORT_DCC_JTAG1	96
+
 #ifdef __KERNEL__
 
 #include <linux/compiler.h>
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 36 lines · Daniel Walker
drivers/serial/dcc.c new file +36 -0
+#if !defined(CONFIG_CPU_V7)
+static inline char
+__dcc_getchar(void)
+{
+	char __c;
+
+	asm("mrc p14, 0, %0, c0, c5, 0	@ read comms data reg"
+		: "=r" (__c) : : "cc");
+
+	return __c;
+}
+#else
+static inline char
+__dcc_getchar(void)
+{
+	char __c;
+
+	asm(
+	"get_wait:	mrc p14, 0, pc, c0, c1, 0                   \n\
+			bne get_wait                                    \n\
+			mrc p14, 0, %0, c0, c5, 0	@ read comms data reg"
+		: "=r" (__c) : : "cc");
+
+	return __c;
+}
+#endif
+
+#if !defined(CONFIG_CPU_V7)
+static inline void
+__dcc_putchar(char c)
+{
+	asm("mcr p14, 0, %0, c0, c5, 0	@ write a char"
+		: /* no output register */
+		: "r" (c) : "cc");
+}
+#else

drivers/serial/dcc.c line 120

Quoted 10 lines
drivers/serial/dcc.c new file +10 -0
+static inline void
+__dcc_putchar(char c)
+{
+	asm(
+	"put_wait:	mrc p14, 0, pc, c0, c1, 0                   \n\
+			bcs put_wait                                \n\
+			mcr p14, 0, %0, c0, c5, 0                   "
+	: : "r" (c) : "cc");
+}
+#endif

Please move the #ifdef conditionals inside the respective functions so to have only one function pair with the various alternatives embedded into them.

Nicolas

#2 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 44 lines · Nicolas Pitre
Quoted 42 lines · Daniel Walker
drivers/serial/dcc.c new file +42 -0
+#if !defined(CONFIG_CPU_V7)
+static inline char
+__dcc_getchar(void)
+{
+	char __c;
+
+	asm("mrc p14, 0, %0, c0, c5, 0	@ read comms data reg"
+		: "=r" (__c) : : "cc");
+
+	return __c;
+}
+#else
+static inline char
+__dcc_getchar(void)
+{
+	char __c;
+
+	asm(
+	"get_wait:	mrc p14, 0, pc, c0, c1, 0                   \n\
+			bne get_wait                                    \n\
+			mrc p14, 0, %0, c0, c5, 0	@ read comms data reg"
+		: "=r" (__c) : : "cc");
+
+	return __c;
+}
+#endif
+
+#if !defined(CONFIG_CPU_V7)
+static inline void
+__dcc_putchar(char c)
+{
+	asm("mcr p14, 0, %0, c0, c5, 0	@ write a char"
+		: /* no output register */
+		: "r" (c) : "cc");
+}
+#else
+static inline void
+__dcc_putchar(char c)
+{
+	asm(
+	"put_wait:	mrc p14, 0, pc, c0, c1, 0                   \n\
+			bcs put_wait                                \n\
Quoted 8 lines

drivers/serial/dcc.c line 120

Quoted 4 lines
drivers/serial/dcc.c new file +4 -0
+			mcr p14, 0, %0, c0, c5, 0                   "
+	: : "r" (c) : "cc");
+}
+#endif

Please move the #ifdef conditionals inside the respective functions so to have only one function pair with the various alternatives embedded into them.

My typical clean up policy is do to the inverse of what your suggesting. Mainly because that's the method that I see used extensive in generic parts of the kernel.

Quoted 1 line

From my perspective there are pluses an minuses to both. Your method

reduces lines, and duplication. My method makes the code easier to read.

Daniel

Signature · 3 lines
Sent by an consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum.
#3 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 54 lines · Daniel Walker
Quoted 44 lines · Nicolas Pitre
Quoted 42 lines · Daniel Walker
drivers/serial/dcc.c new file +42 -0
+#if !defined(CONFIG_CPU_V7)
+static inline char
+__dcc_getchar(void)
+{
+	char __c;
+
+	asm("mrc p14, 0, %0, c0, c5, 0	@ read comms data reg"
+		: "=r" (__c) : : "cc");
+
+	return __c;
+}
+#else
+static inline char
+__dcc_getchar(void)
+{
+	char __c;
+
+	asm(
+	"get_wait:	mrc p14, 0, pc, c0, c1, 0                   \n\
+			bne get_wait                                    \n\
+			mrc p14, 0, %0, c0, c5, 0	@ read comms data reg"
+		: "=r" (__c) : : "cc");
+
+	return __c;
+}
+#endif
+
+#if !defined(CONFIG_CPU_V7)
+static inline void
+__dcc_putchar(char c)
+{
+	asm("mcr p14, 0, %0, c0, c5, 0	@ write a char"
+		: /* no output register */
+		: "r" (c) : "cc");
+}
+#else
+static inline void
+__dcc_putchar(char c)
+{
+	asm(
+	"put_wait:	mrc p14, 0, pc, c0, c1, 0                   \n\
+			bcs put_wait                                \n\
Quoted 8 lines

drivers/serial/dcc.c line 120

Quoted 4 lines
drivers/serial/dcc.c new file +4 -0
+			mcr p14, 0, %0, c0, c5, 0                   "
+	: : "r" (c) : "cc");
+}
+#endif

Please move the #ifdef conditionals inside the respective functions so to have only one function pair with the various alternatives embedded into them.

Quoted 3 lines

My typical clean up policy is do to the inverse of what your suggesting. Mainly because that's the method that I see used extensive in generic parts of the kernel.

Do you have an example? I don't see such thing in generic code, unless two versions of the same function are totally different. In this case you have only the inner inline asm code that is different.

Quoted 2 lines

From my perspective there are pluses an minuses to both. Your method reduces lines, and duplication. My method makes the code easier to read.

I disagree. In reviewing your patch I had to go back and forth between the different versions just to figure out what was actually different to justify this #ifdef in the first place. If the #ifdef..#endif was surrounding only the different inline asm statements then the difference would have been more obvious.

Nicolas

#4 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 56 lines · Nicolas Pitre
Quoted 54 lines · Daniel Walker
Quoted 52 lines · Nicolas Pitre
Quoted 36 lines · Daniel Walker
drivers/serial/dcc.c new file +36 -0
+#if !defined(CONFIG_CPU_V7)
+static inline char
+__dcc_getchar(void)
+{
+	char __c;
+
+	asm("mrc p14, 0, %0, c0, c5, 0	@ read comms data reg"
+		: "=r" (__c) : : "cc");
+
+	return __c;
+}
+#else
+static inline char
+__dcc_getchar(void)
+{
+	char __c;
+
+	asm(
+	"get_wait:	mrc p14, 0, pc, c0, c1, 0                   \n\
+			bne get_wait                                    \n\
+			mrc p14, 0, %0, c0, c5, 0	@ read comms data reg"
+		: "=r" (__c) : : "cc");
+
+	return __c;
+}
+#endif
+
+#if !defined(CONFIG_CPU_V7)
+static inline void
+__dcc_putchar(char c)
+{
+	asm("mcr p14, 0, %0, c0, c5, 0	@ write a char"
+		: /* no output register */
+		: "r" (c) : "cc");
+}
+#else

drivers/serial/dcc.c line 120

Quoted 10 lines
drivers/serial/dcc.c new file +10 -0
+static inline void
+__dcc_putchar(char c)
+{
+	asm(
+	"put_wait:	mrc p14, 0, pc, c0, c1, 0                   \n\
+			bcs put_wait                                \n\
+			mcr p14, 0, %0, c0, c5, 0                   "
+	: : "r" (c) : "cc");
+}
+#endif

Please move the #ifdef conditionals inside the respective functions so to have only one function pair with the various alternatives embedded into them.

Quoted 7 lines
Quoted 3 lines

My typical clean up policy is do to the inverse of what your suggesting. Mainly because that's the method that I see used extensive in generic parts of the kernel.

Do you have an example? I don't see such thing in generic code, unless two versions of the same function are totally different. In this case you have only the inner inline asm code that is different.

These may not be the best examples but in include/linux/workqueue.h line 150, work_static() for instance if fully inside an ifdef. There is one other function example in that file, an one macro version. Also some in include/linux/ftrace.h , but in that case either the functions do something or nothing. ftrace.h is a little bit confsued, it has example of it your way and my way.

It doesn't appear to be a constant .. I see it your way and my way.

Quoted 8 lines
Quoted 2 lines

From my perspective there are pluses an minuses to both. Your method reduces lines, and duplication. My method makes the code easier to read.

I disagree. In reviewing your patch I had to go back and forth between the different versions just to figure out what was actually different to justify this #ifdef in the first place. If the #ifdef..#endif was surrounding only the different inline asm statements then the difference would have been more obvious.

You would have had to go back and forth either way , wouldn't you? In this case the functions are actually totally different.

Daniel

Signature · 3 lines
Sent by an consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum.
#5 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 6 lines · Daniel Walker
Quoted 5 lines · Nicolas Pitre
Quoted 2 lines · Daniel Walker

From my perspective there are pluses an minuses to both. Your method reduces lines, and duplication. My method makes the code easier to read.

Quoted 8 lines
Quoted 5 lines

I disagree. In reviewing your patch I had to go back and forth between the different versions just to figure out what was actually different to justify this #ifdef in the first place. If the #ifdef..#endif was surrounding only the different inline asm statements then the difference would have been more obvious.

You would have had to go back and forth either way , wouldn't you? In this case the functions are actually totally different.

static inline char
__dcc_getchar(void)

{
     char __c;
#if !defined(CONFIG_CPU_V7)
     asm("mrc p14, 0, %0, c0, c5, 0  @ read comms data reg"
             : "=r" (__c) : : "cc");
#else
     asm(
     "get_wait:      mrc p14, 0, pc, c0, c1, 0                       \n\
                     bne get_wait                                    \n\
                     mrc p14, 0, %0, c0, c5, 0       @ read comms data reg"
             : "=r" (__c) : : "cc");

#endif

     return __c;
}

static inline void
__dcc_putchar(char c)
{

#if !defined(CONFIG_CPU_V7)
     asm("mcr p14, 0, %0, c0, c5, 0  @ write a char"
             : /* no output register */
             : "r" (c) : "cc");
#else
     asm(
     "put_wait:      mrc p14, 0, pc, c0, c1, 0                   \n\
                     bcs put_wait                                \n\
                     mcr p14, 0, %0, c0, c5, 0                   "
     : : "r" (c) : "cc");

#endif
}

To me the above is easier to read. Not a big deal since the functions are rather small, but still an improvement. Searching for __dcc_putchar would produce a single hit, and if the prototype has to change it is done in only one place, etc.

BTW the cc clobber in the asm for __dcc_putchar() is unneeded.

Nicolas

#6 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 32 lines · Nicolas Pitre

static inline char
__dcc_getchar(void)

{
     char __c;
#if !defined(CONFIG_CPU_V7)
     asm("mrc p14, 0, %0, c0, c5, 0  @ read comms data reg"
             : "=r" (__c) : : "cc");
#else
     asm(
     "get_wait:      mrc p14, 0, pc, c0, c1, 0                       \n\
                     bne get_wait                                    \n\
                     mrc p14, 0, %0, c0, c5, 0       @ read comms data reg"
             : "=r" (__c) : : "cc");

#endif

     return __c;
}

static inline void
__dcc_putchar(char c)
{

#if !defined(CONFIG_CPU_V7)
     asm("mcr p14, 0, %0, c0, c5, 0  @ write a char"
             : /* no output register */
             : "r" (c) : "cc");
#else
     asm(
     "put_wait:      mrc p14, 0, pc, c0, c1, 0                   \n\
                     bcs put_wait                                \n\
                     mcr p14, 0, %0, c0, c5, 0                   "
     : : "r" (c) : "cc");
Quoted 7 lines

#endif
}

To me the above is easier to read. Not a big deal since the functions are rather small, but still an improvement. Searching for __dcc_putchar would produce a single hit, and if the prototype has to change it is done in only one place, etc.

It makes the internals of the function much more busy. There's more stuff that could be executing that you have to think about while reviewing the function.

Quoted 1 line

BTW the cc clobber in the asm for __dcc_putchar() is unneeded.

Without it caused a crash in __dcc_getchar() ..

Daniel

Signature · 3 lines
Sent by an consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum.
#7 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 37 lines · Daniel Walker
Quoted 35 lines · Nicolas Pitre

static inline char
__dcc_getchar(void)

{
     char __c;
#if !defined(CONFIG_CPU_V7)
     asm("mrc p14, 0, %0, c0, c5, 0  @ read comms data reg"
             : "=r" (__c) : : "cc");
#else
     asm(
     "get_wait:      mrc p14, 0, pc, c0, c1, 0                       \n\
                     bne get_wait                                    \n\
                     mrc p14, 0, %0, c0, c5, 0       @ read comms data reg"
             : "=r" (__c) : : "cc");

#endif

     return __c;
}

static inline void
__dcc_putchar(char c)
{

#if !defined(CONFIG_CPU_V7)
     asm("mcr p14, 0, %0, c0, c5, 0  @ write a char"
             : /* no output register */
             : "r" (c) : "cc");
#else
     asm(
     "put_wait:      mrc p14, 0, pc, c0, c1, 0                   \n\
                     bcs put_wait                                \n\
                     mcr p14, 0, %0, c0, c5, 0                   "
     : : "r" (c) : "cc");

#endif
}

Quoted 8 lines
Quoted 4 lines

To me the above is easier to read. Not a big deal since the functions are rather small, but still an improvement. Searching for __dcc_putchar would produce a single hit, and if the prototype has to change it is done in only one place, etc.

It makes the internals of the function much more busy. There's more stuff that could be executing that you have to think about while reviewing the function.

I still stand by my opinion that the above is better. Feel free to ignore me.

Quoted 3 lines
Quoted 1 line

BTW the cc clobber in the asm for __dcc_putchar() is unneeded.

Without it caused a crash in __dcc_getchar() ..

It is the wrong fix nevertheless. And in this case it isn't a question of opinion.

Nicolas

#8 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 2 lines · Nicolas Pitre

It is the wrong fix nevertheless. And in this case it isn't a question of opinion.

I'm not saying your wrong, I'm sure you know more about it than I do. I was just letting you know why I added it .

Daniel

Signature · 3 lines
Sent by an consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum.
#9 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 7 lines · Daniel Walker
Quoted 2 lines · Nicolas Pitre

It is the wrong fix nevertheless. And in this case it isn't a question of opinion.

I'm not saying your wrong, I'm sure you know more about it than I do. I was just letting you know why I added it .

Sure. However it is best to _understand_ why such things may apparently fix things. In this case it would have been by accident, and the code could be broken again with a different gcc version.

Adding "cc" in the clobber list is needed only when the asm code is modifying the condition flags.

I'd suggest you look at the disassembly difference with and without it. My guess is that the whole thing gets optimized away as there is no dependencies to be dependent on, in which case the proper fix would be to mark it with "volatile".

Nicolas

#10 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 14 lines · Nicolas Pitre
Quoted 7 lines · Daniel Walker
Quoted 2 lines · Nicolas Pitre

It is the wrong fix nevertheless. And in this case it isn't a question of opinion.

I'm not saying your wrong, I'm sure you know more about it than I do. I was just letting you know why I added it .

Sure. However it is best to _understand_ why such things may apparently fix things. In this case it would have been by accident, and the code could be broken again with a different gcc version.

Quoted 7 lines

Adding "cc" in the clobber list is needed only when the asm code is modifying the condition flags.

I'd suggest you look at the disassembly difference with and without it. My guess is that the whole thing gets optimized away as there is no dependencies to be dependent on, in which case the proper fix would be to mark it with "volatile".

Are you saying it's not needed for either the __dcc_putchar or __dcc_getchar ?

With __dcc_getchar() Jeff O. (who is CC'd) discovered that the assembly was setup in a way that assumed the condition bits were not touched, but since they did get touched we ended up missing a branch in dcc_rx_chars for checking if "tty" is set. Since we're branching in the assembly I'm assuming we must be setting condition bits with the mrc instruction.

So for __dcc_getchar it seems like it for sure is need ..

For __dcc_putchar I add "cc" also because again we're branching, so I'm assuming we're also setting condition bits.

Daniel

Signature · 3 lines
Sent by an consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum.
#11 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 18 lines · Daniel Walker
Quoted 17 lines · Nicolas Pitre
Quoted 7 lines · Daniel Walker
Quoted 2 lines · Nicolas Pitre

It is the wrong fix nevertheless. And in this case it isn't a question of opinion.

I'm not saying your wrong, I'm sure you know more about it than I do. I was just letting you know why I added it .

Sure. However it is best to _understand_ why such things may apparently fix things. In this case it would have been by accident, and the code could be broken again with a different gcc version.

Adding "cc" in the clobber list is needed only when the asm code is modifying the condition flags.

Quoted 7 lines
Quoted 4 lines

I'd suggest you look at the disassembly difference with and without it. My guess is that the whole thing gets optimized away as there is no dependencies to be dependent on, in which case the proper fix would be to mark it with "volatile".

Are you saying it's not needed for either the __dcc_putchar or __dcc_getchar ?

I'm saying that "CC" is unneeded in those cases where the condition flag is unmodified. Those are the !CONFIG_CPU_V7 cases.

Quoted 5 lines

With __dcc_getchar() Jeff O. (who is CC'd) discovered that the assembly was setup in a way that assumed the condition bits were not touched, but since they did get touched we ended up missing a branch in dcc_rx_chars for checking if "tty" is set. Since we're branching in the assembly I'm assuming we must be setting condition bits with the mrc instruction.

Yep.

Quoted 4 lines

So for __dcc_getchar it seems like it for sure is need ..

For __dcc_putchar I add "cc" also because again we're branching, so I'm assuming we're also setting condition bits.

I was talking about the non-branching cases.

Nicolas

#12 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 5 lines · Nicolas Pitre
Quoted 2 lines

Are you saying it's not needed for either the __dcc_putchar or __dcc_getchar ?

I'm saying that "CC" is unneeded in those cases where the condition flag is unmodified. Those are the !CONFIG_CPU_V7 cases.

Ok .. I can drop that stuff then.

Daniel

Signature · 3 lines
Sent by an consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum.
#13 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

In reply to Daniel Walker

Hi,

Quoted 36 lines · Daniel Walker
drivers/serial/dcc.c new file +36 -0
+#if !defined(CONFIG_CPU_V7)
+static inline char
+__dcc_getchar(void)
+{
+	char __c;
+
+	asm("mrc p14, 0, %0, c0, c5, 0	@ read comms data reg"
+		: "=r" (__c) : : "cc");
+
+	return __c;
+}
+#else
+static inline char
+__dcc_getchar(void)
+{
+	char __c;
+
+	asm(
+	"get_wait:	mrc p14, 0, pc, c0, c1, 0                   \n\
+			bne get_wait                                    \n\
+			mrc p14, 0, %0, c0, c5, 0	@ read comms data reg"
+		: "=r" (__c) : : "cc");
+
+	return __c;
+}
+#endif
+
+#if !defined(CONFIG_CPU_V7)
+static inline void
+__dcc_putchar(char c)
+{
+	asm("mcr p14, 0, %0, c0, c5, 0	@ write a char"
+		: /* no output register */
+		: "r" (c) : "cc");
+}
+#else

drivers/serial/dcc.c line 120

Quoted 10 lines
drivers/serial/dcc.c new file +10 -0
+static inline void
+__dcc_putchar(char c)
+{
+	asm(
+	"put_wait:	mrc p14, 0, pc, c0, c1, 0                   \n\
+			bcs put_wait                                \n\
+			mcr p14, 0, %0, c0, c5, 0                   "
+	: : "r" (c) : "cc");
+}
+#endif

Can you please pass the read and write functions to the driver in platform_data? We are already booting kernels with both ARMv6 and 7 compiled in.

Also, as it's a driver, other architectures may want to use it too.

Regards,

Tony

#14 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 3 lines · Tony Lindgren

Can you please pass the read and write functions to the driver in platform_data? We are already booting kernels with both ARMv6 and 7 compiled in.

What kind of situation did you want to use it in ? I was thinking about how arm could have these functions in a header file, that way we wouldn't duplicate in multiple places.

Quoted 1 line

Also, as it's a driver, other architectures may want to use it too.

I'm not sure if this model fits other architectures tho. They may not have the same read/write/status sorts of stuff. Atleast I don't know enough about other architectures jtags .

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#15 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 10 lines · Daniel Walker
Quoted 3 lines · Tony Lindgren

Can you please pass the read and write functions to the driver in platform_data? We are already booting kernels with both ARMv6 and 7 compiled in.

What kind of situation did you want to use it in ? I was thinking about how arm could have these functions in a header file, that way we wouldn't duplicate in multiple places.

Quoted 5 lines
Quoted 1 line

Also, as it's a driver, other architectures may want to use it too.

I'm not sure if this model fits other architectures tho. They may not have the same read/write/status sorts of stuff. Atleast I don't know enough about other architectures jtags .

This is ARM specific, and even not all ARM implementations have it.

Nicolas

#16 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 12 lines · Nicolas Pitre
Quoted 10 lines · Daniel Walker
Quoted 3 lines · Tony Lindgren

Can you please pass the read and write functions to the driver in platform_data? We are already booting kernels with both ARMv6 and 7 compiled in.

What kind of situation did you want to use it in ? I was thinking about how arm could have these functions in a header file, that way we wouldn't duplicate in multiple places.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Also, as it's a driver, other architectures may want to use it too.

I'm not sure if this model fits other architectures tho. They may not have the same read/write/status sorts of stuff. Atleast I don't know enough about other architectures jtags .

This is ARM specific, and even not all ARM implementations have it.

Are you sure? I thought DCC is JTAG specific standard?

Tony

#17 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 15 lines · Tony Lindgren
Quoted 14 lines · Nicolas Pitre
Quoted 12 lines · Daniel Walker
Quoted 3 lines · Tony Lindgren

Can you please pass the read and write functions to the driver in platform_data? We are already booting kernels with both ARMv6 and 7 compiled in.

What kind of situation did you want to use it in ? I was thinking about how arm could have these functions in a header file, that way we wouldn't duplicate in multiple places.

Quoted 1 line

Also, as it's a driver, other architectures may want to use it too.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I'm not sure if this model fits other architectures tho. They may not have the same read/write/status sorts of stuff. Atleast I don't know enough about other architectures jtags .

This is ARM specific, and even not all ARM implementations have it.

Are you sure? I thought DCC is JTAG specific standard?

Never mind, it seems like ARM specific scan chain.

Tony

#18 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

In reply to Tony Lindgren
Quoted 15 lines · Tony Lindgren
Quoted 14 lines · Nicolas Pitre
Quoted 12 lines · Daniel Walker
Quoted 3 lines · Tony Lindgren

Can you please pass the read and write functions to the driver in platform_data? We are already booting kernels with both ARMv6 and 7 compiled in.

What kind of situation did you want to use it in ? I was thinking about how arm could have these functions in a header file, that way we wouldn't duplicate in multiple places.

Quoted 1 line

Also, as it's a driver, other architectures may want to use it too.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I'm not sure if this model fits other architectures tho. They may not have the same read/write/status sorts of stuff. Atleast I don't know enough about other architectures jtags .

This is ARM specific, and even not all ARM implementations have it.

Are you sure?

Certainly.

Quoted 1 line

I thought DCC is JTAG specific standard?

Not at all. JTAG standard is a bit like Ethernet while DCC would be HTTP.

Nicolas

#19 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

In reply to Daniel Walker
Quoted 9 lines · Daniel Walker
Quoted 3 lines · Tony Lindgren

Can you please pass the read and write functions to the driver in platform_data? We are already booting kernels with both ARMv6 and 7 compiled in.

What kind of situation did you want to use it in ? I was thinking about how arm could have these functions in a header file, that way we wouldn't duplicate in multiple places.

Well with ifdef else it's still either or for kernels that have ARMv6 and 7 both compiled in. It's best to initialize those functions dynamically.

Regards,

Tony

#20 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

In reply to Tony Lindgren
Quoted 45 lines · Tony Lindgren

Hi,

Quoted 42 lines · Daniel Walker
drivers/serial/dcc.c new file +42 -0
+#if !defined(CONFIG_CPU_V7)
+static inline char
+__dcc_getchar(void)
+{
+	char __c;
+
+	asm("mrc p14, 0, %0, c0, c5, 0	@ read comms data reg"
+		: "=r" (__c) : : "cc");
+
+	return __c;
+}
+#else
+static inline char
+__dcc_getchar(void)
+{
+	char __c;
+
+	asm(
+	"get_wait:	mrc p14, 0, pc, c0, c1, 0                   \n\
+			bne get_wait                                    \n\
+			mrc p14, 0, %0, c0, c5, 0	@ read comms data reg"
+		: "=r" (__c) : : "cc");
+
+	return __c;
+}
+#endif
+
+#if !defined(CONFIG_CPU_V7)
+static inline void
+__dcc_putchar(char c)
+{
+	asm("mcr p14, 0, %0, c0, c5, 0	@ write a char"
+		: /* no output register */
+		: "r" (c) : "cc");
+}
+#else
+static inline void
+__dcc_putchar(char c)
+{
+	asm(
+	"put_wait:	mrc p14, 0, pc, c0, c1, 0                   \n\
+			bcs put_wait                                \n\
Quoted 8 lines

drivers/serial/dcc.c line 120

Quoted 4 lines
drivers/serial/dcc.c new file +4 -0
+			mcr p14, 0, %0, c0, c5, 0                   "
+	: : "r" (c) : "cc");
+}
+#endif

Can you please pass the read and write functions to the driver in platform_data? We are already booting kernels with both ARMv6 and 7 compiled in.

No. This has nothing to do with platform as this can be determined within the driver itself. Would be much better to simply determine which flavor to use at driver init time and assign two function pointers.

Nicolas

#21 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 9 lines · Nicolas Pitre
Quoted 4 lines · Tony Lindgren

Can you please pass the read and write functions to the driver in platform_data? We are already booting kernels with both ARMv6 and 7 compiled in.

No. This has nothing to do with platform as this can be determined within the driver itself. Would be much better to simply determine which flavor to use at driver init time and assign two function pointers.

In the long run some platform init code is needed for powering up the JTAG interface and take care of pin multiplexing etc.

Also, isn't DCC (Debug Communications Channel) a JTAG standard? At least the following does not say anything about DCC being ARM specific:

http://en.wikipedia.org/wiki/Joint_Test_Action_Group

BTW, we already have ETM (Embedded Trace Module) in arch/arm/kernel/etm.c. That is set up as amba driver.

Regards,

Tony

#22 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 14 lines · Tony Lindgren
Quoted 9 lines · Nicolas Pitre
Quoted 4 lines · Tony Lindgren

Can you please pass the read and write functions to the driver in platform_data? We are already booting kernels with both ARMv6 and 7 compiled in.

No. This has nothing to do with platform as this can be determined within the driver itself. Would be much better to simply determine which flavor to use at driver init time and assign two function pointers.

In the long run some platform init code is needed for powering up the JTAG interface and take care of pin multiplexing etc.

Quoted 7 lines

Also, isn't DCC (Debug Communications Channel) a JTAG standard? At least the following does not say anything about DCC being ARM specific:

http://en.wikipedia.org/wiki/Joint_Test_Action_Group

BTW, we already have ETM (Embedded Trace Module) in arch/arm/kernel/etm.c. That is set up as amba driver.

Hmm, then again it says this about the scan chains:

"SCAN_N ... ARM instruction to select the numbered scan chain used with EXTEST or INTEST. There are six scan chains"

Which seems like these scan chains are ARM specific.

Regards,

Tony

#23 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 23 lines · Tony Lindgren
Quoted 14 lines · Tony Lindgren
Quoted 9 lines · Nicolas Pitre
Quoted 4 lines · Tony Lindgren

Can you please pass the read and write functions to the driver in platform_data? We are already booting kernels with both ARMv6 and 7 compiled in.

No. This has nothing to do with platform as this can be determined within the driver itself. Would be much better to simply determine which flavor to use at driver init time and assign two function pointers.

In the long run some platform init code is needed for powering up the JTAG interface and take care of pin multiplexing etc.

Quoted 7 lines

Also, isn't DCC (Debug Communications Channel) a JTAG standard? At least the following does not say anything about DCC being ARM specific:

http://en.wikipedia.org/wiki/Joint_Test_Action_Group

BTW, we already have ETM (Embedded Trace Module) in arch/arm/kernel/etm.c. That is set up as amba driver.

Quoted 6 lines

Hmm, then again it says this about the scan chains:

"SCAN_N ... ARM instruction to select the numbered scan chain used with EXTEST or INTEST. There are six scan chains"

Which seems like these scan chains are ARM specific.

Or ETM specific even.

Nicolas

#24 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

In reply to Tony Lindgren
Quoted 7 lines · Tony Lindgren
Quoted 6 lines · Nicolas Pitre
Quoted 4 lines · Tony Lindgren

Can you please pass the read and write functions to the driver in platform_data? We are already booting kernels with both ARMv6 and 7 compiled in.

Quoted 6 lines
Quoted 3 lines

No. This has nothing to do with platform as this can be determined within the driver itself. Would be much better to simply determine which flavor to use at driver init time and assign two function pointers.

In the long run some platform init code is needed for powering up the JTAG interface and take care of pin multiplexing etc.

Really? That would be really strange and rather different from all the JTAG setups I've seen where the power-up of the interface is done externally i.e. controlled by the JTAG dongle.

Quoted 1 line

Also, isn't DCC (Debug Communications Channel) a JTAG standard?

No.

Quoted 4 lines

At least the following does not say anything about DCC being ARM specific:

http://en.wikipedia.org/wiki/Joint_Test_Action_Group

So called DCC may be part of an extension built on top of JTAG which is not "standardized". Each vendor implements their own extensions, which may or may not include something that can be described as DCC. The JTAG standard concerns itself with only the basic stuff in the full stack. You may have a look at OpenOCD to see how wildly different the debugging interfaces implemented on top of JTAG are.

Furthermore, the DCC access from within the target are implementation specific. In this case, it is a particular ARM coprocessor access, which as the patch shows is not even the same across all ARM versions. And that's valid only for those ARM flavors that implement the EmbeddedICE or CoreSight. On XScale, the debug facility built on top of the JTAG interface is completely different from the ARM Ltd one, relying mostly on software support injected in a special i-cache. In that case, the notion of a DCC would be implemented in software instead of relying on a specific hardware register, multiplexed with other messages sent over the JTAG interface.

Quoted 2 lines

BTW, we already have ETM (Embedded Trace Module) in arch/arm/kernel/etm.c. That is set up as amba driver.

That should be Embedded Trace Macrocell.

Nicolas

#25 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 13 lines · Nicolas Pitre
Quoted 11 lines · Tony Lindgren
Quoted 9 lines · Nicolas Pitre
Quoted 4 lines · Tony Lindgren

Can you please pass the read and write functions to the driver in platform_data? We are already booting kernels with both ARMv6 and 7 compiled in.

No. This has nothing to do with platform as this can be determined within the driver itself. Would be much better to simply determine which flavor to use at driver init time and assign two function pointers.

Quoted 6 lines
Quoted 2 lines

In the long run some platform init code is needed for powering up the JTAG interface and take care of pin multiplexing etc.

Really? That would be really strange and rather different from all the JTAG setups I've seen where the power-up of the interface is done externally i.e. controlled by the JTAG dongle.

Well on omaps JTAG is powered by the EMU powerdomain. The docs say it's software controllable or "automatically on JTAG plug detection". So yeah JTAG power may be automatic.

But the pin selection is board specific. Some boards may need to use the JTAG pins for GPIO etc.

Quoted 16 lines
Quoted 1 line

Also, isn't DCC (Debug Communications Channel) a JTAG standard?

No.

Quoted 4 lines

At least the following does not say anything about DCC being ARM specific:

http://en.wikipedia.org/wiki/Joint_Test_Action_Group

So called DCC may be part of an extension built on top of JTAG which is not "standardized". Each vendor implements their own extensions, which may or may not include something that can be described as DCC. The JTAG standard concerns itself with only the basic stuff in the full stack. You may have a look at OpenOCD to see how wildly different the debugging interfaces implemented on top of JTAG are.

Quoted 10 lines

Furthermore, the DCC access from within the target are implementation specific. In this case, it is a particular ARM coprocessor access, which as the patch shows is not even the same across all ARM versions. And that's valid only for those ARM flavors that implement the EmbeddedICE or CoreSight. On XScale, the debug facility built on top of the JTAG interface is completely different from the ARM Ltd one, relying mostly on software support injected in a special i-cache. In that case, the notion of a DCC would be implemented in software instead of relying on a specific hardware register, multiplexed with other messages sent over the JTAG interface.

Thanks for the info. Hmm, there seems to a section for XScale in arch/arm/kernel/debug.S for elif defined(CONFIG_CPU_XSCALE) for CONFIG_DEBUG_ICEDCC:

#elif defined(CONFIG_CPU_XSCALE)

.macro addruart, rx, tmp
.endm

.macro senduart, rd, rx
mcr p14, 0, \rd, c8, c0, 0
.endm

.macro busyuart, rd, rx
1001:

		mrc	p14, 0, \rx, c14, c0, 0
		tst	\rx, #0x10000000
		beq	1001b
		.endm

		.macro	waituart, rd, rx
		mov	\rd, #0x10000000
1001:
		subs	\rd, \rd, #1
		bmi	1002f
		mrc	p14, 0, \rx, c14, c0, 0
		tst	\rx, #0x10000000
		bne	1001b

1002:
.endm

#else

Is that broken for XScale then?

Regards,

Tony

#26 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 28 lines · Tony Lindgren

Thanks for the info. Hmm, there seems to a section for XScale in arch/arm/kernel/debug.S for elif defined(CONFIG_CPU_XSCALE) for CONFIG_DEBUG_ICEDCC:

#elif defined(CONFIG_CPU_XSCALE)

.macro addruart, rx, tmp
.endm

.macro senduart, rd, rx
mcr p14, 0, \rd, c8, c0, 0
.endm

.macro busyuart, rd, rx
1001:

		mrc	p14, 0, \rx, c14, c0, 0
		tst	\rx, #0x10000000
		beq	1001b
		.endm

		.macro	waituart, rd, rx
		mov	\rd, #0x10000000
1001:
		subs	\rd, \rd, #1
		bmi	1002f
		mrc	p14, 0, \rx, c14, c0, 0
		tst	\rx, #0x10000000
		bne	1001b
Quoted 6 lines

1002:
.endm

#else

Is that broken for XScale then?

Probably not broken, but simplistic. In a fully debug enabled setup, this channel is used to multiplex messages used by the special software on the target and the external debugger. In this case it is used for raw string output only.

For example, here's the code for the debugging stubs that gets injected into the target by OpenOCD:

http://openocd.git.sourceforge.net/git/gitweb.cgi?p=openocd/openocd;a=blob;f=src/target/xscale/debug_handler.S;h=73f3a9d5e44a87

Nicolas

#27 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

In reply to Daniel Walker
Quoted 10 lines · Daniel Walker

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.

Most of the code was taken from Hyok S. Choi original work, but the inline assmebly needed some work and updating. It now supports ARMv7. Also the description above is from Hyok also.

Sorry to join in late, but why would you want to make this a "serial" driver when it really is just a dumb tty.

I think you would be much better off making it a "hvc" driver, where you just need to provide a read character and write character function and an optional interrupt handler but otherwise have the common hvc code take care of polling the hardware and talking to the tty layer.

Arnd

#28 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 7 lines · Arnd Bergmann
Quoted 6 lines · Daniel Walker

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.

Quoted 7 lines
Quoted 4 lines

Most of the code was taken from Hyok S. Choi original work, but the inline assmebly needed some work and updating. It now supports ARMv7. Also the description above is from Hyok also.

Sorry to join in late, but why would you want to make this a "serial" driver when it really is just a dumb tty.

The code has been around since 2003 I think, and Hyok wrote (not me).. So I'm not sure why it's a serial driver. The only thing which I noted in a prior email is that it uses takes over ttyS optionally, so that might be part of the reason.

Quoted 4 lines

I think you would be much better off making it a "hvc" driver, where you just need to provide a read character and write character function and an optional interrupt handler but otherwise have the common hvc code take care of polling the hardware and talking to the tty layer.

I don't know what the "hvc" driver is "Hypervisor Virtual Console" maybe? Can you give any sort of example driver which does what you suggesting?

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#29 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 7 lines · On Wednesday 13 October 2010 18:17:03 Daniel Walker wrote:
Quoted 4 lines

I think you would be much better off making it a "hvc" driver, where you just need to provide a read character and write character function and an optional interrupt handler but otherwise have the common hvc code take care of polling the hardware and talking to the tty layer.

I don't know what the "hvc" driver is "Hypervisor Virtual Console" maybe?

Yes, it originally was used only on hypervisors that had simple read/write type consoles, but has now turned into a generic facility that is used by a number of consoles that don't look like classic serial ports.

Quoted 2 lines

Can you give any sort of example driver which does what you suggesting?

Look at drivers/char/hvc_tile.c for the simplest case or drivers/char/hvc_vio.c for one that uses interrupts.

Arnd

#30 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 14 lines · Arnd Bergmann
Quoted 7 lines · On Wednesday 13 October 2010 18:17:03 Daniel Walker wrote:
Quoted 4 lines

I think you would be much better off making it a "hvc" driver, where you just need to provide a read character and write character function and an optional interrupt handler but otherwise have the common hvc code take care of polling the hardware and talking to the tty layer.

I don't know what the "hvc" driver is "Hypervisor Virtual Console" maybe?

Yes, it originally was used only on hypervisors that had simple read/write type consoles, but has now turned into a generic facility that is used by a number of consoles that don't look like classic serial ports.

Quoted 5 lines
Quoted 2 lines

Can you give any sort of example driver which does what you suggesting?

Look at drivers/char/hvc_tile.c for the simplest case or drivers/char/hvc_vio.c for one that uses interrupts.

I found it independently actually .. It looks like there's at least two problems. This jtag driver has a status register which flags when RX is available, and TX is possible. I'm not sure this status register fits into the model. The other thing is that we have a ttyJ registered for this driver, and it would be nice to use that over something like ttyHVC (I'm not sure if that name is correct, just a guess).

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#31 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 18 lines · On Wednesday 13 October 2010 20:08:35 Daniel Walker wrote:
Quoted 17 lines · Arnd Bergmann
Quoted 7 lines · On Wednesday 13 October 2010 18:17:03 Daniel Walker wrote:
Quoted 4 lines

I think you would be much better off making it a "hvc" driver, where you just need to provide a read character and write character function and an optional interrupt handler but otherwise have the common hvc code take care of polling the hardware and talking to the tty layer.

I don't know what the "hvc" driver is "Hypervisor Virtual Console" maybe?

Yes, it originally was used only on hypervisors that had simple read/write type consoles, but has now turned into a generic facility that is used by a number of consoles that don't look like classic serial ports.

Quoted 2 lines

Can you give any sort of example driver which does what you suggesting?

Quoted 7 lines
Quoted 2 lines

Look at drivers/char/hvc_tile.c for the simplest case or drivers/char/hvc_vio.c for one that uses interrupts.

I found it independently actually .. It looks like there's at least two problems. This jtag driver has a status register which flags when RX is available, and TX is possible. I'm not sure this status register fits into the model.

I think that is how they all work. The read/write functions simply return the number of characters transferred, which may be zero if the output is busy or the input is empty.

Quoted 3 lines

The other thing is that we have a ttyJ registered for
this driver, and it would be nice to use that over something like ttyHVC (I'm not sure if that name is correct, just a guess).

It's hvc0, but I don't see this as a problem because the driver was never upstream before -- you don't really get to complain about compatibility with out-of-tree code :-)

Seriously, I don't think you need it, but if you really do, we can probably find a way to work around this by changing the base hvc driver.

Arnd

#32 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 31 lines · Arnd Bergmann
Quoted 18 lines · On Wednesday 13 October 2010 20:08:35 Daniel Walker wrote:
Quoted 17 lines · Arnd Bergmann
Quoted 7 lines · On Wednesday 13 October 2010 18:17:03 Daniel Walker wrote:
Quoted 4 lines

I think you would be much better off making it a "hvc" driver, where you just need to provide a read character and write character function and an optional interrupt handler but otherwise have the common hvc code take care of polling the hardware and talking to the tty layer.

I don't know what the "hvc" driver is "Hypervisor Virtual Console" maybe?

Yes, it originally was used only on hypervisors that had simple read/write type consoles, but has now turned into a generic facility that is used by a number of consoles that don't look like classic serial ports.

Quoted 2 lines

Can you give any sort of example driver which does what you suggesting?

Quoted 7 lines
Quoted 2 lines

Look at drivers/char/hvc_tile.c for the simplest case or drivers/char/hvc_vio.c for one that uses interrupts.

I found it independently actually .. It looks like there's at least two problems. This jtag driver has a status register which flags when RX is available, and TX is possible. I'm not sure this status register fits into the model.

I think that is how they all work. The read/write functions simply return the number of characters transferred, which may be zero if the output is busy or the input is empty.

Quoted 7 lines
Quoted 3 lines

The other thing is that we have a ttyJ registered for
this driver, and it would be nice to use that over something like ttyHVC (I'm not sure if that name is correct, just a guess).

It's hvc0, but I don't see this as a problem because the driver was never upstream before -- you don't really get to complain about compatibility with out-of-tree code :-)

I'm complaining about naming issues, not compatibility.

Quoted 2 lines

Seriously, I don't think you need it, but if you really do, we can probably find a way to work around this by changing the base hvc driver.

I think we would have to add something that allows different major/minor numbers, because something that includes the name "Hypervisor" shouldn't be used for something general.. /dev/hvcX is also registered for "IBM iSeries/pSeries virtual console" (according to www.lanana.org) which is confusing ..

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#33 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 8 lines · On Wednesday 13 October 2010 21:52:02 Daniel Walker wrote:
Quoted 2 lines

Seriously, I don't think you need it, but if you really do, we can probably find a way to work around this by changing the base hvc driver.

I think we would have to add something that allows different major/minor numbers, because something that includes the name "Hypervisor" shouldn't be used for something general.. /dev/hvcX is also registered for "IBM iSeries/pSeries virtual console" (according to www.lanana.org) which is confusing ..

That only means we need to update the lanana entry now that the hvc driver is used on nine different platforms (not including yours) instead of ust pSeries. Feel free to come up with a backronym for HVC if you're uncomfortable with the old "hypervisor console" name.

Arnd

#34 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · On Wednesday 13 October 2010 21:52:02 Daniel Walker wrote:
Quoted 2 lines

Seriously, I don't think you need it, but if you really do, we can probably find a way to work around this by changing the base hvc driver.

I think we would have to add something that allows different major/minor numbers, because something that includes the name "Hypervisor" shouldn't be used for something general.. /dev/hvcX is also registered for "IBM iSeries/pSeries virtual console" (according to www.lanana.org) which is confusing ..

Quoted 4 lines

That only means we need to update the lanana entry now that the hvc driver is used on nine different platforms (not including yours) instead of ust pSeries. Feel free to come up with a backronym for HVC if you're uncomfortable with the old "hypervisor console" name.

If you read back in this thread you'll see how there was a discussion already on how you shouldn't re-use major/minor numbers for other purposes .. It looks like "hvc" was essentially overridden , which now seems like a no-no given that discussion.. This appears to be a sensitive topic.

It can't hurt anything to make this hvc driver a little more flexible in this regard ..

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#35 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 16 lines · Daniel Walker
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · On Wednesday 13 October 2010 21:52:02 Daniel Walker wrote:
Quoted 2 lines

Seriously, I don't think you need it, but if you really do, we can probably find a way to work around this by changing the base hvc driver.

I think we would have to add something that allows different major/minor numbers, because something that includes the name "Hypervisor" shouldn't be used for something general.. /dev/hvcX is also registered for "IBM iSeries/pSeries virtual console" (according to www.lanana.org) which is confusing ..

Quoted 4 lines

That only means we need to update the lanana entry now that the hvc driver is used on nine different platforms (not including yours) instead of ust pSeries. Feel free to come up with a backronym for HVC if you're uncomfortable with the old "hypervisor console" name.

Quoted 5 lines

If you read back in this thread you'll see how there was a discussion already on how you shouldn't re-use major/minor numbers for other purposes .. It looks like "hvc" was essentially overridden , which now seems like a no-no given that discussion.. This appears to be a sensitive topic.

And I violently disagree with this interpretation.

The tty layer was probably the first subsystem to have been implemented in Linux. There are a big deal of legacy with its device naming. When adding new subsystems we don't need to perpetuate this. Maybe that made sense 20 years ago, but let's leave ttyS0 alone and use good sense for new stuff.

Nicolas

#36 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 24 lines · Nicolas Pitre
Quoted 16 lines · Daniel Walker
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · On Wednesday 13 October 2010 21:52:02 Daniel Walker wrote:
Quoted 2 lines

Seriously, I don't think you need it, but if you really do, we can probably find a way to work around this by changing the base hvc driver.

I think we would have to add something that allows different major/minor numbers, because something that includes the name "Hypervisor" shouldn't be used for something general.. /dev/hvcX is also registered for "IBM iSeries/pSeries virtual console" (according to www.lanana.org) which is confusing ..

Quoted 4 lines

That only means we need to update the lanana entry now that the hvc driver is used on nine different platforms (not including yours) instead of ust pSeries. Feel free to come up with a backronym for HVC if you're uncomfortable with the old "hypervisor console" name.

Quoted 5 lines

If you read back in this thread you'll see how there was a discussion already on how you shouldn't re-use major/minor numbers for other purposes .. It looks like "hvc" was essentially overridden , which now seems like a no-no given that discussion.. This appears to be a sensitive topic.

Quoted 7 lines

And I violently disagree with this interpretation.

The tty layer was probably the first subsystem to have been implemented in Linux. There are a big deal of legacy with its device naming. When adding new subsystems we don't need to perpetuate this. Maybe that made sense 20 years ago, but let's leave ttyS0 alone and use good sense for new stuff.

Your still confusing me here Nico .. It seems like your suggesting adding new overrides is not OK , yet your also saying it is ok ?

Are you saying overrides are OK for anything other than ttyS ?

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#37 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 27 lines · Daniel Walker
Quoted 26 lines · Nicolas Pitre
Quoted 16 lines · Daniel Walker
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · On Wednesday 13 October 2010 21:52:02 Daniel Walker wrote:
Quoted 2 lines

Seriously, I don't think you need it, but if you really do, we can probably find a way to work around this by changing the base hvc driver.

I think we would have to add something that allows different major/minor numbers, because something that includes the name "Hypervisor" shouldn't be used for something general.. /dev/hvcX is also registered for "IBM iSeries/pSeries virtual console" (according to www.lanana.org) which is confusing ..

Quoted 4 lines

That only means we need to update the lanana entry now that the hvc driver is used on nine different platforms (not including yours) instead of ust pSeries. Feel free to come up with a backronym for HVC if you're uncomfortable with the old "hypervisor console" name.

Quoted 5 lines

If you read back in this thread you'll see how there was a discussion already on how you shouldn't re-use major/minor numbers for other purposes .. It looks like "hvc" was essentially overridden , which now seems like a no-no given that discussion.. This appears to be a sensitive topic.

And I violently disagree with this interpretation.

Quoted 8 lines
Quoted 5 lines

The tty layer was probably the first subsystem to have been implemented in Linux. There are a big deal of legacy with its device naming. When adding new subsystems we don't need to perpetuate this. Maybe that made sense 20 years ago, but let's leave ttyS0 alone and use good sense for new stuff.

Your still confusing me here Nico .. It seems like your suggesting adding new overrides is not OK , yet your also saying it is ok ?

What I'm saying is:

1) The hvc layer is there so it is best if the DCC support uses it. Until today I didn't know it existed either, but it offers a higher level of abstraction that the DCC support can use.

2) That level of abstraction already has its device namespace and it is perfectly fine to reuse it across different low-level drivers, just like SCSI and ATA/SATA disk drives are sharing the same namespace these days. There used to be a separate namespace for ATA drives but this is now history.

3) All serial drivers could have migrated to a uniform device node namespace when RMK revamped support for serial devices, with dynamic allocation just like everything else. Unlike for IDE disks, this didn't happen unfortunately because some people couldn't get over a possible device name change (I wonder how they survived the transition to libata).

So if the hvc code has now turned into an abstraction layer that supports multiple different devices while still sharing the same device namespace I think this is perfect.

So I'm suggesting that the DCC driver be moved to the hvc subsystem. And I don't mind if the hvc is reusing the same namespace for different devices. That is what should have happened on a larger scale for all serial devices long ago.

If you _insist_ on having a different device name for the DCC port then it's probably saner to add that ability to the hvc code than keeping a separate serial driver. But I personally really don't care at that point.

Nicolas

#38 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 3 lines · Nicolas Pitre

3) All serial drivers could have migrated to a uniform device node namespace when RMK revamped support for serial devices, with dynamic allocation just like everything else.

Wrong. There was no dynamic allocation, because the layer above did not support it.

Quoted 4 lines

Unlike for IDE disks, this
didn't happen unfortunately because some people couldn't get over a possible device name change (I wonder how they survived the transition to libata).

I was not, and still am firmly of the opinion that my decision was the right one to reject your "approach" to forcefully unifying the serial devices. It was more of a hack, introducing multiple special cases for the old 8250-style ports to make it half sort of work.

Until the tty layer gets fixed so that it doesn't need to be told that there will be N tty ports attached to D tty driver at the point in time when D is registered with the tty subsystem, my opinion on this isn't going to change. This is why your patches needed to special case the 8250 driver - so it could register the right number of 'ttyS' ports.

And to prove the point that my decision was right, the way support for ttyS port space has gone, there's been an overwhelming desire to reduce the number of ttyS ports down to the bare minimum - for common setups to four at the most. That'll require yet more special casing to make your idea work.

The big difference between this and SCSI is that SCSI was built from day one separate the functional drivers from the backing hardware drivers - which is great when there's an adhered to standard protocol which everyone follows. Again, that's not really the case with serial. SCSI has also had from day one the ability to dynamically register and unregister hosts and disks in any order, expanding on the fly with no problem. That's certainly not the case with the tty subsystem.

Get over it. Comparing tty with SCSI is absurdly stupid when they're vastly different beasts.

#39 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 13 lines · Russell King - ARM Linux
Quoted 3 lines · Nicolas Pitre

3) All serial drivers could have migrated to a uniform device node namespace when RMK revamped support for serial devices, with dynamic allocation just like everything else.

Wrong. There was no dynamic allocation, because the layer above did not support it.

Quoted 4 lines

Unlike for IDE disks, this
didn't happen unfortunately because some people couldn't get over a possible device name change (I wonder how they survived the transition to libata).

Quoted 5 lines

I was not, and still am firmly of the opinion that my decision was the right one to reject your "approach" to forcefully unifying the serial devices. It was more of a hack, introducing multiple special cases for the old 8250-style ports to make it half sort of work.

I didn't say my patch was right. But I still think that the general idea, which obviously needed more work, was right. But people didn't even agree on the idea.

Quoted 4 lines

Until the tty layer gets fixed so that it doesn't need to be told that there will be N tty ports attached to D tty driver at the point in time when D is registered with the tty subsystem, my opinion on this isn't going to change.

I totally agree. But that's beside my point. People even didn't agree on the idea that serial port _could_ have dynamically assigned device nodes. In that context there is no point "fixing" the tty layer. That's orthogonal to the work you did on unifying serial support as much as possible which was excellent.

Nicolas

#40 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

In reply to Daniel Walker
Quoted 21 lines · Daniel Walker
Quoted 14 lines · Arnd Bergmann
Quoted 7 lines · On Wednesday 13 October 2010 18:17:03 Daniel Walker wrote:
Quoted 4 lines

I think you would be much better off making it a "hvc" driver, where you just need to provide a read character and write character function and an optional interrupt handler but otherwise have the common hvc code take care of polling the hardware and talking to the tty layer.

I don't know what the "hvc" driver is "Hypervisor Virtual Console" maybe?

Yes, it originally was used only on hypervisors that had simple read/write type consoles, but has now turned into a generic facility that is used by a number of consoles that don't look like classic serial ports.

Quoted 5 lines
Quoted 2 lines

Can you give any sort of example driver which does what you suggesting?

Look at drivers/char/hvc_tile.c for the simplest case or drivers/char/hvc_vio.c for one that uses interrupts.

Quoted 6 lines

I found it independently actually .. It looks like there's at least two problems. This jtag driver has a status register which flags when RX is available, and TX is possible. I'm not sure this status register fits into the model. The other thing is that we have a ttyJ registered for this driver, and it would be nice to use that over something like ttyHVC (I'm not sure if that name is correct, just a guess).

Really? Is there a compelling reason to perpetuate this serial device namespace fragmentation nonsense? Your initial patch even had a config option to hijack /dev/ttyS0 because of that.

Nicolas

#41 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 10 lines · Nicolas Pitre
Quoted 6 lines

I found it independently actually .. It looks like there's at least two problems. This jtag driver has a status register which flags when RX is available, and TX is possible. I'm not sure this status register fits into the model. The other thing is that we have a ttyJ registered for this driver, and it would be nice to use that over something like ttyHVC (I'm not sure if that name is correct, just a guess).

Really? Is there a compelling reason to perpetuate this serial device namespace fragmentation nonsense? Your initial patch even had a config option to hijack /dev/ttyS0 because of that.

I'm not sure how to interpret what your saying .. Are you saying we should use /dev/hvcX or shouldn't ? the reason I want to use ttyJ is because it was assigned specifically for jtags which, to me, makes things a lot less confusing.

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#42 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 8 lines · Daniel Walker
Quoted 7 lines · Nicolas Pitre
Quoted 6 lines

I found it independently actually .. It looks like there's at least two problems. This jtag driver has a status register which flags when RX is available, and TX is possible. I'm not sure this status register fits into the model. The other thing is that we have a ttyJ registered for this driver, and it would be nice to use that over something like ttyHVC (I'm not sure if that name is correct, just a guess).

Quoted 6 lines
Quoted 3 lines

Really? Is there a compelling reason to perpetuate this serial device namespace fragmentation nonsense? Your initial patch even had a config option to hijack /dev/ttyS0 because of that.

I'm not sure how to interpret what your saying .. Are you saying we should use /dev/hvcX or shouldn't ?

Long ago I fought for a uniform namespace for serial ports and alike with dynamically assigned names, just like we do for network interfaces, for disks, for USB devices, etc. so we'd stop making this hack that everybody is doing in their own trees which is to hijack /dev/ttyS0, or perpetuate this proliferation of serial/tty device names. This obviously didn't happen, for "legacy" reasons (people insisted on having their 0x2f8 serial port appear as ttyS1 and not ttyS0).

Quoted 2 lines

the reason I want to use ttyJ is because it was assigned specifically for jtags which, to me, makes things a lot less confusing.

Why did the patch have a config option to use ttyS0 then?

Anyway, given that the hvc layer is there and would simplify the DCC driver, I think it is a good idea to leverage it instead of duplicating and faking tty handling yet again. Maybe extending the generic hvc code to optionally accept alternate device registration could be considered instead if you really want a ttyJ device.

Nicolas

#43 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 25 lines · Nicolas Pitre
Quoted 8 lines · Daniel Walker
Quoted 7 lines · Nicolas Pitre
Quoted 6 lines

I found it independently actually .. It looks like there's at least two problems. This jtag driver has a status register which flags when RX is available, and TX is possible. I'm not sure this status register fits into the model. The other thing is that we have a ttyJ registered for this driver, and it would be nice to use that over something like ttyHVC (I'm not sure if that name is correct, just a guess).

Quoted 6 lines
Quoted 3 lines

Really? Is there a compelling reason to perpetuate this serial device namespace fragmentation nonsense? Your initial patch even had a config option to hijack /dev/ttyS0 because of that.

I'm not sure how to interpret what your saying .. Are you saying we should use /dev/hvcX or shouldn't ?

Long ago I fought for a uniform namespace for serial ports and alike with dynamically assigned names, just like we do for network interfaces, for disks, for USB devices, etc. so we'd stop making this hack that everybody is doing in their own trees which is to hijack /dev/ttyS0, or perpetuate this proliferation of serial/tty device names. This obviously didn't happen, for "legacy" reasons (people insisted on having their 0x2f8 serial port appear as ttyS1 and not ttyS0).

Quoted 4 lines
Quoted 2 lines

the reason I want to use ttyJ is because it was assigned specifically for jtags which, to me, makes things a lot less confusing.

Why did the patch have a config option to use ttyS0 then?

I don't know exactly why .. Hyok wrote it and I assume there was a good reason for it, but he's not responding to tell us what it was..

Quoted 5 lines

Anyway, given that the hvc layer is there and would simplify the DCC driver, I think it is a good idea to leverage it instead of duplicating and faking tty handling yet again. Maybe extending the generic hvc code to optionally accept alternate device registration could be considered instead if you really want a ttyJ device.

That's what I was suggesting to Arng .. We should extend hvc to allow other major/minor devices.

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#44 lore raw

PATCH 1/1 serial: DCC(JTAG) serial and console emulation support

Quoted 2 lines · Daniel Walker

That's what I was suggesting to Arng .. We should extend hvc to allow other major/minor devices.

I mean, Arnd here.. Sorry for the typo..

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.