* [PATCH 0/3] atmel-mci fixes
@ 2012-03-21 15:41 ludovic.desroches
2012-03-21 15:41 ` [PATCH 1/3] mmc: atmel-mci: correct data timeout computation ludovic.desroches
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: ludovic.desroches @ 2012-03-21 15:41 UTC (permalink / raw)
To: linux-mmc, linux-arm-kernel; +Cc: nicolas.ferre, ludovic.desroches, plagnioj
Hi,
The following patches provide some fixes for atmel-mci driver:
- data timeout calculation was not correct and can cause serious issues when
using a rootfs on the sd card.
- the r/w proof features is available only from 2xx hsmci version
- supports for odd clock dividers available from 5xx hsmci version
Regards
Ludovic
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 1/3] mmc: atmel-mci: correct data timeout computation 2012-03-21 15:41 [PATCH 0/3] atmel-mci fixes ludovic.desroches @ 2012-03-21 15:41 ` ludovic.desroches 2012-03-21 16:26 ` Sergei Shtylyov 2012-03-28 10:28 ` [PATCH v2 " ludovic.desroches 2012-03-21 15:41 ` [PATCH 2/3] mmc: atmel-mci: r/w proof capability only available since v2xx ludovic.desroches 2012-03-21 15:41 ` [PATCH 3/3] mmc: atmel-mci: add support for odd clock dividers ludovic.desroches 2 siblings, 2 replies; 14+ messages in thread From: ludovic.desroches @ 2012-03-21 15:41 UTC (permalink / raw) To: linux-mmc, linux-arm-kernel; +Cc: nicolas.ferre, ludovic.desroches, plagnioj From: Ludovic Desroches <ludovic.desroches@atmel.com> The HSMCI operates at a rate of up to Master Clock divided by two. Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> --- drivers/mmc/host/atmel-mci.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index e4449a5..e161452 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -480,7 +480,7 @@ err: static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host, unsigned int ns) { - return (ns * (host->bus_hz / 1000000) + 999) / 1000; + return (ns * ((host->bus_hz/2) / 1000000) + 999) / 1000; } static void atmci_set_timeout(struct atmel_mci *host, -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] mmc: atmel-mci: correct data timeout computation 2012-03-21 15:41 ` [PATCH 1/3] mmc: atmel-mci: correct data timeout computation ludovic.desroches @ 2012-03-21 16:26 ` Sergei Shtylyov 2012-03-22 8:57 ` Ludovic Desroches 2012-03-28 10:28 ` [PATCH v2 " ludovic.desroches 1 sibling, 1 reply; 14+ messages in thread From: Sergei Shtylyov @ 2012-03-21 16:26 UTC (permalink / raw) To: ludovic.desroches; +Cc: linux-mmc, linux-arm-kernel, plagnioj, nicolas.ferre Hello. On 03/21/2012 06:41 PM, ludovic.desroches@atmel.com wrote: > From: Ludovic Desroches<ludovic.desroches@atmel.com> > The HSMCI operates at a rate of up to Master Clock divided by two. > Signed-off-by: Ludovic Desroches<ludovic.desroches@atmel.com> > --- > drivers/mmc/host/atmel-mci.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c > index e4449a5..e161452 100644 > --- a/drivers/mmc/host/atmel-mci.c > +++ b/drivers/mmc/host/atmel-mci.c > @@ -480,7 +480,7 @@ err: > static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host, > unsigned int ns) > { > - return (ns * (host->bus_hz / 1000000) + 999) / 1000; > + return (ns * ((host->bus_hz/2) / 1000000) + 999) / 1000; Why don't you keep the notation by addign spaces around '/'? BTW, could use DIV_ROUND_UP() here. WBR, Sergei ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] mmc: atmel-mci: correct data timeout computation 2012-03-21 16:26 ` Sergei Shtylyov @ 2012-03-22 8:57 ` Ludovic Desroches 0 siblings, 0 replies; 14+ messages in thread From: Ludovic Desroches @ 2012-03-22 8:57 UTC (permalink / raw) To: Sergei Shtylyov Cc: ludovic.desroches, linux-mmc, linux-arm-kernel, plagnioj, nicolas.ferre Hello Sergei, On Wed, Mar 21, 2012 at 07:26:04PM +0300, Sergei Shtylyov wrote: > Hello. > > On 03/21/2012 06:41 PM, ludovic.desroches@atmel.com wrote: > > >From: Ludovic Desroches<ludovic.desroches@atmel.com> > > >The HSMCI operates at a rate of up to Master Clock divided by two. > > >Signed-off-by: Ludovic Desroches<ludovic.desroches@atmel.com> > >--- > > drivers/mmc/host/atmel-mci.c | 2 +- > > 1 files changed, 1 insertions(+), 1 deletions(-) > > >diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c > >index e4449a5..e161452 100644 > >--- a/drivers/mmc/host/atmel-mci.c > >+++ b/drivers/mmc/host/atmel-mci.c > >@@ -480,7 +480,7 @@ err: > > static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host, > > unsigned int ns) > > { > >- return (ns * (host->bus_hz / 1000000) + 999) / 1000; > >+ return (ns * ((host->bus_hz/2) / 1000000) + 999) / 1000; > > Why don't you keep the notation by addign spaces around '/'? > BTW, could use DIV_ROUND_UP() here. > Thanks for your comments. BTW I have realized (when testing values return using DIV_ROUND_UP) that I may have another issue with this timeout calculation. I will send a new patch. Regards Ludovic ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 1/3] mmc: atmel-mci: correct data timeout computation 2012-03-21 15:41 ` [PATCH 1/3] mmc: atmel-mci: correct data timeout computation ludovic.desroches 2012-03-21 16:26 ` Sergei Shtylyov @ 2012-03-28 10:28 ` ludovic.desroches 2012-03-28 11:44 ` Nicolas Ferre 1 sibling, 1 reply; 14+ messages in thread From: ludovic.desroches @ 2012-03-28 10:28 UTC (permalink / raw) To: linux-mmc, linux-arm-kernel; +Cc: nicolas.ferre From: Ludovic Desroches <ludovic.desroches@atmel.com> The HSMCI operates at a rate of up to Master Clock divided by two. Moreover previous calculation can cause overflows and so wrong timeouts. Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Cc: stable <stable@vger.kernel.org> --- drivers/mmc/host/atmel-mci.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index e4449a5..3a57964 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -480,7 +480,14 @@ err: static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host, unsigned int ns) { - return (ns * (host->bus_hz / 1000000) + 999) / 1000; + /* + * It is easier here to use us instead of ns for the timeout, + * it prevents from overflows during calculation. + */ + unsigned int us = DIV_ROUND_UP(ns, 1000); + + /* Maximum clock frequency is host->bus_hz/2 */ + return us * (DIV_ROUND_UP(host->bus_hz, 2000000)); } static void atmci_set_timeout(struct atmel_mci *host, -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/3] mmc: atmel-mci: correct data timeout computation 2012-03-28 10:28 ` [PATCH v2 " ludovic.desroches @ 2012-03-28 11:44 ` Nicolas Ferre 2012-04-01 3:43 ` Chris Ball 0 siblings, 1 reply; 14+ messages in thread From: Nicolas Ferre @ 2012-03-28 11:44 UTC (permalink / raw) To: ludovic.desroches; +Cc: linux-mmc, linux-arm-kernel On 03/28/2012 12:28 PM, ludovic.desroches@atmel.com : > From: Ludovic Desroches <ludovic.desroches@atmel.com> > > The HSMCI operates at a rate of up to Master Clock divided by two. > Moreover previous calculation can cause overflows and so wrong > timeouts. > > Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> > Cc: stable <stable@vger.kernel.org> > --- > drivers/mmc/host/atmel-mci.c | 9 ++++++++- > 1 files changed, 8 insertions(+), 1 deletions(-) > > diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c > index e4449a5..3a57964 100644 > --- a/drivers/mmc/host/atmel-mci.c > +++ b/drivers/mmc/host/atmel-mci.c > @@ -480,7 +480,14 @@ err: > static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host, > unsigned int ns) > { > - return (ns * (host->bus_hz / 1000000) + 999) / 1000; > + /* > + * It is easier here to use us instead of ns for the timeout, > + * it prevents from overflows during calculation. > + */ > + unsigned int us = DIV_ROUND_UP(ns, 1000); > + > + /* Maximum clock frequency is host->bus_hz/2 */ > + return us * (DIV_ROUND_UP(host->bus_hz, 2000000)); > } > > static void atmci_set_timeout(struct atmel_mci *host, -- Nicolas Ferre ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/3] mmc: atmel-mci: correct data timeout computation 2012-03-28 11:44 ` Nicolas Ferre @ 2012-04-01 3:43 ` Chris Ball 0 siblings, 0 replies; 14+ messages in thread From: Chris Ball @ 2012-04-01 3:43 UTC (permalink / raw) To: Nicolas Ferre; +Cc: ludovic.desroches, linux-mmc, linux-arm-kernel Hi, On Wed, Mar 28 2012, Nicolas Ferre wrote: > On 03/28/2012 12:28 PM, ludovic.desroches@atmel.com : >> From: Ludovic Desroches <ludovic.desroches@atmel.com> >> >> The HSMCI operates at a rate of up to Master Clock divided by two. >> Moreover previous calculation can cause overflows and so wrong >> timeouts. >> >> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> > > Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Thanks, pushed to mmc-next for 3.4. - Chris. -- Chris Ball <cjb@laptop.org> <http://printf.net/> One Laptop Per Child ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/3] mmc: atmel-mci: r/w proof capability only available since v2xx 2012-03-21 15:41 [PATCH 0/3] atmel-mci fixes ludovic.desroches 2012-03-21 15:41 ` [PATCH 1/3] mmc: atmel-mci: correct data timeout computation ludovic.desroches @ 2012-03-21 15:41 ` ludovic.desroches 2012-03-22 14:44 ` Nicolas Ferre 2012-03-21 15:41 ` [PATCH 3/3] mmc: atmel-mci: add support for odd clock dividers ludovic.desroches 2 siblings, 1 reply; 14+ messages in thread From: ludovic.desroches @ 2012-03-21 15:41 UTC (permalink / raw) To: linux-mmc, linux-arm-kernel; +Cc: nicolas.ferre, ludovic.desroches, plagnioj From: Ludovic Desroches <ludovic.desroches@atmel.com> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> --- drivers/mmc/host/atmel-mci.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index e161452..9dcb236 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -2009,6 +2009,8 @@ static void __init atmci_get_cap(struct atmel_mci *host) /* keep only major version number */ switch (version & 0xf00) { case 0x100: + host->caps.has_pdc = 1; + break; case 0x200: host->caps.has_pdc = 1; host->caps.has_rwproof = 1; -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] mmc: atmel-mci: r/w proof capability only available since v2xx 2012-03-21 15:41 ` [PATCH 2/3] mmc: atmel-mci: r/w proof capability only available since v2xx ludovic.desroches @ 2012-03-22 14:44 ` Nicolas Ferre 2012-04-01 3:43 ` Chris Ball 0 siblings, 1 reply; 14+ messages in thread From: Nicolas Ferre @ 2012-03-22 14:44 UTC (permalink / raw) To: ludovic.desroches; +Cc: linux-mmc, linux-arm-kernel, plagnioj On 03/21/2012 04:41 PM, ludovic.desroches@atmel.com : > From: Ludovic Desroches <ludovic.desroches@atmel.com> > > Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> > --- > drivers/mmc/host/atmel-mci.c | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c > index e161452..9dcb236 100644 > --- a/drivers/mmc/host/atmel-mci.c > +++ b/drivers/mmc/host/atmel-mci.c > @@ -2009,6 +2009,8 @@ static void __init atmci_get_cap(struct atmel_mci *host) > /* keep only major version number */ > switch (version & 0xf00) { > case 0x100: > + host->caps.has_pdc = 1; > + break; > case 0x200: > host->caps.has_pdc = 1; > host->caps.has_rwproof = 1; -- Nicolas Ferre ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] mmc: atmel-mci: r/w proof capability only available since v2xx 2012-03-22 14:44 ` Nicolas Ferre @ 2012-04-01 3:43 ` Chris Ball 0 siblings, 0 replies; 14+ messages in thread From: Chris Ball @ 2012-04-01 3:43 UTC (permalink / raw) To: Nicolas Ferre; +Cc: ludovic.desroches, linux-mmc, linux-arm-kernel, plagnioj Hi, On Thu, Mar 22 2012, Nicolas Ferre wrote: > On 03/21/2012 04:41 PM, ludovic.desroches@atmel.com : >> From: Ludovic Desroches <ludovic.desroches@atmel.com> >> >> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> > > Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Thanks, pushed to mmc-next for 3.4. - Chris. -- Chris Ball <cjb@laptop.org> <http://printf.net/> One Laptop Per Child ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 3/3] mmc: atmel-mci: add support for odd clock dividers 2012-03-21 15:41 [PATCH 0/3] atmel-mci fixes ludovic.desroches 2012-03-21 15:41 ` [PATCH 1/3] mmc: atmel-mci: correct data timeout computation ludovic.desroches 2012-03-21 15:41 ` [PATCH 2/3] mmc: atmel-mci: r/w proof capability only available since v2xx ludovic.desroches @ 2012-03-21 15:41 ` ludovic.desroches 2012-03-22 14:48 ` Nicolas Ferre 2 siblings, 1 reply; 14+ messages in thread From: ludovic.desroches @ 2012-03-21 15:41 UTC (permalink / raw) To: linux-mmc, linux-arm-kernel; +Cc: nicolas.ferre, ludovic.desroches, plagnioj From: Ludovic Desroches <ludovic.desroches@atmel.com> Add an odd clock divider capability available from v5xx. It also involves changing the clock divider calculation. Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> --- drivers/mmc/host/atmel-mci-regs.h | 1 + drivers/mmc/host/atmel-mci.c | 48 ++++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/drivers/mmc/host/atmel-mci-regs.h b/drivers/mmc/host/atmel-mci-regs.h index 000b3ad..787aba1 100644 --- a/drivers/mmc/host/atmel-mci-regs.h +++ b/drivers/mmc/host/atmel-mci-regs.h @@ -31,6 +31,7 @@ # define ATMCI_MR_PDCFBYTE ( 1 << 13) /* Force Byte Transfer */ # define ATMCI_MR_PDCPADV ( 1 << 14) /* Padding Value */ # define ATMCI_MR_PDCMODE ( 1 << 15) /* PDC-oriented Mode */ +# define ATMCI_MR_CLKODD(x) ((x) << 16) /* LSB of Clock Divider */ #define ATMCI_DTOR 0x0008 /* Data Timeout */ # define ATMCI_DTOCYC(x) ((x) << 0) /* Data Timeout Cycles */ # define ATMCI_DTOMUL(x) ((x) << 4) /* Data Timeout Multiplier */ diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index 9dcb236..75e28c0 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -76,6 +76,7 @@ struct atmel_mci_caps { bool has_cstor_reg; bool has_highspeed; bool has_rwproof; + bool has_odd_clk_div; }; struct atmel_mci_dma { @@ -1124,16 +1125,27 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) } /* Calculate clock divider */ - clkdiv = DIV_ROUND_UP(host->bus_hz, 2 * clock_min) - 1; - if (clkdiv > 255) { - dev_warn(&mmc->class_dev, - "clock %u too slow; using %lu\n", - clock_min, host->bus_hz / (2 * 256)); - clkdiv = 255; + if (host->caps.has_odd_clk_div) { + clkdiv = DIV_ROUND_UP(host->bus_hz, clock_min) - 2; + if (clkdiv > 511) { + dev_warn(&mmc->class_dev, + "clock %u too slow; using %lu\n", + clock_min, host->bus_hz / (511 + 2)); + clkdiv = 511; + } + host->mode_reg = ATMCI_MR_CLKDIV(clkdiv >> 1) + | ATMCI_MR_CLKODD(clkdiv & 1); + } else { + clkdiv = DIV_ROUND_UP(host->bus_hz, 2 * clock_min) - 1; + if (clkdiv > 255) { + dev_warn(&mmc->class_dev, + "clock %u too slow; using %lu\n", + clock_min, host->bus_hz / (2 * 256)); + clkdiv = 255; + } + host->mode_reg = ATMCI_MR_CLKDIV(clkdiv); } - host->mode_reg = ATMCI_MR_CLKDIV(clkdiv); - /* * WRPROOF and RDPROOF prevent overruns/underruns by * stopping the clock when the FIFO is full/empty. @@ -2000,37 +2012,35 @@ static void __init atmci_get_cap(struct atmel_mci *host) "version: 0x%x\n", version); host->caps.has_dma = 0; - host->caps.has_pdc = 0; + host->caps.has_pdc = 1; host->caps.has_cfg_reg = 0; host->caps.has_cstor_reg = 0; host->caps.has_highspeed = 0; host->caps.has_rwproof = 0; + host->caps.has_odd_clk_div = 0; /* keep only major version number */ switch (version & 0xf00) { - case 0x100: - host->caps.has_pdc = 1; - break; - case 0x200: - host->caps.has_pdc = 1; - host->caps.has_rwproof = 1; - break; - case 0x300: - case 0x400: case 0x500: + host->caps.has_odd_clk_div = 1; + case 0x400: + case 0x300: #ifdef CONFIG_AT_HDMAC host->caps.has_dma = 1; #else - host->caps.has_dma = 0; dev_info(&host->pdev->dev, "has dma capability but dma engine is not selected, then use pio\n"); #endif + host->caps.has_pdc = 0; host->caps.has_cfg_reg = 1; host->caps.has_cstor_reg = 1; host->caps.has_highspeed = 1; + case 0x200: host->caps.has_rwproof = 1; + case 0x100: break; default: + host->caps.has_pdc = 0; dev_warn(&host->pdev->dev, "Unmanaged mci version, set minimum capabilities\n"); break; -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 3/3] mmc: atmel-mci: add support for odd clock dividers 2012-03-21 15:41 ` [PATCH 3/3] mmc: atmel-mci: add support for odd clock dividers ludovic.desroches @ 2012-03-22 14:48 ` Nicolas Ferre 2012-04-01 3:44 ` Chris Ball 0 siblings, 1 reply; 14+ messages in thread From: Nicolas Ferre @ 2012-03-22 14:48 UTC (permalink / raw) To: ludovic.desroches; +Cc: linux-mmc, linux-arm-kernel, plagnioj On 03/21/2012 04:41 PM, ludovic.desroches@atmel.com : > From: Ludovic Desroches <ludovic.desroches@atmel.com> > > Add an odd clock divider capability available from v5xx. It also involves > changing the clock divider calculation. Also tell here that you have changed the way that the switch/case directive has been implemented. > Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Otherwise: Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> > --- > drivers/mmc/host/atmel-mci-regs.h | 1 + > drivers/mmc/host/atmel-mci.c | 48 ++++++++++++++++++++++-------------- > 2 files changed, 30 insertions(+), 19 deletions(-) > > diff --git a/drivers/mmc/host/atmel-mci-regs.h b/drivers/mmc/host/atmel-mci-regs.h > index 000b3ad..787aba1 100644 > --- a/drivers/mmc/host/atmel-mci-regs.h > +++ b/drivers/mmc/host/atmel-mci-regs.h > @@ -31,6 +31,7 @@ > # define ATMCI_MR_PDCFBYTE ( 1 << 13) /* Force Byte Transfer */ > # define ATMCI_MR_PDCPADV ( 1 << 14) /* Padding Value */ > # define ATMCI_MR_PDCMODE ( 1 << 15) /* PDC-oriented Mode */ > +# define ATMCI_MR_CLKODD(x) ((x) << 16) /* LSB of Clock Divider */ > #define ATMCI_DTOR 0x0008 /* Data Timeout */ > # define ATMCI_DTOCYC(x) ((x) << 0) /* Data Timeout Cycles */ > # define ATMCI_DTOMUL(x) ((x) << 4) /* Data Timeout Multiplier */ > diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c > index 9dcb236..75e28c0 100644 > --- a/drivers/mmc/host/atmel-mci.c > +++ b/drivers/mmc/host/atmel-mci.c > @@ -76,6 +76,7 @@ struct atmel_mci_caps { > bool has_cstor_reg; > bool has_highspeed; > bool has_rwproof; > + bool has_odd_clk_div; > }; > > struct atmel_mci_dma { > @@ -1124,16 +1125,27 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > } > > /* Calculate clock divider */ > - clkdiv = DIV_ROUND_UP(host->bus_hz, 2 * clock_min) - 1; > - if (clkdiv > 255) { > - dev_warn(&mmc->class_dev, > - "clock %u too slow; using %lu\n", > - clock_min, host->bus_hz / (2 * 256)); > - clkdiv = 255; > + if (host->caps.has_odd_clk_div) { > + clkdiv = DIV_ROUND_UP(host->bus_hz, clock_min) - 2; > + if (clkdiv > 511) { > + dev_warn(&mmc->class_dev, > + "clock %u too slow; using %lu\n", > + clock_min, host->bus_hz / (511 + 2)); > + clkdiv = 511; > + } > + host->mode_reg = ATMCI_MR_CLKDIV(clkdiv >> 1) > + | ATMCI_MR_CLKODD(clkdiv & 1); > + } else { > + clkdiv = DIV_ROUND_UP(host->bus_hz, 2 * clock_min) - 1; > + if (clkdiv > 255) { > + dev_warn(&mmc->class_dev, > + "clock %u too slow; using %lu\n", > + clock_min, host->bus_hz / (2 * 256)); > + clkdiv = 255; > + } > + host->mode_reg = ATMCI_MR_CLKDIV(clkdiv); > } > > - host->mode_reg = ATMCI_MR_CLKDIV(clkdiv); > - > /* > * WRPROOF and RDPROOF prevent overruns/underruns by > * stopping the clock when the FIFO is full/empty. > @@ -2000,37 +2012,35 @@ static void __init atmci_get_cap(struct atmel_mci *host) > "version: 0x%x\n", version); > > host->caps.has_dma = 0; > - host->caps.has_pdc = 0; > + host->caps.has_pdc = 1; > host->caps.has_cfg_reg = 0; > host->caps.has_cstor_reg = 0; > host->caps.has_highspeed = 0; > host->caps.has_rwproof = 0; > + host->caps.has_odd_clk_div = 0; > > /* keep only major version number */ > switch (version & 0xf00) { > - case 0x100: > - host->caps.has_pdc = 1; > - break; > - case 0x200: > - host->caps.has_pdc = 1; > - host->caps.has_rwproof = 1; > - break; > - case 0x300: > - case 0x400: > case 0x500: > + host->caps.has_odd_clk_div = 1; > + case 0x400: > + case 0x300: > #ifdef CONFIG_AT_HDMAC > host->caps.has_dma = 1; > #else > - host->caps.has_dma = 0; > dev_info(&host->pdev->dev, > "has dma capability but dma engine is not selected, then use pio\n"); > #endif > + host->caps.has_pdc = 0; > host->caps.has_cfg_reg = 1; > host->caps.has_cstor_reg = 1; > host->caps.has_highspeed = 1; > + case 0x200: > host->caps.has_rwproof = 1; > + case 0x100: > break; > default: > + host->caps.has_pdc = 0; > dev_warn(&host->pdev->dev, > "Unmanaged mci version, set minimum capabilities\n"); > break; -- Nicolas Ferre ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/3] mmc: atmel-mci: add support for odd clock dividers 2012-03-22 14:48 ` Nicolas Ferre @ 2012-04-01 3:44 ` Chris Ball 2012-04-02 6:52 ` Ludovic Desroches 0 siblings, 1 reply; 14+ messages in thread From: Chris Ball @ 2012-04-01 3:44 UTC (permalink / raw) To: Nicolas Ferre; +Cc: ludovic.desroches, linux-mmc, linux-arm-kernel, plagnioj Hi, On Thu, Mar 22 2012, Nicolas Ferre wrote: > On 03/21/2012 04:41 PM, ludovic.desroches@atmel.com : >> From: Ludovic Desroches <ludovic.desroches@atmel.com> >> >> Add an odd clock divider capability available from v5xx. It also involves >> changing the clock divider calculation. > > Also tell here that you have changed the way that the switch/case > directive has been implemented. > >> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> > > Otherwise: > Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Thanks, pushed to mmc-next for 3.4 with a rewording: Add an odd clock divider capability available from v5xx. It also involves changing the clock divider calculation, and changing the switch-case statement to use top-down fallthrough. - Chris. -- Chris Ball <cjb@laptop.org> <http://printf.net/> One Laptop Per Child ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/3] mmc: atmel-mci: add support for odd clock dividers 2012-04-01 3:44 ` Chris Ball @ 2012-04-02 6:52 ` Ludovic Desroches 0 siblings, 0 replies; 14+ messages in thread From: Ludovic Desroches @ 2012-04-02 6:52 UTC (permalink / raw) To: Chris Ball Cc: Nicolas Ferre, ludovic.desroches, linux-mmc, linux-arm-kernel, plagnioj Hi Chris, On Sat, Mar 31, 2012 at 11:44:41PM -0400, Chris Ball wrote: > Hi, > > On Thu, Mar 22 2012, Nicolas Ferre wrote: > > On 03/21/2012 04:41 PM, ludovic.desroches@atmel.com : > >> From: Ludovic Desroches <ludovic.desroches@atmel.com> > >> > >> Add an odd clock divider capability available from v5xx. It also involves > >> changing the clock divider calculation. > > > > Also tell here that you have changed the way that the switch/case > > directive has been implemented. > > > >> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> > > > > Otherwise: > > Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> > > Thanks, pushed to mmc-next for 3.4 with a rewording: > > Add an odd clock divider capability available from v5xx. It also involves > changing the clock divider calculation, and changing the switch-case > statement to use top-down fallthrough. > > - Chris. > -- > Chris Ball <cjb@laptop.org> <http://printf.net/> > One Laptop Per Child Thanks for rewording the commit message. Regards Ludovic ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2012-04-02 6:53 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-03-21 15:41 [PATCH 0/3] atmel-mci fixes ludovic.desroches 2012-03-21 15:41 ` [PATCH 1/3] mmc: atmel-mci: correct data timeout computation ludovic.desroches 2012-03-21 16:26 ` Sergei Shtylyov 2012-03-22 8:57 ` Ludovic Desroches 2012-03-28 10:28 ` [PATCH v2 " ludovic.desroches 2012-03-28 11:44 ` Nicolas Ferre 2012-04-01 3:43 ` Chris Ball 2012-03-21 15:41 ` [PATCH 2/3] mmc: atmel-mci: r/w proof capability only available since v2xx ludovic.desroches 2012-03-22 14:44 ` Nicolas Ferre 2012-04-01 3:43 ` Chris Ball 2012-03-21 15:41 ` [PATCH 3/3] mmc: atmel-mci: add support for odd clock dividers ludovic.desroches 2012-03-22 14:48 ` Nicolas Ferre 2012-04-01 3:44 ` Chris Ball 2012-04-02 6:52 ` Ludovic Desroches
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox