summaryrefslogtreecommitdiff
path: root/drivers/ddr
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2015-08-01 21:44:00 +0200
committerMarek Vasut <marex@denx.de>2015-08-08 14:14:27 +0200
commitbb056d9c07fd08a743b262b82f26be8fbe710955 (patch)
treebc687eca0496d12a8c48337b42b061ff42be4d74 /drivers/ddr
parent5af914189ec73b2241ba79950f98849fddaf32a2 (diff)
downloadu-boot-imx-bb056d9c07fd08a743b262b82f26be8fbe710955.zip
u-boot-imx-bb056d9c07fd08a743b262b82f26be8fbe710955.tar.gz
u-boot-imx-bb056d9c07fd08a743b262b82f26be8fbe710955.tar.bz2
ddr: altera: sdram: Clean up sdram_calculate_size() part 1
Pluck out all of the CONFIG_HPS_SDR_CTRLCFG_* macros. This change makes sdram.c completely clear of these macros and allows removing of the ugly include of sdram.h . The namespace is now a much nicer place! Signed-off-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'drivers/ddr')
-rw-r--r--drivers/ddr/altera/sdram.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/ddr/altera/sdram.c b/drivers/ddr/altera/sdram.c
index 5267ddc..b540c78 100644
--- a/drivers/ddr/altera/sdram.c
+++ b/drivers/ddr/altera/sdram.c
@@ -12,12 +12,6 @@
#include <asm/arch/system_manager.h>
#include <asm/io.h>
-/*
- * FIXME: This path is temporary until the SDRAM driver gets
- * a proper thorough cleanup.
- */
-#include "../../../board/altera/socfpga/qts/sdram_config.h"
-
DECLARE_GLOBAL_DATA_PTR;
struct sdram_prot_rule {
@@ -470,6 +464,13 @@ unsigned long sdram_calculate_size(void)
{
unsigned long temp;
unsigned long row, bank, col, cs, width;
+ const struct socfpga_sdram_config *cfg = socfpga_get_sdram_config();
+ const unsigned int csbits =
+ ((cfg->dram_addrw & SDR_CTRLGRP_DRAMADDRW_CSBITS_MASK) >>
+ SDR_CTRLGRP_DRAMADDRW_CSBITS_LSB) + 1;
+ const unsigned int rowbits =
+ (cfg->dram_addrw & SDR_CTRLGRP_DRAMADDRW_ROWBITS_MASK) >>
+ SDR_CTRLGRP_DRAMADDRW_ROWBITS_LSB;
temp = readl(&sdr_ctrl->dram_addrw);
col = (temp & SDR_CTRLGRP_DRAMADDRW_COLBITS_MASK) >>
@@ -490,7 +491,7 @@ unsigned long sdram_calculate_size(void)
*/
row = readl(&sysmgr_regs->iswgrp_handoff[4]);
if (row == 0)
- row = CONFIG_HPS_SDR_CTRLCFG_DRAMADDRW_ROWBITS;
+ row = rowbits;
/* If the stored handoff value for rows is greater than
* the field width in the sdr.dramaddrw register then
* something is very wrong. Revert to using the the #define
@@ -498,7 +499,7 @@ unsigned long sdram_calculate_size(void)
* using a broken value.
*/
if (row > 31)
- row = CONFIG_HPS_SDR_CTRLCFG_DRAMADDRW_ROWBITS;
+ row = rowbits;
bank = (temp & SDR_CTRLGRP_DRAMADDRW_BANKBITS_MASK) >>
SDR_CTRLGRP_DRAMADDRW_BANKBITS_LSB;
@@ -512,7 +513,7 @@ unsigned long sdram_calculate_size(void)
SDR_CTRLGRP_DRAMADDRW_CSBITS_LSB;
cs += 1;
- cs = CONFIG_HPS_SDR_CTRLCFG_DRAMADDRW_CSBITS;
+ cs = csbits;
width = readl(&sdr_ctrl->dram_if_width);
/* ECC would not be calculated as its not addressible */