Skip to content

Instantly share code, notes, and snippets.

@iuncuim
Created December 16, 2023 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iuncuim/3d2b20f7274aa8ea69a634bc7aeb54a2 to your computer and use it in GitHub Desktop.
Save iuncuim/3d2b20f7274aa8ea69a634bc7aeb54a2 to your computer and use it in GitHub Desktop.
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))
+ return (1ULL << (config->cols + config->rows + 3)) * width * config->ranks * 3 / 4;
return (1ULL << (config->cols + config->rows + 3)) * width * config->ranks;
}
@MichaIng
Copy link

Many thanks, @iuncuim, this is what we were looking for. I am no C coder, but isn't it possible to reuse the offset variable, like

	u32 offset = (1ULL << (config->cols + config->rows + 3)) * width * config->ranks;
	if (mctl_mem_matches(offset-0x10))
		return offset * 3 / 4;
 	return offset;

?

@iuncuim
Copy link
Author

iuncuim commented Jan 24, 2024

it doesn't matter since it doesn't work with opizero3 lpddr4

@MichaIng
Copy link

MichaIng commented Jan 24, 2024

Oh that is sad to hear. Then I can skip testing it. Is this one supposed to work instead? EDIT: Just read our answer on the OpenWRT forum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment