public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Kumar Gala <galak@kernel.crashing.org>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [RFC][FSL DDR 4/8] FSL DDR: Provide a generic fsl_ddr_sdram_set_lawbar()
Date: Mon,  9 Jun 2008 14:55:18 -0500	[thread overview]
Message-ID: <1213041322-5456-5-git-send-email-galak@kernel.crashing.org> (raw)
In-Reply-To: <1213041322-5456-4-git-send-email-galak@kernel.crashing.org>

Make fsl_ddr_sdram_set_lawbar() a weak function to allow board code to
override if desired.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 drivers/misc/fsl_law.c |   63 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/drivers/misc/fsl_law.c b/drivers/misc/fsl_law.c
index dca6a4d..f9bdf10 100644
--- a/drivers/misc/fsl_law.c
+++ b/drivers/misc/fsl_law.c
@@ -72,6 +72,69 @@ void print_laws(void)
 	return;
 }
 
+#if defined(CONFIG_FSL_DDR1) || \
+    defined(CONFIG_FSL_DDR2) || \
+    defined(CONFIG_FSL_DDR3)
+#include <../cpu/mpc8xxx/fsl_ddr_sdram.h>
+
+void
+__fsl_ddr_sdram_set_lawbar(const common_timing_params_t *memctl_common_params,
+			   unsigned int memctl_interleaved,
+			   unsigned int ctrl_num)
+{
+	unsigned long law_base_address;
+	unsigned long memsize_MB;
+	unsigned int law_size;
+
+	/*
+	 * If no DIMMs on this controller, do not proceed any further.
+	 */
+	if (!memctl_common_params->ndimms_present) {
+		return;
+	}
+
+	law_base_address = memctl_common_params->base_address;
+
+	/*
+	 * Compute LAWBARn[SIZE] value for 2**(SIZE + 1) bytes.
+	 * If interleaving is used, the memory size must represent
+	 * the combined total of both controllers.
+	 * The first supported LAW size is 16M, at LAWAR_SIZE_16M == 23.
+	 * Fnord.
+	 */
+	memsize_MB = memctl_common_params->total_mem / 0x100000;
+	law_size = 19 + __ilog2(memsize_MB << memctl_interleaved);
+
+	if (ctrl_num == 0) {
+		/*
+		 * Set up LAWBAR1 for DDR controller 1 space.
+		 */
+		unsigned int lawbar1_target_id = memctl_interleaved
+			? LAW_TRGT_IF_DDR_INTRLV : LAW_TRGT_IF_DDR_1;
+
+		set_law(1, law_base_address, law_size, lawbar1_target_id);
+		debug("ctl0 law_base_address = 0x%08X, law_size = 0x%x\n",
+		      law_base_address, law_size);
+
+	} else if (ctrl_num == 1) {
+		/*
+		 * Set up LAWBAR2 for DDR controller 2 space.
+		 */
+		set_law(2, law_base_address, law_size, LAW_TRGT_IF_DDR_2);
+		debug("ctl1 law_base_address = 0x%08X, law_size = 0x%x\n",
+		      law_base_address, law_size);
+
+	} else {
+		printf("unexpected controller number %u in fsl_ddr_sdram_set_lawbar()\n", ctrl_num);
+	}
+}
+
+__attribute__((weak, alias("__fsl_ddr_sdram_set_lawbar"))) void
+fsl_ddr_sdram_set_lawbar(const common_timing_params_t *memctl_common_params,
+			 unsigned int memctl_interleaved,
+			 unsigned int ctrl_num);
+#endif
+
 void init_laws(void)
 {
 	int i;
-- 
1.5.5.1

  reply	other threads:[~2008-06-09 19:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-09 19:55 [U-Boot-Users] [RFC][FSL DDR 0/8] Freescale DDR rewrite Kumar Gala
2008-06-09 19:55 ` [U-Boot-Users] [RFC][FSL DDR 1/8] Add proper SPD definitions for DDR1/2/3 Kumar Gala
2008-06-09 19:55   ` [U-Boot-Users] [RFC][FSL DDR 2/8] Rewrite the FSL mpc8xxx DDR controller setup code Kumar Gala
2008-06-09 19:55     ` [U-Boot-Users] [RFC][FSL DDR 3/8] FSL DDR: Add interactive DDR config support Kumar Gala
2008-06-09 19:55       ` Kumar Gala [this message]
2008-06-09 19:55         ` [U-Boot-Users] [RFC][FSL DDR 5/8] FSL DDR: Add e500 TLB helper for DDR code Kumar Gala
2008-06-09 19:55           ` [U-Boot-Users] [RFC][FSL DDR 6/8] Modify mpc8641HPCN to use the new DDR setup code Kumar Gala
2008-06-09 19:55             ` [U-Boot-Users] [RFC][FSL DDR 7/8] Modify MPC8610HPCD " Kumar Gala
2008-06-09 19:55               ` [U-Boot-Users] [RFC][FSL DDR 8/8] Modify MPC8544 DS " Kumar Gala
2008-06-09 21:03   ` [U-Boot-Users] [RFC][FSL DDR 1/8] Add proper SPD definitions for DDR1/2/3 Jerry Van Baren
2008-06-09 21:10     ` Jon Loeliger
2008-07-05 22:32 ` [U-Boot-Users] [RFC][FSL DDR 0/8] Freescale DDR rewrite Wolfgang Denk
2008-07-07 15:48   ` Jon Loeliger
2008-07-07 16:01     ` Kumar Gala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1213041322-5456-5-git-send-email-galak@kernel.crashing.org \
    --to=galak@kernel.crashing.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox