Skip to contentSkip to conversation

ARM: keystone2: Miscellaneous fixes

PATCH Superseded Nishanth Menon 2 participants 14 messages Feb 25, 2016 – Feb 27, 2016

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Nishanth Menon

author maintainer
#0 lore raw

cover ARM: keystone2: Miscellaneous fixes

Hi,
Please find various fixes for DDR, DSP and speed grade operations w.r.t Keystone devices

Based on master 52dd704bf8ed Merge branch 'master' of http://git.denx.de/u-boot-sunxi

Lokesh Vutla (2):
ARM: keystone2: Allow for board specific speed definitions
ARM: keystone2: K2G: Add support for different arm/device speeds

Suman Anna (2):
ARM: keystone2: Use macro for DSP GEM power domain
ARM: keystone2: K2G: power-off DSP during boot

Vitaly Andrianov (2):
ARM: keystone2: use SPD info to configure K2HK and K2E DDR3
ARM: keystone2: use detected ddr3a size

 arch/arm/mach-keystone/Makefile                    |   2 +
 arch/arm/mach-keystone/clock.c                     |  19 +-
 arch/arm/mach-keystone/ddr3_spd.c                  | 466 +++++++++++++++++++++
 arch/arm/mach-keystone/include/mach/clock-k2g.h    |   4 +-
 arch/arm/mach-keystone/include/mach/clock.h        |   8 +-
 arch/arm/mach-keystone/include/mach/ddr3.h         |   9 +
 arch/arm/mach-keystone/include/mach/hardware-k2g.h |   7 +-
 arch/arm/mach-keystone/include/mach/hardware-k2l.h |   7 +
 arch/arm/mach-keystone/include/mach/hardware.h     |   1 +
 arch/arm/mach-keystone/keystone.c                  |   2 +-
 board/ti/ks2_evm/Makefile                          |   4 +-
 board/ti/ks2_evm/board.c                           |   4 +-
 board/ti/ks2_evm/board_k2e.c                       |   2 +-
 board/ti/ks2_evm/board_k2g.c                       |  50 ++-
 board/ti/ks2_evm/board_k2hk.c                      |   4 +-
 board/ti/ks2_evm/board_k2l.c                       |   4 +-
 board/ti/ks2_evm/ddr3_cfg.c                        | 159 +------
 board/ti/ks2_evm/ddr3_cfg.h                        |  11 +-
 board/ti/ks2_evm/ddr3_k2e.c                        |  51 +--
 board/ti/ks2_evm/ddr3_k2hk.c                       |  97 ++---
 include/configs/k2e_evm.h                          |   2 +
 include/configs/k2hk_evm.h                         |   2 +
 22 files changed, 628 insertions(+), 287 deletions(-)
 create mode 100644 arch/arm/mach-keystone/ddr3_spd.c
Signature · 1 line
2.7.0
author maintainer
#1 lore raw

PATCH 1/6 ARM: keystone2: Use macro for DSP GEM power domain

From: Suman Anna <[email protected]>

Define a macro for the DSP GEM power domain id number and use it instead of a hard-coded number in the code that disables all the DSPs on various Keystone2 SoCs.

---
 arch/arm/mach-keystone/include/mach/hardware.h | 1 +
 arch/arm/mach-keystone/keystone.c              | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-keystone/include/mach/hardware.h +1 -0
index edebcd7bc587..8ca19bbcdbe9 100644
@@ -160,6 +160,7 @@ typedef volatile unsigned int   *dv_reg_p;
 #define KS2_LPSC_GEM_0			15
 #define KS2_LPSC_TETRIS			52
 #define KS2_TETRIS_PWR_DOMAIN		31
+#define KS2_GEM_0_PWR_DOMAIN		8
 
 /* Chip configuration unlock codes and registers */
 #define KS2_KICK0			(KS2_DEVICE_STATE_CTRL_BASE + 0x38)
arch/arm/mach-keystone/keystone.c +1 -1
index 11a9357db414..a8071270e9bf 100644
@@ -54,7 +54,7 @@ static void turn_off_all_dsps(int num_dsps)
 		if (psc_disable_module(i + KS2_LPSC_GEM_0))
 			printf("Cannot disable module for #%d DSP", i);
 
-		if (psc_disable_domain(i + 8))
+		if (psc_disable_domain(i + KS2_GEM_0_PWR_DOMAIN))
 			printf("Cannot disable domain for #%d DSP", i);
 	}
 }
Signature · 1 line
2.7.0
#2 lore raw

PATCH 1/6 ARM: keystone2: Use macro for DSP GEM power domain

Quoted 8 lines · Nishanth Menon

From: Suman Anna <[email protected]>

Define a macro for the DSP GEM power domain id number and use it instead of a hard-coded number in the code that disables all the DSPs on various Keystone2 SoCs.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/4928e9da/attachment.sig>
author maintainer
#3 lore raw

PATCH 2/6 ARM: keystone2: K2G: power-off DSP during boot

In reply to Nishanth Menon

From: Suman Anna <[email protected]>

The DSPs are powered on by default upon a Power ON reset, and they are powered off on current Keystone 2 SoCs - K2HK, K2L, K2E during the boot in u-boot. This is not functional on K2G though. Extend the existing DSP power-off support to the only DSP present on K2G. Do note that the PSC clock domain module id for DSP on K2G differs from that of previous Keystone2 SoCs.

---
 arch/arm/mach-keystone/include/mach/hardware-k2g.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm/mach-keystone/include/mach/hardware-k2g.h +5 -2
index fa4162fe9964..ca2a119d3901 100644
@@ -10,7 +10,7 @@
 #ifndef __ASM_ARCH_HARDWARE_K2G_H
 #define __ASM_ARCH_HARDWARE_K2G_H
 
-#define KS2_NUM_DSPS	0
+#define KS2_NUM_DSPS			1
 
 /* Power and Sleep Controller (PSC) Domains */
 #define KS2_LPSC_ALWAYSON		0
@@ -30,7 +30,10 @@
 #define KS2_LPSC_MCASP			15
 #define KS2_LPSC_SR			16
 #define KS2_LPSC_MSMC			17
-#define KS2_LPSC_GEM			18
+#ifdef KS2_LPSC_GEM_0
+#undef KS2_LPSC_GEM_0
+#endif
+#define KS2_LPSC_GEM_0			18
 #define KS2_LPSC_ARM			19
 #define KS2_LPSC_ASRC			20
 #define KS2_LPSC_ICSS			21
Signature · 1 line
2.7.0
#4 lore raw

PATCH 2/6 ARM: keystone2: K2G: power-off DSP during boot

Quoted 11 lines · Nishanth Menon

From: Suman Anna <[email protected]>

The DSPs are powered on by default upon a Power ON reset, and they are powered off on current Keystone 2 SoCs - K2HK, K2L, K2E during the boot in u-boot. This is not functional on K2G though. Extend the existing DSP power-off support to the only DSP present on K2G. Do note that the PSC clock domain module id for DSP on K2G differs from that of previous Keystone2 SoCs.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/0efbf414/attachment.sig>
author maintainer
#5 lore raw

PATCH 3/6 ARM: keystone2: Allow for board specific speed definitions

In reply to Nishanth Menon

From: Lokesh Vutla <[email protected]>

Its not compulsory that speed definition should be same on EFUSE_BOOTROM register for all keystone 2 devices. So, allow for board specific speed definitions.

---
 arch/arm/mach-keystone/clock.c              | 12 ++++++------
 arch/arm/mach-keystone/include/mach/clock.h |  4 ++--
 board/ti/ks2_evm/board_k2e.c                |  2 +-
 board/ti/ks2_evm/board_k2hk.c               |  4 ++--
 board/ti/ks2_evm/board_k2l.c                |  4 ++--
 5 files changed, 13 insertions(+), 13 deletions(-)
arch/arm/mach-keystone/clock.c +6 -6
index 5c6051e76db8..1ae3baf982a1 100644
@@ -228,14 +228,14 @@ void init_plls(void)
 	}
 }
 
-static int get_max_speed(u32 val, u32 speed_supported)
+static int get_max_speed(u32 val, u32 speed_supported, int *spds)
 {
 	int speed;
 
 	/* Left most setbit gives the speed */
 	for (speed = DEVSPEED_NUMSPDS; speed >= 0; speed--) {
 		if ((val & BIT(speed)) & speed_supported)
-			return speeds[speed];
+			return spds[speed];
 	}
 
 	/* If no bit is set, use SPD800 */
@@ -250,24 +250,24 @@ static inline u32 read_efuse_bootrom(void)
 		return __raw_readl(KS2_EFUSE_BOOTROM);
 }
 
-int get_max_arm_speed(void)
+int get_max_arm_speed(int *spds)
 {
 	u32 armspeed = read_efuse_bootrom();
 
 	armspeed = (armspeed & DEVSPEED_ARMSPEED_MASK) >>
 		    DEVSPEED_ARMSPEED_SHIFT;
 
-	return get_max_speed(armspeed, ARM_SUPPORTED_SPEEDS);
+	return get_max_speed(armspeed, ARM_SUPPORTED_SPEEDS, spds);
 }
 
-int get_max_dev_speed(void)
+int get_max_dev_speed(int *spds)
 {
 	u32 devspeed = read_efuse_bootrom();
 
 	devspeed = (devspeed & DEVSPEED_DEVSPEED_MASK) >>
 		    DEVSPEED_DEVSPEED_SHIFT;
 
-	return get_max_speed(devspeed, DEV_SUPPORTED_SPEEDS);
+	return get_max_speed(devspeed, DEV_SUPPORTED_SPEEDS, spds);
 }
 
 /**
arch/arm/mach-keystone/include/mach/clock.h +2 -2
index cdcff3baee36..dfebcb03ea57 100644
@@ -124,8 +124,8 @@ struct pll_init_data *get_pll_init_data(int pll);
 unsigned long clk_get_rate(unsigned int clk);
 unsigned long clk_round_rate(unsigned int clk, unsigned long hz);
 int clk_set_rate(unsigned int clk, unsigned long hz);
-int get_max_dev_speed(void);
-int get_max_arm_speed(void);
+int get_max_dev_speed(int *spds);
+int get_max_arm_speed(int *spds);
 void pll_pa_clk_sel(void);
 
 #endif
board/ti/ks2_evm/board_k2e.c +1 -1
index f58f62358d3e..cbb3077bc36c 100644
@@ -61,7 +61,7 @@ struct pll_init_data *get_pll_init_data(int pll)
 
 	switch (pll) {
 	case MAIN_PLL:
-		speed = get_max_dev_speed();
+		speed = get_max_dev_speed(speeds);
 		data = &core_pll_config[speed];
 		break;
 	case PASS_PLL:
board/ti/ks2_evm/board_k2hk.c +2 -2
index 0bd6b86e2573..e217beaed5e4 100644
@@ -51,11 +51,11 @@ struct pll_init_data *get_pll_init_data(int pll)
 
 	switch (pll) {
 	case MAIN_PLL:
-		speed = get_max_dev_speed();
+		speed = get_max_dev_speed(speeds);
 		data = &core_pll_config[speed];
 		break;
 	case TETRIS_PLL:
-		speed = get_max_arm_speed();
+		speed = get_max_arm_speed(speeds);
 		data = &tetris_pll_config[speed];
 		break;
 	case PASS_PLL:
board/ti/ks2_evm/board_k2l.c +2 -2
index d750ad3c0b05..2a2e0057e24e 100644
@@ -50,11 +50,11 @@ struct pll_init_data *get_pll_init_data(int pll)
 
 	switch (pll) {
 	case MAIN_PLL:
-		speed = get_max_dev_speed();
+		speed = get_max_dev_speed(speeds);
 		data = &core_pll_config[speed];
 		break;
 	case TETRIS_PLL:
-		speed = get_max_arm_speed();
+		speed = get_max_arm_speed(speeds);
 		data = &tetris_pll_config[speed];
 		break;
 	case PASS_PLL:
Signature · 1 line
2.7.0
#6 lore raw

PATCH 3/6 ARM: keystone2: Allow for board specific speed definitions

Quoted 8 lines · Nishanth Menon

From: Lokesh Vutla <[email protected]>

Its not compulsory that speed definition should be same on EFUSE_BOOTROM register for all keystone 2 devices. So, allow for board specific speed definitions.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/35b0b3b1/attachment.sig>
author maintainer
#7 lore raw

PATCH 4/6 ARM: keystone2: K2G: Add support for different arm/device speeds

In reply to Nishanth Menon

From: Lokesh Vutla <[email protected]>

The maximum device and arm speeds can be determined by reading EFUSE_BOOTROM register. As there is already a framework for reading this register, adding support for all possible speeds on k2g devices.

---
 arch/arm/mach-keystone/clock.c                  |  7 +++-
 arch/arm/mach-keystone/include/mach/clock-k2g.h |  4 +-
 arch/arm/mach-keystone/include/mach/clock.h     |  4 ++
 board/ti/ks2_evm/board_k2g.c                    | 50 +++++++++++++++++++++++--
 4 files changed, 57 insertions(+), 8 deletions(-)
arch/arm/mach-keystone/clock.c +5 -2
index 1ae3baf982a1..b25db1e3fede 100644
@@ -238,8 +238,11 @@ static int get_max_speed(u32 val, u32 speed_supported, int *spds)
 			return spds[speed];
 	}
 
-	/* If no bit is set, use SPD800 */
-	return SPD800;
+	/* If no bit is set, return minimum speed */
+	if (cpu_is_k2g())
+		return SPD200;
+	else
+		return SPD800;
 }
 
 static inline u32 read_efuse_bootrom(void)
arch/arm/mach-keystone/include/mach/clock-k2g.h +2 -2
index 214c1d3a8360..74de6202fe50 100644
@@ -12,8 +12,8 @@
 
 #define PLLSET_CMD_LIST		"<pa|arm|ddr3>"
 
-#define DEV_SUPPORTED_SPEEDS	0xfff
-#define ARM_SUPPORTED_SPEEDS	0xfff
+#define DEV_SUPPORTED_SPEEDS	0x1ff
+#define ARM_SUPPORTED_SPEEDS	0xff
 
 #define KS2_CLK1_6 sys_clk0_6_clk
 
arch/arm/mach-keystone/include/mach/clock.h +4 -0
index dfebcb03ea57..72724aa4a912 100644
@@ -63,8 +63,12 @@
 #define CLOCK_INDEXES_LIST	CLK_LIST(GENERATE_INDX_STR)
 
 enum {
+	SPD200,
+	SPD400,
+	SPD600,
 	SPD800,
 	SPD850,
+	SPD900,
 	SPD1000,
 	SPD1200,
 	SPD1250,
board/ti/ks2_evm/board_k2g.c +46 -4

68 lines not on this page · raw message

Signature · 1 line
2.7.0
#8 lore raw

PATCH 4/6 ARM: keystone2: K2G: Add support for different arm/device speeds

Quoted 8 lines · Nishanth Menon

From: Lokesh Vutla <[email protected]>

The maximum device and arm speeds can be determined by reading EFUSE_BOOTROM register. As there is already a framework for reading this register, adding support for all possible speeds on k2g devices.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/fec49a5a/attachment.sig>
author maintainer
#9 lore raw

PATCH 5/6 ARM: keystone2: use SPD info to configure K2HK and K2E DDR3

In reply to Nishanth Menon

From: Vitaly Andrianov <[email protected]>

This commit replaces hard-coded EMIF and PHY DDR3 configurations for predefined SODIMMs to a calculated configuration. The SODIMM parameters are read from SODIMM's SPD and used to calculated the configuration.

The current commit supports calculation for DDR3 with 1600MHz and 1333MHz only.

---
 arch/arm/mach-keystone/Makefile            |   2 +
 arch/arm/mach-keystone/ddr3_spd.c          | 456 +++++++++++++++++++++++++++++
 arch/arm/mach-keystone/include/mach/ddr3.h |   8 +
 board/ti/ks2_evm/Makefile                  |   4 +-
 board/ti/ks2_evm/ddr3_cfg.c                | 159 +---------
 board/ti/ks2_evm/ddr3_cfg.h                |  11 +-
 board/ti/ks2_evm/ddr3_k2e.c                |  51 ++--
 board/ti/ks2_evm/ddr3_k2hk.c               |  97 +++---
 include/configs/k2e_evm.h                  |   2 +
 include/configs/k2hk_evm.h                 |   2 +
 10 files changed, 532 insertions(+), 260 deletions(-)
 create mode 100644 arch/arm/mach-keystone/ddr3_spd.c
arch/arm/mach-keystone/Makefile +2 -0
index ffd9eadb0a49..9713fe4d6858 100644
@@ -13,3 +13,5 @@ obj-y	+= cmd_mon.o
 obj-y	+= msmc.o
 obj-y	+= ddr3.o cmd_ddr3.o
 obj-y	+= keystone.o
+obj-$(CONFIG_K2E_EVM) += ddr3_spd.o
+obj-$(CONFIG_K2HK_EVM) += ddr3_spd.o
arch/arm/mach-keystone/ddr3_spd.c new file +456 -0

456 lines not on this page · raw message

arch/arm/mach-keystone/include/mach/ddr3.h +8 -0
index a22c237c8026..68d3cb4245e9 100644
@@ -48,6 +48,14 @@ struct ddr3_emif_config {
 	unsigned int sdrfc;
 };
 
+struct ddr3_spd_cb {
+	char   dimm_name[32];
+	struct ddr3_phy_config phy_cfg;
+	struct ddr3_emif_config emif_cfg;
+	unsigned int ddrspdclock;
+	int    ddr_size_gbyte;
+};
+
 u32 ddr3_init(void);
 void ddr3_reset_ddrphy(void);
 void ddr3_init_ecc(u32 base, u32 ddr3_size);
board/ti/ks2_evm/Makefile +2 -2
index d60496ef2723..7ef2d2bff5a0 100644
@@ -1,17 +1,17 @@
 #
 # KS2-EVM: board Makefile
-# (C) Copyright 2012-2014
+# (C) Copyright 2012-2015
 #     Texas Instruments Incorporated, <www.ti.com>
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
 obj-y += board.o
-obj-y += ddr3_cfg.o
 obj-$(CONFIG_K2HK_EVM) += board_k2hk.o
 obj-$(CONFIG_K2HK_EVM) += ddr3_k2hk.o
 obj-$(CONFIG_K2E_EVM) += board_k2e.o
 obj-$(CONFIG_K2E_EVM) += ddr3_k2e.o
 obj-$(CONFIG_K2L_EVM) += board_k2l.o
 obj-$(CONFIG_K2L_EVM) += ddr3_k2l.o
+obj-$(CONFIG_K2L_EVM) += ddr3_cfg.o
 obj-$(CONFIG_K2G_EVM) += board_k2g.o
 obj-$(CONFIG_K2G_EVM) += ddr3_k2g.o
board/ti/ks2_evm/ddr3_cfg.c +1 -158

169 lines not on this page · raw message

board/ti/ks2_evm/ddr3_cfg.h +2 -9
index 5bd786cff8e9..f95eddec3308 100644
@@ -10,18 +10,11 @@
 #ifndef __DDR3_CFG_H
 #define __DDR3_CFG_H
 
-extern struct ddr3_phy_config ddr3phy_1600_8g;
-extern struct ddr3_emif_config ddr3_1600_8g;
-
-extern struct ddr3_phy_config ddr3phy_1333_2g;
-extern struct ddr3_emif_config ddr3_1333_2g;
-
-extern struct ddr3_phy_config ddr3phy_1600_4g;
-extern struct ddr3_emif_config ddr3_1600_4g;
+#include <asm/arch/ddr3.h>
 
 extern struct ddr3_phy_config ddr3phy_1600_2g;
 extern struct ddr3_emif_config ddr3_1600_2g;
 
-int ddr3_get_dimm_params(char *dimm_name);
+int ddr3_get_dimm_params_from_spd(struct ddr3_spd_cb *spd_cb);
 
 #endif /* __DDR3_CFG_H */
board/ti/ks2_evm/ddr3_k2e.c +23 -28

72 lines not on this page · raw message

board/ti/ks2_evm/ddr3_k2hk.c +34 -63

111 lines not on this page · raw message

include/configs/k2e_evm.h +2 -0
index 4f4ebf53ec59..e053a54d4169 100644
@@ -38,4 +38,6 @@
 #define CONFIG_KSNET_CPSW_NUM_PORTS	9
 #define CONFIG_KSNET_MDIO_PHY_CONFIG_ENABLE
 
+#define CONFIG_DDR_SPD
+
 #endif /* __CONFIG_K2E_EVM_H */
include/configs/k2hk_evm.h +2 -0
index 6c6dcb1e5ed3..3cd2a85a2d11 100644
@@ -37,4 +37,6 @@
 #define CONFIG_KSNET_NETCP_V1_0
 #define CONFIG_KSNET_CPSW_NUM_PORTS	5
 
+#define CONFIG_DDR_SPD
+
 #endif /* __CONFIG_K2HK_EVM_H */
Signature · 1 line
2.7.0
#10 lore raw

PATCH 5/6 ARM: keystone2: use SPD info to configure K2HK and K2E DDR3

Quoted 12 lines · Nishanth Menon

From: Vitaly Andrianov <[email protected]>

This commit replaces hard-coded EMIF and PHY DDR3 configurations for predefined SODIMMs to a calculated configuration. The SODIMM parameters are read from SODIMM's SPD and used to calculated the configuration.

The current commit supports calculation for DDR3 with 1600MHz and 1333MHz only.

[snip]

arch/arm/mach-keystone/ddr3_spd.c line 18

Quoted 2 lines
arch/arm/mach-keystone/ddr3_spd.c new file +2 -0
+#ifdef DUMP_DDR_CONFIG
+static void dump_phy_config(struct ddr3_phy_config *ptr)

Please figure out how to do this with debug() instead.

[snip]

arch/arm/mach-keystone/ddr3_spd.c line 193

Quoted 1 line
arch/arm/mach-keystone/ddr3_spd.c new file +1 -0
+		puts("DDR3A Speed will be configured for 1333 Operation.\n");

Just printf, always, it's fine, really.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/e4d71068/attachment.sig>
author maintainer
#11 lore raw

PATCH 5/6 ARM: keystone2: use SPD info to configure K2HK and K2E DDR3

Quoted 20 lines · Tom Rini
Quoted 12 lines · Nishanth Menon

From: Vitaly Andrianov <[email protected]>

This commit replaces hard-coded EMIF and PHY DDR3 configurations for predefined SODIMMs to a calculated configuration. The SODIMM parameters are read from SODIMM's SPD and used to calculated the configuration.

The current commit supports calculation for DDR3 with 1600MHz and 1333MHz only.

[snip]

arch/arm/mach-keystone/ddr3_spd.c line 18

Quoted 2 lines
arch/arm/mach-keystone/ddr3_spd.c new file +2 -0
+#ifdef DUMP_DDR_CONFIG
+static void dump_phy_config(struct ddr3_phy_config *ptr)

Please figure out how to do this with debug() instead.

Quoted 5 lines

[snip]

Quoted 1 line

+ puts("DDR3A Speed will be configured for 1333 Operation.\n");

Just printf, always, it's fine, really.

Thank you for the review. Will try to do that and repost.

Signature · 3 lines
---
Regards,
Nishanth Menon
author maintainer
#12 lore raw

PATCH 6/6 ARM: keystone2: use detected ddr3a size

In reply to Nishanth Menon

From: Vitaly Andrianov <[email protected]>

Because KS2 u-boot works in 32 bit address space the existing ram_size global data field cannot be used. The maximum, which the get_ram_size() can detect is 2GB only. The ft_board_setup() needs the actual ddr3 size to fix up dtb.

This commit introduces the ddr3_get_size() which uses SPD data to calculate the ddr3 size. This function replaces the "ddr3_size" environment variable, which was used to get the SODIMM size.

For platforms, which don't have SODIMM with SPD and ddr3 is populated to a board a simple ddr3_get_size function that returns ddr3 size has to be implemented. See hardware-k2l.h

---
 arch/arm/mach-keystone/ddr3_spd.c                  | 10 ++++++++++
 arch/arm/mach-keystone/include/mach/ddr3.h         |  1 +
 arch/arm/mach-keystone/include/mach/hardware-k2l.h |  7 +++++++
 board/ti/ks2_evm/board.c                           |  4 +---
 4 files changed, 19 insertions(+), 3 deletions(-)
arch/arm/mach-keystone/ddr3_spd.c +10 -0
index b0768823f2eb..a99b7728cefb 100644
@@ -427,6 +427,16 @@ static int ddr3_read_spd(ddr3_spd_eeprom_t *spd_params)
 	return 0;
 }
 
+int ddr3_get_size(void)
+{
+	ddr3_spd_eeprom_t spd_params;
+
+	if (ddr3_read_spd(&spd_params))
+		return 0;
+
+	return ddr3_get_size_in_mb(&spd_params) / 1024;
+}
+
 int ddr3_get_dimm_params_from_spd(struct ddr3_spd_cb *spd_cb)
 {
 	struct ddr3_sodimm spd;
arch/arm/mach-keystone/include/mach/ddr3.h +1 -0
index 68d3cb4245e9..5feffe825b97 100644
@@ -66,5 +66,6 @@ void ddr3_err_reset_workaround(void);
 void ddr3_enable_ecc(u32 base, int test);
 void ddr3_init_ddrphy(u32 base, struct ddr3_phy_config *phy_cfg);
 void ddr3_init_ddremif(u32 base, struct ddr3_emif_config *emif_cfg);
+int ddr3_get_size(void);
 
 #endif
arch/arm/mach-keystone/include/mach/hardware-k2l.h +7 -0
index 4f1197ea923d..a59e0713593f 100644
@@ -105,4 +105,11 @@
 /* NETCP */
 #define KS2_NETCP_BASE			0x26000000
 
+#ifndef __ASSEMBLY__
+static inline int ddr3_get_size(void)
+{
+	return 2;
+}
+#endif
+
 #endif /* __ASM_ARCH_HARDWARE_K2L_H */
board/ti/ks2_evm/board.c +1 -3
index 7d1709c880af..ca668a7c6902 100644
@@ -146,9 +146,7 @@ int ft_board_setup(void *blob, bd_t *bd)
 
 	ddr3a_size = 0;
 	if (lpae) {
-		env = getenv("ddr3a_size");
-		if (env)
-			ddr3a_size = simple_strtol(env, NULL, 10);
+		ddr3a_size = ddr3_get_size();
 		if ((ddr3a_size != 8) && (ddr3a_size != 4))
 			ddr3a_size = 0;
 	}
Signature · 1 line
2.7.0
#13 lore raw

PATCH 6/6 ARM: keystone2: use detected ddr3a size

Quoted 11 lines · Nishanth Menon

From: Vitaly Andrianov <[email protected]>

Because KS2 u-boot works in 32 bit address space the existing ram_size global data field cannot be used. The maximum, which the get_ram_size() can detect is 2GB only. The ft_board_setup() needs the actual ddr3 size to fix up dtb.

This commit introduces the ddr3_get_size() which uses SPD data to calculate the ddr3 size. This function replaces the "ddr3_size" environment variable, which was used to get the SODIMM size.

Quoted 6 lines

For platforms, which don't have SODIMM with SPD and ddr3 is populated to a board a simple ddr3_get_size function that returns ddr3 size has to be implemented. See hardware-k2l.h

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/3cf7298e/attachment.sig>