Re: [U-Boot] [PATCH v9 00/21] dm: Generic MTD Subsystem/SPI-NOR

2016-11-05 Thread Simon Glass
Hi Jagan,

On 30 October 2016 at 12:23, Jagan Teki  wrote:
> The previous series [1] [2] are added SPI-NOR on top of
> mtd/spi where it bypassing DM_SPI_FLASH and use the existing
> mtd core (which is non-dm), I feel this is moving in a reverse
> direction where adding new feature with the help of non-dm mtd
> core support and also few of the spi drivers are not fully dm-driven.
>
> Previous design series[3]: keep the mtd/spi as it is and start adding
> spi-nor features separately. The idea here is to add the dm features
> to MTD first and then add UCLASS_MTD spi-nor drivers so-that the commands
> are interfacing to spi-nor through dm-driven MTD core to spi-nor.
>
> This series adding a new command 'mtd.c' which is common for all MTD devices
> SPI-NOR, SPI-NOR(master) and Parallel NOR with dm-driven.
>
> SPI-NOR and Parallel NOR:
> 
>
> 
>   mtd.c
> 
> mtd-uclass
> 
>SPI-NOR CoreCFI FLASH
> 
> m25p80.czynq_qspi
> ---
> spi-uclass  SPI NOR chip
> ---
> spi drivers
> ---
> SPI NOR chip
> ---
>
> drivers/mtd/spi-nor/
>
> - Add dm mtd operations
> - spi-nor.c:   Add basic SPI-NOR core like erase/read/write ops and lock's 
> will add later
> - m25p80.c:spi-nor to spi divers interface layer drivers/spi-nor
> - zynq_qspi.c: zynq qspi spi-nor controller driver.
>
> Current Status:
> --
> - SPI-NOR Controller design flow working, see Log
>
> TODO:
> 
> - SPI-NOR with SPI bus
> - Parallel NOR.
>
> Log:
> 
> Zynq> mtd
> mtd - MTD Sub-system
>
> Usage:
> mtd list- show list of MTD devices
> mtd info- show current MTD device info
> mtd probe devnum- probe the 'devnum' MTD device
> mtd erase offset len- erase 'len' bytes from 'offset'
> mtd write addr to len   - write 'len' bytes to 'to' from 'addr'
> mtd read addr from len  - read 'len' bytes from 'from' to 'addr'
> Zynq> mtd list
> MTD 1:  spi-nor@e000d000
> Zynq>
> MTD 1:  spi-nor@e000d000
> Zynq> mtd list
> MTD 1:  spi-nor@e000d000
> Zynq> mtd probe 0
> failing to set MTD device 0
> Zynq> mtd probe 1
> SPI-NOR: detected s25fl128s_64k with page size 256 Bytes, erase size 64 KiB, 
> total 16 MiB
> Zynq> mtd info
> MTD Device 1: s25fl128s_64k
>  Page size: 256 B
>  Erase size:64 KiB
>  Size:  16 MiB
> Zynq> mtd list
> MTD 1:  spi-nor@e000d000  (active 1)
> Zynq> mtd erase 0xE0 0x10
> MTD: 1048576 bytes @ 0xe0 Erased: OK
> Zynq> mw.b 0x100 0xaa 0x10
> Zynq> mtd write 0x100 0xE0 0x10
> device 0 offset 0xe0, size 0x10
> MTD: 1048576 bytes @ 0xe0 Written: OK
> Zynq> mtd read 0x300 0xE0 0x10
> device 0 offset 0xe0, size 0x10
> MTD: 1048576 bytes @ 0xe0 Read: OK
> Zynq> cmp.b 0x300 0x100 0x10
> Total of 1048576 byte(s) were the same
>
> Testing:
> ---
> $ git clone git://git.denx.de/u-boot-spi.git
> $ cd u-boot-spi
> $ git checkout -b mtd origin/mtd-working
>
> [1] http://lists.denx.de/pipermail/u-boot/2016-March/249286.html
> [2] http://lists.denx.de/pipermail/u-boot/2016-February/245418.html
> [3] [PATCH RFC v8 00/16]  SPI-NOR/MTD addition
>
> Jagan Teki (21):
>   dm: mtd: Add dm mtd core ops
>   mtd: Add SPI-NOR core support
>   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
>   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
>   dm: mtd: Add uclass_driver.flags
>   dm: mtd: Add post_bind
>   cmd: Add mtd command support
>   arm: dts: zynq: Add zynq-qspinor node
>   dm: zynq: microzed: Enable MTD/SPI-NOR
>
>  Makefile   |   1 +
>  arch/arm/dts/zynq-7000.dtsi|  12 +
>  arch/arm/dts/zynq-microzed.dts |   6 +
>  cmd/Kconfig|   6 +
>  cmd/Makefile   |   1 +
>  cmd/mtd.c  | 285 
>  configs/zynq_microzed_defconfig|  14 +-
>  drivers/mtd/Kconfig|   2 +
>  drivers/mtd/Makefile   |   2 +-
>  drivers/mtd/mtd-uclass.c   |  93 +
>  drivers/mtd/spi-nor/Kconfig|  89 +
>  drivers/mtd/spi-nor/Makefile   

[U-Boot] [PATCH v9 00/21] dm: Generic MTD Subsystem/SPI-NOR

2016-10-30 Thread Jagan Teki
The previous series [1] [2] are added SPI-NOR on top of
mtd/spi where it bypassing DM_SPI_FLASH and use the existing
mtd core (which is non-dm), I feel this is moving in a reverse
direction where adding new feature with the help of non-dm mtd
core support and also few of the spi drivers are not fully dm-driven.

Previous design series[3]: keep the mtd/spi as it is and start adding
spi-nor features separately. The idea here is to add the dm features
to MTD first and then add UCLASS_MTD spi-nor drivers so-that the commands
are interfacing to spi-nor through dm-driven MTD core to spi-nor.

This series adding a new command 'mtd.c' which is common for all MTD devices
SPI-NOR, SPI-NOR(master) and Parallel NOR with dm-driven. 

SPI-NOR and Parallel NOR:



  mtd.c

mtd-uclass

   SPI-NOR CoreCFI FLASH

m25p80.czynq_qspi
---
spi-uclass  SPI NOR chip
---
spi drivers
---
SPI NOR chip
---

drivers/mtd/spi-nor/

- Add dm mtd operations
- spi-nor.c:   Add basic SPI-NOR core like erase/read/write ops and lock's will 
add later
- m25p80.c:spi-nor to spi divers interface layer drivers/spi-nor
- zynq_qspi.c: zynq qspi spi-nor controller driver.

Current Status:
--
- SPI-NOR Controller design flow working, see Log

TODO:

- SPI-NOR with SPI bus
- Parallel NOR.

Log:

Zynq> mtd
mtd - MTD Sub-system

Usage:
mtd list- show list of MTD devices
mtd info- show current MTD device info
mtd probe devnum- probe the 'devnum' MTD device
mtd erase offset len- erase 'len' bytes from 'offset'
mtd write addr to len   - write 'len' bytes to 'to' from 'addr'
mtd read addr from len  - read 'len' bytes from 'from' to 'addr'
Zynq> mtd list
MTD 1:  spi-nor@e000d000
Zynq>
MTD 1:  spi-nor@e000d000
Zynq> mtd list
MTD 1:  spi-nor@e000d000
Zynq> mtd probe 0
failing to set MTD device 0
Zynq> mtd probe 1
SPI-NOR: detected s25fl128s_64k with page size 256 Bytes, erase size 64 KiB, 
total 16 MiB
Zynq> mtd info  
MTD Device 1: s25fl128s_64k
 Page size: 256 B
 Erase size:64 KiB
 Size:  16 MiB
Zynq> mtd list
MTD 1:  spi-nor@e000d000  (active 1)
Zynq> mtd erase 0xE0 0x10
MTD: 1048576 bytes @ 0xe0 Erased: OK
Zynq> mw.b 0x100 0xaa 0x10
Zynq> mtd write 0x100 0xE0 0x10
device 0 offset 0xe0, size 0x10
MTD: 1048576 bytes @ 0xe0 Written: OK
Zynq> mtd read 0x300 0xE0 0x10
device 0 offset 0xe0, size 0x10
MTD: 1048576 bytes @ 0xe0 Read: OK
Zynq> cmp.b 0x300 0x100 0x10
Total of 1048576 byte(s) were the same

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

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

Jagan Teki (21):
  dm: mtd: Add dm mtd core ops
  mtd: Add SPI-NOR core support
  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
  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
  dm: mtd: Add uclass_driver.flags
  dm: mtd: Add post_bind
  cmd: Add mtd command support
  arm: dts: zynq: Add zynq-qspinor node
  dm: zynq: microzed: Enable MTD/SPI-NOR

 Makefile   |   1 +
 arch/arm/dts/zynq-7000.dtsi|  12 +
 arch/arm/dts/zynq-microzed.dts |   6 +
 cmd/Kconfig|   6 +
 cmd/Makefile   |   1 +
 cmd/mtd.c  | 285 
 configs/zynq_microzed_defconfig|  14 +-
 drivers/mtd/Kconfig|   2 +
 drivers/mtd/Makefile   |   2 +-
 drivers/mtd/mtd-uclass.c   |  93 +
 drivers/mtd/spi-nor/Kconfig|  89 +
 drivers/mtd/spi-nor/Makefile   |  15 +
 drivers/mtd/spi-nor/m25p80.c   | 218 
 drivers/mtd/spi-nor/spi-nor-ids.c  | 176 ++
 drivers/mtd/spi-nor/spi-nor.c  | 684 +
 drivers/mtd/spi-nor/zynq_qspinor.c | 641 ++
 drivers/spi/spi-uclass.c   |  24 +