diff options
author | Patrick Rudolph <siro@das-labor.org> | 2015-07-12 17:01:42 +0200 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-07-22 18:10:51 +0200 |
commit | e324cc91e09662ef5edb84f8160bbfa830bc701b (patch) | |
tree | d3c6ff0ecfa16e8cda8f24d30141ee8281460e8d /src/northbridge/intel | |
parent | 0620b1e8a3097a1b1fd5f8e29839fec393723b81 (diff) | |
download | coreboot-e324cc91e09662ef5edb84f8160bbfa830bc701b.tar.xz |
intel raminit: rewrite timB high adjust calculation
Found while doing code review.
Simplify the code by using a loop for positive and negative phase
adjustments.
Change-Id: I0980443d0d2815bccef969709fddecc07d61a788
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-on: http://review.coreboot.org/10890
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Nicolas Reinecke <nr@das-labor.org>
Diffstat (limited to 'src/northbridge/intel')
-rw-r--r-- | src/northbridge/intel/sandybridge/raminit_native.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/northbridge/intel/sandybridge/raminit_native.c b/src/northbridge/intel/sandybridge/raminit_native.c index 0708f47730..790f47c46c 100644 --- a/src/northbridge/intel/sandybridge/raminit_native.c +++ b/src/northbridge/intel/sandybridge/raminit_native.c @@ -2288,18 +2288,17 @@ static int get_timB_high_adjust(u64 val) if (val == 0xffffffffffffffffLL) return 0; - if (val >= 0xfffffffffffff000LL) - return 3; - if (val >= 0xfffffffffff00000LL) - return -1; - if (val >= 0xfffffff000000000LL) - return -2; - if (val >= 0xfff0000000000000LL) - return -3; - - for (i = 0; i < 8; i++) - if (val >> (8 * (7 - i) + 4)) - return i; + if (val >= 0xf000000000000000LL) { + /* needs negative adjustment */ + for (i = 0; i < 8; i++) + if (val << (8 * (7 - i) + 4)) + return -i; + } else { + /* needs positive adjustment */ + for (i = 0; i < 8; i++) + if (val >> (8 * (7 - i) + 4)) + return i; + } return 8; } |