aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/memory
diff options
context:
space:
mode:
authorLokesh Vutla <lokeshvutla@ti.com>2013-03-16 02:16:41 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-25 16:18:11 -0400
commit0a5f19cf303ea9cc9bf89a42960a69db4ea3c35b (patch)
treee315ee7a92d5fa1e076d5cfca66e778572776d71 /drivers/memory
parent275b5d2061c20749582060be68b6ec4692736d28 (diff)
memory: emif: Fix the lpmode timeout calculation
The driver tries to round up the specified timeout cycles to the next power of 2 value. This should be done defore updating timeout variable. Correcting this here. Reported-by: Nishanth Menon <nm@ti.com> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/memory')
-rw-r--r--drivers/memory/emif.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c
index ecbc1a996eb6..897c39a8db86 100644
--- a/drivers/memory/emif.c
+++ b/drivers/memory/emif.c
@@ -728,13 +728,17 @@ static u32 get_pwr_mgmt_ctrl(u32 freq, struct emif_data *emif, u32 ip_rev)
728 /* Timeout based on DDR frequency */ 728 /* Timeout based on DDR frequency */
729 timeout = freq >= freq_threshold ? timeout_perf : timeout_pwr; 729 timeout = freq >= freq_threshold ? timeout_perf : timeout_pwr;
730 730
731 /* The value to be set in register is "log2(timeout) - 3" */ 731 /*
732 * The value to be set in register is "log2(timeout) - 3"
733 * if timeout < 16 load 0 in register
734 * if timeout is not a power of 2, round to next highest power of 2
735 */
732 if (timeout < 16) { 736 if (timeout < 16) {
733 timeout = 0; 737 timeout = 0;
734 } else { 738 } else {
735 timeout = __fls(timeout) - 3;
736 if (timeout & (timeout - 1)) 739 if (timeout & (timeout - 1))
737 timeout++; 740 timeout <<= 1;
741 timeout = __fls(timeout) - 3;
738 } 742 }
739 743
740 switch (lpmode) { 744 switch (lpmode) {