[MMC] pxamci: fix data timeout calculation
The MMC layer gives us two parts for the timeout calculation - a fixed timeout in nanoseconds, and a card clock-speed dependent part. The PXA MMC hardware allows for a timeout based on the fixed host clock speed only. This resulted in some cards being given a short timeout, and therefore failing to work. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
parent
6b426e785c
commit
3d63abe56b
1 changed files with 4 additions and 6 deletions
|
@ -65,11 +65,6 @@ struct pxamci_host {
|
||||||
unsigned int dma_dir;
|
unsigned int dma_dir;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline unsigned int ns_to_clocks(unsigned int ns)
|
|
||||||
{
|
|
||||||
return (ns * (CLOCKRATE / 1000000) + 999) / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pxamci_stop_clock(struct pxamci_host *host)
|
static void pxamci_stop_clock(struct pxamci_host *host)
|
||||||
{
|
{
|
||||||
if (readl(host->base + MMC_STAT) & STAT_CLK_EN) {
|
if (readl(host->base + MMC_STAT) & STAT_CLK_EN) {
|
||||||
|
@ -113,6 +108,7 @@ static void pxamci_disable_irq(struct pxamci_host *host, unsigned int mask)
|
||||||
static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data)
|
static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data)
|
||||||
{
|
{
|
||||||
unsigned int nob = data->blocks;
|
unsigned int nob = data->blocks;
|
||||||
|
unsigned long long clks;
|
||||||
unsigned int timeout;
|
unsigned int timeout;
|
||||||
u32 dcmd;
|
u32 dcmd;
|
||||||
int i;
|
int i;
|
||||||
|
@ -125,7 +121,9 @@ static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data)
|
||||||
writel(nob, host->base + MMC_NOB);
|
writel(nob, host->base + MMC_NOB);
|
||||||
writel(1 << data->blksz_bits, host->base + MMC_BLKLEN);
|
writel(1 << data->blksz_bits, host->base + MMC_BLKLEN);
|
||||||
|
|
||||||
timeout = ns_to_clocks(data->timeout_ns) + data->timeout_clks;
|
clks = (unsigned long long)data->timeout_ns * CLOCKRATE;
|
||||||
|
do_div(clks, 1000000000UL);
|
||||||
|
timeout = (unsigned int)clks + (data->timeout_clks << host->clkrt);
|
||||||
writel((timeout + 255) / 256, host->base + MMC_RDTO);
|
writel((timeout + 255) / 256, host->base + MMC_RDTO);
|
||||||
|
|
||||||
if (data->flags & MMC_DATA_READ) {
|
if (data->flags & MMC_DATA_READ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue