Skip to contentSkip to conversation

Add add SPI-NAND Flash controller driver for EN7581

PATCH Superseded Lorenzo Bianconi 3 participants 8 messages Apr 17, 2024 – Apr 18, 2024

Subsystems (4)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Lorenzo Bianconi

author maintainer
#0 lore raw

v2 cover Add add SPI-NAND Flash controller driver for EN7581

Introduce support for SPI-NAND driver of the Airoha NAND Flash Interface found on Airoha ARM EN7581 SoCs.

Changes since v1:
- Introduce spi clock dependency

Lorenzo Bianconi (3):
dt-bindings: spi: airoha: Add YAML schema for SNFI controller
arm64: dts: airoha: add EN7581 spi-nand node
spi: airoha: add SPI-NAND Flash controller driver

 .../bindings/spi/airoha,en7581-snand.yaml     |   72 +
 MAINTAINERS                                   |    9 +
 arch/arm64/boot/dts/airoha/en7581.dtsi        |   21 +
 drivers/spi/Kconfig                           |   10 +
 drivers/spi/Makefile                          |    1 +
 drivers/spi/spi-airoha-snfi.c                 | 1155 +++++++++++++++++
 6 files changed, 1268 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml
 create mode 100644 drivers/spi/spi-airoha-snfi.c
Signature · 1 line
2.44.0
author maintainer
#1 lore raw

PATCH v2 1/3 dt-bindings: spi: airoha: Add YAML schema for SNFI controller

Introduce Airoha EN7581 SPI NAND controller binding

---
 .../bindings/spi/airoha,en7581-snand.yaml     | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml
Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml new file +72 -0
new file mode 100644
index 000000000000..b449bebba601
@@ -0,0 +1,72 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/spi/airoha,en7581-snand.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SPI-NAND flash controller for Airoha ARM SoCs
+
+maintainers:
+  - Lorenzo Bianconi <[email protected]>
+
+allOf:
+  - $ref: spi-controller.yaml#
+
+properties:
+  compatible:
+    const: airoha,en7581-snand
+
+  reg:
+    items:
+      - description: spi base address
+      - description: nfi2spi base address
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: spi
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/en7523-clk.h>
+
+    soc {
+      #address-cells = <2>;
+      #size-cells = <2>;
+
+      spi@1fa10000 {
+        compatible = "airoha,en7581-snand";
+        reg = <0x0 0x1fa10000 0x0 0x140>,
+              <0x0 0x1fa11000 0x0 0x160>;
+
+        clocks = <&scuclk EN7523_CLK_SPI>;
+        clock-names = "spi";
+
+        interrupts = <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        flash@0 {
+          compatible = "spi-nand";
+          reg = <0>;
+          spi-tx-bus-width = <1>;
+          spi-rx-bus-width = <2>;
+        };
+      };
+    };
Signature · 1 line
2.44.0
author maintainer
#3 lore raw

PATCH v2 2/3 arm64: dts: airoha: add EN7581 spi-nand node

In reply to Lorenzo Bianconi

Introduce the Airoha EN7581 spi-nand node in Airoha EN7581 dtsi

---
 arch/arm64/boot/dts/airoha/en7581.dtsi | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
arch/arm64/boot/dts/airoha/en7581.dtsi +21 -0
index 5c4bfe3e1e5a..8affe1c70c7a 100644
@@ -159,5 +159,26 @@ scuclk: clock-controller@1fa20000 {
 			      <0x0 0x1fbe3400 0x0 0xfc>;
 			#clock-cells = <1>;
 		};
+
+		snfi: spi@1fa10000 {
+			compatible = "airoha,en7581-snand";
+			reg = <0x0 0x1fa10000 0x0 0x140>,
+			      <0x0 0x1fa11000 0x0 0x160>;
+
+			clocks = <&scuclk EN7523_CLK_SPI>;
+			clock-names = "spi";
+
+			interrupts = <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>;
+
+			#address-cells = <1>;
+			#size-cells = <0>;
+			spi_nand: nand@0 {
+				compatible = "spi-nand";
+				reg = <0>;
+				spi-max-frequency = <50000000>;
+				spi-tx-bus-width = <1>;
+				spi-rx-bus-width = <2>;
+			};
+		};
 	};
 };
Signature · 1 line
2.44.0
author maintainer
#4 lore raw

PATCH v2 3/3 spi: airoha: add SPI-NAND Flash controller driver

In reply to Lorenzo Bianconi

Introduce support for SPI-NAND driver of the Airoha NAND Flash Interface found on Airoha ARM SoCs.

---
 MAINTAINERS                   |    9 +
 drivers/spi/Kconfig           |   10 +
 drivers/spi/Makefile          |    1 +
 drivers/spi/spi-airoha-snfi.c | 1155 +++++++++++++++++++++++++++++++++
 4 files changed, 1175 insertions(+)
 create mode 100644 drivers/spi/spi-airoha-snfi.c
MAINTAINERS +9 -0
index aa3b947fb080..f79bd24eb790 100644
@@ -653,6 +653,15 @@ S:	Supported
 F:	fs/aio.c
 F:	include/linux/*aio*.h
 
+AIROHA SPI SNFI DRIVER
+M:	Lorenzo Bianconi <[email protected]>
+M:	Ray Liu <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/spi/airoha,spi-airoha-snfi.yaml
+F:	drivers/spi/spi-airoha.c
+
 AIRSPY MEDIA DRIVER
 L:	[email protected]
 S:	Orphan
drivers/spi/Kconfig +10 -0
index bc7021da2fe9..6fa91775f334 100644
@@ -57,6 +57,16 @@ config SPI_MEM
 
 comment "SPI Master Controller Drivers"
 
+config SPI_AIROHA_SNFI
+	tristate "Airoha SPI NAND Flash Interface"
+	depends on ARCH_AIROHA || COMPILE_TEST
+	depends on SPI_MASTER
+	select REGMAP_MMIO
+	help
+	  This enables support for SPI-NAND mode on the Airoha NAND
+	  Flash Interface found on Airoha ARM SoCs. This controller
+	  is implemented as a SPI-MEM controller.
+
 config SPI_ALTERA
 	tristate "Altera SPI Controller platform driver"
 	select SPI_ALTERA_CORE
drivers/spi/Makefile +1 -0
index 4ff8d725ba5e..e694254dec04 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_SPI_SPIDEV)		+= spidev.o
 obj-$(CONFIG_SPI_LOOPBACK_TEST)		+= spi-loopback-test.o
 
 # SPI master controller drivers (bus)
+obj-$(CONFIG_SPI_AIROHA_SNFI)		+= spi-airoha-snfi.o
 obj-$(CONFIG_SPI_ALTERA)		+= spi-altera-platform.o
 obj-$(CONFIG_SPI_ALTERA_CORE)		+= spi-altera-core.o
 obj-$(CONFIG_SPI_ALTERA_DFL)		+= spi-altera-dfl.o
drivers/spi/spi-airoha-snfi.c new file +1155 -0

1,155 lines not on this page · raw message

Signature · 1 line
2.44.0
#5 lore raw

Re: [PATCH v2 3/3] spi: airoha: add SPI-NAND Flash controller driver

kernel test robot noticed the following build warnings:

Hi Lorenzo,

kernel test robot noticed the following build warnings:

[auto build test WARNING on next-20240416]
[cannot apply to broonie-spi/for-next robh/for-next arm/for-next arm/fixes arm64/for-next/core kvmarm/next rockchip/for-next shawnguo/for-next soc/for-next linus/master v6.9-rc4 v6.9-rc3 v6.9-rc2 v6.9-rc4] [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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Lorenzo-Bianconi/dt-bindings-spi-airoha-Add-YAML-schema-for-SNFI-controller/20240417-144847
base:   next-20240416
patch link:    https://lore.kernel.org/r/25dd4334e3b37eaa628c20265841f251968c2b75.1713335916.git.lorenzo%40kernel.org
patch subject: [PATCH v2 3/3] spi: airoha: add SPI-NAND Flash controller driver
reproduce: (https://download.01.org/0day-ci/archive/20240417/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

Documentation/userspace-api/netlink/netlink-raw.rst: :doc:tc<../../networking/netlink_spec/tc>
Warning: Documentation/devicetree/bindings/power/wakeup-source.txt references a file that doesn't exist: Documentation/devicetree/bindings/input/qcom,pm8xxx-keypad.txt
Warning: Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml references a file that doesn't exist: Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
Warning: Documentation/userspace-api/netlink/index.rst references a file that doesn't exist: Documentation/networking/netlink_spec/index.rst
Warning: Documentation/userspace-api/netlink/specs.rst references a file that doesn't exist: Documentation/networking/netlink_spec/index.rst

>> Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/spi/airoha,spi-airoha-snfi.yaml

Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/reserved-memory/qcom
Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/display/exynos/ Using alabaster theme

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#6 lore raw

Re: [PATCH v2 3/3] spi: airoha: add SPI-NAND Flash controller driver

In reply to Lorenzo Bianconi
kernel test robot noticed the following build errors:

Hi Lorenzo,

kernel test robot noticed the following build errors:

[auto build test ERROR on next-20240416]
[cannot apply to broonie-spi/for-next robh/for-next arm/for-next arm/fixes arm64/for-next/core kvmarm/next rockchip/for-next shawnguo/for-next soc/for-next linus/master v6.9-rc4 v6.9-rc3 v6.9-rc2 v6.9-rc4] [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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Lorenzo-Bianconi/dt-bindings-spi-airoha-Add-YAML-schema-for-SNFI-controller/20240417-144847
base:   next-20240416
patch link:    https://lore.kernel.org/r/25dd4334e3b37eaa628c20265841f251968c2b75.1713335916.git.lorenzo%40kernel.org
patch subject: [PATCH v2 3/3] spi: airoha: add SPI-NAND Flash controller driver
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20240418/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240418/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/spi/spi-airoha-snfi.c: In function 'airoha_snand_set_fifo_op':

>> drivers/spi/spi-airoha-snfi.c:233:28: error: implicit declaration of function 'FIELD_PREP' [-Werror=implicit-function-declaration]
     233 |                            FIELD_PREP(SPI_CTRL_OPFIFO_LEN, op_len) |
         |                            ^~~~~~~~~~
   drivers/spi/spi-airoha-snfi.c: In function 'airoha_snand_read_data_from_fifo':
>> drivers/spi/spi-airoha-snfi.c:320:26: error: implicit declaration of function 'FIELD_GET' [-Werror=implicit-function-declaration]
     320 |                 ptr[i] = FIELD_GET(SPI_CTRL_DFIFO_RDATA, val);
         |                          ^~~~~~~~~

cc1: some warnings being treated as errors

vim +/FIELD_PREP +233 drivers/spi/spi-airoha-snfi.c

225
226 static int airoha_snand_set_fifo_op(struct airoha_snand_ctrl *as_ctrl,
227 u8 op_cmd, int op_len)
228 {
229 int err;
230 u32 val;
231
232 err = regmap_write(as_ctrl->regmap_ctrl, REG_SPI_CTRL_OPFIFO_WDATA,

 > 233				   FIELD_PREP(SPI_CTRL_OPFIFO_LEN, op_len) |
   234				   FIELD_PREP(SPI_CTRL_OPFIFO_OP, op_cmd));
   235		if (err)
   236			return err;
   237	
   238		err = regmap_read_poll_timeout(as_ctrl->regmap_ctrl,
   239					       REG_SPI_CTRL_OPFIFO_FULL,
   240					       val, !(val & SPI_CTRL_OPFIFO_FULL),
   241					       0, 250 * USEC_PER_MSEC);
   242		if (err)
   243			return err;
   244	
   245		err = regmap_write(as_ctrl->regmap_ctrl, REG_SPI_CTRL_OPFIFO_WR,
   246				   SPI_CTRL_OPFIFO_WR);
   247		if (err)
   248			return err;
   249	
   250		return regmap_read_poll_timeout(as_ctrl->regmap_ctrl,
   251						REG_SPI_CTRL_OPFIFO_EMPTY,
   252						val, (val & SPI_CTRL_OPFIFO_EMPTY),
   253						0, 250 * USEC_PER_MSEC);
   254	}
   255	
   256	static int airoha_snand_set_cs(struct airoha_snand_ctrl *as_ctrl, u8 cs)
   257	{
   258		return airoha_snand_set_fifo_op(as_ctrl, cs, sizeof(cs));
   259	}
   260	
   261	static int airoha_snand_write_data_to_fifo(struct airoha_snand_ctrl *as_ctrl,
   262						   const u8 *data, int len)
   263	{
   264		int i;
   265	
   266		for (i = 0; i < len; i++) {
   267			int err;
   268			u32 val;
   269	
   270			/* 1. Wait until dfifo is not full */
   271			err = regmap_read_poll_timeout(as_ctrl->regmap_ctrl,
   272						       REG_SPI_CTRL_DFIFO_FULL, val,
   273						       !(val & SPI_CTRL_DFIFO_FULL),
   274						       0, 250 * USEC_PER_MSEC);
   275			if (err)
   276				return err;
   277	
   278			/* 2. Write data to register DFIFO_WDATA */
   279			err = regmap_write(as_ctrl->regmap_ctrl,
   280					   REG_SPI_CTRL_DFIFO_WDATA,
   281					   FIELD_PREP(SPI_CTRL_DFIFO_WDATA, data[i]));
   282			if (err)
   283				return err;
   284	
   285			/* 3. Wait until dfifo is not full */
   286			err = regmap_read_poll_timeout(as_ctrl->regmap_ctrl,
   287						       REG_SPI_CTRL_DFIFO_FULL, val,
   288						       !(val & SPI_CTRL_DFIFO_FULL),
   289						       0, 250 * USEC_PER_MSEC);
   290			if (err)
   291				return err;
   292		}
   293	
   294		return 0;
   295	}
   296	
   297	static int airoha_snand_read_data_from_fifo(struct airoha_snand_ctrl *as_ctrl,
   298						    u8 *ptr, int len)
   299	{
   300		int i;
   301	
   302		for (i = 0; i < len; i++) {
   303			int err;
   304			u32 val;
   305	
   306			/* 1. wait until dfifo is not empty */
   307			err = regmap_read_poll_timeout(as_ctrl->regmap_ctrl,
   308						       REG_SPI_CTRL_DFIFO_EMPTY, val,
   309						       !(val & SPI_CTRL_DFIFO_EMPTY),
   310						       0, 250 * USEC_PER_MSEC);
   311			if (err)
   312				return err;
   313	
   314			/* 2. read from dfifo to register DFIFO_RDATA */
   315			err = regmap_read(as_ctrl->regmap_ctrl,
   316					  REG_SPI_CTRL_DFIFO_RDATA, &val);
   317			if (err)
   318				return err;
   319	
 > 320			ptr[i] = FIELD_GET(SPI_CTRL_DFIFO_RDATA, val);

321 /* 3. enable register DFIFO_RD to read next byte */
322 err = regmap_write(as_ctrl->regmap_ctrl,
323 REG_SPI_CTRL_DFIFO_RD, SPI_CTRL_DFIFO_RD);
324 if (err)
325 return err;
326 }
327
328 return 0;
329 }
330

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#7 lore raw

Re: [PATCH v2 3/3] spi: airoha: add SPI-NAND Flash controller driver

In reply to Lorenzo Bianconi
kernel test robot noticed the following build errors:

Hi Lorenzo,

kernel test robot noticed the following build errors:

[auto build test ERROR on next-20240416]
[cannot apply to broonie-spi/for-next robh/for-next arm/for-next arm/fixes arm64/for-next/core kvmarm/next rockchip/for-next shawnguo/for-next soc/for-next linus/master v6.9-rc4 v6.9-rc3 v6.9-rc2 v6.9-rc4] [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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Lorenzo-Bianconi/dt-bindings-spi-airoha-Add-YAML-schema-for-SNFI-controller/20240417-144847
base:   next-20240416
patch link:    https://lore.kernel.org/r/25dd4334e3b37eaa628c20265841f251968c2b75.1713335916.git.lorenzo%40kernel.org
patch subject: [PATCH v2 3/3] spi: airoha: add SPI-NAND Flash controller driver
config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20240418/[email protected]/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 7089c359a3845323f6f30c44a47dd901f2edfe63)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240418/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from drivers/spi/spi-airoha-snfi.c:10:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:8:
In file included from include/linux/mm.h:2254:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]

     514 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from drivers/spi/spi-airoha-snfi.c:10:
   In file included from include/linux/dma-mapping.h:11:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     548 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     561 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   In file included from drivers/spi/spi-airoha-snfi.c:10:
   In file included from include/linux/dma-mapping.h:11:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     574 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   In file included from drivers/spi/spi-airoha-snfi.c:10:
   In file included from include/linux/dma-mapping.h:11:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     585 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     595 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     605 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
>> drivers/spi/spi-airoha-snfi.c:233:7: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     233 |                            FIELD_PREP(SPI_CTRL_OPFIFO_LEN, op_len) |
         |                            ^
   drivers/spi/spi-airoha-snfi.c:281:8: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     281 |                                    FIELD_PREP(SPI_CTRL_DFIFO_WDATA, data[i]));
         |                                    ^
>> drivers/spi/spi-airoha-snfi.c:320:12: error: call to undeclared function 'FIELD_GET'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     320 |                 ptr[i] = FIELD_GET(SPI_CTRL_DFIFO_RDATA, val);
         |                          ^
   drivers/spi/spi-airoha-snfi.c:487:9: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     487 |                 val = FIELD_PREP(SPI_NFI_SPARE_SIZE, 0x1);
         |                       ^
   drivers/spi/spi-airoha-snfi.c:507:9: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     507 |                 val = FIELD_PREP(SPI_NFI_PAGE_SIZE, 0x1);
         |                       ^
   drivers/spi/spi-airoha-snfi.c:523:8: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     523 |         val = FIELD_PREP(SPI_NFI_SEC_NUM, as_ctrl->nfi_cfg.sec_num);
         |               ^
   drivers/spi/spi-airoha-snfi.c:694:8: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     694 |         val = FIELD_PREP(SPI_NFI_READ_DATA_BYTE_NUM, val);
         |               ^
   drivers/spi/spi-airoha-snfi.c:819:8: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     819 |         val = FIELD_PREP(SPI_NFI_PROG_LOAD_BYTE_NUM, val);
         |               ^
   drivers/spi/spi-airoha-snfi.c:1034:12: error: call to undeclared function 'FIELD_GET'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    1034 |         sec_num = FIELD_GET(SPI_NFI_SEC_NUM, val);
         |                   ^

7 warnings and 9 errors generated.

vim +/FIELD_PREP +233 drivers/spi/spi-airoha-snfi.c

225
226 static int airoha_snand_set_fifo_op(struct airoha_snand_ctrl *as_ctrl,
227 u8 op_cmd, int op_len)
228 {
229 int err;
230 u32 val;
231
232 err = regmap_write(as_ctrl->regmap_ctrl, REG_SPI_CTRL_OPFIFO_WDATA,

 > 233				   FIELD_PREP(SPI_CTRL_OPFIFO_LEN, op_len) |
   234				   FIELD_PREP(SPI_CTRL_OPFIFO_OP, op_cmd));
   235		if (err)
   236			return err;
   237	
   238		err = regmap_read_poll_timeout(as_ctrl->regmap_ctrl,
   239					       REG_SPI_CTRL_OPFIFO_FULL,
   240					       val, !(val & SPI_CTRL_OPFIFO_FULL),
   241					       0, 250 * USEC_PER_MSEC);
   242		if (err)
   243			return err;
   244	
   245		err = regmap_write(as_ctrl->regmap_ctrl, REG_SPI_CTRL_OPFIFO_WR,
   246				   SPI_CTRL_OPFIFO_WR);
   247		if (err)
   248			return err;
   249	
   250		return regmap_read_poll_timeout(as_ctrl->regmap_ctrl,
   251						REG_SPI_CTRL_OPFIFO_EMPTY,
   252						val, (val & SPI_CTRL_OPFIFO_EMPTY),
   253						0, 250 * USEC_PER_MSEC);
   254	}
   255	
   256	static int airoha_snand_set_cs(struct airoha_snand_ctrl *as_ctrl, u8 cs)
   257	{
   258		return airoha_snand_set_fifo_op(as_ctrl, cs, sizeof(cs));
   259	}
   260	
   261	static int airoha_snand_write_data_to_fifo(struct airoha_snand_ctrl *as_ctrl,
   262						   const u8 *data, int len)
   263	{
   264		int i;
   265	
   266		for (i = 0; i < len; i++) {
   267			int err;
   268			u32 val;
   269	
   270			/* 1. Wait until dfifo is not full */
   271			err = regmap_read_poll_timeout(as_ctrl->regmap_ctrl,
   272						       REG_SPI_CTRL_DFIFO_FULL, val,
   273						       !(val & SPI_CTRL_DFIFO_FULL),
   274						       0, 250 * USEC_PER_MSEC);
   275			if (err)
   276				return err;
   277	
   278			/* 2. Write data to register DFIFO_WDATA */
   279			err = regmap_write(as_ctrl->regmap_ctrl,
   280					   REG_SPI_CTRL_DFIFO_WDATA,
   281					   FIELD_PREP(SPI_CTRL_DFIFO_WDATA, data[i]));
   282			if (err)
   283				return err;
   284	
   285			/* 3. Wait until dfifo is not full */
   286			err = regmap_read_poll_timeout(as_ctrl->regmap_ctrl,
   287						       REG_SPI_CTRL_DFIFO_FULL, val,
   288						       !(val & SPI_CTRL_DFIFO_FULL),
   289						       0, 250 * USEC_PER_MSEC);
   290			if (err)
   291				return err;
   292		}
   293	
   294		return 0;
   295	}
   296	
   297	static int airoha_snand_read_data_from_fifo(struct airoha_snand_ctrl *as_ctrl,
   298						    u8 *ptr, int len)
   299	{
   300		int i;
   301	
   302		for (i = 0; i < len; i++) {
   303			int err;
   304			u32 val;
   305	
   306			/* 1. wait until dfifo is not empty */
   307			err = regmap_read_poll_timeout(as_ctrl->regmap_ctrl,
   308						       REG_SPI_CTRL_DFIFO_EMPTY, val,
   309						       !(val & SPI_CTRL_DFIFO_EMPTY),
   310						       0, 250 * USEC_PER_MSEC);
   311			if (err)
   312				return err;
   313	
   314			/* 2. read from dfifo to register DFIFO_RDATA */
   315			err = regmap_read(as_ctrl->regmap_ctrl,
   316					  REG_SPI_CTRL_DFIFO_RDATA, &val);
   317			if (err)
   318				return err;
   319	
 > 320			ptr[i] = FIELD_GET(SPI_CTRL_DFIFO_RDATA, val);

321 /* 3. enable register DFIFO_RD to read next byte */
322 err = regmap_write(as_ctrl->regmap_ctrl,
323 REG_SPI_CTRL_DFIFO_RD, SPI_CTRL_DFIFO_RD);
324 if (err)
325 return err;
326 }
327
328 return 0;
329 }
330

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki