rockchip: rk3288: add board_debug_uart_init()
authorKever Yang <kever.yang@rock-chips.com>
Fri, 29 Mar 2019 01:09:04 +0000 (09:09 +0800)
committerPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Wed, 1 May 2019 07:40:58 +0000 (09:40 +0200)
Use board_debug_uart_init() for UART iomux init instead of
do it in board_init_f, and move the function to soc file so
that we can find all the soc/board setting in soc file and
use a common board file for all rockchip SoCs later.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
arch/arm/mach-rockchip/rk3288-board-spl.c
arch/arm/mach-rockchip/rk3288-board-tpl.c
arch/arm/mach-rockchip/rk3288/rk3288.c

index 937a99d..d8d215d 100644 (file)
@@ -109,16 +109,7 @@ void board_init_f(ulong dummy)
        struct udevice *dev;
        int ret;
 
-       /* Example code showing how to enable the debug UART on RK3288 */
-#include <asm/arch-rockchip/grf_rk3288.h>
-       /* Enable early UART on the RK3288 */
-#define GRF_BASE       0xff770000
-       struct rk3288_grf * const grf = (void *)GRF_BASE;
-
-       rk_clrsetreg(&grf->gpio7ch_iomux, GPIO7C7_MASK << GPIO7C7_SHIFT |
-                    GPIO7C6_MASK << GPIO7C6_SHIFT,
-                    GPIO7C7_UART2DBG_SOUT << GPIO7C7_SHIFT |
-                    GPIO7C6_UART2DBG_SIN << GPIO7C6_SHIFT);
+#ifdef CONFIG_DEBUG_UART
        /*
         * Debug UART can be used from here if required:
         *
@@ -129,6 +120,7 @@ void board_init_f(ulong dummy)
         */
        debug_uart_init();
        debug("\nspl:debug uart enabled in %s\n", __func__);
+#endif
        ret = spl_early_init();
        if (ret) {
                debug("spl_early_init() failed: %d\n", ret);
index a430bb4..a984806 100644 (file)
 #include <spl.h>
 #include <version.h>
 #include <asm/io.h>
-#include <asm/arch-rockchip/bootrom.h>
 #include <asm/arch-rockchip/clock.h>
-#include <asm/arch-rockchip/grf_rk3288.h>
-#include <asm/arch-rockchip/periph.h>
-#include <asm/arch-rockchip/pmu_rk3288.h>
 #include <asm/arch-rockchip/sys_proto.h>
 #include <asm/arch-rockchip/timer.h>
 
-#define GRF_BASE               0xff770000
 void board_init_f(ulong dummy)
 {
        struct udevice *dev;
        int ret;
 
-       /* Example code showing how to enable the debug UART on RK3288 */
-       /* Enable early UART on the RK3288 */
-       struct rk3288_grf * const grf = (void *)GRF_BASE;
-
-       rk_clrsetreg(&grf->gpio7ch_iomux, GPIO7C7_MASK << GPIO7C7_SHIFT |
-                    GPIO7C6_MASK << GPIO7C6_SHIFT,
-                    GPIO7C7_UART2DBG_SOUT << GPIO7C7_SHIFT |
-                    GPIO7C6_UART2DBG_SIN << GPIO7C6_SHIFT);
+#ifdef CONFIG_DEBUG_UART
        /*
         * Debug UART can be used from here if required:
         *
@@ -41,7 +29,7 @@ void board_init_f(ulong dummy)
         * printascii("string");
         */
        debug_uart_init();
-
+#endif
        ret = spl_early_init();
        if (ret) {
                debug("spl_early_init() failed: %d\n", ret);
index 987fae5..7941ca6 100644 (file)
@@ -18,3 +18,16 @@ int arch_cpu_init(void)
 
        return 0;
 }
+
+#ifdef CONFIG_DEBUG_UART_BOARD_INIT
+void board_debug_uart_init(void)
+{
+       /* Enable early UART on the RK3288 */
+       struct rk3288_grf * const grf = (void *)GRF_BASE;
+
+       rk_clrsetreg(&grf->gpio7ch_iomux, GPIO7C7_MASK << GPIO7C7_SHIFT |
+                    GPIO7C6_MASK << GPIO7C6_SHIFT,
+                    GPIO7C7_UART2DBG_SOUT << GPIO7C7_SHIFT |
+                    GPIO7C6_UART2DBG_SIN << GPIO7C6_SHIFT);
+}
+#endif