[{"id":728,"web_url":"http://patchwork.ozlabs.org/comment/728/","msgid":"<20080916101048.GA4322@fluff.org.uk>","list_archive_url":null,"date":"2008-09-16T10:10:48","subject":"Re: [PATCH] [MTD] [NAND] nand_base.c: reset chip first","submitter":{"id":160,"url":"http://patchwork.ozlabs.org/api/people/160/","name":"Ben Dooks","email":"ben-linux@fluff.org"},"content":"On Mon, Sep 15, 2008 at 02:37:29PM +0200, Karl Beldan wrote:\n> Some chips require a RESET after power-up (e.g. Micron MT29FxGxxxxx).\n> The first command sent is NAND_CMD_READID.\n> Issue a NAND_CMD_RESET in nand_scan_ident before reading the device id.\n> Tested with an MT29F4G08AAC.\n\nThis seems sensible to me, we don't really know what state the NAND\nchip is in.\n\nDoes there need to be a delay after sending the reset command before\nattempting to read the chip's identity?\n \n> Signed-off-by: Karl Beldan <karl.beldan@gmail.com>\n> ---\n> Prior to resetting, the chip gives a correct first ID byte though.\n> \n> \n> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c\n> index d1129ba..2cfac9b 100644\n> --- a/drivers/mtd/nand/nand_base.c\n> +++ b/drivers/mtd/nand/nand_base.c\n> @@ -2318,6 +2318,12 @@ static struct nand_flash_dev\n> *nand_get_flash_type(struct mtd_info *mtd,\n>  \t/* Select the device */\n>  \tchip->select_chip(mtd, 0);\n> \n> +\t/*\n> +\t * Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx)\n> +\t * after power-up\n> +\t */\n> +\tchip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);\n> +\n>  \t/* Send the command for reading device ID */\n>  \tchip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);\n> \n> @@ -2488,6 +2494,8 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips)\n>  \t/* Check for a chip array */\n>  \tfor (i = 1; i < maxchips; i++) {\n>  \t\tchip->select_chip(mtd, i);\n> +\t\t/* See comment in nand_get_flash_type for reset */\n> +\t\tchip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);\n>  \t\t/* Send the command for reading device ID */\n>  \t\tchip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);\n>  \t\t/* Read manufacturer and device IDs */\n> \n> ______________________________________________________\n> Linux MTD discussion mailing list\n> http://lists.infradead.org/mailman/listinfo/linux-mtd/","headers":{"Return-Path":"<linux-mtd-bounces+patchwork=ozlabs.org@lists.infradead.org>","X-Original-To":"patchwork@ozlabs.org","Delivered-To":"patchwork@ozlabs.org","Received":["from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34])\n\t(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\n\t(Client did not present a certificate)\n\tby ozlabs.org (Postfix) with ESMTPS id 1A539DDF51\n\tfor <patchwork@ozlabs.org>; Tue, 16 Sep 2008 21:03:20 +1000 (EST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux))\n\tid 1KfYKm-00011n-F4; Tue, 16 Sep 2008 11:03:04 +0000","from aeryn.fluff.org.uk ([87.194.8.8] helo=kira.home.fluff.org)\n\tby bombadil.infradead.org with esmtps (Exim 4.68 #1 (Red Hat Linux))\n\tid 1KfXWH-000799-Ed\n\tfor linux-mtd@lists.infradead.org; Tue, 16 Sep 2008 10:10:53 +0000","from ben by kira.home.fluff.org with local (Exim 4.69)\n\t(envelope-from <ben@fluff.org.uk>)\n\tid 1KfXWC-0006tN-0j; Tue, 16 Sep 2008 11:10:48 +0100"],"Date":"Tue, 16 Sep 2008 11:10:48 +0100","From":"Ben Dooks <ben-linux@fluff.org>","To":"Karl Beldan <karl.beldan@gmail.com>","Subject":"Re: [PATCH] [MTD] [NAND] nand_base.c: reset chip first","Message-ID":"<20080916101048.GA4322@fluff.org.uk>","References":"<ea2442770809150537p538f5298s9b5b003a1825b09f@mail.gmail.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<ea2442770809150537p538f5298s9b5b003a1825b09f@mail.gmail.com>","X-Disclaimer":"These are my own opinions, so there!","User-Agent":"Mutt/1.5.18 (2008-05-17)","X-Spam-Score":"0.0 (/)","Cc":"linux-mtd@lists.infradead.org, David.Woodhouse@intel.com","X-BeenThere":"linux-mtd@lists.infradead.org","X-Mailman-Version":"2.1.9","Precedence":"list","List-Id":"Linux MTD discussion mailing list <linux-mtd.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n\t<mailto:linux-mtd-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-mtd>","List-Post":"<mailto:linux-mtd@lists.infradead.org>","List-Help":"<mailto:linux-mtd-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n\t<mailto:linux-mtd-request@lists.infradead.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"linux-mtd-bounces@lists.infradead.org","Errors-To":"linux-mtd-bounces+patchwork=ozlabs.org@lists.infradead.org"}},{"id":732,"web_url":"http://patchwork.ozlabs.org/comment/732/","msgid":"<48CF9E98.1030706@gmail.com>","list_archive_url":null,"date":"2008-09-16T11:55:04","subject":"Re: [PATCH] [MTD] [NAND] nand_base.c: reset chip first","submitter":{"id":144,"url":"http://patchwork.ozlabs.org/api/people/144/","name":"Karl Beldan","email":"karl.beldan@gmail.com"},"content":"Ben Dooks wrote:\n> On Mon, Sep 15, 2008 at 02:37:29PM +0200, Karl Beldan wrote:\n>> Some chips require a RESET after power-up (e.g. Micron MT29FxGxxxxx).\n>> The first command sent is NAND_CMD_READID.\n>> Issue a NAND_CMD_RESET in nand_scan_ident before reading the device id.\n>> Tested with an MT29F4G08AAC.\n> \n> This seems sensible to me, we don't really know what state the NAND\n> chip is in.\n> \n> Does there need to be a delay after sending the reset command before\n> attempting to read the chip's identity?\n>  \n\nThere's the tWB + tRST delay which is handled by the CMD_RESET case in \nnand_command if that's what you were thinking of.\nTested both R/B and STATUS_READY code paths.\n\n>> Signed-off-by: Karl Beldan <karl.beldan@gmail.com>\n>> ---\n>> Prior to resetting, the chip gives a correct first ID byte though.\n>>\n>>\n>> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c\n>> index d1129ba..2cfac9b 100644\n>> --- a/drivers/mtd/nand/nand_base.c\n>> +++ b/drivers/mtd/nand/nand_base.c\n>> @@ -2318,6 +2318,12 @@ static struct nand_flash_dev\n>> *nand_get_flash_type(struct mtd_info *mtd,\n>>  \t/* Select the device */\n>>  \tchip->select_chip(mtd, 0);\n>>\n>> +\t/*\n>> +\t * Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx)\n>> +\t * after power-up\n>> +\t */\n>> +\tchip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);\n>> +\n>>  \t/* Send the command for reading device ID */\n>>  \tchip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);\n>>\n>> @@ -2488,6 +2494,8 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips)\n>>  \t/* Check for a chip array */\n>>  \tfor (i = 1; i < maxchips; i++) {\n>>  \t\tchip->select_chip(mtd, i);\n>> +\t\t/* See comment in nand_get_flash_type for reset */\n>> +\t\tchip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);\n>>  \t\t/* Send the command for reading device ID */\n>>  \t\tchip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);\n>>  \t\t/* Read manufacturer and device IDs */\n>>\n>> ______________________________________________________\n>> Linux MTD discussion mailing list\n>> http://lists.infradead.org/mailman/listinfo/linux-mtd/\n>","headers":{"Return-Path":"<linux-mtd-bounces+patchwork=ozlabs.org@lists.infradead.org>","X-Original-To":"patchwork@ozlabs.org","Delivered-To":"patchwork@ozlabs.org","Received":["from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34])\n\t(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\n\t(Client did not present a certificate)\n\tby ozlabs.org (Postfix) with ESMTPS id 91CE9DDE31\n\tfor <patchwork@ozlabs.org>; Tue, 16 Sep 2008 21:55:50 +1000 (EST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux))\n\tid 1KfZ94-000619-Ac; Tue, 16 Sep 2008 11:55:02 +0000","from ik-out-1112.google.com ([66.249.90.181])\n\tby bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux))\n\tid 1KfZ92-0005xQ-Io\n\tfor linux-mtd@lists.infradead.org; Tue, 16 Sep 2008 11:55:01 +0000","by ik-out-1112.google.com with SMTP id c21so2470377ika.2\n\tfor <linux-mtd@lists.infradead.org>;\n\tTue, 16 Sep 2008 04:54:59 -0700 (PDT)","by 10.86.82.6 with SMTP id f6mr672188fgb.38.1221566099367;\n\tTue, 16 Sep 2008 04:54:59 -0700 (PDT)","from ?192.168.2.205? ( [82.225.11.200])\n\tby mx.google.com with ESMTPS id\n\te20sm16455027fga.1.2008.09.16.04.54.57\n\t(version=TLSv1/SSLv3 cipher=RC4-MD5);\n\tTue, 16 Sep 2008 04:54:58 -0700 (PDT)"],"Message-ID":"<48CF9E98.1030706@gmail.com>","Date":"Tue, 16 Sep 2008 13:55:04 +0200","From":"Karl Beldan <karl.beldan@gmail.com>","User-Agent":"Thunderbird 2.0.0.9 (X11/20071031)","MIME-Version":"1.0","To":"Ben Dooks <ben-linux@fluff.org>","Subject":"Re: [PATCH] [MTD] [NAND] nand_base.c: reset chip first","References":"<ea2442770809150537p538f5298s9b5b003a1825b09f@mail.gmail.com>\n\t<20080916101048.GA4322@fluff.org.uk>","In-Reply-To":"<20080916101048.GA4322@fluff.org.uk>","X-Spam-Score":"0.0 (/)","Cc":"linux-mtd@lists.infradead.org, David.Woodhouse@intel.com","X-BeenThere":"linux-mtd@lists.infradead.org","X-Mailman-Version":"2.1.9","Precedence":"list","List-Id":"Linux MTD discussion mailing list <linux-mtd.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n\t<mailto:linux-mtd-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-mtd>","List-Post":"<mailto:linux-mtd@lists.infradead.org>","List-Help":"<mailto:linux-mtd-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n\t<mailto:linux-mtd-request@lists.infradead.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"linux-mtd-bounces@lists.infradead.org","Errors-To":"linux-mtd-bounces+patchwork=ozlabs.org@lists.infradead.org"}}]