Commit ea505bc9 authored by Viresh Kumar's avatar Viresh Kumar Committed by Grant Likely

spi/pl022: Allow request for higher frequency than maximum possible

Currently, if we request for frequency greater than maximum possible, spi driver
returns error.

For example, if the spi block src frequency is 333/4 MHz, i.e. 83.33.. MHz,
maximum frequency programmable would be src/2. Which would come around 41.6...

It is difficult to pass frequency in these figures. We normally try to program
in round figures, like 42 MHz and it should get programmed to <=
requested_frequency, i.e. 41.6...

For this to happen, we must not return error even if requested freq is higher
than max possible. But should program it to max possible.
Reported-by: default avatarVinit Kamalaksha Shenoy <vinit.shenoy@st.com>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@st.com>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent 88a3a255
...@@ -1667,9 +1667,15 @@ static int calculate_effective_freq(struct pl022 *pl022, int freq, struct ...@@ -1667,9 +1667,15 @@ static int calculate_effective_freq(struct pl022 *pl022, int freq, struct
/* cpsdvsr = 254 & scr = 255 */ /* cpsdvsr = 254 & scr = 255 */
min_tclk = spi_rate(rate, CPSDVR_MAX, SCR_MAX); min_tclk = spi_rate(rate, CPSDVR_MAX, SCR_MAX);
if (!((freq <= max_tclk) && (freq >= min_tclk))) { if (freq > max_tclk)
dev_warn(&pl022->adev->dev,
"Max speed that can be programmed is %d Hz, you requested %d\n",
max_tclk, freq);
if (freq < min_tclk) {
dev_err(&pl022->adev->dev, dev_err(&pl022->adev->dev,
"controller data is incorrect: out of range frequency"); "Requested frequency: %d Hz is less than minimum possible %d Hz\n",
freq, min_tclk);
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment