Skip to contentSkip to conversation

spi: add support for Mediatek SPI-NAND controller

PATCH RESEND Superseded Chuanhong Guo 3 participants 8 messages Apr 3, 2022

Subsystems (6)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover spi: add support for Mediatek SPI-NAND controller

Mediatek has an extended version of their NAND Flash Interface which has a SPI-NAND mode. In this mode, the controller can perform 1-bit spi-mem ops for up-to 0xa0 bytes and typical SPI-NAND single, dual and quad IO page cache ops with 2-byte address. Additionally, the page cache ops can be performed with ECC and auto data formatting using the ECC engine of the controller.

This patchset implements support of this mode as a separated SPI-MEM driver with piplined ECC engine.

Chuanhong Guo (4):
mtd: nand: make mtk_ecc.c a separated module
spi: add driver for MTK SPI NAND Flash Interface
dt-bindings: spi: add binding doc for spi-mtk-snfi
arm64: dts: mediatek: add dt node for MTK SNFI

 .../bindings/spi/mediatek,spi-mtk-snfi.yaml   |   87 ++
 arch/arm64/boot/dts/mediatek/mt7622.dtsi      |   12 +
 drivers/mtd/nand/Kconfig                      |    7 +
 drivers/mtd/nand/Makefile                     |    1 +
 drivers/mtd/nand/{raw/mtk_ecc.c => ecc-mtk.c} |    3 +-
 drivers/mtd/nand/raw/Kconfig                  |    1 +
 drivers/mtd/nand/raw/Makefile                 |    2 +-
 drivers/mtd/nand/raw/mtk_nand.c               |    2 +-
 drivers/spi/Kconfig                           |   10 +
 drivers/spi/Makefile                          |    1 +
 drivers/spi/spi-mtk-snfi.c                    | 1356 +++++++++++++++++
 .../linux/mtd/nand-ecc-mtk.h                  |    0
 12 files changed, 1478 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
 rename drivers/mtd/nand/{raw/mtk_ecc.c => ecc-mtk.c} (99%)
 create mode 100644 drivers/spi/spi-mtk-snfi.c
 rename drivers/mtd/nand/raw/mtk_ecc.h => include/linux/mtd/nand-ecc-mtk.h (100%)
Signature · 1 line
2.35.1
#1 lore raw

PATCH RESEND 1/4 mtd: nand: make mtk_ecc.c a separated module

this code will be used in mediatek snfi spi-mem controller with pipelined ECC engine.

---
 drivers/mtd/nand/Kconfig                                   | 7 +++++++
 drivers/mtd/nand/Makefile                                  | 1 +
 drivers/mtd/nand/{raw/mtk_ecc.c => ecc-mtk.c}              | 3 +--
 drivers/mtd/nand/raw/Kconfig                               | 1 +
 drivers/mtd/nand/raw/Makefile                              | 2 +-
 drivers/mtd/nand/raw/mtk_nand.c                            | 2 +-
 .../nand/raw/mtk_ecc.h => include/linux/mtd/nand-ecc-mtk.h | 0
 7 files changed, 12 insertions(+), 4 deletions(-)
 rename drivers/mtd/nand/{raw/mtk_ecc.c => ecc-mtk.c} (99%)
 rename drivers/mtd/nand/raw/mtk_ecc.h => include/linux/mtd/nand-ecc-mtk.h (100%)
drivers/mtd/nand/Kconfig +7 -0
index 9b249826ef93..39df4621ac25 100644
@@ -53,6 +53,13 @@ config MTD_NAND_ECC_MXIC
 	help
 	  This enables support for the hardware ECC engine from Macronix.
 
+config MTD_NAND_ECC_MEDIATEK
+	bool "Mediatek hardware ECC engine"
+	depends on HAS_IOMEM
+	select MTD_NAND_ECC
+	help
+	  This enables support for the hardware ECC engine from Mediatek.
+
 endmenu
 
 endmenu
drivers/mtd/nand/Makefile +1 -0
index a4e6b7ae0614..e5f40ed9300f 100644
@@ -11,3 +11,4 @@ nandcore-$(CONFIG_MTD_NAND_ECC) += ecc.o
 nandcore-$(CONFIG_MTD_NAND_ECC_SW_HAMMING) += ecc-sw-hamming.o
 nandcore-$(CONFIG_MTD_NAND_ECC_SW_BCH) += ecc-sw-bch.o
 nandcore-$(CONFIG_MTD_NAND_ECC_MXIC) += ecc-mxic.o
+nandcore-$(CONFIG_MTD_NAND_ECC_MEDIATEK) += ecc-mtk.o
drivers/mtd/nand/ecc-mtk.c renamed from drivers/mtd/nand/raw/mtk_ecc.c +1 -2
similarity index 99%
rename from drivers/mtd/nand/raw/mtk_ecc.c
rename to drivers/mtd/nand/ecc-mtk.c
index 49ab3448b9b1..74ddaa46ba7c 100644
@@ -15,8 +15,7 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/mutex.h>
-
-#include "mtk_ecc.h"
+#include <linux/mtd/nand-ecc-mtk.h>
 
 #define ECC_IDLE_MASK		BIT(0)
 #define ECC_IRQ_EN		BIT(0)
drivers/mtd/nand/raw/Kconfig +1 -0
index 9b078e78f3fa..8b6d7a515445 100644
@@ -374,6 +374,7 @@ config MTD_NAND_QCOM
 
 config MTD_NAND_MTK
 	tristate "MTK NAND controller"
+	depends on MTD_NAND_ECC_MEDIATEK
 	depends on ARCH_MEDIATEK || COMPILE_TEST
 	depends on HAS_IOMEM
 	help
drivers/mtd/nand/raw/Makefile +1 -1
index 88a566513c56..fa1d00120310 100644
@@ -48,7 +48,7 @@ obj-$(CONFIG_MTD_NAND_SUNXI)		+= sunxi_nand.o
 obj-$(CONFIG_MTD_NAND_HISI504)	        += hisi504_nand.o
 obj-$(CONFIG_MTD_NAND_BRCMNAND)		+= brcmnand/
 obj-$(CONFIG_MTD_NAND_QCOM)		+= qcom_nandc.o
-obj-$(CONFIG_MTD_NAND_MTK)		+= mtk_ecc.o mtk_nand.o
+obj-$(CONFIG_MTD_NAND_MTK)		+= mtk_nand.o
 obj-$(CONFIG_MTD_NAND_MXIC)		+= mxic_nand.o
 obj-$(CONFIG_MTD_NAND_TEGRA)		+= tegra_nand.o
 obj-$(CONFIG_MTD_NAND_STM32_FMC2)	+= stm32_fmc2_nand.o
drivers/mtd/nand/raw/mtk_nand.c +1 -1
index 66f04c693c87..d540454cbbdf 100644
@@ -17,7 +17,7 @@
 #include <linux/iopoll.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include "mtk_ecc.h"
+#include <linux/mtd/nand-ecc-mtk.h>
 
 /* NAND controller register definition */
 #define NFI_CNFG		(0x00)
include/linux/mtd/nand-ecc-mtk.h renamed from drivers/mtd/nand/raw/mtk_ecc.h +0 -0
similarity index 100%
rename from drivers/mtd/nand/raw/mtk_ecc.h
rename to include/linux/mtd/nand-ecc-mtk.h
Signature · 1 line
2.35.1
#3 lore raw

PATCH RESEND 2/4 spi: add driver for MTK SPI NAND Flash Interface

In reply to Chuanhong Guo

This driver implements support for the SPI-NAND mode of MTK NAND Flash Interface as a SPI-MEM controller with piplined ECC capability.

---
 drivers/spi/Kconfig        |   10 +
 drivers/spi/Makefile       |    1 +
 drivers/spi/spi-mtk-snfi.c | 1356 ++++++++++++++++++++++++++++++++++++
 3 files changed, 1367 insertions(+)
 create mode 100644 drivers/spi/spi-mtk-snfi.c
drivers/spi/Kconfig +10 -0
index d2815eb361c0..739eec7d0c15 100644
@@ -590,6 +590,16 @@ config SPI_MTK_NOR
 	  SPI interface as well as several SPI NOR specific instructions
 	  via SPI MEM interface.
 
+config SPI_MTK_SNFI
+	tristate "MediaTek SPI NAND Flash Interface"
+	depends on ARCH_MEDIATEK || COMPILE_TEST
+	depends on MTD_NAND_ECC_MEDIATEK
+	help
+	  This enables support for SPI-NAND mode on the MediaTek NAND
+	  Flash Interface found on MediaTek ARM SoCs. This controller
+	  is implemented as a SPI-MEM controller with pipelined ECC
+	  capcability.
+
 config SPI_NPCM_FIU
 	tristate "Nuvoton NPCM FLASH Interface Unit"
 	depends on ARCH_NPCM || COMPILE_TEST
drivers/spi/Makefile +1 -0
index 3aa28ed3f761..51541ff17e67 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_SPI_MPC52xx)		+= spi-mpc52xx.o
 obj-$(CONFIG_SPI_MT65XX)                += spi-mt65xx.o
 obj-$(CONFIG_SPI_MT7621)		+= spi-mt7621.o
 obj-$(CONFIG_SPI_MTK_NOR)		+= spi-mtk-nor.o
+obj-$(CONFIG_SPI_MTK_SNFI)		+= spi-mtk-snfi.o
 obj-$(CONFIG_SPI_MXIC)			+= spi-mxic.o
 obj-$(CONFIG_SPI_MXS)			+= spi-mxs.o
 obj-$(CONFIG_SPI_NPCM_FIU)		+= spi-npcm-fiu.o
drivers/spi/spi-mtk-snfi.c new file +1356 -0

1,356 lines not on this page · raw message

Signature · 1 line
2.35.1
#5 lore raw

PATCH RESEND 3/4 dt-bindings: spi: add binding doc for spi-mtk-snfi

In reply to Chuanhong Guo

Add device-tree binding documentation for Mediatek SPI-NAND Flash Interface.

---
 .../bindings/spi/mediatek,spi-mtk-snfi.yaml   | 87 +++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml new file +87 -0
new file mode 100644
index 000000000000..166c6b50b9d1
@@ -0,0 +1,87 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/spi/mediatek,spi-mtk-snfi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SPI-NAND flash controller for MediaTek ARM SoCs
+
+maintainers:
+  - Chuanhong Guo <[email protected]>
+
+description: |
+  The Mediatek SPI-NAND flash controller is an extended version of
+  the Mediatek NAND flash controller. It can perform standard SPI
+  instructions with one continuous write and one read for up-to 0xa0
+  bytes. It also supports typical SPI-NAND page cache operations
+  in single, dual or quad IO mode with piplined ECC encoding/decoding
+  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
+  reg:
+    items:
+      - description: core registers
+
+  interrupts:
+    items:
+      - description: NFI interrupt
+
+  clocks:
+    items:
+      - description: clock used for the controller
+      - description: clock used for the SPI bus
+
+  clock-names:
+    items:
+      - const: nfi_clk
+      - const: pad_clk
+
+  ecc-engine:
+    description: device-tree node of the accompanying ECC engine.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - ecc-engine
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/mt7622-clk.h>
+    soc {
+      #address-cells = <2>;
+      #size-cells = <2>;
+      snfi: spi@1100d000 {
+        compatible = "mediatek,mt7622-snand";
+        reg = <0 0x1100d000 0 0x1000>;
+        interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>;
+        clocks = <&pericfg CLK_PERI_NFI_PD>, <&pericfg CLK_PERI_SNFI_PD>;
+        clock-names = "nfi_clk", "pad_clk";
+        ecc-engine = <&bch>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        flash@0 {
+          compatible = "spi-nand";
+          reg = <0>;
+          spi-tx-bus-width = <4>;
+          spi-rx-bus-width = <4>;
+          nand-ecc-engine = <&snfi>;
+        };
+      };
+    };
Signature · 1 line
2.35.1
#7 lore raw

PATCH RESEND 4/4 arm64: dts: mediatek: add dt node for MTK SNFI

In reply to Chuanhong Guo

This patch adds a device-tree node for the MTK SPI-NAND Flash Interface.

---
 arch/arm64/boot/dts/mediatek/mt7622.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/mediatek/mt7622.dtsi +12 -0
index 6f8cb3ad1e84..40112fdca67e 100644
@@ -545,6 +545,18 @@ nandc: nfi@1100d000 {
 		status = "disabled";
 	};
 
+	snfi: spi@1100d000 {
+		compatible = "mediatek,mt7622-snand";
+		reg = <0 0x1100d000 0 0x1000>;
+		interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>;
+		clocks = <&pericfg CLK_PERI_NFI_PD>, <&pericfg CLK_PERI_SNFI_PD>;
+		clock-names = "nfi_clk", "pad_clk";
+		ecc-engine = <&bch>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "disabled";
+	};
+
 	bch: ecc@1100e000 {
 		compatible = "mediatek,mt7622-ecc";
 		reg = <0 0x1100e000 0 0x1000>;
Signature · 1 line
2.35.1
#4 lore raw

Re: [PATCH resend 2/4] spi: add driver for MTK SPI NAND Flash Interface

In reply to Chuanhong Guo
Thank you for the patch! Yet something to improve:

Hi Chuanhong,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20220401]
[cannot apply to mtd/nand/next broonie-spi/for-next robh/for-next v5.17 v5.17-rc8 v5.17-rc7 v5.17] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Chuanhong-Guo/spi-add-support-for-Mediatek-SPI-NAND-controller/20220403-211703
base:    e5071887cd2296a7704dbcd10c1cedf0f11cdbd5
config: mips-allmodconfig (https://download.01.org/0day-ci/archive/20220404/[email protected]/config)
compiler: mips-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/42beed649ed9c6674bdb176691f10365f093a82d
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Chuanhong-Guo/spi-add-support-for-Mediatek-SPI-NAND-controller/20220403-211703 git checkout 42beed649ed9c6674bdb176691f10365f093a82d
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=mips SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

All error/warnings (new ones prefixed by >>):

In file included from include/linux/printk.h:555,

                    from include/linux/kernel.h:29,
                    from drivers/spi/spi-mtk-snfi.c:70:
   drivers/spi/spi-mtk-snfi.c: In function 'mtk_snand_mac_io':
>> drivers/spi/spi-mtk-snfi.c:499:27: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
     499 |         dev_dbg(snf->dev, "SNF TX: %lu RX: %lu", reg_offs, rx_len);
         |                           ^~~~~~~~~~~~~~~~~~~~~
   include/linux/dynamic_debug.h:134:29: note: in definition of macro '__dynamic_func_call'
     134 |                 func(&id, ##__VA_ARGS__);               \
         |                             ^~~~~~~~~~~
   include/linux/dynamic_debug.h:166:9: note: in expansion of macro '_dynamic_func_call'
     166 |         _dynamic_func_call(fmt,__dynamic_dev_dbg,               \
         |         ^~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:155:9: note: in expansion of macro 'dynamic_dev_dbg'
     155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~~~~~~~~
   include/linux/dev_printk.h:155:30: note: in expansion of macro 'dev_fmt'
     155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                              ^~~~~~~
   drivers/spi/spi-mtk-snfi.c:499:9: note: in expansion of macro 'dev_dbg'
     499 |         dev_dbg(snf->dev, "SNF TX: %lu RX: %lu", reg_offs, rx_len);
         |         ^~~~~~~
   drivers/spi/spi-mtk-snfi.c:499:38: note: format string is defined here
     499 |         dev_dbg(snf->dev, "SNF TX: %lu RX: %lu", reg_offs, rx_len);
         |                                    ~~^
         |                                      |
         |                                      long unsigned int
         |                                    %u
   In file included from include/linux/printk.h:555,
                    from include/linux/kernel.h:29,
                    from drivers/spi/spi-mtk-snfi.c:70:
   drivers/spi/spi-mtk-snfi.c:499:27: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
     499 |         dev_dbg(snf->dev, "SNF TX: %lu RX: %lu", reg_offs, rx_len);
         |                           ^~~~~~~~~~~~~~~~~~~~~
   include/linux/dynamic_debug.h:134:29: note: in definition of macro '__dynamic_func_call'
     134 |                 func(&id, ##__VA_ARGS__);               \
         |                             ^~~~~~~~~~~
   include/linux/dynamic_debug.h:166:9: note: in expansion of macro '_dynamic_func_call'
     166 |         _dynamic_func_call(fmt,__dynamic_dev_dbg,               \
         |         ^~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:155:9: note: in expansion of macro 'dynamic_dev_dbg'
     155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~~~~~~~~
   include/linux/dev_printk.h:155:30: note: in expansion of macro 'dev_fmt'
     155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                              ^~~~~~~
   drivers/spi/spi-mtk-snfi.c:499:9: note: in expansion of macro 'dev_dbg'
     499 |         dev_dbg(snf->dev, "SNF TX: %lu RX: %lu", reg_offs, rx_len);
         |         ^~~~~~~
   drivers/spi/spi-mtk-snfi.c:499:46: note: format string is defined here
     499 |         dev_dbg(snf->dev, "SNF TX: %lu RX: %lu", reg_offs, rx_len);
         |                                            ~~^
         |                                              |
         |                                              long unsigned int
         |                                            %u
   In file included from include/linux/device.h:15,
                    from drivers/spi/spi-mtk-snfi.c:73:
   drivers/spi/spi-mtk-snfi.c: In function 'mtk_snand_setup_pagefmt':
   drivers/spi/spi-mtk-snfi.c:619:27: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
     619 |         dev_err(snf->dev, "page size %lu+%lu is not supported\n", page_size,
         |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ^~~
   include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
     144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                        ^~~~~~~
   drivers/spi/spi-mtk-snfi.c:619:9: note: in expansion of macro 'dev_err'
     619 |         dev_err(snf->dev, "page size %lu+%lu is not supported\n", page_size,
         |         ^~~~~~~
   drivers/spi/spi-mtk-snfi.c:619:40: note: format string is defined here
     619 |         dev_err(snf->dev, "page size %lu+%lu is not supported\n", page_size,
         |                                      ~~^
         |                                        |
         |                                        long unsigned int
         |                                      %u
   In file included from include/linux/device.h:15,
                    from drivers/spi/spi-mtk-snfi.c:73:
   drivers/spi/spi-mtk-snfi.c:619:27: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
     619 |         dev_err(snf->dev, "page size %lu+%lu is not supported\n", page_size,
         |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ^~~
   include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
     144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                        ^~~~~~~
   drivers/spi/spi-mtk-snfi.c:619:9: note: in expansion of macro 'dev_err'
     619 |         dev_err(snf->dev, "page size %lu+%lu is not supported\n", page_size,
         |         ^~~~~~~
   drivers/spi/spi-mtk-snfi.c:619:44: note: format string is defined here
     619 |         dev_err(snf->dev, "page size %lu+%lu is not supported\n", page_size,
         |                                          ~~^
         |                                            |
         |                                            long unsigned int
         |                                          %u
--
>> drivers/spi/spi-mtk-snfi.c:728: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst

* swap [pagesize] byte on nand with the first fdm byte in the last sector.
drivers/spi/spi-mtk-snfi.c:748: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
* swap the first fdm byte in the first and the last sector.
drivers/spi/spi-mtk-snfi.c:1048: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
* Check whether op can be executed with read_from_cache or program_load
--
mips-linux-ld: drivers/mtd/nand/ecc-mtk.o: in function `mtk_ecc_driver_exit':

>> ecc-mtk.c:(.exit.text+0x0): multiple definition of `cleanup_module'; drivers/mtd/nand/ecc-mxic.o:ecc-mxic.c:(.exit.text+0x0): first defined here
   mips-linux-ld: drivers/mtd/nand/ecc-mtk.o: in function `mtk_ecc_driver_init':
>> ecc-mtk.c:(.init.text+0x0): multiple definition of `init_module'; drivers/mtd/nand/ecc-mxic.o:ecc-mxic.c:(.init.text+0x0): first defined here

vim +499 drivers/spi/spi-mtk-snfi.c

437
438 static int mtk_snand_mac_io(struct mtk_snand *snf, const struct spi_mem_op *op)
439 {
440 size_t rx_len = 0;
441 size_t reg_offs = 0;
442 u32 val = 0;
443 const u8 *tx_buf = NULL;
444 u8 *rx_buf = NULL;
445 int i, ret;
446 u8 b;
447
448 if (op->data.dir == SPI_MEM_DATA_IN) {
449 rx_len = op->data.nbytes;
450 rx_buf = op->data.buf.in;
451 } else {
452 tx_buf = op->data.buf.out;
453 }
454
455 mtk_snand_mac_reset(snf);
456
457 for (i = 0; i < op->cmd.nbytes; i++, reg_offs++) {
458 b = (op->cmd.opcode >> ((op->cmd.nbytes - i - 1) * 8)) & 0xff;
459 val |= b << (8 * (reg_offs % 4));
460 if (reg_offs % 4 == 3) {
461 nfi_write32(snf, SNF_GPRAM + reg_offs - 3, val);
462 val = 0;
463 }
464 }
465
466 for (i = 0; i < op->addr.nbytes; i++, reg_offs++) {
467 b = (op->addr.val >> ((op->addr.nbytes - i - 1) * 8)) & 0xff;
468 val |= b << (8 * (reg_offs % 4));
469 if (reg_offs % 4 == 3) {
470 nfi_write32(snf, SNF_GPRAM + reg_offs - 3, val);
471 val = 0;
472 }
473 }
474
475 for (i = 0; i < op->dummy.nbytes; i++, reg_offs++) {
476 if (reg_offs % 4 == 3) {
477 nfi_write32(snf, SNF_GPRAM + reg_offs - 3, val);
478 val = 0;
479 }
480 }
481
482 if (op->data.dir == SPI_MEM_DATA_OUT) {
483 for (i = 0; i < op->data.nbytes; i++, reg_offs++) {
484 val |= tx_buf[i] << (8 * (reg_offs % 4));
485 if (reg_offs % 4 == 3) {
486 nfi_write32(snf, SNF_GPRAM + reg_offs - 3, val);
487 val = 0;
488 }
489 }
490 }
491
492 if (reg_offs % 4 != 3)
493 nfi_write32(snf, SNF_GPRAM + (reg_offs & ~3), val);
494
495 for (i = 0; i < reg_offs; i += 4)
496 dev_dbg(snf->dev, "%d: %08X", i,
497 nfi_read32(snf, SNF_GPRAM + i));
498

 > 499		dev_dbg(snf->dev, "SNF TX: %lu RX: %lu", reg_offs, rx_len);

500
501 ret = mtk_snand_mac_trigger(snf, reg_offs, rx_len);
502 if (ret)
503 return ret;
504
505 if (!rx_len)
506 return 0;
507
508 nfi_read_data(snf, SNF_GPRAM + reg_offs, rx_buf, rx_len);
509 return 0;
510 }
511

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#2 lore raw

Re: [PATCH resend 1/4] mtd: nand: make mtk_ecc.c a separated module

In reply to Chuanhong Guo
Thank you for the patch! Yet something to improve:

Hi Chuanhong,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20220401]
[cannot apply to mtd/nand/next broonie-spi/for-next robh/for-next v5.17 v5.17-rc8 v5.17-rc7 v5.17] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Chuanhong-Guo/spi-add-support-for-Mediatek-SPI-NAND-controller/20220403-211703
base:    e5071887cd2296a7704dbcd10c1cedf0f11cdbd5
config: alpha-allmodconfig (https://download.01.org/0day-ci/archive/20220404/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/48656e578a2cec7121f79d875d14403f5b56096e
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Chuanhong-Guo/spi-add-support-for-Mediatek-SPI-NAND-controller/20220403-211703 git checkout 48656e578a2cec7121f79d875d14403f5b56096e
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

alpha-linux-ld: drivers/mtd/nand/ecc-mtk.o: in function `mtk_ecc_driver_exit':

>> ecc-mtk.o:(.exit.text+0x0): multiple definition of `cleanup_module'; drivers/mtd/nand/ecc-mxic.o:ecc-mxic.o:(.exit.text+0x0): first defined here
   alpha-linux-ld: drivers/mtd/nand/ecc-mtk.o: in function `mtk_ecc_driver_init':
>> ecc-mtk.o:(.init.text+0x0): multiple definition of `init_module'; drivers/mtd/nand/ecc-mxic.o:ecc-mxic.o:(.init.text+0x0): first defined here
Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp