Re: [PATCH v6 03/17] arm: mach-k3: Add basic support for J784S4 SoC definition

2023-12-13 Thread Bryan Brattlof
On December  7, 2023 thus sayeth Neha Malcom Francis:
> Hi Apurva,
> 
> On 06/12/23 18:07, Apurva Nandan wrote:
> > Add J784S4 initialization files for initial SPL boot.
> > 
> > Signed-off-by: Hari Nagalla 
> > [ add firewall configurations and change the R5 MCU scratchpad ]
> > Signed-off-by: Manorit Chawdhry 
> > Signed-off-by: Dasnavis Sabiya 
> > Signed-off-by: Apurva Nandan 
> > ---
> >   arch/arm/mach-k3/Kconfig  |  16 +-
> >   arch/arm/mach-k3/Makefile |   2 +
> >   arch/arm/mach-k3/arm64-mmu.c  |  52 +++
> >   arch/arm/mach-k3/include/mach/hardware.h  |   4 +
> >   .../mach-k3/include/mach/j784s4_hardware.h|  60 
> >   arch/arm/mach-k3/include/mach/j784s4_spl.h|  47 +++
> >   arch/arm/mach-k3/include/mach/spl.h   |   4 +
> >   arch/arm/mach-k3/j784s4_fdt.c |  15 +
> >   arch/arm/mach-k3/j784s4_init.c| 335 ++
> >   arch/arm/mach-k3/r5/Makefile  |   1 +
> >   10 files changed, 529 insertions(+), 7 deletions(-)
> >   create mode 100644 arch/arm/mach-k3/include/mach/j784s4_hardware.h
> >   create mode 100644 arch/arm/mach-k3/include/mach/j784s4_spl.h
> >   create mode 100644 arch/arm/mach-k3/j784s4_fdt.c
> >   create mode 100644 arch/arm/mach-k3/j784s4_init.c
> > 

...

> > +
> > +void k3_mmc_stop_clock(void)
> > +{
> > +   if (IS_ENABLED(CONFIG_K3_LOAD_SYSFW)) {
> > +   if (spl_boot_device() == BOOT_DEVICE_MMC1) {
> > +   struct mmc *mmc = find_mmc_device(0);
> > +
> > +   if (!mmc)
> > +   return;
> > +
> > +   mmc->saved_clock = mmc->clock;
> > +   mmc_set_clock(mmc, 0, true);
> > +   }
> > +   }
> > +}
> > +
> > +void k3_mmc_restart_clock(void)
> > +{
> > +   if (IS_ENABLED(CONFIG_K3_LOAD_SYSFW)) {
> > +   if (spl_boot_device() == BOOT_DEVICE_MMC1) {
> > +   struct mmc *mmc = find_mmc_device(0);
> > +
> > +   if (!mmc)
> > +   return;
> > +
> > +   mmc_set_clock(mmc, mmc->saved_clock, false);
> > +   }
> > +   }
> > +}

...

> > +void board_init_f(ulong dummy)
> > +{
> > +   struct udevice *dev;
> > +   int ret, ctr = 1;
> > +
> > +   /*
> > +* Cannot delay this further as there is a chance that
> > +* K3_BOOT_PARAM_TABLE_INDEX can be over written by SPL MALLOC section.
> > +*/
> > +   store_boot_info_from_rom();
> > +
> > +   /* Make all control module registers accessible */
> > +   ctrl_mmr_unlock();
> > +
> > +   if (IS_ENABLED(CONFIG_CPU_V7R)) {
> > +   disable_linefill_optimization();
> > +   setup_k3_mpu_regions();
> > +   }
> > +
> > +   /* Init DM early */
> > +   ret = spl_early_init();
> > +
> > +   /* Prepare console output */
> > +   preloader_console_init();
> > +
> > +   if (IS_ENABLED(CONFIG_K3_LOAD_SYSFW)) {
> > +   /*
> > +* Process pinctrl for the serial0 a.k.a. WKUP_UART0 module and 
> > continue
> > +* regardless of the result of pinctrl. Do this without probing 
> > the
> > +* device, but instead by searching the device that would 
> > request the
> > +* given sequence number if probed. The UART will be used by 
> > the system
> > +* firmware (SYSFW) image for various purposes and SYSFW 
> > depends on us
> > +* to initialize its pin settings.
> > +*/
> > +   ret = uclass_find_device_by_seq(UCLASS_SERIAL, 0, &dev);
> > +   if (!ret)
> > +   pinctrl_select_state(dev, "default");
> > +
> > +   /*
> > +* Load, start up, and configure system controller firmware. 
> > Provide
> > +* the U-Boot console init function to the SYSFW post-PM 
> > configuration
> > +* callback hook, effectively switching on (or over) the console
> > +* output.
> > +*/
> > +   k3_sysfw_loader(is_rom_loaded_sysfw(&bootdata),
> > +   k3_mmc_stop_clock, k3_mmc_restart_clock);
> > +
> 
> All these K3 specific code, should we push it out to a separate function
> like J721S2? (commit fca27ee8b993bd1a5752fc2156b1e86358fa8041 "arch:
> mach-k3: Update board specific API name to K3 generic API name")
> 
> Else we can take this up in a separate clean up series.
>

Do we still have a need to support the split binary (sysfw.itb) boot
anymore now that binman is building tiboot3 for us? I don't think we 
will ever be in a situation where ROM hasn't loaded the firmware for us.

> > +#ifdef CONFIG_SPL_OF_LIST
> > +   if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT))
> > +   do_board_detect();
> > +#endif
> > +

Should we tie CONFIG_SPL_OF_LIST and CONFIG_TI_I2C_BOARD_DETECT together 
in Kconfig to avoid this?

> > +   if (IS_ENABLED(CONFIG_SPL_CLK_K3)) {
> > +   /*
> > +* Force probe 

Re: [PATCH v6 03/17] arm: mach-k3: Add basic support for J784S4 SoC definition

2023-12-06 Thread Neha Malcom Francis

Hi Apurva,

On 06/12/23 18:07, Apurva Nandan wrote:

Add J784S4 initialization files for initial SPL boot.

Signed-off-by: Hari Nagalla 
[ add firewall configurations and change the R5 MCU scratchpad ]
Signed-off-by: Manorit Chawdhry 
Signed-off-by: Dasnavis Sabiya 
Signed-off-by: Apurva Nandan 
---
  arch/arm/mach-k3/Kconfig  |  16 +-
  arch/arm/mach-k3/Makefile |   2 +
  arch/arm/mach-k3/arm64-mmu.c  |  52 +++
  arch/arm/mach-k3/include/mach/hardware.h  |   4 +
  .../mach-k3/include/mach/j784s4_hardware.h|  60 
  arch/arm/mach-k3/include/mach/j784s4_spl.h|  47 +++
  arch/arm/mach-k3/include/mach/spl.h   |   4 +
  arch/arm/mach-k3/j784s4_fdt.c |  15 +
  arch/arm/mach-k3/j784s4_init.c| 335 ++
  arch/arm/mach-k3/r5/Makefile  |   1 +
  10 files changed, 529 insertions(+), 7 deletions(-)
  create mode 100644 arch/arm/mach-k3/include/mach/j784s4_hardware.h
  create mode 100644 arch/arm/mach-k3/include/mach/j784s4_spl.h
  create mode 100644 arch/arm/mach-k3/j784s4_fdt.c
  create mode 100644 arch/arm/mach-k3/j784s4_init.c

diff --git a/arch/arm/mach-k3/Kconfig b/arch/arm/mach-k3/Kconfig
index 03898424c9..150d0bfa14 100644
--- a/arch/arm/mach-k3/Kconfig
+++ b/arch/arm/mach-k3/Kconfig
@@ -22,6 +22,9 @@ config SOC_K3_AM625
  config SOC_K3_AM62A7
bool "TI's K3 based AM62A7 SoC Family Support"
  
+config SOC_K3_J784S4

+   bool "TI's K3 based J784S4 SoC Family Support"
+
  endchoice
  
  if SOC_K3_J721E

@@ -35,7 +38,7 @@ config SYS_SOC
  config SYS_K3_NON_SECURE_MSRAM_SIZE
hex
default 0x8 if SOC_K3_AM654
-   default 0x10 if SOC_K3_J721E || SOC_K3_J721S2
+   default 0x10 if SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_J784S4
default 0x1c if SOC_K3_AM642
default 0x3c000 if SOC_K3_AM625 || SOC_K3_AM62A7
help
@@ -47,7 +50,7 @@ config SYS_K3_NON_SECURE_MSRAM_SIZE
  config SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE
hex
default 0x58000 if SOC_K3_AM654
-   default 0xc if SOC_K3_J721E || SOC_K3_J721S2
+   default 0xc if SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_J784S4
default 0x18 if SOC_K3_AM642
default 0x38000 if SOC_K3_AM625 || SOC_K3_AM62A7
help
@@ -57,15 +60,14 @@ config SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE
  config SYS_K3_MCU_SCRATCHPAD_BASE
hex
default 0x4028 if SOC_K3_AM654
-   default 0x41cff9fc if SOC_K3_J721S2
-   default 0x41cff9fc if SOC_K3_J721E
+   default 0x41cff9fc if SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_J784S4
help
  Describes the base address of MCU Scratchpad RAM.
  
  config SYS_K3_MCU_SCRATCHPAD_SIZE

hex
default 0x200 if SOC_K3_AM654
-   default 0x200 if SOC_K3_J721E || SOC_K3_J721S2
+   default 0x200 if SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_J784S4
help
  Describes the size of MCU Scratchpad RAM.
  
@@ -73,7 +75,7 @@ config SYS_K3_BOOT_PARAM_TABLE_INDEX

hex
default 0x41c7fbfc if SOC_K3_AM654
default 0x41cffbfc if SOC_K3_J721E
-   default 0x41cfdbfc if SOC_K3_J721S2
+   default 0x41cfdbfc if SOC_K3_J721S2 || SOC_K3_J784S4
default 0x701bebfc if SOC_K3_AM642
default 0x43c3f290 if SOC_K3_AM625
default 0x43c3f290 if SOC_K3_AM62A7 && CPU_V7R
@@ -130,7 +132,7 @@ config K3_ATF_LOAD_ADDR
  
  config K3_DM_FW

bool "Separate DM firmware image"
-   depends on CPU_V7R && (SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_AM625 || SOC_K3_AM62A7) 
&& !CLK_TI_SCI && !TI_SCI_POWER_DOMAIN
+   depends on CPU_V7R && (SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_AM625 || SOC_K3_AM62A7 
|| SOC_K3_J784S4) && !CLK_TI_SCI && !TI_SCI_POWER_DOMAIN
default y
help
  Enabling this will indicate that the system has separate DM
diff --git a/arch/arm/mach-k3/Makefile b/arch/arm/mach-k3/Makefile
index 4216137646..945698e6e8 100644
--- a/arch/arm/mach-k3/Makefile
+++ b/arch/arm/mach-k3/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_SOC_K3_AM654) += am654_fdt.o
  obj-$(CONFIG_SOC_K3_J721E) += j721e_fdt.o
  obj-$(CONFIG_SOC_K3_J721S2) += j721s2_fdt.o
  obj-$(CONFIG_SOC_K3_AM625) += am625_fdt.o
+obj-$(CONFIG_SOC_K3_J784S4) += j784s4_fdt.o
  endif
  ifeq ($(CONFIG_SPL_BUILD),y)
  obj-$(CONFIG_SOC_K3_AM654) += am654_init.o
@@ -20,5 +21,6 @@ obj-$(CONFIG_SOC_K3_J721S2) += j721s2_init.o
  obj-$(CONFIG_SOC_K3_AM642) += am642_init.o
  obj-$(CONFIG_SOC_K3_AM625) += am625_init.o
  obj-$(CONFIG_SOC_K3_AM62A7) += am62a7_init.o
+obj-$(CONFIG_SOC_K3_J784S4) += j784s4_init.o
  endif
  obj-y += common.o security.o
diff --git a/arch/arm/mach-k3/arm64-mmu.c b/arch/arm/mach-k3/arm64-mmu.c
index e8db5332ae..f8b8a9b94f 100644
--- a/arch/arm/mach-k3/arm64-mmu.c
+++ b/arch/arm/mach-k3/arm64-mmu.c
@@ -317,3 +317,55 @@ struct mm_region am64_mem_map[NR_MMU_REGIONS] = {
  
  struct mm_region *mem_map = am64_mem_map;

  #endif /* CONFIG_SOC_K