Skip to contentSkip to conversation

mtd: gpmi: add device tree support for mx6q and mx28

PATCH Superseded Huang Shijie 4 participants 9 messages May 2, 2012 – May 4, 2012

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

PATCH v3 1/1 mtd: gpmi: add device tree support for mx6q and mx28

add gpmi support for mx6q.
add DT support to mx6q and mx28.

---
Please select the CONFIG_USE_OF before you do the comipler-test.

v2 -- > v3:
[0] split this patch from a patch set to avoid git-am failure.
[1] fix the binding file.
[2] remove the unused header files.
[3] fix Coding style.

v1 -- > v2:
[1] merge the gpmi/bch into one device node.
[2] add partition support.
[3] misc.

---
 .../devicetree/bindings/mtd/gpmi-nand.txt          |   33 +++++
 drivers/mtd/nand/Kconfig                           |    2 +-
 drivers/mtd/nand/gpmi-nand/bch-regs.h              |   42 +++++--
 drivers/mtd/nand/gpmi-nand/gpmi-lib.c              |   18 ++--
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c             |  129 ++++++++++----------
 drivers/mtd/nand/gpmi-nand/gpmi-nand.h             |    6 +-
 include/linux/mtd/gpmi-nand.h                      |    8 +-
 7 files changed, 149 insertions(+), 89 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/gpmi-nand.txt
Documentation/devicetree/bindings/mtd/gpmi-nand.txt new file +33 -0
new file mode 100644
index 0000000..1a5bbd3
@@ -0,0 +1,33 @@
+* Freescale General-Purpose Media Interface (GPMI)
+
+The GPMI nand controller provides an interface to control the
+NAND flash chips. We support only one NAND chip now.
+
+Required properties:
+  - compatible : should be "fsl,<chip>-gpmi-nand"
+  - reg : should contain registers location and length for gpmi and bch.
+  - reg-names: Should contain the reg names "gpmi-nand" and "bch"
+  - interrupts : The first is the DMA interrupt number for GPMI.
+                 The second is the BCH interrupt number.
+  - interrupt-names : The interrupt names "gpmi-dma", "bch";
+  - fsl,gpmi-dma-channel : Should contain the dma channel it uses.
+
+The device tree may optionally contain sub-nodes describing partitions of the
+address space. See partition.txt for more detail.
+
+Examples:
+
+gpmi-nand at 8000c000 {
+	compatible = "fsl,imx28-gpmi-nand";
+	#address-cells = <1>;
+	#size-cells = <1>;
+	reg = <0x8000c000 2000>, <0x8000a000 2000>;
+	reg-names = "gpmi-nand", "bch";
+	interrupts = <88>, <41>;
+	interrupt-names = "gpmi-dma", "bch";
+	fsl,gpmi-dma-channel = <4>;
+
+	partition at 0 {
+	...
+	};
+};
drivers/mtd/nand/Kconfig +1 -1
index 7d17cec..bf0a28d 100644
@@ -440,7 +440,7 @@ config MTD_NAND_NANDSIM
 
 config MTD_NAND_GPMI_NAND
         bool "GPMI NAND Flash Controller driver"
-        depends on MTD_NAND && (SOC_IMX23 || SOC_IMX28)
+        depends on MTD_NAND && (SOC_IMX23 || SOC_IMX28 || SOC_IMX6Q)
         help
 	 Enables NAND Flash support for IMX23 or IMX28.
 	 The GPMI controller is very powerful, with the help of BCH
drivers/mtd/nand/gpmi-nand/bch-regs.h +32 -10

60 lines not on this page · raw message

drivers/mtd/nand/gpmi-nand/gpmi-lib.c +10 -8
index fa5200b..a1f4332 100644
@@ -224,13 +224,13 @@ int bch_set_geometry(struct gpmi_nand_data *this)
 	/* Configure layout 0. */
 	writel(BF_BCH_FLASH0LAYOUT0_NBLOCKS(block_count)
 			| BF_BCH_FLASH0LAYOUT0_META_SIZE(metadata_size)
-			| BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength)
-			| BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block_size),
+			| BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this)
+			| BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block_size, this),
 			r->bch_regs + HW_BCH_FLASH0LAYOUT0);
 
 	writel(BF_BCH_FLASH0LAYOUT1_PAGE_SIZE(page_size)
-			| BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength)
-			| BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size),
+			| BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this)
+			| BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size, this),
 			r->bch_regs + HW_BCH_FLASH0LAYOUT1);
 
 	/* Set *all* chip selects to use layout 0. */
@@ -256,11 +256,12 @@ static unsigned int ns_to_cycles(unsigned int time,
 	return max(k, min);
 }
 
+#define DEF_MIN_PROP_DELAY	5
+#define DEF_MAX_PROP_DELAY	9
 /* Apply timing to current hardware conditions. */
 static int gpmi_nfc_compute_hardware_timing(struct gpmi_nand_data *this,
 					struct gpmi_nfc_hardware_timing *hw)
 {
-	struct gpmi_nand_platform_data *pdata = this->pdata;
 	struct timing_threshod *nfc = &timing_default_threshold;
 	struct nand_chip *nand = &this->nand;
 	struct nand_timing target = this->timing;
@@ -277,8 +278,8 @@ static int gpmi_nfc_compute_hardware_timing(struct gpmi_nand_data *this,
 	int ideal_sample_delay_in_ns;
 	unsigned int sample_delay_factor;
 	int tEYE;
-	unsigned int min_prop_delay_in_ns = pdata->min_prop_delay_in_ns;
-	unsigned int max_prop_delay_in_ns = pdata->max_prop_delay_in_ns;
+	unsigned int min_prop_delay_in_ns = DEF_MIN_PROP_DELAY;
+	unsigned int max_prop_delay_in_ns = DEF_MAX_PROP_DELAY;
 
 	/*
 	 * If there are multiple chips, we need to relax the timings to allow
@@ -804,7 +805,8 @@ int gpmi_is_ready(struct gpmi_nand_data *this, unsigned chip)
 	if (GPMI_IS_MX23(this)) {
 		mask = MX23_BM_GPMI_DEBUG_READY0 << chip;
 		reg = readl(r->gpmi_regs + HW_GPMI_DEBUG);
-	} else if (GPMI_IS_MX28(this)) {
+	} else if (GPMI_IS_MX28(this) || GPMI_IS_MX6Q(this)) {
+		/* 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);
 	} else
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +65 -64

216 lines not on this page · raw message

drivers/mtd/nand/gpmi-nand/gpmi-nand.h +4 -2
index ec6180d..ce5daa1 100644
@@ -266,8 +266,10 @@ extern int gpmi_read_page(struct gpmi_nand_data *,
 #define STATUS_UNCORRECTABLE	0xfe
 
 /* Use the platform_id to distinguish different Archs. */
-#define IS_MX23			0x1
-#define IS_MX28			0x2
+#define IS_MX23			0x0
+#define IS_MX28			0x1
+#define IS_MX6Q			0x2
 #define GPMI_IS_MX23(x)		((x)->pdev->id_entry->driver_data == IS_MX23)
 #define GPMI_IS_MX28(x)		((x)->pdev->id_entry->driver_data == IS_MX28)
+#define GPMI_IS_MX6Q(x)		((x)->pdev->id_entry->driver_data == IS_MX6Q)
 #endif
include/linux/mtd/gpmi-nand.h +4 -4
index 69b6dbf..ed3c4e0 100644
@@ -23,12 +23,12 @@
 #define GPMI_NAND_RES_SIZE	6
 
 /* Resource names for the GPMI NAND driver. */
-#define GPMI_NAND_GPMI_REGS_ADDR_RES_NAME  "GPMI NAND GPMI Registers"
+#define GPMI_NAND_GPMI_REGS_ADDR_RES_NAME  "gpmi-nand"
 #define GPMI_NAND_GPMI_INTERRUPT_RES_NAME  "GPMI NAND GPMI Interrupt"
-#define GPMI_NAND_BCH_REGS_ADDR_RES_NAME   "GPMI NAND BCH Registers"
-#define GPMI_NAND_BCH_INTERRUPT_RES_NAME   "GPMI NAND BCH Interrupt"
+#define GPMI_NAND_BCH_REGS_ADDR_RES_NAME   "bch"
+#define GPMI_NAND_BCH_INTERRUPT_RES_NAME   "bch"
 #define GPMI_NAND_DMA_CHANNELS_RES_NAME    "GPMI NAND DMA Channels"
-#define GPMI_NAND_DMA_INTERRUPT_RES_NAME   "GPMI NAND DMA Interrupt"
+#define GPMI_NAND_DMA_INTERRUPT_RES_NAME   "gpmi-dma"
 
 /**
  * struct gpmi_nand_platform_data - GPMI NAND driver platform data.
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH v3 1/1 mtd: gpmi: add device tree support for mx6q and mx28

Quoted 4 lines · Huang Shijie

add gpmi support for mx6q.
add DT support to mx6q and mx28.

Hi Artem,

As the patch heavily depends on mxs device tree branch, I think it will be easier to have it go through arm-soc tree. If you agree, can you please give your ack if the patch looks fine to you?

Signature · 2 lines
Regards,
Shawn
#2 lore raw

PATCH v3 1/1 mtd: gpmi: add device tree support for mx6q and mx28

Quoted 11 lines · Shawn Guo
Quoted 4 lines · Huang Shijie

add gpmi support for mx6q.
add DT support to mx6q and mx28.

Hi Artem,

As the patch heavily depends on mxs device tree branch, I think it will be easier to have it go through arm-soc tree. If you agree, can you please give your ack if the patch looks fine to you?

I do not mind if it goes via the arm-soc tree. I cannot really review this patch - it is too big, I think it should be split on smaller chunks.

Signature · 9 lines
Best Regards,
Artem Bityutskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120503/11b13754/attachment.sig>
#3 lore raw

PATCH v3 1/1 mtd: gpmi: add device tree support for mx6q and mx28

Quoted 11 lines · Artem Bityutskiy
Quoted 5 lines · Shawn Guo

Hi Artem,

As the patch heavily depends on mxs device tree branch, I think it will be easier to have it go through arm-soc tree. ?If you agree, can you please give your ack if the patch looks fine to you?

I do not mind if it goes via the arm-soc tree. I cannot really review this patch - it is too big, I think it should be split on smaller chunks.

Right. I also think that the patch should at least be split into two, one converts the driver to device tree and the other adds imx6q support. Shijie, can you do that?

Regards,
Shawn

#4 lore raw

PATCH v3 1/1 mtd: gpmi: add device tree support for mx6q and mx28

Quoted 8 lines · Shawn Guo
Quoted 7 lines · Artem Bityutskiy
Quoted 5 lines · Shawn Guo

Hi Artem,

As the patch heavily depends on mxs device tree branch, I think it will be easier to have it go through arm-soc tree. ?If you agree, can you please give your ack if the patch looks fine to you?

Quoted 7 lines
Quoted 4 lines

I do not mind if it goes via the arm-soc tree. I cannot really review this patch - it is too big, I think it should be split on smaller chunks.

Right. ?I also think that the patch should at least be split into two, one converts the driver to device tree and the other adds imx6q support. ?Shijie, can you do that?

ok, I will do it tomorrow.

It's better that this patch is merged by l2-mtd, because this patch depends on another patch which is
on the l2-mtd now.

Best Regards
Huang Shijie

#5 lore raw

PATCH v3 1/1 mtd: gpmi: add device tree support for mx6q and mx28

Quoted 4 lines · Huang Shijie

It's better that this patch is merged by l2-mtd, because this patch depends on another patch which is
on the l2-mtd now.

But you patch has to be based on mxs-dma DT support to function. Maybe we should wait for the next merge window?

Regards,
Shawn

#6 lore raw

PATCH v3 1/1 mtd: gpmi: add device tree support for mx6q and mx28

? 2012?05?03? 22:23, Shawn Guo ??:

Quoted 6 lines · Huang Shijie
Quoted 4 lines

It's better that this patch is merged by l2-mtd, because this patch depends on another patch which is
on the l2-mtd now.

But you patch has to be based on mxs-dma DT support to function.

The mxs-dma is another driver (just as the pinctrl driver). I think it's better to do the job in parallel.

Best Regards
Huang Shijie

Quoted 5 lines

Maybe we should wait for the next merge window?

Regards,
Shawn

#7 lore raw

PATCH v3 1/1 mtd: gpmi: add device tree support for mx6q and mx28

Quoted 3 lines · Huang Shijie

The mxs-dma is another driver (just as the pinctrl driver). I think it's better to do the job in parallel.

The problem is if the patch gets applied on mtd tree as it is, the gpmi-nand will stop functioning on mtd tree. Or you are fine with that, since no in-tree board support is using the driver so far? If you are fine with that, I'm fine too.

Regards,
Shawn

#8 lore raw

PATCH v3 1/1 mtd: gpmi: add device tree support for mx6q and mx28

? 2012?05?04? 10:28, Shawn Guo ??:

Quoted 6 lines · Huang Shijie
Quoted 3 lines

The mxs-dma is another driver (just as the pinctrl driver). I think it's better to do the job in parallel.

The problem is if the patch gets applied on mtd tree as it is, the gpmi-nand will stop functioning on mtd tree. Or you are fine with

even this patch is get applied. the gpmi-nand still can not work. I still have to add the pinctl patch to it. So it have no difference on whether the mxs-dma driver is ready or not. :)
So let it go in parallel.

Best Regards
Huang Shijie

Quoted 6 lines

that, since no in-tree board support is using the driver so far? If you are fine with that, I'm fine too.

Regards,
Shawn