mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
6710247706
commit
068b44b714
|
@ -92,7 +92,7 @@ static struct nand_ecclayout atmel_oobinfo_small = {
|
||||||
struct atmel_nfc {
|
struct atmel_nfc {
|
||||||
void __iomem *base_cmd_regs;
|
void __iomem *base_cmd_regs;
|
||||||
void __iomem *hsmc_regs;
|
void __iomem *hsmc_regs;
|
||||||
void __iomem *sram_bank0;
|
void *sram_bank0;
|
||||||
dma_addr_t sram_bank0_phys;
|
dma_addr_t sram_bank0_phys;
|
||||||
bool use_nfc_sram;
|
bool use_nfc_sram;
|
||||||
bool write_by_sram;
|
bool write_by_sram;
|
||||||
|
@ -105,7 +105,7 @@ struct atmel_nfc {
|
||||||
struct completion comp_xfer_done;
|
struct completion comp_xfer_done;
|
||||||
|
|
||||||
/* Point to the sram bank which include readed data via NFC */
|
/* Point to the sram bank which include readed data via NFC */
|
||||||
void __iomem *data_in_sram;
|
void *data_in_sram;
|
||||||
bool will_write_sram;
|
bool will_write_sram;
|
||||||
};
|
};
|
||||||
static struct atmel_nfc nand_nfc;
|
static struct atmel_nfc nand_nfc;
|
||||||
|
@ -257,26 +257,6 @@ static int atmel_nand_set_enable_ready_pins(struct mtd_info *mtd)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void memcpy32_fromio(void *trg, const void __iomem *src, size_t size)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
u32 *t = trg;
|
|
||||||
const __iomem u32 *s = src;
|
|
||||||
|
|
||||||
for (i = 0; i < (size >> 2); i++)
|
|
||||||
*t++ = readl_relaxed(s++);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void memcpy32_toio(void __iomem *trg, const void *src, int size)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
u32 __iomem *t = trg;
|
|
||||||
const u32 *s = src;
|
|
||||||
|
|
||||||
for (i = 0; i < (size >> 2); i++)
|
|
||||||
writel_relaxed(*s++, t++);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Minimal-overhead PIO for data access.
|
* Minimal-overhead PIO for data access.
|
||||||
*/
|
*/
|
||||||
|
@ -286,7 +266,7 @@ static void atmel_read_buf8(struct mtd_info *mtd, u8 *buf, int len)
|
||||||
struct atmel_nand_host *host = nand_chip->priv;
|
struct atmel_nand_host *host = nand_chip->priv;
|
||||||
|
|
||||||
if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) {
|
if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) {
|
||||||
memcpy32_fromio(buf, host->nfc->data_in_sram, len);
|
memcpy(buf, host->nfc->data_in_sram, len);
|
||||||
host->nfc->data_in_sram += len;
|
host->nfc->data_in_sram += len;
|
||||||
} else {
|
} else {
|
||||||
__raw_readsb(nand_chip->IO_ADDR_R, buf, len);
|
__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)
|
||||||
struct atmel_nand_host *host = nand_chip->priv;
|
struct atmel_nand_host *host = nand_chip->priv;
|
||||||
|
|
||||||
if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) {
|
if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) {
|
||||||
memcpy32_fromio(buf, host->nfc->data_in_sram, len);
|
memcpy(buf, host->nfc->data_in_sram, len);
|
||||||
host->nfc->data_in_sram += len;
|
host->nfc->data_in_sram += len;
|
||||||
} else {
|
} else {
|
||||||
__raw_readsw(nand_chip->IO_ADDR_R, buf, len / 2);
|
__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,
|
||||||
int cfg, len;
|
int cfg, len;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
struct atmel_nand_host *host = chip->priv;
|
struct atmel_nand_host *host = chip->priv;
|
||||||
void __iomem *sram = host->nfc->sram_bank0 + nfc_get_sram_off(host);
|
void *sram = host->nfc->sram_bank0 + nfc_get_sram_off(host);
|
||||||
|
|
||||||
/* Subpage write is not supported */
|
/* Subpage write is not supported */
|
||||||
if (offset || (data_len < mtd->writesize))
|
if (offset || (data_len < mtd->writesize))
|
||||||
|
@ -1983,14 +1963,14 @@ static int nfc_sram_write_page(struct mtd_info *mtd, struct nand_chip *chip,
|
||||||
if (use_dma) {
|
if (use_dma) {
|
||||||
if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) != 0)
|
if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) != 0)
|
||||||
/* Fall back to use cpu copy */
|
/* Fall back to use cpu copy */
|
||||||
memcpy32_toio(sram, buf, len);
|
memcpy(sram, buf, len);
|
||||||
} else {
|
} else {
|
||||||
memcpy32_toio(sram, buf, len);
|
memcpy(sram, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg = nfc_readl(host->nfc->hsmc_regs, CFG);
|
cfg = nfc_readl(host->nfc->hsmc_regs, CFG);
|
||||||
if (unlikely(raw) && oob_required) {
|
if (unlikely(raw) && oob_required) {
|
||||||
memcpy32_toio(sram + len, chip->oob_poi, mtd->oobsize);
|
memcpy(sram + len, chip->oob_poi, mtd->oobsize);
|
||||||
len += mtd->oobsize;
|
len += mtd->oobsize;
|
||||||
nfc_writel(host->nfc->hsmc_regs, CFG, cfg | NFC_CFG_WSPARE);
|
nfc_writel(host->nfc->hsmc_regs, CFG, cfg | NFC_CFG_WSPARE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2333,7 +2313,8 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
nfc_sram = platform_get_resource(pdev, IORESOURCE_MEM, 2);
|
nfc_sram = platform_get_resource(pdev, IORESOURCE_MEM, 2);
|
||||||
if (nfc_sram) {
|
if (nfc_sram) {
|
||||||
nfc->sram_bank0 = devm_ioremap_resource(&pdev->dev, nfc_sram);
|
nfc->sram_bank0 = (void * __force)
|
||||||
|
devm_ioremap_resource(&pdev->dev, nfc_sram);
|
||||||
if (IS_ERR(nfc->sram_bank0)) {
|
if (IS_ERR(nfc->sram_bank0)) {
|
||||||
dev_warn(&pdev->dev, "Fail to ioremap the NFC sram with error: %ld. So disable NFC sram.\n",
|
dev_warn(&pdev->dev, "Fail to ioremap the NFC sram with error: %ld. So disable NFC sram.\n",
|
||||||
PTR_ERR(nfc->sram_bank0));
|
PTR_ERR(nfc->sram_bank0));
|
||||||
|
|
Loading…
Reference in New Issue