diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2017-03-30 15:45:54 +0900 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@free-electrons.com> | 2017-04-25 14:18:35 +0200 |
commit | 210a2c876fe02c9440569c9282af43e7a85562e3 (patch) | |
tree | 9bf52dabe1c46e11efc47a1962e82793122deb60 /drivers/mtd | |
parent | a56609c4c3f34de76d905e39160511b3c53310ac (diff) | |
download | linux-210a2c876fe02c9440569c9282af43e7a85562e3.tar.gz linux-210a2c876fe02c9440569c9282af43e7a85562e3.tar.bz2 linux-210a2c876fe02c9440569c9282af43e7a85562e3.zip |
mtd: nand: denali: support 64bit capable DMA engine
The current driver only supports the DMA engine up to 32 bit
physical address, but there also exists 64 bit capable DMA engine
for this IP.
The data DMA setup sequence is completely different, so I added the
64 bit DMA code as a new function denali_setup_dma64(). The 32 bit
one has been renamed to denali_setup_dma32().
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/nand/denali.c | 39 | ||||
-rw-r--r-- | drivers/mtd/nand/denali.h | 1 |
2 files changed, 36 insertions, 4 deletions
diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index b95e33a84201..417a8950cf49 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -979,8 +979,30 @@ static void denali_enable_dma(struct denali_nand_info *denali, bool en) ioread32(denali->flash_reg + DMA_ENABLE); } -/* setups the HW to perform the data DMA */ -static void denali_setup_dma(struct denali_nand_info *denali, int op) +static void denali_setup_dma64(struct denali_nand_info *denali, int op) +{ + uint32_t mode; + const int page_count = 1; + uint64_t addr = denali->buf.dma_buf; + + mode = MODE_10 | BANK(denali->flash_bank) | denali->page; + + /* DMA is a three step process */ + + /* + * 1. setup transfer type, interrupt when complete, + * burst len = 64 bytes, the number of pages + */ + index_addr(denali, mode, 0x01002000 | (64 << 16) | op | page_count); + + /* 2. set memory low address */ + index_addr(denali, mode, addr); + + /* 3. set memory high address */ + index_addr(denali, mode, addr >> 32); +} + +static void denali_setup_dma32(struct denali_nand_info *denali, int op) { uint32_t mode; const int page_count = 1; @@ -1003,6 +1025,14 @@ static void denali_setup_dma(struct denali_nand_info *denali, int op) index_addr(denali, mode | 0x14000, 0x2400); } +static void denali_setup_dma(struct denali_nand_info *denali, int op) +{ + if (denali->caps & DENALI_CAP_DMA_64BIT) + denali_setup_dma64(denali, op); + else + denali_setup_dma32(denali, op); +} + /* * writes a page. user specifies type, and this function handles the * configuration details. @@ -1518,8 +1548,9 @@ int denali_init(struct denali_nand_info *denali) goto failed_req_irq; } - /* Is 32-bit DMA supported? */ - ret = dma_set_mask(denali->dev, DMA_BIT_MASK(32)); + ret = dma_set_mask(denali->dev, + DMA_BIT_MASK(denali->caps & DENALI_CAP_DMA_64BIT ? + 64 : 32)); if (ret) { dev_err(denali->dev, "No usable DMA configuration\n"); goto failed_req_irq; diff --git a/drivers/mtd/nand/denali.h b/drivers/mtd/nand/denali.h index e532956b7177..1f413d05a010 100644 --- a/drivers/mtd/nand/denali.h +++ b/drivers/mtd/nand/denali.h @@ -347,6 +347,7 @@ struct denali_nand_info { }; #define DENALI_CAP_HW_ECC_FIXUP BIT(0) +#define DENALI_CAP_DMA_64BIT BIT(1) extern int denali_init(struct denali_nand_info *denali); extern void denali_remove(struct denali_nand_info *denali); |