aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/spi/spi-pl022.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 1ead49dbebce..8aa44e7adaef 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1681,26 +1681,37 @@ static int calculate_effective_freq(struct pl022 *pl022, int freq, struct
1681 while (scr <= SCR_MAX) { 1681 while (scr <= SCR_MAX) {
1682 tmp = spi_rate(rate, cpsdvsr, scr); 1682 tmp = spi_rate(rate, cpsdvsr, scr);
1683 1683
1684 if (tmp > freq) 1684 if (tmp > freq) {
1685 /* we need lower freq */
1685 scr++; 1686 scr++;
1687 continue;
1688 }
1689
1686 /* 1690 /*
1687 * If found exact value, update and break. 1691 * If found exact value, mark found and break.
1688 * If found more closer value, update and continue. 1692 * If found more closer value, update and break.
1689 */ 1693 */
1690 else if ((tmp == freq) || (tmp > best_freq)) { 1694 if (tmp > best_freq) {
1691 best_freq = tmp; 1695 best_freq = tmp;
1692 best_cpsdvsr = cpsdvsr; 1696 best_cpsdvsr = cpsdvsr;
1693 best_scr = scr; 1697 best_scr = scr;
1694 1698
1695 if (tmp == freq) 1699 if (tmp == freq)
1696 break; 1700 found = 1;
1697 } 1701 }
1698 scr++; 1702 /*
1703 * increased scr will give lower rates, which are not
1704 * required
1705 */
1706 break;
1699 } 1707 }
1700 cpsdvsr += 2; 1708 cpsdvsr += 2;
1701 scr = SCR_MIN; 1709 scr = SCR_MIN;
1702 } 1710 }
1703 1711
1712 WARN(!best_freq, "pl022: Matching cpsdvsr and scr not found for %d Hz rate \n",
1713 freq);
1714
1704 clk_freq->cpsdvsr = (u8) (best_cpsdvsr & 0xFF); 1715 clk_freq->cpsdvsr = (u8) (best_cpsdvsr & 0xFF);
1705 clk_freq->scr = (u8) (best_scr & 0xFF); 1716 clk_freq->scr = (u8) (best_scr & 0xFF);
1706 dev_dbg(&pl022->adev->dev, 1717 dev_dbg(&pl022->adev->dev,