All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/3] ram: k3-am654: Add support for LPDDR4 and DDR3L
@ 2019-10-07  8:34 Lokesh Vutla
  2019-10-07  8:34 ` [U-Boot] [PATCH 1/3] armv7r: dts: am654-base-board: Rename 1600MHz to 1600MTs in dtsi filename Lokesh Vutla
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Lokesh Vutla @ 2019-10-07  8:34 UTC (permalink / raw)
  To: u-boot

This series adds support for LPDDR4 and DDR3L ddrs for k3-am654 and
minor updates to driver.

James Doublesin (3):
  armv7r: dts: am654-base-board: Rename 1600MHz to 1600MTs in dtsi
    filename
  ram: k3-am654: add support for LPDDR4 and DDR3L DDRs
  ram: k3-am654: Do not rely on default values for certain DDR register

 ... => k3-am654-base-board-ddr4-1600MTs.dtsi} |  30 +-
 arch/arm/dts/k3-am654-ddr.dtsi                |   9 +
 arch/arm/dts/k3-am654-r5-base-board.dts       |   2 +-
 drivers/ram/k3-am654-ddrss.c                  | 284 +++++++++++++++++-
 drivers/ram/k3-am654-ddrss.h                  |  10 +
 5 files changed, 310 insertions(+), 25 deletions(-)
 rename arch/arm/dts/{k3-am654-base-board-ddr4-1600MHz.dtsi => k3-am654-base-board-ddr4-1600MTs.dtsi} (88%)

-- 
2.23.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 1/3] armv7r: dts: am654-base-board: Rename 1600MHz to 1600MTs in dtsi filename
  2019-10-07  8:34 [U-Boot] [PATCH 0/3] ram: k3-am654: Add support for LPDDR4 and DDR3L Lokesh Vutla
@ 2019-10-07  8:34 ` Lokesh Vutla
  2019-10-26  0:06   ` Tom Rini
  2019-10-07  8:34 ` [U-Boot] [PATCH 2/3] ram: k3-am654: add support for LPDDR4 and DDR3L DDRs Lokesh Vutla
  2019-10-07  8:34 ` [U-Boot] [PATCH 3/3] ram: k3-am654: Do not rely on default values for certain DDR register Lokesh Vutla
  2 siblings, 1 reply; 7+ messages in thread
From: Lokesh Vutla @ 2019-10-07  8:34 UTC (permalink / raw)
  To: u-boot

From: James Doublesin <doublesin@ti.com>

The current configuration of DDR on AM654 base board is for 1600MTs but
the file name is specified as k3-am654-base-board-ddr4-1600MHz.dtsi.
Since 1600MHz is misleading, rename it to
k3-am654-base-board-ddr4-1600MTs.dtsi

Signed-off-by: James Doublesin <doublesin@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 ...-ddr4-1600MHz.dtsi => k3-am654-base-board-ddr4-1600MTs.dtsi} | 0
 arch/arm/dts/k3-am654-r5-base-board.dts                         | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename arch/arm/dts/{k3-am654-base-board-ddr4-1600MHz.dtsi => k3-am654-base-board-ddr4-1600MTs.dtsi} (100%)

diff --git a/arch/arm/dts/k3-am654-base-board-ddr4-1600MHz.dtsi b/arch/arm/dts/k3-am654-base-board-ddr4-1600MTs.dtsi
similarity index 100%
rename from arch/arm/dts/k3-am654-base-board-ddr4-1600MHz.dtsi
rename to arch/arm/dts/k3-am654-base-board-ddr4-1600MTs.dtsi
diff --git a/arch/arm/dts/k3-am654-r5-base-board.dts b/arch/arm/dts/k3-am654-r5-base-board.dts
index 7ed307f0d8..b94b30aca2 100644
--- a/arch/arm/dts/k3-am654-r5-base-board.dts
+++ b/arch/arm/dts/k3-am654-r5-base-board.dts
@@ -7,7 +7,7 @@
 
 #include "k3-am654.dtsi"
 #include "k3-am654-base-board-u-boot.dtsi"
-#include "k3-am654-base-board-ddr4-1600MHz.dtsi"
+#include "k3-am654-base-board-ddr4-1600MTs.dtsi"
 #include "k3-am654-ddr.dtsi"
 
 / {
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 2/3] ram: k3-am654: add support for LPDDR4 and DDR3L DDRs
  2019-10-07  8:34 [U-Boot] [PATCH 0/3] ram: k3-am654: Add support for LPDDR4 and DDR3L Lokesh Vutla
  2019-10-07  8:34 ` [U-Boot] [PATCH 1/3] armv7r: dts: am654-base-board: Rename 1600MHz to 1600MTs in dtsi filename Lokesh Vutla
@ 2019-10-07  8:34 ` Lokesh Vutla
  2019-10-26  0:06   ` Tom Rini
  2019-10-07  8:34 ` [U-Boot] [PATCH 3/3] ram: k3-am654: Do not rely on default values for certain DDR register Lokesh Vutla
  2 siblings, 1 reply; 7+ messages in thread
From: Lokesh Vutla @ 2019-10-07  8:34 UTC (permalink / raw)
  To: u-boot

From: James Doublesin <doublesin@ti.com>

Added training support for LPDDR4 and DDR3L DDRs.  Also added/changed
some register configuration to support all 3 DDR types

Signed-off-by: James Doublesin <doublesin@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 drivers/ram/k3-am654-ddrss.c | 241 +++++++++++++++++++++++++++++++++--
 1 file changed, 230 insertions(+), 11 deletions(-)

diff --git a/drivers/ram/k3-am654-ddrss.c b/drivers/ram/k3-am654-ddrss.c
index 7957f678a1..100cb9f801 100644
--- a/drivers/ram/k3-am654-ddrss.c
+++ b/drivers/ram/k3-am654-ddrss.c
@@ -143,6 +143,7 @@ static void am654_ddrss_ctrl_configuration(struct am654_ddrss_desc *ddrss)
 	ddrss_ctl_writel(DDRSS_DDRCTL_DRAMTMG11, tmg->ddrctl_dramtmg11);
 	ddrss_ctl_writel(DDRSS_DDRCTL_DRAMTMG12, tmg->ddrctl_dramtmg12);
 	ddrss_ctl_writel(DDRSS_DDRCTL_DRAMTMG13, tmg->ddrctl_dramtmg13);
+	ddrss_ctl_writel(DDRSS_DDRCTL_DRAMTMG14, tmg->ddrctl_dramtmg14);
 	ddrss_ctl_writel(DDRSS_DDRCTL_DRAMTMG15, tmg->ddrctl_dramtmg15);
 	ddrss_ctl_writel(DDRSS_DDRCTL_DRAMTMG17, tmg->ddrctl_dramtmg17);
 
@@ -152,6 +153,7 @@ static void am654_ddrss_ctrl_configuration(struct am654_ddrss_desc *ddrss)
 	ddrss_ctl_writel(DDRSS_DDRCTL_DFITMG0, reg->ddrctl_dfitmg0);
 	ddrss_ctl_writel(DDRSS_DDRCTL_DFITMG1, reg->ddrctl_dfitmg1);
 	ddrss_ctl_writel(DDRSS_DDRCTL_DFITMG2, reg->ddrctl_dfitmg2);
+	ddrss_ctl_writel(DDRSS_DDRCTL_DFIMISC, reg->ddrctl_dfimisc);
 
 	ddrss_ctl_writel(DDRSS_DDRCTL_ADDRMAP0, map->ddrctl_addrmap0);
 	ddrss_ctl_writel(DDRSS_DDRCTL_ADDRMAP1, map->ddrctl_addrmap1);
@@ -204,11 +206,13 @@ static void am654_ddrss_phy_configuration(struct am654_ddrss_desc *ddrss)
 
 	debug("%s: DDR phy register configuration started\n", __func__);
 
+	ddrss_phy_writel(DDRSS_DDRPHY_PGCR0, cfg->ddrphy_pgcr0);
 	ddrss_phy_writel(DDRSS_DDRPHY_PGCR1, cfg->ddrphy_pgcr1);
 	ddrss_phy_writel(DDRSS_DDRPHY_PGCR2, cfg->ddrphy_pgcr2);
 	ddrss_phy_writel(DDRSS_DDRPHY_PGCR3, cfg->ddrphy_pgcr3);
 	ddrss_phy_writel(DDRSS_DDRPHY_PGCR6, cfg->ddrphy_pgcr6);
 
+	ddrss_phy_writel(DDRSS_DDRPHY_PTR2, tmg->ddrphy_ptr2);
 	ddrss_phy_writel(DDRSS_DDRPHY_PTR3, tmg->ddrphy_ptr3);
 	ddrss_phy_writel(DDRSS_DDRPHY_PTR4, tmg->ddrphy_ptr4);
 	ddrss_phy_writel(DDRSS_DDRPHY_PTR5, tmg->ddrphy_ptr5);
@@ -240,6 +244,11 @@ static void am654_ddrss_phy_configuration(struct am654_ddrss_desc *ddrss)
 	ddrss_phy_writel(DDRSS_DDRPHY_MR4, ctrl->ddrphy_mr4);
 	ddrss_phy_writel(DDRSS_DDRPHY_MR5, ctrl->ddrphy_mr5);
 	ddrss_phy_writel(DDRSS_DDRPHY_MR6, ctrl->ddrphy_mr6);
+	ddrss_phy_writel(DDRSS_DDRPHY_MR11, ctrl->ddrphy_mr11);
+	ddrss_phy_writel(DDRSS_DDRPHY_MR12, ctrl->ddrphy_mr12);
+	ddrss_phy_writel(DDRSS_DDRPHY_MR13, ctrl->ddrphy_mr13);
+	ddrss_phy_writel(DDRSS_DDRPHY_MR14, ctrl->ddrphy_mr14);
+	ddrss_phy_writel(DDRSS_DDRPHY_MR22, ctrl->ddrphy_mr22);
 
 	ddrss_phy_writel(DDRSS_DDRPHY_VTCR0, ctrl->ddrphy_vtcr0);
 
@@ -354,13 +363,32 @@ int read_dqs_training(struct am654_ddrss_desc *ddrss)
 	return 0;
 }
 
-int rest_training(struct am654_ddrss_desc *ddrss)
+int dqs2dq_training(struct am654_ddrss_desc *ddrss)
 {
 	int ret;
-	u32 val;
-	u32 dgsl0, dgsl1, dgsl2, dgsl3, rddly, rd2wr_wr2rd;
 
-	debug("%s: Rest of the training started\n", __func__);
+	debug("%s: DQS2DQ training started\n", __func__);
+
+	ret = __phy_builtin_init_routine(ddrss, PIR_DQS2DQ_MASK,
+					 PGSR0_DQS2DQDONE_MASK,
+					 PGSR0_DQS2DQERR_MASK);
+	if (ret) {
+		if (ret == -ETIMEDOUT)
+			printf("%s: ERROR: DQS2DQ training timedout\n",
+			       __func__);
+		else
+			printf("%s:ERROR: DQS2DQ training failed\n",
+			       __func__);
+		return ret;
+	}
+
+	debug("%s: DQS2DQ training completed\n", __func__);
+	return 0;
+}
+
+int write_leveling_adjustment(struct am654_ddrss_desc *ddrss)
+{
+	int ret;
 
 	debug("%s: Write Leveling adjustment\n", __func__);
 	ret = __phy_builtin_init_routine(ddrss, PIR_WLADJ_MASK,
@@ -374,6 +402,14 @@ int rest_training(struct am654_ddrss_desc *ddrss)
 			       __func__);
 		return ret;
 	}
+	return 0;
+}
+
+int rest_training(struct am654_ddrss_desc *ddrss)
+{
+	int ret;
+
+	debug("%s: Rest of the training started\n", __func__);
 
 	debug("%s: Read Deskew adjustment\n", __func__);
 	ret = __phy_builtin_init_routine(ddrss, PIR_RDDSKW_MASK,
@@ -422,7 +458,12 @@ int rest_training(struct am654_ddrss_desc *ddrss)
 			       __func__);
 		return ret;
 	}
+	return 0;
+}
 
+int VREF_training(struct am654_ddrss_desc *ddrss)
+{
+	int ret;
 	debug("%s: VREF training\n", __func__);
 	ret = __phy_builtin_init_routine(ddrss, PIR_VREF_MASK, PGSR0_VDONE_MASK,
 					 PGSR0_VERR_MASK);
@@ -433,6 +474,31 @@ int rest_training(struct am654_ddrss_desc *ddrss)
 			printf("%s: ERROR: VREF training failed\n", __func__);
 		return ret;
 	}
+	return 0;
+}
+
+int enable_dqs_pd(struct am654_ddrss_desc *ddrss)
+{
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL0DQSCTL, 0x012640F7);
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL1DQSCTL, 0x012640F7);
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL2DQSCTL, 0x012640F7);
+	sdelay(16);
+	return 0;
+}
+
+int disable_dqs_pd(struct am654_ddrss_desc *ddrss)
+{
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL0DQSCTL, 0x01264000);
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL1DQSCTL, 0x01264000);
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL2DQSCTL, 0x01264000);
+	sdelay(16);
+	return 0;
+}
+
+int cleanup_training(struct am654_ddrss_desc *ddrss)
+{
+	u32 val;
+	u32 dgsl0, dgsl1, dgsl2, dgsl3, rddly, rd2wr_wr2rd;
 
 	ddrss_phy_writel(DDRSS_DDRPHY_RANKIDR, 0x00000000);
 	dgsl0 = (ddrss_phy_readl(DDRSS_DDRPHY_DX0GTR0) & 0x1F) >> 2;
@@ -528,6 +594,9 @@ int rest_training(struct am654_ddrss_desc *ddrss)
 static int am654_ddrss_init(struct am654_ddrss_desc *ddrss)
 {
 	int ret;
+	u32 val;
+
+	debug("Starting DDR initialization...\n");
 
 	debug("%s(ddrss=%p)\n", __func__, ddrss);
 
@@ -541,6 +610,7 @@ static int am654_ddrss_init(struct am654_ddrss_desc *ddrss)
 
 	am654_ddrss_phy_configuration(ddrss);
 
+	debug("Starting DDR training...\n");
 	ret = __phy_builtin_init_routine(ddrss, PIR_PHY_INIT, 0x1, 0);
 	if (ret) {
 		dev_err(ddrss->dev, "PHY initialization failed %d\n", ret);
@@ -561,15 +631,162 @@ static int am654_ddrss_init(struct am654_ddrss_desc *ddrss)
 		return ret;
 	}
 
-	ret = write_leveling(ddrss);
-	if (ret)
-		return ret;
+	val = am654_ddrss_get_type(ddrss);
 
-	ret = read_dqs_training(ddrss);
-	if (ret)
-		return ret;
+	switch (val) {
+	case DDR_TYPE_LPDDR4:
+
+		ret = __phy_builtin_init_routine(ddrss, PIR_DRAM_INIT,
+						 PGSR0_DRAM_INIT_MASK, 0);
+		if (ret) {
+			dev_err(ddrss->dev, "DRAM initialization failed %d\n",
+				ret);
+			return ret;
+		}
+
+		/* must perform DRAM_INIT twice for LPDDR4 */
+		ret = __phy_builtin_init_routine(ddrss, PIR_DRAM_INIT,
+						 PGSR0_DRAM_INIT_MASK, 0);
+		if (ret) {
+			dev_err(ddrss->dev, "DRAM initialization failed %d\n",
+				ret);
+			return ret;
+		}
+
+		ret = am654_ddrss_dram_wait_for_init_complt(ddrss);
+		if (ret) {
+			printf("%s: ERROR: DRAM Wait for init complete timedout\n",
+			       __func__);
+			return ret;
+		}
+
+		ret = write_leveling(ddrss);
+		if (ret)
+			return ret;
+
+		ret = enable_dqs_pd(ddrss);
+		if (ret)
+			return ret;
+
+		ret = read_dqs_training(ddrss);
+		if (ret)
+			return ret;
+
+		ret = disable_dqs_pd(ddrss);
+		if (ret)
+			return ret;
+
+		ret = dqs2dq_training(ddrss);
+		if (ret)
+			return ret;
+
+		ret = write_leveling_adjustment(ddrss);
+		if (ret)
+			return ret;
+
+		ret = rest_training(ddrss);
+		if (ret)
+			return ret;
+
+		ret = VREF_training(ddrss);
+		if (ret)
+			return ret;
+
+		debug("LPDDR4 training complete\n");
+		break;
+
+	case DDR_TYPE_DDR4:
+
+		debug("Starting DDR4 training\n");
+
+		ret = __phy_builtin_init_routine(ddrss, PIR_DRAM_INIT,
+						 PGSR0_DRAM_INIT_MASK, 0);
+		if (ret) {
+			dev_err(ddrss->dev, "DRAM initialization failed %d\n",
+				ret);
+			return ret;
+		}
+
+		ret = am654_ddrss_dram_wait_for_init_complt(ddrss);
+		if (ret) {
+			printf("%s: ERROR: DRAM Wait for init complete timedout\n",
+			       __func__);
+			return ret;
+		}
+
+		ret = write_leveling(ddrss);
+		if (ret)
+			return ret;
 
-	ret = rest_training(ddrss);
+		ret = read_dqs_training(ddrss);
+		if (ret)
+			return ret;
+
+		ret = write_leveling_adjustment(ddrss);
+		if (ret)
+			return ret;
+
+		ret = rest_training(ddrss);
+		if (ret)
+			return ret;
+
+		ret = VREF_training(ddrss);
+		if (ret)
+			return ret;
+		debug("DDR4 training complete\n");
+		break;
+
+	case DDR_TYPE_DDR3:
+
+		debug("Starting DDR3 training\n");
+
+		ret = __phy_builtin_init_routine(ddrss, PIR_DRAM_INIT,
+						 PGSR0_DRAM_INIT_MASK, 0);
+		if (ret) {
+			dev_err(ddrss->dev, "DRAM initialization failed %d\n",
+				ret);
+			return ret;
+		}
+
+		ret = am654_ddrss_dram_wait_for_init_complt(ddrss);
+		if (ret) {
+			printf("%s: ERROR: DRAM Wait for init complete timedout\n",
+			       __func__);
+			return ret;
+		}
+
+		ret = write_leveling(ddrss);
+		if (ret)
+			return ret;
+
+		ret = enable_dqs_pd(ddrss);
+		if (ret)
+			return ret;
+
+		ret = read_dqs_training(ddrss);
+		if (ret)
+			return ret;
+
+		ret = disable_dqs_pd(ddrss);
+		if (ret)
+			return ret;
+
+		ret = write_leveling_adjustment(ddrss);
+		if (ret)
+			return ret;
+
+		ret = rest_training(ddrss);
+		if (ret)
+			return ret;
+
+		debug("DDR3 training complete\n");
+		break;
+	default:
+		printf("%s: ERROR: Unsupported DDR type\n", __func__);
+		return -EINVAL;
+	}
+
+	ret = cleanup_training(ddrss);
 	if (ret)
 		return ret;
 
@@ -581,6 +798,8 @@ static int am654_ddrss_init(struct am654_ddrss_desc *ddrss)
 	ddrss_phy_writel(DDRSS_DDRPHY_PGCR1,
 			 ddrss_phy_readl(DDRSS_DDRPHY_PGCR1) & ~0x40);
 
+	debug("Completed DDR training\n");
+
 	return 0;
 }
 
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 3/3] ram: k3-am654: Do not rely on default values for certain DDR register
  2019-10-07  8:34 [U-Boot] [PATCH 0/3] ram: k3-am654: Add support for LPDDR4 and DDR3L Lokesh Vutla
  2019-10-07  8:34 ` [U-Boot] [PATCH 1/3] armv7r: dts: am654-base-board: Rename 1600MHz to 1600MTs in dtsi filename Lokesh Vutla
  2019-10-07  8:34 ` [U-Boot] [PATCH 2/3] ram: k3-am654: add support for LPDDR4 and DDR3L DDRs Lokesh Vutla
@ 2019-10-07  8:34 ` Lokesh Vutla
  2019-10-26  0:06   ` Tom Rini
  2 siblings, 1 reply; 7+ messages in thread
From: Lokesh Vutla @ 2019-10-07  8:34 UTC (permalink / raw)
  To: u-boot

From: James Doublesin <doublesin@ti.com>

Added the following registers to the DDR configuration:
- ACIOCR0,
- ACIOCR3,
- V2H_CTL_REG,
- DX8SLxDQSCTL.

Modified enable_dqs_pd and disable_dqs_pd to only touch the associated
bit fields for pullup and pulldown registers (to preserve slew rate and
other bits in that same register). Also update the dts files in the same
patch to maintain git bisectability.

Signed-off-by: James Doublesin <doublesin@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 .../dts/k3-am654-base-board-ddr4-1600MTs.dtsi | 30 ++++++----
 arch/arm/dts/k3-am654-ddr.dtsi                |  9 +++
 drivers/ram/k3-am654-ddrss.c                  | 55 ++++++++++++++++---
 drivers/ram/k3-am654-ddrss.h                  | 10 ++++
 4 files changed, 85 insertions(+), 19 deletions(-)

diff --git a/arch/arm/dts/k3-am654-base-board-ddr4-1600MTs.dtsi b/arch/arm/dts/k3-am654-base-board-ddr4-1600MTs.dtsi
index e861cb7c67..d07aaea93f 100644
--- a/arch/arm/dts/k3-am654-base-board-ddr4-1600MTs.dtsi
+++ b/arch/arm/dts/k3-am654-base-board-ddr4-1600MTs.dtsi
@@ -1,15 +1,16 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
- * This file was generated by the AM65x_DRA80xM EMIF Tool:
+ * This file was generated by AM65x_DRA80xM_EMIF_Tool_1.98.xlsm
  * http://www.ti.com/lit/pdf/spracj0
  * Configuration Parameters
  * Memory Type: DDR4
- * Data Rate: 1600
+ * Data Rate: 1600 MT/s
  * ECC Enabled: No
- * Data Width: 32
+ * Data Width: 32 bits
  */
 #define DDR_PLL_FREQUENCY 400000000
+#define DDRSS_V2H_CTL_REG 0x000073FF
 #define DDRCTL_MSTR 0x41040010
 #define DDRCTL_RFSHCTL0 0x00210070
 #define DDRCTL_ECCCFG0 0x00000000
@@ -32,10 +33,10 @@
 #define DDRCTL_DRAMTMG5 0x04040302
 #define DDRCTL_DRAMTMG6 0x00000004
 #define DDRCTL_DRAMTMG7 0x00000404
-#define DDRCTL_DRAMTMG8 0x03030C05
+#define DDRCTL_DRAMTMG8 0x03030A05
 #define DDRCTL_DRAMTMG9 0x00020208
 #define DDRCTL_DRAMTMG10 0x001C180A
-#define DDRCTL_DRAMTMG11 0x1106010E
+#define DDRCTL_DRAMTMG11 0x0E06010E
 #define DDRCTL_DRAMTMG12 0x00020008
 #define DDRCTL_DRAMTMG13 0x0B100002
 #define DDRCTL_DRAMTMG14 0x00000000
@@ -47,7 +48,7 @@
 #define DDRCTL_DFITMG1 0x000A0606
 #define DDRCTL_DFITMG2 0x00000604
 #define DDRCTL_DFIMISC 0x00000001
-#define DDRCTL_ADDRMAP0 0x001F1F1F
+#define DDRCTL_ADDRMAP0 0x0000001F
 #define DDRCTL_ADDRMAP1 0x003F0808
 #define DDRCTL_ADDRMAP2 0x00000000
 #define DDRCTL_ADDRMAP3 0x00000000
@@ -83,13 +84,13 @@
 #define DDRPHY_DCR 0x0000040C
 #define DDRPHY_DTPR0 0x041A0B06
 #define DDRPHY_DTPR1 0x28140000
-#define DDRPHY_DTPR2 0x0034E300
-#define DDRPHY_DTPR3 0x02800800
+#define DDRPHY_DTPR2 0x0034E255
+#define DDRPHY_DTPR3 0x01D50800
 #define DDRPHY_DTPR4 0x31180805
 #define DDRPHY_DTPR5 0x00250B06
 #define DDRPHY_DTPR6 0x00000505
 #define DDRPHY_ZQCR 0x008A2A58
-#define DDRPHY_ZQ0PR0    0x000077DD
+#define DDRPHY_ZQ0PR0 0x000077DD
 #define DDRPHY_ZQ1PR0 0x000077DD
 #define DDRPHY_MR0 0x00000214
 #define DDRPHY_MR1 0x00000501
@@ -109,6 +110,8 @@
 #define DDRPHY_DX8SL2PLLCR0 0x021c4000
 #define DDRPHY_DTCR0 0x8000B1C7
 #define DDRPHY_DTCR1 0x00010236
+#define DDRPHY_ACIOCR0 0x30070000
+#define DDRPHY_ACIOCR3 0x00000001
 #define DDRPHY_ACIOCR5 0x04800000
 #define DDRPHY_IOVCR0 0x0F0C0C0C
 #define DDRPHY_DX0GCR0 0x00000000
@@ -148,9 +151,12 @@
 #define DDRPHY_DX3GTR0 0x00020002
 #define DDRPHY_DX4GTR0 0x00020002
 #define DDRPHY_ODTCR 0x00010000
-#define DDRPHY_DX8SL0IOCR 0x04800000
-#define DDRPHY_DX8SL1IOCR 0x04800000
-#define DDRPHY_DX8SL2IOCR 0x04800000
+#define DDRPHY_DX8SL0IOCR 0x74800000
+#define DDRPHY_DX8SL1IOCR 0x74800000
+#define DDRPHY_DX8SL2IOCR 0x74800000
 #define DDRPHY_DX8SL0DXCTL2 0x00141830
 #define DDRPHY_DX8SL1DXCTL2 0x00141830
 #define DDRPHY_DX8SL2DXCTL2 0x00141830
+#define DDRPHY_DX8SL0DQSCTL 0x01264000
+#define DDRPHY_DX8SL1DQSCTL 0x01264000
+#define DDRPHY_DX8SL2DQSCTL 0x01264000
diff --git a/arch/arm/dts/k3-am654-ddr.dtsi b/arch/arm/dts/k3-am654-ddr.dtsi
index 622a3edb61..b22879695e 100644
--- a/arch/arm/dts/k3-am654-ddr.dtsi
+++ b/arch/arm/dts/k3-am654-ddr.dtsi
@@ -17,6 +17,10 @@
 		assigned-clock-rates = <DDR_PLL_FREQUENCY>;
 		u-boot,dm-spl;
 
+		ti,ss-reg = <
+			DDRSS_V2H_CTL_REG
+		>;
+
 		ti,ctl-reg = <
 			DDRCTL_DFIMISC
 			DDRCTL_DFITMG0
@@ -132,12 +136,15 @@
 			DDRPHY_DX8SL0DXCTL2
 			DDRPHY_DX8SL0IOCR
 			DDRPHY_DX8SL0PLLCR0
+			DDRPHY_DX8SL0DQSCTL
 			DDRPHY_DX8SL1DXCTL2
 			DDRPHY_DX8SL1IOCR
 			DDRPHY_DX8SL1PLLCR0
+			DDRPHY_DX8SL1DQSCTL
 			DDRPHY_DX8SL2DXCTL2
 			DDRPHY_DX8SL2IOCR
 			DDRPHY_DX8SL2PLLCR0
+			DDRPHY_DX8SL2DQSCTL
 			DDRPHY_DXCCR
 			DDRPHY_ODTCR
 			DDRPHY_PGCR0
@@ -168,6 +175,8 @@
 		>;
 
 		ti,phy-ioctl = <
+			DDRPHY_ACIOCR0
+			DDRPHY_ACIOCR3
 			DDRPHY_ACIOCR5
 			DDRPHY_IOVCR0
 		>;
diff --git a/drivers/ram/k3-am654-ddrss.c b/drivers/ram/k3-am654-ddrss.c
index 100cb9f801..7015d8cfe7 100644
--- a/drivers/ram/k3-am654-ddrss.c
+++ b/drivers/ram/k3-am654-ddrss.c
@@ -259,6 +259,8 @@ static void am654_ddrss_phy_configuration(struct am654_ddrss_desc *ddrss)
 	ddrss_phy_writel(DDRSS_DDRPHY_DTCR0, ctrl->ddrphy_dtcr0);
 	ddrss_phy_writel(DDRSS_DDRPHY_DTCR1, ctrl->ddrphy_dtcr1);
 
+	ddrss_phy_writel(DDRSS_DDRPHY_ACIOCR0, ioctl->ddrphy_aciocr0);
+	ddrss_phy_writel(DDRSS_DDRPHY_ACIOCR3, ioctl->ddrphy_aciocr3);
 	ddrss_phy_writel(DDRSS_DDRPHY_ACIOCR5, ioctl->ddrphy_aciocr5);
 	ddrss_phy_writel(DDRSS_DDRPHY_IOVCR0, ioctl->ddrphy_iovcr0);
 
@@ -294,6 +296,10 @@ static void am654_ddrss_phy_configuration(struct am654_ddrss_desc *ddrss)
 	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL1DXCTL2, cfg->ddrphy_dx8sl1dxctl2);
 	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL2DXCTL2, cfg->ddrphy_dx8sl2dxctl2);
 
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL0DQSCTL, cfg->ddrphy_dx8sl0dqsctl);
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL1DQSCTL, cfg->ddrphy_dx8sl1dqsctl);
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL2DQSCTL, cfg->ddrphy_dx8sl2dqsctl);
+
 	debug("%s: DDR phy register configuration completed\n", __func__);
 }
 
@@ -479,18 +485,43 @@ int VREF_training(struct am654_ddrss_desc *ddrss)
 
 int enable_dqs_pd(struct am654_ddrss_desc *ddrss)
 {
-	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL0DQSCTL, 0x012640F7);
-	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL1DQSCTL, 0x012640F7);
-	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL2DQSCTL, 0x012640F7);
+	u32 val;
+
+	val = ddrss_phy_readl(DDRSS_DDRPHY_DX8SL0DQSCTL);
+	val &= ~0xFF;
+	val |= 0xF7;
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL0DQSCTL, val);
+
+	val = ddrss_phy_readl(DDRSS_DDRPHY_DX8SL1DQSCTL);
+	val &= ~0xFF;
+	val |= 0xF7;
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL1DQSCTL, val);
+
+	val = ddrss_phy_readl(DDRSS_DDRPHY_DX8SL2DQSCTL);
+	val &= ~0xFF;
+	val |= 0xF7;
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL2DQSCTL, val);
+
 	sdelay(16);
 	return 0;
 }
 
 int disable_dqs_pd(struct am654_ddrss_desc *ddrss)
 {
-	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL0DQSCTL, 0x01264000);
-	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL1DQSCTL, 0x01264000);
-	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL2DQSCTL, 0x01264000);
+	u32 val;
+
+	val = ddrss_phy_readl(DDRSS_DDRPHY_DX8SL0DQSCTL);
+	val &= ~0xFF;
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL0DQSCTL, val);
+
+	val = ddrss_phy_readl(DDRSS_DDRPHY_DX8SL1DQSCTL);
+	val &= ~0xFF;
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL1DQSCTL, val);
+
+	val = ddrss_phy_readl(DDRSS_DDRPHY_DX8SL2DQSCTL);
+	val &= ~0xFF;
+	ddrss_phy_writel(DDRSS_DDRPHY_DX8SL2DQSCTL, val);
+
 	sdelay(16);
 	return 0;
 }
@@ -595,12 +626,14 @@ static int am654_ddrss_init(struct am654_ddrss_desc *ddrss)
 {
 	int ret;
 	u32 val;
+	struct ddrss_ss_reg_params *reg = &ddrss->params.ss_reg;
 
 	debug("Starting DDR initialization...\n");
 
 	debug("%s(ddrss=%p)\n", __func__, ddrss);
 
-	ddrss_writel(ddrss->ddrss_ss_cfg, DDRSS_V2H_CTL_REG, 0x000073FF);
+	ddrss_writel(ddrss->ddrss_ss_cfg, DDRSS_V2H_CTL_REG,
+		     reg->ddrss_v2h_ctl_reg);
 
 	am654_ddrss_ctrl_configuration(ddrss);
 
@@ -901,6 +934,14 @@ static int am654_ddrss_ofdata_to_priv(struct udevice *dev)
 	}
 	ddrss->ddrss_phy_cfg = (void *)reg;
 
+	ret = dev_read_u32_array(dev, "ti,ss-reg",
+			         (u32 *)&ddrss->params.ss_reg,
+			         sizeof(ddrss->params.ss_reg) / sizeof(u32));
+	if (ret) {
+		dev_err(dev, "Cannot read ti,ss-reg params\n");
+		return ret;
+	}
+
 	ret = dev_read_u32_array(dev, "ti,ctl-reg",
 				 (u32 *)&ddrss->params.ctl_reg,
 				 sizeof(ddrss->params.ctl_reg) / sizeof(u32));
diff --git a/drivers/ram/k3-am654-ddrss.h b/drivers/ram/k3-am654-ddrss.h
index 78d73cd9fc..94a7c91b2b 100644
--- a/drivers/ram/k3-am654-ddrss.h
+++ b/drivers/ram/k3-am654-ddrss.h
@@ -996,6 +996,10 @@
 					PGSR0_DIDONE_MASK)
 #define PGSR0_DATA_TR_INIT_MASK		(PGSR0_DRAM_INIT_MASK)
 
+struct ddrss_ss_reg_params {
+	u32 ddrss_v2h_ctl_reg;
+};
+
 struct ddrss_ddrctl_reg_params {
 	u32 ddrctl_dfimisc;
 	u32 ddrctl_dfitmg0;
@@ -1111,12 +1115,15 @@ struct ddrss_ddrphy_cfg_params {
 	u32 ddrphy_dx8sl0dxctl2;
 	u32 ddrphy_dx8sl0iocr;
 	u32 ddrphy_dx8sl0pllcr0;
+	u32 ddrphy_dx8sl0dqsctl;
 	u32 ddrphy_dx8sl1dxctl2;
 	u32 ddrphy_dx8sl1iocr;
 	u32 ddrphy_dx8sl1pllcr0;
+	u32 ddrphy_dx8sl1dqsctl;
 	u32 ddrphy_dx8sl2dxctl2;
 	u32 ddrphy_dx8sl2iocr;
 	u32 ddrphy_dx8sl2pllcr0;
+	u32 ddrphy_dx8sl2dqsctl;
 	u32 ddrphy_dxccr;
 	u32 ddrphy_odtcr;
 	u32 ddrphy_pgcr0;
@@ -1147,6 +1154,8 @@ struct ddrss_ddrphy_ctrl_params {
 };
 
 struct ddrss_ddrphy_ioctl_params {
+	u32 ddrphy_aciocr0;
+	u32 ddrphy_aciocr3;
 	u32 ddrphy_aciocr5;
 	u32 ddrphy_iovcr0;
 };
@@ -1173,6 +1182,7 @@ struct ddrss_ddrphy_zq_params {
 };
 
 struct ddrss_params {
+	struct ddrss_ss_reg_params ss_reg;
 	struct ddrss_ddrctl_reg_params ctl_reg;
 	struct ddrss_ddrctl_crc_params ctl_crc;
 	struct ddrss_ddrctl_ecc_params ctl_ecc;
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 1/3] armv7r: dts: am654-base-board: Rename 1600MHz to 1600MTs in dtsi filename
  2019-10-07  8:34 ` [U-Boot] [PATCH 1/3] armv7r: dts: am654-base-board: Rename 1600MHz to 1600MTs in dtsi filename Lokesh Vutla
@ 2019-10-26  0:06   ` Tom Rini
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2019-10-26  0:06 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 07, 2019 at 02:04:25PM +0530, Lokesh Vutla wrote:

> From: James Doublesin <doublesin@ti.com>
> 
> The current configuration of DDR on AM654 base board is for 1600MTs but
> the file name is specified as k3-am654-base-board-ddr4-1600MHz.dtsi.
> Since 1600MHz is misleading, rename it to
> k3-am654-base-board-ddr4-1600MTs.dtsi
> 
> Signed-off-by: James Doublesin <doublesin@ti.com>
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191025/03a3de64/attachment.sig>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 2/3] ram: k3-am654: add support for LPDDR4 and DDR3L DDRs
  2019-10-07  8:34 ` [U-Boot] [PATCH 2/3] ram: k3-am654: add support for LPDDR4 and DDR3L DDRs Lokesh Vutla
@ 2019-10-26  0:06   ` Tom Rini
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2019-10-26  0:06 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 07, 2019 at 02:04:26PM +0530, Lokesh Vutla wrote:

> From: James Doublesin <doublesin@ti.com>
> 
> Added training support for LPDDR4 and DDR3L DDRs.  Also added/changed
> some register configuration to support all 3 DDR types
> 
> Signed-off-by: James Doublesin <doublesin@ti.com>
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191025/75c8eb96/attachment.sig>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 3/3] ram: k3-am654: Do not rely on default values for certain DDR register
  2019-10-07  8:34 ` [U-Boot] [PATCH 3/3] ram: k3-am654: Do not rely on default values for certain DDR register Lokesh Vutla
@ 2019-10-26  0:06   ` Tom Rini
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2019-10-26  0:06 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 07, 2019 at 02:04:27PM +0530, Lokesh Vutla wrote:

> From: James Doublesin <doublesin@ti.com>
> 
> Added the following registers to the DDR configuration:
> - ACIOCR0,
> - ACIOCR3,
> - V2H_CTL_REG,
> - DX8SLxDQSCTL.
> 
> Modified enable_dqs_pd and disable_dqs_pd to only touch the associated
> bit fields for pullup and pulldown registers (to preserve slew rate and
> other bits in that same register). Also update the dts files in the same
> patch to maintain git bisectability.
> 
> Signed-off-by: James Doublesin <doublesin@ti.com>
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191025/b251683d/attachment.sig>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-10-26  0:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07  8:34 [U-Boot] [PATCH 0/3] ram: k3-am654: Add support for LPDDR4 and DDR3L Lokesh Vutla
2019-10-07  8:34 ` [U-Boot] [PATCH 1/3] armv7r: dts: am654-base-board: Rename 1600MHz to 1600MTs in dtsi filename Lokesh Vutla
2019-10-26  0:06   ` Tom Rini
2019-10-07  8:34 ` [U-Boot] [PATCH 2/3] ram: k3-am654: add support for LPDDR4 and DDR3L DDRs Lokesh Vutla
2019-10-26  0:06   ` Tom Rini
2019-10-07  8:34 ` [U-Boot] [PATCH 3/3] ram: k3-am654: Do not rely on default values for certain DDR register Lokesh Vutla
2019-10-26  0:06   ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.