tegra124: Add function for obtaining DRAM size via MC regs
This adds a method for obtaining DRAM size from memory controller registers. It is intended as an SoC-specific helper function that can be used from very early ramstage code. BUG=none BRANCH=none TEST=built and booted on Nyan Signed-off-by: David Hendricks <dhendrix@chromium.org> Change-Id: Ib8b30e464b1398b78c5ffd8eada88b60d25ebf2b Reviewed-on: https://chromium-review.googlesource.com/184535 Reviewed-by: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org> Commit-Queue: David Hendricks <dhendrix@chromium.org>
This commit is contained in:
parent
5ff002d09f
commit
d4580c46de
3 changed files with 25 additions and 0 deletions
|
|
@ -115,6 +115,9 @@ struct tegra_mc_regs {
|
|||
};
|
||||
|
||||
enum {
|
||||
MC_EMEM_CFG_SIZE_MB_SHIFT = 0,
|
||||
MC_EMEM_CFG_SIZE_MB_MASK = 0x3fff,
|
||||
|
||||
MC_EMEM_ARB_MISC0_MC_EMC_SAME_FREQ_SHIFT = 27,
|
||||
MC_EMEM_ARB_MISC0_MC_EMC_SAME_FREQ_MASK = 1 << 27,
|
||||
|
||||
|
|
|
|||
|
|
@ -609,3 +609,24 @@ uint32_t sdram_get_ram_code(void)
|
|||
PMC_STRAPPING_OPT_A_RAM_CODE_MASK) >>
|
||||
PMC_STRAPPING_OPT_A_RAM_CODE_SHIFT);
|
||||
}
|
||||
|
||||
/* returns total amount of DRAM (in MB) from memory controller registers */
|
||||
int sdram_size_mb(void)
|
||||
{
|
||||
struct tegra_mc_regs *mc = (struct tegra_mc_regs *)TEGRA_MC_BASE;
|
||||
static int total_size = 0;
|
||||
|
||||
if (total_size)
|
||||
return total_size;
|
||||
|
||||
/*
|
||||
* This obtains memory size from the External Memory Aperture
|
||||
* Configuration register. Nvidia confirmed that it is safe to assume
|
||||
* this value represents the total physical DRAM size.
|
||||
*/
|
||||
total_size = (read32(&mc->emem_cfg) >>
|
||||
MC_EMEM_CFG_SIZE_MB_SHIFT) & MC_EMEM_CFG_SIZE_MB_MASK;
|
||||
|
||||
printk(BIOS_DEBUG, "%s: Total SDRAM (MB): %u\n", __func__, total_size);
|
||||
return total_size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,6 @@
|
|||
|
||||
uint32_t sdram_get_ram_code(void);
|
||||
void sdram_init(const struct sdram_params *param);
|
||||
int sdram_size_mb(void);
|
||||
|
||||
#endif /* __SOC_NVIDIA_TEGRA124_SDRAM_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue