[U-Boot-Users] 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.
Signed-off-by: Michael Schwingen michael@schwingen.org
diff --git a/cpu/ixp/serial.c b/cpu/ixp/serial.c index 2015958..e0f56fe 100644 --- a/cpu/ixp/serial.c +++ b/cpu/ixp/serial.c @@ -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; }

On 16:47 Sat 10 Nov , Michael Schwingen wrote:
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 michael@schwingen.org
diff --git a/cpu/ixp/serial.c b/cpu/ixp/serial.c index 2015958..e0f56fe 100644 --- a/cpu/ixp/serial.c +++ b/cpu/ixp/serial.c @@ -50,6 +50,8 @@ void serial_setbrg (void) quot = 16; else if (gd->baudrate == 115200) quot = 8;
- else if (gd->baudrate == 230400)
else hang ();quot = 4;
@@ -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.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
diff --git a/cpu/ixp/serial.c b/cpu/ixp/serial.c index 2015958..1f13077 100644 --- a/cpu/ixp/serial.c +++ b/cpu/ixp/serial.c @@ -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.

On Saturday 08 December 2007, Jean-Christophe PLAGNIOL-VILLARD wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
diff --git a/cpu/ixp/serial.c b/cpu/ixp/serial.c index 2015958..1f13077 100644 --- a/cpu/ixp/serial.c +++ b/cpu/ixp/serial.c @@ -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)
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@denx.de =====================================================================

In message 1197128128-13438-1-git-send-email-plagnioj@jcrosoft.com you wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
diff --git a/cpu/ixp/serial.c b/cpu/ixp/serial.c index 2015958..1f13077 100644 --- a/cpu/ixp/serial.c +++ b/cpu/ixp/serial.c @@ -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;
Is it correct to assume that the old "quot" for 1200 bps was actually wrong, and you now fix this?
Best regards,
Wolfgang Denk

On 17:58 Sat 08 Dec , Wolfgang Denk wrote:
In message 1197128128-13438-1-git-send-email-plagnioj@jcrosoft.com you wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
diff --git a/cpu/ixp/serial.c b/cpu/ixp/serial.c index 2015958..1f13077 100644 --- a/cpu/ixp/serial.c +++ b/cpu/ixp/serial.c @@ -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)
there is a missing '=' 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?
Yes you're right, according to the cpu datasheet the quot for 1200 must be 768 and not 192
Best Regards, J.

Jean-Christophe PLAGNIOL-VILLARD wrote:
2 points about this patch
- I will send a patch to support all baud rates for ipx42x, ixp45x and ixp46x
Great!
- 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

On 23:37 Sat 08 Dec , Michael Schwingen wrote:
Jean-Christophe PLAGNIOL-VILLARD wrote:
- 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.
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.

On Sat, Dec 08, 2007 at 04:32:45PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
2 points about this patch
I will send a patch to support all baud rates for ipx42x, ixp45x and ixp46x
Cou you make the RTS part configurable by a MACRO like
CONFIG_SERIAL_RTS?
Okay - how about this:
Signed-off-by: Michael Schwingen michael@schwingen.org
diff --git a/cpu/ixp/serial.c b/cpu/ixp/serial.c index 62b1f24..190641a 100644 --- a/cpu/ixp/serial.c +++ b/cpu/ixp/serial.c @@ -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

On 18:00 Sun 09 Dec , Michael Schwingen wrote:
On Sat, Dec 08, 2007 at 04:32:45PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
2 points about this patch
I will send a patch to support all baud rates for ipx42x, ixp45x and ixp46x
Cou you make the RTS part configurable by a MACRO like
CONFIG_SERIAL_RTS?
Okay - how about this:
Signed-off-by: Michael Schwingen michael@schwingen.org
diff --git a/cpu/ixp/serial.c b/cpu/ixp/serial.c index 62b1f24..190641a 100644 --- a/cpu/ixp/serial.c +++ b/cpu/ixp/serial.c @@ -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.
Hi Michael,
Could resend this patch?
Best Regards, J.

On Thu, Jan 10, 2008 at 11:56:03AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
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 michael@schwingen.org
diff --git a/cpu/ixp/serial.c b/cpu/ixp/serial.c index cf520b6..4549631 100644 --- a/cpu/ixp/serial.c +++ b/cpu/ixp/serial.c @@ -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

On 22:59 Thu 10 Jan , Michael Schwingen wrote:
On Thu, Jan 10, 2008 at 11:56:03AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
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 michael@schwingen.org
diff --git a/cpu/ixp/serial.c b/cpu/ixp/serial.c index cf520b6..4549631 100644
Apply in testing ixp repos
Best Regards, J.
participants (6)
-
Jean-Christophe PLAGNIOL-VILLARD
-
Michael Schwingen
-
Michael Schwingen
-
rincewind@discworld.dascon.de
-
Stefan Roese
-
Wolfgang Denk