summaryrefslogtreecommitdiff
path: root/arch/blackfin/cpu/serial1.h
diff options
context:
space:
mode:
authorSonic Zhang <sonic.zhang@analog.com>2013-02-05 19:10:34 +0800
committerSonic Zhang <sonic.zhang@analog.com>2013-05-13 15:47:24 +0800
commit79f2b3992f52334b510214c6b1b60c4200133658 (patch)
treea839a67095de369dc074303ec81c493de42df0e5 /arch/blackfin/cpu/serial1.h
parentf4d8038439fb372c91c3a27121a911c359603bcf (diff)
downloadu-boot-imx-79f2b3992f52334b510214c6b1b60c4200133658.zip
u-boot-imx-79f2b3992f52334b510214c6b1b60c4200133658.tar.gz
u-boot-imx-79f2b3992f52334b510214c6b1b60c4200133658.tar.bz2
blackfin: Set correct early debug serial baudrate.
Calculate the early uart clock from the system clock registers set by the bootrom other than the predefine uboot clock macros. Split the early baudrate setting function and the normal baudrate setting one. Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Diffstat (limited to 'arch/blackfin/cpu/serial1.h')
-rw-r--r--arch/blackfin/cpu/serial1.h43
1 files changed, 16 insertions, 27 deletions
diff --git a/arch/blackfin/cpu/serial1.h b/arch/blackfin/cpu/serial1.h
index a20175b..52f1c62 100644
--- a/arch/blackfin/cpu/serial1.h
+++ b/arch/blackfin/cpu/serial1.h
@@ -15,6 +15,8 @@
#ifndef __ASSEMBLY__
+#include <asm/clock.h>
+
#define MMR_UART(n) _PASTE_UART(n, UART, DLL)
#ifdef UART_DLL
# define UART0_DLL UART_DLL
@@ -230,19 +232,6 @@ static inline void serial_early_do_portmux(void)
}
__attribute__((always_inline))
-static inline uint32_t uart_sclk(void)
-{
-#if defined(BFIN_IN_INITCODE) || defined(CONFIG_DEBUG_EARLY_SERIAL)
- /* We cannot use get_sclk() early on as it uses
- * caches in external memory
- */
- return CONFIG_CLKIN_HZ * CONFIG_VCO_MULT / CONFIG_SCLK_DIV;
-#else
- return get_sclk();
-#endif
-}
-
-__attribute__((always_inline))
static inline int uart_init(uint32_t uart_base)
{
/* always enable UART -- avoids anomalies 05000309 and 05000350 */
@@ -275,21 +264,8 @@ static inline int serial_early_uninit(uint32_t uart_base)
}
__attribute__((always_inline))
-static inline int serial_early_enabled(uint32_t uart_base)
+static inline void serial_set_divisor(uint32_t uart_base, uint16_t divisor)
{
- return bfin_read(&pUART->gctl) & UCEN;
-}
-
-__attribute__((always_inline))
-static inline void serial_early_set_baud(uint32_t uart_base, uint32_t baud)
-{
- /* Translate from baud into divisor in terms of SCLK. The
- * weird multiplication is to make sure we over sample just
- * a little rather than under sample the incoming signals.
- */
- uint16_t divisor = (uart_sclk() + (baud * 8)) / (baud * 16) -
- ANOMALY_05000230;
-
/* Set DLAB in LCR to Access DLL and DLH */
ACCESS_LATCH();
SSYNC();
@@ -305,6 +281,19 @@ static inline void serial_early_set_baud(uint32_t uart_base, uint32_t baud)
}
__attribute__((always_inline))
+static inline void serial_early_set_baud(uint32_t uart_base, uint32_t baud)
+{
+ /* Translate from baud into divisor in terms of SCLK. The
+ * weird multiplication is to make sure we over sample just
+ * a little rather than under sample the incoming signals.
+ */
+ uint16_t divisor = early_division(early_get_uart_clk() + (baud * 8),
+ baud * 16) - ANOMALY_05000230;
+
+ serial_set_divisor(uart_base, divisor);
+}
+
+__attribute__((always_inline))
static inline void serial_early_put_div(uint16_t divisor)
{
uint32_t uart_base = UART_BASE;