mbox series

[v1,00/14] mtd: spi-nor: move vendor specific code into vendor modules

Message ID 20220202145853.4187726-1-michael@walle.cc
Headers show
Series mtd: spi-nor: move vendor specific code into vendor modules | expand

Message

Michael Walle Feb. 2, 2022, 2:58 p.m. UTC
It turns out that most of the special status register handling is
specific for a particular vendor. I.e. Xilinx has some different
opcodes for the status register read, Micron has an additional FSR
register and Spansion has these flags integrated into the SR.

Create a callback to ready() where a flash chip can register its
own function. This will let us move all the vendor specific stuff
out of the core into the vendor modules.

Please note that this is only compile-time tested.

For sake of consistency and better readability of the code flow,
I also converted the setup() callback to be optional.

Michael Walle (14):
  mtd: spi-nor: export more function to be used in vendor modules
  mtd: spi-nor: slightly refactor the spi_nor_setup()
  mtd: spi-nor: allow a flash to define its own ready() function
  mtd: spi-nor: move all xilinx specifics into xilinx.c
  mtd: spi-nor: xilinx: rename vendor specific functions and defines
  mtd: spi-nor: xilinx: correct the debug message
  mtd: spi-nor: move all micron-st specifics into micron-st.c
  mtd: spi-nor: micron-st: convert USE_FSR to a manufacturer flag
  mtd: spi-nor: micron-st: fix micron_st prefix
  mtd: spi-nor: micron-st: rename vendor specific functions and defines
  mtd: spi-nor: spansion: slightly rework control flow in late_init()
  mtd: spi-nor: move all spansion specifics into spansion.c
  mtd: spi-nor: spansion: convert USE_CLSR to a manufacturer flag
  mtd: spi-nor: renumber flags

 drivers/mtd/spi-nor/core.c      | 265 ++------------------------------
 drivers/mtd/spi-nor/core.h      |  70 ++++-----
 drivers/mtd/spi-nor/micron-st.c | 225 ++++++++++++++++++++++-----
 drivers/mtd/spi-nor/spansion.c  | 133 ++++++++++++----
 drivers/mtd/spi-nor/xilinx.c    |  79 +++++++++-
 include/linux/mtd/spi-nor.h     |  18 ---
 6 files changed, 417 insertions(+), 373 deletions(-)

Comments

Tudor Ambarus Feb. 10, 2022, 3:42 a.m. UTC | #1
On 2/2/22 16:58, Michael Walle wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> It turns out that most of the special status register handling is
> specific for a particular vendor. I.e. Xilinx has some different
> opcodes for the status register read, Micron has an additional FSR
> register and Spansion has these flags integrated into the SR.
> 
> Create a callback to ready() where a flash chip can register its
> own function. This will let us move all the vendor specific stuff
> out of the core into the vendor modules.
> 
> Please note that this is only compile-time tested.
> 
> For sake of consistency and better readability of the code flow,
> I also converted the setup() callback to be optional.
> 
> Michael Walle (14):
>   mtd: spi-nor: export more function to be used in vendor modules
>   mtd: spi-nor: slightly refactor the spi_nor_setup()
>   mtd: spi-nor: allow a flash to define its own ready() function
>   mtd: spi-nor: move all xilinx specifics into xilinx.c
>   mtd: spi-nor: xilinx: rename vendor specific functions and defines
>   mtd: spi-nor: xilinx: correct the debug message
>   mtd: spi-nor: move all micron-st specifics into micron-st.c
>   mtd: spi-nor: micron-st: convert USE_FSR to a manufacturer flag
>   mtd: spi-nor: micron-st: fix micron_st prefix
>   mtd: spi-nor: micron-st: rename vendor specific functions and defines
>   mtd: spi-nor: spansion: slightly rework control flow in late_init()
>   mtd: spi-nor: move all spansion specifics into spansion.c
>   mtd: spi-nor: spansion: convert USE_CLSR to a manufacturer flag
>   mtd: spi-nor: renumber flags
> 
>  drivers/mtd/spi-nor/core.c      | 265 ++------------------------------
>  drivers/mtd/spi-nor/core.h      |  70 ++++-----
>  drivers/mtd/spi-nor/micron-st.c | 225 ++++++++++++++++++++++-----
>  drivers/mtd/spi-nor/spansion.c  | 133 ++++++++++++----
>  drivers/mtd/spi-nor/xilinx.c    |  79 +++++++++-
>  include/linux/mtd/spi-nor.h     |  18 ---
>  6 files changed, 417 insertions(+), 373 deletions(-)
> 

Good job, Michael! I added R-b to some patches to inform you that they
look fine to me. You don't need to add the tags on the next version, as
I'll be the one that will apply them. I think I have a micron and a spansion
flash somewhere, will try to test your series once v2 is out.

Cheers,
ta
Tudor Ambarus Feb. 17, 2022, 7:31 a.m. UTC | #2
+ Yaliang,

might be interested in reviewing/testing this, as there were some similar
patches submitted a while ago:

https://patchwork.ozlabs.org/project/linux-mtd/list/?series=237043

Cheers,
ta

On 2/2/22 16:58, Michael Walle wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> It turns out that most of the special status register handling is
> specific for a particular vendor. I.e. Xilinx has some different
> opcodes for the status register read, Micron has an additional FSR
> register and Spansion has these flags integrated into the SR.
> 
> Create a callback to ready() where a flash chip can register its
> own function. This will let us move all the vendor specific stuff
> out of the core into the vendor modules.
> 
> Please note that this is only compile-time tested.
> 
> For sake of consistency and better readability of the code flow,
> I also converted the setup() callback to be optional.
> 
> Michael Walle (14):
>   mtd: spi-nor: export more function to be used in vendor modules
>   mtd: spi-nor: slightly refactor the spi_nor_setup()
>   mtd: spi-nor: allow a flash to define its own ready() function
>   mtd: spi-nor: move all xilinx specifics into xilinx.c
>   mtd: spi-nor: xilinx: rename vendor specific functions and defines
>   mtd: spi-nor: xilinx: correct the debug message
>   mtd: spi-nor: move all micron-st specifics into micron-st.c
>   mtd: spi-nor: micron-st: convert USE_FSR to a manufacturer flag
>   mtd: spi-nor: micron-st: fix micron_st prefix
>   mtd: spi-nor: micron-st: rename vendor specific functions and defines
>   mtd: spi-nor: spansion: slightly rework control flow in late_init()
>   mtd: spi-nor: move all spansion specifics into spansion.c
>   mtd: spi-nor: spansion: convert USE_CLSR to a manufacturer flag
>   mtd: spi-nor: renumber flags
> 
>  drivers/mtd/spi-nor/core.c      | 265 ++------------------------------
>  drivers/mtd/spi-nor/core.h      |  70 ++++-----
>  drivers/mtd/spi-nor/micron-st.c | 225 ++++++++++++++++++++++-----
>  drivers/mtd/spi-nor/spansion.c  | 133 ++++++++++++----
>  drivers/mtd/spi-nor/xilinx.c    |  79 +++++++++-
>  include/linux/mtd/spi-nor.h     |  18 ---
>  6 files changed, 417 insertions(+), 373 deletions(-)
> 
> --
> 2.30.2
>