* Copyright (C) 2009-2010, Intel Corporation and its suppliers.
*/
-#include <cpu_func.h>
+#include <asm/dma-mapping.h>
#include <dm.h>
#include <nand.h>
#include <linux/bitfield.h>
#include "denali.h"
-static dma_addr_t dma_map_single(void *dev, void *ptr, size_t size,
- enum dma_data_direction dir)
-{
- unsigned long addr = (unsigned long)ptr;
-
- size = ALIGN(size, ARCH_DMA_MINALIGN);
-
- if (dir == DMA_FROM_DEVICE)
- invalidate_dcache_range(addr, addr + size);
- else
- flush_dcache_range(addr, addr + size);
-
- return addr;
-}
-
-static void dma_unmap_single(void *dev, dma_addr_t addr, size_t size,
- enum dma_data_direction dir)
-{
- size = ALIGN(size, ARCH_DMA_MINALIGN);
-
- if (dir != DMA_TO_DEVICE)
- invalidate_dcache_range(addr, addr + size);
-}
-
-static int dma_mapping_error(void *dev, dma_addr_t addr)
-{
- return 0;
-}
-
#define DENALI_NAND_NAME "denali-nand"
/* for Indexed Addressing */
enum dma_data_direction dir = write ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
int ret = 0;
- dma_addr = dma_map_single(denali->dev, buf, size, dir);
+ dma_addr = dma_map_single(buf, size, dir);
if (dma_mapping_error(denali->dev, dma_addr)) {
dev_dbg(denali->dev, "Failed to DMA-map buffer. Trying PIO.\n");
return denali_pio_xfer(denali, buf, size, page, raw, write);
iowrite32(0, denali->reg + DMA_ENABLE);
- dma_unmap_single(denali->dev, dma_addr, size, dir);
+ dma_unmap_single(buf, size, dir);
if (irq_status & INTR__ERASED_PAGE)
memset(buf, 0xff, size);
denali->revision = swab16(ioread32(denali->reg + REVISION));
/*
- * tell driver how many bit controller will skip before writing
- * ECC code in OOB. This is normally used for bad block marker
+ * Set how many bytes should be skipped before writing data in OOB.
+ * If a platform requests a non-zero value, set it to the register.
+ * Otherwise, read the value out, expecting it has already been set up
+ * by firmware.
*/
- denali->oob_skip_bytes = CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES;
- iowrite32(denali->oob_skip_bytes, denali->reg + SPARE_AREA_SKIP_BYTES);
+ if (denali->oob_skip_bytes)
+ iowrite32(denali->oob_skip_bytes,
+ denali->reg + SPARE_AREA_SKIP_BYTES);
+ else
+ denali->oob_skip_bytes = ioread32(denali->reg +
+ SPARE_AREA_SKIP_BYTES);
+
denali_detect_max_banks(denali);
iowrite32(0x0F, denali->reg + RB_PIN_ENABLED);
iowrite32(CHIP_EN_DONT_CARE__FLAG, denali->reg + CHIP_ENABLE_DONT_CARE);