From 8b2c8f1c10d81299196ac8413cb51330ba3d1f12 Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Tue, 17 Feb 2015 04:31:01 -0600 Subject: sandybridge/raminit: Get max mem clock from devicetree Note that the limit is not set in the devicetree.cb which use native sandybridge raminit, as it is not needed. When that isn't set, it's automatically set to zero, and when we find that, we automatically return the default limit. Thus behavior isn't changed for any board. Change-Id: I447399eea71355612b654710a56f3a0077c2f7f9 Signed-off-by: Alexandru Gagniuc Reviewed-on: http://review.coreboot.org/8476 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Patrick Georgi --- src/northbridge/intel/sandybridge/chip.h | 6 ++++ .../intel/sandybridge/romstage_native.c | 33 +++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'src/northbridge/intel') diff --git a/src/northbridge/intel/sandybridge/chip.h b/src/northbridge/intel/sandybridge/chip.h index 07809f5716..a0abf44fb7 100644 --- a/src/northbridge/intel/sandybridge/chip.h +++ b/src/northbridge/intel/sandybridge/chip.h @@ -41,5 +41,11 @@ struct northbridge_intel_sandybridge_config { u32 gpu_cpu_backlight; /* CPU Backlight PWM value */ u32 gpu_pch_backlight; /* PCH Backlight PWM value */ + /* + * Maximum memory clock. + * For example 666 for DDR3-1333, or 800 for DDR3-1600 + */ + u16 max_mem_clock_mhz; + struct i915_gpu_controller_info gfx; }; diff --git a/src/northbridge/intel/sandybridge/romstage_native.c b/src/northbridge/intel/sandybridge/romstage_native.c index 737cd63c32..332d9ba175 100644 --- a/src/northbridge/intel/sandybridge/romstage_native.c +++ b/src/northbridge/intel/sandybridge/romstage_native.c @@ -29,11 +29,42 @@ #include "sandybridge.h" #include #include +#include +#include #include #include "raminit_native.h" +#include #include "southbridge/intel/bd82x6x/pch.h" #include "southbridge/intel/bd82x6x/gpio.h" +#define HOST_BRIDGE PCI_DEVFN(0, 0) +#define DEFAULT_TCK TCK_800MHZ + +static unsigned int get_mem_min_tck(void) +{ + const struct device *dev; + const struct northbridge_intel_sandybridge_config *cfg; + + dev = dev_find_slot(0, HOST_BRIDGE); + if (!(dev && dev->chip_info)) + return DEFAULT_TCK; + + cfg = dev->chip_info; + + /* If this is zero, it just means devicetree.cb didn't set it */ + if (cfg->max_mem_clock_mhz == 0) + return DEFAULT_TCK; + + if (cfg->max_mem_clock_mhz >= 800) + return TCK_800MHZ; + else if (cfg->max_mem_clock_mhz >= 666) + return TCK_666MHZ; + else if (cfg->max_mem_clock_mhz >= 533) + return TCK_533MHZ; + else + return TCK_400MHZ; +} + void main(unsigned long bist) { int s3resume = 0; @@ -87,7 +118,7 @@ void main(unsigned long bist) timestamp_add_now(TS_BEFORE_INITRAM); - init_dram_ddr3(spd, 1, TCK_800MHZ, s3resume); + init_dram_ddr3(spd, 1, get_mem_min_tck(), s3resume); timestamp_add_now(TS_AFTER_INITRAM); post_code(0x3c); -- cgit v1.2.3