From 770996fd86a2dfd44b0985b898af56c9dc10244b Mon Sep 17 00:00:00 2001 From: "Ronald G. Minnich" Date: Tue, 29 Jan 2013 11:52:05 -0800 Subject: Exynos5250: make vendor enums in the timing array more debuggable. The timing array is crucial to proper operation of DRAM. Getting a valid pointer to it is hence very important. Unfortunately, the constants chosen for the vendor were '1', and '2', (this in a 32-bit word) which in a debug print makes it almost impossible to tell if you've got a misaligned pointer. Note: coreboot people did not choose them :-) So, give them values which are extremely unlikely to occur elsewhere in the array (or in memory, for that matter). Given the frequency with which this check occurs, i.e. once, I would much prefer strings but I expect I'd get shouted down on that one. Constants in this case are an almost useless optimization but we'll go with them for now. Note no space is saved by not using strings: there's an entire function somewhere devoted to mapping the enum to a string! Debug prints of pointers to structs in this array are now far more useful than they were. See snarky comment in the code (left there to make sure nobody gets tempted to get fancy again). Comment now less snarky. This is tested on google snow to the point that the DRAM works. Change-Id: I30bc44719f321f791fd82ded60e29393399d9e3d Signed-off-by: Ronald G. Minnich Reviewed-on: http://review.coreboot.org/2221 Reviewed-by: David Hendricks Tested-by: build bot (Jenkins) --- src/cpu/samsung/exynos5250/dmc.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/cpu/samsung/exynos5250') diff --git a/src/cpu/samsung/exynos5250/dmc.h b/src/cpu/samsung/exynos5250/dmc.h index d1dfbb162f..b778e099d8 100644 --- a/src/cpu/samsung/exynos5250/dmc.h +++ b/src/cpu/samsung/exynos5250/dmc.h @@ -152,12 +152,27 @@ enum ddr_mode { DDR_MODE_COUNT, }; +/* For reasons unknown, people are in the habit of taking a 32-bit + * field with 2 possible values and packing it with, say, 2 bits. A + * non-robust encoding, using only 2 bits of a 32-bit field, is + * incredibly difficult to deal with when things go wrong, because + * there are a lot of things that get expressed as 0, 1, or 2. If + * you're scanning with jtag or dumping memory it is really hard to + * tell when you've hit the beginning of the struct. So, let's be a + * bit smart here. First, while it's common to let the enum count + * entries for you, when there are two of them, we can do the + * counting. And, let's set the values to something we can easily scan + * for in memory. Since '1' and '2' are rather common, we pick + * something that's actually of some value when things go wrong. This + * setup motivated by a use case: something's going wrong and having a + * manuf name of '1' or '2' is completely useless! + */ enum mem_manuf { MEM_MANUF_AUTODETECT, - MEM_MANUF_ELPIDA, - MEM_MANUF_SAMSUNG, + MEM_MANUF_ELPIDA = 0xe7b1da, + MEM_MANUF_SAMSUNG = 0x5a5096, - MEM_MANUF_COUNT, + MEM_MANUF_COUNT = 2, // fancy that. }; /* CONCONTROL register fields */ -- cgit v1.2.3