From: Sascha Hauer <s.hauer@pengutronix.de> To: Boris Brezillon <boris.brezillon@free-electrons.com> Cc: linux-mtd@lists.infradead.org, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 8/9] mtd: nand: mxc: implement onfi get/set features Date: Tue, 22 Nov 2016 11:52:53 +0100 [thread overview] Message-ID: <20161122105253.tzz2hvzhkse7telr@pengutronix.de> (raw) In-Reply-To: <20161121145643.7804e28f@bbrezillon> 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 <s.hauer@pengutronix.de> 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 <s.hauer@pengutronix.de> > > --- > > 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 <s.hauer@pengutronix.de> Date: Tue, 22 Nov 2016 11:48:36 +0100 Subject: [PATCH] wip Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- 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); -- 2.10.2 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
WARNING: multiple messages have this Message-ID (diff)
From: s.hauer@pengutronix.de (Sascha Hauer) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 8/9] mtd: nand: mxc: implement onfi get/set features Date: Tue, 22 Nov 2016 11:52:53 +0100 [thread overview] Message-ID: <20161122105253.tzz2hvzhkse7telr@pengutronix.de> (raw) In-Reply-To: <20161121145643.7804e28f@bbrezillon> 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 <s.hauer@pengutronix.de> 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 <s.hauer@pengutronix.de> > > --- > > 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 <s.hauer@pengutronix.de> Date: Tue, 22 Nov 2016 11:48:36 +0100 Subject: [PATCH] wip Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- 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); -- 2.10.2 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2016-11-22 10:53 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-09-15 8:32 [PATCH v4] mtd: nand: automate NAND timings selection Sascha Hauer 2016-09-15 8:32 ` Sascha Hauer 2016-09-15 8:32 ` [PATCH 1/9] mtd: nand: Create a NAND reset function Sascha Hauer 2016-09-15 8:32 ` Sascha Hauer 2016-09-15 8:32 ` [PATCH 2/9] mtd: nand: Introduce nand_data_interface Sascha Hauer 2016-09-15 8:32 ` Sascha Hauer 2016-09-15 8:32 ` [PATCH 3/9] mtd: nand: convert ONFI mode into data interface Sascha Hauer 2016-09-15 8:32 ` Sascha Hauer 2016-09-15 8:32 ` [PATCH 4/9] mtd: nand: Add function to convert ONFI mode to data_interface Sascha Hauer 2016-09-15 8:32 ` Sascha Hauer 2016-09-15 8:32 ` [PATCH 5/9] mtd: nand: Expose data interface for ONFI mode 0 Sascha Hauer 2016-09-15 8:32 ` Sascha Hauer 2016-09-15 12:56 ` Boris Brezillon 2016-09-15 12:56 ` Boris Brezillon 2016-10-09 5:12 ` Brian Norris 2016-10-09 5:12 ` Brian Norris 2016-10-09 11:58 ` Boris Brezillon 2016-10-09 11:58 ` Boris Brezillon 2016-09-15 8:32 ` [PATCH 6/9] mtd: nand: automate NAND timings selection Sascha Hauer 2016-09-15 8:32 ` Sascha Hauer 2016-09-15 8:32 ` [PATCH 7/9] mtd: nand: sunxi: switch from manual to automated timing config Sascha Hauer 2016-09-15 8:32 ` Sascha Hauer 2016-09-15 8:32 ` [PATCH 8/9] mtd: nand: mxc: implement onfi get/set features Sascha Hauer 2016-09-15 8:32 ` Sascha Hauer 2016-11-21 13:56 ` Boris Brezillon 2016-11-21 13:56 ` Boris Brezillon 2016-11-22 10:52 ` Sascha Hauer [this message] 2016-11-22 10:52 ` Sascha Hauer 2016-11-22 11:03 ` Boris Brezillon 2016-11-22 11:03 ` Boris Brezillon 2016-09-15 8:32 ` [PATCH 9/9] mtd: nand: mxc: Add timing setup for v2 controllers Sascha Hauer 2016-09-15 8:32 ` Sascha Hauer 2016-09-16 12:19 ` [PATCH v4] mtd: nand: automate NAND timings selection Boris Brezillon 2016-09-16 12:19 ` Boris Brezillon 2016-09-19 6:43 ` Sascha Hauer 2016-09-19 6:43 ` Sascha Hauer -- strict thread matches above, loose matches on Subject: below -- 2016-09-09 12:05 Sascha Hauer 2016-09-09 12:05 ` [PATCH 8/9] mtd: nand: mxc: implement onfi get/set features Sascha Hauer 2016-09-09 12:05 ` Sascha Hauer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20161122105253.tzz2hvzhkse7telr@pengutronix.de \ --to=s.hauer@pengutronix.de \ --cc=boris.brezillon@free-electrons.com \ --cc=kernel@pengutronix.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-mtd@lists.infradead.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.