From patchwork Tue Nov 22 10:52:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 9440807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3137A60237 for ; Tue, 22 Nov 2016 10:57:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18F2A284E0 for ; Tue, 22 Nov 2016 10:57:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DA5F284E4; Tue, 22 Nov 2016 10:57:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 723BC284E0 for ; Tue, 22 Nov 2016 10:56:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c98hf-0001cN-1I; Tue, 22 Nov 2016 10:53:31 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c98hS-0001TR-1Y for linux-arm-kernel@lists.infradead.org; Tue, 22 Nov 2016 10:53:20 +0000 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1c98h5-0005GV-5F; Tue, 22 Nov 2016 11:52:55 +0100 Received: from sha by pty.hi.pengutronix.de with local (Exim 4.84_2) (envelope-from ) id 1c98h3-0000aD-T7; Tue, 22 Nov 2016 11:52:53 +0100 Date: Tue, 22 Nov 2016 11:52:53 +0100 From: Sascha Hauer To: Boris Brezillon Subject: Re: [PATCH 8/9] mtd: nand: mxc: implement onfi get/set features Message-ID: <20161122105253.tzz2hvzhkse7telr@pengutronix.de> References: <1473928373-8680-1-git-send-email-s.hauer@pengutronix.de> <1473928373-8680-9-git-send-email-s.hauer@pengutronix.de> <20161121145643.7804e28f@bbrezillon> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161121145643.7804e28f@bbrezillon> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 11:48:53 up 11 days, 21:57, 29 users, load average: 0.00, 0.06, 0.02 User-Agent: Mutt/1.6.2-neo (2016-06-11) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161122_025318_362036_21C5D8B8 X-CRM114-Status: GOOD ( 29.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Boris, On Mon, Nov 21, 2016 at 02:56:43PM +0100, Boris Brezillon wrote: > Hi Sascha, > > On Thu, 15 Sep 2016 10:32:52 +0200 > Sascha Hauer wrote: > > > To be able to support different ONFI timing modes we have to implement > > the onfi_set_features and onfi_get_features. Tested on an i.MX25 SoC. > > > > Signed-off-by: Sascha Hauer > > --- > > drivers/mtd/nand/mxc_nand.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 53 insertions(+) > > > > diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c > > index 5173fad..1db8299 100644 > > --- a/drivers/mtd/nand/mxc_nand.c > > +++ b/drivers/mtd/nand/mxc_nand.c > > @@ -1239,6 +1239,57 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, > > } > > } > > > > +static int mxc_nand_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip, > > + int addr, uint8_t *subfeature_param) > > +{ > > + struct nand_chip *nand_chip = mtd_to_nand(mtd); > > + struct mxc_nand_host *host = nand_get_controller_data(nand_chip); > > + int i; > > + > > + if (!chip->onfi_version || > > + !(le16_to_cpu(chip->onfi_params.opt_cmd) > > + & ONFI_OPT_CMD_SET_GET_FEATURES)) > > + return -EINVAL; > > + > > + host->buf_start = 0; > > + > > + for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i) > > + chip->write_byte(mtd, subfeature_param[i]); > > + > > + memcpy32_toio(host->main_area0, host->data_buf, mtd->writesize); > > + host->devtype_data->send_cmd(host, NAND_CMD_SET_FEATURES, false); > > + mxc_do_addr_cycle(mtd, addr, -1); > > + host->devtype_data->send_page(mtd, NFC_INPUT); > > I've been working with an mx27 board embedding a NAND device lately, > and had a closer look at the NAND controller IP. > With this IP, you're not able to send only 4 bytes of data, and I'm > sure sure what you're doing here (sending a full page of data) works > for a SET_FEATURE command. > > Do you have a way to test it (my NAND is not ONFI compliant)? By test > it, I mean, set a timing mode using SET_FEATURE and check if the new > mode has been applied using GET_FEATURE. I have an i.MX27 board with ONFI flash, but this one does not have the ONFI_OPT_CMD_SET_GET_FEATURES bit set, so I can't test it there. However, I can confirm that it works on an i.MX25. With the attached patch applied on vanilla v4.9-rc5 I get: GET FEATURES. chip->onfi_timing_mode_default: 4 timing before: 0x00 timing after: 0x04 Sascha -------------------------8<------------------------------- From 38e45851a796ba47e25c72ebc58e358c70e18275 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 22 Nov 2016 11:48:36 +0100 Subject: [PATCH] wip Signed-off-by: Sascha Hauer --- drivers/mtd/nand/nand_base.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 3bde96a..5b5be2b 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1017,12 +1017,24 @@ static int nand_setup_data_interface(struct nand_chip *chip) u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = { chip->onfi_timing_mode_default, }; + u8 rmode_param[ONFI_SUBFEATURE_PARAM_LEN] = {}; + + printk("GET FEATURES. chip->onfi_timing_mode_default: %d\n", chip->onfi_timing_mode_default); + ret = chip->onfi_get_features(mtd, chip, ONFI_FEATURE_ADDR_TIMING_MODE, rmode_param); + if (ret) + goto err; + printk("timing before: 0x%02x\n", rmode_param[0]); ret = chip->onfi_set_features(mtd, chip, ONFI_FEATURE_ADDR_TIMING_MODE, tmode_param); if (ret) goto err; + + ret = chip->onfi_get_features(mtd, chip, ONFI_FEATURE_ADDR_TIMING_MODE, rmode_param); + if (ret) + goto err; + printk("timing after: 0x%02x\n", rmode_param[0]); } ret = chip->setup_data_interface(mtd, chip->data_interface, false);