From a037e04e78b7ca3155dc47427408e453bb1b4d84 Mon Sep 17 00:00:00 2001
From: Samuel Holland <samuel@sholland.org>
Date: Tue, 31 Oct 2023 02:40:12 -0500
Subject: [PATCH 62/68] ram: sunxi: Hack up the driver for the D1

Signed-off-by: Samuel Holland <samuel@sholland.org>
---
 drivers/ram/sunxi/Kconfig          |  4 ++--
 drivers/ram/sunxi/dram_sun20i_d1.c | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

--- a/drivers/ram/sunxi/Kconfig
+++ b/drivers/ram/sunxi/Kconfig
@@ -1,6 +1,6 @@
 config DRAM_SUN20I_D1
-	bool
-	depends on ARCH_SUNXI
+	bool "DRAM driver support for Allwinner R528/T113s"
+	depends on BOARD_SUNXI
 	help
 	  This enables support for the DRAM controller driver covering
 	  the Allwinner D1/R528/T113s SoCs.
--- a/drivers/ram/sunxi/dram_sun20i_d1.c
+++ b/drivers/ram/sunxi/dram_sun20i_d1.c
@@ -12,7 +12,23 @@
  * [1] https://github.com/szemzoa/awboot.git
  */
 
+#ifndef CONFIG_DRAM_CLK
+#define CONFIG_DRAM_CLK 792
+#endif
+
+#ifndef CONFIG_DRAM_ZQ
+#define CONFIG_DRAM_ZQ 0x007b7bfb
+#endif
+
+#define readl rv_readl
+#define writel rv_writel
 #include <asm/io.h>
+#undef readl
+#undef writel
+
+#define readl(x)       rv_readl((const volatile void __iomem *)(u64)(x))
+#define writel(v, x)   rv_writel(v, (volatile void __iomem *)(u64)(x))
+
 #include <common.h>
 #ifdef CONFIG_RAM
   #include <dm.h>
