SAMA5D3/4: Fix some logic in conversion of physical and virtal DRAM addresses when running out of DRAM
This commit is contained in:
parent
f6a3d4b728
commit
03f3f8966c
@ -217,7 +217,8 @@ static inline uintptr_t isram_physramaddr(uintptr_t virtramaddr)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SAMA5_DDRCS
|
||||
#if defined(CONFIG_SAMA5_DDRCS) || defined(CONFIG_SAMA5_BOOT_SDRAM) || \
|
||||
defined(CONFIG_BOOT_SDRAM_DATA)
|
||||
static inline uintptr_t sdram_physramaddr(uintptr_t virtramaddr)
|
||||
{
|
||||
#if SAM_DDRCS_PSECTION != SAM_DDRCS_VSECTION
|
||||
@ -472,7 +473,8 @@ static inline uintptr_t isram_virtramaddr(uintptr_t physramaddr)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SAMA5_DDRCS
|
||||
#if defined(CONFIG_SAMA5_DDRCS) || defined(CONFIG_SAMA5_BOOT_SDRAM) || \
|
||||
defined(CONFIG_BOOT_SDRAM_DATA)
|
||||
static inline uintptr_t sdram_virtramaddr(uintptr_t physramaddr)
|
||||
{
|
||||
#if SAM_DDRCS_PSECTION != SAM_DDRCS_VSECTION
|
||||
@ -787,14 +789,52 @@ uintptr_t sam_physramaddr(uintptr_t virtramaddr)
|
||||
return isram_physramaddr(virtramaddr);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SAMA5_DDRCS
|
||||
/* Check for external SDRAM */
|
||||
#if defined(CONFIG_SAMA5_DDRCS)
|
||||
/* Check for external SDRAM. We may have external DRAM if, as examples,
|
||||
* we are running from NOR FLASH or ISRAM with data in DRAM
|
||||
* (SAMA5_BOOT_ISRAM or SAMA5_BOOT_CS0FLASH with CONFIG_SAMA5_DDRCS). In
|
||||
* this case, the DRAM configuration settings, SAM_DDRCS_VSECTION and
|
||||
* SAMA5_DDRCS_SIZE give us the correct size of the installed DRAM.
|
||||
*
|
||||
* SAM_DDRCS_VSECTION -- Virtual start of the DRAM memory region
|
||||
* SAMA5_DDRCS_SIZE -- The installed DRAM size.
|
||||
*
|
||||
* REVISIT: However, not all of it may be mapped? Only the "primary"
|
||||
* RAM region will be mapped by default. See below.
|
||||
*/
|
||||
|
||||
else if (virtramaddr >= SAM_DDRCS_VSECTION &&
|
||||
virtramaddr < (SAM_DDRCS_VSECTION + SAMA5_DDRCS_SIZE))
|
||||
{
|
||||
return sdram_physramaddr(virtramaddr);
|
||||
}
|
||||
|
||||
#elif defined(CONFIG_SAMA5_BOOT_SDRAM) || defined(CONFIG_BOOT_SDRAM_DATA)
|
||||
/* The DDRCS values may be highly couple to the CONFIG_RAM_START,
|
||||
* CONFIG_RAM_VSTART, and CONFIG_RAM_SIZE when CONFIG_SAMA5_BOOT_SDRAM or
|
||||
* CONFIG_BOOT_SDRAM_DATA is selected.
|
||||
*
|
||||
* CONFIG_SAMA5_BOOT_SDRAM -- We were booted into DRAM by some bootloader.
|
||||
* DRAM support is not enabled, SAMA5_DDRCS_SIZE is not valid.
|
||||
* CONFIG_BOOT_SDRAM_DATA -- We are running from NOR or ISRAM, but our
|
||||
* .bss, .data, and primary heap are in DRAM (In this case, I would
|
||||
* expect CONFIG_SAMA5_DDRCS to also be set, however).
|
||||
*
|
||||
* In all cases, CONFIG_RAM_START, RAM_VSTART, and RAM_SIZE describe the
|
||||
* "primary" RAM region that is mapped at boot time. This "primary" RAM
|
||||
* region is the one that holds .bss, .data, and primary head. And this
|
||||
* is the only DRAM memory region that is mapped at boot time.
|
||||
*
|
||||
* REVISIT: How does this work if we want to set aside a block of DRAM
|
||||
* outside of .bss, .data, and .heap for, as an example, for a framebuffer.
|
||||
* In that case, we will to revisit this.
|
||||
*/
|
||||
|
||||
else if (virtramaddr >= CONFIG_RAM_VSTART &&
|
||||
virtramaddr < (CONFIG_RAM_VSTART + CONFIG_RAM_SIZE))
|
||||
{
|
||||
return sdram_physramaddr(virtramaddr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check for NFCS SRAM. If NFC SRAM is not being used by the NAND logic,
|
||||
@ -896,13 +936,23 @@ uintptr_t sam_virtramaddr(uintptr_t physramaddr)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SAMA5_DDRCS
|
||||
/* Check for external SDRAM */
|
||||
/* Check for external SDRAM. NOTE: See comments in sam_physramaddr */
|
||||
|
||||
else if (physramaddr >= SAM_DDRCS_PSECTION &&
|
||||
physramaddr < (SAM_DDRCS_PSECTION + SAMA5_DDRCS_SIZE))
|
||||
{
|
||||
return sdram_virtramaddr(physramaddr);
|
||||
}
|
||||
|
||||
#elif defined(CONFIG_SAMA5_BOOT_SDRAM) || defined(CONFIG_BOOT_SDRAM_DATA)
|
||||
/* See comments in sam_physramaddr */
|
||||
|
||||
else if (physramaddr >= CONFIG_RAM_START &&
|
||||
physramaddr < (CONFIG_RAM_START + CONFIG_RAM_SIZE))
|
||||
{
|
||||
return sdram_physramaddr(physramaddr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Check for NFCS SRAM. If NFC SRAM is not being used by the NAND logic,
|
||||
|
Loading…
Reference in New Issue
Block a user