Skip to contentSkip to conversation

Coldfire: Applied baudrate formula of serial_init to serial_setbrg

PATCH New Richard Retanubun 1 participant 3 messages Jan 23, 2009 – Feb 4, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 6/7 Coldfire: Applied baudrate formula of serial_init to serial_setbrg

Applied the patch for baudrate divider value truncation for serial_init to serial_setbrg as well.

---
  drivers/serial/mcfuart.c |    5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)
drivers/serial/mcfuart.c +3 -2
index e04fc29..0b53140 100644
@@ -115,8 +115,9 @@ void serial_setbrg(void)
  	volatile uart_t *uart = (volatile uart_t *)(CONFIG_SYS_UART_BASE);
  	u32 counter;
 
-	counter = ((gd->bus_clk / gd->baudrate)) >> 5;
-	counter++;
+	/* Setting up BaudRate */
+	counter = (u32) ((gd->bus_clk / 32) + (gd->baudrate / 2));
+	counter = counter / gd->baudrate;
 
  	/* write to CTUR: divide counter upper byte */
  	uart->ubg1 = ((counter & 0xff00) >> 8);
Signature · 1 line
1.5.6.5
#1 lore raw

PATCH 6/7 Coldfire: Applied baudrate formula of serial_init to serial_setbrg

M5271 dynamic clock multiplier. It is currently fixed at 100MHz.

Allow the board header file to set their own multiplier and divider. Added the #define for the multiplier and divider to the cpu header file.

---

Rebased on:

commit 9d8811c5bd2b7dd6307742cf22fbdb7953b6f816
Merge: 716ebf4... bd99ec1...
Author: Wolfgang Denk <[email protected]>
Date: Tue Feb 3 23:16:15 2009 +0100

  cpu/mcf52x2/cpu_init.c   |    7 +++++-
  include/asm-m68k/m5271.h |   53 ++++++++++++++++++++++++++++++++++++++++++++-
  2 files changed, 57 insertions(+), 3 deletions(-)
cpu/mcf52x2/cpu_init.c +6 -1
index 66f9164..02f37ae 100644
@@ -181,9 +181,14 @@ void cpu_init_f(void)
  	/* FlexBus Chipselect */
  	init_fbcs();
 
+#ifdef CONFIG_SYS_MCF_SYNCR
+	/* Set clockspeed according to board header file */
+	mbar_writeLong(MCF_FMPLL_SYNCR, CONFIG_SYS_MCF_SYNCR);
+#else
  	/* Set clockspeed to 100MHz */
-	mbar_writeShort(MCF_FMPLL_SYNCR,
+	mbar_writeLong(MCF_FMPLL_SYNCR,
  			MCF_FMPLL_SYNCR_MFD(0) | MCF_FMPLL_SYNCR_RFD(0));
+#endif
  	while (!mbar_readByte(MCF_FMPLL_SYNSR) & MCF_FMPLL_SYNSR_LOCK) ;
  }
 
include/asm-m68k/m5271.h +51 -2

76 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#2 lore raw

PATCH v2 6/7 Coldfire: Applied baudrate formula of serial_init to serial_setbrg

Applied the patch for baudrate divider value truncation for serial_init to serial_setbrg as well.

---
PLEASE disregard previous rebase, that was a copy-paste error of another patch

Rebased on:

commit 9d8811c5bd2b7dd6307742cf22fbdb7953b6f816
Merge: 716ebf4... bd99ec1...
Author: Wolfgang Denk <[email protected]>
Date: Tue Feb 3 23:16:15 2009 +0100

  drivers/serial/mcfuart.c |    5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)
drivers/serial/mcfuart.c +3 -2
index e04fc29..0b53140 100644
@@ -115,8 +115,9 @@ void serial_setbrg(void)
  	volatile uart_t *uart = (volatile uart_t *)(CONFIG_SYS_UART_BASE);
  	u32 counter;
 
-	counter = ((gd->bus_clk / gd->baudrate)) >> 5;
-	counter++;
+	/* Setting up BaudRate */
+	counter = (u32) ((gd->bus_clk / 32) + (gd->baudrate / 2));
+	counter = counter / gd->baudrate;
 
  	/* write to CTUR: divide counter upper byte */
  	uart->ubg1 = ((counter & 0xff00) >> 8);
Signature · 1 line
1.5.6.5