aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorWu, Josh <Josh.wu@atmel.com>2014-06-10 05:50:09 -0400
committerBrian Norris <computersforpeace@gmail.com>2014-07-21 23:02:01 -0400
commit50e04e2f0cf25917d8bec05326d0003cc2ab25eb (patch)
tree20b2d923e6644d37941a59e27e34aa1361aff6ff /drivers/mtd
parentb38576667cdcf7a646843b07666faae11cc63e9c (diff)
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')
-rw-r--r--drivers/mtd/nand/atmel_nand.c24
-rw-r--r--drivers/mtd/nand/atmel_nand_nfc.h4
2 files changed, 27 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,
1572 return 0; 1572 return 0;
1573} 1573}
1574 1574
1575static inline u32 nfc_read_status(struct atmel_nand_host *host)
1576{
1577 u32 err_flags = NFC_SR_DTOE | NFC_SR_UNDEF | NFC_SR_AWB | NFC_SR_ASE;
1578 u32 nfc_status = nfc_readl(host->nfc->hsmc_regs, SR);
1579
1580 if (unlikely(nfc_status & err_flags)) {
1581 if (nfc_status & NFC_SR_DTOE)
1582 dev_err(host->dev, "NFC: Waiting Nand R/B Timeout Error\n");
1583 else if (nfc_status & NFC_SR_UNDEF)
1584 dev_err(host->dev, "NFC: Access Undefined Area Error\n");
1585 else if (nfc_status & NFC_SR_AWB)
1586 dev_err(host->dev, "NFC: Access memory While NFC is busy\n");
1587 else if (nfc_status & NFC_SR_ASE)
1588 dev_err(host->dev, "NFC: Access memory Size Error\n");
1589 }
1590
1591 return nfc_status;
1592}
1593
1575/* SMC interrupt service routine */ 1594/* SMC interrupt service routine */
1576static irqreturn_t hsmc_interrupt(int irq, void *dev_id) 1595static irqreturn_t hsmc_interrupt(int irq, void *dev_id)
1577{ 1596{
@@ -1579,7 +1598,7 @@ static irqreturn_t hsmc_interrupt(int irq, void *dev_id)
1579 u32 status, mask, pending; 1598 u32 status, mask, pending;
1580 irqreturn_t ret = IRQ_HANDLED; 1599 irqreturn_t ret = IRQ_HANDLED;
1581 1600
1582 status = nfc_readl(host->nfc->hsmc_regs, SR); 1601 status = nfc_read_status(host);
1583 mask = nfc_readl(host->nfc->hsmc_regs, IMR); 1602 mask = nfc_readl(host->nfc->hsmc_regs, IMR);
1584 pending = status & mask; 1603 pending = status & mask;
1585 1604
@@ -2209,6 +2228,9 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
2209 } 2228 }
2210 } 2229 }
2211 2230
2231 nfc_writel(nfc->hsmc_regs, IDR, 0xffffffff);
2232 nfc_readl(nfc->hsmc_regs, SR); /* clear the NFC_SR */
2233
2212 nfc->is_initialized = true; 2234 nfc->is_initialized = true;
2213 dev_info(&pdev->dev, "NFC is probed.\n"); 2235 dev_info(&pdev->dev, "NFC is probed.\n");
2214 return 0; 2236 return 0;
diff --git a/drivers/mtd/nand/atmel_nand_nfc.h b/drivers/mtd/nand/atmel_nand_nfc.h
index 4efd117cd3a3..85b8ca6af7d2 100644
--- a/drivers/mtd/nand/atmel_nand_nfc.h
+++ b/drivers/mtd/nand/atmel_nand_nfc.h
@@ -37,6 +37,10 @@
37#define ATMEL_HSMC_NFC_SR 0x08 /* NFC Status Register */ 37#define ATMEL_HSMC_NFC_SR 0x08 /* NFC Status Register */
38#define NFC_SR_XFR_DONE (1 << 16) 38#define NFC_SR_XFR_DONE (1 << 16)
39#define NFC_SR_CMD_DONE (1 << 17) 39#define NFC_SR_CMD_DONE (1 << 17)
40#define NFC_SR_DTOE (1 << 20)
41#define NFC_SR_UNDEF (1 << 21)
42#define NFC_SR_AWB (1 << 22)
43#define NFC_SR_ASE (1 << 23)
40#define NFC_SR_RB_EDGE (1 << 24) 44#define NFC_SR_RB_EDGE (1 << 24)
41 45
42#define ATMEL_HSMC_NFC_IER 0x0c 46#define ATMEL_HSMC_NFC_IER 0x0c