public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sonic Zhang <sonic.adi@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 2/2] blackfin: Correct early serial mess output in BYPASS boot mode.
Date: Wed, 27 Feb 2013 17:06:36 +0800	[thread overview]
Message-ID: <1361955997-12596-2-git-send-email-sonic.adi@gmail.com> (raw)
In-Reply-To: <1361955997-12596-1-git-send-email-sonic.adi@gmail.com>

From: Sonic Zhang <sonic.zhang@analog.com>

The early serial should not be configured again in initcode() for BYPASS
boot mode and in start() for the other LDR boot modes.

In BYPASS boot mode, the start up code is located in Nor flash address other
than the DRAM address defined in link script. The code embedded string can't
be addressed by its compile time symbol. Calculate it according to the flash
offset.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
 arch/blackfin/cpu/initcode.c      |    2 ++
 arch/blackfin/cpu/serial.h        |   17 +++++++++++++++--
 arch/blackfin/cpu/serial1.h       |    5 +++++
 arch/blackfin/include/asm/clock.h |    6 +++++-
 4 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/arch/blackfin/cpu/initcode.c b/arch/blackfin/cpu/initcode.c
index 5c12726..4b10b6c 100644
--- a/arch/blackfin/cpu/initcode.c
+++ b/arch/blackfin/cpu/initcode.c
@@ -193,10 +193,12 @@ static inline void serial_init(void)
 	}
 #endif
 
+#if CONFIG_BFIN_BOOT_MODE != BFIN_BOOT_BYPASS
 	if (BFIN_DEBUG_EARLY_SERIAL) {
 		serial_early_init(uart_base);
 		serial_early_set_baud(uart_base, CONFIG_BAUDRATE);
 	}
+#endif
 }
 
 __attribute__((always_inline))
diff --git a/arch/blackfin/cpu/serial.h b/arch/blackfin/cpu/serial.h
index 9200339..d67fd81 100644
--- a/arch/blackfin/cpu/serial.h
+++ b/arch/blackfin/cpu/serial.h
@@ -78,19 +78,31 @@ static inline void serial_early_puts(const char *s)
 #else
 
 .macro serial_early_init
-#ifdef CONFIG_DEBUG_EARLY_SERIAL
+#if defined(CONFIG_DEBUG_EARLY_SERIAL) && defined(BFIN_BOOT_BYPASS)
 	call _serial_initialize;
 #endif
 .endm
 
 .macro serial_early_set_baud
-#ifdef CONFIG_DEBUG_EARLY_SERIAL
+#if defined(CONFIG_DEBUG_EARLY_SERIAL) && defined(BFIN_BOOT_BYPASS)
 	R0.L = LO(CONFIG_BAUDRATE);
 	R0.H = HI(CONFIG_BAUDRATE);
 	call _serial_set_baud;
 #endif
 .endm
 
+#if CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_BYPASS
+#define update_serial_early_string_addr \
+	R1.L = _start; \
+	R1.H = _start; \
+	R0 = R0 - R1; \
+	R1.L = 0; \
+	R1.H = 0x2000; \
+	R0 = R0 + R1;
+#else
+#define update_serial_early_string_addr
+#endif
+
 /* Since we embed the string right into our .text section, we need
  * to find its address.  We do this by getting our PC and adding 2
  * bytes (which is the length of the jump instruction).  Then we
@@ -108,6 +120,7 @@ static inline void serial_early_puts(const char *s)
 	.previous; \
 	R0.L = 7b; \
 	R0.H = 7b; \
+	update_serial_early_string_addr \
 	call _serial_puts;
 #else
 # define serial_early_puts(str)
diff --git a/arch/blackfin/cpu/serial1.h b/arch/blackfin/cpu/serial1.h
index 52f1c62..467d381 100644
--- a/arch/blackfin/cpu/serial1.h
+++ b/arch/blackfin/cpu/serial1.h
@@ -287,8 +287,13 @@ static inline void serial_early_set_baud(uint32_t uart_base, uint32_t baud)
 	 * weird multiplication is to make sure we over sample just
 	 * a little rather than under sample the incoming signals.
 	 */
+#if CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_BYPASS
+	uint16_t divisor = (early_get_uart_clk() + baud * 8) / (baud * 16)
+			- ANOMALY_05000230;
+#else
 	uint16_t divisor = early_division(early_get_uart_clk() + (baud * 8),
 			baud * 16) - ANOMALY_05000230;
+#endif
 
 	serial_set_divisor(uart_base, divisor);
 }
diff --git a/arch/blackfin/include/asm/clock.h b/arch/blackfin/include/asm/clock.h
index df6cd68..f1fcd40 100644
--- a/arch/blackfin/include/asm/clock.h
+++ b/arch/blackfin/include/asm/clock.h
@@ -10,7 +10,7 @@
 #include <asm/blackfin.h>
 #ifdef PLL_CTL
 #include <asm/mach-common/bits/pll.h>
-# define pll_is_bypassed() (bfin_read_PLL_STAT() & DF)
+# define pll_is_bypassed() (bfin_read_PLL_CTL() & BYPASS)
 #else
 #include <asm/mach-common/bits/cgu.h>
 # define pll_is_bypassed() (bfin_read_CGU_STAT() & PLLBP)
@@ -55,7 +55,11 @@ static inline uint32_t early_get_uart_clk(void)
 	if (!pll_is_bypassed()) {
 		div = bfin_read_PLL_DIV();
 		ssel = (div & SSEL) >> SSEL_P;
+#if CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_BYPASS
+		sclk = vco/ssel;
+#else
 		sclk = early_division(vco, ssel);
+#endif
 	}
 	uclk = sclk;
 #ifdef CGU_DIV
-- 
1.7.0.4

      reply	other threads:[~2013-02-27  9:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-27  9:06 [U-Boot] [PATCH v1 1/2] blackfin: Set correct early debug serial baudrate Sonic Zhang
2013-02-27  9:06 ` Sonic Zhang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1361955997-12596-2-git-send-email-sonic.adi@gmail.com \
    --to=sonic.adi@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox