From: 黄涛 Date: Fri, 9 Mar 2012 12:31:37 +0000 (+0800) Subject: rk30: add debug uart port configuration X-Git-Tag: firefly_0821_release~9595^2~78 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a2027ba517f08c31e5996a37f6f7cbad3f61c213;p=firefly-linux-kernel-4.4.55.git rk30: add debug uart port configuration --- diff --git a/arch/arm/mach-rk30/devices.c b/arch/arm/mach-rk30/devices.c index dc608b7aee2b..98ecfb42eb4a 100755 --- a/arch/arm/mach-rk30/devices.c +++ b/arch/arm/mach-rk30/devices.c @@ -999,8 +999,8 @@ static int __init rk30_init_devices(void) platform_device_register(&device_tsadc); #endif rk30_init_sdmmc(); -#ifdef CONFIG_FIQ_DEBUGGER - rk_serial_debug_init(RK30_UART1_PHYS, IRQ_UART1, IRQ_UART_SIGNAL, -1); +#if defined(CONFIG_FIQ_DEBUGGER) && defined(DEBUG_UART_PHYS) + rk_serial_debug_init(DEBUG_UART_PHYS, IRQ_UART0 + CONFIG_RK_DEBUG_UART, IRQ_UART_SIGNAL, -1); #endif rk30_init_i2s(); diff --git a/arch/arm/mach-rk30/include/mach/debug-macro.S b/arch/arm/mach-rk30/include/mach/debug-macro.S index d6da9a518d23..2a57cc79fa7e 100644 --- a/arch/arm/mach-rk30/include/mach/debug-macro.S +++ b/arch/arm/mach-rk30/include/mach/debug-macro.S @@ -15,10 +15,21 @@ #include +#ifdef DEBUG_UART_PHYS .macro addruart, rp, rv - ldr \rp, = RK30_UART1_PHYS - ldr \rv, = RK30_UART1_BASE + ldr \rp, = DEBUG_UART_PHYS + ldr \rv, = DEBUG_UART_BASE .endm #define UART_SHIFT 2 #include +#else + .macro addruart, rp, rv + .endm + .macro senduart, rd, rx + .endm + .macro busyuart, rd, rx + .endm + .macro waituart, rd, rx + .endm +#endif diff --git a/arch/arm/mach-rk30/include/mach/io.h b/arch/arm/mach-rk30/include/mach/io.h index 99ccf481a53a..3cbcf6e1432d 100644 --- a/arch/arm/mach-rk30/include/mach/io.h +++ b/arch/arm/mach-rk30/include/mach/io.h @@ -197,8 +197,10 @@ #define RK30_TSADC_PHYS 0x20060000 #define RK30_TSADC_SIZE SZ_16K #define RK30_UART2_PHYS 0x20064000 +#define RK30_UART2_BASE RK30_IO_TO_VIRT1(RK30_UART2_PHYS) #define RK30_UART2_SIZE SZ_16K #define RK30_UART3_PHYS 0x20068000 +#define RK30_UART3_BASE RK30_IO_TO_VIRT1(RK30_UART3_PHYS) #define RK30_UART3_SIZE SZ_16K #define RK30_SARADC_PHYS 0x2006c000 #define RK30_SARADC_SIZE SZ_16K @@ -217,4 +219,18 @@ #define RK30_GPIO4_BASE RK30_IO_TO_VIRT1(RK30_GPIO4_PHYS) #define RK30_GPIO4_SIZE SZ_16K +#if CONFIG_RK_DEBUG_UART == 0 +#define DEBUG_UART_PHYS RK30_UART0_PHYS +#define DEBUG_UART_BASE RK30_UART0_BASE +#elif CONFIG_RK_DEBUG_UART == 1 +#define DEBUG_UART_PHYS RK30_UART1_PHYS +#define DEBUG_UART_BASE RK30_UART1_BASE +#elif CONFIG_RK_DEBUG_UART == 2 +#define DEBUG_UART_PHYS RK30_UART2_PHYS +#define DEBUG_UART_BASE RK30_UART2_BASE +#elif CONFIG_RK_DEBUG_UART == 3 +#define DEBUG_UART_PHYS RK30_UART3_PHYS +#define DEBUG_UART_BASE RK30_UART3_BASE +#endif + #endif diff --git a/arch/arm/mach-rk30/include/mach/uncompress.h b/arch/arm/mach-rk30/include/mach/uncompress.h index a83b2440c39c..f165f074ee01 100644 --- a/arch/arm/mach-rk30/include/mach/uncompress.h +++ b/arch/arm/mach-rk30/include/mach/uncompress.h @@ -4,7 +4,8 @@ #include #include -static volatile u32 *UART = (u32 *)RK30_UART1_PHYS; +#ifdef DEBUG_UART_PHYS +static volatile u32 *UART = (u32 *)DEBUG_UART_PHYS; static void putc(int c) { @@ -12,6 +13,11 @@ static void putc(int c) barrier(); UART[UART_TX] = c; } +#else +static inline void putc(int c) +{ +} +#endif static inline void flush(void) { diff --git a/arch/arm/mach-rk30/io.c b/arch/arm/mach-rk30/io.c index cf6b0b2cdfbf..b370cd6e8035 100644 --- a/arch/arm/mach-rk30/io.c +++ b/arch/arm/mach-rk30/io.c @@ -29,8 +29,15 @@ static struct map_desc rk30_io_desc[] __initdata = { RK30_DEVICE(CORE), +#if CONFIG_RK_DEBUG_UART == 0 RK30_DEVICE(UART0), +#elif CONFIG_RK_DEBUG_UART == 1 RK30_DEVICE(UART1), +#elif CONFIG_RK_DEBUG_UART == 2 + RK30_DEVICE(UART2), +#elif CONFIG_RK_DEBUG_UART == 3 + RK30_DEVICE(UART3), +#endif RK30_DEVICE(GRF), RK30_DEVICE(CRU), RK30_DEVICE(PMU), diff --git a/arch/arm/mach-rk30/pm.c b/arch/arm/mach-rk30/pm.c index e2363719eac8..6e5bfe4d94b3 100755 --- a/arch/arm/mach-rk30/pm.c +++ b/arch/arm/mach-rk30/pm.c @@ -21,15 +21,17 @@ void __sramfunc sram_printch(char byte) { - writel_relaxed(byte, RK30_UART1_BASE); +#ifdef DEBUG_UART_BASE + writel_relaxed(byte, DEBUG_UART_BASE); dsb(); /* loop check LSR[6], Transmitter Empty bit */ - while (!(readl_relaxed(RK30_UART1_BASE + 0x14) & 0x40)) + while (!(readl_relaxed(DEBUG_UART_BASE + 0x14) & 0x40)) barrier(); if (byte == '\n') sram_printch('\r'); +#endif } #ifdef CONFIG_DDR_TEST diff --git a/arch/arm/plat-rk/Kconfig b/arch/arm/plat-rk/Kconfig index 845bb9f23013..9ba0b4d7c71a 100644 --- a/arch/arm/plat-rk/Kconfig +++ b/arch/arm/plat-rk/Kconfig @@ -120,4 +120,11 @@ config RK_EARLY_PRINTK Say Y here if you want to have an early console using the kernel low-level debugging functions. +config RK_DEBUG_UART + int "Debug UART" + default 1 if ARCH_RK29 + default 2 if ARCH_RK30 + help + Select a UART for debugging. -1 disable. + endif