Skip to contentSkip to conversation

*** phyCORE-AM62x: DDR detection / Inject DDR timing deltas ***

PATCH In review Wadim Egorov 3 participants 9 messages May 22, 2024 – Jun 7, 2024

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

v2 cover *** phyCORE-AM62x: DDR detection / Inject DDR timing deltas ***

Changes in v2:
- Reabse to current next
- Add Tested-by: John Ma <[email protected]>
- Add Kconfig option to select RAM size statically
- Make board/phytec/common/k3 always compile for CONFIG_ARCH_K3

v1: https://lists.denx.de/pipermail/u-boot/2024-May/553057.html

Wadim Egorov (5):
board: phytec: Make AM6 SoM detection depend on I2C
board: phytec: Fix function definitions in AM6x SOM detection
arm: mach-k3: am625: Call do_board_detect() before DDR probing
board: phytec: common: Introduce a method to inject DDR timings deltas
board: phytec: am62x: Add support for 1 & 4 GB RAM variants

 arch/arm/mach-k3/am62x/am625_init.c           |   2 +
 board/phytec/common/Kconfig                   |   2 +
 board/phytec/common/Makefile                  |   4 +-
 board/phytec/common/am6_som_detection.c       |  18 +-
 board/phytec/common/am6_som_detection.h       |   8 +
 board/phytec/common/k3/Makefile               |   1 +
 board/phytec/common/k3/k3_ddrss_patch.c       |  68 ++++++
 board/phytec/common/k3/k3_ddrss_patch.h       |  28 +++
 board/phytec/phycore_am62x/Kconfig            |  30 +++
 board/phytec/phycore_am62x/MAINTAINERS        |   1 +
 board/phytec/phycore_am62x/phycore-am62x.c    | 152 ++++++++++++-
 board/phytec/phycore_am62x/phycore-ddr-data.h | 206 ++++++++++++++++++
 configs/phycore_am62x_a53_defconfig           |   4 +
 configs/phycore_am62x_r5_defconfig            |   4 +
 14 files changed, 514 insertions(+), 14 deletions(-)
 create mode 100644 board/phytec/common/k3/k3_ddrss_patch.c
 create mode 100644 board/phytec/common/k3/k3_ddrss_patch.h
 create mode 100644 board/phytec/phycore_am62x/phycore-ddr-data.h
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/5 board: phytec: Make AM6 SoM detection depend on I2C

SoM detection is using I2C driver model functions. Let's depend on I2C.

---
 board/phytec/common/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
board/phytec/common/Kconfig +2 -0
index 1077f0f4b61..56c8290f641 100644
@@ -16,6 +16,7 @@ config PHYTEC_AM62_SOM_DETECTION
 	bool "Support SoM detection for AM62x PHYTEC platforms"
 	depends on (TARGET_PHYCORE_AM62X_A53 || TARGET_PHYCORE_AM62X_R5) && \
 		   PHYTEC_SOM_DETECTION
+	depends on SPL_I2C && DM_I2C
 	default y
 	help
 	   Support of I2C EEPROM based SoM detection. Supported
@@ -25,6 +26,7 @@ config PHYTEC_AM64_SOM_DETECTION
 	bool "Support SoM detection for AM64x PHYTEC platforms"
 	depends on (TARGET_PHYCORE_AM64X_A53 || TARGET_PHYCORE_AM64X_R5) && \
 		   PHYTEC_SOM_DETECTION
+	depends on SPL_I2C && DM_I2C
 	default y
 	help
 	   Support of I2C EEPROM based SoM detection. Supported
Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 2/5 board: phytec: Fix function definitions in AM6x SOM detection

In reply to Wadim Egorov

Functions are declared as phytec_am6* and not phytec_am62*. Update the definitions to match the declarations.

Fixes 9d152c23279c ("board: phytec: Add SOM detection for AM6x")
---
 board/phytec/common/am6_som_detection.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
board/phytec/common/am6_som_detection.c +9 -9
index 2e9884dab44..7930ab42d1c 100644
@@ -73,7 +73,7 @@ static u8 phytec_check_opt(struct phytec_eeprom_data *data, u8 option)
  *  - The size
  *  - PHYTEC_EEPROM_INVAL when the data is invalid.
  */
-u8 __maybe_unused phytec_get_am62_ddr_size(struct phytec_eeprom_data *data)
+u8 __maybe_unused phytec_get_am6_ddr_size(struct phytec_eeprom_data *data)
 {
 	u8 ddr_id = phytec_check_opt(data, 3);
 
@@ -89,7 +89,7 @@ u8 __maybe_unused phytec_get_am62_ddr_size(struct phytec_eeprom_data *data)
  *  - Otherwise a board depended code for the size.
  *  - PHYTEC_EEPROM_INVAL when the data is invalid.
  */
-u8 __maybe_unused phytec_get_am62_spi(struct phytec_eeprom_data *data)
+u8 __maybe_unused phytec_get_am6_spi(struct phytec_eeprom_data *data)
 {
 	u8 spi = phytec_check_opt(data, 5);
 
@@ -105,7 +105,7 @@ u8 __maybe_unused phytec_get_am62_spi(struct phytec_eeprom_data *data)
  *  - 0x1 if 10/100/1000 MBit Phy is populated.
  *  - PHYTEC_EEPROM_INVAL when the data is invalid.
  */
-u8 __maybe_unused phytec_get_am62_eth(struct phytec_eeprom_data *data)
+u8 __maybe_unused phytec_get_am6_eth(struct phytec_eeprom_data *data)
 {
 	u8 eth = phytec_check_opt(data, 6);
 
@@ -121,7 +121,7 @@ u8 __maybe_unused phytec_get_am62_eth(struct phytec_eeprom_data *data)
  *  - 1 if it is populated.
  *  - PHYTEC_EEPROM_INVAL when the data is invalid.
  */
-u8 __maybe_unused phytec_get_am62_rtc(struct phytec_eeprom_data *data)
+u8 __maybe_unused phytec_get_am6_rtc(struct phytec_eeprom_data *data)
 {
 	u8 rtc = phytec_check_opt(data, 7);
 
@@ -131,28 +131,28 @@ u8 __maybe_unused phytec_get_am62_rtc(struct phytec_eeprom_data *data)
 
 #else
 
-inline int __maybe_unused phytec_am62_detect(struct phytec_eeprom_data *data)
+inline int __maybe_unused phytec_am6_detect(struct phytec_eeprom_data *data)
 {
 	return -1;
 }
 
 inline u8 __maybe_unused
-phytec_get_am62_ddr_size(struct phytec_eeprom_data *data)
+phytec_get_am6_ddr_size(struct phytec_eeprom_data *data)
 {
 	return PHYTEC_EEPROM_INVAL;
 }
 
-inline u8 __maybe_unused phytec_get_am62_spi(struct phytec_eeprom_data *data)
+inline u8 __maybe_unused phytec_get_am6_spi(struct phytec_eeprom_data *data)
 {
 	return PHYTEC_EEPROM_INVAL;
 }
 
-inline u8 __maybe_unused phytec_get_am62_eth(struct phytec_eeprom_data *data)
+inline u8 __maybe_unused phytec_get_am6_eth(struct phytec_eeprom_data *data)
 {
 	return PHYTEC_EEPROM_INVAL;
 }
 
-inline u8 __maybe_unused phytec_get_am62_rtc(struct phytec_eeprom_data *data)
+inline u8 __maybe_unused phytec_get_am6_rtc(struct phytec_eeprom_data *data)
 {
 	return PHYTEC_EEPROM_INVAL;
 }
Signature · 1 line
2.34.1
Reviewed-by on v2 2/5
#4 lore raw

Re: [PATCH v2 2/5] board: phytec: Fix function definitions in AM6x SOM detection

Quoted 10 lines · Wadim Egorov

Functions are declared as phytec_am6* and not phytec_am62*. Update the definitions to match the declarations.

Fixes 9d152c23279c ("board: phytec: Add SOM detection for AM6x")
---
 board/phytec/common/am6_som_detection.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

[...]

Signature · 2 lines
Best regards,
Dhruva Gole
#5 lore raw

PATCH v2 3/5 arm: mach-k3: am625: Call do_board_detect() before DDR probing

In reply to Wadim Egorov

Call do_board_detect() hook before the K3 DDRSS driver gets probed. It will allow boards to adjust DDR timings in do_board_detect().

---
 arch/arm/mach-k3/am62x/am625_init.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-k3/am62x/am625_init.c +2 -0
index ed8d24e0433..72a752d38e8 100644
@@ -213,6 +213,8 @@ void board_init_f(ulong dummy)
 
 	preloader_console_init();
 
+	do_board_detect();
+
 	/*
 	 * Allow establishing an early console as required for example when
 	 * doing a UART-based boot. Note that this console may not "survive"
Signature · 1 line
2.34.1
#6 lore raw

PATCH v2 4/5 board: phytec: common: Introduce a method to inject DDR timings deltas

In reply to Wadim Egorov

Introduce fdt_apply_ddrss_timings_patch() to allow board code to override DDR settings in the device tree prior to DDRSS driver probing.

---
v2:
- Make board/phytec/common/k3 always compile for CONFIG_ARCH_K3

---
 board/phytec/common/Makefile            |  4 +-
 board/phytec/common/k3/Makefile         |  1 +
 board/phytec/common/k3/k3_ddrss_patch.c | 68 +++++++++++++++++++++++++
 board/phytec/common/k3/k3_ddrss_patch.h | 28 ++++++++++
 board/phytec/phycore_am62x/MAINTAINERS  |  1 +
 5 files changed, 99 insertions(+), 3 deletions(-)
 create mode 100644 board/phytec/common/k3/k3_ddrss_patch.c
 create mode 100644 board/phytec/common/k3/k3_ddrss_patch.h
board/phytec/common/Makefile +1 -3
index c34fc503059..988c5742db5 100644
@@ -5,10 +5,8 @@
 ifdef CONFIG_SPL_BUILD
 # necessary to create built-in.o
 obj- := __dummy__.o
-else
-obj-$(CONFIG_ARCH_K3) += k3/
 endif
 
 obj-y += phytec_som_detection.o
-obj-$(CONFIG_ARCH_K3) += am6_som_detection.o
+obj-$(CONFIG_ARCH_K3) += am6_som_detection.o k3/
 obj-$(CONFIG_ARCH_IMX8M) += imx8m_som_detection.o
board/phytec/common/k3/Makefile +1 -0
index bcca1a9f846..40e91a43e99 100644
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0+
 obj-y += board.o
+obj-$(CONFIG_K3_DDRSS) += k3_ddrss_patch.o
board/phytec/common/k3/k3_ddrss_patch.c new file +68 -0

68 lines not on this page · raw message

board/phytec/common/k3/k3_ddrss_patch.h new file +28 -0
new file mode 100644
index 00000000000..0a47c85116a
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2024 PHYTEC Messtechnik GmbH
+ * Author: Wadim Egorov <[email protected]>
+ */
+
+#ifndef K3_DDRSS_PATCH
+#define K3_DDRSS_PATCH
+
+#include <linux/types.h>
+
+struct ddr_reg {
+	u32 off;
+	u32 val;
+};
+
+struct ddrss {
+	struct ddr_reg *ctl_regs;
+	u32 ctl_regs_num;
+	struct ddr_reg *pi_regs;
+	u32 pi_regs_num;
+	struct ddr_reg *phy_regs;
+	u32 phy_regs_num;
+};
+
+int fdt_apply_ddrss_timings_patch(void *fdt, struct ddrss *ddrss);
+
+#endif /* K3_DDRSS_PATCH */
board/phytec/phycore_am62x/MAINTAINERS +1 -0
index 02ac88e58a4..42463ad054e 100644
@@ -11,3 +11,4 @@ F:	configs/phycore_am62x_a53_defconfig
 F:	configs/phycore_am62x_r5_defconfig
 F:	include/configs/phycore_am62x.h
 F:	doc/board/phytec/phycore-am62x.rst
+F:	board/phytec/common/k3
Signature · 1 line
2.34.1
#7 lore raw

PATCH v2 5/5 board: phytec: am62x: Add support for 1 & 4 GB RAM variants

In reply to Wadim Egorov

Use content of EEPROM to detect the actual RAM size and adjust DDR timings, size and banks accordingly.
Also enable the SoM detection per default in the defconfigs.

---
v2:
- Add Kconfig option to select RAM size statically

---
 board/phytec/common/am6_som_detection.h       |   8 +
 board/phytec/phycore_am62x/Kconfig            |  30 +++
 board/phytec/phycore_am62x/phycore-am62x.c    | 152 ++++++++++++-
 board/phytec/phycore_am62x/phycore-ddr-data.h | 206 ++++++++++++++++++
 configs/phycore_am62x_a53_defconfig           |   4 +
 configs/phycore_am62x_r5_defconfig            |   4 +
 6 files changed, 402 insertions(+), 2 deletions(-)
 create mode 100644 board/phytec/phycore_am62x/phycore-ddr-data.h
board/phytec/common/am6_som_detection.h +8 -0
index 032f9da3aab..c5c6e179da6 100644
@@ -9,11 +9,19 @@
 
 #include "phytec_som_detection.h"
 
+#define EEPROM_ADDR				0x50
 #define PHYTEC_AM62X_SOM			71
 #define PHYTEC_AM64X_SOM			72
 #define PHYTEC_EEPROM_VALUE_X			0x21
 #define PHYTEC_EEPROM_NOR_FLASH_64MB_QSPI	0xC
 
+enum {
+	EEPROM_RAM_SIZE_512MB = 0,
+	EEPROM_RAM_SIZE_1GB = 1,
+	EEPROM_RAM_SIZE_2GB = 2,
+	EEPROM_RAM_SIZE_4GB = 4
+};
+
 int __maybe_unused phytec_am6_detect(struct phytec_eeprom_data *data);
 u8 __maybe_unused phytec_get_am6_ddr_size(struct phytec_eeprom_data *data);
 u8 __maybe_unused phytec_get_am6_spi(struct phytec_eeprom_data *data);
board/phytec/phycore_am62x/Kconfig +30 -0
index 1de8850c6c4..7c179ef0078 100644
@@ -35,3 +35,33 @@ config SPL_LDSCRIPT
 source "board/phytec/common/Kconfig"
 
 endif
+
+config PHYCORE_AM62X_RAM_SIZE_FIX
+        bool "Set phyCORE-AM62x RAM size fix instead of detecting"
+        default false
+        help
+          RAM size is automatic being detected with the help of
+          the EEPROM introspection data. Set RAM size to a fix value
+          instead.
+
+choice
+        prompt "phyCORE-AM62x RAM size"
+        depends on PHYCORE_AM62X_RAM_SIZE_FIX
+        default PHYCORE_AM62X_RAM_SIZE_2GB
+
+config PHYCORE_AM62X_RAM_SIZE_1GB
+        bool "1GB RAM"
+        help
+          Set RAM size fix to 1GB for phyCORE-AM62x.
+
+config PHYCORE_AM62X_RAM_SIZE_2GB
+        bool "2GB RAM"
+        help
+          Set RAM size fix to 2GB for phyCORE-AM62x.
+
+config PHYCORE_AM62X_RAM_SIZE_4GB
+        bool "4GB RAM"
+        help
+          Set RAM size fix to 4GB for phyCORE-AM62x.
+
+endchoice
board/phytec/phycore_am62x/phycore-am62x.c +150 -2

172 lines not on this page · raw message

board/phytec/phycore_am62x/phycore-ddr-data.h new file +206 -0

206 lines not on this page · raw message

configs/phycore_am62x_a53_defconfig +4 -0
index fd36edc29dd..145887c0286 100644
@@ -5,6 +5,7 @@ CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_SOC_K3_AM625=y
+CONFIG_PHYTEC_SOM_DETECTION=y
 CONFIG_TARGET_PHYCORE_AM62X_A53=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80b80000
@@ -45,6 +46,7 @@ CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
 CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
+CONFIG_SPL_I2C=y
 CONFIG_SPL_DM_MAILBOX=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_POWER_DOMAIN=y
@@ -73,6 +75,8 @@ CONFIG_CLK_TI_SCI=y
 CONFIG_DMA_CHANNELS=y
 CONFIG_TI_K3_NAVSS_UDMA=y
 CONFIG_TI_SCI_PROTOCOL=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_OMAP24XX=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_SUPPORT_EMMC_BOOT=y
configs/phycore_am62x_r5_defconfig +4 -0
index 389672d5227..0062a4e3569 100644
@@ -6,6 +6,7 @@ CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_SOC_K3_AM625=y
+CONFIG_PHYTEC_SOM_DETECTION=y
 CONFIG_TARGET_PHYCORE_AM62X_R5=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x43c3a7f0
@@ -50,6 +51,7 @@ CONFIG_SPL_SYS_MALLOC_SIZE=0x1000000
 CONFIG_SPL_EARLY_BSS=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x400
+CONFIG_SPL_I2C=y
 CONFIG_SPL_DM_MAILBOX=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_DM_RESET=y
@@ -88,6 +90,7 @@ CONFIG_SPL_CLK_K3_PLL=y
 CONFIG_SPL_CLK_K3=y
 CONFIG_TI_SCI_PROTOCOL=y
 CONFIG_DA8XX_GPIO=y
+CONFIG_DM_I2C=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_SPL_MISC=y
@@ -129,3 +132,4 @@ CONFIG_SPL_TIMER=y
 CONFIG_OMAP_TIMER=y
 CONFIG_LIB_RATIONAL=y
 CONFIG_SPL_LIB_RATIONAL=y
+CONFIG_SYS_I2C_OMAP24XX=y
Signature · 1 line
2.34.1