From patchwork Fri Jun 6 03:47:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Wu X-Patchwork-Id: 4309841 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3AE569F23C for ; Fri, 6 Jun 2014 03:59:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5A10D2020F for ; Fri, 6 Jun 2014 03:59:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C61A201E4 for ; Fri, 6 Jun 2014 03:59:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WslHo-00042s-Nw; Fri, 06 Jun 2014 03:57:48 +0000 Received: from nasmtp02.atmel.com ([204.2.163.16] helo=SJOEDG01.corp.atmel.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WslHf-00040u-LE; Fri, 06 Jun 2014 03:57:40 +0000 Received: from apsmtp01.atmel.com (10.168.254.30) by sjoedg01.corp.atmel.com (10.64.253.30) with Microsoft SMTP Server (TLS) id 14.2.347.0; Thu, 5 Jun 2014 20:58:28 -0700 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server id 14.2.347.0; Fri, 6 Jun 2014 11:57:43 +0800 From: Josh Wu To: Subject: [PATCH 1/2] mtd: atmel_nand: NFC: use different compeletion for different interrupt Date: Fri, 6 Jun 2014 11:47:59 +0800 Message-ID: <1402026480-26648-1-git-send-email-josh.wu@atmel.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140605_205739_694023_C0346F26 X-CRM114-Status: UNSURE ( 9.84 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) Cc: Josh Wu , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After this patch, we can know which NFC interrupt is handled. It's a preparation for handling multiple NFC interrupts. Signed-off-by: Josh Wu --- drivers/mtd/nand/atmel_nand.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index 4ce181a..347cee2 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c @@ -97,7 +97,9 @@ struct atmel_nfc { bool write_by_sram; bool is_initialized; - struct completion comp_nfc; + struct completion comp_ready; + struct completion comp_cmd_done; + struct completion comp_xfer_done; /* Point to the sram bank which include readed data via NFC */ void __iomem *data_in_sram; @@ -1584,13 +1586,13 @@ static irqreturn_t hsmc_interrupt(int irq, void *dev_id) pending = status & mask; if (pending & NFC_SR_XFR_DONE) { - complete(&host->nfc->comp_nfc); + complete(&host->nfc->comp_xfer_done); nfc_writel(host->nfc->hsmc_regs, IDR, NFC_SR_XFR_DONE); } else if (pending & NFC_SR_RB_EDGE) { - complete(&host->nfc->comp_nfc); + complete(&host->nfc->comp_ready); nfc_writel(host->nfc->hsmc_regs, IDR, NFC_SR_RB_EDGE); } else if (pending & NFC_SR_CMD_DONE) { - complete(&host->nfc->comp_nfc); + complete(&host->nfc->comp_cmd_done); nfc_writel(host->nfc->hsmc_regs, IDR, NFC_SR_CMD_DONE); } else { ret = IRQ_NONE; @@ -1603,12 +1605,25 @@ static irqreturn_t hsmc_interrupt(int irq, void *dev_id) static int nfc_wait_interrupt(struct atmel_nand_host *host, u32 flag) { unsigned long timeout; - init_completion(&host->nfc->comp_nfc); + struct completion *comp; + + if (flag & NFC_SR_XFR_DONE) { + comp = &host->nfc->comp_xfer_done; + } else if (flag & NFC_SR_RB_EDGE) { + comp = &host->nfc->comp_ready; + } else if (flag & NFC_SR_CMD_DONE) { + comp = &host->nfc->comp_cmd_done; + } else { + dev_err(host->dev, "Unkown interrupt flag: 0x%08x\n", flag); + return -EINVAL; + } + + init_completion(comp); /* Enable interrupt that need to wait for */ nfc_writel(host->nfc->hsmc_regs, IER, flag); - timeout = wait_for_completion_timeout(&host->nfc->comp_nfc, + timeout = wait_for_completion_timeout(comp, msecs_to_jiffies(NFC_TIME_OUT_MS)); if (timeout) return 0;