Commit 5b9000dd25052310ee2d76a295dbe77a2edc5f81

Authored by Simon Glass
1 parent 4c509343ab

dm: core: Add a function to bind a driver for a device tree node

Some device tree nodes do not have compatible strings but do require
drivers. This is pretty rare, and somewhat unfortunate. Add a function
to permit creation of a driver for any device tree node.

Signed-off-by: Simon Glass <sjg@chromium.org>

Showing 2 changed files with 24 additions and 1 deletions Side-by-side Diff

drivers/core/lists.c
... ... @@ -74,6 +74,13 @@
74 74 int device_bind_driver(struct udevice *parent, const char *drv_name,
75 75 const char *dev_name, struct udevice **devp)
76 76 {
  77 + return device_bind_driver_to_node(parent, drv_name, dev_name, -1, devp);
  78 +}
  79 +
  80 +int device_bind_driver_to_node(struct udevice *parent, const char *drv_name,
  81 + const char *dev_name, int node,
  82 + struct udevice **devp)
  83 +{
77 84 struct driver *drv;
78 85 int ret;
79 86  
... ... @@ -82,7 +89,7 @@
82 89 printf("Cannot find driver '%s'\n", drv_name);
83 90 return -ENOENT;
84 91 }
85   - ret = device_bind(parent, drv, dev_name, NULL, -1, devp);
  92 + ret = device_bind(parent, drv, dev_name, NULL, node, devp);
86 93 if (ret) {
87 94 printf("Cannot create device named '%s' (err=%d)\n",
88 95 dev_name, ret);
... ... @@ -73,5 +73,21 @@
73 73 int device_bind_driver(struct udevice *parent, const char *drv_name,
74 74 const char *dev_name, struct udevice **devp);
75 75  
  76 +/**
  77 + * device_bind_driver_to_node() - bind a device to a driver for a node
  78 + *
  79 + * This binds a new device to a driver for a given device tree node. This
  80 + * should only be needed if the node lacks a compatible strings.
  81 + *
  82 + * @parent: Parent device
  83 + * @drv_name: Name of driver to attach to this parent
  84 + * @dev_name: Name of the new device thus created
  85 + * @node: Device tree node
  86 + * @devp: Returns the newly bound device
  87 + */
  88 +int device_bind_driver_to_node(struct udevice *parent, const char *drv_name,
  89 + const char *dev_name, int node,
  90 + struct udevice **devp);
  91 +
76 92 #endif