public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/25] Introduce driver model support for SPI, SPI flash, cros_ec
@ 2014-07-15  0:56 Simon Glass
  2014-07-15  0:56 ` [U-Boot] [PATCH 01/25] sandbox: Convert SPI flash emulation to use sf_params Simon Glass
                   ` (25 more replies)
  0 siblings, 26 replies; 51+ messages in thread
From: Simon Glass @ 2014-07-15  0:56 UTC (permalink / raw)
  To: u-boot

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.

On the other hand, we change the driver at the same time as the CONFIG
option is enabled. Keeping both version of the driver around involves a
flock of #ifdefs, the benefit of which is not apparent to me, since the
old code is removed anyway.

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 help with conversion of SPI drivers to driver model, documentation is
provided which takes the happy camper through the process with an example.

As always, driver model patches are available at u-boot-dm.git branch
'working'.

Note: This series is not fully ready - e.g. some header files are missing
comments. But I wanted to get it out for review early since some SPI work
is ongoing which might depend on it.


Simon Glass (25):
  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: exynos: Convert SPI to driver model
  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

 arch/arm/dts/exynos5250-snow.dts            |   8 +
 arch/arm/dts/exynos5420-peach-pit.dts       |   1 +
 arch/sandbox/dts/sandbox.dts                |  25 ++
 arch/sandbox/include/asm/spi.h              |  13 -
 arch/sandbox/include/asm/state.h            |   2 +-
 board/buffalo/lsxl/lsxl.c                   |   3 +-
 board/samsung/common/board.c                |   3 -
 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/m25p80.txt |  29 ++
 doc/driver-model/spi-howto.txt              | 570 ++++++++++++++++++++++++++++
 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                        |   5 +
 drivers/spi/exynos_spi.c                    | 509 +++++++++----------------
 drivers/spi/sandbox_spi.c                   | 198 ++++------
 drivers/spi/spi-emul-uclass.c               |  15 +
 drivers/spi/spi-uclass.c                    | 253 ++++++++++++
 include/configs/exynos5-dt.h                |   2 +
 include/configs/sandbox.h                   |  13 +-
 include/configs/smdk5420.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.dts                            |  17 +-
 42 files changed, 2504 insertions(+), 762 deletions(-)
 create mode 100644 doc/device-tree-bindings/mtd/spi/m25p80.txt
 create mode 100644 doc/driver-model/spi-howto.txt
 create mode 100644 drivers/mtd/spi/sf-uclass.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.0.0.526.g5318336

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

end of thread, other threads:[~2014-09-15  1:03 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-15  0:56 [U-Boot] [PATCH 0/25] Introduce driver model support for SPI, SPI flash, cros_ec Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 01/25] sandbox: Convert SPI flash emulation to use sf_params Simon Glass
2014-08-25  9:24   ` Jagan Teki
2014-07-15  0:56 ` [U-Boot] [PATCH 02/25] sandbox: config: Enable all SPI flash chips Simon Glass
2014-08-25  9:24   ` Jagan Teki
2014-07-15  0:56 ` [U-Boot] [PATCH 03/25] sandbox: dts: Add a SPI device and cros_ec device Simon Glass
2014-08-25  9:32   ` Jagan Teki
2014-07-15  0:56 ` [U-Boot] [PATCH 04/25] dm: spi: Move cmd device code into its own function Simon Glass
2014-08-25 18:31   ` Jagan Teki
2014-09-02 19:22     ` Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 05/25] spi: Add brackets and tidy defines in spi.h Simon Glass
2014-08-25  9:34   ` Jagan Teki
2014-07-15  0:56 ` [U-Boot] [PATCH 06/25] dm: spi: Add a uclass for SPI Simon Glass
2014-07-15  8:26   ` Pavel Herrmann
2014-07-17  5:39     ` Simon Glass
2014-07-17  7:57       ` Pavel Herrmann
2014-07-17 15:26         ` Simon Glass
2014-07-17 18:01           ` Pavel Herrmann
2014-07-17 18:29             ` Pavel Herrmann
2014-07-21  2:17               ` Simon Glass
2014-07-21  2:15             ` Simon Glass
2014-08-11 21:46   ` Daniel Schwierzeck
2014-08-28  8:58   ` Jagan Teki
2014-08-29 23:38     ` Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 07/25] dm: sandbox: Add a SPI emulation uclass Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 08/25] dm: Remove spi_init() from board_r.c when using driver model Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 09/25] dm: Add spi.h header to a few files Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 10/25] dm: spi: Adjust cmd_spi to work with driver model Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 11/25] dm: sandbox: spi: Move to " Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 12/25] dm: spi: Add documentation on how to convert over SPI drivers Simon Glass
2014-08-28 11:32   ` Jagan Teki
2014-09-01  5:06     ` Simon Glass
2014-09-01  6:45       ` Jagan Teki
2014-09-02  0:24         ` Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 13/25] dm: exynos: Convert SPI to driver model Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 14/25] sf: Add an empty entry to the parameter list Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 15/25] sf: Tidy up public and private header files Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 16/25] spi: Use error return value in sf_ops Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 17/25] dm: sf: Add a uclass for SPI flash Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 18/25] dm: Convert spi_flash_probe() and 'sf probe' to use driver model Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 19/25] dm: sf: sandbox: Convert SPI flash driver to " Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 20/25] dm: exynos: config: Use driver model for SPI flash Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 21/25] dm: spi: Add tests Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 22/25] dm: sf: Add tests for SPI flash Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 23/25] dm: cros_ec: Add support for driver model Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 24/25] dm: sandbox: cros_ec: Move sandbox cros_ec to driver module Simon Glass
2014-07-15  0:56 ` [U-Boot] [PATCH 25/25] dm: exynos: cros_ec: Move cros_ec_spi to driver model Simon Glass
2014-08-09 21:29 ` [U-Boot] [PATCH 0/25] Introduce driver model support for SPI, SPI flash, cros_ec Simon Glass
2014-08-10  9:16   ` Jagan Teki
2014-08-11 19:55     ` Simon Glass
2014-09-15  1:03       ` Simon Glass

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