[U-Boot] [PATCH v2 0/30] Introduce driver model support for SPI, SPI flash, cros_ec
Simon Glass
sjg at chromium.org
Mon Sep 15 14:33:17 CEST 2014
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, event 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.
As always, driver model patches are available at u-boot-dm.git branch
'working'.
Changes in v2:
- Add new patch to fix README merge error
- Adjust binding to avoid Linux-specific mentions
- Use 'bus' instead of 'dev' to make the API clearer
- Fix code nits from Daniel Schwierzeck
- Add missing comments for struct spi_slave
- Fix comment on 'slave' parameter to match the parameter name
- Fix a typo in the commit message
- Add spi.h header to dfu_sf.c and some renesas boards
- Correct sandbox's xfer() method signature
- Use 'bus' instead of 'dev' to make the API clearer
- Update for changes to exynos driver
- Fix typos reported by Jagannadha Sutradharudu Teki
- Add additional debug() statements
- Use 'bus' instead of 'dev' to distinguish bus from slave
- Adjust xfer() method for new API
- Create a 'spi.bin' file for the SPI tests
Simon Glass (30):
dm: Fix repeated comment in README
sandbox: Convert SPI flash emulation to use sf_params
sandbox: config: Enable all SPI flash chips
sandbox: dts: Add a SPI device and cros_ec device
dm: spi: Move cmd device code into its own function
spi: Add brackets and tidy defines in spi.h
dm: spi: Add a uclass for SPI
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: Add documentation on how to convert over SPI drivers
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
exynos: universal_c210: Move to driver model soft_spi
sf: Add an empty entry to the parameter list
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
dm: spi: Add tests
dm: sf: Add tests for SPI flash
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
README | 5 +-
arch/arm/dts/exynos4210-universal_c210.dts | 13 +
arch/arm/dts/exynos5250-snow.dts | 8 +
arch/arm/dts/exynos5420-peach-pit.dts | 1 +
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/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 | 24 +
common/cmd_spi.c | 73 +++-
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 | 32 ++
doc/driver-model/spi-howto.txt | 583 +++++++++++++++++++++++++
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 | 438 +++++++++++++------
drivers/mtd/spi/sf-uclass.c | 63 +++
drivers/mtd/spi/sf_internal.h | 67 ++-
drivers/mtd/spi/sf_params.c | 2 +
drivers/mtd/spi/sf_probe.c | 153 +++++--
drivers/mtd/spi/spi_spl_load.c | 1 +
drivers/spi/Makefile | 8 +-
drivers/spi/exynos_spi.c | 518 ++++++++--------------
drivers/spi/sandbox_spi.c | 198 +++------
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 | 252 +++++++++++
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 | 13 +-
include/configs/zipitz2.h | 1 -
include/cros_ec.h | 27 +-
include/dm/uclass-id.h | 4 +
include/spi.h | 194 +++++++-
include/spi_flash.h | 127 +++---
test/dm/Makefile | 2 +
test/dm/sf.c | 43 ++
test/dm/spi.c | 47 ++
test/dm/test-dm.sh | 2 +
test/dm/test.dts | 17 +-
56 files changed, 2902 insertions(+), 910 deletions(-)
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
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 test/dm/sf.c
create mode 100644 test/dm/spi.c
--
2.1.0.rc2.206.gedb03e5
More information about the U-Boot
mailing list