Skip to contentSkip to conversation

8GB LPDDR4 support for the phycore_am68x

PATCH New Dominik Haller 1 participant 7 messages Dec 1

Subsystems (2)
lore
Share & tools
lore
#2 lore raw

PATCH 2/6 board: phytec: Add phycore_am68x to som detection

In reply to Dominik Haller

Add the phycore_am68x (internal number: PCM-074) to the common phytec som detection functions.

---
 board/phytec/common/Kconfig             | 11 +++++++++++
 board/phytec/common/am6_som_detection.c |  7 ++++++-
 board/phytec/common/am6_som_detection.h |  1 +
 3 files changed, 18 insertions(+), 1 deletion(-)
board/phytec/common/Kconfig +11 -0
index 87fa70632e5d..f6381bb1e5c1 100644
@@ -60,6 +60,17 @@ config PHYTEC_AM64_SOM_DETECTION
 	  Support of I2C EEPROM based SoM detection. Supported
 	  for PHYTEC AM64x boards.
 
+config PHYTEC_AM68_SOM_DETECTION
+	bool "Support SoM detection for AM68x PHYTEC platforms"
+	depends on (TARGET_PHYCORE_AM68X_A72 || TARGET_PHYCORE_AM68X_R5) && \
+		   PHYTEC_SOM_DETECTION
+	select PHYTEC_SOM_DETECTION_BLOCKS
+	depends on SPL_I2C && DM_I2C
+	default y
+	help
+	  Support of I2C EEPROM based SoM detection. Supported
+	  for PHYTEC AM68x boards.
+
 config PHYTEC_EEPROM_BUS
 	int "Board EEPROM's I2C bus number"
 	range 0 8
board/phytec/common/am6_som_detection.c +6 -1
index f5de5de48210..1883c85a3cec 100644
@@ -12,12 +12,14 @@ extern struct phytec_eeprom_data eeprom_data;
 
 #if IS_ENABLED(CONFIG_PHYTEC_AM62_SOM_DETECTION) || \
 	IS_ENABLED(CONFIG_PHYTEC_AM62A_SOM_DETECTION) || \
-	IS_ENABLED(CONFIG_PHYTEC_AM64_SOM_DETECTION)
+	IS_ENABLED(CONFIG_PHYTEC_AM64_SOM_DETECTION) || \
+	IS_ENABLED(CONFIG_PHYTEC_AM68_SOM_DETECTION)
 
 /* Check if the SoM is actually one of the following products:
  * - phyCORE-AM62x
  * - phyCORE-AM62Ax
  * - phyCORE-AM64x
+ * - phyCORE-AM68x
  *
  * Returns 0 in case it's a known SoM. Otherwise, returns -1.
  */
@@ -49,6 +51,9 @@ int phytec_am6_detect(struct phytec_eeprom_data *data)
 	if (som == PHYTEC_AM64X_SOM && soc_is_am64x())
 		return 0;
 
+	if (som == PHYTEC_AM68X_SOM && soc_is_j721s2())
+		return 0;
+
 	return -1;
 }
 
board/phytec/common/am6_som_detection.h +1 -0
index 0b3c9c8e1ee8..d84f7dee6bc5 100644
@@ -13,6 +13,7 @@
 #define PHYTEC_AM62X_SOM			71
 #define PHYTEC_AM62AX_SOM			75
 #define PHYTEC_AM64X_SOM			72
+#define PHYTEC_AM68X_SOM			74
 #define PHYTEC_EEPROM_VALUE_X			0x21
 #define PHYTEC_EEPROM_NOR_FLASH_64MB_QSPI	0xC
 
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/6 board: phytec: k3: Make k3_ddrss_patch SoC agnostic

In reply to Dominik Haller

k3_ddrss_patch is somewhat hard coded to support the phycore_am62x which is using the ti,am64-ddrss memory controller.

Add the following changes to support the j721s2 dual ddr-controller:

- Instead of using static defines for the registers take the property count from the actual devicetree node and return -EINVAL in case the register is out of range
- Pass the controller node from board code instead of hard coding it here
- Ignore the msmc properties for single memory controller SoCs

Update the call for the phycore_am62x accordingly.

---
 board/phytec/common/k3/k3_ddrss_patch.c    | 135 +++++++++++++++------
 board/phytec/common/k3/k3_ddrss_patch.h    |  56 ++++++++-
 board/phytec/phycore_am62x/phycore-am62x.c |   8 +-
 3 files changed, 157 insertions(+), 42 deletions(-)
board/phytec/common/k3/k3_ddrss_patch.c +95 -40
index 5afe5a20c7f3..8370a93c19c6 100644
@@ -9,12 +9,6 @@
 #include <fdt_support.h>
 #include <linux/errno.h>
 
-#ifdef CONFIG_K3_AM64_DDRSS
-#define LPDDR4_INTR_CTL_REG_COUNT (423U)
-#define LPDDR4_INTR_PHY_INDEP_REG_COUNT (345U)
-#define LPDDR4_INTR_PHY_REG_COUNT (1406U)
-#endif
-
 static int fdt_setprop_inplace_idx_u32(void *fdt, int nodeoffset,
 				       const char *name, uint32_t idx, u32 val)
 {
@@ -25,45 +19,106 @@ static int fdt_setprop_inplace_idx_u32(void *fdt, int nodeoffset,
 						   sizeof(val));
 }
 
-int fdt_apply_ddrss_timings_patch(void *fdt, struct ddrss *ddrss)
+/*
+ * Patch a ti,*-data register array property of one DDR controller node
+ * with the given delta.
+ *
+ * Return: 0 on success, -ENOENT if the property is missing, -EINVAL if a
+ * register offset is out of range or a libfdt error code otherwise.
+ */
+static int fdt_patch_reg_array(void *fdt, int nodeoffset, const char *name,
+			       const struct ddr_reg *regs, u32 num)
+{
+	u32 count, i;
+	int len, ret;
+
+	/* Nothing to patch */
+	if (!regs || !num)
+		return 0;
+
+	if (!fdt_getprop(fdt, nodeoffset, name, &len))
+		return -ENOENT;
+
+	count = len / sizeof(u32);
+	for (i = 0; i < num; i++) {
+		if (regs[i].off >= count)
+			return -EINVAL;
+
+		ret = fdt_setprop_inplace_idx_u32(fdt, nodeoffset, name,
+						  regs[i].off, regs[i].val);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+static int fdt_apply_ddrss_controller_patch(void *fdt, int root_offset,
+					    const struct k3_ddrss_ctrl_patch *ctrl)
 {
-	int i, j;
+	int ctrl_offset = root_offset;
 	int ret;
-	int mem_offset;
 
-	mem_offset = fdt_path_offset(fdt, "/memorycontroller@f300000");
-	if (mem_offset < 0)
+	if (ctrl->name && *ctrl->name) {
+		ctrl_offset = fdt_subnode_offset(fdt, root_offset, ctrl->name);
+		if (ctrl_offset < 0)
+			return -ENODEV;
+	}
+
+	if (ctrl->ddrss) {
+		ret = fdt_patch_reg_array(fdt, ctrl_offset, "ti,ctl-data",
+					  ctrl->ddrss->ctl_regs,
+					  ctrl->ddrss->ctl_regs_num);
+		if (ret)
+			return ret;
+
+		ret = fdt_patch_reg_array(fdt, ctrl_offset, "ti,pi-data",
+					  ctrl->ddrss->pi_regs,
+					  ctrl->ddrss->pi_regs_num);
+		if (ret)
+			return ret;
+
+		ret = fdt_patch_reg_array(fdt, ctrl_offset, "ti,phy-data",
+					  ctrl->ddrss->phy_regs,
+					  ctrl->ddrss->phy_regs_num);
+		if (ret)
+			return ret;
+	}
+
+	/* ti,ddr-fhs-cnt is a per-controller property */
+	if (ctrl->fhs_cnt >= 0)
+		return fdt_setprop_inplace_u32(fdt, ctrl_offset, "ti,ddr-fhs-cnt",
+					       ctrl->fhs_cnt);
+
+	return 0;
+}
+
+int fdt_apply_ddrss_timings_patch(void *fdt, const char *node_path,
+				  const struct k3_ddrss_msmc_patch *msmc,
+				  const struct k3_ddrss_ctrl_patch *ctrls,
+				  int num_ctrls)
+{
+	int root_offset;
+	int ret;
+	int i;
+
+	root_offset = fdt_path_offset(fdt, node_path);
+	if (root_offset < 0)
 		return -ENODEV;
 
-	for (i = 0; i < LPDDR4_INTR_CTL_REG_COUNT; i++)
-		for (j = 0; j < ddrss->ctl_regs_num; j++)
-			if (i == ddrss->ctl_regs[j].off) {
-				ret = fdt_setprop_inplace_idx_u32(fdt,
-						mem_offset, "ti,ctl-data", i,
-						ddrss->ctl_regs[j].val);
-				if (ret)
-					return ret;
-			}
-
-	for (i = 0; i < LPDDR4_INTR_PHY_INDEP_REG_COUNT; i++)
-		for (j = 0; j < ddrss->pi_regs_num; j++)
-			if (i == ddrss->pi_regs[j].off) {
-				ret = fdt_setprop_inplace_idx_u32(fdt,
-						mem_offset, "ti,pi-data", i,
-						ddrss->pi_regs[j].val);
-				if (ret)
-					return ret;
-			}
-
-	for (i = 0; i < LPDDR4_INTR_PHY_REG_COUNT; i++)
-		for (j = 0; j < ddrss->phy_regs_num; j++)
-			if (i == ddrss->phy_regs[j].off) {
-				ret = fdt_setprop_inplace_idx_u32(fdt,
-						mem_offset, "ti,phy-data", i,
-						ddrss->phy_regs[j].val);
-				if (ret)
-					return ret;
-			}
+	if (msmc && msmc->intrlv_size >= 0) {
+		ret = fdt_setprop_inplace_u32(fdt, root_offset, "intrlv-size",
+					      msmc->intrlv_size);
+		if (ret)
+			return ret;
+	}
+
+	for (i = 0; i < num_ctrls; i++) {
+		ret = fdt_apply_ddrss_controller_patch(fdt, root_offset,
+						       &ctrls[i]);
+		if (ret)
+			return ret;
+	}
 
 	return 0;
 }
board/phytec/common/k3/k3_ddrss_patch.h +55 -1

61 lines not on this page · raw message

board/phytec/phycore_am62x/phycore-am62x.c +7 -1
index 376379767cfc..5c556b33bf44 100644
@@ -143,6 +143,10 @@ int update_ddrss_timings(void)
 	int ret;
 	u8 ram_size;
 	struct ddrss *ddr_patch = NULL;
+	struct k3_ddrss_ctrl_patch ctrl = {
+		.name = NULL,
+		.fhs_cnt = -1,
+	};
 	void *fdt = (void *)gd->fdt_blob;
 
 	ram_size = phytec_get_am62_ddr_size_default();
@@ -166,7 +170,9 @@ int update_ddrss_timings(void)
 
 	debug("Applying DDRSS timings patch for ram_size %d\n", ram_size);
 
-	ret = fdt_apply_ddrss_timings_patch(fdt, ddr_patch);
+	ctrl.ddrss = ddr_patch;
+	ret = fdt_apply_ddrss_timings_patch(fdt, "/memorycontroller@f300000",
+					    NULL, &ctrl, 1);
 	if (ret < 0) {
 		printf("Failed to apply ddrs timings patch %d\n", ret);
 		return ret;
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/6 arm: dts: k3-am68-phyboard-izar: Add bootph property to wkup_pmx2

In reply to Dominik Haller

Add bootph-all to wkup_pmx2 so the wkup_i2c0 pins can be configured for the eeprom readout.

---
 arch/arm/dts/k3-am68-phyboard-izar-u-boot.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/arm/dts/k3-am68-phyboard-izar-u-boot.dtsi +1 -0
index 503ed69d123f..37556533358e 100644
@@ -9,6 +9,7 @@
 #include "k3-am68-phycore-som-binman.dtsi"
 
 &wkup_pmx2 {
+	bootph-all;
 	mcu_i2c0_pins_default: mcu-i2c0-default-pins {
 		pinctrl-single,pins = <
 			J721S2_WKUP_IOPAD(0x0a0, PIN_INPUT, 0) /* (G24) MCU_I2C0_SCL */
Signature · 1 line
2.43.0
#4 lore raw

PATCH 4/6 arm: mach-k3: j721s2_init: Call board_detect for non TI boards

In reply to Dominik Haller

Call do_board_detect outside of do_dt_magic to run the board detection for boards without TI_I2C_BOARD_DETECT.

---
 arch/arm/mach-k3/j721s2/j721s2_init.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-k3/j721s2/j721s2_init.c +2 -0
index 780d853423f8..8e6e4c35f807 100644
@@ -341,6 +341,8 @@ void board_init_f(ulong dummy)
 	k3_spl_init();
 #if defined(CONFIG_SPL_OF_LIST) && defined(CONFIG_TI_I2C_BOARD_DETECT)
 	do_dt_magic();
+#else
+	do_board_detect();
 #endif
 	k3_mem_init();
 
Signature · 1 line
2.43.0
#0 lore raw

cover 8GB LPDDR4 support for the phycore_am68x

Hi,

this patch stack adds the phycore_am68x to the Phytec eeprom based som detection to support an 8GB LPDDR4 option in a 2x4GB configuration.

In order to support both the Jacinto Multicore Shared Memory Controller and the single instance controllers of the Sitaras the config deltas are embedded into a struct where the msmc properties can be ignored on the AM62x.

Tested on 4GB and 8GB phycore_am68x and 2GB phycore_am62x (1GB delta still gets applied cleanly).

Dominik Haller (6):
board: phytec: k3: Make k3_ddrss_patch SoC agnostic
board: phytec: Add phycore_am68x to som detection
arm: dts: k3-am68-phyboard-izar: Add bootph property to wkup_pmx2
arm: mach-k3: j721s2_init: Call board_detect for non TI boards
board: phytec: phycore_am68x: Support 8GB LPDDR4
doc: board: phytec: phycore-am68x: Document runtime DDR size selection

 .../arm/dts/k3-am68-phyboard-izar-u-boot.dtsi |   1 +
 arch/arm/mach-k3/j721s2/Kconfig               |   1 +
 arch/arm/mach-k3/j721s2/j721s2_init.c         |   2 +
 board/phytec/common/Kconfig                   |  11 ++
 board/phytec/common/am6_som_detection.c       |   7 +-
 board/phytec/common/am6_som_detection.h       |   1 +
 board/phytec/common/k3/k3_ddrss_patch.c       | 135 ++++++++++-----
 board/phytec/common/k3/k3_ddrss_patch.h       |  56 +++++-
 board/phytec/phycore_am62x/phycore-am62x.c    |   8 +-
 board/phytec/phycore_am68x/Kconfig            |  28 +++
 .../phycore_am68x/phycore-am68x-ddr-data.h    |  78 +++++++++
 board/phytec/phycore_am68x/phycore-am68x.c    | 161 +++++++++++++++++-
 doc/board/phytec/phycore-am68x.rst            |  15 ++
 13 files changed, 456 insertions(+), 48 deletions(-)
 create mode 100644 board/phytec/phycore_am68x/phycore-am68x-ddr-data.h
Signature · 1 line
2.43.0
#5 lore raw

PATCH 5/6 board: phytec: phycore_am68x: Support 8GB LPDDR4

Apply the DDR config delta for the 8GB in 2x4GB configuration option based on the introspection data in the eeprom. While the byte is at the same position the mapping is different from the other Phytec K3 SoMs.

Use k3_ddrss_patch to update the DDR config registers and the devicetree nodes. Add Kconfig options to set the RAM size statically.

---
 arch/arm/mach-k3/j721s2/Kconfig               |   1 +
 board/phytec/phycore_am68x/Kconfig            |  28 +++
 .../phycore_am68x/phycore-am68x-ddr-data.h    |  78 +++++++++
 board/phytec/phycore_am68x/phycore-am68x.c    | 161 +++++++++++++++++-
 4 files changed, 263 insertions(+), 5 deletions(-)
 create mode 100644 board/phytec/phycore_am68x/phycore-am68x-ddr-data.h
arch/arm/mach-k3/j721s2/Kconfig +1 -0
index feb76ab19da8..27225bc29154 100644
@@ -46,6 +46,7 @@ config TARGET_PHYCORE_AM68X_R5
 	select SPL_RAM
 	select K3_DDRSS
 	select BINMAN
+	select PHYTEC_K3_DDR_PATCH
 	imply SYS_K3_SPL_ATF
 
 endchoice
board/phytec/phycore_am68x/Kconfig +28 -0
index d82cdaf819b9..df800ed7455b 100644
@@ -39,3 +39,31 @@ source "board/phytec/common/Kconfig"
 source "board/phytec/common/k3/Kconfig"
 
 endif
+
+config PHYCORE_AM68X_RAM_SIZE_FIX
+	bool "Set phyCORE-AM68x RAM size fix instead of detecting"
+	depends on TARGET_PHYCORE_AM68X_R5
+	default n
+	help
+	  The RAM size is automatically detected with the help of
+	  the EEPROM introspection data. Set the RAM size to a fixed value
+	  instead.
+
+choice
+	prompt "phyCORE-AM68x RAM size"
+	depends on PHYCORE_AM68X_RAM_SIZE_FIX
+	default PHYCORE_AM68X_RAM_SIZE_2X2GB
+
+config PHYCORE_AM68X_RAM_SIZE_2X2GB
+	bool "2x2GB RAM"
+	help
+	  Set the RAM size to a fixed 4GB in 2x2GB configuration for
+	  phyCORE-AM68x.
+
+config PHYCORE_AM68X_RAM_SIZE_2X4GB
+	bool "2x4GB RAM"
+	help
+	  Set the RAM size to a fixed 8GB in 2x4GB configuration for
+	  phyCORE-AM68x.
+
+endchoice
board/phytec/phycore_am68x/phycore-am68x-ddr-data.h new file +78 -0

78 lines not on this page · raw message

board/phytec/phycore_am68x/phycore-am68x.c +156 -5

198 lines not on this page · raw message

Signature · 1 line
2.43.0
#6 lore raw

PATCH 6/6 doc: board: phytec: phycore-am68x: Document runtime DDR size selection

In reply to Dominik Haller

The phyCORE-AM68x/TDA4x R5 SPL detects the populated DDR size from the SoM EEPROM and falls back to 2x2 GB if detection fails. For boards without a populated EEPROM or if no detection is needed, the detection can be bypassed via CONFIG_PHYCORE_AM68X_RAM_SIZE_FIX and one of the CONFIG_PHYCORE_AM68X_RAM_SIZE_<size> choices.

---
 doc/board/phytec/phycore-am68x.rst | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
doc/board/phytec/phycore-am68x.rst +15 -0
index 974dc53a30a8..5cde07cc7748 100644
@@ -157,6 +157,21 @@ Boot switches should be changed with power off.
      - 00000010
      - 00001100
 
+DDR RAM Size
+------------
+
+By default, the R5 SPL detects the populated DDR size by reading the SoM
+EEPROM and configures the DDR controllers and the U-Boot device-tree memory
+node accordingly. The phyCORE-AM68x/TDA4x is available with 4 GB (2x2 GB) or
+8 GB (2x4 GB) of LPDDR4. If the EEPROM cannot be read, is invalid or reports an
+unsupported size, the SPL falls back to a 4 GB configuration.
+
+EEPROM-based detection can be bypassed by enabling
+`CONFIG_PHYCORE_AM68X_RAM_SIZE_FIX` in the R5 defconfig and selecting one of:
+
+* `CONFIG_PHYCORE_AM68X_RAM_SIZE_2X2GB`
+* `CONFIG_PHYCORE_AM68X_RAM_SIZE_2X4GB`
+
 .. include:: k3-common.rst
 
 Further Information
Signature · 1 line
2.43.0