* [PATCH] spi: pl022: Allow request for higher frequency than maximum possible
@ 2012-04-19 6:18 Viresh Kumar
[not found] ` <fef35098d2e7f03888b21356bd2a5f73936ab6d1.1334814714.git.viresh.kumar-qxv4g6HH51o@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2012-04-19 6:18 UTC (permalink / raw)
To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
grant.likely-s3s/WqlpOiPyB63q8FvJNQ
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Viresh Kumar,
spear-devel-nkJGhpqTU55BDgjK7y7TUQ
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: Vinit Kamalaksha Shenoy <vinit.shenoy-qxv4g6HH51o@public.gmane.org>
Signed-off-by: Viresh Kumar <viresh.kumar-qxv4g6HH51o@public.gmane.org>
---
drivers/spi/spi-pl022.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 09c925a..99d5f6d 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1667,9 +1667,15 @@ static int calculate_effective_freq(struct pl022 *pl022, int freq, struct
/* cpsdvsr = 254 & scr = 255 */
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,
- "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;
}
--
1.7.9
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: pl022: Allow request for higher frequency than maximum possible
[not found] ` <fef35098d2e7f03888b21356bd2a5f73936ab6d1.1334814714.git.viresh.kumar-qxv4g6HH51o@public.gmane.org>
@ 2012-04-19 17:29 ` Linus Walleij
2012-04-27 18:08 ` Grant Likely
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2012-04-19 17:29 UTC (permalink / raw)
To: Viresh Kumar
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
spear-devel-nkJGhpqTU55BDgjK7y7TUQ
On Thu, Apr 19, 2012 at 8:18 AM, Viresh Kumar <viresh.kumar-qxv4g6HH51o@public.gmane.org> wrote:
> 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: Vinit Kamalaksha Shenoy <vinit.shenoy-qxv4g6HH51o@public.gmane.org>
> Signed-off-by: Viresh Kumar <viresh.kumar-qxv4g6HH51o@public.gmane.org>
Looks reasonable and mostly harmless :-)
Acked-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Yours,
Linus Walleij
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: pl022: Allow request for higher frequency than maximum possible
[not found] ` <fef35098d2e7f03888b21356bd2a5f73936ab6d1.1334814714.git.viresh.kumar-qxv4g6HH51o@public.gmane.org>
2012-04-19 17:29 ` Linus Walleij
@ 2012-04-27 18:08 ` Grant Likely
1 sibling, 0 replies; 3+ messages in thread
From: Grant Likely @ 2012-04-27 18:08 UTC (permalink / raw)
To: Viresh Kumar, linus.walleij-QSEj5FYQhm4dnm+yROfE0A
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Viresh Kumar,
spear-devel-nkJGhpqTU55BDgjK7y7TUQ
On Thu, 19 Apr 2012 11:48:15 +0530, Viresh Kumar <viresh.kumar-qxv4g6HH51o@public.gmane.org> wrote:
> 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: Vinit Kamalaksha Shenoy <vinit.shenoy-qxv4g6HH51o@public.gmane.org>
> Signed-off-by: Viresh Kumar <viresh.kumar-qxv4g6HH51o@public.gmane.org>
Applied, thanks.
g.
> ---
> drivers/spi/spi-pl022.c | 10 ++++++++--
> 1 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
> index 09c925a..99d5f6d 100644
> --- a/drivers/spi/spi-pl022.c
> +++ b/drivers/spi/spi-pl022.c
> @@ -1667,9 +1667,15 @@ static int calculate_effective_freq(struct pl022 *pl022, int freq, struct
> /* cpsdvsr = 254 & scr = 255 */
> 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,
> - "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;
> }
>
> --
> 1.7.9
>
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-04-27 18:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-19 6:18 [PATCH] spi: pl022: Allow request for higher frequency than maximum possible Viresh Kumar
[not found] ` <fef35098d2e7f03888b21356bd2a5f73936ab6d1.1334814714.git.viresh.kumar-qxv4g6HH51o@public.gmane.org>
2012-04-19 17:29 ` Linus Walleij
2012-04-27 18:08 ` Grant Likely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).