ram: rockchip: Add debug sdram driver
authorJagan Teki <jagan@amarulasolutions.com>
Mon, 15 Jul 2019 18:28:48 +0000 (23:58 +0530)
committerKever Yang <kever.yang@rock-chips.com>
Fri, 19 Jul 2019 03:11:09 +0000 (11:11 +0800)
Add sdram driver to handle debug across rockchip SoCs.

This would help to improve code debugging feature for
sdram drivers in rockchip family, whoever wants to
debug the driver should call these core debug code on
their respective platform sdram drivers.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: YouMin Chen <cym@rock-chips.com>
Reviewed-by: Kever Yang <Kever.yang@rock-chips.com>
arch/arm/include/asm/arch-rockchip/sdram_common.h
drivers/ram/rockchip/Kconfig
drivers/ram/rockchip/Makefile
drivers/ram/rockchip/sdram_debug.c [new file with mode: 0644]

index 7ac25af327c8dc841765a91ea7a006e9b90156dc..171b233f952df172ceb9fba6d08bb28b816f14f6 100644 (file)
@@ -92,4 +92,13 @@ size_t rockchip_sdram_size(phys_addr_t reg);
 
 /* Called by U-Boot board_init_r for Rockchip SoCs */
 int dram_init(void);
+
+#if !defined(CONFIG_RAM_ROCKCHIP_DEBUG)
+inline void sdram_print_dram_type(unsigned char dramtype)
+{
+}
+#else
+void sdram_print_dram_type(unsigned char dramtype);
+#endif /* CONFIG_RAM_ROCKCHIP_DEBUG */
+
 #endif
index 995cb487b89382c3d1a3edb06e5cca1b3431c524..151ffb684d9e4da25530bffdf7fc9c14bc46129a 100644 (file)
@@ -7,6 +7,15 @@ config RAM_ROCKCHIP
 
 if RAM_ROCKCHIP
 
+config RAM_ROCKCHIP_DEBUG
+       bool "Rockchip ram drivers debugging"
+       help
+         This enables debugging ram driver API's for the platforms
+         based on Rockchip SoCs.
+
+         This is an option for developers to understand the ram drivers
+         initialization, configurations and etc.
+
 config RAM_RK3399
        bool "Ram driver for Rockchip RK3399"
        default ROCKCHIP_RK3399
index 07d4b62a9d124981ea34ead479e772b05dba487d..feb1f82d00773f643fc40063cbdbe09d865e5861 100644 (file)
@@ -3,6 +3,7 @@
 # Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
 #
 
+obj-$(CONFIG_RAM_ROCKCHIP_DEBUG) += sdram_debug.o
 obj-$(CONFIG_ROCKCHIP_RK3368) = dmc-rk3368.o
 obj-$(CONFIG_ROCKCHIP_RK3128) = sdram_rk3128.o
 obj-$(CONFIG_ROCKCHIP_RK3188) = sdram_rk3188.o
diff --git a/drivers/ram/rockchip/sdram_debug.c b/drivers/ram/rockchip/sdram_debug.c
new file mode 100644 (file)
index 0000000..c13e140
--- /dev/null
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * (C) Copyright 2019 Rockchip Electronics Co., Ltd
+ * (C) Copyright 2019 Amarula Solutions.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <debug_uart.h>
+#include <asm/arch-rockchip/sdram_common.h>
+
+void sdram_print_dram_type(unsigned char dramtype)
+{
+       switch (dramtype) {
+       case DDR3:
+               printascii("DDR3");
+               break;
+       case DDR4:
+               printascii("DDR4");
+               break;
+       case LPDDR2:
+               printascii("LPDDR2");
+               break;
+       case LPDDR3:
+               printascii("LPDDR3");
+               break;
+       case LPDDR4:
+               printascii("LPDDR4");
+               break;
+       default:
+               printascii("Unknown Device");
+               break;
+       }
+}