Skip to contentSkip to conversation

at91rm9200 serial frequency fix

U-Boot-Users michael trimarchi 3 participants 5 messages Aug 19, 2007 Arm/Microchip (AT91) SoC support

lore
Share & tools
lore
#0 lore raw

Fix CD calcutation on serial device.

---

arm920t/at91rm9200/serial.c renamed from arm920t/at91rm9200/serial.c.orig +6 -2
@@ -50,14 +50,18 @@ AT91PS_USART us = (AT91PS_USART) AT91C_B
 AT91PS_USART us = (AT91PS_USART) AT91C_BASE_US1;
 #endif
 
+#define BAUDRATE(mck, baud) \
+	((((mck) * 10) % ((baud) * 16)) >= 5) ? \
+	(mck / (baud * 16) + 1) : ((mck) / (baud * 16))
+
 void serial_setbrg (void)
 {
 	int baudrate;
 
 	if ((baudrate = gd->baudrate) <= 0)
 		baudrate = CONFIG_BAUDRATE;
-	/* MASTER_CLOCK/(16 * baudrate) */
-	us->US_BRGR = (AT91C_MASTER_CLOCK >> 4) / (unsigned)baudrate;
+
+	us->US_BRGR = BOUDRATE(AT91C_MASTER_CLOCK, (unsigned)baudrate);
 }
 
 int serial_init (void)
#1 lore raw

s?n 2007-08-19 klockan 18:35 +0200 skrev michael trimarchi:

Quoted 16 lines

Fix CD calcutation on serial device.

---

arm920t/at91rm9200/serial.c renamed from arm920t/at91rm9200/serial.c.orig +4 -0
@@ -50,14 +50,18 @@ AT91PS_USART us = (AT91PS_USART) AT91C_B
 AT91PS_USART us = (AT91PS_USART) AT91C_BASE_US1;
 #endif
 
+#define BAUDRATE(mck, baud) \
+	((((mck) * 10) % ((baud) * 16)) >= 5) ? \
+	(mck / (baud * 16) + 1) : ((mck) / (baud * 16))
+
 void serial_setbrg (void)

arm920t/at91rm9200/serial.c AT91PS_USART us = (AT91PS_USART) AT91C_B · line 65

Quoted 10 lines
arm920t/at91rm9200/serial.c renamed from arm920t/at91rm9200/serial.c.orig +2 -2
 {
 	int baudrate;
 
 	if ((baudrate = gd->baudrate) <= 0)
 		baudrate = CONFIG_BAUDRATE;
-	/* MASTER_CLOCK/(16 * baudrate) */
-	us->US_BRGR = (AT91C_MASTER_CLOCK >> 4) / (unsigned)baudrate;
+
+	us->US_BRGR = BOUDRATE(AT91C_MASTER_CLOCK, (unsigned)baudrate);
 }

You should read the part of the documentation where is says that you should test any patch before sending it to the list.

You have obviously not tested your patch before use, since there is a spelling error.
BAUDRATE != BOUDRATE

Pls reject this patch.

BR
Ulf Samuelsson

#2 lore raw
Quoted 14 lines · Ulf Samuelsson

s?n 2007-08-19 klockan 18:35 +0200 skrev michael trimarchi:

arm920t/at91rm9200/serial.c AT91PS_USART us = (AT91PS_USART) AT91C_B · line 52

Quoted 11 lines

Fix CD calcutation on serial device.

---

arm920t/at91rm9200/serial.c renamed from arm920t/at91rm9200/serial.c.orig +0 -0
@@ -50,14 +50,18 @@ AT91PS_USART us = (AT91PS_USART) AT91C_B
 AT91PS_USART us = (AT91PS_USART) AT91C_BASE_US1;
 #endif
 

you should test any patch before sending it to the list.

Quoted 10 lines

You have obviously not tested your patch before use, since there is a spelling error.
BAUDRATE != BOUDRATE

Pls reject this patch.

BR
Ulf Samuelsson

I'm so sorry! I test this code on my at91 but when I prepare the patch from the last git, I does't notice the error in the integration. The next time I test again my code.

Regards Michael

#3 lore raw
In reply to michael trimarchi
Quoted 11 lines
arm920t/at91rm9200/serial.c renamed from arm920t/at91rm9200/serial.c.orig +4 -0
+#define BAUDRATE(mck, baud) \
+	((((mck) * 10) % ((baud) * 16)) >= 5) ? \
+	(mck / (baud * 16) + 1) : ((mck) / (baud * 16))
+
 void serial_setbrg (void)
 {
 	int baudrate;

arm920t/at91rm9200/serial.c AT91PS_USART us = (AT91PS_USART) AT91C_B · line 67

Quoted 10 lines
arm920t/at91rm9200/serial.c renamed from arm920t/at91rm9200/serial.c.orig +2 -2
 
 	if ((baudrate = gd->baudrate) <= 0)
 		baudrate = CONFIG_BAUDRATE;
-	/* MASTER_CLOCK/(16 * baudrate) */
-	us->US_BRGR = (AT91C_MASTER_CLOCK >> 4) / (unsigned)baudrate;
+
+	us->US_BRGR = BOUDRATE(AT91C_MASTER_CLOCK, (unsigned)baudrate);
 }
 
 int serial_init (void)

Excuse me I take the wrong diff file, containg and error on macro name. I will send the right one soon.

Regards Michael

#4 lore raw
In reply to michael trimarchi

arm920t/at91rm9200/serial.c AT91PS_USART us = (AT91PS_USART) AT91C_B · line 53

Quoted 12 lines · In message <[email protected]> you wrote:

Fix CD calcutation on serial device.

---

arm920t/at91rm9200/serial.c renamed from arm920t/at91rm9200/serial.c.orig +1 -0
@@ -50,14 +50,18 @@ AT91PS_USART us = (AT91PS_USART) AT91C_B
 AT91PS_USART us = (AT91PS_USART) AT91C_BASE_US1;
 #endif
 
+#define BAUDRATE(mck, baud) \
           ^^^^^^^^

arm920t/at91rm9200/serial.c AT91PS_USART us = (AT91PS_USART) AT91C_B · line 64

Quoted 1 line
arm920t/at91rm9200/serial.c renamed from arm920t/at91rm9200/serial.c.orig +1 -0
+	us->US_BRGR = BOUDRATE(AT91C_MASTER_CLOCK, (unsigned)baudrate);
                      ^^^^^^^^

Spelling...

Best regards,

Wolfgang Denk

Signature · 6 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
Hi there! This is just a note from me, to you, to tell you, the  per-
son  reading this note, that I can't think up any more famous quotes,
jokes, nor bizarre stories, so you may as well go home.