Subject: [PATCH 2/5] gnu: u-boot: Use DDR3 patch for Nano Pi R4S.

From: Herman Rimm <[email-masked]>
Date: Thu, 9 May 2024 07:35:27 +0200

* gnu/packages/bootloaders.scm (%u-boot-nanopi-r4s-ddr3-patch): Add
variable.
(u-boot)[source]: Use patch.
* gnu/packages/patches/u-boot-nanopi-r4s-ddr3.patch: Add file.
* gnu/local.mk (dist_patch_DATA): Register patch.

Change-Id: Ibbf952f2806c9cac7fc29e1264d427bf6ee67d01
---
 gnu/local.mk                                  |  3 ++-
 gnu/packages/bootloaders.scm                  |  7 +++++-
 .../patches/u-boot-nanopi-r4s-ddr3.patch      | 25 +++++++++++++++++++
 3 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/u-boot-nanopi-r4s-ddr3.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index edd546f81d..9b3e80de08 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -62,7 +62,7 @@
 # Copyright © 2023 B. Wilson <[email-masked]>
 # Copyright © 2023 Bruno Victal <[email-masked]>
 # Copyright © 2023 gemmaro <[email-masked]>
-# Copyright © 2023 Herman Rimm <[email-masked]>
+# Copyright © 2023-2024 Herman Rimm <[email-masked]>
 # Copyright © 2023 Troy Figiel <[email-masked]>
 # Copyright © 2024 David Elsing <[email-masked]>
 #
@@ -2134,6 +2134,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/u-boot-build-without-libcrypto.patch	\
   %D%/packages/patches/u-boot-nintendo-nes-serial.patch		\
   %D%/packages/patches/u-boot-rockchip-inno-usb.patch		\
+  %D%/packages/patches/u-boot-nanopi-r4s-ddr3.patch		\
   %D%/packages/patches/ucx-tcp-iface-ioctl.patch		\
   %D%/packages/patches/ultrastar-deluxe-no-freesans.patch		\
   %D%/packages/patches/ungoogled-chromium-extension-search-path.patch	\
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index d1bf0fcd98..9443de0a1d 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -720,6 +720,10 @@ (define %u-boot-build-without-libcrypto-patch
   ;; Upstream commit to fix Amlogic builds in u-boot 2024.01.
   (search-patch "u-boot-build-without-libcrypto.patch"))
 
+(define %u-boot-nanopi-r4s-ddr3-patch
+  ;; Use DDR3 instead of LPDDR4 for the Nano Pi R4S U-boot.
+  (search-patch "u-boot-nanopi-r4s-ddr3.patch"))
+
 (define u-boot
   (package
     (name "u-boot")
@@ -728,7 +732,8 @@ (define u-boot
               (patches
                (list %u-boot-rockchip-inno-usb-patch
                      %u-boot-build-without-libcrypto-patch
-                     %u-boot-allow-disabling-openssl-patch))
+                     %u-boot-allow-disabling-openssl-patch
+                     %u-boot-nanopi-r4s-ddr3-patch))
               (method url-fetch)
               (uri (string-append
                     "https://ftp.denx.de/pub/u-boot/"
diff --git a/gnu/packages/patches/u-boot-nanopi-r4s-ddr3.patch b/gnu/packages/patches/u-boot-nanopi-r4s-ddr3.patch
new file mode 100644
index 0000000000..3c4f5efaf4
--- /dev/null
+++ b/gnu/packages/patches/u-boot-nanopi-r4s-ddr3.patch
@@ -0,0 +1,25 @@
+diff --git a/arch/arm/dts/rk3399-nanopi-r4s-u-boot.dtsi b/arch/arm/dts/rk3399-nanopi-r4s-u-boot.dtsi
+index 69800cc368..a3054849f8 100644
+--- a/arch/arm/dts/rk3399-nanopi-r4s-u-boot.dtsi
++++ b/arch/arm/dts/rk3399-nanopi-r4s-u-boot.dtsi
+@@ -13,7 +13,7 @@
+  */
+ 
+ #include "rk3399-nanopi4-u-boot.dtsi"
+-#include "rk3399-sdram-lpddr4-100.dtsi"
++#include "rk3399-sdram-ddr3-1866.dtsi"
+ 
+ / {
+ 	smbios {
+diff --git a/configs/nanopi-r4s-rk3399_defconfig b/configs/nanopi-r4s-rk3399_defconfig
+index 4f4363cb0f..bfa7ee628d 100644
+--- a/configs/nanopi-r4s-rk3399_defconfig
++++ b/configs/nanopi-r4s-rk3399_defconfig
+@@ -54,7 +54,6 @@ CONFIG_PMIC_RK8XX=y
+ CONFIG_REGULATOR_PWM=y
+ CONFIG_REGULATOR_RK8XX=y
+ CONFIG_PWM_ROCKCHIP=y
+-CONFIG_RAM_ROCKCHIP_LPDDR4=y
+ CONFIG_BAUDRATE=1500000
+ CONFIG_DEBUG_UART_SHIFT=2
+ CONFIG_SYS_NS16550_MEM32=y
-- 
2.41.0