]> err.no Git - linux-2.6/commitdiff
at91_mci: AT91SAM9260/9263 12 byte write erratum (v2)
authorVille Syrjala <syrjala@sci.fi>
Sat, 14 Jun 2008 17:27:20 +0000 (20:27 +0300)
committerPierre Ossman <drzeus@drzeus.cx>
Tue, 15 Jul 2008 12:14:42 +0000 (14:14 +0200)
AT91SAM926[0/3] PDC must write at least 12 bytes. The code compiles and runs
but the actual condition for this erratum did not trigger in my tests so it's
unclear if it actually works as intended.

Signed-off-by: Ville Syrjala <syrjala@sci.fi>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
drivers/mmc/host/at91_mci.c

index e4d018b2fe9fae488aa9dc0a6bcb72e61ff14c85..d3e96ff4142877238311761d8489a2f71ad3998f 100644 (file)
@@ -198,9 +198,14 @@ static inline void at91_mci_sg_to_dma(struct at91mci_host *host, struct mmc_data
        unsigned int len, i, size;
        unsigned *dmabuf = host->buffer;
 
-       size = host->total_length;
+       size = data->blksz * data->blocks;
        len = data->sg_len;
 
+       /* AT91SAM926[0/3] Data Write Operation and number of bytes erratum */
+       if (cpu_is_at91sam9260() || cpu_is_at91sam9263())
+               if (host->total_length == 12)
+                       memset(dmabuf, 0, 12);
+
        /*
         * Just loop through all entries. Size might not
         * be the entire list though so make sure that
@@ -222,9 +227,10 @@ static inline void at91_mci_sg_to_dma(struct at91mci_host *host, struct mmc_data
 
                        for (index = 0; index < (amount / 4); index++)
                                *dmabuf++ = swab32(sgbuffer[index]);
-               }
-               else
+               } else {
                        memcpy(dmabuf, sgbuffer, amount);
+                       dmabuf += amount;
+               }
 
                kunmap_atomic(sgbuffer, KM_BIO_SRC_IRQ);
 
@@ -417,7 +423,7 @@ static void at91_mci_update_bytes_xfered(struct at91mci_host *host)
                        /* card is in IDLE mode now */
                        pr_debug("-> bytes_xfered %d, total_length = %d\n",
                                data->bytes_xfered, host->total_length);
-                       data->bytes_xfered = host->total_length;
+                       data->bytes_xfered = data->blksz * data->blocks;
                }
        }
 }
@@ -600,6 +606,13 @@ static void at91_mci_send_command(struct at91mci_host *host, struct mmc_command
                                 * Handle a write
                                 */
                                host->total_length = block_length * blocks;
+                               /*
+                                * AT91SAM926[0/3] Data Write Operation and
+                                * number of bytes erratum
+                                */
+                               if (cpu_is_at91sam9260 () || cpu_is_at91sam9263())
+                                       if (host->total_length < 12)
+                                               host->total_length = 12;
                                host->buffer = dma_alloc_coherent(NULL,
                                                host->total_length,
                                                &host->physical_address, GFP_KERNEL);