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 <[email protected]> Pavel Herrmann <[email protected]> Viktor Křivák <[email protected]> Tomas Hlavacek <[email protected]> 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 dm4 at: http://git.denx.de/u-boot-x86.git (Branch dm contains the original implementation) Changes in v5: - Change to new SPDX license headers - Correct >80col line missed last time - Change to new SPDX license headers - Fix style nit on for() loop - Change to new SPDX license headers - Change to new SPDX license headers - Change to new SPDX license headers - Adjust patch to completely remove old driver model documentation Changes in v4: - Move common/dm to drivers/core - device_chld_unbind() continues on error - Correct 'out.dtb' typo - Change 'dm dump' command to 'dm tree' - Remove duplicated .op line Changes in v3: - Add new patch to build a device tree file for sandbox - Updated README.txt to cover changes since version 2 - 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 - 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 Simon Glass (16): 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 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 +- 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 | 102 +++++++ common/cmd_gpio.c | 127 ++++++++- common/command.c | 10 + doc/driver-model/README.txt | 321 ++++++++++++++++++++++ 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 | 434 ------------------------------ 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 | 175 ------------ 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 | 27 ++ drivers/core/device.c | 323 ++++++++++++++++++++++ drivers/core/lists.c | 155 +++++++++++ drivers/core/root.c | 102 +++++++ drivers/core/uclass.c | 285 ++++++++++++++++++++ drivers/core/util.c | 37 +++ drivers/demo/Makefile | 31 +++ drivers/demo/demo-pdata.c | 47 ++++ drivers/demo/demo-shape.c | 130 +++++++++ drivers/demo/demo-simple.c | 47 ++++ drivers/demo/demo-uclass.c | 60 +++++ drivers/gpio/Makefile | 2 + drivers/gpio/gpio-uclass.c | 266 +++++++++++++++++++ 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 | 10 +- include/dm-demo.h | 36 +++ include/dm.h | 14 + include/dm/device-internal.h | 87 ++++++ include/dm/device.h | 136 ++++++++++ include/dm/lists.h | 39 +++ include/dm/platform_data.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 ++ lib/fdtdec.c | 8 +- test/dm/Makefile | 40 +++ test/dm/cmd_dm.c | 133 ++++++++++ test/dm/core.c | 544 ++++++++++++++++++++++++++++++++++++++ test/dm/gpio.c | 111 ++++++++ test/dm/test-driver.c | 146 ++++++++++ test/dm/test-fdt.c | 135 ++++++++++ test/dm/test-main.c | 107 ++++++++ test/dm/test-uclass.c | 104 ++++++++ test/dm/test.dts | 59 +++++ test/dm/ut.c | 33 +++ 77 files changed, 4745 insertions(+), 3802 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/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.4 _______________________________________________ U-Boot mailing list [email protected] http://lists.denx.de/mailman/listinfo/u-boot

