1.. SPDX-License-Identifier: GPL-2.0+:
2
3bind command
4============
5
6Synopsis
7--------
8
9::
10
11    bind <node path> <driver>
12    bind <class> <index> <driver>
13
14Description
15-----------
16
17The bind command is used to bind a device to a driver. This makes the
18device available in U-Boot.
19
20While binding to a *node path* typically provides a working device
21binding by parent node and driver may lead to a device that is only
22partially initialized.
23
24node path
25    path of the device's device-tree node
26
27class
28    device class name
29
30index
31    index of the parent device in the device class
32
33driver
34    device driver name
35
36Example
37-------
38
39Given a system with a real time clock device with device path */pl031@9010000*
40and using driver rtc-pl031 unbinding and binding of the device is demonstrated
41using the two alternative bind syntaxes.
42
43.. code-block::
44
45    => dm tree
46     Class     Index  Probed  Driver                Name
47    -----------------------------------------------------------
48     root          0  [ + ]   root_driver           root_driver
49    ...
50     rtc           0  [   ]   rtc-pl031             |-- pl031@9010000
51    ...
52    => fdt addr $fdtcontroladdr
53    Working FDT set to 7ed7fdb0
54    => fdt print
55    / {
56            interrupt-parent = <0x00008003>;
57            model = "linux,dummy-virt";
58            #size-cells = <0x00000002>;
59            #address-cells = <0x00000002>;
60            compatible = "linux,dummy-virt";
61    ...
62            pl031@9010000 {
63                    clock-names = "apb_pclk";
64                    clocks = <0x00008000>;
65                    interrupts = <0x00000000 0x00000002 0x00000004>;
66                    reg = <0x00000000 0x09010000 0x00000000 0x00001000>;
67                    compatible = "arm,pl031", "arm,primecell";
68            };
69    ...
70    }
71    => unbind /pl031@9010000
72    => date
73    Cannot find RTC: err=-19
74    => dm tree
75     Class     Index  Probed  Driver                Name
76    -----------------------------------------------------------
77     root          0  [ + ]   root_driver           root_driver
78    ...
79    => bind /pl031@9010000 rtc-pl031
80    => dm tree
81     Class     Index  Probed  Driver                Name
82    -----------------------------------------------------------
83     root          0  [ + ]   root_driver           root_driver
84    ...
85     rtc           0  [   ]   rtc-pl031             |-- pl031@9010000
86    => date
87    Date: 2023-06-22 (Thursday)    Time: 15:14:51
88    => unbind rtc 0 rtc-pl031
89    => bind root 0 rtc-pl031
90    => date
91    Date: 1980-08-19 (Tuesday)    Time: 14:45:30
92
93Obviously the device is not initialized correctly by the last bind command.
94
95Configuration
96-------------
97
98The bind command is only available if CONFIG_CMD_BIND=y.
99
100Return code
101-----------
102
103The return code $? is 0 (true) on success and 1 (false) on failure.
104