tifm_sd: fix hardware timeout setup
authorAlex Dubov <oakad@yahoo.com>
Fri, 8 Dec 2006 05:50:50 +0000 (16:50 +1100)
committerPierre Ossman <drzeus@drzeus.cx>
Sun, 4 Feb 2007 19:54:07 +0000 (20:54 +0100)
The register access order when setting hardware timeout was incorrect and
causing problems (wrong timeout intervals). This is now fixed.

Signed-off-by: Alex Dubov <oakad@yahoo.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
drivers/mmc/tifm_sd.c

index 69b78eb16eff583d0e486d84e834fc0d46a59295..5817a138a1e43caf5ed19275292e3d87e2c217e8 100644 (file)
@@ -442,22 +442,21 @@ static void tifm_sd_set_data_timeout(struct tifm_sd *host,
                return;
 
        data_timeout += data->timeout_ns /
-                       ((1000000000 / host->clk_freq) * host->clk_div);
-       data_timeout *= 10; // call it fudge factor for now
+                       ((1000000000UL / host->clk_freq) * host->clk_div);
 
        if (data_timeout < 0xffff) {
-               writel((~TIFM_MMCSD_DPE) &
-                               readl(sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG),
-                      sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG);
                writel(data_timeout, sock->addr + SOCK_MMCSD_DATA_TO);
+               writel((~TIFM_MMCSD_DPE)
+                      & readl(sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG),
+                      sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG);
        } else {
-               writel(TIFM_MMCSD_DPE |
-                               readl(sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG),
-                       sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG);
                data_timeout = (data_timeout >> 10) + 1;
                if(data_timeout > 0xffff)
                        data_timeout = 0;       /* set to unlimited */
                writel(data_timeout, sock->addr + SOCK_MMCSD_DATA_TO);
+               writel(TIFM_MMCSD_DPE
+                      | readl(sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG),
+                      sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG);
        }
 }