u-boot-brain/include/dm
Masahiro Yamada f887cb6d86 dm: add of_match_ptr() macro
The driver model supports two ways for passing device parameters;
Device Tree and platform_data (board file).
Each driver should generally support both of them because some
popular IPs are used on various platforms.

Assume the following scenario:
  - The driver Foo is used on SoC Bar and SoC Baz
  - The SoC Bar uses Device Tree control (CONFIG_OF_CONTROL=y)
  - The SoC Baz does not support Device Tree; uses a board file

In this situation, the device driver Foo should work with/without
the device tree control.  The driver should have .of_match and
.ofdata_to_platdata members for SoC Bar, while they are meaningless
for SoC Baz; therefore those device-tree control code should go
inside #ifdef CONFIG_OF_CONTROL.

The driver code will be like this:

  #ifdef CONFIG_OF_CONTROL
  static const struct udevice_id foo_of_match = {
          { .compatible = "foo_driver" },
          {},
  }

  static int foo_ofdata_to_platdata(struct udevice *dev)
  {
          ...
  }
  #endif

  U_BOOT_DRIVER(foo_driver) = {
          ...
          .of_match = of_match_ptr(foo_of_match),
          .ofdata_to_platdata = of_match_ptr(foo_ofdata_to_platdata),
          ...
  }

This idea has been borrowed from Linux.
(In Linux, this macro is defined in include/linux/of.h)

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Acked-by: Simon Glass <sjg@chromium.org>
2014-10-22 10:32:17 -06:00
..
device-internal.h dm: Allow drivers to be marked 'before relocation' 2014-07-23 14:07:24 +01:00
device.h dm: add of_match_ptr() macro 2014-10-22 10:32:17 -06:00
lists.h dm: fix comments 2014-10-22 10:32:16 -06:00
platdata.h dm: include <linker_lists.h> from platdata.h and uclass.h 2014-10-22 10:32:17 -06:00
root.h dm: Add dm_scan_other() to locate board-specific devices 2014-07-23 14:08:37 +01:00
test.h dm: Add child_pre_probe() and child_post_remove() methods 2014-07-23 14:08:37 +01:00
uclass-id.h dm: Add a uclass for serial devices 2014-09-10 13:00:00 -06:00
uclass-internal.h dm: Introduce device sequence numbering 2014-07-23 14:07:25 +01:00
uclass.h dm: include <linker_lists.h> from platdata.h and uclass.h 2014-10-22 10:32:17 -06:00
ut.h dm: Add basic tests 2014-03-04 12:15:29 -05:00
util.h dm: fix include guard 2014-10-22 10:32:17 -06:00