]> git.baikalelectronics.ru Git - kernel.git/commit
spi/spi-pl022: calculate_effective_freq() must set rate <= requested rate
authorViresh Kumar <viresh.kumar@st.com>
Wed, 10 Aug 2011 08:50:57 +0000 (14:20 +0530)
committerGrant Likely <grant.likely@secretlab.ca>
Wed, 21 Sep 2011 15:41:47 +0000 (09:41 -0600)
commit1128fa25e0dd8e161e63db8c715a940ac90f0847
tree8b23e1c9779352c633f82d4d341222ab11df7593
parent33eeb40608c92b4d0ea91890732b7a461a5d2b69
spi/spi-pl022: calculate_effective_freq() must set rate <= requested rate

There were few issues with calculate_effective_freq() routine:
- It was returning first rate found >= requested rate. Now, if system have spi's
  rate as 83 MHz, with possible prescaled rates as 83, 41.5, 20.75, 13.83 (as we
  can prescale with multiples of 2). If user has given rate to be programmed as
  22 MHz, then driver programmes it to 41.5 MHz. This looks to be incorrect, as
  user might have given the upper limit of the device, and we are programming it
  above it.
- Driver finds the first satisfying rate and programmes it, but with other
  values of scr & cpsdvsr, it is possible to get more closer rate.

This patch fixes these two issues, with some reformatting inside the code.  This
also creates a inline routine to calculate prescaled rate based on spi's rate,
cpsdvsr and scr.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
drivers/spi/spi-pl022.c