public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v10 00/27] dm: Generic MTD Subsystem, with SPI-NOR interface
@ 2017-12-28  6:12 Jagan Teki
  2017-12-28  6:12 ` [U-Boot] [PATCH v10 01/27] mtd: Add mtd core ops Jagan Teki
                   ` (28 more replies)
  0 siblings, 29 replies; 56+ messages in thread
From: Jagan Teki @ 2017-12-28  6:12 UTC (permalink / raw)
  To: u-boot

Compared to previous series’s [1], [2], [3] and [4] this patch set
redefined most of the implementation suitable to fit into existing driver-model.

MTD is generic subsystem for underlying flash devices like nand,
parallel nor, spinor, dataflash etc. So to drive this theory with
driver model(with an example of block layer) mtd is common device
interaction for most of  memory technology flashes like nand, parallel nor,
spinor, dataflash etc, these are treated as interface types wrt u-boot driver model.

Once the respective interface driver bind happen, the uclass driver will
pass an 'interface type' to mtd layer to create device for it,
for example once spinor ULASS_SPI_NOR driver bind happen,
the uclass driver of spinor will pass MTD_IF_TYPE_SPI_NOR 
interface type to create mtd device for spinor devices.

SPI-NOR:
=======
Some of the SPI device drivers at drivers/spi not a real
spi controllers, Unlike normal/generic SPI controllers they
operates only with SPI-NOR flash devices. these were technically
termed as SPI-NOR controllers, Ex: drivers/spi/fsl_qspi.c

The problem with these were resides at drivers/spi is entire
SPI layer becomes SPI-NOR flash oriented which is absolutely
a wrong indication where SPI layer getting effected more with
flash operations - So this SPI-NOR core will resolve this issue
by separating all SPI-NOR flash operations from spi layer and
creats a generic layer called SPI-NOR core which can be used to
interact SPI-NOR to SPI driver interface layer and the SPI-NOR
controller driver.

=======================================
             cmd/spinor.c
=======================================
             mtd-uclass.c
=======================================
           spi-nor-uclass.c
=======================================
              spi-nor.c
=======================================
m25p80.c                zynq_qspinor.c
=======================================
spi-uclass.c
=======================================
zynq_qspi.c
=======================================
        #####SPI NOR chip######
=======================================

Changes for v10:
- Update Simon's R-B tag
- Add mtd dm test case
- implemented entire code wrt MTD, with interface type

code size:
==========
before:
$ arm-linux-gnueabi-size u-boot
   text	   data	    bss	    dec	    hex	filename
 473712	  15152	 222568	 711432	  adb08	u-boot
$ du -hs u-boot-dtb.img 
488K	u-boot-dtb.img

after:
$ arm-linux-gnueabi-size u-boot
   text	   data	    bss	    dec	    hex	filename
 470124	  14352	 222584	 707060	  ac9f4	u-boot
$ du -hs u-boot-dtb.img 
484K	u-boot-dtb.img

approximately 4KiB but DM_SPI_FLASH still there which
can be removed once support added in SPL

test log:
========
Zynq> spinor
spinor - SPI-NOR Sub-system

Usage:
spinor list                     - show list of spinor devices
spinor info                     - show current spinor device info
spinor dev [devnum]             - show or set current spinor device
spinor erase offset len         - erase 'len' bytes from 'offset'
spinor write addr to len        - write 'len' bytes to 'to' from 'addr'
spinor read addr from len       - read 'len' bytes from 'from' to 'addr'
spinor protect lock/unlock sector len - protect/unprotect 'len' bytes starting
                                  at address 'sector'
Zynq> spinor list
flash at 0: 0
spi-nor at e000d000: 1
Zynq> spinor dev 0
switch to dev #0, OK
spinor0 is current device
Zynq> spinor info
bus: flash at 0: 0
device: s25fl128s_64k
page size: 256 B
erase size: 64 KiB
size: 16 MiB
Zynq> spinor erase 0xE00000 0x100000
SPI-NOR: 1048576 bytes @ 0xe00000 Erased: OK
Zynq> mw.b 0x100 0xcc 0x100000
Zynq> spinor write 0x100 0xE00000 0x100000
device 0 offset 0xe00000, size 0x100000
SPI-NOR: 1048576 bytes @ 0xe00000 Written: OK
Zynq> spinor read 0x3000000 0xE00000 0x100000
device 0 offset 0xe00000, size 0x100000
SPI-NOR: 1048576 bytes @ 0xe00000 Read: OK
Zynq> cmp.b 0x3000000 0x100 0x100000
Total of 1048576 byte(s) were the same
Zynq> spinor dev 1
switch to dev #1, OK
spinor1 is current device
Zynq> spinor info
bus: spi-nor at e000d000: 1
device: s25fl128s_64k
page size: 256 B
erase size: 64 KiB
size: 16 MiB
Zynq> spinor erase 0xE00000 0x100000
SPI-NOR: 1048576 bytes @ 0xe00000 Erased: OK
Zynq> mw.b 0x100 0xbb 0x100000
Zynq> spinor write 0x100 0xE00000 0x100000
device 0 offset 0xe00000, size 0x100000
SPI-NOR: 1048576 bytes @ 0xe00000 Written: OK
Zynq> spinor read 0x3000000 0xE00000 0x100000
device 0 offset 0xe00000, size 0x100000
SPI-NOR: 1048576 bytes @ 0xe00000 Read: OK
Zynq> cmp.b 0x3000000 0x100 0x100000
Total of 1048576 byte(s) were the same

WIP:
===
- to support non-dm code
- to support spinor SPL

Repo:
====
$ git clone git://git.denx.de/u-boot-spi.git
$ cd u-boot-spi
$ git checkout -b mtd-spinor-working origin/mtd-spinor-working

[1] https://lists.denx.de/pipermail/u-boot/2016-October/271459.html
[2] http://lists.denx.de/pipermail/u-boot/2016-March/249286.html
[3] http://lists.denx.de/pipermail/u-boot/2016-February/245418.html
[4] [PATCH RFC v8 00/16]  SPI-NOR/MTD addition

Jagan Teki (27):
  mtd: Add mtd core ops
  mtd: add mtd device create operations
  mtd: add SPI-NOR core support
  mtd: spi-nor: sync/modify sst write operations
  mtd: spi-nor: sync/modify lock operations
  mtd: spi-nor: Kconfig: Add MTD_SPI_NOR entry
  mtd: spi-nor: Kconfig: Add MTD_SPI_NOR_USE_4K_SECTORS
  mtd: spi-nor: Kconfig: Add SPI_NOR_MISC entry
  mtd: spi-nor: Kconfig: Add SPI_NOR_MACRONIX entry
  mtd: spi-nor: Kconfig: Add SPI_NOR_SPANSION entry
  mtd: spi-nor: Kconfig: Add SPI_NOR_STMICRO entry
  mtd: spi-nor: Kconfig: Add SPI_NOR_SST entry
  mtd: spi-nor: Kconfig: Add SPI_NOR_WINBOND entry
  mtd-uclass: use platdata_auto_alloc
  spi: Add spi_write_then_read
  mtd: spi-nor: Add m25p80 driver
  mtd: spi-nor: Kconfig: Add MTD_M25P80 entry
  mtd: spi-nor: Add zynq qspinor driver
  mtd: spi-nor: zynq_qspi: Kconfig: Add MTD_ZYNQ
  mtd: spi-nor: Add 4-byte addresswidth support
  cmd: add spinor cmd support
  cmd: spinor: sync/update protect command
  board_r: initialize spi_nor
  env: add spi-nor environment
  arm: dts: zynq: Add zynq-qspinor node
  dm: zynq: microzed: enable MTD/SPI-NOR framework
  test: dm: add tests for mtd devices

 Makefile                             |   1 +
 arch/arm/dts/zynq-7000.dtsi          |  12 +
 arch/arm/dts/zynq-microzed.dts       |  12 +-
 cmd/Kconfig                          |   5 +
 cmd/Makefile                         |   1 +
 cmd/nvedit.c                         |   1 +
 cmd/spinor.c                         | 326 ++++++++++++
 common/board_r.c                     |  13 +
 configs/sandbox_defconfig            |   8 +-
 configs/zynq_microzed_defconfig      |  17 +-
 drivers/mtd/Kconfig                  |   2 +
 drivers/mtd/Makefile                 |   7 +-
 drivers/mtd/mtd-uclass.c             | 203 +++++++-
 drivers/mtd/spi-nor/Kconfig          |  89 ++++
 drivers/mtd/spi-nor/Makefile         |  15 +
 drivers/mtd/spi-nor/m25p80.c         | 251 ++++++++++
 drivers/mtd/spi-nor/spi-nor-ids.c    | 184 +++++++
 drivers/mtd/spi-nor/spi-nor-uclass.c | 160 ++++++
 drivers/mtd/spi-nor/spi-nor.c        | 940 +++++++++++++++++++++++++++++++++++
 drivers/mtd/spi-nor/zynq_qspinor.c   | 622 +++++++++++++++++++++++
 drivers/spi/spi-uclass.c             |  24 +
 env/Kconfig                          |  27 +
 env/Makefile                         |   1 +
 env/env.c                            |   2 +
 env/spinor.c                         | 113 +++++
 include/dm/uclass-id.h               |   1 +
 include/environment.h                |   1 +
 include/linux/mtd/mtd.h              |  14 +
 include/linux/mtd/spi-nor.h          | 223 +++++++++
 include/mtd.h                        | 176 +++++++
 include/spi.h                        |  20 +
 test/dm/Makefile                     |   1 +
 test/dm/mtd.c                        |  33 ++
 33 files changed, 3493 insertions(+), 12 deletions(-)
 create mode 100644 cmd/spinor.c
 create mode 100644 drivers/mtd/spi-nor/Kconfig
 create mode 100644 drivers/mtd/spi-nor/Makefile
 create mode 100644 drivers/mtd/spi-nor/m25p80.c
 create mode 100644 drivers/mtd/spi-nor/spi-nor-ids.c
 create mode 100644 drivers/mtd/spi-nor/spi-nor-uclass.c
 create mode 100644 drivers/mtd/spi-nor/spi-nor.c
 create mode 100644 drivers/mtd/spi-nor/zynq_qspinor.c
 create mode 100644 env/spinor.c
 create mode 100644 include/linux/mtd/spi-nor.h
 create mode 100644 test/dm/mtd.c

-- 
2.7.4

^ permalink raw reply	[flat|nested] 56+ messages in thread
* [U-Boot] [PATCH v10 00/27] dm: Generic MTD Subsystem, with SPI-NOR interface
@ 2018-02-28  9:32 Prabhakar Kushwaha
  0 siblings, 0 replies; 56+ messages in thread
From: Prabhakar Kushwaha @ 2018-02-28  9:32 UTC (permalink / raw)
  To: u-boot

Dear Jagan,

> -----Original Message-----
> From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Jagan
> Teki
> Sent: Thursday, December 28, 2017 11:42 AM
> To: u-boot at lists.denx.de
> Cc: Tom Rini <trini@konsulko.com>
> Subject: [U-Boot] [PATCH v10 00/27] dm: Generic MTD Subsystem, with SPI-
> NOR interface
> 
> Compared to previous series’s [1], [2], [3] and [4] this patch set redefined
> most of the implementation suitable to fit into existing driver-model.
> 
> MTD is generic subsystem for underlying flash devices like nand, parallel nor,
> spinor, dataflash etc. So to drive this theory with driver model(with an
> example of block layer) mtd is common device interaction for most of
> memory technology flashes like nand, parallel nor, spinor, dataflash etc,
> these are treated as interface types wrt u-boot driver model.
> 
> Once the respective interface driver bind happen, the uclass driver will pass
> an 'interface type' to mtd layer to create device for it, for example once
> spinor ULASS_SPI_NOR driver bind happen, the uclass driver of spinor will
> pass MTD_IF_TYPE_SPI_NOR interface type to create mtd device for spinor
> devices.
> 
> SPI-NOR:
> =======
> Some of the SPI device drivers at drivers/spi not a real spi controllers, Unlike
> normal/generic SPI controllers they operates only with SPI-NOR flash
> devices. these were technically termed as SPI-NOR controllers, Ex:
> drivers/spi/fsl_qspi.c
> 
> The problem with these were resides at drivers/spi is entire SPI layer
> becomes SPI-NOR flash oriented which is absolutely a wrong indication
> where SPI layer getting effected more with flash operations - So this SPI-NOR
> core will resolve this issue by separating all SPI-NOR flash operations from spi
> layer and creats a generic layer called SPI-NOR core which can be used to
> interact SPI-NOR to SPI driver interface layer and the SPI-NOR controller
> driver.
> 
> =======================================
>              cmd/spinor.c
> =======================================
>              mtd-uclass.c
> =======================================
>            spi-nor-uclass.c
> =======================================
>               spi-nor.c
> =======================================
> m25p80.c                zynq_qspinor.c
> =======================================
> spi-uclass.c
> =======================================
> zynq_qspi.c
> =======================================
>         #####SPI NOR chip######
> =======================================
> 

As per this patch-set, fsl_qspi is looks to be getting proposed in driver/mtd/spi-nor/ folder.

fsl_qspi is supporting both flash and fpga.  We are not sure about its location. 

There is an on-going effort for similar type of requirement in Linux by Boris Brezillon . It is dealing with controllers supporting NORs, NANDs, SRAMs etc. 
http://patchwork.ozlabs.org/project/linux-mtd/list/?series=27088

Borris has also ported fsl_qspi in driver/spi to use this new framework. It is still not completely tested.  
https://github.com/bbrezillon/linux/commit/43cc45764b975bfbb191de3f6a37e073da1a2706


Will you also follow similar approach as being done in http://patchwork.ozlabs.org/project/linux-mtd/list/?series=27088 for longer term?

For Now, We are planning to update fsl_qspi driver to support dynamic LUT. Similar patch is in progress in Linux http://patchwork.ozlabs.org/project/linux-mtd/list/?series=26084
Now we are confused, should be port fsl_qspi in driver/mtd/spi-nor and then update driver
Or
We update driver/spi/fsl_qspi for dynamic LUTs. We may need to modify existing framework to get all required info for dynamic LUT.  

Also we want some change in framework like support of
 -  4 byte address and SFDP :  http://patchwork.ozlabs.org/project/uboot/list/?series=19621&state=*
 -  SMPT : in discussion in Linux http://patchwork.ozlabs.org/patch/869718/
 Which code base should we use?   u-boot-spi.git branch mtd-spinor-working  or u-boot.git master branch

--pk

 

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

end of thread, other threads:[~2018-03-06  6:38 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-28  6:12 [U-Boot] [PATCH v10 00/27] dm: Generic MTD Subsystem, with SPI-NOR interface Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 01/27] mtd: Add mtd core ops Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 02/27] mtd: add mtd device create operations Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 03/27] mtd: add SPI-NOR core support Jagan Teki
2017-12-29  9:25   ` Andy Yan
2018-01-02 10:18   ` Prabhakar Kushwaha
2018-01-02 10:31     ` Jagan Teki
2018-01-03  8:49   ` Vignesh R
2018-01-03  9:32     ` Jagan Teki
2018-01-03  9:56       ` Vignesh R
2018-01-03 10:07         ` Jagan Teki
2018-01-04  2:33   ` Andy Yan
2018-02-28  9:42   ` Prabhakar Kushwaha
2018-02-28 12:10     ` Boris Brezillon
2018-03-06  5:59       ` Prabhakar Kushwaha
2018-03-06  6:38     ` Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 04/27] mtd: spi-nor: sync/modify sst write operations Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 05/27] mtd: spi-nor: sync/modify lock operations Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 06/27] mtd: spi-nor: Kconfig: Add MTD_SPI_NOR entry Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 07/27] mtd: spi-nor: Kconfig: Add MTD_SPI_NOR_USE_4K_SECTORS Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 08/27] mtd: spi-nor: Kconfig: Add SPI_NOR_MISC entry Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 09/27] mtd: spi-nor: Kconfig: Add SPI_NOR_MACRONIX entry Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 10/27] mtd: spi-nor: Kconfig: Add SPI_NOR_SPANSION entry Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 11/27] mtd: spi-nor: Kconfig: Add SPI_NOR_STMICRO entry Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 12/27] mtd: spi-nor: Kconfig: Add SPI_NOR_SST entry Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 13/27] mtd: spi-nor: Kconfig: Add SPI_NOR_WINBOND entry Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 14/27] mtd-uclass: use platdata_auto_alloc Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 15/27] spi: Add spi_write_then_read Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 16/27] mtd: spi-nor: Add m25p80 driver Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 17/27] mtd: spi-nor: Kconfig: Add MTD_M25P80 entry Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 18/27] mtd: spi-nor: Add zynq qspinor driver Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 19/27] mtd: spi-nor: zynq_qspi: Kconfig: Add MTD_ZYNQ Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 20/27] mtd: spi-nor: Add 4-byte addresswidth support Jagan Teki
2017-12-28  8:06   ` Cyrille Pitchen
2017-12-28  8:08     ` Cyrille Pitchen
2017-12-28  6:12 ` [U-Boot] [PATCH v10 21/27] cmd: add spinor cmd support Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 22/27] cmd: spinor: sync/update protect command Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 23/27] board_r: initialize spi_nor Jagan Teki
2018-01-08  3:52   ` Simon Glass
2017-12-28  6:12 ` [U-Boot] [PATCH v10 24/27] env: add spi-nor environment Jagan Teki
2018-01-04  7:06   ` Prabhakar Kushwaha
2017-12-28  6:12 ` [U-Boot] [PATCH v10 25/27] arm: dts: zynq: Add zynq-qspinor node Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 26/27] dm: zynq: microzed: enable MTD/SPI-NOR framework Jagan Teki
2017-12-28  6:12 ` [U-Boot] [PATCH v10 27/27] test: dm: add tests for mtd devices Jagan Teki
2017-12-28 14:44 ` [U-Boot] [PATCH v10 00/27] dm: Generic MTD Subsystem, with SPI-NOR interface Lukasz Majewski
2018-01-02 10:09   ` Jagan Teki
2018-01-03  8:48     ` Vignesh R
2018-01-03  9:24       ` Jagan Teki
2018-01-03 10:59         ` Lukasz Majewski
2018-01-31  8:07           ` Andy Yan
2018-01-04 11:52         ` Vignesh R
2018-01-23  9:50     ` Siva Durga Prasad Paladugu
2018-01-23  9:59       ` Jagan Teki
2018-01-23 11:50         ` Siva Durga Prasad Paladugu
2018-01-23  9:00 ` Siva Durga Prasad Paladugu
  -- strict thread matches above, loose matches on Subject: below --
2018-02-28  9:32 Prabhakar Kushwaha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox