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

Simon Glass sjg at chromium.org
Wed Jun 19 05:52:24 CEST 2013


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.

This patch 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. So far the documentation in doc/driver-model has not
been updated.

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

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

(Branch dm contains the original implementation)

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

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

Pavel Herrmann (1):
  dm: Add README for driver model

Simon Glass (15):
  sandbox: Make map_to_sysmem() use a constant pointer
  sandbox: Correct data sizes and printf() strings in fdtdec.c
  sandbox: config: Don't use 64-bit physical memory
  sandbox: Build a device tree file for sandbox
  Add cmd_process_error() to report and process errors
  sandbox: config: Enable driver model
  dm: Add base driver model support
  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: Move old driver model documentation into an 'old-docs' directory

 Makefile                                         |   5 +
 arch/sandbox/config.mk                           |   2 +
 arch/sandbox/include/asm/gpio.h                  |  14 +-
 arch/sandbox/include/asm/io.h                    |   2 +-
 arch/sandbox/include/asm/types.h                 |   4 +-
 board/sandbox/dts/sandbox.dts                    |  20 +
 board/sandbox/sandbox/sandbox.c                  |   7 +-
 common/Makefile                                  |   1 +
 common/board_r.c                                 |  33 ++
 common/cmd_demo.c                                | 115 +++++
 common/cmd_gpio.c                                | 127 +++++-
 common/command.c                                 |  10 +
 common/dm/Makefile                               |  43 ++
 common/dm/device.c                               | 331 ++++++++++++++
 common/dm/lists.c                                | 168 +++++++
 common/dm/root.c                                 | 115 +++++
 common/dm/uclass.c                               | 298 ++++++++++++
 common/dm/util.c                                 |  50 ++
 doc/driver-model/README.txt                      | 320 +++++++++++++
 doc/driver-model/old-docs/README                 |  29 ++
 doc/driver-model/{ => old-docs}/UDM-block.txt    |   0
 doc/driver-model/{ => old-docs}/UDM-cores.txt    |   0
 doc/driver-model/{ => old-docs}/UDM-design.txt   |   0
 doc/driver-model/{ => old-docs}/UDM-fpga.txt     |   0
 doc/driver-model/{ => old-docs}/UDM-gpio.txt     |   0
 doc/driver-model/{ => old-docs}/UDM-hwmon.txt    |   0
 doc/driver-model/{ => old-docs}/UDM-keyboard.txt |   0
 doc/driver-model/{ => old-docs}/UDM-mmc.txt      |   0
 doc/driver-model/{ => old-docs}/UDM-net.txt      |   0
 doc/driver-model/{ => old-docs}/UDM-pci.txt      |   0
 doc/driver-model/{ => old-docs}/UDM-pcmcia.txt   |   0
 doc/driver-model/{ => old-docs}/UDM-power.txt    |   0
 doc/driver-model/{ => old-docs}/UDM-rtc.txt      |   0
 doc/driver-model/{ => old-docs}/UDM-serial.txt   |   0
 doc/driver-model/{ => old-docs}/UDM-spi.txt      |   0
 doc/driver-model/{ => old-docs}/UDM-stdio.txt    |   0
 doc/driver-model/{ => old-docs}/UDM-tpm.txt      |   0
 doc/driver-model/{ => old-docs}/UDM-twserial.txt |   0
 doc/driver-model/{ => old-docs}/UDM-usb.txt      |   0
 doc/driver-model/{ => old-docs}/UDM-video.txt    |   0
 doc/driver-model/{ => old-docs}/UDM-watchdog.txt |   0
 drivers/demo/Makefile                            |  44 ++
 drivers/demo/demo-pdata.c                        |  60 +++
 drivers/demo/demo-shape.c                        | 143 ++++++
 drivers/demo/demo-simple.c                       |  61 +++
 drivers/demo/demo-uclass.c                       |  73 +++
 drivers/gpio/Makefile                            |   2 +
 drivers/gpio/gpio-uclass.c                       | 279 ++++++++++++
 drivers/gpio/sandbox.c                           | 210 +++++----
 include/asm-generic/global_data.h                |   8 +
 include/asm-generic/gpio.h                       | 104 +++++
 include/command.h                                |   9 +
 include/common.h                                 |   2 +-
 include/configs/sandbox.h                        |  11 +-
 include/dm-demo.h                                |  49 ++
 include/dm.h                                     |  27 ++
 include/dm/device-internal.h                     | 100 ++++
 include/dm/device.h                              | 149 ++++++
 include/dm/lists.h                               |  52 +++
 include/dm/platform_data.h                       |  35 ++
 include/dm/root.h                                |  66 +++
 include/dm/test.h                                | 180 ++++++++
 include/dm/uclass-id.h                           |  41 ++
 include/dm/uclass-internal.h                     |  98 ++++
 include/dm/uclass.h                              | 155 +++++++
 include/dm/ut.h                                  | 108 +++++
 include/dm/util.h                                |  42 ++
 lib/fdtdec.c                                     |   8 +-
 test/dm/Makefile                                 |  53 +++
 test/dm/cmd_dm.c                                 | 146 ++++++
 test/dm/core.c                                   | 557 +++++++++++++++++++++++
 test/dm/gpio.c                                   | 124 +++++
 test/dm/test-driver.c                            | 159 +++++++
 test/dm/test-fdt.c                               | 148 ++++++
 test/dm/test-main.c                              | 120 +++++
 test/dm/test-uclass.c                            | 117 +++++
 test/dm/test.dts                                 |  59 +++
 test/dm/ut.c                                     |  46 ++
 78 files changed, 5229 insertions(+), 110 deletions(-)
 create mode 100644 board/sandbox/dts/sandbox.dts
 create mode 100644 common/cmd_demo.c
 create mode 100644 common/dm/Makefile
 create mode 100644 common/dm/device.c
 create mode 100644 common/dm/lists.c
 create mode 100644 common/dm/root.c
 create mode 100644 common/dm/uclass.c
 create mode 100644 common/dm/util.c
 create mode 100644 doc/driver-model/README.txt
 create mode 100644 doc/driver-model/old-docs/README
 rename doc/driver-model/{ => old-docs}/UDM-block.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-cores.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-design.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-fpga.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-gpio.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-hwmon.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-keyboard.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-mmc.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-net.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-pci.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-pcmcia.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-power.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-rtc.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-serial.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-spi.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-stdio.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-tpm.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-twserial.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-usb.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-video.txt (100%)
 rename doc/driver-model/{ => old-docs}/UDM-watchdog.txt (100%)
 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/platform_data.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/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 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.3



More information about the U-Boot mailing list