[U-Boot] [PATCH v3 0/29] Introduce driver model support for SPI, SPI flash, cros_ec

Jagan Teki jagannadh.teki at gmail.com
Sat Oct 11 20:46:33 CEST 2014


On 30 September 2014 01:04, Simon Glass <sjg at chromium.org> wrote:
> Up until now driver model has not been used for any type of bus. Buses
> have some unique properties and needs, so we cannot claim that driver
> model can cover all the common cases unless we have converted a bus over
> to driver model.
>
> SPI is a reasonable choice for this next step. It has a fairly simple
> API and not too many dependencies. The main one is SPI flash so we may
> as well convert that also. Since the boards I test with have cros_ec I
> have also included that, for SPI only.
>
> The technique used is make use of driver model's supported data structures
> to hold information currently kept by each subsystem in a private data
> structure. Since 'struct spi_slave' relates to the slave device on the bus
> it is stored in the 'parent' data with each child device of the bus.
> Since 'struct spi_flash' is a standard interface used for each SPI flash
> driver, it is stored in the SPI FLash uclass's private data for each
> device.
>
> New defines are created to enable driver model for each subsystem. These
> are:
>
>    CONFIG_DM_SPI
>    CONFIG_DM_SPI_FLASH
>    CONFIG_DM_CROS_EC
>
> This allows us to move some boards and drivers to driver model, while
> leaving others behind. A 'big bang' conversion of everything to driver
> model, even at a subsystem level, is never going to work.
>
> There is some cost in changing the uclass interface after it is created,
> so if you have limited time, please spend it reviewing the uclass
> interfaces in spi.h and spi_flash.h. These need to be supported by each
> driver, so changing them later may involve changing multiple drivers.
>
> To assist with the conversion of other SPI drivers, a README file is
> added to walk through the process.
>
> So far, sandbox, exynos and tegra drivers are converted over.
>
> As always, driver model patches are available at u-boot-dm.git branch
> 'working'. There is a branch for just this series called 'spi-working'.
>
> Changes in v3:
> - Add a cs_info() method to the driver model SPI API
> - Add a debug() in the probe method
> - Add a few more debug() statements
> - Add a function comment for sandbox_spi_get_emul()
> - Add a missing tab character
> - Add a uclass for a generic SPI device (for use with the 'sspi' command)
> - Add implementation/comment for the cs_info() method
> - Add missing comments to spi.h
> - Add new functions to iterate through device children
> - Add new patch to add a clarifying comment on struct udevice's seq member
> - Add new patch to add aliases for spi on tegra30 boards
> - Add new patch to allow parents to pass data to children during probe
> - Add new patch to convert Tegra SPI to driver model
> - Add spi.h header to 3 sh boards
> - Correct typo where 'slave' should say 'bus'
> - Expand SPI tests to cover compatibility functions
> - Fix two comment typos
> - Make sure the old device is both removed and unbound in 'sf probe'
> - Minor renames for clarity
> - Put the cs member back into spi_slave
> - Rebase to master
> - Remove the child_pre_probe() method which is no longer needed
> - Update for the new cs_info() method
> - Use a generic SPI device for the 'sspi command'
> - Use an explicit chip select value instead of reusing device sequence number
> - Word-wrap the first paragraph of the binding
>
> Changes in v2:
> - Add additional debug() statements
> - Add missing comments for struct spi_slave
> - Add spi.h header to dfu_sf.c
> - Adjust binding to avoid Linux-specific mentions
> - Adjust xfer() method for new API
> - Correct sandbox's xfer() method signature
> - Create a 'spi.bin' file for the SPI tests
> - Fix a typo in the commit message
> - Fix code nits from Daniel Schwierzeck
> - Fix comment on 'slave' parameter to match the parameter name
> - Fix typos reported by Jagannadha Sutradharudu Teki
> - Update for changes to exynos driver
> - Use 'bus' instead of 'dev' to distinguish bus from slave
> - Use 'bus' instead of 'dev' to make the API clearer
>
> Simon Glass (29):
>   sandbox: dts: Add a SPI device and cros_ec device

Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki at gmail.com>

>   dm: core: Add functions for iterating through device children
>   dm: core: Allow parents to pass data to children during probe
>   dm: core: Add a clarifying comment on struct udevice's seq member

Acked-by: Jagannadha Sutradharudu Teki <jagannadh.teki at gmail.com>

>   dm: spi: Add a uclass for SPI

Discussed some follow-up comments which will address in future add-ons

>   dm: sandbox: Add a SPI emulation uclass
>   dm: Remove spi_init() from board_r.c when using driver model
>   dm: Add spi.h header to a few files
>   dm: spi: Adjust cmd_spi to work with driver model
>   dm: sandbox: spi: Move to driver model
>   dm: spi: Rename soft_spi.c to soft_spi_legacy.c
>   dm: spi: Remove SPI_INIT feature
>   dm: spi: Add soft_spi implementation
>   dm: exynos: Convert SPI to driver model
>   dm: spi: Add documentation on how to convert over SPI drivers
>   exynos: universal_c210: Move to driver model soft_spi
>   sf: Tidy up public and private header files
>   spi: Use error return value in sf_ops
>   dm: sf: Add a uclass for SPI flash
>   dm: Convert spi_flash_probe() and 'sf probe' to use driver model
>   dm: sf: sandbox: Convert SPI flash driver to driver model
>   dm: exynos: config: Use driver model for SPI flash

Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki at gmail.com>

>   dm: spi: Add tests
>   dm: sf: Add tests for SPI flash

Acked-by: Jagannadha Sutradharudu Teki <jagannadh.teki at gmail.com>

>   dm: tegra: dts: Add aliases for spi on tegra30 boards
>   dm: tegra: spi: Convert to driver model

Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki at gmail.com>

>   dm: cros_ec: Add support for driver model
>   dm: sandbox: cros_ec: Move sandbox cros_ec to driver module
>   dm: exynos: cros_ec: Move cros_ec_spi to driver model

Acked-by: Jagannadha Sutradharudu Teki <jagannadh.teki at gmail.com>

>
>  arch/arm/dts/exynos4210-universal_c210.dts         |  13 +
>  arch/arm/dts/exynos5250-snow.dts                   |   8 +
>  arch/arm/dts/exynos5420-peach-pit.dts              |   1 +
>  arch/arm/dts/tegra20-trimslice.dts                 |   1 +
>  arch/arm/dts/tegra30-beaver.dts                    |   1 +
>  arch/arm/dts/tegra30-cardhu.dts                    |   1 +
>  arch/arm/dts/tegra30-colibri.dts                   |   1 +
>  arch/arm/include/asm/arch-tegra114/tegra114_spi.h  |  41 --
>  arch/arm/include/asm/arch-tegra20/tegra20_sflash.h |  41 --
>  arch/arm/include/asm/arch-tegra20/tegra20_slink.h  |  41 --
>  arch/sandbox/dts/sandbox.dts                       |  26 +
>  arch/sandbox/include/asm/spi.h                     |  13 -
>  arch/sandbox/include/asm/state.h                   |   2 +-
>  board/buffalo/lsxl/lsxl.c                          |   3 +-
>  board/compulab/common/eeprom.c                     |   2 +-
>  board/nvidia/common/board.c                        |   3 +-
>  board/renesas/sh7752evb/sh7752evb.c                |   1 +
>  board/renesas/sh7753evb/sh7753evb.c                |   1 +
>  board/renesas/sh7757lcr/sh7757lcr.c                |   1 +
>  board/samsung/common/board.c                       |   3 -
>  board/samsung/universal_c210/universal.c           |  52 --
>  common/board_r.c                                   |   2 +-
>  common/cmd_sf.c                                    |  26 +
>  common/cmd_spi.c                                   |  39 +-
>  common/cros_ec.c                                   |  30 ++
>  common/env_sf.c                                    |   1 +
>  common/exports.c                                   |   4 +-
>  doc/device-tree-bindings/mtd/spi/spi-flash.txt     |  25 +
>  doc/device-tree-bindings/spi/soft-spi.txt          |  34 ++
>  doc/driver-model/README.txt                        |   7 +-
>  doc/driver-model/spi-howto.txt                     | 594 +++++++++++++++++++++
>  drivers/core/device.c                              |  36 +-
>  drivers/dfu/dfu_sf.c                               |   1 +
>  drivers/misc/cros_ec.c                             | 122 ++++-
>  drivers/misc/cros_ec_sandbox.c                     |  99 +++-
>  drivers/misc/cros_ec_spi.c                         |  68 ++-
>  drivers/mtd/spi/Makefile                           |   7 +-
>  drivers/mtd/spi/ramtron.c                          |   1 +
>  drivers/mtd/spi/sandbox.c                          | 338 ++++++++++--
>  drivers/mtd/spi/sf-uclass.c                        |  63 +++
>  drivers/mtd/spi/sf_internal.h                      |  67 ++-
>  drivers/mtd/spi/sf_params.c                        |   1 +
>  drivers/mtd/spi/sf_probe.c                         | 154 ++++--
>  drivers/mtd/spi/spi_spl_load.c                     |   1 +
>  drivers/spi/Makefile                               |   9 +-
>  drivers/spi/exynos_spi.c                           | 513 +++++++-----------
>  drivers/spi/fdt_spi.c                              | 186 -------
>  drivers/spi/sandbox_spi.c                          | 200 +++----
>  drivers/spi/soft_spi.c                             | 227 +++++---
>  drivers/spi/soft_spi_legacy.c                      | 176 ++++++
>  drivers/spi/spi-emul-uclass.c                      |  15 +
>  drivers/spi/spi-uclass.c                           | 390 ++++++++++++++
>  drivers/spi/tegra114_spi.c                         | 254 ++++-----
>  drivers/spi/tegra20_sflash.c                       | 238 +++++----
>  drivers/spi/tegra20_slink.c                        | 235 ++++----
>  drivers/spi/tegra_spi.h                            |  12 +
>  include/configs/exynos-common.h                    |   2 +
>  include/configs/peach-pit.h                        |   1 +
>  include/configs/s5pc210_universal.h                |  12 +-
>  include/configs/sacsng.h                           |   1 -
>  include/configs/sandbox.h                          |   5 +-
>  include/configs/tegra-common-post.h                |   2 +-
>  include/configs/tegra-common.h                     |   2 +
>  include/configs/zipitz2.h                          |   1 -
>  include/cros_ec.h                                  |  27 +-
>  include/dm/device-internal.h                       |  13 +
>  include/dm/device.h                                |  25 +-
>  include/dm/uclass-id.h                             |   5 +
>  include/spi.h                                      | 299 ++++++++++-
>  include/spi_flash.h                                | 127 +++--
>  test/dm/Makefile                                   |   2 +
>  test/dm/bus.c                                      |  31 ++
>  test/dm/sf.c                                       |  43 ++
>  test/dm/spi.c                                      | 127 +++++
>  test/dm/test-dm.sh                                 |   2 +
>  test/dm/test.dts                                   |  17 +-
>  76 files changed, 3703 insertions(+), 1472 deletions(-)
>  delete mode 100644 arch/arm/include/asm/arch-tegra114/tegra114_spi.h
>  delete mode 100644 arch/arm/include/asm/arch-tegra20/tegra20_sflash.h
>  delete mode 100644 arch/arm/include/asm/arch-tegra20/tegra20_slink.h
>  create mode 100644 doc/device-tree-bindings/mtd/spi/spi-flash.txt
>  create mode 100644 doc/device-tree-bindings/spi/soft-spi.txt
>  create mode 100644 doc/driver-model/spi-howto.txt
>  create mode 100644 drivers/mtd/spi/sf-uclass.c
>  delete mode 100644 drivers/spi/fdt_spi.c
>  create mode 100644 drivers/spi/soft_spi_legacy.c
>  create mode 100644 drivers/spi/spi-emul-uclass.c
>  create mode 100644 drivers/spi/spi-uclass.c
>  create mode 100644 drivers/spi/tegra_spi.h
>  create mode 100644 test/dm/sf.c
>  create mode 100644 test/dm/spi.c
>
> --
> 2.1.0.rc2.206.gedb03e5
>

thanks!
-- 
Jagan.


More information about the U-Boot mailing list