PATCH: ixp42x UART: support 230400bps, enable RTS
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
@@ -50,6 +50,8 @@ void serial_setbrg (void) quot =16 ; else if (gd->baudrate == 115200) quot =8 ; + else if (gd->baudrate == 230400) + quot =4 ; elsehang ();
@@ -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 ; }
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.Signed-off-by Michael Schwingen <[email protected]>cpu/ixp/serial.c +2
-0@@ -50,6 +50,8 @@ void serial_setbrg (void) quot =16 ; else if (gd->baudrate == 115200) quot =8 ; + else if (gd->baudrate == 230400) + quot =4 ; elsehang ();
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.
PATCH 1/1 IXP: Add full baud-rate support for ixp42x, ixp45x and ixp46x
cpu/ixp/serial.c +10 -14
@@ -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
PATCH 1/1 IXP: Add full baud-rate support for ixp42x, ixp45x and ixp46x
Quoted 28 lines · Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>cpu/ixp/serial.c +7
-5@@ -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
=====================================================================
PATCH 1/1 IXP: Add full baud-rate support for ixp42x, ixp45x and ixp46x
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 29 lines · In message <[email protected]> you wrote:
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>cpu/ixp/serial.c +7
-6@@ -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
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:
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>cpu/ixp/serial.c +7
-7@@ -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.
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
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.
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
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
@@ -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
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:
Signed-off-by Michael Schwingen <[email protected]>cpu/ixp/serial.c +4
-1@@ -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.
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
@@ -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
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.
Signed-off-by Michael Schwingen <[email protected]>cpu/ixp/serial.c +0
-0
Apply in testing ixp repos
Best Regards,
J.