[platform][lpc43xx] support some faster debug uart baudrates

TARGET_DEBUG_BAUDRATE may be 115200, 1000000, 2000000, or 3000000
This commit is contained in:
Brian Swetland
2015-07-05 23:10:55 -07:00
parent 45a6034cf6
commit b736d68903
2 changed files with 31 additions and 1 deletions

View File

@@ -25,6 +25,11 @@
#include <reg.h>
#include <platform/lpc43xx-uart.h>
#include <platform/lpc43xx-clocks.h>
#ifndef TARGET_DEBUG_BAUDRATE
#define TARGET_DEBUG_BAUDRATE 115200
#endif
#if TARGET_DEBUG_UART == 1
#define UART_BASE UART0_BASE
@@ -38,14 +43,38 @@
#warning TARGET_DEBUG_UART unspecified
#endif
static u32 base_uart_clk[4] = {
BASE_UART0_CLK,
BASE_UART1_CLK,
BASE_UART2_CLK,
BASE_UART3_CLK
};
void lpc43xx_debug_early_init(void)
{
#ifdef UART_BASE
#if TARGET_DEBUG_BAUDRATE == 115200
// config for 115200-n-8-1 from 12MHz clock
writel(BASE_X_SEL(CLK_IRC), base_uart_clk[TARGET_DEBUG_UART - 1]);
writel(LCR_DLAB, UART_BASE + REG_LCR);
writel(4, UART_BASE + REG_DLL);
writel(0, UART_BASE + REG_DLM);
writel(FDR_DIVADDVAL(5) | FDR_MULVAL(8), UART_BASE + REG_FDR);
#else
writel(BASE_X_SEL(CLK_IDIVC), base_uart_clk[TARGET_DEBUG_UART - 1]);
writel(LCR_DLAB, UART_BASE + REG_LCR);
#if TARGET_DEBUG_BAUDRATE == 1000000
writel(6, UART_BASE + REG_DLL);
#elif TARGET_DEBUG_BAUDRATE == 2000000
writel(3, UART_BASE + REG_DLL);
#elif TARGET_DEBUG_BAUDRATE == 3000000
writel(2, UART_BASE + REG_DLL);
#else
#error Unsupported TARGET_DEBUG_BAUDRATE
#endif
writel(0, UART_BASE + REG_DLM);
writel(0, UART_BASE + REG_FDR);
#endif
writel(LCR_WLS_8 | LCR_SBS_1, UART_BASE + REG_LCR);
writel(FCR_FIFOEN | FCR_RX_TRIG_1, UART_BASE + REG_FCR);
#endif

View File

@@ -6,7 +6,8 @@ PLATFORM := lpc43xx
GLOBAL_DEFINES += \
CRYSTAL_FREQ=12000000 \
TARGET_DEBUG_UART=3
TARGET_DEBUG_UART=3 \
TARGET_DEBUG_BAUDRATE=3000000
GLOBAL_INCLUDES += \
$(LOCAL_DIR)/include