Skip to contentSkip to conversation

PATCH: ixp42x UART: support 230400bps, enable RTS

U-Boot-Users New Michael Schwingen 5 participants 13 messages Nov 10, 2007 – Jan 11, 2008

lore
Share & tools
lore
#0 lore raw

Hi,

the following patch
- adds support for 230400bps
- enables the RTS signal. No handshaking is done, but the active RTS signal allows to connect to the target using a PC which is using RTS/CTS handshake, and does no harm if the PC is set to ignore RTS.

cpu/ixp/serial.c +3 -0
index 2015958..e0f56fe 100644
@@ -50,6 +50,8 @@ void serial_setbrg (void)
 		quot = 16;
 	else if (gd->baudrate == 115200)
 		quot = 8;
+	else if (gd->baudrate == 230400)
+		quot = 4;
 	else
 		hang ();
 
@@ -61,6 +63,7 @@ void serial_setbrg (void)
 	DLL(uart) = quot & 0xff;
 	DLH(uart) = quot >> 8;
 	LCR(uart) = LCR_WLS0 | LCR_WLS1;
+	MCR(uart) = MCR_RTS;				/* set RTS active */
 
 	IER(uart) = IER_UUE;
 }
#1 lore raw
Quoted 24 lines · Michael Schwingen

Hi,

the following patch
- adds support for 230400bps
- enables the RTS signal. No handshaking is done, but the active RTS signal allows to connect to the target using a PC which is using RTS/CTS handshake, and does no harm if the PC is set to ignore RTS.

cpu/ixp/serial.c +2 -0
index 2015958..e0f56fe 100644
@@ -50,6 +50,8 @@ void serial_setbrg (void)
 		quot = 16;
 	else if (gd->baudrate == 115200)
 		quot = 8;
+	else if (gd->baudrate == 230400)
+		quot = 4;
 	else
 		hang ();
 

cpu/ixp/serial.c void serial_setbrg (void) · line 69

Quoted 7 lines
cpu/ixp/serial.c +1 -0
@@ -61,6 +63,7 @@ void serial_setbrg (void)
 	DLL(uart) = quot & 0xff;
 	DLH(uart) = quot >> 8;
 	LCR(uart) = LCR_WLS0 | LCR_WLS1;
+	MCR(uart) = MCR_RTS;				/* set RTS active */
 
 	IER(uart) = IER_UUE;
 }

Hi,

2 points about this patch

1) I will send a patch to support all baud rates for ipx42x, ixp45x and ixp46x

2) Cou you make the RTS part configurable by a MACRO like CONFIG_SERIAL_RTS?

Best Regards,
J.

#2 lore raw

PATCH 1/1 IXP: Add full baud-rate support for ixp42x, ixp45x and ixp46x

cpu/ixp/serial.c +10 -14
index 2015958..1f13077 100644
@@ -31,25 +31,22 @@
 #include <common.h>
 #include <asm/arch/ixp425.h>
 
+/*
+ *               14.7456 MHz
+ * Baud Rate = --------------
+ *              16 x Divisor
+ */
+#define SERIAL_CLOCK 921600 
+
 DECLARE_GLOBAL_DATA_PTR;
 
 void serial_setbrg (void)
 {
 	unsigned int quot = 0;
 	int uart = CFG_IXP425_CONSOLE;
-
-	if (gd->baudrate == 1200)
-		quot = 192;
-	else if (gd->baudrate == 9600)
-		quot = 96;
-	else if (gd->baudrate == 19200)
-		quot = 48;
-	else if (gd->baudrate == 38400)
-		quot = 24;
-	else if (gd->baudrate == 57600)
-		quot = 16;
-	else if (gd->baudrate == 115200)
-		quot = 8;
+	
+	if(gd->baudrate < SERIAL_CLOCK && SERIAL_CLOCK % gd->baudrate == 0)
+		quot = SERIAL_CLOCK / gd->baudrate;
 	else
 		hang ();
 
@@ -65,7 +62,6 @@ void serial_setbrg (void)
 	IER(uart) = IER_UUE;
 }
 
-
 /*
  * Initialise the serial port with the given baudrate. The settings
  * are always 8 data bits, no parity, 1 stop bit, no start bits.
Signature · 1 line
1.5.3.7
#3 lore raw

PATCH 1/1 IXP: Add full baud-rate support for ixp42x, ixp45x and ixp46x

Quoted 28 lines · Jean-Christophe PLAGNIOL-VILLARD
cpu/ixp/serial.c +7 -5
index 2015958..1f13077 100644
@@ -31,25 +31,22 @@
 #include <common.h>
 #include <asm/arch/ixp425.h>
 
+/*
+ *               14.7456 MHz
+ * Baud Rate = --------------
+ *              16 x Divisor
+ */
+#define SERIAL_CLOCK 921600
+
 DECLARE_GLOBAL_DATA_PTR;
 
 void serial_setbrg (void)
 {
 	unsigned int quot = 0;
 	int uart = CFG_IXP425_CONSOLE;
-
-	if (gd->baudrate == 1200)
-		quot = 192;
-	else if (gd->baudrate == 9600)
-		quot = 96;

cpu/ixp/serial.c line 48

Quoted 10 lines
cpu/ixp/serial.c +2 -8
-	else if (gd->baudrate == 19200)
-		quot = 48;
-	else if (gd->baudrate == 38400)
-		quot = 24;
-	else if (gd->baudrate == 57600)
-		quot = 16;
-	else if (gd->baudrate == 115200)
-		quot = 8;
+
+	if(gd->baudrate < SERIAL_CLOCK && SERIAL_CLOCK % gd->baudrate == 0)

Space after "if" please. And some braces would make this line more readable.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================

#4 lore raw

PATCH 1/1 IXP: Add full baud-rate support for ixp42x, ixp45x and ixp46x

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 29 lines · In message <[email protected]> you wrote:
cpu/ixp/serial.c +7 -6
index 2015958..1f13077 100644
@@ -31,25 +31,22 @@
 #include <common.h>
 #include <asm/arch/ixp425.h>
 
+/*
+ *               14.7456 MHz
+ * Baud Rate = --------------
+ *              16 x Divisor
+ */
+#define SERIAL_CLOCK 921600 
+
 DECLARE_GLOBAL_DATA_PTR;
 
 void serial_setbrg (void)
 {
 	unsigned int quot = 0;
 	int uart = CFG_IXP425_CONSOLE;
-
-	if (gd->baudrate == 1200)
-		quot = 192;
-	else if (gd->baudrate == 9600)
-		quot = 96;
-	else if (gd->baudrate == 19200)

cpu/ixp/serial.c line 49

Quoted 10 lines
cpu/ixp/serial.c +3 -7
-		quot = 48;
-	else if (gd->baudrate == 38400)
-		quot = 24;
-	else if (gd->baudrate == 57600)
-		quot = 16;
-	else if (gd->baudrate == 115200)
-		quot = 8;
+	
+	if(gd->baudrate < SERIAL_CLOCK && SERIAL_CLOCK % gd->baudrate == 0)
+		quot = SERIAL_CLOCK / gd->baudrate;

Is it correct to assume that the old "quot" for 1200 bps was actually wrong, and you now fix this?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The trouble with our times is that the future is not what it used  to
be.                                                     - Paul Valery
#5 lore raw

PATCH 1/1 IXP: Add full baud-rate support for ixp42x, ixp45x and ixp46x

Quoted 31 lines · Wolfgang Denk
Quoted 30 lines · In message <[email protected]> you wrote:
cpu/ixp/serial.c +7 -7
index 2015958..1f13077 100644
@@ -31,25 +31,22 @@
 #include <common.h>
 #include <asm/arch/ixp425.h>
 
+/*
+ *               14.7456 MHz
+ * Baud Rate = --------------
+ *              16 x Divisor
+ */
+#define SERIAL_CLOCK 921600 
+
 DECLARE_GLOBAL_DATA_PTR;
 
 void serial_setbrg (void)
 {
 	unsigned int quot = 0;
 	int uart = CFG_IXP425_CONSOLE;
-
-	if (gd->baudrate == 1200)
-		quot = 192;
-	else if (gd->baudrate == 9600)
-		quot = 96;
-	else if (gd->baudrate == 19200)
-		quot = 48;
Quoted 8 lines

cpu/ixp/serial.c line 48

Quoted 8 lines
cpu/ixp/serial.c +2 -6
-	else if (gd->baudrate == 38400)
-		quot = 24;
-	else if (gd->baudrate == 57600)
-		quot = 16;
-	else if (gd->baudrate == 115200)
-		quot = 8;
+	
+	if(gd->baudrate < SERIAL_CLOCK && SERIAL_CLOCK % gd->baudrate == 0)

there is a missing '='

	if(gd->baudrate <= SERIAL_CLOCK && SERIAL_CLOCK % gd->baudrate == 0)
Quoted 4 lines

cpu/ixp/serial.c line 49

Quoted 1 line
cpu/ixp/serial.c +1 -0
+		quot = SERIAL_CLOCK / gd->baudrate;

Is it correct to assume that the old "quot" for 1200 bps was actually wrong, and you now fix this?

Yes you're right, according to the cpu datasheet the quot for 1200 must be 768 and not 192

Best Regards,
J.

#6 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD

2 points about this patch

1) I will send a patch to support all baud rates for ipx42x, ixp45x and ixp46x

Great!

Quoted 3 lines

2) Cou you make the RTS part configurable by a MACRO like CONFIG_SERIAL_RTS?

Is this really necessary? I do not like to add configuration switches for stuff that does not need to be configurable. It is not like we are adding full hardware handshake ...

Currently, RTS is always inactive, so it must be ignored by anyone talking to such a target board.

If we make RTS always active, this should cause no harm, but make it possible to talk to the board using a terminal program that has RTS/CTS handshaking activated.

cu
Michael

#7 lore raw
Quoted 8 lines · Michael Schwingen
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD

2) Cou you make the RTS part configurable by a MACRO like CONFIG_SERIAL_RTS?

Is this really necessary? I do not like to add configuration switches for stuff that does not need to be configurable. It is not like we are adding full hardware handshake ...

Quoted 6 lines

Currently, RTS is always inactive, so it must be ignored by anyone talking to such a target board.

If we make RTS always active, this should cause no harm, but make it possible to talk to the board using a terminal program that has RTS/CTS handshaking activated.

I've already have problem when using usb <=> serial device when you have RTS active on the board and not on the Host.

Best Regards,
J.

#8 lore raw
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD

I've already have problem when using usb <=> serial device when you have RTS active on the board and not on the Host.

Hm - one more reason why I don't like those USB-RS232 thingies. Okay, I'll make it conditional then.

cu
Michael

#9 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 6 lines · Jean-Christophe PLAGNIOL-VILLARD

2 points about this patch

1) I will send a patch to support all baud rates for ipx42x, ixp45x and ixp46x

2) Cou you make the RTS part configurable by a MACRO like CONFIG_SERIAL_RTS?

Okay - how about this:

cpu/ixp/serial.c +4 -1
index 62b1f24..190641a 100644
@@ -63,8 +63,11 @@ void serial_setbrg (void)
 	DLL(uart) = quot & 0xff;
 	DLH(uart) = quot >> 8;
 	LCR(uart) = LCR_WLS0 | LCR_WLS1;
+#ifdef CONFIG_SERIAL_RTS_ACTIVE
 	MCR(uart) = MCR_RTS;				/* set RTS active */
-
+#else
+	MCR(uart) = 0;					/* set RTS inactive */
+#endif
 	IER(uart) = IER_UUE;
 }
 

This also adds code to initialize RTS to off in case you did not set CONFIG_SERIAL_RTS_ACTIVE.

cu
Michael

#10 lore raw
Quoted 29 lines · Michael Schwingen
Quoted 6 lines · Jean-Christophe PLAGNIOL-VILLARD

2 points about this patch

1) I will send a patch to support all baud rates for ipx42x, ixp45x and ixp46x

2) Cou you make the RTS part configurable by a MACRO like CONFIG_SERIAL_RTS?

Okay - how about this:

cpu/ixp/serial.c +4 -1
index 62b1f24..190641a 100644
@@ -63,8 +63,11 @@ void serial_setbrg (void)
 	DLL(uart) = quot & 0xff;
 	DLH(uart) = quot >> 8;
 	LCR(uart) = LCR_WLS0 | LCR_WLS1;
+#ifdef CONFIG_SERIAL_RTS_ACTIVE
 	MCR(uart) = MCR_RTS;				/* set RTS active */
-
+#else
+	MCR(uart) = 0;					/* set RTS inactive */
+#endif
 	IER(uart) = IER_UUE;
 }
 
Quoted 2 lines

This also adds code to initialize RTS to off in case you did not set CONFIG_SERIAL_RTS_ACTIVE.

Hi Michael,

Could resend this patch?

Best Regards,
J.

#11 lore raw
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD

Hi Michael,

Could resend this patch?

Sure - this is from my local tree with the lastest changes from master pulled in, although I don't see much differences - but maybe git does.

cpu/ixp/serial.c +5 -1
index cf520b6..4549631 100644
@@ -58,7 +58,11 @@ void serial_setbrg (void)
 	DLL(uart) = quot & 0xff;
 	DLH(uart) = quot >> 8;
 	LCR(uart) = LCR_WLS0 | LCR_WLS1;
-
+#ifdef CONFIG_SERIAL_RTS_ACTIVE
+	MCR(uart) = MCR_RTS;				/* set RTS active */
+#else
+	MCR(uart) = 0;					/* set RTS inactive */
+#endif
 	IER(uart) = IER_UUE;
 }
 

cu
Michael

#12 lore raw

cpu/ixp/serial.c

Quoted 12 lines · Michael Schwingen
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD

Hi Michael,

Could resend this patch?

Sure - this is from my local tree with the lastest changes from master pulled in, although I don't see much differences - but maybe git does.

cpu/ixp/serial.c +0 -0
index cf520b6..4549631 100644

Apply in testing ixp repos

Best Regards,
J.