[coreboot-gerrit] Change in coreboot[master]: nb/intel/x4x: Rework programming DQ and DQS DLL timings

Arthur Heymans (Code Review) gerrit at coreboot.org
Fri Jun 9 22:57:28 CEST 2017


Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/20136


Change subject: nb/intel/x4x: Rework programming DQ and DQS DLL timings
......................................................................

nb/intel/x4x: Rework programming DQ and DQS DLL timings

This does the following:
* Clarify that settings are set to the same value for each rank;
* Allows to program coarse
* fix some style issues like white spaces between arithmetic
  operators.

Change-Id: I3a9e28cfec915a0bb15789c23bea259f621b5096
Signed-off-by: Arthur Heymans <arthur at aheymans.xyz>
---
M src/northbridge/intel/x4x/raminit_ddr2.c
1 file changed, 44 insertions(+), 75 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/36/20136/1

diff --git a/src/northbridge/intel/x4x/raminit_ddr2.c b/src/northbridge/intel/x4x/raminit_ddr2.c
index a4a830d..eb7c82e 100644
--- a/src/northbridge/intel/x4x/raminit_ddr2.c
+++ b/src/northbridge/intel/x4x/raminit_ddr2.c
@@ -398,92 +398,61 @@
 		setting->tap;
 }
 
+/**
+ * All finer DQ and DQS DLL settings are set to the same value
+ * for each rank in a channel, while coarse is common.
+ */
 static void dqsset(u8 ch, u8 lane, const struct dll_setting *setting)
 {
-	MCHBAR32(0x400*ch + 0x5fc) = MCHBAR32(0x400*ch + 0x5fc) & ~(2 << (lane*4));
+	int rank;
 
-	MCHBAR32(0x400*ch + 0x5b4) = (MCHBAR32(0x400*ch + 0x5b4) & ~(0x201 << lane)) |
-		(setting->db_en << (9 + lane)) |
-		(setting->db_sel << lane);
-	MCHBAR32(0x400*ch + 0x5b8) = (MCHBAR32(0x400*ch + 0x5b8) & ~(0x201 << lane)) |
-		(setting->db_en << (9 + lane)) |
-		(setting->db_sel << lane);
-	MCHBAR32(0x400*ch + 0x5bc) = (MCHBAR32(0x400*ch + 0x5bc) & ~(0x201 << lane)) |
-		(setting->db_en << (9 + lane)) |
-		(setting->db_sel << lane);
-	MCHBAR32(0x400*ch + 0x5c0) = (MCHBAR32(0x400*ch + 0x5c0) & ~(0x201 << lane)) |
-		(setting->db_en << (9 + lane)) |
-		(setting->db_sel << lane);
+	MCHBAR32(0x400 * ch + 0x5fc) = (MCHBAR32(0x400 * ch + 0x5fc)
+			& ~(1 << (lane * 4 + 1)))
+		| (setting->coarse << (lane * 4 + 1));
 
-	MCHBAR32(0x400*ch + 0x5c8) = (MCHBAR32(0x400*ch + 0x5c8) & ~(0x3 << (16+lane*2))) |
-		(setting->clk_delay << (16+lane*2));
-	MCHBAR32(0x400*ch + 0x5cc) = (MCHBAR32(0x400*ch + 0x5cc) & ~(0x3 << (16+lane*2))) |
-		(setting->clk_delay << (16+lane*2));
-	MCHBAR32(0x400*ch + 0x5d0) = (MCHBAR32(0x400*ch + 0x5d0) & ~(0x3 << (16+lane*2))) |
-		(setting->clk_delay << (16+lane*2));
-	MCHBAR32(0x400*ch + 0x5d4) = (MCHBAR32(0x400*ch + 0x5d4) & ~(0x3 << (16+lane*2))) |
-		(setting->clk_delay << (16+lane*2));
+	for (rank = 0; rank < 4; rank++) {
+		MCHBAR32(0x400 * ch + 0x5b4 + rank * 4) =
+			(MCHBAR32(0x400 * ch + 0x5b4 + rank * 4)
+				& ~(0x201 << lane))
+			| (setting->db_en << (9 + lane))
+			| (setting->db_sel << lane);
 
-	MCHBAR8(0x400*ch + 0x520 + lane*4) = (MCHBAR8(0x400*ch + 0x520 + lane*4) & ~0x70) |
-		(setting->pi << 4);
-	MCHBAR8(0x400*ch + 0x520 + lane*4) = (MCHBAR8(0x400*ch + 0x520 + lane*4) & ~0xf) |
-		setting->tap;
-	MCHBAR8(0x400*ch + 0x521 + lane*4) = (MCHBAR8(0x400*ch + 0x521 + lane*4) & ~0x70) |
-		(setting->pi << 4);
-	MCHBAR8(0x400*ch + 0x521 + lane*4) = (MCHBAR8(0x400*ch + 0x521 + lane*4) & ~0xf) |
-		setting->tap;
-	MCHBAR8(0x400*ch + 0x522 + lane*4) = (MCHBAR8(0x400*ch + 0x522 + lane*4) & ~0x70) |
-		(setting->pi << 4);
-	MCHBAR8(0x400*ch + 0x522 + lane*4) = (MCHBAR8(0x400*ch + 0x522 + lane*4) & ~0xf) |
-		setting->tap;
-	MCHBAR8(0x400*ch + 0x523 + lane*4) = (MCHBAR8(0x400*ch + 0x523 + lane*4) & ~0x70) |
-		(setting->pi << 4);
-	MCHBAR8(0x400*ch + 0x523 + lane*4) = (MCHBAR8(0x400*ch + 0x523 + lane*4) & ~0xf) |
-		setting->tap;
+		MCHBAR32(0x400*ch + 0x5c8 + rank * 4) =
+			(MCHBAR32(0x400 * ch + 0x5c8 + rank * 4)
+				& ~(0x3 << (16 + lane * 2)))
+			| (setting->clk_delay << (16+lane * 2));
+
+		MCHBAR8(0x400*ch + 0x520 + lane * 4 + rank) =
+			(MCHBAR8(0x400*ch + 0x520 + lane*4) & ~0x7f)
+			| (setting->pi << 4)
+			| setting->tap;
+	}
 }
 
 static void dqset(u8 ch, u8 lane, const struct dll_setting *setting)
 {
-	MCHBAR32(0x400*ch + 0x5fc) = MCHBAR32(0x400*ch + 0x5fc) & ~(1 << (lane*4));
+	int rank;
+	MCHBAR32(0x400 * ch + 0x5fc) = (MCHBAR32(0x400 * ch + 0x5fc)
+			& ~(1 << (lane * 4)))
+		| (setting->coarse << (lane * 4));
 
-	MCHBAR32(0x400*ch + 0x5a4) = (MCHBAR32(0x400*ch + 0x5a4) & ~(0x201 << lane)) |
-		(setting->db_en << (9 + lane)) |
-		(setting->db_sel << lane);
-	MCHBAR32(0x400*ch + 0x5a8) = (MCHBAR32(0x400*ch + 0x5a8) & ~(0x201 << lane)) |
-		(setting->db_en << (9 + lane)) |
-		(setting->db_sel << lane);
-	MCHBAR32(0x400*ch + 0x5ac) = (MCHBAR32(0x400*ch + 0x5ac) & ~(0x201 << lane)) |
-		(setting->db_en << (9 + lane)) |
-		(setting->db_sel << lane);
-	MCHBAR32(0x400*ch + 0x5b0) = (MCHBAR32(0x400*ch + 0x5b0) & ~(0x201 << lane)) |
-		(setting->db_en << (9 + lane)) |
-		(setting->db_sel << lane);
+	for (rank = 0; rank < 4; rank++) {
+		MCHBAR32(0x400 * ch + 0x5a4 + rank * 4) =
+			(MCHBAR32(0x400 * ch + 0x5a4 + rank * 4)
+				& ~(0x201 << lane))
+			| (setting->db_en << (9 + lane))
+			| (setting->db_sel << lane);
 
-	MCHBAR32(0x400*ch + 0x5c8) = (MCHBAR32(0x400*ch + 0x5c8) & ~(0x3 << (lane*2))) |
-		(setting->clk_delay << (2 * lane));
-	MCHBAR32(0x400*ch + 0x5cc) = (MCHBAR32(0x400*ch + 0x5cc) & ~(0x3 << (lane*2))) |
-		(setting->clk_delay << (2 * lane));
-	MCHBAR32(0x400*ch + 0x5d0) = (MCHBAR32(0x400*ch + 0x5d0) & ~(0x3 << (lane*2))) |
-		(setting->clk_delay << (2 * lane));
-	MCHBAR32(0x400*ch + 0x5d4) = (MCHBAR32(0x400*ch + 0x5d4) & ~(0x3 << (lane*2))) |
-		(setting->clk_delay << (2 * lane));
-
-	MCHBAR8(0x400*ch + 0x500 + lane*4) = (MCHBAR8(0x400*ch + 0x500 + lane*4) & ~0x70) |
-		(setting->pi << 4);
-	MCHBAR8(0x400*ch + 0x500 + lane*4) = (MCHBAR8(0x400*ch + 0x500 + lane*4) & ~0xf) |
-		setting->tap;
-	MCHBAR8(0x400*ch + 0x501 + lane*4) = (MCHBAR8(0x400*ch + 0x501 + lane*4) & ~0x70) |
-		(setting->pi << 4);
-	MCHBAR8(0x400*ch + 0x501 + lane*4) = (MCHBAR8(0x400*ch + 0x501 + lane*4) & ~0xf) |
-		setting->tap;
-	MCHBAR8(0x400*ch + 0x502 + lane*4) = (MCHBAR8(0x400*ch + 0x502 + lane*4) & ~0x70) |
-		(setting->pi << 4);
-	MCHBAR8(0x400*ch + 0x502 + lane*4) = (MCHBAR8(0x400*ch + 0x502 + lane*4) & ~0xf) |
-		setting->tap;
-	MCHBAR8(0x400*ch + 0x503 + lane*4) = (MCHBAR8(0x400*ch + 0x503 + lane*4) & ~0x70) |
-		(setting->pi << 4);
-	MCHBAR8(0x400*ch + 0x503 + lane*4) = (MCHBAR8(0x400*ch + 0x503 + lane*4) & ~0xf) |
-		setting->tap;
+		MCHBAR32(0x400 * ch + 0x5c8 + rank * 4) =
+			(MCHBAR32(0x400 * ch + 0x5c8 + rank * 4)
+				& ~(0x3 << (lane * 2)))
+			| (setting->clk_delay << (2 * lane));
+o
+		MCHBAR8(0x400*ch + 0x500 + lane * 4 + rank) =
+			(MCHBAR8(0x400 * ch + 0x500 + lane * 4 + rank) & ~0x7f)
+			| (setting->pi << 4)
+			| setting->tap;
+	}
 }
 
 static void timings_ddr2(struct sysinfo *s)

-- 
To view, visit https://review.coreboot.org/20136
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3a9e28cfec915a0bb15789c23bea259f621b5096
Gerrit-Change-Number: 20136
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur at aheymans.xyz>



More information about the coreboot-gerrit mailing list