[U-Boot] [PATCH v7 0/13] Driver model implementation, tests, demo and GPIO

Simon Glass sjg at chromium.org
Fri Nov 29 00:27:31 CET 2013


This series adds a driver model implementation. It is taken from
the driver model code developed by:

   Marek Vasut <marex at denx.de>
   Pavel Herrmann <morpheus.ibis at gmail.com>
   Viktor Křivák <viktor.krivak at gmail.com>
   Tomas Hlavacek <tmshlvck at gmail.com>

Please see doc/driver-model/README.txt for details of how to run this and
what to look for. The old driver model documentation is removed.

Note: If you are reviewing this code, but don't have a lot of time, please
consider starting with the 'demo' driver (patch 'dm: Add a
demonstration/example driver') since it clearly shows how devices and
uclasses work. Much of this series consists of test code and plumbing, so
is of less interest to driver authors.

There is also a presentation on driver model at this page:

http://www.denx.de/wiki/U-Boot/MiniSummitELCE2013

You can find a test version of the code used here in branch dm7 at:

   http://git.denx.de/u-boot-x86.git

(Branch dm contains the original implementation)

Changes in v7:
- Fix typo in README
- Rebase to master
- Update Makefile libraries to specify only the directory
- Update cover letter to point to ELCE 2013 presentation, etc.

Changes in v6:
- Add a test script for driver model
- Add dev_get_platdata to access devices's platdata
- Add dev_get_priv() to access device's private data
- Add ofdata_to_pdata method to convert device tree data to platdata
- Convert Makefiles to new Kconfig format
- Rename platform_data to platdata
- Revise and update README
- Use ofdata_to_platdata feature
- Use ofdata_to_platdata method to convert device tree data to platdata

Changes in v5:
- Adjust patch to completely remove old driver model documentation
- Change to new SPDX license headers
- Correct >80col line missed last time
- Fix style nit on for() loop

Changes in v4:
- Change 'dm dump' command to 'dm tree'
- Correct 'out.dtb' typo
- Move common/dm to drivers/core
- Remove duplicated .op line
- device_chld_unbind() continues on error

Changes in v3:
- Add a flag for tracking whether DM allocates/frees platform_data
- Add function/struct comments to tests
- Add new patch to build a device tree file for sandbox
- Add new patch to move driver model documentation
- Fix up demo command help
- Rename per_device_priv_size to per_device_auto_alloc_size, etc.
- Tidy up commenting of functions and structures
- Tidy up comments/documentation in GPIO module
- Update GPIO support to use new struct member names
- Update demo driver to use device tree
- Update sandbox GPIO header file comments
- Updated README.txt to cover changes since version 2

Changes in v2:
- Add GPIO uclass and tests
- Add U_BOOT_DEVICE to declare platform_data
- Add a single include/dm.h to bring in driver model code
- Add auto-probing feature for platform_data to avoid driver_bind() calls
- Add automatic allocation of device-specific priv data for uclasses
- Add automatic allocation of platform_data for FDT
- Add automatic allocation of priv data for devices
- Add device tree support in driver model
- Add dm_warn() to warn about impending doom
- Add integration tests for driver model
- Add new header file for lists
- Add new util file to hold utility functions
- Add sandbox GPIO driver
- Add script to run tests
- Add simple unit test functions
- Add test infrastructure for driver model
- Add tests for core code
- Allow a driver to bind to only one uclass
- Allow driver_bind() to support a NULL parent
- Put platform_data definitions in their own header file
- Remove relocation functions
- Remove unneeded arguments to uclass_bind(), uclass_unbind()
- Removed pointer return values in favour of integer
- Rename data structures to hopefully be clearer
- Rename struct device's 'bus' to 'parent'
- Standardise variable names (e.g. uclass instead of class)
- Update gpio command to use driver model
- Use driver_bind() in dm_init() instead of writing new code

Simon Glass (13):
  sandbox: Build a device tree file for sandbox
  Add cmd_process_error() to report and process errors
  dm: Add README for driver model
  dm: Add base driver model support
  sandbox: config: Enable driver model
  dm: Set up driver model after relocation
  dm: Add basic tests
  dm: Add a 'dm' command for testing
  dm: Add a demonstration/example driver
  dm: Add GPIO support and tests
  sandbox: Convert GPIOs to use driver model
  dm: Enable gpio command to support driver model
  dm: Remove old driver model documentation

 Makefile                          |   4 +
 arch/sandbox/config.mk            |   2 +
 arch/sandbox/include/asm/gpio.h   |  14 +-
 board/sandbox/dts/sandbox.dts     |  20 ++
 board/sandbox/sandbox/sandbox.c   |   7 +-
 common/Makefile                   |   1 +
 common/board_r.c                  |  33 +++
 common/cmd_demo.c                 | 102 +++++++
 common/cmd_gpio.c                 | 127 ++++++++-
 common/command.c                  |  10 +
 doc/driver-model/README.txt       | 368 ++++++++++++++++++++++++++
 doc/driver-model/UDM-block.txt    | 278 -------------------
 doc/driver-model/UDM-cores.txt    | 126 ---------
 doc/driver-model/UDM-design.txt   | 315 ----------------------
 doc/driver-model/UDM-fpga.txt     | 115 --------
 doc/driver-model/UDM-gpio.txt     | 106 --------
 doc/driver-model/UDM-hwmon.txt    | 118 ---------
 doc/driver-model/UDM-keyboard.txt |  47 ----
 doc/driver-model/UDM-mmc.txt      | 319 ----------------------
 doc/driver-model/UDM-net.txt      | 428 ------------------------------
 doc/driver-model/UDM-pci.txt      | 257 ------------------
 doc/driver-model/UDM-pcmcia.txt   |  78 ------
 doc/driver-model/UDM-power.txt    |  88 ------
 doc/driver-model/UDM-rtc.txt      | 253 ------------------
 doc/driver-model/UDM-serial.txt   | 159 -----------
 doc/driver-model/UDM-spi.txt      | 200 --------------
 doc/driver-model/UDM-stdio.txt    | 191 -------------
 doc/driver-model/UDM-tpm.txt      |  48 ----
 doc/driver-model/UDM-twserial.txt |  47 ----
 doc/driver-model/UDM-usb.txt      |  94 -------
 doc/driver-model/UDM-video.txt    |  74 ------
 doc/driver-model/UDM-watchdog.txt | 329 -----------------------
 drivers/core/Makefile             |   7 +
 drivers/core/device.c             | 348 ++++++++++++++++++++++++
 drivers/core/lists.c              | 155 +++++++++++
 drivers/core/root.c               | 102 +++++++
 drivers/core/uclass.c             | 285 ++++++++++++++++++++
 drivers/core/util.c               |  37 +++
 drivers/demo/Makefile             |   9 +
 drivers/demo/demo-pdata.c         |  47 ++++
 drivers/demo/demo-shape.c         | 127 +++++++++
 drivers/demo/demo-simple.c        |  47 ++++
 drivers/demo/demo-uclass.c        |  58 ++++
 drivers/gpio/Makefile             |   2 +
 drivers/gpio/gpio-uclass.c        | 266 +++++++++++++++++++
 drivers/gpio/sandbox.c            | 217 +++++++++------
 include/asm-generic/global_data.h |   8 +
 include/asm-generic/gpio.h        | 104 ++++++++
 include/command.h                 |   9 +
 include/configs/sandbox.h         |   9 +
 include/dm-demo.h                 |  36 +++
 include/dm.h                      |  14 +
 include/dm/device-internal.h      |  87 ++++++
 include/dm/device.h               | 159 +++++++++++
 include/dm/lists.h                |  39 +++
 include/dm/platdata.h             |  22 ++
 include/dm/root.h                 |  53 ++++
 include/dm/test.h                 | 167 ++++++++++++
 include/dm/uclass-id.h            |  28 ++
 include/dm/uclass-internal.h      |  85 ++++++
 include/dm/uclass.h               | 142 ++++++++++
 include/dm/ut.h                   |  95 +++++++
 include/dm/util.h                 |  29 ++
 test/dm/.gitignore                |   1 +
 test/dm/Makefile                  |  18 ++
 test/dm/cmd_dm.c                  | 133 ++++++++++
 test/dm/core.c                    | 544 ++++++++++++++++++++++++++++++++++++++
 test/dm/gpio.c                    | 111 ++++++++
 test/dm/test-dm.sh                |   7 +
 test/dm/test-driver.c             | 146 ++++++++++
 test/dm/test-fdt.c                | 144 ++++++++++
 test/dm/test-main.c               | 107 ++++++++
 test/dm/test-uclass.c             | 104 ++++++++
 test/dm/test.dts                  |  59 +++++
 test/dm/ut.c                      |  33 +++
 75 files changed, 4787 insertions(+), 3771 deletions(-)
 create mode 100644 board/sandbox/dts/sandbox.dts
 create mode 100644 common/cmd_demo.c
 create mode 100644 doc/driver-model/README.txt
 delete mode 100644 doc/driver-model/UDM-block.txt
 delete mode 100644 doc/driver-model/UDM-cores.txt
 delete mode 100644 doc/driver-model/UDM-design.txt
 delete mode 100644 doc/driver-model/UDM-fpga.txt
 delete mode 100644 doc/driver-model/UDM-gpio.txt
 delete mode 100644 doc/driver-model/UDM-hwmon.txt
 delete mode 100644 doc/driver-model/UDM-keyboard.txt
 delete mode 100644 doc/driver-model/UDM-mmc.txt
 delete mode 100644 doc/driver-model/UDM-net.txt
 delete mode 100644 doc/driver-model/UDM-pci.txt
 delete mode 100644 doc/driver-model/UDM-pcmcia.txt
 delete mode 100644 doc/driver-model/UDM-power.txt
 delete mode 100644 doc/driver-model/UDM-rtc.txt
 delete mode 100644 doc/driver-model/UDM-serial.txt
 delete mode 100644 doc/driver-model/UDM-spi.txt
 delete mode 100644 doc/driver-model/UDM-stdio.txt
 delete mode 100644 doc/driver-model/UDM-tpm.txt
 delete mode 100644 doc/driver-model/UDM-twserial.txt
 delete mode 100644 doc/driver-model/UDM-usb.txt
 delete mode 100644 doc/driver-model/UDM-video.txt
 delete mode 100644 doc/driver-model/UDM-watchdog.txt
 create mode 100644 drivers/core/Makefile
 create mode 100644 drivers/core/device.c
 create mode 100644 drivers/core/lists.c
 create mode 100644 drivers/core/root.c
 create mode 100644 drivers/core/uclass.c
 create mode 100644 drivers/core/util.c
 create mode 100644 drivers/demo/Makefile
 create mode 100644 drivers/demo/demo-pdata.c
 create mode 100644 drivers/demo/demo-shape.c
 create mode 100644 drivers/demo/demo-simple.c
 create mode 100644 drivers/demo/demo-uclass.c
 create mode 100644 drivers/gpio/gpio-uclass.c
 create mode 100644 include/dm-demo.h
 create mode 100644 include/dm.h
 create mode 100644 include/dm/device-internal.h
 create mode 100644 include/dm/device.h
 create mode 100644 include/dm/lists.h
 create mode 100644 include/dm/platdata.h
 create mode 100644 include/dm/root.h
 create mode 100644 include/dm/test.h
 create mode 100644 include/dm/uclass-id.h
 create mode 100644 include/dm/uclass-internal.h
 create mode 100644 include/dm/uclass.h
 create mode 100644 include/dm/ut.h
 create mode 100644 include/dm/util.h
 create mode 100644 test/dm/.gitignore
 create mode 100644 test/dm/Makefile
 create mode 100644 test/dm/cmd_dm.c
 create mode 100644 test/dm/core.c
 create mode 100644 test/dm/gpio.c
 create mode 100755 test/dm/test-dm.sh
 create mode 100644 test/dm/test-driver.c
 create mode 100644 test/dm/test-fdt.c
 create mode 100644 test/dm/test-main.c
 create mode 100644 test/dm/test-uclass.c
 create mode 100644 test/dm/test.dts
 create mode 100644 test/dm/ut.c

-- 
1.8.4.1



More information about the U-Boot mailing list