Driver model implementation, tests, demo and GPIO
Subsystems (4)
v4 cover Driver model implementation, tests, demo and GPIO
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 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
sandbox: config: Enable driver model
dm: Add README for 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 | 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 | 115 +++++
common/cmd_gpio.c | 127 +++++-
common/command.c | 10 +
doc/driver-model/README.txt | 321 +++++++++++++
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/core/Makefile | 43 ++
drivers/core/device.c | 335 ++++++++++++++
drivers/core/lists.c | 168 +++++++
drivers/core/root.c | 115 +++++
drivers/core/uclass.c | 298 ++++++++++++
drivers/core/util.c | 50 ++
drivers/demo/Makefile | 44 ++
drivers/demo/demo-pdata.c | 60 +++
drivers/demo/demo-shape.c | 143 ++++++
drivers/demo/demo-simple.c | 60 +++
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 | 10 +-
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, 5231 insertions(+), 110 deletions(-)
create mode 100644 board/sandbox/dts/sandbox.dts
create mode 100644 common/cmd_demo.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/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.cSignature · 1 line
1.8.4
PATCH v4 1/16 sandbox: Make map_to_sysmem() use a constant pointer
Very often a constant pointer is passed to this function, so we should declare this, since map_to_sysmem() does not change the pointer.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
arch/sandbox/include/asm/io.h | 2 +- include/common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/sandbox/include/asm/io.h +1 -1
@@ -38,6 +38,6 @@ static inline void unmap_sysmem(const void *vaddr) }/* Map from a pointer to our RAM buffer */ -phys_addr_t map_to_sysmem (void *ptr); +phys_addr_t map_to_sysmem (const void *ptr);#endif
include/common.h +1 -1
@@ -923,7 +923,7 @@ static inline void unmap_sysmem(const void *vaddr) { } -static inline phys_addr_t map_to_sysmem (void *ptr) +static inline phys_addr_t map_to_sysmem (const void *ptr) {return (phys_addr_t )(uintptr_t )ptr; }
Signature · 1 line
1.8.4
PATCH v4 1/16 sandbox: Make map_to_sysmem() use a constant pointer
Dear Simon Glass,
Quoted 4 lines
Very often a constant pointer is passed to this function, so we should declare this, since
map_to_sysmem()does not change the pointer.Signed-off-by Simon Glass <[email protected]>
I think this can be applied separately.
Quoted 26 lines
---
Changes in v4: None
Changes in v3: None
Changes in v2: Nonearch/sandbox/include/asm/io.h | 2 +- include/common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/sandbox/include/asm/io.h +1
-1@@ -38,6 +38,6 @@ static inline void unmap_sysmem(const void *vaddr) }/* Map from a pointer to our RAM buffer */ -phys_addr_t map_to_sysmem (void *ptr); +phys_addr_t map_to_sysmem (const void *ptr);#endif include/common.h +0
-0
include/common.h static inline void unmap_sysmem(const void *vaddr) · line 929
Quoted 8 lines
include/common.h +1
-1@@ -923,7 +923,7 @@ static inline void unmap_sysmem(const void *vaddr) { } -static inline phys_addr_t map_to_sysmem (void *ptr) +static inline phys_addr_t map_to_sysmem (const void *ptr) {return (phys_addr_t )(uintptr_t )ptr; }
Best regards,
Marek Vasut
PATCH v4 2/16 sandbox: Correct data sizes and printf() strings in fdtdec.c
In reply to Simon GlassThere are a few warnings in this file when building for sandbox. Addresses coming from the device tree need to be treated as ulong as elsewhere in U-Boot and we must use map_sysmem() to convert to a pointer when needed.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
lib/fdtdec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/fdtdec.c +4 -4
@@ -84,10 +84,10 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node, size = (fdt_size_t *)((char *)cell +sizeof (fdt_addr_t)); *sizep =fdt_size_to_cpu (*size); -debug ("addr=%p, size=%p\n" , (void *)addr, - (void *)*sizep); +debug ("addr=%08lx, size=%08x\n" , + (ulong )addr, *sizep); }else { -debug ("%p\n" , (void *)addr); +debug ("%08lx\n" , (ulong )addr); }return addr; }
@@ -609,7 +609,7 @@ int fdtdec_decode_region(const void *blob, int node,if (!cell || (len !=sizeof (fdt_addr_t) *2 ))return -1 ; - *ptrp = (void *)fdt_addr_to_cpu (*cell); + *ptrp =map_sysmem (fdt_addr_to_cpu (*cell), *size); *size =fdt_size_to_cpu (cell[1 ]);debug ("%s: size=%zx\n" , __func__, *size);return 0 ;
Signature · 1 line
1.8.4
PATCH v4 2/16 sandbox: Correct data sizes and printf() strings in fdtdec.c
Dear Simon Glass,
Quoted 5 lines
There are a few warnings in this file when building for sandbox. Addresses coming from the device tree need to be treated as ulong as elsewhere in U-Boot and we must use
map_sysmem()to convert to a pointer when needed.Signed-off-by Simon Glass <[email protected]>
Quoted 27 lines
---
Changes in v4: None
Changes in v3: None
Changes in v2: Nonelib/fdtdec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)lib/fdtdec.c +0
-0@@ -84,10 +84,10 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, intnode, size = (
fdt_size_t*)((char *)cell +lib/fdtdec.c +3
-3sizeof(fdt_addr_t)); *sizep =fdt_size_to_cpu (*size); -debug ("addr=%p, size=%p\n" , (void *)addr, - (void *)*sizep); +debug ("addr=%08lx, size=%08x\n" , + (ulong )addr, *sizep); }else { -debug ("%p\n" , (void *)addr); +debug ("%08lx\n" , (ulong )addr); }return addr; }
lib/fdtdec.c int fdtdec_decode_region(const void *blob, int node, · line 615
Quoted 8 lines
lib/fdtdec.c +1
-1@@ -609,7 +609,7 @@ int fdtdec_decode_region(const void *blob, int node,if (!cell || (len !=sizeof (fdt_addr_t) *2 ))return -1 ; - *ptrp = (void *)fdt_addr_to_cpu (*cell); + *ptrp =map_sysmem (fdt_addr_to_cpu (*cell), *size); *size =fdt_size_to_cpu (cell[1 ]);debug ("%s: size=%zx\n" , __func__, *size);return 0 ;
Best regards,
Marek Vasut
PATCH v4 3/16 sandbox: config: Don't use 64-bit physical memory
In reply to Simon GlassSandbox uses an emulated memory map which is quite small. We don't need the CONFIG_PHYS_64BIT option since we can address memory with a 32-bit offset into our ram_buf.
Adjust the phys_addr_t and phys_size_t types accordingly.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
arch/sandbox/include/asm/types.h | 4 ++-- include/configs/sandbox.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-)
arch/sandbox/include/asm/types.h +2 -2
@@ -48,8 +48,8 @@ typedef unsigned long long u64;#define BITS_PER_LONG CONFIG_SANDBOX_BITS_PER_LONGtypedef unsigned long dma_addr_t ; -typedef unsigned long phys_addr_t ; -typedef unsigned long phys_size_t ; +typedef u32 phys_addr_t ; +typedef u32 phys_size_t ;#endif /* __KERNEL__ */
include/configs/sandbox.h +0 -1
@@ -72,7 +72,6 @@#define CONFIG_SYS_LOAD_ADDR 0x00000000#define CONFIG_SYS_MEMTEST_START 0x00100000#define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_MEMTEST_START + 0x1000) -#define CONFIG_PHYS_64BIT #define CONFIG_SYS_FDT_LOAD_ADDR 0x1000000/* Size of our emulated memory */
Signature · 1 line
1.8.4
PATCH v4 3/16 sandbox: config: Don't use 64-bit physical memory
Dear Simon Glass,
Quoted 7 lines
Sandbox uses an emulated memory map which is quite small. We don't need the
CONFIG_PHYS_64BIToption since we can address memory with a 32-bit offset into ourram_buf.Adjust the
phys_addr_tandphys_size_ttypes accordingly.Signed-off-by Simon Glass <[email protected]>
Do we support AMD64 ? I guess not ;-)
btw. is there any real need to mix sandbox patches and DM patches ?
Best regards,
Marek Vasut
PATCH v4 3/16 sandbox: config: Don't use 64-bit physical memory
Hi Marek,
Quoted 4 lines · Marek Vasut
Dear Simon Glass,
Quoted 1 line
Sandbox uses an emulated memory map which is quite small. We don't need
the
Quoted 1 line
Quoted 1 line
CONFIG_PHYS_64BIToption since we can address memory with a 32-bit
offset
Quoted 7 lines
Quoted 5 lines
into our
ram_buf.Adjust the
phys_addr_tandphys_size_ttypes accordingly.Signed-off-by Simon Glass <[email protected]>Do we support AMD64 ? I guess not ;-)
Yes, but even on that sandbox only supports a limited amount of RAM.
Quoted 2 lines
btw. is there any real need to mix sandbox patches and DM patches ?
At present DM needs sandbox since it is the only way to test. It could be a separate dependent series I suppose.
Regards,
Simon
Quoted 3 lines
Best regards,
Marek Vasut
PATCH v4 4/16 sandbox: Build a device tree file for sandbox
In reply to Simon GlassAdd support for building a device tree for sandbox's CONFIG_OF_HOSTFILE option to make it easier to use device tree with sandbox.
This adjusts the Makefile to build a u-boot.dtb file which can be passed to sandbox U-Boot with:
./u-boot -d u-boot.dtb
---
Changes in v4: None
Changes in v3:
- Add new patch to build a device tree file for sandbox
Changes in v2: None
Makefile | 1 + arch/sandbox/config.mk | 2 ++ board/sandbox/dts/sandbox.dts | 20 ++++++++++++++++++++ include/configs/sandbox.h | 1 + 4 files changed, 24 insertions(+) create mode 100644 board/sandbox/dts/sandbox.dts
Makefile +1 -0
@@ -402,6 +402,7 @@ ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin ALL-$(CONFIG_SPL_FRAMEWORK) += $(obj)u-boot.img ALL-$(CONFIG_TPL) += $(obj)tpl/u-boot-tpl.bin ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin +ALL-$(CONFIG_OF_HOSTFILE) += $(obj)u-boot.dtb ifneq ($(CONFIG_SPL_TARGET),) ALL-$(CONFIG_SPL) += $(obj)$(subst ",,$(CONFIG_SPL_TARGET)) endif
arch/sandbox/config.mk +2 -0
@@ -7,3 +7,5 @@ PLATFORM_LIBS += -lrt # Support generic board on sandbox __HAVE_ARCH_GENERIC_BOARD := y + +CONFIG_ARCH_DEVICE_TREE := sandbox
board/sandbox/dts/sandbox.dts new file +20 -0
@@ -0,0 +1,20 @@ +/dts-v1/; + +/ { + triangle { + compatible = "demo-shape"; + colour = "cyan"; + sides = <3>; + character = <83>; + }; + square { + compatible = "demo-shape"; + colour = "blue"; + sides = <4>; + }; + hexagon { + compatible = "demo-simple"; + colour = "white"; + sides = <6>; + }; +};
include/configs/sandbox.h +1 -0
@@ -30,6 +30,7 @@#define CONFIG_FIT_SIGNATURE #define CONFIG_RSA #define CONFIG_CMD_FDT +#define CONFIG_DEFAULT_DEVICE_TREE sandbox#define CONFIG_FS_FAT #define CONFIG_FS_EXT4
Signature · 1 line
1.8.4
PATCH v4 4/16 sandbox: Build a device tree file for sandbox
Dear Simon Glass,
board/sandbox/dts/sandbox.dts
Quoted 51 lines
Add support for building a device tree for sandbox's
CONFIG_OF_HOSTFILEoption to make it easier to use device tree with sandbox.This adjusts the
Makefileto build a u-boot.dtb file which can be passed to sandbox U-Boot with:./u-boot -d u-boot.dtbSigned-off-by Simon Glass <[email protected]>---
Changes in v4: None
Changes in v3:
- Add new patch to build a device tree file for sandboxChanges in v2: None
Makefile | 1 + arch/sandbox/config.mk | 2 ++ board/sandbox/dts/sandbox.dts | 20 ++++++++++++++++++++ include/configs/sandbox.h | 1 + 4 files changed, 24 insertions(+) create mode 100644 board/sandbox/dts/sandbox.dtsMakefile +1
-0@@ -402,6 +402,7 @@ ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin ALL-$(CONFIG_SPL_FRAMEWORK) += $(obj)u-boot.img ALL-$(CONFIG_TPL) += $(obj)tpl/u-boot-tpl.bin ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin +ALL-$(CONFIG_OF_HOSTFILE) += $(obj)u-boot.dtb ifneq ($(CONFIG_SPL_TARGET),) ALL-$(CONFIG_SPL) += $(obj)$(subst ",,$(CONFIG_SPL_TARGET)) endifarch/sandbox/config.mk +2
-0@@ -7,3 +7,5 @@ PLATFORM_LIBS += -lrt # Support generic board on sandbox __HAVE_ARCH_GENERIC_BOARD := y + +CONFIG_ARCH_DEVICE_TREE := sandboxboard/sandbox/dts/sandbox.dts new file +0
-0@@ -0,0 +1,20 @@
Arent you missing a license in this file ?
Quoted 2 lines
board/sandbox/dts/sandbox.dts new file +2
-0+/dts-v1/; +
[...]
PATCH v4 4/16 sandbox: Build a device tree file for sandbox
Hi Marek,
Quoted 44 lines · Marek Vasut
Dear Simon Glass,
Quoted 41 lines
Add support for building a device tree for sandbox's
CONFIG_OF_HOSTFILEoption to make it easier to use device tree with sandbox.This adjusts the
Makefileto build a u-boot.dtb file which can be passed to sandbox U-Boot with:./u-boot -d u-boot.dtbSigned-off-by Simon Glass <[email protected]>---
Changes in v4: None
Changes in v3:
- Add new patch to build a device tree file for sandboxChanges in v2: None
Makefile | 1 + arch/sandbox/config.mk | 2 ++ board/sandbox/dts/sandbox.dts | 20 ++++++++++++++++++++ include/configs/sandbox.h | 1 + 4 files changed, 24 insertions(+) create mode 100644 board/sandbox/dts/sandbox.dtsMakefile +1
-0@@ -402,6 +402,7 @@ ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin ALL-$(CONFIG_SPL_FRAMEWORK) += $(obj)u-boot.img ALL-$(CONFIG_TPL) += $(obj)tpl/u-boot-tpl.bin ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin +ALL-$(CONFIG_OF_HOSTFILE) += $(obj)u-boot.dtb ifneq ($(CONFIG_SPL_TARGET),) ALL-$(CONFIG_SPL) += $(obj)$(subst ",,$(CONFIG_SPL_TARGET)) endifarch/sandbox/config.mk +0
-0@@ -7,3 +7,5 @@ PLATFORM_LIBS += -lrt
Quoted 5 lines
Review
Quoted 5 lines
arch/sandbox/config.mk +2
-0# Support generic board on sandbox __HAVE_ARCH_GENERIC_BOARD := y + +CONFIG_ARCH_DEVICE_TREE := sandbox(quoted diff) +0
-0
b/board/sandbox/dts/sandbox.dts
Quoted 7 lines
board/sandbox/dts/sandbox.dts
Quoted 5 lines
new file mode 100644
index 0000000..96a4438board/sandbox/dts/sandbox.dts new file +0
-0@@ -0,0 +1,20 @@Arent you missing a license in this file ?
Hmm actually I think I need to tidy up all the licenses given the recent changes in U-Boot.
Regards,
Simon
Quoted 4 lines
Quoted 3 lines
board/sandbox/dts/sandbox.dts new file +2
-0+/dts-v1/; +[...]
PATCH v4 5/16 Add cmd_process_error() to report and process errors
In reply to Simon GlassU-Boot now uses errors defined in include/errno.h which are negative integers. Commands which fail need to report the error and return 1 to indicate failure. Add this functionality in cmd_process_error().
For now this merely reports the error number. It would be possible also to produce a helpful error message by storing the error strings in U-Boot.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
common/command.c | 10 ++++++++++ include/command.h | 9 +++++++++ 2 files changed, 19 insertions(+)
common/command.c +10 -0
@@ -538,3 +538,13 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[], rc =cmd_usage (cmdtp);return rc; } + +int cmd_process_error (cmd_tbl_t *cmdtp,int err) +{ +if (err) { +printf ("Command '%s' failed: Error %d\n" , cmdtp->name, err); +return 1 ; + } + +return 0 ; +}
include/command.h +9 -0
@@ -64,6 +64,15 @@ extern int var_complete(int argc, char * const argv[], char last_char, int maxv,extern int cmd_auto_complete (const char *const prompt,char *buf,int *np,int *colp);#endif +/** +* cmd_process_error() - report and process a possible error +* +* @cmdtp: Command which caused the error +* @err: Error code (0 if none, -ve for error, like -EIO) +* @return 0 if there is not error, 1 (CMD_RET_FAILURE) if an error is found +*/ +int cmd_process_error (cmd_tbl_t *cmdtp,int err); +/* * Monitor Command *
Signature · 1 line
1.8.4
PATCH v4 6/16 sandbox: config: Enable driver model
In reply to Simon GlassUse driver model in sandbox to permit running of driver model unit test.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
include/configs/sandbox.h | 1 + 1 file changed, 1 insertion(+)
include/configs/sandbox.h +1 -0
@@ -18,6 +18,7 @@#define CONFIG_BOOTSTAGE #define CONFIG_BOOTSTAGE_REPORT +#define CONFIG_DM /* Number of bits in a C 'long' on this architecture */ #define CONFIG_SANDBOX_BITS_PER_LONG 64
Signature · 1 line
1.8.4
PATCH v4 6/16 sandbox: config: Enable driver model
Dear Simon Glass,
Quoted 4 lines
Use driver model in sandbox to permit running of driver model unit test.
Signed-off-by Simon Glass <[email protected]>---
This should go in as the last patch I believe. CONFIG_DM does not exist yet.
Quoted 12 lines
Changes in v4: None
Changes in v3: None
Changes in v2: Noneinclude/configs/sandbox.h | 1 + 1 file changed, 1 insertion(+)include/configs/sandbox.h +0
-0
include/configs/sandbox.h line 24
Quoted 7 lines
include/configs/sandbox.h +1
-0@@ -18,6 +18,7 @@#define CONFIG_BOOTSTAGE #define CONFIG_BOOTSTAGE_REPORT +#define CONFIG_DM /* Number of bits in a C 'long' on this architecture */ #define CONFIG_SANDBOX_BITS_PER_LONG 64
Best regards,
Marek Vasut
PATCH v4 6/16 sandbox: config: Enable driver model
Hi Marek,
Quoted 9 lines · Marek Vasut
Dear Simon Glass,
Quoted 4 lines
Use driver model in sandbox to permit running of driver model unit test.
Signed-off-by Simon Glass <[email protected]>---
This should go in as the last patch I believe.
CONFIG_DMdoes not exist yet.
This was so I could check the bisectability of each patch as it is added - I'll adjust the order.
Regards,
Simon
PATCH v4 6/16 sandbox: config: Enable driver model
Dear Simon Glass,
Quoted 8 lines
Hi Marek,
Quoted 5 lines · Marek Vasut
Dear Simon Glass,
Quoted 3 lines
Use driver model in sandbox to permit running of driver model unit test.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Simon Glass <[email protected]>---
This should go in as the last patch I believe.
CONFIG_DMdoes not exist yet.This was so I could check the bisectability of each patch as it is added - I'll adjust the order.
Sure, btw I hope we can discuss it on the ELCE. Also, is there any reason you no longer pop up on IRC ?
Best regards,
Marek Vasut
PATCH v4 6/16 sandbox: config: Enable driver model
Hi Marek,
Quoted 16 lines · Marek Vasut
Dear Simon Glass,
Quoted 14 lines
Hi Marek,
Quoted 10 lines · Marek Vasut
Dear Simon Glass,
Quoted 5 lines
Use driver model in sandbox to permit running of driver model unit test.
Signed-off-by Simon Glass <[email protected]>---
This should go in as the last patch I believe.
CONFIG_DMdoes not exist yet.
Quoted 6 lines
Quoted 3 lines
This was so I could check the bisectability of each patch as it is added - I'll adjust the order.
Sure, btw I hope we can discuss it on the ELCE. Also, is there any reason you no longer pop up on IRC ?
Sure we should be able to find time to do that.
I dropped it when I got a new computer...I'll see if I can rectify that.
Regards,
Simon
PATCH v4 7/16 dm: Add README for driver model
In reply to Simon GlassThis adds a README to help with understanding of this series.
---
Changes in v4: None
Changes in v3:
- Updated README.txt to cover changes since version 2
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
doc/driver-model/README.txt | 321 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 doc/driver-model/README.txt
doc/driver-model/README.txt new file +321 -0
@@ -0,0 +1,321 @@ +Driver Model +============ + +This README contains high-level information about driver model, a unified +way of declaring and accessing drivers in U-Boot. The original work was done +by: + + Marek Vasut <[email protected]> + Pavel Herrmann <[email protected]> + Viktor K?iv?k <[email protected]> + Tomas Hlavacek <[email protected]> + +This has been both simplified and extended into the current implementation +by: + + Simon Glass <[email protected]> + + +Terminology +----------- + +Uclass - a group of device which operate in the same way. A uclass provides + a way of accessing invidual devices within the group, but always + using the same interface. For example a GPIO uclass provides + operations for get/set value. An I2C uclass may have 10 I2C ports, + 4 with one driver, and 6 with another. + +Driver - some code which talks to a peripheral and presents a higher-level + interface to it. + +Device - an instance of a driver, tied to a particular port or peripheral. + + +How to try it +------------- + +Build U-Boot sandbox and run it: + + make sandbox_config + make + ./u-boot + + (type 'reset' to exit U-Boot) + + +There is a uclass called 'demo'. This uclass handles +saying hello, and reporting its status. There are two drivers in this +uclass: + + - simple: Just prints a message for hello, doesn't implement status + - shape: Prints shapes and reports number of characters printed as status + +The demo class is pretty simple, but not trivial. The intention is that it +can be used for testing, so it will implement all driver model features and +provide 100% code coverage of them. It does have multiple drivers, it +handles parameter data and platform_data (data which tells the driver how +to operate on a particular platform) and it uses private driver data. + +To try it, see the example session below: + +=>demo hello 1 +Hello '@' from 07981110: red 4 +=>demo status 2 +Status: 0 +=>demo hello 2 +g +r@ +e@@ +e@@@ +n@@@@ +g@@@@@ +=>demo status 2 +Status: 21 +=>demo hello 4 ^ + y^^^ + e^^^^^ +l^^^^^^^ +l^^^^^^^ + o^^^^^ + w^^^ +=>demo status 4 +Status: 36 +=> + + +Running the tests +----------------- + +The intent with driver model is that the core portion has 100% test coverage +in sandbox, and every uclass has its own test. As a move towards this, tests +are provided in test/dm. To run them, try: + + ./test/dm/test-dm.sh + + +What is going on? +----------------- + +Let's start at the top. The demo command is in common/cmd_demo.c. It does +the usual command procesing and then: + + struct device *demo_dev; + + ret = uclass_get_device(UCLASS_DEMO, &demo_dev); + +UCLASS_DEMO means the class of devices which implement 'demo'. Other +classes might be MMC, or GPIO, hashing or serial. The idea is that the +devices in the class all share a particular way of working. The class +presents a unified view of all these devices to U-Boot. + +This function looks up the device for the demo uclass. Given a device +number we can find the device because all devices have registered with +the UCLASS_DEMO uclass. + +Having found the device, we activate it with: + + ret = driver_activate(demo_dev); + +This is because all devices are inactive until used in U-Boot. The exact +mechanism of activating a driver will hopefully change. For example, i +may be possible to combine uclass_get_child() and driver_activate(). + +Now that we have the device we can do things like: + + return demo_hello(demo_dev, ch); + +This function is in the demo uclass. It takes care of calling the 'hello' +method of the relevant driver. Bearing in mind that there are two drivers, +this particular device may use one or other of them. + +The code for demo_hello() is in drivers/demo/demo-uclass.c: + +int demo_hello(struct device *dev, int ch) +{ + const struct demo_ops *ops = device_get_ops(dev); + + if (!ops->hello) + return -ENOSYS; + + return ops->hello(dev, ch); +} + +As you can see it just calls the relevant driver method. One of these is +in drivers/demo/demo-simple.c: + +static int simple_hello(struct device *dev, int ch) +{ + const struct dm_demo_pdata *pdata = dev->platform_data; + + printf("Hello from %08x: %s %d\n", map_to_sysmem(dev), + pdata->colour, pdata->sides); + + return 0; +} + + +So that is a trip from top to bottom but it leaves a lot of topics to +address. + + +Declaring Drivers +----------------- + +A driver declaration looks something like this (see +drivers/demo/demo-shape.c): + +static const struct demo_ops simple_ops = { + .hello = shape_hello, + .status = shape_status, +}; + +U_BOOT_DRIVER(demo_shape_drv) = { + .name = "demo_shape_drv", + .id = UCLASS_DEMO, + .ops = &simple_ops, + .priv_data_size = sizeof(struct shape_data), +}; + + +This driver has two methods (hello and status) and requires a bit +of private data (accessible through dev->priv once the driver has +been probed). It is a member of UCLASS_DEMO so will register itself +there. + +In U_BOOT_DRIVER it is also possible to specify special methods for probe, +and bind, and these are called at appropriate times. For many drivers +it is hoped that only 'probe' and 'remove' will be needed. + +The U_BOOT_DRIVER macro creates a data structure accessible from C, +so driver model can find the drivers that are available. + + +Platform Data +------------- + +Where does the platform data come from? See demo-pdata.c which +sets up a table of driver names and their associated platform data. +The data can be interpreted by the drivers however they like - it is +basically a communication scheme between the board-specific code and +the generic drivers, which are intended to work on any board. + +Drivers can acceess their data via dev->info->platform_data. Here is +the declaration for the platform data, which would normally appear +in the board file. + + static const struct dm_demo_cdata red_square = { + .colour = "red", + .sides = 4. + }; + static const struct driver_info info[] = { + { + .name = "demo_shape_drv", + .platform_data = &red_square, + }, + }; + + demo1 = driver_bind(root, &info[0]); + + +Device Tree +----------- + +While platform_data is useful, a more flexible way of providing device data is +by using device tree. With device tree we replace the above code with the +following device treefragment: + + red-square { + compatible = "demo-shape"; + colour = "red"; + sides = <4>; + }; + + +The easiest way to make this work it to add a platform_data_size member to +the driver: + + .platform_data_auto_alloc_size = sizeof(struct dm_test_pdata), + +This will be allocated and zeroed before the driver's probe method is called. +The driver can then read the information out of the device tree and put it +in dev->priv, typically using a ..._parse_dt() function. + + +Declaring Uclasses +------------------ + +The demo uclass is declared like this: + +U_BOOT_CLASS(demo) = { + .id = UCLASS_DEMO, +}; + +It is also possible to specify special methods for probe, etc. The uclass +numbering comes from include/dm/uclass.h. To add a new uclass, add to the +end of the enum there, then declare your uclass as above. + + +Data Structures +--------------- + +Driver model uses a doubly-linked list as the basic data structure. Some +nodes have several lists running through them. Creating a more efficient +data structure might be worthwhile in some rare cases, once we understand +what the bottlenecks are. + + +Changes since v1 +---------------- + +For the record, this implementation uses a very similar approach to the +original patches, but makes at least the following changes: + +- Tried to agressively remove boilerplate, so that for most drivers there +is little or no 'driver model' code to write. +- Moved some data from code into data structure - e.g. store a pointer to +the driver operations structure in the driver, rather than passing it +to the driver bind function. +- Rename some structures to make them more similar to Linux (struct device +instead of struct instance, struct platform_data, etc.) +- Change the name 'core' to 'uclass', meaning U-Boot class. It seems that +this concept relates to a class of drivers (or a subsystem). We shouldn't +use 'class' since it is a C++ reserved word, so U-Boot class (uclass) seems +better than 'core'. +- Remove 'struct driver_instance' and just use a single 'struct device'. +This removes a level of indirection that doesn't seem necessary. +- Built in device tree support, to avoid the need for platform_data +- Removed the concept of driver relocation, and just make it possible for +the new driver (created after relocation) to access the old driver data. +I feel that relocation is a very special case and will only apply to a few +drivers, many of which can/will just re-init anyway. So the overhead of +dealing with this might not be worth it. +- Implemented a GPIO system, trying to keep it simple + + +Things to punt for later +------------------------ + +- SPL support - this will have to be present before many drivers can be +converted, but it seems like we can add it once we are happy with the +core implementation. +- Pre-relocation support - similar story + +That is not to say that no thinking has gone into these - in fact there +is quite a lot there. However, getting these right is non-trivial and +there is a high cost associated with going down the wrong path. + +For SPL, it may be possible to fit in a simplified driver model with only +bind and probe methods, to reduce size. + +For pre-relocation we can simply call the driver model init function. Then +post relocation we throw that away and re-init driver model again. For drivers +which require some sort of continuity between pre- and post-relocation +devices, we can provide access to the pre-relocatoin device pointers. + + +Simon Glass +sjg at chromium.org +April 2013 +Updated 7-May-13 +Updated 14-Jun-13 +Updated 18-Oct-13
Signature · 1 line
1.8.4
PATCH v4 8/16 dm: Add base driver model support
In reply to Simon GlassAdd driver model functionality for generic board.
This includes data structures and base code for registering devices and uclasses (groups of devices with the same purpose, e.g. all I2C ports will be in the same uclass).
The feature is enabled with CONFIG_DM.
---
Changes in v4:
- Move common/dm to drivers/core
- device_chld_unbind() continues on error
Changes in v3:
- 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
Changes in v2: None
Makefile | 1 + drivers/core/Makefile | 43 +++++ drivers/core/device.c | 335 ++++++++++++++++++++++++++++++++++++++ drivers/core/lists.c | 168 +++++++++++++++++++ drivers/core/root.c | 115 +++++++++++++ drivers/core/uclass.c | 298 +++++++++++++++++++++++++++++++++ drivers/core/util.c | 50 ++++++ include/asm-generic/global_data.h | 8 + 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/uclass-id.h | 41 +++++ include/dm/uclass-internal.h | 98 +++++++++++ include/dm/uclass.h | 155 ++++++++++++++++++ include/dm/util.h | 42 +++++ 18 files changed, 1783 insertions(+) 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 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/uclass-id.h create mode 100644 include/dm/uclass-internal.h create mode 100644 include/dm/uclass.h create mode 100644 include/dm/util.h
Makefile +1 -0
@@ -323,6 +323,7 @@ LIBS-y += lib/libfdt/libfdt.o LIBS-y += api/libapi.o LIBS-y += post/libpost.o LIBS-y += test/libtest.o +LIBS-$(CONFIG_DM) += drivers/core/libdm.o ifneq ($(CONFIG_OMAP_COMMON),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
drivers/core/Makefile new file +43 -0
43 lines not on this page · raw message
drivers/core/device.c new file +335 -0
335 lines not on this page · raw message
drivers/core/lists.c new file +168 -0
168 lines not on this page · raw message
drivers/core/root.c new file +115 -0
115 lines not on this page · raw message
drivers/core/uclass.c new file +298 -0
298 lines not on this page · raw message
drivers/core/util.c new file +50 -0
50 lines not on this page · raw message
include/asm-generic/global_data.h +8 -0
@@ -21,6 +21,8 @@*/ #ifndef __ASSEMBLY__ +#include <linux/list.h> + typedef struct global_data { bd_t *bd; unsigned long flags;
@@ -61,6 +63,12 @@ typedef struct global_data {unsigned long start_addr_sp;/* start_addr_stackpointer */ unsigned long reloc_off;struct global_data *new_gd;/* relocated global data */ + +#ifdef CONFIG_DM +struct device *dm_root;/* Root instance for Driver Model */ +struct list_head uclass_root;/* Head of core tree */ +#endif +const void *fdt_blob;/* Our device tree, NULL if none */ void *new_fdt;/* Relocated FDT */ unsigned long fdt_size;/* Space reserved for relocated FDT */
include/dm.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright (c) 2013 Google, Inc +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +#ifndef _DM_H_ +#define _DM_H + +#include <dm/device.h> +#include <dm/platform_data.h> +#include <dm/uclass.h> + +#endif
include/dm/device-internal.h new file +100 -0
100 lines not on this page · raw message
include/dm/device.h new file +149 -0
149 lines not on this page · raw message
include/dm/lists.h new file +52 -0
52 lines not on this page · raw message
include/dm/platform_data.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright (c) 2013 Google, Inc +* +* (C) Copyright 2012 +* Pavel Herrmann <[email protected]> +* Marek Vasut <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +#ifndef _DM_PLATFORM_DATA_H +#define _DM_PLATFORM_DATA_H + +struct driver_info { +const char *name; +const void *platform_data; +}; + +#define U_BOOT_DEVICE (__name) \ + ll_entry_declare(struct driver_info, __name, driver_info) + +#endif
include/dm/root.h new file +66 -0
66 lines not on this page · raw message
include/dm/uclass-id.h new file +41 -0
41 lines not on this page · raw message
include/dm/uclass-internal.h new file +98 -0
98 lines not on this page · raw message
include/dm/uclass.h new file +155 -0
155 lines not on this page · raw message
include/dm/util.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
1.8.4
PATCH v4 9/16 dm: Set up driver model after relocation
In reply to Simon GlassMake driver model available after relocation, by setting up data structures and scanning for devices using compiled-in platform_data and (when available) the device tree.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
common/board_r.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
common/board_r.c +33 -0
@@ -18,6 +18,7 @@#ifdef CONFIG_HAS_DATAFLASH #include <dataflash.h> #endif +#include <dm.h> #include <environment.h> #include <fdtdec.h> #if defined(CONFIG_CMD_IDE )
@@ -51,7 +52,9 @@#ifdef CONFIG_X86 #include <asm/init_helpers.h> #endif +#include <dm/root.h> #include <linux/compiler.h> +#include <linux/err.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -263,6 +266,33 @@ static int initr_malloc(void)return 0 ; } +#ifdef CONFIG_DM +static int initr_dm (void ) +{ +int ret; + + ret =dm_init (); +if (ret) { +debug ("dm_init() failed: %d\n" , ret); +return ret; + } + ret =dm_scan_platform_data (); +if (ret) { +debug ("dm_scan_platform_data() failed: %d\n" , ret); +return ret; + } +#ifdef CONFIG_OF_CONTROL + ret =dm_scan_fdt (gd->fdt_blob); +if (ret) { +debug ("dm_scan_fdt() failed: %d\n" , ret); +return ret; + } +#endif + +return 0 ; +} +#endif +__weak int power_init_board (void ) {return 0 ;
@@ -761,6 +791,9 @@ init_fnc_t init_sequence_r[] = { initr_barrier, initr_malloc, bootstage_relocate, +#ifdef CONFIG_DM + initr_dm, +#endif #ifdef CONFIG_ARCH_EARLY_INIT_R arch_early_init_r, #endif
Signature · 1 line
1.8.4
PATCH v4 10/16 dm: Add basic tests
In reply to Simon GlassAdd some tests of driver model functionality. Coverage includes:
- basic init
- binding of drivers to devices using platform_data
- automatic probing of devices when referenced
- availability of platform data to devices
- lifecycle from bind to probe to remove to unbind
- renumbering within a uclass when devices are probed/removed
- calling driver-defined operations
- deactivation of drivers when removed
- memory leak across creation and destruction of drivers/uclasses
- uclass init/destroy methods
- automatic probe/remove of children/parents when needed
This function is enabled for sandbox, using CONFIG_DM_TEST.
---
Changes in v4:
- Correct 'out.dtb' typo
Changes in v3:
- Add function/struct comments to tests
Changes in v2: None
Makefile | 1 + include/configs/sandbox.h | 1 + include/dm/test.h | 180 +++++++++++++++ include/dm/ut.h | 108 +++++++++ test/dm/Makefile | 52 +++++ test/dm/core.c | 557 ++++++++++++++++++++++++++++++++++++++++++++++ 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 ++++ 12 files changed, 1548 insertions(+) create mode 100644 include/dm/test.h create mode 100644 include/dm/ut.h create mode 100644 test/dm/Makefile create mode 100644 test/dm/core.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
Makefile +1 -0
@@ -324,6 +324,7 @@ LIBS-y += api/libapi.o LIBS-y += post/libpost.o LIBS-y += test/libtest.o LIBS-$(CONFIG_DM) += drivers/core/libdm.o +LIBS-y += test/dm/libtestdm.o ifneq ($(CONFIG_OMAP_COMMON),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
include/configs/sandbox.h +1 -0
@@ -19,6 +19,7 @@#define CONFIG_BOOTSTAGE #define CONFIG_BOOTSTAGE_REPORT #define CONFIG_DM +#define CONFIG_DM_TEST /* Number of bits in a C 'long' on this architecture */ #define CONFIG_SANDBOX_BITS_PER_LONG 64
include/dm/test.h new file +180 -0
180 lines not on this page · raw message
include/dm/ut.h new file +108 -0
108 lines not on this page · raw message
test/dm/Makefile new file +52 -0
52 lines not on this page · raw message
test/dm/core.c new file +557 -0
557 lines not on this page · raw message
test/dm/test-driver.c new file +159 -0
159 lines not on this page · raw message
test/dm/test-fdt.c new file +148 -0
148 lines not on this page · raw message
test/dm/test-main.c new file +120 -0
120 lines not on this page · raw message
test/dm/test-uclass.c new file +117 -0
117 lines not on this page · raw message
test/dm/test.dts new file +59 -0
59 lines not on this page · raw message
test/dm/ut.c new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
1.8.4
PATCH v4 11/16 dm: Add a 'dm' command for testing
In reply to Simon GlassThis command is not required for driver model operation, but can be useful for testing. It provides simple dumps of internal data structures.
---
Changes in v4:
- Change 'dm dump' command to 'dm tree'
Changes in v3: None
Changes in v2: None
include/configs/sandbox.h | 1 + test/dm/Makefile | 1 + test/dm/cmd_dm.c | 146 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 test/dm/cmd_dm.c
include/configs/sandbox.h +1 -0
@@ -19,6 +19,7 @@#define CONFIG_BOOTSTAGE #define CONFIG_BOOTSTAGE_REPORT #define CONFIG_DM +#define CONFIG_CMD_DM #define CONFIG_DM_TEST /* Number of bits in a C 'long' on this architecture */
test/dm/Makefile +1 -0
@@ -21,6 +21,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)libtestdm.o +COBJS-$(CONFIG_CMD_DM) += cmd_dm.o COBJS-$(CONFIG_DM_TEST) += test-driver.o COBJS-$(CONFIG_DM_TEST) += test-fdt.o COBJS-$(CONFIG_DM_TEST) += test-main.o
test/dm/cmd_dm.c new file +146 -0
146 lines not on this page · raw message
Signature · 1 line
1.8.4
PATCH v4 12/16 dm: Add a demonstration/example driver
In reply to Simon GlassAs an example of how to write a uclass and a driver, provide a demo version of each, accessible through the 'demo' command.
To use these with driver model, define CONFIG_CMD_DEMO and CONFIG_DM_DEMO.
The two demo drivers are enabled with CONFIG_DM_DEMO_SIMPLE and CONFIG_DM_DEMO_SHAPE.
---
Changes in v4:
- Remove duplicated .op line
Changes in v3:
- Fix up demo command help
- Update demo driver to use device tree
Changes in v2: None
Makefile | 1 + common/Makefile | 1 + common/cmd_demo.c | 115 ++++++++++++++++++++++++++++++++++++ drivers/demo/Makefile | 44 ++++++++++++++ drivers/demo/demo-pdata.c | 60 +++++++++++++++++++ drivers/demo/demo-shape.c | 143 +++++++++++++++++++++++++++++++++++++++++++++ drivers/demo/demo-simple.c | 60 +++++++++++++++++++ drivers/demo/demo-uclass.c | 73 +++++++++++++++++++++++ include/configs/sandbox.h | 4 ++ include/dm-demo.h | 49 ++++++++++++++++ 10 files changed, 550 insertions(+) create mode 100644 common/cmd_demo.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 include/dm-demo.h
Makefile +1 -0
@@ -325,6 +325,7 @@ LIBS-y += post/libpost.o LIBS-y += test/libtest.o LIBS-$(CONFIG_DM) += drivers/core/libdm.o LIBS-y += test/dm/libtestdm.o +LIBS-$(CONFIG_DM_DEMO) += drivers/demo/libdemo.o ifneq ($(CONFIG_OMAP_COMMON),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
common/Makefile +1 -0
@@ -67,6 +67,7 @@ COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o COBJS-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o COBJS-$(CONFIG_DATAFLASH_MMC_SELECT) += cmd_dataflash_mmc_mux.o COBJS-$(CONFIG_CMD_DATE) += cmd_date.o +COBJS-$(CONFIG_CMD_DEMO) += cmd_demo.o COBJS-$(CONFIG_CMD_SOUND) += cmd_sound.o ifdef CONFIG_4xx COBJS-$(CONFIG_CMD_SETGETDCR) += cmd_dcr.o
common/cmd_demo.c new file +115 -0
115 lines not on this page · raw message
drivers/demo/Makefile new file +44 -0
44 lines not on this page · raw message
drivers/demo/demo-pdata.c new file +60 -0
60 lines not on this page · raw message
drivers/demo/demo-shape.c new file +143 -0
143 lines not on this page · raw message
drivers/demo/demo-simple.c new file +60 -0
60 lines not on this page · raw message
drivers/demo/demo-uclass.c new file +73 -0
73 lines not on this page · raw message
include/configs/sandbox.h +4 -0
@@ -19,7 +19,11 @@#define CONFIG_BOOTSTAGE #define CONFIG_BOOTSTAGE_REPORT #define CONFIG_DM +#define CONFIG_CMD_DEMO #define CONFIG_CMD_DM +#define CONFIG_DM_DEMO +#define CONFIG_DM_DEMO_SIMPLE +#define CONFIG_DM_DEMO_SHAPE #define CONFIG_DM_TEST /* Number of bits in a C 'long' on this architecture */
include/dm-demo.h new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
1.8.4
PATCH v4 13/16 dm: Add GPIO support and tests
In reply to Simon GlassAdd driver model support for GPIOs. Since existing GPIO drivers do not use driver model, this feature must be enabled by CONFIG_DM_GPIO. After all GPO drivers are converted over we can perhaps remove this config.
Tests are provided for the sandbox implementation, and are a sufficient sanity check for basic operation.
The GPIO uclass understands the concept of named banks of GPIOs, with each GPIO device providing a single bank. Within each bank the GPIOs are numbered using an offset from 0 to n-1. For example a bank named 'b' with 20 offsets will provide GPIOs named b0 to b19.
Anonymous GPIO banks are also supported, and are just numbered without any prefix.
Each time a GPIO driver is added to the uclass, the GPIOs are renumbered accordinging, so there is always a global GPIO numbering order.
---
Changes in v4: None
Changes in v3:
- Update GPIO support to use new struct member names
- Tidy up comments/documentation in GPIO module
Changes in v2: None
drivers/gpio/Makefile | 2 + drivers/gpio/gpio-uclass.c | 279 +++++++++++++++++++++++++++++++++++++++++++++ include/asm-generic/gpio.h | 104 +++++++++++++++++ test/dm/gpio.c | 124 ++++++++++++++++++++ 4 files changed, 509 insertions(+) create mode 100644 drivers/gpio/gpio-uclass.c create mode 100644 test/dm/gpio.c
drivers/gpio/Makefile +2 -0
@@ -9,6 +9,8 @@ include $(TOPDIR)/config.mk LIB := $(obj)libgpio.o +COBJS-$(CONFIG_DM_GPIO) += gpio-uclass.o + COBJS-$(CONFIG_AT91_GPIO) += at91_gpio.o COBJS-$(CONFIG_INTEL_ICH6_GPIO) += intel_ich6_gpio.o COBJS-$(CONFIG_KIRKWOOD_GPIO) += kw_gpio.o
drivers/gpio/gpio-uclass.c new file +279 -0
279 lines not on this page · raw message
include/asm-generic/gpio.h +104 -0
108 lines not on this page · raw message
test/dm/gpio.c new file +124 -0
124 lines not on this page · raw message
Signature · 1 line
1.8.4
PATCH v4 14/16 sandbox: Convert GPIOs to use driver model
In reply to Simon GlassConvert sandbox over to use driver model GPIOs.
---
Changes in v4: None
Changes in v3:
- Update sandbox GPIO header file comments
Changes in v2: None
arch/sandbox/include/asm/gpio.h | 14 +-- board/sandbox/sandbox/sandbox.c | 7 +- drivers/gpio/sandbox.c | 210 +++++++++++++++++++++++++--------------- include/configs/sandbox.h | 1 + 4 files changed, 144 insertions(+), 88 deletions(-)
arch/sandbox/include/asm/gpio.h +5 -9
@@ -29,7 +29,7 @@* @param gp GPIO number * @return -1 on error, 0 if GPIO is low, >0 if high */ -int sandbox_gpio_get_value (unsigned gp); +int sandbox_gpio_get_value (struct device *dev,unsigned int offset);/** * Set the simulated value of a GPIO (used only in sandbox test code)
@@ -38,7 +38,7 @@ int sandbox_gpio_get_value(unsigned gp);* @param value value to set (0 for low, non-zero for high) * @return -1 on error, 0 if ok */ -int sandbox_gpio_set_value (unsigned gp,int value); +int sandbox_gpio_set_value (struct device *dev,unsigned int offset,int value);/** * Return the simulated direction of a GPIO (used only in sandbox test code)
@@ -46,7 +46,7 @@ int sandbox_gpio_set_value(unsigned gp, int value);* @param gp GPIO number * @return -1 on error, 0 if GPIO is input, >0 if output */ -int sandbox_gpio_get_direction (unsigned gp); +int sandbox_gpio_get_direction (struct device *dev,unsigned int offset);/** * Set the simulated direction of a GPIO (used only in sandbox test code)
@@ -55,11 +55,7 @@ int sandbox_gpio_get_direction(unsigned gp);* @param output 0 to set as input, 1 to set as output * @return -1 on error, 0 if ok */ -int sandbox_gpio_set_direction (unsigned gp,int output); - -/* Display information about each GPIO */ -void gpio_info (void ); - -#define gpio_status () gpio_info() +int sandbox_gpio_set_direction (struct device *dev,unsigned int offset, +int output);#endif
board/sandbox/sandbox/sandbox.c +6 -1
@@ -4,7 +4,7 @@*/ #include <common.h> - +#include <dm.h> #include <os.h> /*
@@ -14,6 +14,11 @@*/ gd_t *gd; +/* Add a simple GPIO device */ +U_BOOT_DEVICE (gpio_sandbox) = { + .name ="gpio_sandbox" , +}; +void flush_cache (unsigned long start,unsigned long size) { }
drivers/gpio/sandbox.c +132 -78
311 lines not on this page · raw message
include/configs/sandbox.h +1 -0
@@ -24,6 +24,7 @@#define CONFIG_DM_DEMO #define CONFIG_DM_DEMO_SIMPLE #define CONFIG_DM_DEMO_SHAPE +#define CONFIG_DM_GPIO #define CONFIG_DM_TEST /* Number of bits in a C 'long' on this architecture */
Signature · 1 line
1.8.4
PATCH v4 15/16 dm: Enable gpio command to support driver model
In reply to Simon GlassNow that named GPIO banks are supported, along with a way of obtaining the status of a GPIO (input or output), we can provide an enhanced GPIO command for driver model. Where the driver provides its own operation for obtaining the GPIO state, this is used, otherwise a generic version is sufficient.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
common/cmd_gpio.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 114 insertions(+), 13 deletions(-)
common/cmd_gpio.c +114 -13
@@ -8,7 +8,7 @@#include <common.h> #include <command.h> - +#include <dm.h> #include <asm/gpio.h> #ifndef name_to_gpio
@@ -22,25 +22,115 @@ enum gpio_cmd { GPIO_TOGGLE, }; +#if defined(CONFIG_DM_GPIO ) && !defined(gpio_status) +static const char *const gpio_function[] = { +"input" , +"output" , +"unknown" , +}; + +static void show_gpio (struct device *dev,const char *bank_name,int offset) +{ +struct dm_gpio_ops *ops =gpio_get_ops (dev); +char buf[80 ]; +int ret; + + *buf ='\0' ; +if (ops->get_state) { + ret = ops->get_state (dev, offset, buf,sizeof (buf)); +if (ret) { +puts ("<unknown>" ); +return ; + } + }else { +int func =GPIOF_UNKNOWN ; +int ret; + +if (ops->get_function) { + ret = ops->get_function (dev, offset); +if (ret >=0 && ret <ARRAY_SIZE (gpio_function)) + func = ret; + } +sprintf (buf,"%s%u: %8s %d" , bank_name, offset, + gpio_function[func], ops->get_value (dev, offset)); + } + +puts (buf); +puts ("\n" ); +} + +static int do_gpio_status (const char *gpio_name) +{ +struct device *dev; +int newline =0 ; +int ret; + +if (gpio_name && !*gpio_name) + gpio_name =NULL ; +for (ret =uclass_first_device (UCLASS_GPIO , &dev); + dev; + ret =uclass_next_device (&dev)) { +const char *bank_name; +int num_bits; + + bank_name =gpio_get_bank_info (dev, &num_bits); + +if (!gpio_name || !bank_name || + !strncmp (gpio_name, bank_name,strlen (bank_name))) { +const char *p =NULL ; +int offset; + +if (bank_name) { +if (newline) +putc ('\n' ); +printf ("Bank %s:\n" , bank_name); + } + newline =1 ; +if (gpio_name && bank_name) { + p = gpio_name +strlen (bank_name); + offset =simple_strtoul (p,NULL ,10 ); +show_gpio (dev, bank_name, offset); + }else { +for (offset =0 ; offset < num_bits; offset++) +show_gpio (dev, bank_name, offset); + } + } + } + +return ret; +} +#endif +static int do_gpio (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) { -int gpio; +unsigned int gpio;enum gpio_cmd sub_cmd;ulong value; -const char *str_cmd, *str_gpio; +const char *str_cmd, *str_gpio =NULL ; +#ifdef CONFIG_DM_GPIO +int ret; +#endif +if (argc <2 ) + show_usage: +return CMD_RET_USAGE ; + str_cmd = argv[1 ]; +if (argc >2 ) + str_gpio = argv[2 ]; +if (!strcmp (str_cmd,"status" )) { +/* Support deprecated gpio_status() */ #ifdef gpio_status -if (argc ==2 && !strcmp (argv[1 ],"status" )) {gpio_status ();return 0 ; - } +#elif defined(CONFIG_DM_GPIO ) +return cmd_process_error (cmdtp,do_gpio_status (str_gpio)); +#else + goto show_usage;#endif + } -if (argc !=3 ) - show_usage: -return CMD_RET_USAGE ; - str_cmd = argv[1 ]; - str_gpio = argv[2 ]; +if (!str_gpio) + goto show_usage;/* parse the behavior */ switch (*str_cmd) {
@@ -51,11 +141,21 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])default : goto show_usage; } +#if defined(CONFIG_DM_GPIO ) +/* +* TODO(sjg at chromium.org): Convert this code over to use the GPIO +* uclass interface instead of the numbered GPIO compatibility +* layer. +*/ + ret =gpio_lookup_name (str_gpio,NULL ,NULL , &gpio); +if (ret) +return cmd_process_error (cmdtp, ret); +#else /* turn the gpio name into a gpio number */ gpio =name_to_gpio (str_gpio);if (gpio <0 ) goto show_usage; - +#endif /* grab the pin before we tweak it */ if (gpio_request (gpio,"cmd_gpio" )) {printf ("gpio: requesting pin %u failed\n" , gpio);
@@ -84,6 +184,7 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }U_BOOT_CMD (gpio,3 ,0 , do_gpio, -"input/set/clear/toggle gpio pins" , +"query and control gpio pins" ,"<input|set|clear|toggle> <pin>\n" -" - input/set/clear/toggle the specified pin" ); +" - input/set/clear/toggle the specified pin\n" +"gpio status [<bank> | <pin>]" );
Signature · 1 line
1.8.4
PATCH v4 16/16 dm: Move old driver model documentation into an 'old-docs' directory
In reply to Simon GlassThis documentation is still useful but is not fully correct with the API changes since the original driver model implementation. So move it into a separate directory, and create a README to describe what is going on.
This documentation pertains to the planned implementation of driver model in U-Boot for each subsystem. It is probably better to have this documentation in the source code for each subsystem where possible, so that docbook will pick it up. Where this does not make sense, new documentation can be placed in some suitable file in doc/driver-model.
---
Changes in v4: None
Changes in v3:
- Add new patch to move driver model documentation
Changes in v2: None
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
22 files changed, 29 insertions(+)
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%)doc/driver-model/old-docs/README new file +29 -0
@@ -0,0 +1,29 @@ +The U-Boot Driver Model Project +=============================== + +This directory contains the original driver model documents. The documents +are still useful and relevant, but some of the terminology has changed, +and some of the APIs are a little different. + +The changes (which are not reflected in the docs in this directory) are: + +- Tried to agressively remove boilerplate, so that for most drivers there +is little or no 'driver model' code to write. +- Moved some data from code into data structure - e.g. store a pointer to +the driver operations structure in the driver, rather than passing it +to the driver bind function. +- Rename some structures to make them more similar to Linux (struct device +instead of struct instance, struct platform_data, etc.) +- Change the name 'core' to 'uclass', meaning U-Boot class. It seems that +this concept relates to a class of drivers (or a subsystem). We shouldn't +use 'class' since it is a C++ reserved word, so U-Boot class (uclass) seems +better than 'core'. +- Remove 'struct driver_instance' and just use a single 'struct device'. +This removes a level of indirection that doesn't seem necessary. +- Built in device tree support, to avoid the need for platform_data +- Removed the concept of driver relocation, and just make it possible for +the new driver (created after relocation) to access the old driver data. +I feel that relocation is a very special case and will only apply to a few +drivers, many of which can/will just re-init anyway. So the overhead of +dealing with this might not be worth it. +- Implemented a GPIO system, trying to keep it simple
doc/driver-model/old-docs/UDM-block.txt renamed from doc/driver-model/UDM-block.txt +0 -0
doc/driver-model/old-docs/UDM-cores.txt renamed from doc/driver-model/UDM-cores.txt +0 -0
doc/driver-model/old-docs/UDM-design.txt renamed from doc/driver-model/UDM-design.txt +0 -0
doc/driver-model/old-docs/UDM-fpga.txt renamed from doc/driver-model/UDM-fpga.txt +0 -0
doc/driver-model/old-docs/UDM-gpio.txt renamed from doc/driver-model/UDM-gpio.txt +0 -0
doc/driver-model/old-docs/UDM-hwmon.txt renamed from doc/driver-model/UDM-hwmon.txt +0 -0
doc/driver-model/old-docs/UDM-keyboard.txt renamed from doc/driver-model/UDM-keyboard.txt +0 -0
doc/driver-model/old-docs/UDM-mmc.txt renamed from doc/driver-model/UDM-mmc.txt +0 -0
doc/driver-model/old-docs/UDM-net.txt renamed from doc/driver-model/UDM-net.txt +0 -0
doc/driver-model/old-docs/UDM-pci.txt renamed from doc/driver-model/UDM-pci.txt +0 -0
doc/driver-model/old-docs/UDM-pcmcia.txt renamed from doc/driver-model/UDM-pcmcia.txt +0 -0
doc/driver-model/old-docs/UDM-power.txt renamed from doc/driver-model/UDM-power.txt +0 -0
doc/driver-model/old-docs/UDM-rtc.txt renamed from doc/driver-model/UDM-rtc.txt +0 -0
doc/driver-model/old-docs/UDM-serial.txt renamed from doc/driver-model/UDM-serial.txt +0 -0
doc/driver-model/old-docs/UDM-spi.txt renamed from doc/driver-model/UDM-spi.txt +0 -0
doc/driver-model/old-docs/UDM-stdio.txt renamed from doc/driver-model/UDM-stdio.txt +0 -0
doc/driver-model/old-docs/UDM-tpm.txt renamed from doc/driver-model/UDM-tpm.txt +0 -0
doc/driver-model/old-docs/UDM-twserial.txt renamed from doc/driver-model/UDM-twserial.txt +0 -0
doc/driver-model/old-docs/UDM-usb.txt renamed from doc/driver-model/UDM-usb.txt +0 -0
doc/driver-model/old-docs/UDM-video.txt renamed from doc/driver-model/UDM-video.txt +0 -0
doc/driver-model/old-docs/UDM-watchdog.txt renamed from doc/driver-model/UDM-watchdog.txt +0 -0
Signature · 1 line
1.8.4
PATCH v4 16/16 dm: Move old driver model documentation into an 'old-docs' directory
Dear Simon Glass,
Quoted 11 lines
This documentation is still useful but is not fully correct with the API changes since the original driver model implementation. So move it into a separate directory, and create a README to describe what is going on.
This documentation pertains to the planned implementation of driver model in U-Boot for each subsystem. It is probably better to have this documentation in the source code for each subsystem where possible, so that docbook will pick it up. Where this does not make sense, new documentation can be placed in some suitable file in doc/driver-model.
Signed-off-by Simon Glass <[email protected]>
I'd just remove the old documentation, it's useless and out-of-date now.
Best regards,
Marek Vasut
PATCH v4 16/16 dm: Move old driver model documentation into an 'old-docs' directory
Hi Marek,
Quoted 12 lines · Marek Vasut
Dear Simon Glass,
Quoted 10 lines
This documentation is still useful but is not fully correct with the API changes since the original driver model implementation. So move it into a separate directory, and create a README to describe what is going on.
This documentation pertains to the planned implementation of driver model in U-Boot for each subsystem. It is probably better to have this documentation in the source code for each subsystem where possible, so that docbook will pick it up. Where this does not make sense, new documentation can be placed in some suitable file in doc/driver-model.
Quoted 3 lines
Quoted 1 line
Signed-off-by Simon Glass <[email protected]>I'd just remove the old documentation, it's useless and out-of-date now.
OK, done.
Regards,
Simon