mbox series

[v6,0/5] spi: add support for Mediatek SPI-NAND controller

Message ID 20220424032527.673605-1-gch981213@gmail.com (mailing list archive)
Headers show
Series spi: add support for Mediatek SPI-NAND controller | expand

Message

Chuanhong Guo April 24, 2022, 3:25 a.m. UTC
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 pipelined ECC engine.

Changes since v1:
 add a blank line between properties in dt binding doc
 rename ecc-engine to nand-ecc-engine for the generic properties
 fix warnings/errors from the CI

Changes since v2:
 use streamed DMA api to avoid an extra memory copy during read
 make ECC engine config a per-nand context
 take user-requested ECC strength into account

Change since v3:
 fix a missed ecc-engine rename in doc from v1

Changes since v4:
 fix typo: piplined -> pipelined
 fix missing OOB write in snfi driver
 print page format with dev_dbg instead
 replace uint*_t copied from vendor driver with u*

Changes since v5:
 add missing nfi mode register configuration in probe
 fix an off-by-one bug in mtk_snand_mac_io

Chuanhong Guo (5):
  mtd: nand: make mtk_ecc.c a separated module
  spi: add driver for MTK SPI NAND Flash Interface
  mtd: nand: mtk-ecc: also parse nand-ecc-engine if available
  spi: dt-bindings: add binding doc for spi-mtk-snfi
  arm64: dts: mediatek: add mtk-snfi for mt7622

 .../bindings/spi/mediatek,spi-mtk-snfi.yaml   |   88 +
 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} |    8 +-
 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                    | 1470 +++++++++++++++++
 .../linux/mtd/nand-ecc-mtk.h                  |    0
 12 files changed, 1597 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
 rename drivers/mtd/nand/{raw/mtk_ecc.c => ecc-mtk.c} (98%)
 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%)

Comments

Miquel Raynal April 27, 2022, 9:28 a.m. UTC | #1
Hi Mark,

gch981213@gmail.com wrote on Sun, 24 Apr 2022 11:25:22 +0800:

> 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 pipelined ECC engine.


[...]

The patch actually look independent, so if it's fine for you I can take
the two mtd patches and let you merge the spi/binding changes.

Would this work for you?

> Chuanhong Guo (5):
>   mtd: nand: make mtk_ecc.c a separated module
>   spi: add driver for MTK SPI NAND Flash Interface
>   mtd: nand: mtk-ecc: also parse nand-ecc-engine if available
>   spi: dt-bindings: add binding doc for spi-mtk-snfi
>   arm64: dts: mediatek: add mtk-snfi for mt7622
> 
>  .../bindings/spi/mediatek,spi-mtk-snfi.yaml   |   88 +
>  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} |    8 +-
>  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                    | 1470 +++++++++++++++++
>  .../linux/mtd/nand-ecc-mtk.h                  |    0
>  12 files changed, 1597 insertions(+), 5 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
>  rename drivers/mtd/nand/{raw/mtk_ecc.c => ecc-mtk.c} (98%)
>  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%)
> 


Thanks,
Miquèl
Mark Brown April 27, 2022, 1:11 p.m. UTC | #2
On Wed, Apr 27, 2022 at 11:28:57AM +0200, Miquel Raynal wrote:

> The patch actually look independent, so if it's fine for you I can take
> the two mtd patches and let you merge the spi/binding changes.

> Would this work for you?

That sounds great.
Chuanhong Guo April 27, 2022, 2:04 p.m. UTC | #3
Hi Miquel!

On Wed, Apr 27, 2022 at 5:29 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>
> [...]
>
> The patch actually look independent, so if it's fine for you I can take
> the two mtd patches and let you merge the spi/binding changes.

Out of curiosity:
Wouldn't that break the build for spi subsystem? Because...

> >  rename drivers/mtd/nand/raw/mtk_ecc.h => include/linux/mtd/nand-ecc-mtk.h (100%)

The spi driver needs this header file which is moved in the mtd patch.
Mark Brown April 27, 2022, 2:13 p.m. UTC | #4
On Wed, Apr 27, 2022 at 10:04:57PM +0800, Chuanhong Guo wrote:
> On Wed, Apr 27, 2022 at 5:29 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> > The patch actually look independent, so if it's fine for you I can take
> > the two mtd patches and let you merge the spi/binding changes.

> Out of curiosity:
> Wouldn't that break the build for spi subsystem? Because...

> > >  rename drivers/mtd/nand/raw/mtk_ecc.h => include/linux/mtd/nand-ecc-mtk.h (100%)

> The spi driver needs this header file which is moved in the mtd patch.

Ah, that'll be an issue indeed - if I could get a signed tag with the
dependency in it I can go ahead with the SPI bits?
Miquel Raynal April 27, 2022, 3:13 p.m. UTC | #5
Hi Mark,

broonie@kernel.org wrote on Wed, 27 Apr 2022 15:13:42 +0100:

> On Wed, Apr 27, 2022 at 10:04:57PM +0800, Chuanhong Guo wrote:
> > On Wed, Apr 27, 2022 at 5:29 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:  
> 
> > > The patch actually look independent, so if it's fine for you I can take
> > > the two mtd patches and let you merge the spi/binding changes.  
> 
> > Out of curiosity:
> > Wouldn't that break the build for spi subsystem? Because...  
> 
> > > >  rename drivers/mtd/nand/raw/mtk_ecc.h => include/linux/mtd/nand-ecc-mtk.h (100%)  
> 
> > The spi driver needs this header file which is moved in the mtd patch.  

Ah, yeah, right.

> Ah, that'll be an issue indeed - if I could get a signed tag with the
> dependency in it I can go ahead with the SPI bits?

Ok, I'll share an immutable tag.

Thanks,
Miquèl
Miquel Raynal April 27, 2022, 4:17 p.m. UTC | #6
Hello,

broonie@kernel.org wrote on Wed, 27 Apr 2022 15:13:42 +0100:

> On Wed, Apr 27, 2022 at 10:04:57PM +0800, Chuanhong Guo wrote:
> > On Wed, Apr 27, 2022 at 5:29 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:  
> 
> > > The patch actually look independent, so if it's fine for you I can take
> > > the two mtd patches and let you merge the spi/binding changes.  
> 
> > Out of curiosity:
> > Wouldn't that break the build for spi subsystem? Because...  
> 
> > > >  rename drivers/mtd/nand/raw/mtk_ecc.h => include/linux/mtd/nand-ecc-mtk.h (100%)  
> 
> > The spi driver needs this header file which is moved in the mtd patch.  
> 
> Ah, that'll be an issue indeed - if I could get a signed tag with the
> dependency in it I can go ahead with the SPI bits?

I pulled the two patches, here is a tag with these patches for you,
Mark.

The following changes since commit 3123109284176b1532874591f7c81f3837bbdc17:

  Linux 5.18-rc1 (2022-04-03 14:08:21 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git tags/mtd/mtk-spi-nand-for-5.19

for you to fetch changes up to 4c5bf4b51c9857e20c5f5e9d74b86aa1bd1def40:

  mtd: nand: mtk-ecc: also parse nand-ecc-engine if available (2022-04-27 18:12:43 +0200)

----------------------------------------------------------------
Mediatek ECC changes:
* Also parse the default nand-ecc-engine property if available
* Make mtk_ecc.c a separated module

----------------------------------------------------------------
Chuanhong Guo (2):
      mtd: nand: make mtk_ecc.c a separated module
      mtd: nand: mtk-ecc: also parse nand-ecc-engine if available

 drivers/mtd/nand/Kconfig                                           | 7 +++++++
 drivers/mtd/nand/Makefile                                          | 1 +
 drivers/mtd/nand/{raw/mtk_ecc.c => ecc-mtk.c}                      | 8 +++++---
 drivers/mtd/nand/raw/Kconfig                                       | 1 +
 drivers/mtd/nand/raw/Makefile                                      | 2 +-
 drivers/mtd/nand/raw/mtk_nand.c                                    | 2 +-
 drivers/mtd/nand/raw/mtk_ecc.h => include/linux/mtd/nand-ecc-mtk.h | 0
 7 files changed, 16 insertions(+), 5 deletions(-)
 rename drivers/mtd/nand/{raw/mtk_ecc.c => ecc-mtk.c} (98%)
 rename drivers/mtd/nand/raw/mtk_ecc.h => include/linux/mtd/nand-ecc-mtk.h (100%)
Mark Brown April 27, 2022, 10:06 p.m. UTC | #7
On Sun, 24 Apr 2022 11:25:22 +0800, Chuanhong Guo wrote:
> 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[2/5] spi: add driver for MTK SPI NAND Flash Interface
      commit: 764f1b7481645b2b4488eda26c4da7f331697e6b
[4/5] spi: dt-bindings: add binding doc for spi-mtk-snfi
      commit: 69bb9b29bf67e850beece45e9c99ca707eac7e41

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark