@@ -590,11 +590,13 @@ static int RAMFUNCTION hal_flash_status_wait(uint32_t sector, uint32_t timeout_u
590590 uint32_t timeout = 0 ;
591591 uint16_t read1 , read2 ;
592592
593- /* Replicate 8-bit AMD toggle bit to both bytes for parallel chips */
593+ /* Replicate 8-bit AMD toggle/error bits to both bytes for parallel chips */
594594#if FLASH_CFI_WIDTH == 16
595595 uint16_t toggle16 = (AMD_STATUS_TOGGLE << 8 ) | AMD_STATUS_TOGGLE ;
596+ uint16_t error16 = (AMD_STATUS_ERROR << 8 ) | AMD_STATUS_ERROR ;
596597#else
597598 uint16_t toggle16 = AMD_STATUS_TOGGLE ;
599+ uint16_t error16 = AMD_STATUS_ERROR ;
598600#endif
599601
600602 do {
@@ -618,7 +620,7 @@ static int RAMFUNCTION hal_flash_status_wait(uint32_t sector, uint32_t timeout_u
618620 if (((read1 ^ read2 ) & toggle16 ) == 0 )
619621 break ;
620622 /* Check DQ5 (error) on both chips while still toggling */
621- if (read1 & (( AMD_STATUS_ERROR << 8 ) | AMD_STATUS_ERROR ) ) {
623+ if (read1 & error16 ) {
622624 /* Read one more time to confirm it's not a false DQ5 */
623625#if FLASH_CFI_WIDTH == 16
624626 read1 = FLASH_IO16_READ (sector , 0 );
@@ -811,6 +813,10 @@ extern uint32_t _secondary_start_page;
811813extern uint32_t _second_half_boot_page ;
812814extern uint32_t _spin_table [];
813815extern uint32_t _spin_table_addr ;
816+
817+ /* DDR address of the spin table, set during hal_mp_init() and reused in
818+ * hal_dts_fixup() for cpu-release-addr fixups. */
819+ static uint32_t g_spin_table_ddr = 0 ;
814820extern uint32_t _bootpg_addr ;
815821
816822/* Startup additional cores with spin table and synchronize the timebase.
@@ -950,6 +956,9 @@ static void hal_mp_init(void)
950956 }
951957 flush_cache (second_half_ddr , BOOT_ROM_SIZE );
952958
959+ /* Persist DDR spin-table base for use in hal_dts_fixup() */
960+ g_spin_table_ddr = spin_table_ddr ;
961+
953962 /* start cores and wait for them to be enabled */
954963 hal_mp_up (bootpg , spin_table_ddr );
955964}
@@ -1021,9 +1030,11 @@ int hal_dts_fixup(void* dts_addr)
10211030 }
10221031
10231032 #ifdef ENABLE_MP
1024- /* calculate location of spin table for core */
1025- core_spin_table = (uint64_t )((uintptr_t )(
1026- (uint8_t * )_spin_table + (core * ENTRY_SIZE )));
1033+ /* Calculate DDR address of this core's spin table entry.
1034+ * Must use g_spin_table_ddr (the DDR copy), NOT _spin_table which
1035+ * is the flash/VMA address — Linux writes the release word to this
1036+ * address, and XIP flash is read-only. */
1037+ core_spin_table = (uint64_t )(g_spin_table_ddr + (core * ENTRY_SIZE ));
10271038
10281039 fdt_fixup_str (fdt , off , "cpu" , "status" , (core == 0 ) ? "okay" : "disabled" );
10291040 fdt_fixup_val64 (fdt , off , "cpu" , "cpu-release-addr" , core_spin_table );
0 commit comments