Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 299750
b: refs/heads/master
c: 5eb806a
h: refs/heads/master
v: v3
  • Loading branch information
Viresh Kumar authored and Grant Likely committed Apr 27, 2012
1 parent 6b84411 commit 385bcd4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: eb798c641a34ae9cee9fcacfbe5dd40bd7777607
refs/heads/master: 5eb806a3a68920a9f373f18b03fa14852047e62b
23 changes: 17 additions & 6 deletions trunk/drivers/spi/spi-pl022.c
Original file line number Diff line number Diff line change
Expand Up @@ -1681,26 +1681,37 @@ static int calculate_effective_freq(struct pl022 *pl022, int freq, struct
while (scr <= SCR_MAX) {
tmp = spi_rate(rate, cpsdvsr, scr);

if (tmp > freq)
if (tmp > freq) {
/* we need lower freq */
scr++;
continue;
}

/*
* If found exact value, update and break.
* If found more closer value, update and continue.
* If found exact value, mark found and break.
* If found more closer value, update and break.
*/
else if ((tmp == freq) || (tmp > best_freq)) {
if (tmp > best_freq) {
best_freq = tmp;
best_cpsdvsr = cpsdvsr;
best_scr = scr;

if (tmp == freq)
break;
found = 1;
}
scr++;
/*
* increased scr will give lower rates, which are not
* required
*/
break;
}
cpsdvsr += 2;
scr = SCR_MIN;
}

WARN(!best_freq, "pl022: Matching cpsdvsr and scr not found for %d Hz rate \n",
freq);

clk_freq->cpsdvsr = (u8) (best_cpsdvsr & 0xFF);
clk_freq->scr = (u8) (best_scr & 0xFF);
dev_dbg(&pl022->adev->dev,
Expand Down

0 comments on commit 385bcd4

Please sign in to comment.