* [PATCH 4/4] mmc: dw_mmc: correct the calculation for CLKDIV
@ 2012-05-20 4:27 Seungwon Jeon
2012-05-21 10:25 ` Will Newton
0 siblings, 1 reply; 3+ messages in thread
From: Seungwon Jeon @ 2012-05-20 4:27 UTC (permalink / raw)
To: linux-mmc
Cc: 'Chris Ball', 'Will Newton',
'James Hogan'
In case of "host->bus_hz < slot->clock", divider value is
miscalculated. And clock divider register value is multiple
of 2. If calculated divider value is odd number, result can
be over-clocking.
Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
---
drivers/mmc/host/dw_mmc.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index f2f8463..c87745e 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -617,14 +617,16 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot)
u32 div;
if (slot->clock != host->current_speed) {
- if (host->bus_hz % slot->clock)
+ div = host->bus_hz / slot->clock;
+ if (host->bus_hz % slot->clock &&
+ host->bus_hz > slot->clock)
/*
* move the + 1 after the divide to prevent
* over-clocking the card.
*/
- div = ((host->bus_hz / slot->clock) >> 1) + 1;
- else
- div = (host->bus_hz / slot->clock) >> 1;
+ div += 1;
+
+ div = (host->bus_hz != slot->clock) ? DIV_ROUND_UP(div, 2) : 0;
dev_info(&slot->mmc->class_dev,
"Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ"
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 4/4] mmc: dw_mmc: correct the calculation for CLKDIV
2012-05-20 4:27 [PATCH 4/4] mmc: dw_mmc: correct the calculation for CLKDIV Seungwon Jeon
@ 2012-05-21 10:25 ` Will Newton
2012-05-22 3:35 ` Seungwon Jeon
0 siblings, 1 reply; 3+ messages in thread
From: Will Newton @ 2012-05-21 10:25 UTC (permalink / raw)
To: Seungwon Jeon; +Cc: linux-mmc, Chris Ball, James Hogan
On Sun, May 20, 2012 at 5:27 AM, Seungwon Jeon <tgih.jun@samsung.com> wrote:
> In case of "host->bus_hz < slot->clock", divider value is
> miscalculated. And clock divider register value is multiple
> of 2. If calculated divider value is odd number, result can
> be over-clocking.
>
> Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
> ---
> drivers/mmc/host/dw_mmc.c | 10 ++++++----
> 1 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index f2f8463..c87745e 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -617,14 +617,16 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot)
> u32 div;
>
> if (slot->clock != host->current_speed) {
> - if (host->bus_hz % slot->clock)
> + div = host->bus_hz / slot->clock;
> + if (host->bus_hz % slot->clock &&
> + host->bus_hz > slot->clock)
> /*
> * move the + 1 after the divide to prevent
> * over-clocking the card.
> */
This comment seems to be no longer relevant so it should be removed.
> - div = ((host->bus_hz / slot->clock) >> 1) + 1;
> - else
> - div = (host->bus_hz / slot->clock) >> 1;
> + div += 1;
> +
> + div = (host->bus_hz != slot->clock) ? DIV_ROUND_UP(div, 2) : 0;
>
> dev_info(&slot->mmc->class_dev,
> "Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ"
> --
> 1.7.0.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH 4/4] mmc: dw_mmc: correct the calculation for CLKDIV
2012-05-21 10:25 ` Will Newton
@ 2012-05-22 3:35 ` Seungwon Jeon
0 siblings, 0 replies; 3+ messages in thread
From: Seungwon Jeon @ 2012-05-22 3:35 UTC (permalink / raw)
To: 'Will Newton'
Cc: linux-mmc, 'Chris Ball', 'James Hogan'
Will Newton <will.newton@gmail.com> wrote:
> On Sun, May 20, 2012 at 5:27 AM, Seungwon Jeon <tgih.jun@samsung.com> wrote:
> > In case of "host->bus_hz < slot->clock", divider value is
> > miscalculated. And clock divider register value is multiple
> > of 2. If calculated divider value is odd number, result can
> > be over-clocking.
> >
> > Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
> > ---
> > drivers/mmc/host/dw_mmc.c | 10 ++++++----
> > 1 files changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> > index f2f8463..c87745e 100644
> > --- a/drivers/mmc/host/dw_mmc.c
> > +++ b/drivers/mmc/host/dw_mmc.c
> > @@ -617,14 +617,16 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot)
> > u32 div;
> >
> > if (slot->clock != host->current_speed) {
> > - if (host->bus_hz % slot->clock)
> > + div = host->bus_hz / slot->clock;
> > + if (host->bus_hz % slot->clock &&
> > + host->bus_hz > slot->clock)
> > /*
> > * move the + 1 after the divide to prevent
> > * over-clocking the card.
> > */
>
> This comment seems to be no longer relevant so it should be removed.
>
> > - div = ((host->bus_hz / slot->clock) >> 1) + 1;
> > - else
> > - div = (host->bus_hz / slot->clock) >> 1;
> > + div += 1;
div += 1;
It's still effective.
Best regards,
Seungwon Jeon
> > +
> > + div = (host->bus_hz != slot->clock) ? DIV_ROUND_UP(div, 2) : 0;
> >
> > dev_info(&slot->mmc->class_dev,
> > "Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ"
> > --
> > 1.7.0.4
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-05-22 3:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-20 4:27 [PATCH 4/4] mmc: dw_mmc: correct the calculation for CLKDIV Seungwon Jeon
2012-05-21 10:25 ` Will Newton
2012-05-22 3:35 ` Seungwon Jeon
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).