[U-Boot,2/8] rockchip: rk3188: Decode the actual amount of ram

Message ID 20170320114036.21475-3-heiko@sntech.de
State Accepted
Commit 78959d4cbf429ac41f2903c87cbdf00852abb877
Delegated to: Simon Glass
Headers show

Commit Message

Heiko Stuebner March 20, 2017, 11:40 a.m.
There was still a static ram value set in the rk3188-board from the
time where we didn't have actual sdram init code.
Now the sdram init leaves the ram information in SYS_REG2 and we can
decode it similarly to the rk3288.

Right now we have two duplicates of that code, which is still ok and
doesn't really count as common code yet, but if we get a third copy
at some point from a newer soc, we should think about moving that to
a more general position.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 arch/arm/mach-rockchip/rk3188-board.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

Comments

Simon Glass March 24, 2017, 3:27 a.m. | #1
On 20 March 2017 at 05:40, Heiko Stuebner <heiko@sntech.de> wrote:
> There was still a static ram value set in the rk3188-board from the
> time where we didn't have actual sdram init code.
> Now the sdram init leaves the ram information in SYS_REG2 and we can
> decode it similarly to the rk3288.
>
> Right now we have two duplicates of that code, which is still ok and
> doesn't really count as common code yet, but if we get a third copy
> at some point from a newer soc, we should think about moving that to
> a more general position.
>
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> ---
>  arch/arm/mach-rockchip/rk3188-board.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>
Simon Glass March 26, 2017, 2:42 a.m. | #2
On 23 March 2017 at 21:27, Simon Glass <sjg@chromium.org> wrote:
> On 20 March 2017 at 05:40, Heiko Stuebner <heiko@sntech.de> wrote:
>> There was still a static ram value set in the rk3188-board from the
>> time where we didn't have actual sdram init code.
>> Now the sdram init leaves the ram information in SYS_REG2 and we can
>> decode it similarly to the rk3288.
>>
>> Right now we have two duplicates of that code, which is still ok and
>> doesn't really count as common code yet, but if we get a third copy
>> at some point from a newer soc, we should think about moving that to
>> a more general position.
>>
>> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
>> ---
>>  arch/arm/mach-rockchip/rk3188-board.c | 18 ++++++++++++++++--
>>  1 file changed, 16 insertions(+), 2 deletions(-)
>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-rockchip, thanks!

Patch

diff --git a/arch/arm/mach-rockchip/rk3188-board.c b/arch/arm/mach-rockchip/rk3188-board.c
index 16f38559af..c370156e4c 100644
--- a/arch/arm/mach-rockchip/rk3188-board.c
+++ b/arch/arm/mach-rockchip/rk3188-board.c
@@ -56,8 +56,22 @@  err:
 
 int dram_init(void)
 {
-	/* FIXME: read back ram size from sys_reg2 */
-	gd->ram_size = 0x40000000;
+	struct ram_info ram;
+	struct udevice *dev;
+	int ret;
+
+	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
+	if (ret) {
+		debug("DRAM init failed: %d\n", ret);
+		return ret;
+	}
+	ret = ram_get_info(dev, &ram);
+	if (ret) {
+		debug("Cannot get DRAM size: %d\n", ret);
+		return ret;
+	}
+	debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
+	gd->ram_size = ram.size;
 
 	return 0;
 }