arch: arm: dts: phyboard-electra-uboot.dtsi: Add bootph props to i2c
PATCH v2 1/3 arch: arm: dts: phyboard-electra-uboot.dtsi: Add bootph props to i2c
Add bootph-all properties to I2C0 nodes to ensure the bus and EEPROM are accessible across all stages. This enables reading the SoM configuration at any point during the boot process.
---
v2: Add Tested-by from Daniel
--- arch/arm/dts/k3-am642-phyboard-electra-rdk-u-boot.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/dts/k3-am642-phyboard-electra-rdk-u-boot.dtsi +8 -0
@@ -72,6 +72,14 @@ bootph-all; }; +&main_i2c0 { + bootph-all; +}; + +&main_i2c0_pins_default { + bootph-all; +}; + &main_mmc1_pins_default { bootph-all; };
Signature · 1 line
2.34.1
PATCH v2 2/3 board: phytec: phycore_am64x: Add support for 1 GB RAM variant and ECC
Detect RAM size via EEPROM and adjust DDR size and banks accordingly. Include necessary fixups to handle ECC-enabled configurations.
---
v2: Add Tested-by from Daniel
--- board/phytec/phycore_am64x/Kconfig | 25 +++++ board/phytec/phycore_am64x/phycore-am64x.c | 105 ++++++++++++++++++++- 2 files changed, 128 insertions(+), 2 deletions(-)
board/phytec/phycore_am64x/Kconfig +25 -0
@@ -35,3 +35,28 @@ config SYS_CONFIG_NAME source "board/phytec/common/Kconfig" endif + +config PHYCORE_AM64X_RAM_SIZE_FIX + bool "Set phyCORE-AM64x 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-AM64x RAM size" + depends on PHYCORE_AM64X_RAM_SIZE_FIX + default PHYCORE_AM64X_RAM_SIZE_2GB + +config PHYCORE_AM64X_RAM_SIZE_1GB + bool "1GB RAM" + help + Set RAM size fix to 1GB for phyCORE-AM64x. + +config PHYCORE_AM64X_RAM_SIZE_2GB + bool "2GB RAM" + help + Set RAM size fix to 2GB for phyCORE-AM64x. + +endchoice
board/phytec/phycore_am64x/phycore-am64x.c +103 -2
127 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v2 2/3] board: phytec: phycore_am64x: Add support for 1 GB RAM variant and ECC
Quoted 17 lines · Wadim Egorov
Detect RAM size via EEPROM and adjust DDR size and banks accordingly. Include necessary fixups to handle ECC-enabled configurations.
Signed-off-by Wadim Egorov <[email protected]>Tested-by Daniel Schultz <[email protected]>---
v2: Add Tested-by from Daniel--- board/phytec/phycore_am64x/Kconfig | 25 +++++ board/phytec/phycore_am64x/phycore-am64x.c | 105 ++++++++++++++++++++- 2 files changed, 128 insertions(+), 2 deletions(-)board/phytec/phycore_am64x/Kconfig +0
-0
board/phytec/phycore_am64x/Kconfig config SYS_CONFIG_NAME · line 43
Quoted 9 lines
board/phytec/phycore_am64x/Kconfig +6
-0@@ -35,3 +35,28 @@ config SYS_CONFIG_NAME source "board/phytec/common/Kconfig" endif + +config PHYCORE_AM64X_RAM_SIZE_FIX + bool "Set phyCORE-AM64x RAM size fix instead of detecting" + default false + help + RAM size is automatic being detected with the help of
s/automatic/automatically
Quoted 24 lines
board/phytec/phycore_am64x/Kconfig +19
-0+ the EEPROM introspection data. Set RAM size to a fix value + instead. + +choice + prompt "phyCORE-AM64x RAM size" + depends on PHYCORE_AM64X_RAM_SIZE_FIX + default PHYCORE_AM64X_RAM_SIZE_2GB + +config PHYCORE_AM64X_RAM_SIZE_1GB + bool "1GB RAM" + help + Set RAM size fix to 1GB for phyCORE-AM64x. + +config PHYCORE_AM64X_RAM_SIZE_2GB + bool "2GB RAM" + help + Set RAM size fix to 2GB for phyCORE-AM64x. + +endchoiceboard/phytec/phycore_am64x/phycore-am64x.c +0
-0
board/phytec/phycore_am64x/phycore-am64x.c line 14
Quoted 4 lines
board/phytec/phycore_am64x/phycore-am64x.c +1
-0@@ -11,9 +11,12 @@#include <env.h> #include <env_internal.h> #include <spl.h> +#include <asm/arch/k3-ddr.h>
If adding new header might as well put it below asm/arch/hardware.h to maintain some level of sort?
board/phytec/phycore_am64x/phycore-am64x.c line 19
Quoted 5 lines
board/phytec/phycore_am64x/phycore-am64x.c +2
-0#include <fdt_support.h> #include <asm/arch/hardware.h> +#include "../common/am6_som_detection.h" +
I am already seeing 3 different way am6_som_detection.h is being included. Please can we consider using <> to abstract these relative paths?
It looks much cleaner that way and easier to maintain IMHO.
Quoted 87 lines
board/phytec/phycore_am64x/phycore-am64x.c +72
-2DECLARE_GLOBAL_DATA_PTR ;int board_init (void )@@ -21,15 +24,113 @@ int board_init(void)return 0 ; } +static u8 phytec_get_am64_ddr_size_default (void ) +{ +int ret; +struct phytec_eeprom_data data; + +if (IS_ENABLED (CONFIG_PHYCORE_AM64X_RAM_SIZE_FIX )) { +if (IS_ENABLED (CONFIG_PHYCORE_AM64X_RAM_SIZE_1GB )) +return EEPROM_RAM_SIZE_1GB ; +else if (IS_ENABLED (CONFIG_PHYCORE_AM64X_RAM_SIZE_2GB )) +return EEPROM_RAM_SIZE_2GB ; + } + + ret =phytec_eeprom_data_setup (&data,0 ,EEPROM_ADDR ); +if (!ret && data.valid) +return phytec_get_am6_ddr_size (&data); + +/* Default DDR size is 2GB */ +return EEPROM_RAM_SIZE_2GB ; +} +int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +u8 ram_size; + +if (!IS_ENABLED (CONFIG_CPU_V7R )) +return fdtdec_setup_mem_size_base (); + + ram_size =phytec_get_am64_ddr_size_default (); + +switch (ram_size) { +case EEPROM_RAM_SIZE_1GB : + gd->ram_size =0x40000000 ; +break ; +case EEPROM_RAM_SIZE_2GB : + gd->ram_size =0x80000000 ; +break ; +default : + gd->ram_size =0x80000000 ; + } + +return 0 ; }int dram_init_banksize (void ) { -return fdtdec_setup_memory_banksize (); +u8 ram_size; + +memset (gd->bd->bi_dram,0 ,sizeof (gd->bd->bi_dram[0 ]) *CONFIG_NR_DRAM_BANKS ); + +if (!IS_ENABLED (CONFIG_CPU_V7R )) +return fdtdec_setup_memory_banksize (); + + ram_size =phytec_get_am64_ddr_size_default (); +switch (ram_size) { +case EEPROM_RAM_SIZE_1GB : + gd->bd->bi_dram[0 ].start =CFG_SYS_SDRAM_BASE ; + gd->bd->bi_dram[0 ].size =0x40000000 ; + gd->ram_size =0x40000000 ; +break ; + +case EEPROM_RAM_SIZE_2GB : + gd->bd->bi_dram[0 ].start =CFG_SYS_SDRAM_BASE ; + gd->bd->bi_dram[0 ].size =0x80000000 ; + gd->ram_size =0x80000000 ; +break ; + +default : +/* Continue with default 2GB setup */ + gd->bd->bi_dram[0 ].start =CFG_SYS_SDRAM_BASE ; + gd->bd->bi_dram[0 ].size =0x80000000 ; + gd->ram_size =0x80000000 ; +printf ("DDR size %d is not supported\n" , ram_size); + } + +return 0 ; +} + +#if defined(CONFIG_K3_DDRSS )
board/phytec/phycore_am64x/phycore-am64x.c int board_init(void) · line 114
Quoted 10 lines
board/phytec/phycore_am64x/phycore-am64x.c +10
-0+int do_board_detect (void ) +{ +void *fdt = (void *)gd->fdt_blob; +int bank; + +u64 start[CONFIG_NR_DRAM_BANKS ]; +u64 size[CONFIG_NR_DRAM_BANKS ]; + +dram_init (); +dram_init_banksize ();
No check for any failures from fdtdec_setup_memory_banksize ?
board/phytec/phycore_am64x/phycore-am64x.c int board_init(void) · line 123
Quoted 9 lines
board/phytec/phycore_am64x/phycore-am64x.c +9
-0+ +for (bank =0 ; bank <CONFIG_NR_DRAM_BANKS ; bank++) { + start[bank] = gd->bd->bi_dram[bank].start; + size[bank] = gd->bd->bi_dram[bank].size; + } + + return fdt_fixup_memory_banks(fdt, start, size, CONFIG_NR_DRAM_BANKS); +} +#endif
Nit:
Try and end #endifs like this:
#endif /* CONFIG_K3_DDRSS */
Follow the convention everywhere else as it really improves code readability.
Quoted 16 lines
board/phytec/phycore_am64x/phycore-am64x.c +9
-0+ +#if IS_ENABLED (CONFIG_XPL_BUILD ) +void spl_perform_fixups (struct spl_image_info *spl_image) +{ +if (IS_ENABLED (CONFIG_K3_DDRSS ) &&IS_ENABLED (CONFIG_K3_INLINE_ECC )) +fixup_ddr_driver_for_ecc (spl_image); +else +fixup_memory_node (spl_image); } +#endif #define CTRLMMR_USB0_PHY_CTRL 0x43004008#define CORE_VOLTAGE 0x80000000Signature · 1 line
2.34.1
Signature · 3 lines
Best regards, Dhruva Gole Texas Instruments Incorporated
Re: [PATCH v2 2/3] board: phytec: phycore_am64x: Add support for 1 GB RAM variant and ECC
Hi Dhruva,
Am 05.02.25 um 12:55 schrieb Dhruva Gole:
Quoted 7 lines · Wadim Egorov
Quoted 6 lines
Detect RAM size via EEPROM and adjust DDR size and banks accordingly. Include necessary fixups to handle ECC-enabled configurations.
Signed-off-by Wadim Egorov <[email protected]>Tested-by Daniel Schultz <[email protected]>---
<snip>
Quoted 12 lines
board/phytec/phycore_am64x/phycore-am64x.c line 14
Quoted 5 lines
board/phytec/phycore_am64x/phycore-am64x.c +1
-0@@ -11,9 +11,12 @@#include <env.h> #include <env_internal.h> #include <spl.h> +#include <asm/arch/k3-ddr.h> If adding new header might as well put it below
asm/arch/hardware.hto maintain some level of sort?Quoted 3 lines
board/phytec/phycore_am64x/phycore-am64x.c +0
-0#include <fdt_support.h> #include <asm/arch/hardware.h>
Quoted 8 lines
board/phytec/phycore_am64x/phycore-am64x.c line 19
Quoted 2 lines
board/phytec/phycore_am64x/phycore-am64x.c +2
-0+#include "../common/am6_som_detection.h" +I am already seeing 3 different way
am6_som_detection.his being included. Please can we consider using <> to abstract these relative paths?
It looks much cleaner that way and easier to maintain IMHO.
I'll keep this in mind for a future cleanup series.
Quoted 91 lines
Quoted 91 lines
board/phytec/phycore_am64x/phycore-am64x.c +76
-2DECLARE_GLOBAL_DATA_PTR ;int board_init (void )@@ -21,15 +24,113 @@ int board_init(void)return 0 ; } +static u8 phytec_get_am64_ddr_size_default (void ) +{ +int ret; +struct phytec_eeprom_data data; + +if (IS_ENABLED (CONFIG_PHYCORE_AM64X_RAM_SIZE_FIX )) { +if (IS_ENABLED (CONFIG_PHYCORE_AM64X_RAM_SIZE_1GB )) +return EEPROM_RAM_SIZE_1GB ; +else if (IS_ENABLED (CONFIG_PHYCORE_AM64X_RAM_SIZE_2GB )) +return EEPROM_RAM_SIZE_2GB ; + } + + ret =phytec_eeprom_data_setup (&data,0 ,EEPROM_ADDR ); +if (!ret && data.valid) +return phytec_get_am6_ddr_size (&data); + +/* Default DDR size is 2GB */ +return EEPROM_RAM_SIZE_2GB ; +} +int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +u8 ram_size; + +if (!IS_ENABLED (CONFIG_CPU_V7R )) +return fdtdec_setup_mem_size_base (); + + ram_size =phytec_get_am64_ddr_size_default (); + +switch (ram_size) { +case EEPROM_RAM_SIZE_1GB : + gd->ram_size =0x40000000 ; +break ; +case EEPROM_RAM_SIZE_2GB : + gd->ram_size =0x80000000 ; +break ; +default : + gd->ram_size =0x80000000 ; + } + +return 0 ; }int dram_init_banksize (void ) { -return fdtdec_setup_memory_banksize (); +u8 ram_size; + +memset (gd->bd->bi_dram,0 ,sizeof (gd->bd->bi_dram[0 ]) *CONFIG_NR_DRAM_BANKS ); + +if (!IS_ENABLED (CONFIG_CPU_V7R )) +return fdtdec_setup_memory_banksize (); + + ram_size =phytec_get_am64_ddr_size_default (); +switch (ram_size) { +case EEPROM_RAM_SIZE_1GB : + gd->bd->bi_dram[0 ].start =CFG_SYS_SDRAM_BASE ; + gd->bd->bi_dram[0 ].size =0x40000000 ; + gd->ram_size =0x40000000 ; +break ; + +case EEPROM_RAM_SIZE_2GB : + gd->bd->bi_dram[0 ].start =CFG_SYS_SDRAM_BASE ; + gd->bd->bi_dram[0 ].size =0x80000000 ; + gd->ram_size =0x80000000 ; +break ; + +default : +/* Continue with default 2GB setup */ + gd->bd->bi_dram[0 ].start =CFG_SYS_SDRAM_BASE ; + gd->bd->bi_dram[0 ].size =0x80000000 ; + gd->ram_size =0x80000000 ; +printf ("DDR size %d is not supported\n" , ram_size); + } + +return 0 ; +} + +#if defined(CONFIG_K3_DDRSS ) +int do_board_detect (void ) +{ +void *fdt = (void *)gd->fdt_blob; +int bank;
Quoted 8 lines
board/phytec/phycore_am64x/phycore-am64x.c int board_init(void) · line 114
Quoted 6 lines
board/phytec/phycore_am64x/phycore-am64x.c +6
-0+ +u64 start[CONFIG_NR_DRAM_BANKS ]; +u64 size[CONFIG_NR_DRAM_BANKS ]; + +dram_init (); +dram_init_banksize ();No check for any failures from
fdtdec_setup_memory_banksize?
No need to, because dram_init_banksize() always returns success in this case. fdtdec_setup_memory_banksize() gets never called for CONFIG_CPU_V7R.
Quoted 14 lines
board/phytec/phycore_am64x/phycore-am64x.c int board_init(void) · line 123
Quoted 10 lines
board/phytec/phycore_am64x/phycore-am64x.c +9
-0+ +for (bank =0 ; bank <CONFIG_NR_DRAM_BANKS ; bank++) { + start[bank] = gd->bd->bi_dram[bank].start; + size[bank] = gd->bd->bi_dram[bank].size; + } + + return fdt_fixup_memory_banks(fdt, start, size, CONFIG_NR_DRAM_BANKS); +} +#endif Nit:
Try and end #endifs like this:
#endif /*CONFIG_K3_DDRSS*/
Same here, will keep this in mind for a future cleanup series.
Regards,
Wadim
PATCH v2 3/3 configs: phycore_am64x_r5_defconfig: Enable PHYTEC_SOM_DETECTION
In reply to Wadim EgorovEnable configs required for detecting and fixing up for different RAM variants. Also resync after savedefconfig.
---
v1: https://lists.denx.de/pipermail/u-boot/2025-January/578618.html
v2:
- Rebase after 0e198ff1a911 ("configs: Resync with savedefconfig")
- Add Tested-by from Daniel
- Drop CONFIG_OF_BOARD_SETUP=y, Fixes:
board/phytec/common/k3/board.c: In function 'fdt_apply_overlay_from_fit':
board/phytec/common/k3/board.c:203:47: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
203 | return fdt_overlay_apply_verbose(fdt, (void *)loadaddr);
--- configs/phycore_am64x_r5_defconfig | 2 ++ 1 file changed, 2 insertions(+)
configs/phycore_am64x_r5_defconfig +2 -0
@@ -7,6 +7,7 @@ CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_SOC_K3_AM642=y CONFIG_TARGET_PHYCORE_AM64X_R5=y +CONFIG_PHYTEC_SOM_DETECTION=y CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7019b800 CONFIG_SF_DEFAULT_SPEED=25000000
@@ -15,6 +16,7 @@ CONFIG_ENV_SIZE=0x20000 CONFIG_DM_GPIO=y CONFIG_SPL_DM_SPI=y CONFIG_DEFAULT_DEVICE_TREE="k3-am642-r5-phycore-som-2gb" +CONFIG_OF_LIBFDT_OVERLAY=y CONFIG_DM_RESET=y CONFIG_SPL_MMC=y CONFIG_SPL_SERIAL=y
Signature · 1 line
2.34.1
Quoted 18 lines · Wadim Egorov
Add bootph-all properties to I2C0 nodes to ensure the bus and EEPROM are accessible across all stages. This enables reading the SoM configuration at any point during the boot process.
Signed-off-by Wadim Egorov <[email protected]>Tested-by Daniel Schultz <[email protected]>---
v2: Add Tested-by from Daniel--- arch/arm/dts/k3-am642-phyboard-electra-rdk-u-boot.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)arch/arm/dts/k3-am642-phyboard-electra-rdk-u-boot.dtsi +0
-0@@ -72,6 +72,14 @@ bootph-all;
arch/arm/dts/k3-am642-phyboard-electra-rdk-u-boot.dtsi line 82
Quoted 10 lines
arch/arm/dts/k3-am642-phyboard-electra-rdk-u-boot.dtsi +8
-0}; +&main_i2c0 { + bootph-all; +}; + +&main_i2c0_pins_default { + bootph-all; +}; +
Signature · 3 lines
Best regards, Dhruva Gole Texas Instruments Incorporated
Quoted 5 lines · Wadim Egorov
Add bootph-all properties to I2C0 nodes to ensure the bus and EEPROM are accessible across all stages. This enables reading the SoM configuration at any point during the boot process.
Applied to u-boot/master, thanks!
Signature · 1 line
Tom