Skip to contentSkip to conversation

mtd: gpmi: support two nand chips at most

PATCH In review Huang Shijie 5 participants 19 messages Aug 27, 2013 – Oct 23, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover mtd: gpmi: support two nand chips at most

Current gpmi-nand driver only supports one chips. But we may meet some embarrassing situation, such as Micron MT29F32G08QAA.
This nand chip has two DIEs internally. Each die has its own chip select pin, so this chip acts as two nand chips.

If we only scan one chip, we may find that we only get 2G for this chip, but in actually, this chip's size is 4G.

So scan two chips by default.

In order to support two nand chips, we have to do the following:
1.) Decouple the chip select from the DMA channel,
We can use the dma 0 to access all the nand chips.

2.) fix the wrong method of checking the ready/busy status.
In the imx6, all the ready/busy pins are binding together, we should check ready/busy status of chip 0 for the all the chips.

Tested this patch set with MT29F32G08QAA.

To Brian:
My "better" solution was proved to be a bad idea. So i resend this patch set again.

v1 --> v2:
[0] rebase on the latest l2-mtd tree.

Huang Shijie (4):
mtd: gpmi: decouple the chip select from the DMA channel
mtd: gpmi: use DMA channel 0 for all the nand chips
mtd: gpmi: scan two nand chips
mtd: gpmi: imx6: fix the wrong method for checking ready/busy

 drivers/mtd/nand/gpmi-nand/gpmi-lib.c  |   13 +++++++++++++
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    7 +++----
 drivers/mtd/nand/gpmi-nand/gpmi-regs.h |    3 +++
 3 files changed, 19 insertions(+), 4 deletions(-)
#1 lore raw

PATCH v2 1/4 mtd: gpmi: decouple the chip select from the DMA channel

Decouple the chip select from the DMA channel, we use the DMA channel 0 to accecc all the nand devices.

---
 drivers/mtd/nand/gpmi-nand/gpmi-lib.c  |    6 ++++++
 drivers/mtd/nand/gpmi-nand/gpmi-regs.h |    3 +++
 2 files changed, 9 insertions(+), 0 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +6 -0
index 4f8857f..7d56d87 100644
@@ -187,6 +187,12 @@ int gpmi_init(struct gpmi_nand_data *this)
 	/* Select BCH ECC. */
 	writel(BM_GPMI_CTRL1_BCH_MODE, r->gpmi_regs + HW_GPMI_CTRL1_SET);
 
+	/*
+	 * Decouple the chip select from dma channel. We use dma0 for all
+	 * the chips.
+	 */
+	writel(BM_GPMI_CTRL1_DECOUPLE_CS, r->gpmi_regs + HW_GPMI_CTRL1_SET);
+
 	gpmi_disable_clk(this);
 	return 0;
 err_out:
drivers/mtd/nand/gpmi-nand/gpmi-regs.h +3 -0
index 53397cc..82114cd 100644
@@ -108,6 +108,9 @@
 #define HW_GPMI_CTRL1_CLR				0x00000068
 #define HW_GPMI_CTRL1_TOG				0x0000006c
 
+#define BP_GPMI_CTRL1_DECOUPLE_CS			24
+#define BM_GPMI_CTRL1_DECOUPLE_CS	(1 << BP_GPMI_CTRL1_DECOUPLE_CS)
+
 #define BP_GPMI_CTRL1_WRN_DLY_SEL			22
 #define BM_GPMI_CTRL1_WRN_DLY_SEL	(0x3 << BP_GPMI_CTRL1_WRN_DLY_SEL)
 #define BF_GPMI_CTRL1_WRN_DLY_SEL(v)  \
Signature · 1 line
1.7.1
#2 lore raw

PATCH v2 2/4 mtd: gpmi: use DMA channel 0 for all the nand chips

In reply to Huang Shijie

We only have one DMA channel : the channel 0.
Use DMA channel 0 to access all the nand chips.

---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +2 -3
index 8d8a814..24ee8d7 100644
@@ -357,9 +357,8 @@ int common_nfc_set_geometry(struct gpmi_nand_data *this)
 
 struct dma_chan *get_dma_chan(struct gpmi_nand_data *this)
 {
-	int chipnr = this->current_chip;
-
-	return this->dma_chans[chipnr];
+	/* We use the DMA channel 0 to access all the nand chips. */
+	return this->dma_chans[0];
 }
 
 /* Can we use the upper's buffer directly for DMA? */
Signature · 1 line
1.7.1
#5 lore raw

PATCH v2 3/4 mtd: gpmi: scan two nand chips

In reply to Huang Shijie

Some nand chip has two DIEs in a single chip, such as Micron MT29F32G08QAA. Each die has its own chip select pin, so this chip acts as two nand chips.

If we only scan one chip, we may find that we only get 2G for this chip, but in actually, this chip's size is 4G.

So scan two chips by default.

---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +1 -1
index 24ee8d7..eba7b79 100644
@@ -1676,7 +1676,7 @@ static int gpmi_nfc_init(struct gpmi_nand_data *this)
 	if (ret)
 		goto err_out;
 
-	ret = nand_scan_ident(mtd, 1, NULL);
+	ret = nand_scan_ident(mtd, 2, NULL);
 	if (ret)
 		goto err_out;
 
Signature · 1 line
1.7.1
#6 lore raw

PATCH v2 4/4 mtd: gpmi: imx6: fix the wrong method for checking ready/busy

In reply to Huang Shijie

In the imx6, all the ready/busy pins are binding togeter. So we should always check the ready/busy pin of the chip 0.

In the other word, when the CS1 is enabled, we should also check the ready/busy of chip 0; if we check the ready/busy of chip 1, we will get the wrong result.

---
 drivers/mtd/nand/gpmi-nand/gpmi-lib.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +7 -0
index 7d56d87..5edd25b 100644
@@ -1079,6 +1079,13 @@ int gpmi_is_ready(struct gpmi_nand_data *this, unsigned chip)
 		mask = MX23_BM_GPMI_DEBUG_READY0 << chip;
 		reg = readl(r->gpmi_regs + HW_GPMI_DEBUG);
 	} else if (GPMI_IS_MX28(this) || GPMI_IS_MX6Q(this)) {
+		/*
+		 * In the imx6, all the ready/busy pins are binding
+		 * togeter. So we only need to check the chip 0.
+		 */
+		if (GPMI_IS_MX6Q(this))
+			chip = 0;
+
 		/* MX28 shares the same R/B register as MX6Q. */
 		mask = MX28_BF_GPMI_STAT_READY_BUSY(1 << chip);
 		reg = readl(r->gpmi_regs + HW_GPMI_STAT);
Signature · 1 line
1.7.1
#3 lore raw

Re: [PATCH V2 2/4] mtd: gpmi: use DMA channel 0 for all the nand chips

In reply to Huang Shijie
Quoted 2 lines · Huang Shijie

We only have one DMA channel : the channel 0.
Use DMA channel 0 to access all the nand chips.

IIRC, We have 4 DMA channels. Don't we?

Quoted 22 lines
---
  drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    5 ++---
  1 files changed, 2 insertions(+), 3 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +2 -3
index 8d8a814..24ee8d7 100644
@@ -357,9 +357,8 @@ int common_nfc_set_geometry(struct gpmi_nand_data *this)
 
  struct dma_chan *get_dma_chan(struct gpmi_nand_data *this)
  {
-	int chipnr = this->current_chip;
-
-	return this->dma_chans[chipnr];
+	/* We use the DMA channel 0 to access all the nand chips. */
+	return this->dma_chans[0];
  }
 
  /* Can we use the upper's buffer directly for DMA? */
#4 lore raw

Re: [PATCH V2 2/4] mtd: gpmi: use DMA channel 0 for all the nand chips

Quoted 1 line · Vikram Narayanan

IIRC, We have 4 DMA channels. Don't we?

yes, we have. But we only have one gpmi.

I ever tried to use different dma channels for different chip selects. But after discussed with our IC guy, it is proved to be meaningless. We only have one gpmi, and so we only have one data bus. Even we have 4 dma channels , we have to do the DMA operations one by one.

thanks
Huang Shijie

#7 lore raw
In reply to Huang Shijie
Quoted 33 lines · Huang Shijie

Current gpmi-nand driver only supports one chips. But we may meet some embarrassing situation, such as Micron MT29F32G08QAA.
This nand chip has two DIEs internally. Each die has its own chip select pin, so this chip acts as two nand chips.

If we only scan one chip, we may find that we only get 2G for this chip, but in actually, this chip's size is 4G.

So scan two chips by default.

In order to support two nand chips, we have to do the following:
1.) Decouple the chip select from the DMA channel,
We can use the dma 0 to access all the nand chips.

2.) fix the wrong method of checking the ready/busy status.
In the imx6, all the ready/busy pins are binding together, we should check ready/busy status of chip 0 for the all the chips.

Tested this patch set with MT29F32G08QAA.

To Brian:
My "better" solution was proved to be a bad idea. So i resend this patch set again.

v1 --> v2:
[0] rebase on the latest l2-mtd tree.

Huang Shijie (4):
mtd: gpmi: decouple the chip select from the DMA channel
mtd: gpmi: use DMA channel 0 for all the nand chips
mtd: gpmi: scan two nand chips
mtd: gpmi: imx6: fix the wrong method for checking ready/busy

Quoted 5 lines
 drivers/mtd/nand/gpmi-nand/gpmi-lib.c  |   13 +++++++++++++
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    7 +++----
 drivers/mtd/nand/gpmi-nand/gpmi-regs.h |    3 +++
 3 files changed, 19 insertions(+), 4 deletions(-)

just a ping

#8 lore raw
In reply to Huang Shijie
Quoted 33 lines · Huang Shijie

Current gpmi-nand driver only supports one chips. But we may meet some embarrassing situation, such as Micron MT29F32G08QAA.
This nand chip has two DIEs internally. Each die has its own chip select pin, so this chip acts as two nand chips.

If we only scan one chip, we may find that we only get 2G for this chip, but in actually, this chip's size is 4G.

So scan two chips by default.

In order to support two nand chips, we have to do the following:
1.) Decouple the chip select from the DMA channel,
We can use the dma 0 to access all the nand chips.

2.) fix the wrong method of checking the ready/busy status.
In the imx6, all the ready/busy pins are binding together, we should check ready/busy status of chip 0 for the all the chips.

Tested this patch set with MT29F32G08QAA.

To Brian:
My "better" solution was proved to be a bad idea. So i resend this patch set again.

v1 --> v2:
[0] rebase on the latest l2-mtd tree.

Huang Shijie (4):
mtd: gpmi: decouple the chip select from the DMA channel
mtd: gpmi: use DMA channel 0 for all the nand chips
mtd: gpmi: scan two nand chips
mtd: gpmi: imx6: fix the wrong method for checking ready/busy

Quoted 5 lines
 drivers/mtd/nand/gpmi-nand/gpmi-lib.c  |   13 +++++++++++++
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    7 +++----
 drivers/mtd/nand/gpmi-nand/gpmi-regs.h |    3 +++
 3 files changed, 19 insertions(+), 4 deletions(-)

Hi Artem & Brian:
Could you please merge this patch set?
it seems you have missed this patch set.

thanks
Huang Shijie

#9 lore raw
Quoted 34 lines · Huang Shijie
Quoted 33 lines · Huang Shijie

Current gpmi-nand driver only supports one chips. But we may meet some embarrassing situation, such as Micron MT29F32G08QAA.
This nand chip has two DIEs internally. Each die has its own chip select pin, so this chip acts as two nand chips.

If we only scan one chip, we may find that we only get 2G for this chip, but in actually, this chip's size is 4G.

So scan two chips by default.

In order to support two nand chips, we have to do the following:
1.) Decouple the chip select from the DMA channel,
We can use the dma 0 to access all the nand chips.

2.) fix the wrong method of checking the ready/busy status.
In the imx6, all the ready/busy pins are binding together, we should check ready/busy status of chip 0 for the all the chips.

Tested this patch set with MT29F32G08QAA.

To Brian:
My "better" solution was proved to be a bad idea. So i resend this patch set again.

v1 --> v2:
[0] rebase on the latest l2-mtd tree.

Huang Shijie (4):
mtd: gpmi: decouple the chip select from the DMA channel
mtd: gpmi: use DMA channel 0 for all the nand chips
mtd: gpmi: scan two nand chips
mtd: gpmi: imx6: fix the wrong method for checking ready/busy

Quoted 8 lines
Quoted 5 lines
 drivers/mtd/nand/gpmi-nand/gpmi-lib.c  |   13 +++++++++++++
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    7 +++----
 drivers/mtd/nand/gpmi-nand/gpmi-regs.h |    3 +++
 3 files changed, 19 insertions(+), 4 deletions(-)

Hi Artem & Brian:
Could you please merge this patch set?
it seems you have missed this patch set.

Yes, I seem to have overlooked this set. I think it must have come in parallel with your MLC patch set, so I delayed it until the MLC patch set settled down?

Anyway, I'll revisit this soon. But I probably need to take care of your mtd-utils updates first, since they should go along with the MLC patch set.

And on top of that (to update the world on daily status), I seem to be tripping over some UBIFS bugs that are inhibiting the validation I'm trying to do for some new hardware. So, I'm all-around pretty busy! I'll get myself together next week, hopefully.

In the meantime, other people's code could use some extra eyes. I know Ezequiel just sent out a 27 (!) patch series today. There's also the pending cmdline.c patch from months ago, where Cai Zhiyong wanted to migrate our command line partition parser to a common block/cmdline-parser.c. Part of her work (for block devices) is upstream already, and part has just sat on our mailing list without eyes to test it...

See: http://lists.infradead.org/pipermail/linux-mtd/2013-August/048101.html

And finally, I believe Tim Harvey has just reported ECC regressions for GPMI NAND on some of your code that made it into 3.12 so far. That issue is probably more urgent than new features.

Brian

#10 lore raw
Quoted 4 lines · Brian Norris

Yes, I seem to have overlooked this set. I think it must have come in parallel with your MLC patch set, so I delayed it until the MLC patch set settled down?

this patch set has no relationship with MLC patch.

Quoted 8 lines

Anyway, I'll revisit this soon. But I probably need to take care of your mtd-utils updates first, since they should go along with the MLC patch set.

And on top of that (to update the world on daily status), I seem to be tripping over some UBIFS bugs that are inhibiting the validation I'm trying to do for some new hardware. So, I'm all-around pretty busy! I'll get myself together next week, hopefully.

understood.

I am too busy too, i am starting to code the Qspi driver now. I was blocked by a bluetooth/uart/dma issue last month.

Quoted 5 lines

In the meantime, other people's code could use some extra eyes. I know Ezequiel just sent out a 27 (!) patch series today. There's also the pending cmdline.c patch from months ago, where Cai Zhiyong wanted to migrate our command line partition parser to a common block/cmdline-parser.c. Part of her work (for block devices) is

I like Cai zhiyong's patch. But I do not have time to test his patch.

thanks
Huang Shijie

#11 lore raw

Hi Shijie,

Quoted 4 lines

From: Huang Shijie

I am too busy too, i am starting to code the Qspi driver now.

(1)
Your controller uses LUT based approach, So in case, you are planning to follow DT based approach of populating flash information in your QSPI controller then I can help you to put that as part of generic framework so that both ti-qspi and fsl-qspi can re-use it.

(2)
Also, would you be interested in deriving generic framework for serial NOR something like mtd/spinor/.. where m25p80 can plug-in ?

Based on the following cleaned up version of mtd/spinand/...
https://lkml.org/lkml/2013/6/26/88
by Mona Anonuevo <[email protected]>

with regards, pekon

#12 lore raw
Quoted 11 lines · Pekon

Hi Shijie,

Quoted 4 lines

From: Huang Shijie

I am too busy too, i am starting to code the Qspi driver now.

(1)
Your controller uses LUT based approach, So in case, you are planning to follow DT based approach of populating flash information in your QSPI controller then I can help you to put that as part of generic framework so that both ti-qspi and fsl-qspi can re-use it.

it's very good.

Quoted 3 lines

(2)
Also, would you be interested in deriving generic framework for serial NOR something like mtd/spinor/.. where m25p80 can plug-in ?

yes.

Do you have any solution about the generic framework for spi nor?

i want to chage the m25p80.c, and make it not only work for SPI drivers, but also can work for SPI-NOR(QSPI) driver.

thanks
Huang Shijie

Quoted 7 lines

Based on the following cleaned up version of mtd/spinand/...
https://lkml.org/lkml/2013/6/26/88
by Mona Anonuevo<[email protected]>

with regards, pekon

#13 lore raw

Hi,

Quoted 18 lines

From: Huang Shijie [mailto:[email protected]]

Quoted 11 lines · Pekon

Hi Shijie,

Quoted 4 lines

From: Huang Shijie

I am too busy too, i am starting to code the Qspi driver now.

(1)
Your controller uses LUT based approach, So in case, you are planning to follow DT based approach of populating flash information in your QSPI controller then I can help you to put that as part of generic framework so that both ti-qspi and fsl-qspi can re-use it.

it's very good.

Quoted 3 lines

(2)
Also, would you be interested in deriving generic framework for serial NOR something like mtd/spinor/.. where m25p80 can plug-in ?

Quoted 7 lines

yes.

Do you have any solution about the generic framework for spi nor?

i want to chage the m25p80.c, and make it not only work for SPI drivers, but also can work for SPI-NOR(QSPI) driver.

Thanks, but in that case, please do not add generic code in m25p80.c. Let it live as driver for NOR devices, because it supports too many other devices. Rather I was thinking on following ways:

* Step-1: define an interface between SPI-NOR and MTD *
+ create include/linux/mtd/spinor.h

struct spinor {
	/* modes */
	enum modes { MM_MODE, SPI_MODE };
	/* erase operation */	
	uint32 erase_opcode;
	uint32 erase_dummy_cycles;
	int (* erase_done) (...);
	/* read operation */
	uint32 read_opcode;
	uint32 read_dummy_cycles;
	int (*read_done) (...);
	/* write operation */
	[...]
}

This is similar to struct nand_chip in include/linux/mtd/nand.h But specific to SPI NOR device attributes.

* Step-2: spawn out generic code from m25p80 into generic framework * _(maintaining original authorship)_
+ create /driver/mtd/spinor/spinor.c
m25p80_erase() -> spinor_erase(mtd, ...)
m25p80_read() -> spinor_read( mtd, from, len, *buf, ... ) m25p80_write() -> spinor_write (mtd, to, len, *buf, ... )

If you already have done some work on m25p80.c then please see if you can convert on above thoughts and post it. I'll review them and add more stuff and cleanups.
Else, I plan to do that from scratch but need sometime, as I'm bit stuck in some omap2-nand driver clean-up activities.
Let me know what suits you, as per your QSPI-FSL driver timelines..

with regards, pekon

#14 lore raw
Quoted 3 lines · Pekon

If you already have done some work on m25p80.c then please see if you can convert on above thoughts and post it. I'll review them and add more stuff and cleanups.

I will convert my code, and send out as soon as possible.

thanks
Huang Shijie

#15 lore raw

Hi Huang,

Quoted 10 lines · Huang Shijie
Quoted 3 lines · Pekon

If you already have done some work on m25p80.c then please see if you can convert on above thoughts and post it. I'll review them and add more stuff and cleanups.

I will convert my code, and send out as soon as possible.

thanks
Huang Shijie

Did you get the chance to follow the three patch series which I had sent?
One of the patch modifies m25p80 to add support for spnasion and macronix quad read support. If that looks cool also to you[1], we can push for that patch. So that, our further works on m25p80 will be reduced.

[1]: http://permalink.gmane.org/gmane.linux.drivers.mtd/48755

Quoted 3 lines

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#16 lore raw
Quoted 7 lines · Sourav Poddar

Hi Huang,
Did you get the chance to follow the three patch series which I had sent?
One of the patch modifies m25p80 to add support for spnasion and macronix quad read support. If that looks cool also to you[1], we can push for that patch. So that, our further works on m25p80 will be reduced.

[1]: http://permalink.gmane.org/gmane.linux.drivers.mtd/48755

to Brian:
could you please check Sourav's patch?

If you think his patch is ok, please merge it, and i can do my work base on his patch.

thanks
Huang Shijie

#17 lore raw
In reply to Huang Shijie
Quoted 6 lines · Huang Shijie
Quoted 4 lines · Brian Norris

Yes, I seem to have overlooked this set. I think it must have come in parallel with your MLC patch set, so I delayed it until the MLC patch set settled down?

this patch set has no relationship with MLC patch.

Well, it did touch the same driver, and your patch set kept evolving so I chose to focus on just one of your patch sets at a time there...

I'll take a look now.

Quoted 11 lines
Quoted 8 lines

Anyway, I'll revisit this soon. But I probably need to take care of your mtd-utils updates first, since they should go along with the MLC patch set.

And on top of that (to update the world on daily status), I seem to be tripping over some UBIFS bugs that are inhibiting the validation I'm trying to do for some new hardware. So, I'm all-around pretty busy! I'll get myself together next week, hopefully.

understood.

Quoted 8 lines

I am too busy too, i am starting to code the Qspi driver now. I was blocked by a bluetooth/uart/dma issue last month.

Quoted 5 lines

In the meantime, other people's code could use some extra eyes. I know Ezequiel just sent out a 27 (!) patch series today. There's also the pending cmdline.c patch from months ago, where Cai Zhiyong wanted to migrate our command line partition parser to a common block/cmdline-parser.c. Part of her work (for block devices) is

I like Cai zhiyong's patch. But I do not have time to test his patch.

Well, this represents a bad community mentality, where people have time to submit plenty of code for their own drivers, and ask a lot from maintainers to review and merge their code, yet they do not have any time to review others' work. I believe that bearing the sole responsibility of code review is a major contributing factor in both Artem's and my long latency to merging patches.

That said, I understand that people get very busy sometimes, and I don't mean to particularly focus on you, Huang. This is a general pattern that I've seen, and I have done the same thing previously, where I simply did not have (and did not make) time to review others' work much.

Brian

#18 lore raw
In reply to Huang Shijie
Quoted 14 lines · Huang Shijie

Current gpmi-nand driver only supports one chips. But we may meet some embarrassing situation, such as Micron MT29F32G08QAA.
This nand chip has two DIEs internally. Each die has its own chip select pin, so this chip acts as two nand chips.

If we only scan one chip, we may find that we only get 2G for this chip, but in actually, this chip's size is 4G.

So scan two chips by default.

In order to support two nand chips, we have to do the following:
1.) Decouple the chip select from the DMA channel,
We can use the dma 0 to access all the nand chips.

Quoted 5 lines

2.) fix the wrong method of checking the ready/busy status.
In the imx6, all the ready/busy pins are binding together, we should check ready/busy status of chip 0 for the all the chips.

Tested this patch set with MT29F32G08QAA.

I fixed up some typos in patch 4 and pushed the series. Thanks!

Brian