From patchwork Thu Sep 13 15:06:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raphael Assenat X-Patchwork-Id: 183650 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (unknown [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B29A72C0088 for ; Fri, 14 Sep 2012 01:14:53 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TCB0q-0002tg-K8; Thu, 13 Sep 2012 15:07:28 +0000 Received: from bombadil.infradead.org ([2001:4830:2446:ff00:4687:fcff:fea6:5117]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TCB01-0002N2-8P for linux-mtd@merlin.infradead.org; Thu, 13 Sep 2012 15:06:37 +0000 Received: from roc.holo.8d.com ([64.254.227.115]) by bombadil.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TCAzy-0005KG-Rw for linux-mtd@lists.infradead.org; Thu, 13 Sep 2012 15:06:36 +0000 Received: from raph.usine.8d.com ([192.168.142.55] helo=renkinjitsu.usine.8d.com) by roc.holo.8d.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1TCAzh-0001hg-1B; Thu, 13 Sep 2012 11:06:17 -0400 Received: from raph by renkinjitsu.usine.8d.com with local (Exim 4.80) (envelope-from ) id 1TCAzg-0003ju-6i; Thu, 13 Sep 2012 11:06:16 -0400 Date: Thu, 13 Sep 2012 11:06:15 -0400 From: Raphael Assenat To: linux-omap@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [PATCH] mtd: nand: omap2: Fix the nand-disk led trigger Message-ID: <20120913150614.GC22993@renkinjitsu.usine.8d.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -2.6 X-Spam-Level: -- X-Spam-Report: -2.6 points, 5.0 required autolearn=ham -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20120913_110635_147332_8B42A18B X-CRM114-Status: GOOD ( 12.65 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When the omap2 nand flash driver is used, the nand-disk led trigger does not work due to nand_wait_ready not being called. This patch exports the trigger from nand_base.c, letting specific drivers such omap2 control the led as appropriate. Signed-off-by: Raphael Assenat diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index a11253a..b967c45 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -103,7 +103,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, * For devices which display every fart in the system on a separate LED. Is * compiled away when LED support is disabled. */ -DEFINE_LED_TRIGGER(nand_led_trigger); +DEFINE_LED_TRIGGER_GLOBAL(nand_led_trigger); static int check_offs_len(struct mtd_info *mtd, loff_t ofs, uint64_t len) diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index ac4fd75..6aa683f 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -254,6 +255,8 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char *buf, int len) int ret = 0; u32 *p = (u32 *)buf; + led_trigger_event(nand_led_trigger, LED_FULL); + /* take care of subpage reads */ if (len % 4) { if (info->nand.options & NAND_BUSWIDTH_16) @@ -284,6 +287,8 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char *buf, int len) /* disable and stop the PFPW engine */ gpmc_prefetch_reset(info->gpmc_cs); } + + led_trigger_event(nand_led_trigger, LED_OFF); } /** @@ -302,6 +307,8 @@ static void omap_write_buf_pref(struct mtd_info *mtd, u16 *p = (u16 *)buf; unsigned long tim, limit; + led_trigger_event(nand_led_trigger, LED_FULL); + /* take care of subpage writes */ if (len % 2 != 0) { writeb(*buf, info->nand.IO_ADDR_W); @@ -335,6 +342,8 @@ static void omap_write_buf_pref(struct mtd_info *mtd, /* disable and stop the PFPW engine */ gpmc_prefetch_reset(info->gpmc_cs); } + + led_trigger_event(nand_led_trigger, LED_OFF); } /* @@ -366,6 +375,8 @@ static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr, unsigned n; int ret; + led_trigger_event(nand_led_trigger, LED_FULL); + if (addr >= high_memory) { struct page *p1; @@ -417,6 +428,8 @@ static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr, gpmc_prefetch_reset(info->gpmc_cs); dma_unmap_sg(info->dma->device->dev, &sg, 1, dir); + + led_trigger_event(nand_led_trigger, LED_OFF); return 0; out_copy_unmap: @@ -428,6 +441,9 @@ out_copy: else is_write == 0 ? omap_read_buf8(mtd, (u_char *) addr, len) : omap_write_buf8(mtd, (u_char *) addr, len); + + led_trigger_event(nand_led_trigger, LED_OFF); + return 0; } @@ -886,6 +902,8 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip) else timeo += (HZ * 20) / 1000; + led_trigger_event(nand_led_trigger, LED_FULL); + gpmc_nand_write(info->gpmc_cs, GPMC_NAND_COMMAND, (NAND_CMD_STATUS & 0xFF)); while (time_before(jiffies, timeo)) { @@ -894,6 +912,7 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip) break; cond_resched(); } + led_trigger_event(nand_led_trigger, LED_OFF); status = gpmc_nand_read(info->gpmc_cs, GPMC_NAND_DATA); return status; @@ -909,6 +928,8 @@ static int omap_dev_ready(struct mtd_info *mtd) struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, mtd); + led_trigger_event(nand_led_trigger, LED_FULL); + val = gpmc_read_status(GPMC_GET_IRQ_STATUS); if ((val & 0x100) == 0x100) { /* Clear IRQ Interrupt */ @@ -923,6 +944,8 @@ static int omap_dev_ready(struct mtd_info *mtd) val = gpmc_read_status(GPMC_GET_IRQ_STATUS); } } + + led_trigger_event(nand_led_trigger, LED_OFF); return 1; } diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 57977c6..321b7ef 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -23,6 +23,7 @@ #include #include #include +#include struct mtd_info; struct nand_flash_dev; @@ -48,6 +49,9 @@ extern int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len); /* unlocks specified locked blocks */ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); +/* LED trigger for NAND drivers not using nand_wait_ready. */ +extern DEFINE_LED_TRIGGER_GLOBAL(nand_led_trigger); + /* The maximum number of NAND chips in an array */ #define NAND_MAX_CHIPS 8