diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2015-10-13 10:09:14 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-10-16 14:07:45 -0400 |
commit | 3ad48062233f32a8dd2649403f5afc076710f86b (patch) | |
tree | 928182d75cd5a3a1f17d572793b40fe54ffd2a75 /drivers/spi/spi-pxa2xx.c | |
parent | 289de5541ca6aec56308c04b76c1bb59f00b1f09 (diff) |
spi: pxa2xx: choose closest lower speed
As per discussion [1] the best choice is to set closest speed which is not
going over the asked one.
Do the same approach for Intel Quark boards.
[1] http://www.spinics.net/lists/linux-spi/msg03389.html
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-pxa2xx.c')
-rw-r--r-- | drivers/spi/spi-pxa2xx.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 22b473ebf607..158967a10bec 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c | |||
@@ -730,7 +730,7 @@ static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds) | |||
730 | mul = (1 << 24) >> 1; | 730 | mul = (1 << 24) >> 1; |
731 | 731 | ||
732 | /* Calculate initial quot */ | 732 | /* Calculate initial quot */ |
733 | q1 = DIV_ROUND_CLOSEST(fref1, rate); | 733 | q1 = DIV_ROUND_UP(fref1, rate); |
734 | 734 | ||
735 | /* Scale q1 if it's too big */ | 735 | /* Scale q1 if it's too big */ |
736 | if (q1 > 256) { | 736 | if (q1 > 256) { |
@@ -755,7 +755,7 @@ static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds) | |||
755 | 755 | ||
756 | /* Case 2 */ | 756 | /* Case 2 */ |
757 | 757 | ||
758 | q2 = DIV_ROUND_CLOSEST(fref2, rate); | 758 | q2 = DIV_ROUND_UP(fref2, rate); |
759 | r2 = abs(fref2 / q2 - rate); | 759 | r2 = abs(fref2 / q2 - rate); |
760 | 760 | ||
761 | /* | 761 | /* |
@@ -774,13 +774,13 @@ static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds) | |||
774 | mul = (1 << 24) * 2 / 5; | 774 | mul = (1 << 24) * 2 / 5; |
775 | } | 775 | } |
776 | 776 | ||
777 | /* Check case 3 only If the divisor is big enough */ | 777 | /* Check case 3 only if the divisor is big enough */ |
778 | if (fref / rate >= 80) { | 778 | if (fref / rate >= 80) { |
779 | u64 fssp; | 779 | u64 fssp; |
780 | u32 m; | 780 | u32 m; |
781 | 781 | ||
782 | /* Calculate initial quot */ | 782 | /* Calculate initial quot */ |
783 | q1 = DIV_ROUND_CLOSEST(fref, rate); | 783 | q1 = DIV_ROUND_UP(fref, rate); |
784 | m = (1 << 24) / q1; | 784 | m = (1 << 24) / q1; |
785 | 785 | ||
786 | /* Get the remainder */ | 786 | /* Get the remainder */ |