* [U-Boot] [PATCH 1/2] mpc512x: Fix PSC divisor calculation for baudrate setting
@ 2009-06-02 14:53 Stefan Roese
2009-06-02 14:53 ` [U-Boot] [PATCH 2/2] mpc512x: Use serial_setbrg() in serial_init() to not duplicate the code Stefan Roese
2009-06-05 12:18 ` [U-Boot] [PATCH 1/2] mpc512x: Fix PSC divisor calculation for baudrate setting Wolfgang Denk
0 siblings, 2 replies; 4+ messages in thread
From: Stefan Roese @ 2009-06-02 14:53 UTC (permalink / raw)
To: u-boot
The wrong input frequency was used in serial_setbrg(). This patch fixes
this by using ips_clk as input frequency for the PSC baudrate generator.
Signed-off-by: Stefan Roese <sr@denx.de>
---
cpu/mpc512x/serial.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cpu/mpc512x/serial.c b/cpu/mpc512x/serial.c
index 16ce770..d3ffff9 100644
--- a/cpu/mpc512x/serial.c
+++ b/cpu/mpc512x/serial.c
@@ -167,7 +167,7 @@ void serial_setbrg (void)
volatile psc512x_t *psc = (psc512x_t *) &im->psc[CONFIG_PSC_CONSOLE];
unsigned long baseclk, div;
- baseclk = (gd->csb_clk + 8) / 16;
+ baseclk = (gd->ips_clk + 8) / 16;
div = (baseclk + (gd->baudrate / 2)) / gd->baudrate;
out_8(&psc->ctur, (div >> 8) & 0xFF);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 2/2] mpc512x: Use serial_setbrg() in serial_init() to not duplicate the code
2009-06-02 14:53 [U-Boot] [PATCH 1/2] mpc512x: Fix PSC divisor calculation for baudrate setting Stefan Roese
@ 2009-06-02 14:53 ` Stefan Roese
2009-06-05 12:19 ` Wolfgang Denk
2009-06-05 12:18 ` [U-Boot] [PATCH 1/2] mpc512x: Fix PSC divisor calculation for baudrate setting Wolfgang Denk
1 sibling, 1 reply; 4+ messages in thread
From: Stefan Roese @ 2009-06-02 14:53 UTC (permalink / raw)
To: u-boot
This patch removes the duplicated code for baudrate generator configuration
in the PSC serial_init() implementation by calling serial_setbrg() instead
of duplicating the code.
Signed-off-by: Stefan Roese <sr@denx.de>
---
cpu/mpc512x/serial.c | 36 +++++++++++++++---------------------
1 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/cpu/mpc512x/serial.c b/cpu/mpc512x/serial.c
index d3ffff9..4fc4693 100644
--- a/cpu/mpc512x/serial.c
+++ b/cpu/mpc512x/serial.c
@@ -60,12 +60,24 @@ static void fifo_init (volatile psc512x_t *psc)
__asm__ volatile ("sync");
}
+void serial_setbrg(void)
+{
+ volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
+ volatile psc512x_t *psc = (psc512x_t *) &im->psc[CONFIG_PSC_CONSOLE];
+ unsigned long baseclk, div;
+
+ /* calculate dividor for setting PSC CTUR and CTLR registers */
+ baseclk = (gd->ips_clk + 8) / 16;
+ div = (baseclk + (gd->baudrate / 2)) / gd->baudrate;
+
+ out_8(&psc->ctur, (div >> 8) & 0xff);
+ out_8(&psc->ctlr, div & 0xff); /* set baudrate */
+}
+
int serial_init(void)
{
volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
volatile psc512x_t *psc = (psc512x_t *) &im->psc[CONFIG_PSC_CONSOLE];
- unsigned long baseclk;
- int div;
fifo_init (psc);
@@ -87,13 +99,8 @@ int serial_init(void)
/* now, mode register points to mr2 */
out_8(&psc->mode, PSC_MODE_1_STOPBIT);
- /* calculate dividor for setting PSC CTUR and CTLR registers */
- baseclk = (gd->ips_clk + 8) / 16;
- div = (baseclk + (gd->baudrate / 2)) / gd->baudrate;
-
- out_8(&psc->ctur, (div >> 8) & 0xff);
/* set baudrate */
- out_8(&psc->ctlr, div & 0xff);
+ serial_setbrg();
/* disable all interrupts */
out_be16(&psc->psc_imr, 0);
@@ -161,19 +168,6 @@ int serial_tstc (void)
return !(in_be32(&psc->rfstat) & PSC_FIFO_EMPTY);
}
-void serial_setbrg (void)
-{
- volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
- volatile psc512x_t *psc = (psc512x_t *) &im->psc[CONFIG_PSC_CONSOLE];
- unsigned long baseclk, div;
-
- baseclk = (gd->ips_clk + 8) / 16;
- div = (baseclk + (gd->baudrate / 2)) / gd->baudrate;
-
- out_8(&psc->ctur, (div >> 8) & 0xFF);
- out_8(&psc->ctlr, div & 0xff); /* set baudrate */
-}
-
void serial_setrts(int s)
{
volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 1/2] mpc512x: Fix PSC divisor calculation for baudrate setting
2009-06-02 14:53 [U-Boot] [PATCH 1/2] mpc512x: Fix PSC divisor calculation for baudrate setting Stefan Roese
2009-06-02 14:53 ` [U-Boot] [PATCH 2/2] mpc512x: Use serial_setbrg() in serial_init() to not duplicate the code Stefan Roese
@ 2009-06-05 12:18 ` Wolfgang Denk
1 sibling, 0 replies; 4+ messages in thread
From: Wolfgang Denk @ 2009-06-05 12:18 UTC (permalink / raw)
To: u-boot
Dear Stefan Roese,
In message <1243954396-24775-1-git-send-email-sr@denx.de> you wrote:
> The wrong input frequency was used in serial_setbrg(). This patch fixes
> this by using ips_clk as input frequency for the PSC baudrate generator.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> ---
> cpu/mpc512x/serial.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
Applied to mpc5xxx/next. Thanks.
Best regards,
Wolfgang Denk
--
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
Today is the yesterday you worried about tomorrow.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 2/2] mpc512x: Use serial_setbrg() in serial_init() to not duplicate the code
2009-06-02 14:53 ` [U-Boot] [PATCH 2/2] mpc512x: Use serial_setbrg() in serial_init() to not duplicate the code Stefan Roese
@ 2009-06-05 12:19 ` Wolfgang Denk
0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Denk @ 2009-06-05 12:19 UTC (permalink / raw)
To: u-boot
Dear Stefan Roese,
In message <1243954396-24775-2-git-send-email-sr@denx.de> you wrote:
> This patch removes the duplicated code for baudrate generator configuration
> in the PSC serial_init() implementation by calling serial_setbrg() instead
> of duplicating the code.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> ---
> cpu/mpc512x/serial.c | 36 +++++++++++++++---------------------
> 1 files changed, 15 insertions(+), 21 deletions(-)
Applied to mpc5xxx/next. Thanks.
Best regards,
Wolfgang Denk
--
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
"It was the Law of the Sea, they said. Civilization ends at the wa-
terline. Beyond that, we all enter the food chain, and not always
right at the top." - Hunter S. Thompson
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-06-05 12:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-02 14:53 [U-Boot] [PATCH 1/2] mpc512x: Fix PSC divisor calculation for baudrate setting Stefan Roese
2009-06-02 14:53 ` [U-Boot] [PATCH 2/2] mpc512x: Use serial_setbrg() in serial_init() to not duplicate the code Stefan Roese
2009-06-05 12:19 ` Wolfgang Denk
2009-06-05 12:18 ` [U-Boot] [PATCH 1/2] mpc512x: Fix PSC divisor calculation for baudrate setting Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox