]> git.sur5r.net Git - u-boot/blobdiff - drivers/mtd/nand/omap_gpmc.c
Merge branch 'agust@denx.de' of git://git.denx.de/u-boot-staging
[u-boot] / drivers / mtd / nand / omap_gpmc.c
index de90d55a9fe82d1efd204804bc0c1f912a0fb719..4814fa202a65b0274a4f4f8f82409edb4a004cd3 100644 (file)
@@ -415,7 +415,17 @@ static int __read_prefetch_aligned(struct nand_chip *chip, uint32_t *buf, int le
        return 0;
 }
 
-static void omap_nand_read_prefetch8(struct mtd_info *mtd, uint8_t *buf, int len)
+static inline void omap_nand_read(struct mtd_info *mtd, uint8_t *buf, int len)
+{
+       struct nand_chip *chip = mtd->priv;
+
+       if (chip->options & NAND_BUSWIDTH_16)
+               nand_read_buf16(mtd, buf, len);
+       else
+               nand_read_buf(mtd, buf, len);
+}
+
+static void omap_nand_read_prefetch(struct mtd_info *mtd, uint8_t *buf, int len)
 {
        int ret;
        uint32_t head, tail;
@@ -427,7 +437,7 @@ static void omap_nand_read_prefetch8(struct mtd_info *mtd, uint8_t *buf, int len
         */
        head = ((uint32_t) buf) % 4;
        if (head) {
-               nand_read_buf(mtd, buf, head);
+               omap_nand_read(mtd, buf, head);
                buf += head;
                len -= head;
        }
@@ -438,13 +448,13 @@ static void omap_nand_read_prefetch8(struct mtd_info *mtd, uint8_t *buf, int len
         */
        tail = len % 4;
 
-       ret = __read_prefetch_aligned(chip, (uint32_t *) buf, len - tail);
+       ret = __read_prefetch_aligned(chip, (uint32_t *)buf, len - tail);
        if (ret < 0) {
                /* fallback in case the prefetch engine is busy */
-               nand_read_buf(mtd, buf, len);
+               omap_nand_read(mtd, buf, len);
        } else if (tail) {
                buf += len - tail;
-               nand_read_buf(mtd, buf, tail);
+               omap_nand_read(mtd, buf, tail);
        }
 }
 #endif /* CONFIG_NAND_OMAP_GPMC_PREFETCH */
@@ -548,10 +558,10 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat,
                bit_pos  = error_loc[count] % 8;
                if (byte_pos < SECTOR_BYTES) {
                        dat[byte_pos] ^= 1 << bit_pos;
-                       printf("nand: bit-flip corrected @data=%d\n", byte_pos);
+                       debug("nand: bit-flip corrected @data=%d\n", byte_pos);
                } else if (byte_pos < error_max) {
                        read_ecc[byte_pos - SECTOR_BYTES] ^= 1 << bit_pos;
-                       printf("nand: bit-flip corrected @oob=%d\n", byte_pos -
+                       debug("nand: bit-flip corrected @oob=%d\n", byte_pos -
                                                                SECTOR_BYTES);
                } else {
                        err = -EBADMSG;
@@ -653,7 +663,7 @@ static int omap_correct_data_bch_sw(struct mtd_info *mtd, u_char *data,
                        /* correct data only, not ecc bytes */
                        if (errloc[i] < 8*512)
                                data[errloc[i]/8] ^= 1 << (errloc[i] & 7);
-                       printf("corrected bitflip %u\n", errloc[i]);
+                       debug("corrected bitflip %u\n", errloc[i]);
 #ifdef DEBUG
                        puts("read_ecc: ");
                        /*
@@ -1011,13 +1021,11 @@ int board_nand_init(struct nand_chip *nand)
        if (err)
                return err;
 
-       /* TODO: Implement for 16-bit bus width */
-       if (nand->options & NAND_BUSWIDTH_16)
-               nand->read_buf = nand_read_buf16;
 #ifdef CONFIG_NAND_OMAP_GPMC_PREFETCH
-       else
-               nand->read_buf = omap_nand_read_prefetch8;
+       nand->read_buf = omap_nand_read_prefetch;
 #else
+       if (nand->options & NAND_BUSWIDTH_16)
+               nand->read_buf = nand_read_buf16;
        else
                nand->read_buf = nand_read_buf;
 #endif