Skip to content

Instantly share code, notes, and snippets.

@iuncuim
iuncuim / gist:a7b01ecd919dfd82d90f0f0fe81b50fd
Created December 18, 2023 16:38
0007-h616-shrink-ram-size.patch
From 4a542204ebd3ce90393c24a102679c9a3c7c13bc Mon Sep 17 00:00:00 2001
From: iuncuim <iuncuim@gmail.com>
Date: Sat, 16 Dec 2023 19:00:16 +0300
Subject: [PATCH] Update dram_sun50i_h616.h and dram_sun50i_h616.c
---
.../include/asm/arch-sunxi/dram_sun50i_h616.h | 1 +
arch/arm/mach-sunxi/dram_sun50i_h616.c | 18 ++++++++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-sunxi/dram_sun50i_h616.c b/arch/arm/mach-sunxi/dram_sun50i_h616.c
index c5c1331..9b51b7e 100644
--- a/arch/arm/mach-sunxi/dram_sun50i_h616.c
+++ b/arch/arm/mach-sunxi/dram_sun50i_h616.c
@@ -1352,6 +1352,9 @@ static unsigned long mctl_calc_size(const struct dram_config *config)
u8 width = config->bus_full_width ? 4 : 2;
/* 8 banks */
+ u32 offset = (1ULL << (config->cols + config->rows + 3)) * width * config->ranks;
+ if (mctl_mem_matches(offset-0x10))
From bb043903189cd76d534227d3c9c002290d1cb8f9 Mon Sep 17 00:00:00 2001
From: iuncuim <iuncuim@gmail.com>
Date: Sat, 21 Oct 2023 11:13:29 +0300
Subject: [PATCH] Update dram_sun50i_h616.c
---
arch/arm/mach-sunxi/dram_sun50i_h616.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-sunxi/dram_sun50i_h616.c b/arch/arm/mach-sunxi/dram_sun50i_h616.c
// SPDX-License-Identifier: GPL-2.0+
/*
* sun50i H616 platform dram controller driver
*
* While controller is very similar to that in H6, PHY is completely
* unknown. That's why this driver has plenty of magic numbers. Some
* meaning was nevertheless deduced from strings found in boot0 and
* known meaning of some dram parameters.
* This driver only supports DDR3 memory and omits logic for all
* other supported types supported by hardware.
From 1cb292ee14f3e6dd331e3e9f4291ecd57cddc447 Mon Sep 17 00:00:00 2001
From: iuncuim <iuncuim@gmail.com>
Date: Thu, 19 Oct 2023 08:20:30 +0300
Subject: [PATCH] Update Kconfig, dram_sun50i_h616.c, and 2 more files...
---
arch/arm/mach-sunxi/Kconfig | 1 +
arch/arm/mach-sunxi/dram_sun50i_h616.c | 26 +++++++++++---
.../dram_timings/h616_lpddr4_2133.c | 4 +--
configs/orangepi_zero3_defconfig | 34 +++++++++++++++++++
#define MASK_BYTE(reg, nr) (((reg) >> ((nr) * 8)) & 0x1f)
static void mctl_phy_configure_odt(const struct dram_para *para)
{
uint32_t val_lo, val_hi;
val_lo = para->dx_dri;
val_hi = (para->type == SUNXI_DRAM_TYPE_LPDDR4) ? 4 : para->dx_dri;
writel_relaxed(MASK_BYTE(val_lo, 0), SUNXI_DRAM_PHY0_BASE + 0x388);
writel_relaxed(MASK_BYTE(val_hi, 0), SUNXI_DRAM_PHY0_BASE + 0x38c);
writel_relaxed(MASK_BYTE(val_lo, 1), SUNXI_DRAM_PHY0_BASE + 0x3c8);
===================================================
video=HDMI-A-1:1920x1080@60e
===================================================
[ 0.000000] Kernel command line: initrd=/initramfs-linux.img console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait audit=0 splash plymouth.ignore-serial-consoles debug drm.debug=0x1e video=HDMI-A-1:1920x1080@60e
[ 1.289022] [drm:sun4i_drv_probe] Adding component /soc/bus@1000000/mixer@100000
[ 1.289126] [drm:sun4i_drv_probe] Adding component /soc/tcon-top@6510000
[ 1.289180] [drm:sun4i_drv_traverse_endpoints] No output to bind on port 3
[ 1.289232] [drm:sun4i_drv_probe] Adding component /soc/lcd-controller@6515000
[ 1.289277] [drm:sun4i_drv_traverse_endpoints] TCON output endpoint is TCON TOP... skipping
[ 1.289310] [drm:sun4i_drv_probe] Adding component /soc/hdmi@6000000
***
spi1: spi-gpio {
status = "okay";
compatible = "spi-gpio";
sck-gpios = <&gpio 36 0>;
miso-gpios = <&gpio 37 0>;
mosi-gpios = <&gpio 38 0>;
cs-gpios = <&gpio 34 0>, <&gpio 35 0>;
num-chipselects = <2>;
DMESG
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[ 0.000000] Linux version 6.3.0-rc6-3 (lane@SerialExperiment) (aarch64-linux-gnu-gcc (GCC) 13.1.0, GNU ld (GNU Binutils) 2.40) #1 SMP PREEMPT Wed Jul 5 08:41:56 MSK 2023
[ 0.000000] Machine model: Tanix TX6s (axp313)
[ 0.000000] efi: UEFI not found.
[ 0.000000] OF: reserved mem: 0x0000000040000000..0x000000004003ffff (256 KiB) nomap non-reusable secmon@40000000
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x0000000040000000-0x000000009fffffff]
[ 0.000000] DMA32 empty
[ 0.000000] Normal empty
// SPDX-License-Identifier: BSD-3-Clause
/dts-v1/;
#include "msm8976.dtsi"
#include "pm8950.dtsi"
#include "pm8004.dtsi"
#include "pmi8950.dtsi"
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/gpio-keys.h>
#include <dt-bindings/input/input.h>