Skip to contentSkip to conversation

mtd: hisilicon: add a new driver for NAND controller of hisilicon hip04 Soc

PATCH Superseded Zhou Wang 2 participants 5 messages Oct 23, 2014 – Oct 25, 2014

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Zhou Wang

author
#0 lore raw

v2 cover mtd: hisilicon: add a new driver for NAND controller of hisilicon hip04 Soc

This patchset adds the support for NAND controller of hisilicon hip04 Soc. The NAND controller IP was developed by hisilicon and needs a new driver to support it. This patchset is based on v3.18-rc1. I have tested that NAND flash controller works fine in Hip04 D01 board.

Changes in v2:
- Remove the patch for device tree, now patchset only has the driver and its device tree binding documentation.
- Change the file name: hisi_nand.c to hisi504_nand.c.
Changes in v1:
- Remove callback functions out of struct hinfc_host, and call them directly in relative functions.
- Change hinfc_read and hinfc_write from macros to inline functions.
- Instead of putting pointers, embed struct nand_chip and struct mtd_info in struct hinfc_host directly.
- rewrite some unclear lines in device tree binding document, correct some code style error.

Link on v1:
- https://lkml.org/lkml/2014/7/15/198

Zhou Wang (2):
mtd: hisilicon: add a new NAND controller driver for hisilicon hip04 Soc
mtd: hisilicon: add device tree binding documentation

 .../devicetree/bindings/mtd/hisi504-nand.txt       |   40 +
 drivers/mtd/nand/Kconfig                           |    5 +
 drivers/mtd/nand/Makefile                          |    1 +
 drivers/mtd/nand/hisi504_nand.c                    |  836 ++++++++++++++++++++
 4 files changed, 882 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/hisi504-nand.txt
 create mode 100644 drivers/mtd/nand/hisi504_nand.c
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v2 1/2 mtd: hisilicon: add a new NAND controller driver for hisilicon hip04 Soc

---
 drivers/mtd/nand/Kconfig        |    5 +
 drivers/mtd/nand/Makefile       |    1 +
 drivers/mtd/nand/hisi504_nand.c |  836 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 842 insertions(+)
 create mode 100644 drivers/mtd/nand/hisi504_nand.c
drivers/mtd/nand/Kconfig +5 -0
index dd10646..e451a08 100644
@@ -516,4 +516,9 @@ config MTD_NAND_XWAY
 	  Enables support for NAND Flash chips on Lantiq XWAY SoCs. NAND is attached
 	  to the External Bus Unit (EBU).
 
+config MTD_NAND_HISI504
+	tristate "Support for NAND controller on Hisilicon SoC Hip04"
+	help
+	  Enables support for NAND controller on Hisilicon SoC Hip04.
+
 endif # MTD_NAND
drivers/mtd/nand/Makefile +1 -0
index 9c847e4..fb1b2e4 100644
@@ -50,5 +50,6 @@ obj-$(CONFIG_MTD_NAND_JZ4740)		+= jz4740_nand.o
 obj-$(CONFIG_MTD_NAND_GPMI_NAND)	+= gpmi-nand/
 obj-$(CONFIG_MTD_NAND_XWAY)		+= xway_nand.o
 obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH)	+= bcm47xxnflash/
+obj-$(CONFIG_MTD_NAND_HISI504)	        += hisi504_nand.o
 
 nand-objs := nand_base.o nand_bbt.o nand_timings.o
drivers/mtd/nand/hisi504_nand.c new file +836 -0

836 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH v2 1/2] mtd: hisilicon: add a new NAND controller driver for hisilicon hip04 Soc

Quoted 8 lines · Zhou Wang
---
 drivers/mtd/nand/Kconfig        |    5 +
 drivers/mtd/nand/Makefile       |    1 +
 drivers/mtd/nand/hisi504_nand.c |  836 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 842 insertions(+)
 create mode 100644 drivers/mtd/nand/hisi504_nand.c

I think that you need to run scripts/checkpatch.pl. There're some warnings reported on this patch.

drivers/mtd/nand/hisi504_nand.c line 461

Quoted 4 lines
drivers/mtd/nand/hisi504_nand.c new file +4 -0
+
+       case NAND_CMD_SEQIN:
+               host->offset = column;
+

It's better not using waterfall style. Maybe you can write it clearly.

            case NAND_CMD_SEQIN:
                    host->offset = column;
                    set_addr(mtd, column, page_addr);
                    break;

drivers/mtd/nand/hisi504_nand.c line 703

Quoted 3 lines
drivers/mtd/nand/hisi504_nand.c new file +3 -0
+       chip->ecc.mode = of_get_nand_ecc_mode(np);
+       /* read ecc-bits from dts */
+       of_property_read_u32(np, "hisi,nand-ecc-bits", &host->ecc_bits);

Do you need to check the ecc_bits at here? Maybe user inputed the wrong ecc_bits in DTS.

Best Regards
Haojian
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#3 lore raw

Re: [PATCH v2 1/2] mtd: hisilicon: add a new NAND controller driver for hisilicon hip04 Soc

Quoted 10 lines · Haojian Zhuang
Quoted 8 lines · Zhou Wang
---
  drivers/mtd/nand/Kconfig        |    5 +
  drivers/mtd/nand/Makefile       |    1 +
  drivers/mtd/nand/hisi504_nand.c |  836 +++++++++++++++++++++++++++++++++++++++
  3 files changed, 842 insertions(+)

create mode 100644 drivers/mtd/nand/hisi504_nand.c

Quoted 3 lines

I think that you need to run scripts/checkpatch.pl. There're some warnings reported on this patch.

Hi Haojian,

I will run the checkpatch.pl again and fix the warnings.
But for lines like this:
+ if (host->command == NAND_CMD_ERASE1)
+ host->addr_value[0] |= ((page_addr >>16) & 0xff) << 16;
+ else
+ host->addr_value[1] |= ((page_addr >> 16) & 0xff);
Only over 80 for some characters in one line, it will report a warning. Can I just leave the warning there for the tidy of the code?

Quoted 10 lines

drivers/mtd/nand/hisi504_nand.c line 461

Quoted 4 lines
drivers/mtd/nand/hisi504_nand.c new file +4 -0
+
+       case NAND_CMD_SEQIN:
+               host->offset = column;
+

It's better not using waterfall style. Maybe you can write it clearly.

             case NAND_CMD_SEQIN:
                     host->offset = column;
                     set_addr(mtd, column, page_addr);
                     break;

Thanks, I will modify the code like this above.

Quoted 7 lines

drivers/mtd/nand/hisi504_nand.c line 703

Quoted 4 lines
drivers/mtd/nand/hisi504_nand.c new file +3 -0
+       chip->ecc.mode = of_get_nand_ecc_mode(np);
+       /* read ecc-bits from dts */
+       of_property_read_u32(np, "hisi,nand-ecc-bits", &host->ecc_bits);

Do you need to check the ecc_bits at here? Maybe user inputed the wrong ecc_bits in DTS.

Yes, it is better to check the ecc_bits here, thanks for your reminding.

Best regards,
Zhou Wang

Quoted 4 lines

Best Regards
Haojian

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#4 lore raw

PATCH v2 2/2 mtd: hisilicon: add device tree binding documentation

In reply to Zhou Wang
---
 .../devicetree/bindings/mtd/hisi504-nand.txt       |   40 ++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/hisi504-nand.txt
Documentation/devicetree/bindings/mtd/hisi504-nand.txt new file +40 -0
new file mode 100644
index 0000000..c8b3988
@@ -0,0 +1,40 @@
+Hisilicon Hip04 Soc NAND controller DT binding
+
+Required properties:
+- compatible:          Should be "hisilicon,504-nfc".
+- reg:                 The first contains base physical address and size of
+                       NAND controller's registers. The second contains base
+                       physical address and size of NAND controller's buffer.
+- interrupts:          Interrupt number for nfc.
+- nand-bus-width:      See nand.txt.
+- nand-ecc-mode:       See nand.txt.
+- hisi,nand-ecc-bits:  ECC bits type support.
+                 <0>:  none ecc
+                 <1>:  Can correct 1bit per 512byte.
+                 <6>:  Can correct 16bits per 1K byte.
+- #address-cells:      partition address, should be set 1.
+- #size-cells:         partition size, should be set 1.
+
+Flash chip may optionally contain additional sub-nodes describing partitions of
+the address space. See partition.txt for more detail.
+
+Example:
+
+	nand: nand@4020000 {
+		compatible = "hisilicon,504-nfc";
+		reg = <0x4020000 0x10000>, <0x5000000 0x1000>;
+		interrupts = <0 379 4>;
+		nand-bus-width = <8>;
+		nand-ecc-mode = "hw";
+		hisi,nand-ecc-bits = <1>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		partition@0 {
+			label = "nand_text";
+			reg = <0x00000000 0x00400000>;
+		};
+
+		...
+
+	};
Signature · 1 line
1.7.9.5