aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWu, Josh <Josh.wu@atmel.com>2014-11-07 02:26:09 -0500
committerBrian Norris <computersforpeace@gmail.com>2014-11-26 02:22:28 -0500
commit068b44b714952092e0791b321b05be79de9baa1e (patch)
tree64a708a360bbff738bdb80ab8e8c5629d2cf56ad
parent6710247706bfc4e6ad22a124c097964bb713fb8d (diff)
mtd: atmel_nand: replace memcpy32_toio/memcpy32_fromio with memcpy
There is no need to use memcpy32_toio/memcpy32_fromio to transfer data between memory and NFC sram. As the NFC sram is a also a memory space not an I/O space, we can just use memcpy(). We remove the __iomem prefix for NFC sram to avoid sparse warnings. Signed-off-by: Josh Wu <josh.wu@atmel.com> Reviewed-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--drivers/mtd/nand/atmel_nand.c39
1 files changed, 10 insertions, 29 deletions
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 5c1423a2ffb5..9c28d010dbd9 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -92,7 +92,7 @@ static struct nand_ecclayout atmel_oobinfo_small = {
92struct atmel_nfc { 92struct atmel_nfc {
93 void __iomem *base_cmd_regs; 93 void __iomem *base_cmd_regs;
94 void __iomem *hsmc_regs; 94 void __iomem *hsmc_regs;
95 void __iomem *sram_bank0; 95 void *sram_bank0;
96 dma_addr_t sram_bank0_phys; 96 dma_addr_t sram_bank0_phys;
97 bool use_nfc_sram; 97 bool use_nfc_sram;
98 bool write_by_sram; 98 bool write_by_sram;
@@ -105,7 +105,7 @@ struct atmel_nfc {
105 struct completion comp_xfer_done; 105 struct completion comp_xfer_done;
106 106
107 /* Point to the sram bank which include readed data via NFC */ 107 /* Point to the sram bank which include readed data via NFC */
108 void __iomem *data_in_sram; 108 void *data_in_sram;
109 bool will_write_sram; 109 bool will_write_sram;
110}; 110};
111static struct atmel_nfc nand_nfc; 111static struct atmel_nfc nand_nfc;
@@ -257,26 +257,6 @@ static int atmel_nand_set_enable_ready_pins(struct mtd_info *mtd)
257 return res; 257 return res;
258} 258}
259 259
260static void memcpy32_fromio(void *trg, const void __iomem *src, size_t size)
261{
262 int i;
263 u32 *t = trg;
264 const __iomem u32 *s = src;
265
266 for (i = 0; i < (size >> 2); i++)
267 *t++ = readl_relaxed(s++);
268}
269
270static void memcpy32_toio(void __iomem *trg, const void *src, int size)
271{
272 int i;
273 u32 __iomem *t = trg;
274 const u32 *s = src;
275
276 for (i = 0; i < (size >> 2); i++)
277 writel_relaxed(*s++, t++);
278}
279
280/* 260/*
281 * Minimal-overhead PIO for data access. 261 * Minimal-overhead PIO for data access.
282 */ 262 */
@@ -286,7 +266,7 @@ static void atmel_read_buf8(struct mtd_info *mtd, u8 *buf, int len)
286 struct atmel_nand_host *host = nand_chip->priv; 266 struct atmel_nand_host *host = nand_chip->priv;
287 267
288 if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) { 268 if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) {
289 memcpy32_fromio(buf, host->nfc->data_in_sram, len); 269 memcpy(buf, host->nfc->data_in_sram, len);
290 host->nfc->data_in_sram += len; 270 host->nfc->data_in_sram += len;
291 } else { 271 } else {
292 __raw_readsb(nand_chip->IO_ADDR_R, buf, len); 272 __raw_readsb(nand_chip->IO_ADDR_R, buf, len);
@@ -299,7 +279,7 @@ static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len)
299 struct atmel_nand_host *host = nand_chip->priv; 279 struct atmel_nand_host *host = nand_chip->priv;
300 280
301 if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) { 281 if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) {
302 memcpy32_fromio(buf, host->nfc->data_in_sram, len); 282 memcpy(buf, host->nfc->data_in_sram, len);
303 host->nfc->data_in_sram += len; 283 host->nfc->data_in_sram += len;
304 } else { 284 } else {
305 __raw_readsw(nand_chip->IO_ADDR_R, buf, len / 2); 285 __raw_readsw(nand_chip->IO_ADDR_R, buf, len / 2);
@@ -1972,7 +1952,7 @@ static int nfc_sram_write_page(struct mtd_info *mtd, struct nand_chip *chip,
1972 int cfg, len; 1952 int cfg, len;
1973 int status = 0; 1953 int status = 0;
1974 struct atmel_nand_host *host = chip->priv; 1954 struct atmel_nand_host *host = chip->priv;
1975 void __iomem *sram = host->nfc->sram_bank0 + nfc_get_sram_off(host); 1955 void *sram = host->nfc->sram_bank0 + nfc_get_sram_off(host);
1976 1956
1977 /* Subpage write is not supported */ 1957 /* Subpage write is not supported */
1978 if (offset || (data_len < mtd->writesize)) 1958 if (offset || (data_len < mtd->writesize))
@@ -1983,14 +1963,14 @@ static int nfc_sram_write_page(struct mtd_info *mtd, struct nand_chip *chip,
1983 if (use_dma) { 1963 if (use_dma) {
1984 if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) != 0) 1964 if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) != 0)
1985 /* Fall back to use cpu copy */ 1965 /* Fall back to use cpu copy */
1986 memcpy32_toio(sram, buf, len); 1966 memcpy(sram, buf, len);
1987 } else { 1967 } else {
1988 memcpy32_toio(sram, buf, len); 1968 memcpy(sram, buf, len);
1989 } 1969 }
1990 1970
1991 cfg = nfc_readl(host->nfc->hsmc_regs, CFG); 1971 cfg = nfc_readl(host->nfc->hsmc_regs, CFG);
1992 if (unlikely(raw) && oob_required) { 1972 if (unlikely(raw) && oob_required) {
1993 memcpy32_toio(sram + len, chip->oob_poi, mtd->oobsize); 1973 memcpy(sram + len, chip->oob_poi, mtd->oobsize);
1994 len += mtd->oobsize; 1974 len += mtd->oobsize;
1995 nfc_writel(host->nfc->hsmc_regs, CFG, cfg | NFC_CFG_WSPARE); 1975 nfc_writel(host->nfc->hsmc_regs, CFG, cfg | NFC_CFG_WSPARE);
1996 } else { 1976 } else {
@@ -2333,7 +2313,8 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
2333 2313
2334 nfc_sram = platform_get_resource(pdev, IORESOURCE_MEM, 2); 2314 nfc_sram = platform_get_resource(pdev, IORESOURCE_MEM, 2);
2335 if (nfc_sram) { 2315 if (nfc_sram) {
2336 nfc->sram_bank0 = devm_ioremap_resource(&pdev->dev, nfc_sram); 2316 nfc->sram_bank0 = (void * __force)
2317 devm_ioremap_resource(&pdev->dev, nfc_sram);
2337 if (IS_ERR(nfc->sram_bank0)) { 2318 if (IS_ERR(nfc->sram_bank0)) {
2338 dev_warn(&pdev->dev, "Fail to ioremap the NFC sram with error: %ld. So disable NFC sram.\n", 2319 dev_warn(&pdev->dev, "Fail to ioremap the NFC sram with error: %ld. So disable NFC sram.\n",
2339 PTR_ERR(nfc->sram_bank0)); 2320 PTR_ERR(nfc->sram_bank0));