devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 00/10] Add MediaTek MT7986 SPI NAND and ECC support
@ 2022-12-19  2:40 Xiangsheng Hou
  2022-12-19  2:40 ` [PATCH v5 01/10] spi: mtk-snfi: Change default page format to setup default setting Xiangsheng Hou
                   ` (9 more replies)
  0 siblings, 10 replies; 16+ messages in thread
From: Xiangsheng Hou @ 2022-12-19  2:40 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger, Mark Brown,
	Chuanhong Guo
  Cc: Xiangsheng Hou, linux-mtd, devicetree, linux-arm-kernel,
	linux-mediatek, linux-kernel, linux-spi, benliang.zhao, bin.zhang

This patch series add MediaTek MT7986 SPI NAND and ECC controller
support, split ECC engine with rawnand controller in bindings and
change to YAML schema.

Changes since V4:
 - Split arm and arm64 dts patch for fix existing NAND controller node name.

Changes since V3:
 - Correct mediatek,mtk-nfc.yaml dt-bindings.

Changes since V2:
 - Change ECC err_mask value with GENMASK macro.
 - Change snfi mediatek,rx-latch-latency to mediatek,rx-latch-latency-ns.
 - Add a separate patch for DTS change.
 - Move common description to top-level pattern properties.
 - Drop redundant parts in dt-bindings.

Changes since V1:
 - Use existing sample delay property.
 - Add restricting for optional nfi_hclk.
 - Improve and perfect dt-bindings documentation.
 - Change existing node name to match NAND controller DT bingings.
 - Fix issues reported by dt_binding_check.
 - Fix issues reported by dtbs_check.

Xiangsheng Hou (10):
  spi: mtk-snfi: Change default page format to setup default setting
  spi: mtk-snfi: Add optional nfi_hclk which is needed for MT7986
  mtd: nand: ecc-mtk: Add ECC support fot MT7986 IC
  dt-bindings: spi: mtk-snfi: Add compatible for MT7986
  spi: mtk-snfi: Add snfi sample delay and read latency adjustment
  dt-bindings: spi: mtk-snfi: Add read latch latency property
  dt-bindings: mtd: Split ECC engine with rawnand controller
  arm64: dts: mediatek: Fix existing NAND controller node name
  arm: dts: mediatek: Fix existing NAND controller node name
  dt-bindings: mtd: mediatek,nand-ecc-engine: Add compatible for MT7986

 .../bindings/mtd/mediatek,mtk-nfc.yaml        | 155 +++++++++++++++
 .../mtd/mediatek,nand-ecc-engine.yaml         |  63 +++++++
 .../devicetree/bindings/mtd/mtk-nand.txt      | 176 ------------------
 .../bindings/spi/mediatek,spi-mtk-snfi.yaml   |  54 +++++-
 arch/arm/boot/dts/mt2701.dtsi                 |   2 +-
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi     |   2 +-
 arch/arm64/boot/dts/mediatek/mt7622.dtsi      |   2 +-
 drivers/mtd/nand/ecc-mtk.c                    |  28 ++-
 drivers/spi/spi-mtk-snfi.c                    |  41 +++-
 9 files changed, 330 insertions(+), 193 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml
 create mode 100644 Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml
 delete mode 100644 Documentation/devicetree/bindings/mtd/mtk-nand.txt

-- 
2.25.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v5 01/10] spi: mtk-snfi: Change default page format to setup default setting
  2022-12-19  2:40 [PATCH v5 00/10] Add MediaTek MT7986 SPI NAND and ECC support Xiangsheng Hou
@ 2022-12-19  2:40 ` Xiangsheng Hou
  2022-12-19 15:30   ` Matthias Brugger
  2022-12-19  2:40 ` [PATCH v5 02/10] spi: mtk-snfi: Add optional nfi_hclk which is needed for MT7986 Xiangsheng Hou
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Xiangsheng Hou @ 2022-12-19  2:40 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger, Mark Brown,
	Chuanhong Guo
  Cc: Xiangsheng Hou, linux-mtd, devicetree, linux-arm-kernel,
	linux-mediatek, linux-kernel, linux-spi, benliang.zhao, bin.zhang

Change default page format to setup default setting since the sector
size 1024 on MT7986 will lead to probe fail.

Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
---
 drivers/spi/spi-mtk-snfi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/spi/spi-mtk-snfi.c b/drivers/spi/spi-mtk-snfi.c
index fa8412ba20e2..719fc6f53ab1 100644
--- a/drivers/spi/spi-mtk-snfi.c
+++ b/drivers/spi/spi-mtk-snfi.c
@@ -1430,8 +1430,7 @@ static int mtk_snand_probe(struct platform_device *pdev)
 
 	// setup an initial page format for ops matching page_cache_op template
 	// before ECC is called.
-	ret = mtk_snand_setup_pagefmt(ms, ms->caps->sector_size,
-				      ms->caps->spare_sizes[0]);
+	ret = mtk_snand_setup_pagefmt(ms, SZ_2K, SZ_64);
 	if (ret) {
 		dev_err(ms->dev, "failed to set initial page format\n");
 		goto disable_clk;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v5 02/10] spi: mtk-snfi: Add optional nfi_hclk which is needed for MT7986
  2022-12-19  2:40 [PATCH v5 00/10] Add MediaTek MT7986 SPI NAND and ECC support Xiangsheng Hou
  2022-12-19  2:40 ` [PATCH v5 01/10] spi: mtk-snfi: Change default page format to setup default setting Xiangsheng Hou
@ 2022-12-19  2:40 ` Xiangsheng Hou
  2022-12-19  2:40 ` [PATCH v5 03/10] mtd: nand: ecc-mtk: Add ECC support fot MT7986 IC Xiangsheng Hou
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Xiangsheng Hou @ 2022-12-19  2:40 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger, Mark Brown,
	Chuanhong Guo
  Cc: Xiangsheng Hou, linux-mtd, devicetree, linux-arm-kernel,
	linux-mediatek, linux-kernel, linux-spi, benliang.zhao, bin.zhang,
	AngeloGioacchino Del Regno

Add optional nfi_hclk which is needed for MT7986.

Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/spi/spi-mtk-snfi.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/spi/spi-mtk-snfi.c b/drivers/spi/spi-mtk-snfi.c
index 719fc6f53ab1..85644308df23 100644
--- a/drivers/spi/spi-mtk-snfi.c
+++ b/drivers/spi/spi-mtk-snfi.c
@@ -297,6 +297,7 @@ struct mtk_snand {
 	struct device *dev;
 	struct clk *nfi_clk;
 	struct clk *pad_clk;
+	struct clk *nfi_hclk;
 	void __iomem *nfi_base;
 	int irq;
 	struct completion op_done;
@@ -1339,7 +1340,16 @@ static int mtk_snand_enable_clk(struct mtk_snand *ms)
 		dev_err(ms->dev, "unable to enable pad clk\n");
 		goto err1;
 	}
+	ret = clk_prepare_enable(ms->nfi_hclk);
+	if (ret) {
+		dev_err(ms->dev, "unable to enable nfi hclk\n");
+		goto err2;
+	}
+
 	return 0;
+
+err2:
+	clk_disable_unprepare(ms->pad_clk);
 err1:
 	clk_disable_unprepare(ms->nfi_clk);
 	return ret;
@@ -1347,6 +1357,7 @@ static int mtk_snand_enable_clk(struct mtk_snand *ms)
 
 static void mtk_snand_disable_clk(struct mtk_snand *ms)
 {
+	clk_disable_unprepare(ms->nfi_hclk);
 	clk_disable_unprepare(ms->pad_clk);
 	clk_disable_unprepare(ms->nfi_clk);
 }
@@ -1401,6 +1412,13 @@ static int mtk_snand_probe(struct platform_device *pdev)
 		goto release_ecc;
 	}
 
+	ms->nfi_hclk = devm_clk_get_optional(&pdev->dev, "nfi_hclk");
+	if (IS_ERR(ms->nfi_hclk)) {
+		ret = PTR_ERR(ms->nfi_hclk);
+		dev_err(&pdev->dev, "unable to get nfi_hclk, err = %d\n", ret);
+		goto release_ecc;
+	}
+
 	ret = mtk_snand_enable_clk(ms);
 	if (ret)
 		goto release_ecc;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v5 03/10] mtd: nand: ecc-mtk: Add ECC support fot MT7986 IC
  2022-12-19  2:40 [PATCH v5 00/10] Add MediaTek MT7986 SPI NAND and ECC support Xiangsheng Hou
  2022-12-19  2:40 ` [PATCH v5 01/10] spi: mtk-snfi: Change default page format to setup default setting Xiangsheng Hou
  2022-12-19  2:40 ` [PATCH v5 02/10] spi: mtk-snfi: Add optional nfi_hclk which is needed for MT7986 Xiangsheng Hou
@ 2022-12-19  2:40 ` Xiangsheng Hou
  2022-12-19  2:40 ` [PATCH v5 04/10] dt-bindings: spi: mtk-snfi: Add compatible for MT7986 Xiangsheng Hou
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Xiangsheng Hou @ 2022-12-19  2:40 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger, Mark Brown,
	Chuanhong Guo
  Cc: Xiangsheng Hou, linux-mtd, devicetree, linux-arm-kernel,
	linux-mediatek, linux-kernel, linux-spi, benliang.zhao, bin.zhang,
	AngeloGioacchino Del Regno

Add ECC support fot MT7986 IC, and change err_mask value with
GENMASK macro.

Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/mtd/nand/ecc-mtk.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/ecc-mtk.c b/drivers/mtd/nand/ecc-mtk.c
index 9f9b201fe706..c75bb8b80cc1 100644
--- a/drivers/mtd/nand/ecc-mtk.c
+++ b/drivers/mtd/nand/ecc-mtk.c
@@ -40,6 +40,10 @@
 #define ECC_IDLE_REG(op)	((op) == ECC_ENCODE ? ECC_ENCIDLE : ECC_DECIDLE)
 #define ECC_CTL_REG(op)		((op) == ECC_ENCODE ? ECC_ENCCON : ECC_DECCON)
 
+#define ECC_ERRMASK_MT7622	GENMASK(4, 0)
+#define ECC_ERRMASK_MT2701	GENMASK(5, 0)
+#define ECC_ERRMASK_MT2712	GENMASK(6, 0)
+
 struct mtk_ecc_caps {
 	u32 err_mask;
 	u32 err_shift;
@@ -79,6 +83,10 @@ static const u8 ecc_strength_mt7622[] = {
 	4, 6, 8, 10, 12
 };
 
+static const u8 ecc_strength_mt7986[] = {
+	4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24
+};
+
 enum mtk_ecc_regs {
 	ECC_ENCPAR00,
 	ECC_ENCIRQ_EN,
@@ -451,7 +459,7 @@ unsigned int mtk_ecc_get_parity_bits(struct mtk_ecc *ecc)
 EXPORT_SYMBOL(mtk_ecc_get_parity_bits);
 
 static const struct mtk_ecc_caps mtk_ecc_caps_mt2701 = {
-	.err_mask = 0x3f,
+	.err_mask = ECC_ERRMASK_MT2701,
 	.err_shift = 8,
 	.ecc_strength = ecc_strength_mt2701,
 	.ecc_regs = mt2701_ecc_regs,
@@ -462,7 +470,7 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt2701 = {
 };
 
 static const struct mtk_ecc_caps mtk_ecc_caps_mt2712 = {
-	.err_mask = 0x7f,
+	.err_mask = ECC_ERRMASK_MT2712,
 	.err_shift = 8,
 	.ecc_strength = ecc_strength_mt2712,
 	.ecc_regs = mt2712_ecc_regs,
@@ -473,7 +481,7 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt2712 = {
 };
 
 static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = {
-	.err_mask = 0x1f,
+	.err_mask = ECC_ERRMASK_MT7622,
 	.err_shift = 5,
 	.ecc_strength = ecc_strength_mt7622,
 	.ecc_regs = mt7622_ecc_regs,
@@ -483,6 +491,17 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = {
 	.pg_irq_sel = 0,
 };
 
+static const struct mtk_ecc_caps mtk_ecc_caps_mt7986 = {
+	.err_mask = ECC_ERRMASK_MT7622,
+	.err_shift = 8,
+	.ecc_strength = ecc_strength_mt7986,
+	.ecc_regs = mt2712_ecc_regs,
+	.num_ecc_strength = 11,
+	.ecc_mode_shift = 5,
+	.parity_bits = 14,
+	.pg_irq_sel = 1,
+};
+
 static const struct of_device_id mtk_ecc_dt_match[] = {
 	{
 		.compatible = "mediatek,mt2701-ecc",
@@ -493,6 +512,9 @@ static const struct of_device_id mtk_ecc_dt_match[] = {
 	}, {
 		.compatible = "mediatek,mt7622-ecc",
 		.data = &mtk_ecc_caps_mt7622,
+	}, {
+		.compatible = "mediatek,mt7986-ecc",
+		.data = &mtk_ecc_caps_mt7986,
 	},
 	{},
 };
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v5 04/10] dt-bindings: spi: mtk-snfi: Add compatible for MT7986
  2022-12-19  2:40 [PATCH v5 00/10] Add MediaTek MT7986 SPI NAND and ECC support Xiangsheng Hou
                   ` (2 preceding siblings ...)
  2022-12-19  2:40 ` [PATCH v5 03/10] mtd: nand: ecc-mtk: Add ECC support fot MT7986 IC Xiangsheng Hou
@ 2022-12-19  2:40 ` Xiangsheng Hou
  2022-12-19  2:40 ` [PATCH v5 05/10] spi: mtk-snfi: Add snfi sample delay and read latency adjustment Xiangsheng Hou
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Xiangsheng Hou @ 2022-12-19  2:40 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger, Mark Brown,
	Chuanhong Guo
  Cc: Xiangsheng Hou, linux-mtd, devicetree, linux-arm-kernel,
	linux-mediatek, linux-kernel, linux-spi, benliang.zhao, bin.zhang,
	Krzysztof Kozlowski, AngeloGioacchino Del Regno

Add dt-bindings documentation of SPI NAND controller
for MediaTek MT7986 SoC platform. And add optional
nfi_hclk property which is needed for MT7986.

Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 .../bindings/spi/mediatek,spi-mtk-snfi.yaml   | 51 +++++++++++++++----
 1 file changed, 42 insertions(+), 9 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml b/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
index 6e6e02c91780..bab23f1b11fd 100644
--- a/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
+++ b/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
@@ -18,14 +18,12 @@ description: |
   using the accompanying ECC engine. There should be only one spi
   slave device following generic spi bindings.
 
-allOf:
-  - $ref: /schemas/spi/spi-controller.yaml#
-
 properties:
   compatible:
     enum:
       - mediatek,mt7622-snand
       - mediatek,mt7629-snand
+      - mediatek,mt7986-snand
 
   reg:
     items:
@@ -36,14 +34,12 @@ properties:
       - description: NFI interrupt
 
   clocks:
-    items:
-      - description: clock used for the controller
-      - description: clock used for the SPI bus
+    minItems: 2
+    maxItems: 3
 
   clock-names:
-    items:
-      - const: nfi_clk
-      - const: pad_clk
+    minItems: 2
+    maxItems: 3
 
   nand-ecc-engine:
     description: device-tree node of the accompanying ECC engine.
@@ -57,6 +53,43 @@ required:
   - clock-names
   - nand-ecc-engine
 
+allOf:
+  - $ref: /schemas/spi/spi-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          enum:
+            - mediatek,mt7622-snand
+            - mediatek,mt7629-snand
+    then:
+      properties:
+        clocks:
+          items:
+            - description: clock used for the controller
+            - description: clock used for the SPI bus
+        clock-names:
+          items:
+            - const: nfi_clk
+            - const: pad_clk
+
+  - if:
+      properties:
+        compatible:
+          enum:
+            - mediatek,mt7986-snand
+    then:
+      properties:
+        clocks:
+          items:
+            - description: clock used for the controller
+            - description: clock used for the SPI bus
+            - description: clock used for the AHB bus
+        clock-names:
+          items:
+            - const: nfi_clk
+            - const: pad_clk
+            - const: nfi_hclk
+
 unevaluatedProperties: false
 
 examples:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v5 05/10] spi: mtk-snfi: Add snfi sample delay and read latency adjustment
  2022-12-19  2:40 [PATCH v5 00/10] Add MediaTek MT7986 SPI NAND and ECC support Xiangsheng Hou
                   ` (3 preceding siblings ...)
  2022-12-19  2:40 ` [PATCH v5 04/10] dt-bindings: spi: mtk-snfi: Add compatible for MT7986 Xiangsheng Hou
@ 2022-12-19  2:40 ` Xiangsheng Hou
  2022-12-19  2:40 ` [PATCH v5 06/10] dt-bindings: spi: mtk-snfi: Add read latch latency property Xiangsheng Hou
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Xiangsheng Hou @ 2022-12-19  2:40 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger, Mark Brown,
	Chuanhong Guo
  Cc: Xiangsheng Hou, linux-mtd, devicetree, linux-arm-kernel,
	linux-mediatek, linux-kernel, linux-spi, benliang.zhao, bin.zhang,
	AngeloGioacchino Del Regno

Add snfi sample delay and read latency adjustment which can get
from dts property.

Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/spi/spi-mtk-snfi.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/spi/spi-mtk-snfi.c b/drivers/spi/spi-mtk-snfi.c
index 85644308df23..f3f95eb37365 100644
--- a/drivers/spi/spi-mtk-snfi.c
+++ b/drivers/spi/spi-mtk-snfi.c
@@ -195,6 +195,8 @@
 #define DATA_READ_MODE_X4 2
 #define DATA_READ_MODE_DUAL 5
 #define DATA_READ_MODE_QUAD 6
+#define DATA_READ_LATCH_LAT GENMASK(9, 8)
+#define DATA_READ_LATCH_LAT_S 8
 #define PG_LOAD_CUSTOM_EN BIT(7)
 #define DATARD_CUSTOM_EN BIT(6)
 #define CS_DESELECT_CYC_S 0
@@ -205,6 +207,9 @@
 
 #define SNF_DLY_CTL3 0x548
 #define SFCK_SAM_DLY_S 0
+#define SFCK_SAM_DLY GENMASK(5, 0)
+#define SFCK_SAM_DLY_TOTAL 9
+#define SFCK_SAM_DLY_RANGE 47
 
 #define SNF_STA_CTL1 0x550
 #define CUS_PG_DONE BIT(28)
@@ -1368,6 +1373,8 @@ static int mtk_snand_probe(struct platform_device *pdev)
 	const struct of_device_id *dev_id;
 	struct spi_controller *ctlr;
 	struct mtk_snand *ms;
+	unsigned long spi_freq;
+	u32 val = 0;
 	int ret;
 
 	dev_id = of_match_node(mtk_snand_ids, np);
@@ -1446,6 +1453,19 @@ static int mtk_snand_probe(struct platform_device *pdev)
 	// switch to SNFI mode
 	nfi_write32(ms, SNF_CFG, SPI_MODE);
 
+	ret = of_property_read_u32(np, "rx-sample-delay-ns", &val);
+	if (!ret)
+		nfi_rmw32(ms, SNF_DLY_CTL3, SFCK_SAM_DLY,
+			  val * SFCK_SAM_DLY_RANGE / SFCK_SAM_DLY_TOTAL);
+
+	ret = of_property_read_u32(np, "mediatek,rx-latch-latency-ns", &val);
+	if (!ret) {
+		spi_freq = clk_get_rate(ms->pad_clk);
+		val = DIV_ROUND_CLOSEST(val, NSEC_PER_SEC / spi_freq);
+		nfi_rmw32(ms, SNF_MISC_CTL, DATA_READ_LATCH_LAT,
+			  val << DATA_READ_LATCH_LAT_S);
+	}
+
 	// setup an initial page format for ops matching page_cache_op template
 	// before ECC is called.
 	ret = mtk_snand_setup_pagefmt(ms, SZ_2K, SZ_64);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v5 06/10] dt-bindings: spi: mtk-snfi: Add read latch latency property
  2022-12-19  2:40 [PATCH v5 00/10] Add MediaTek MT7986 SPI NAND and ECC support Xiangsheng Hou
                   ` (4 preceding siblings ...)
  2022-12-19  2:40 ` [PATCH v5 05/10] spi: mtk-snfi: Add snfi sample delay and read latency adjustment Xiangsheng Hou
@ 2022-12-19  2:40 ` Xiangsheng Hou
  2022-12-19 15:38   ` Rob Herring
  2022-12-19  2:40 ` [PATCH v5 07/10] dt-bindings: mtd: Split ECC engine with rawnand controller Xiangsheng Hou
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Xiangsheng Hou @ 2022-12-19  2:40 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger, Mark Brown,
	Chuanhong Guo
  Cc: Xiangsheng Hou, linux-mtd, devicetree, linux-arm-kernel,
	linux-mediatek, linux-kernel, linux-spi, benliang.zhao, bin.zhang,
	Krzysztof Kozlowski, AngeloGioacchino Del Regno

Add mediatek,rx-latch-latency-ns property which adjust data read
latch latency in the unit of nanoseconds.

Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 .../devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml         | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml b/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
index bab23f1b11fd..1e5e89a693c3 100644
--- a/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
+++ b/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
@@ -45,6 +45,9 @@ properties:
     description: device-tree node of the accompanying ECC engine.
     $ref: /schemas/types.yaml#/definitions/phandle
 
+  mediatek,rx-latch-latency-ns:
+    description: Data read latch latency, unit is nanoseconds.
+
 required:
   - compatible
   - reg
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v5 07/10] dt-bindings: mtd: Split ECC engine with rawnand controller
  2022-12-19  2:40 [PATCH v5 00/10] Add MediaTek MT7986 SPI NAND and ECC support Xiangsheng Hou
                   ` (5 preceding siblings ...)
  2022-12-19  2:40 ` [PATCH v5 06/10] dt-bindings: spi: mtk-snfi: Add read latch latency property Xiangsheng Hou
@ 2022-12-19  2:40 ` Xiangsheng Hou
  2022-12-19  2:40 ` [PATCH v5 08/10] arm64: dts: mediatek: Fix existing NAND controller node name Xiangsheng Hou
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Xiangsheng Hou @ 2022-12-19  2:40 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger, Mark Brown,
	Chuanhong Guo
  Cc: Xiangsheng Hou, linux-mtd, devicetree, linux-arm-kernel,
	linux-mediatek, linux-kernel, linux-spi, benliang.zhao, bin.zhang,
	Krzysztof Kozlowski

Split MediaTek ECC engine with rawnand controller and convert to
YAML schema.

Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 .../bindings/mtd/mediatek,mtk-nfc.yaml        | 155 +++++++++++++++
 .../mtd/mediatek,nand-ecc-engine.yaml         |  62 ++++++
 .../devicetree/bindings/mtd/mtk-nand.txt      | 176 ------------------
 3 files changed, 217 insertions(+), 176 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml
 create mode 100644 Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml
 delete mode 100644 Documentation/devicetree/bindings/mtd/mtk-nand.txt

diff --git a/Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml b/Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml
new file mode 100644
index 000000000000..a6e7f123eda7
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml
@@ -0,0 +1,155 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/mediatek,mtk-nfc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek(MTK) SoCs raw NAND FLASH controller (NFC)
+
+maintainers:
+  - Xiangsheng Hou <xiangsheng.hou@mediatek.com>
+
+properties:
+  compatible:
+    enum:
+      - mediatek,mt2701-nfc
+      - mediatek,mt2712-nfc
+      - mediatek,mt7622-nfc
+
+  reg:
+    items:
+      - description: Base physical address and size of NFI.
+
+  interrupts:
+    items:
+      - description: NFI interrupt
+
+  clocks:
+    items:
+      - description: clock used for the controller
+      - description: clock used for the pad
+
+  clock-names:
+    items:
+      - const: nfi_clk
+      - const: pad_clk
+
+  ecc-engine:
+    description: device-tree node of the required ECC engine.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+patternProperties:
+  "^nand@[a-f0-9]$":
+    $ref: nand-chip.yaml#
+    unevaluatedProperties: false
+    properties:
+      reg:
+        maximum: 1
+      nand-on-flash-bbt: true
+      nand-ecc-mode:
+        const: hw
+
+allOf:
+  - $ref: nand-controller.yaml#
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: mediatek,mt2701-nfc
+    then:
+      patternProperties:
+        "^nand@[a-f0-9]$":
+          properties:
+            nand-ecc-step-size:
+              enum: [ 512, 1024 ]
+            nand-ecc-strength:
+              enum: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36,
+                     40, 44, 48, 52, 56, 60]
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: mediatek,mt2712-nfc
+    then:
+      patternProperties:
+        "^nand@[a-f0-9]$":
+          properties:
+            nand-ecc-step-size:
+              enum: [ 512, 1024 ]
+            nand-ecc-strength:
+              enum: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36,
+                     40, 44, 48, 52, 56, 60, 68, 72, 80]
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: mediatek,mt7622-nfc
+    then:
+      patternProperties:
+        "^nand@[a-f0-9]$":
+          properties:
+            nand-ecc-step-size:
+              const: 512
+            nand-ecc-strength:
+              enum: [4, 6, 8, 10, 12]
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - ecc-engine
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt2701-clk.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        nand-controller@1100d000 {
+            compatible = "mediatek,mt2701-nfc";
+            reg = <0 0x1100d000 0 0x1000>;
+            interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_LOW>;
+            clocks = <&pericfg CLK_PERI_NFI>,
+                     <&pericfg CLK_PERI_NFI_PAD>;
+            clock-names = "nfi_clk", "pad_clk";
+            ecc-engine = <&bch>;
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            nand@0 {
+                reg = <0>;
+
+                nand-on-flash-bbt;
+                nand-ecc-mode = "hw";
+                nand-ecc-step-size = <1024>;
+                nand-ecc-strength = <24>;
+
+                partitions {
+                    compatible = "fixed-partitions";
+                    #address-cells = <1>;
+                    #size-cells = <1>;
+
+                    preloader@0 {
+                        label = "pl";
+                        read-only;
+                        reg = <0x0 0x400000>;
+                    };
+                    android@400000 {
+                        label = "android";
+                        reg = <0x400000 0x12c00000>;
+                    };
+                };
+            };
+        };
+    };
diff --git a/Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml b/Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml
new file mode 100644
index 000000000000..b13d801eda76
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/mediatek,nand-ecc-engine.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek(MTK) SoCs NAND ECC engine
+
+maintainers:
+  - Xiangsheng Hou <xiangsheng.hou@mediatek.com>
+
+description: |
+  MTK NAND ECC engine can cowork with MTK raw NAND and SPI NAND controller.
+
+properties:
+  compatible:
+    enum:
+      - mediatek,mt2701-ecc
+      - mediatek,mt2712-ecc
+      - mediatek,mt7622-ecc
+
+  reg:
+    items:
+      - description: Base physical address and size of ECC.
+
+  interrupts:
+    items:
+      - description: ECC interrupt
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    const: nfiecc_clk
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt2701-clk.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        bch: ecc@1100e000 {
+            compatible = "mediatek,mt2701-ecc";
+            reg = <0 0x1100e000 0 0x1000>;
+            interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_LOW>;
+            clocks = <&pericfg CLK_PERI_NFI_ECC>;
+            clock-names = "nfiecc_clk";
+        };
+    };
diff --git a/Documentation/devicetree/bindings/mtd/mtk-nand.txt b/Documentation/devicetree/bindings/mtd/mtk-nand.txt
deleted file mode 100644
index 839ea2f93d04..000000000000
--- a/Documentation/devicetree/bindings/mtd/mtk-nand.txt
+++ /dev/null
@@ -1,176 +0,0 @@
-MTK SoCs NAND FLASH controller (NFC) DT binding
-
-This file documents the device tree bindings for MTK SoCs NAND controllers.
-The functional split of the controller requires two drivers to operate:
-the nand controller interface driver and the ECC engine driver.
-
-The hardware description for both devices must be captured as device
-tree nodes.
-
-1) NFC NAND Controller Interface (NFI):
-=======================================
-
-The first part of NFC is NAND Controller Interface (NFI) HW.
-Required NFI properties:
-- compatible:			Should be one of
-				"mediatek,mt2701-nfc",
-				"mediatek,mt2712-nfc",
-				"mediatek,mt7622-nfc".
-- reg:				Base physical address and size of NFI.
-- interrupts:			Interrupts of NFI.
-- clocks:			NFI required clocks.
-- clock-names:			NFI clocks internal name.
-- ecc-engine:			Required ECC Engine node.
-- #address-cells:		NAND chip index, should be 1.
-- #size-cells:			Should be 0.
-
-Example:
-
-	nandc: nfi@1100d000 {
-		compatible = "mediatek,mt2701-nfc";
-		reg = <0 0x1100d000 0 0x1000>;
-		interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_LOW>;
-		clocks = <&pericfg CLK_PERI_NFI>,
-			 <&pericfg CLK_PERI_NFI_PAD>;
-		clock-names = "nfi_clk", "pad_clk";
-		ecc-engine = <&bch>;
-		#address-cells = <1>;
-		#size-cells = <0>;
-        };
-
-Platform related properties, should be set in {platform_name}.dts:
-- children nodes:	NAND chips.
-
-Children nodes properties:
-- reg:			Chip Select Signal, default 0.
-			Set as reg = <0>, <1> when need 2 CS.
-Optional:
-- nand-on-flash-bbt:	Store BBT on NAND Flash.
-- nand-ecc-mode:	the NAND ecc mode (check driver for supported modes)
-- nand-ecc-step-size:	Number of data bytes covered by a single ECC step.
-			valid values:
-			512 and 1024 on mt2701 and mt2712.
-			512 only on mt7622.
-			1024 is recommended for large page NANDs.
-- nand-ecc-strength:	Number of bits to correct per ECC step.
-			The valid values that each controller supports:
-			mt2701: 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28,
-				32, 36, 40, 44, 48, 52, 56, 60.
-			mt2712: 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28,
-				32, 36, 40, 44, 48, 52, 56, 60, 68, 72, 80.
-			mt7622: 4, 6, 8, 10, 12, 14, 16.
-			The strength should be calculated as follows:
-			E = (S - F) * 8 / B
-			S = O / (P / Q)
-				E :	nand-ecc-strength.
-				S :	spare size per sector.
-				F :	FDM size, should be in the range [1,8].
-					It is used to store free oob data.
-				O :	oob size.
-				P :	page size.
-				Q :	nand-ecc-step-size.
-				B :	number of parity bits needed to correct
-					1 bitflip.
-					According to MTK NAND controller design,
-					this number depends on max ecc step size
-					that MTK NAND controller supports.
-					If max ecc step size supported is 1024,
-					then it should be always 14. And if max
-					ecc step size is 512, then it should be
-					always 13.
-			If the result does not match any one of the listed
-			choices above, please select the smaller valid value from
-			the list.
-			(otherwise the driver will do the adjustment at runtime)
-- pinctrl-names:	Default NAND pin GPIO setting name.
-- pinctrl-0:		GPIO setting node.
-
-Example:
-	&pio {
-		nand_pins_default: nanddefault {
-			pins_dat {
-				pinmux = <MT2701_PIN_111_MSDC0_DAT7__FUNC_NLD7>,
-					 <MT2701_PIN_112_MSDC0_DAT6__FUNC_NLD6>,
-					 <MT2701_PIN_114_MSDC0_DAT4__FUNC_NLD4>,
-					 <MT2701_PIN_118_MSDC0_DAT3__FUNC_NLD3>,
-					 <MT2701_PIN_121_MSDC0_DAT0__FUNC_NLD0>,
-					 <MT2701_PIN_120_MSDC0_DAT1__FUNC_NLD1>,
-					 <MT2701_PIN_113_MSDC0_DAT5__FUNC_NLD5>,
-					 <MT2701_PIN_115_MSDC0_RSTB__FUNC_NLD8>,
-					 <MT2701_PIN_119_MSDC0_DAT2__FUNC_NLD2>;
-				input-enable;
-				drive-strength = <MTK_DRIVE_8mA>;
-				bias-pull-up;
-			};
-
-			pins_we {
-				pinmux = <MT2701_PIN_117_MSDC0_CLK__FUNC_NWEB>;
-				drive-strength = <MTK_DRIVE_8mA>;
-				bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
-			};
-
-			pins_ale {
-				pinmux = <MT2701_PIN_116_MSDC0_CMD__FUNC_NALE>;
-				drive-strength = <MTK_DRIVE_8mA>;
-				bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
-			};
-		};
-	};
-
-	&nandc {
-		status = "okay";
-		pinctrl-names = "default";
-		pinctrl-0 = <&nand_pins_default>;
-		nand@0 {
-			reg = <0>;
-			nand-on-flash-bbt;
-			nand-ecc-mode = "hw";
-			nand-ecc-strength = <24>;
-			nand-ecc-step-size = <1024>;
-		};
-	};
-
-NAND chip optional subnodes:
-- Partitions, see Documentation/devicetree/bindings/mtd/mtd.yaml
-
-Example:
-	nand@0 {
-		partitions {
-			compatible = "fixed-partitions";
-			#address-cells = <1>;
-			#size-cells = <1>;
-
-			preloader@0 {
-				label = "pl";
-				read-only;
-				reg = <0x00000000 0x00400000>;
-			};
-			android@00400000 {
-				label = "android";
-				reg = <0x00400000 0x12c00000>;
-			};
-		};
-	};
-
-2) ECC Engine:
-==============
-
-Required BCH properties:
-- compatible:	Should be one of
-		"mediatek,mt2701-ecc",
-		"mediatek,mt2712-ecc",
-		"mediatek,mt7622-ecc".
-- reg:		Base physical address and size of ECC.
-- interrupts:	Interrupts of ECC.
-- clocks:	ECC required clocks.
-- clock-names:	ECC clocks internal name.
-
-Example:
-
-	bch: ecc@1100e000 {
-		compatible = "mediatek,mt2701-ecc";
-		reg = <0 0x1100e000 0 0x1000>;
-		interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_LOW>;
-		clocks = <&pericfg CLK_PERI_NFI_ECC>;
-		clock-names = "nfiecc_clk";
-	};
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v5 08/10] arm64: dts: mediatek: Fix existing NAND controller node name
  2022-12-19  2:40 [PATCH v5 00/10] Add MediaTek MT7986 SPI NAND and ECC support Xiangsheng Hou
                   ` (6 preceding siblings ...)
  2022-12-19  2:40 ` [PATCH v5 07/10] dt-bindings: mtd: Split ECC engine with rawnand controller Xiangsheng Hou
@ 2022-12-19  2:40 ` Xiangsheng Hou
  2022-12-19  2:40 ` [PATCH v5 09/10] arm: " Xiangsheng Hou
  2022-12-19  2:40 ` [PATCH v5 10/10] dt-bindings: mtd: mediatek,nand-ecc-engine: Add compatible for MT7986 Xiangsheng Hou
  9 siblings, 0 replies; 16+ messages in thread
From: Xiangsheng Hou @ 2022-12-19  2:40 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger, Mark Brown,
	Chuanhong Guo
  Cc: Xiangsheng Hou, linux-mtd, devicetree, linux-arm-kernel,
	linux-mediatek, linux-kernel, linux-spi, benliang.zhao, bin.zhang,
	AngeloGioacchino Del Regno

Change the existing node name in order to match NAND controller DT
bindings.

Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 2 +-
 arch/arm64/boot/dts/mediatek/mt7622.dtsi  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
index 92212cddd37e..cfbec2a2ed9d 100644
--- a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
@@ -560,7 +560,7 @@ spi0: spi@1100a000 {
 		status = "disabled";
 	};
 
-	nandc: nfi@1100e000 {
+	nandc: nand-controller@1100e000 {
 		compatible = "mediatek,mt2712-nfc";
 		reg = <0 0x1100e000 0 0x1000>;
 		interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>;
diff --git a/arch/arm64/boot/dts/mediatek/mt7622.dtsi b/arch/arm64/boot/dts/mediatek/mt7622.dtsi
index 146e18b5b1f4..d98aa4936092 100644
--- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi
@@ -539,7 +539,7 @@ bluetooth {
 		};
 	};
 
-	nandc: nfi@1100d000 {
+	nandc: nand-controller@1100d000 {
 		compatible = "mediatek,mt7622-nfc";
 		reg = <0 0x1100D000 0 0x1000>;
 		interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v5 09/10] arm: dts: mediatek: Fix existing NAND controller node name
  2022-12-19  2:40 [PATCH v5 00/10] Add MediaTek MT7986 SPI NAND and ECC support Xiangsheng Hou
                   ` (7 preceding siblings ...)
  2022-12-19  2:40 ` [PATCH v5 08/10] arm64: dts: mediatek: Fix existing NAND controller node name Xiangsheng Hou
@ 2022-12-19  2:40 ` Xiangsheng Hou
  2022-12-19  2:40 ` [PATCH v5 10/10] dt-bindings: mtd: mediatek,nand-ecc-engine: Add compatible for MT7986 Xiangsheng Hou
  9 siblings, 0 replies; 16+ messages in thread
From: Xiangsheng Hou @ 2022-12-19  2:40 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger, Mark Brown,
	Chuanhong Guo
  Cc: Xiangsheng Hou, linux-mtd, devicetree, linux-arm-kernel,
	linux-mediatek, linux-kernel, linux-spi, benliang.zhao, bin.zhang,
	AngeloGioacchino Del Regno

Change the existing node name in order to match NAND controller DT
bindings.

Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 arch/arm/boot/dts/mt2701.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
index b8eba3ba153c..049ed797766b 100644
--- a/arch/arm/boot/dts/mt2701.dtsi
+++ b/arch/arm/boot/dts/mt2701.dtsi
@@ -360,7 +360,7 @@ thermal: thermal@1100b000 {
 		mediatek,apmixedsys = <&apmixedsys>;
 	};
 
-	nandc: nfi@1100d000 {
+	nandc: nand-controller@1100d000 {
 		compatible = "mediatek,mt2701-nfc";
 		reg = <0 0x1100d000 0 0x1000>;
 		interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_LOW>;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v5 10/10] dt-bindings: mtd: mediatek,nand-ecc-engine: Add compatible for MT7986
  2022-12-19  2:40 [PATCH v5 00/10] Add MediaTek MT7986 SPI NAND and ECC support Xiangsheng Hou
                   ` (8 preceding siblings ...)
  2022-12-19  2:40 ` [PATCH v5 09/10] arm: " Xiangsheng Hou
@ 2022-12-19  2:40 ` Xiangsheng Hou
  9 siblings, 0 replies; 16+ messages in thread
From: Xiangsheng Hou @ 2022-12-19  2:40 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger, Mark Brown,
	Chuanhong Guo
  Cc: Xiangsheng Hou, linux-mtd, devicetree, linux-arm-kernel,
	linux-mediatek, linux-kernel, linux-spi, benliang.zhao, bin.zhang,
	Krzysztof Kozlowski

Add dt-bindings documentation of ECC for MediaTek MT7986 SoC
platform.

Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 .../devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml        | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml b/Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml
index b13d801eda76..505baf1e8830 100644
--- a/Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml
+++ b/Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml
@@ -18,6 +18,7 @@ properties:
       - mediatek,mt2701-ecc
       - mediatek,mt2712-ecc
       - mediatek,mt7622-ecc
+      - mediatek,mt7986-ecc
 
   reg:
     items:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v5 01/10] spi: mtk-snfi: Change default page format to setup default setting
  2022-12-19  2:40 ` [PATCH v5 01/10] spi: mtk-snfi: Change default page format to setup default setting Xiangsheng Hou
@ 2022-12-19 15:30   ` Matthias Brugger
  2022-12-20  2:15     ` Xiangsheng Hou (侯祥胜)
  0 siblings, 1 reply; 16+ messages in thread
From: Matthias Brugger @ 2022-12-19 15:30 UTC (permalink / raw)
  To: Xiangsheng Hou, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski, Mark Brown,
	Chuanhong Guo
  Cc: linux-mtd, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel, linux-spi, benliang.zhao, bin.zhang

Thanks for your patch! There is something to improve please see below.

On 19/12/2022 03:40, Xiangsheng Hou wrote:
> Change default page format to setup default setting since the sector
> size 1024 on MT7986 will lead to probe fail.
> 
> Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
> ---
>   drivers/spi/spi-mtk-snfi.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi-mtk-snfi.c b/drivers/spi/spi-mtk-snfi.c
> index fa8412ba20e2..719fc6f53ab1 100644
> --- a/drivers/spi/spi-mtk-snfi.c
> +++ b/drivers/spi/spi-mtk-snfi.c
> @@ -1430,8 +1430,7 @@ static int mtk_snand_probe(struct platform_device *pdev)
>   
>   	// setup an initial page format for ops matching page_cache_op template
>   	// before ECC is called.
> -	ret = mtk_snand_setup_pagefmt(ms, ms->caps->sector_size,
> -				      ms->caps->spare_sizes[0]);
> +	ret = mtk_snand_setup_pagefmt(ms, SZ_2K, SZ_64);

Couldn't you just set sector_size in mt7986_snand_caps?

Regards,
Matthias


>   	if (ret) {
>   		dev_err(ms->dev, "failed to set initial page format\n");
>   		goto disable_clk;

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v5 06/10] dt-bindings: spi: mtk-snfi: Add read latch latency property
  2022-12-19  2:40 ` [PATCH v5 06/10] dt-bindings: spi: mtk-snfi: Add read latch latency property Xiangsheng Hou
@ 2022-12-19 15:38   ` Rob Herring
  2022-12-20  1:59     ` Xiangsheng Hou (侯祥胜)
  0 siblings, 1 reply; 16+ messages in thread
From: Rob Herring @ 2022-12-19 15:38 UTC (permalink / raw)
  To: Xiangsheng Hou
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Krzysztof Kozlowski, Matthias Brugger, Mark Brown, Chuanhong Guo,
	linux-mtd, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel, linux-spi, benliang.zhao, bin.zhang,
	Krzysztof Kozlowski, AngeloGioacchino Del Regno

On Mon, Dec 19, 2022 at 10:40:15AM +0800, Xiangsheng Hou wrote:
> Add mediatek,rx-latch-latency-ns property which adjust data read
> latch latency in the unit of nanoseconds.
> 
> Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
>  .../devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml         | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml b/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
> index bab23f1b11fd..1e5e89a693c3 100644
> --- a/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
> +++ b/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
> @@ -45,6 +45,9 @@ properties:
>      description: device-tree node of the accompanying ECC engine.
>      $ref: /schemas/types.yaml#/definitions/phandle
>  
> +  mediatek,rx-latch-latency-ns:
> +    description: Data read latch latency, unit is nanoseconds.

Doesn't the common 'rx-sample-delay-ns' work for you?

Rob

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v5 06/10] dt-bindings: spi: mtk-snfi: Add read latch latency property
  2022-12-19 15:38   ` Rob Herring
@ 2022-12-20  1:59     ` Xiangsheng Hou (侯祥胜)
  0 siblings, 0 replies; 16+ messages in thread
From: Xiangsheng Hou (侯祥胜) @ 2022-12-20  1:59 UTC (permalink / raw)
  To: robh@kernel.org
  Cc: miquel.raynal@bootlin.com, linux-mediatek@lists.infradead.org,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org,
	Benliang Zhao (赵本亮),
	krzysztof.kozlowski@linaro.org, broonie@kernel.org,
	linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	krzysztof.kozlowski+dt@linaro.org, matthias.bgg@gmail.com,
	Bin Zhang (章斌), gch981213@gmail.com,
	vigneshr@ti.com, angelogioacchino.delregno@collabora.com,
	richard@nod.at

Hi Rob,

On Mon, 2022-12-19 at 09:38 -0600, Rob Herring wrote:
> On Mon, Dec 19, 2022 at 10:40:15AM +0800, Xiangsheng Hou wrote:
> > Add mediatek,rx-latch-latency-ns property which adjust data read
> > latch latency in the unit of nanoseconds.
> > 
> > Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
> > Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > Reviewed-by: AngeloGioacchino Del Regno <
> > angelogioacchino.delregno@collabora.com>
> > ---
> >  .../devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml         | 3
> > +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/spi/mediatek,spi-
> > mtk-snfi.yaml b/Documentation/devicetree/bindings/spi/mediatek,spi-
> > mtk-snfi.yaml
> > index bab23f1b11fd..1e5e89a693c3 100644
> > --- a/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-
> > snfi.yaml
> > +++ b/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-
> > snfi.yaml
> > @@ -45,6 +45,9 @@ properties:
> >      description: device-tree node of the accompanying ECC engine.
> >      $ref: /schemas/types.yaml#/definitions/phandle
> >  
> > +  mediatek,rx-latch-latency-ns:
> > +    description: Data read latch latency, unit is nanoseconds.
> 
> Doesn't the common 'rx-sample-delay-ns' work for you?

The driver need two timing related parameter, one for sample delay
which have been used by rx-sample-delay-ns. Another is read latency,
just introduce this private timing property since the common spi-rx-
delay-us is microsecond in unit.

Thanks
XIangsheng Hou

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v5 01/10] spi: mtk-snfi: Change default page format to setup default setting
  2022-12-19 15:30   ` Matthias Brugger
@ 2022-12-20  2:15     ` Xiangsheng Hou (侯祥胜)
  2023-01-05 11:42       ` Xiangsheng Hou (侯祥胜)
  0 siblings, 1 reply; 16+ messages in thread
From: Xiangsheng Hou (侯祥胜) @ 2022-12-20  2:15 UTC (permalink / raw)
  To: miquel.raynal@bootlin.com, robh+dt@kernel.org, broonie@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, matthias.bgg@gmail.com,
	gch981213@gmail.com, vigneshr@ti.com, richard@nod.at
  Cc: linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
	linux-mtd@lists.infradead.org, devicetree@vger.kernel.org,
	Benliang Zhao (赵本亮),
	linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Bin Zhang (章斌)

Hi Matthias,

On Mon, 2022-12-19 at 16:30 +0100, Matthias Brugger wrote:
> Thanks for your patch! There is something to improve please see
> below.
> 
> On 19/12/2022 03:40, Xiangsheng Hou wrote:
> > Change default page format to setup default setting since the
> > sector
> > size 1024 on MT7986 will lead to probe fail.
> > 
> > Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
> > ---
> >   drivers/spi/spi-mtk-snfi.c | 3 +--
> >   1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/spi/spi-mtk-snfi.c b/drivers/spi/spi-mtk-
> > snfi.c
> > index fa8412ba20e2..719fc6f53ab1 100644
> > --- a/drivers/spi/spi-mtk-snfi.c
> > +++ b/drivers/spi/spi-mtk-snfi.c
> > @@ -1430,8 +1430,7 @@ static int mtk_snand_probe(struct
> > platform_device *pdev)
> >   
> >   	// setup an initial page format for ops matching page_cache_op
> > template
> >   	// before ECC is called.
> > -	ret = mtk_snand_setup_pagefmt(ms, ms->caps->sector_size,
> > -				      ms->caps->spare_sizes[0]);
> > +	ret = mtk_snand_setup_pagefmt(ms, SZ_2K, SZ_64);
> 
> Couldn't you just set sector_size in mt7986_snand_caps?

The function mtk_snand_setup_pagefmt need use page and OOB size of NAND
device to setup pagefmt.
The controller page size can support 512/1k/2k/4k..., the sector size
1k have been set in mt7986_snand_caps. However this will also lead to
fail in this function since the 1k page size will not be supported.
Just use page size 2k and OOB size 64 as default parameter since this
can be supported by all ICs with this controller.

Thanks
Xiangsheng Hou

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v5 01/10] spi: mtk-snfi: Change default page format to setup default setting
  2022-12-20  2:15     ` Xiangsheng Hou (侯祥胜)
@ 2023-01-05 11:42       ` Xiangsheng Hou (侯祥胜)
  0 siblings, 0 replies; 16+ messages in thread
From: Xiangsheng Hou (侯祥胜) @ 2023-01-05 11:42 UTC (permalink / raw)
  To: miquel.raynal@bootlin.com, mbrugger@suse.com, robh+dt@kernel.org,
	broonie@kernel.org, krzysztof.kozlowski+dt@linaro.org,
	matthias.bgg@gmail.com, gch981213@gmail.com, vigneshr@ti.com,
	angelogioacchino.delregno@collabora.com, richard@nod.at
  Cc: linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
	linux-mtd@lists.infradead.org, devicetree@vger.kernel.org,
	Benliang Zhao (赵本亮),
	linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Bin Zhang (章斌)

On Tue, 2022-12-20 at 10:15 +0800, xiangsheng.hou wrote:
Hi Matthias, Angelo
> 
> On Mon, 2022-12-19 at 16:30 +0100, Matthias Brugger wrote:
> > Thanks for your patch! There is something to improve please see
> > below.
> > 
> > On 19/12/2022 03:40, Xiangsheng Hou wrote:
> > > Change default page format to setup default setting since the
> > > sector
> > > size 1024 on MT7986 will lead to probe fail.
> > > 
> > > Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
> > > ---
> > >   drivers/spi/spi-mtk-snfi.c | 3 +--
> > >   1 file changed, 1 insertion(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/spi/spi-mtk-snfi.c b/drivers/spi/spi-mtk-
> > > snfi.c
> > > index fa8412ba20e2..719fc6f53ab1 100644
> > > --- a/drivers/spi/spi-mtk-snfi.c
> > > +++ b/drivers/spi/spi-mtk-snfi.c
> > > @@ -1430,8 +1430,7 @@ static int mtk_snand_probe(struct
> > > platform_device *pdev)
> > >   
> > >   	// setup an initial page format for ops matching
> > > page_cache_op
> > > template
> > >   	// before ECC is called.
> > > -	ret = mtk_snand_setup_pagefmt(ms, ms->caps->sector_size,
> > > -				      ms->caps->spare_sizes[0]);
> > > +	ret = mtk_snand_setup_pagefmt(ms, SZ_2K, SZ_64);
> > 
> > Couldn't you just set sector_size in mt7986_snand_caps?
> 
> The function mtk_snand_setup_pagefmt need use page and OOB size of
> NAND
> device to setup pagefmt.
> The controller page size can support 512/1k/2k/4k..., the sector size
> 1k have been set in mt7986_snand_caps. However this will also lead to
> fail in this function since the 1k page size will not be supported.
> Just use page size 2k and OOB size 64 as default parameter since this
> can be supported by all ICs with this controller.

Could you please help to review this patch.

Best Regards,
Xiangsheng Hou

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-01-05 11:42 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-19  2:40 [PATCH v5 00/10] Add MediaTek MT7986 SPI NAND and ECC support Xiangsheng Hou
2022-12-19  2:40 ` [PATCH v5 01/10] spi: mtk-snfi: Change default page format to setup default setting Xiangsheng Hou
2022-12-19 15:30   ` Matthias Brugger
2022-12-20  2:15     ` Xiangsheng Hou (侯祥胜)
2023-01-05 11:42       ` Xiangsheng Hou (侯祥胜)
2022-12-19  2:40 ` [PATCH v5 02/10] spi: mtk-snfi: Add optional nfi_hclk which is needed for MT7986 Xiangsheng Hou
2022-12-19  2:40 ` [PATCH v5 03/10] mtd: nand: ecc-mtk: Add ECC support fot MT7986 IC Xiangsheng Hou
2022-12-19  2:40 ` [PATCH v5 04/10] dt-bindings: spi: mtk-snfi: Add compatible for MT7986 Xiangsheng Hou
2022-12-19  2:40 ` [PATCH v5 05/10] spi: mtk-snfi: Add snfi sample delay and read latency adjustment Xiangsheng Hou
2022-12-19  2:40 ` [PATCH v5 06/10] dt-bindings: spi: mtk-snfi: Add read latch latency property Xiangsheng Hou
2022-12-19 15:38   ` Rob Herring
2022-12-20  1:59     ` Xiangsheng Hou (侯祥胜)
2022-12-19  2:40 ` [PATCH v5 07/10] dt-bindings: mtd: Split ECC engine with rawnand controller Xiangsheng Hou
2022-12-19  2:40 ` [PATCH v5 08/10] arm64: dts: mediatek: Fix existing NAND controller node name Xiangsheng Hou
2022-12-19  2:40 ` [PATCH v5 09/10] arm: " Xiangsheng Hou
2022-12-19  2:40 ` [PATCH v5 10/10] dt-bindings: mtd: mediatek,nand-ecc-engine: Add compatible for MT7986 Xiangsheng Hou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).