diff options
author | Wu, Josh <Josh.wu@atmel.com> | 2014-06-10 17:50:09 +0800 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2014-07-21 20:02:01 -0700 |
commit | 50e04e2f0cf25917d8bec05326d0003cc2ab25eb (patch) | |
tree | 20b2d923e6644d37941a59e27e34aa1361aff6ff /drivers/mtd/nand/atmel_nand.c | |
parent | b38576667cdcf7a646843b07666faae11cc63e9c (diff) | |
download | linux-50e04e2f0cf25917d8bec05326d0003cc2ab25eb.tar.bz2 |
mtd: atmel_nand: add NFC status error check
Add a new function to read the NFC status. Meantime, this function will
check if there is any errors in NFC.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
Tested-by: Matthieu Crapet <Matthieu.Crapet@ingenico.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd/nand/atmel_nand.c')
-rw-r--r-- | drivers/mtd/nand/atmel_nand.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index 4f5348fd409c..22e9137412b4 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c @@ -1572,6 +1572,25 @@ static int atmel_hw_nand_init_params(struct platform_device *pdev, return 0; } +static inline u32 nfc_read_status(struct atmel_nand_host *host) +{ + u32 err_flags = NFC_SR_DTOE | NFC_SR_UNDEF | NFC_SR_AWB | NFC_SR_ASE; + u32 nfc_status = nfc_readl(host->nfc->hsmc_regs, SR); + + if (unlikely(nfc_status & err_flags)) { + if (nfc_status & NFC_SR_DTOE) + dev_err(host->dev, "NFC: Waiting Nand R/B Timeout Error\n"); + else if (nfc_status & NFC_SR_UNDEF) + dev_err(host->dev, "NFC: Access Undefined Area Error\n"); + else if (nfc_status & NFC_SR_AWB) + dev_err(host->dev, "NFC: Access memory While NFC is busy\n"); + else if (nfc_status & NFC_SR_ASE) + dev_err(host->dev, "NFC: Access memory Size Error\n"); + } + + return nfc_status; +} + /* SMC interrupt service routine */ static irqreturn_t hsmc_interrupt(int irq, void *dev_id) { @@ -1579,7 +1598,7 @@ static irqreturn_t hsmc_interrupt(int irq, void *dev_id) u32 status, mask, pending; irqreturn_t ret = IRQ_HANDLED; - status = nfc_readl(host->nfc->hsmc_regs, SR); + status = nfc_read_status(host); mask = nfc_readl(host->nfc->hsmc_regs, IMR); pending = status & mask; @@ -2209,6 +2228,9 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev) } } + nfc_writel(nfc->hsmc_regs, IDR, 0xffffffff); + nfc_readl(nfc->hsmc_regs, SR); /* clear the NFC_SR */ + nfc->is_initialized = true; dev_info(&pdev->dev, "NFC is probed.\n"); return 0; |