blob: 7bc1962a7546a2bf515f75f31998c3229eb258d7 [file] [log] [blame]
Simon Glassd32f62f2022-05-08 04:39:22 -06001.. SPDX-License-Identifier: GPL-2.0+:
2
3dm command
4==========
5
6Synopis
7-------
8
9::
10
11 dm compat
12 dm devres
13 dm drivers
14 dm static
15 dm tree
16 dm uclass
17
18Description
19-----------
20
21The *dm* command allows viewing information about driver model, including the
22tree of devices and list of available uclasses.
23
24
25dm compat
26~~~~~~~~~
27
28This shows the compatible strings associated with each driver. Often there
29is only one, but multiple strings are shown on their own line. These strings
30can be looked up in the device tree files for each board, to see which driver is
31used for each node.
32
33dm devres
34~~~~~~~~~
35
36This shows a list of a `devres` (device resource) records for a device. Some
37drivers use the devres API to allocate memory, so that it can be freed
38automatically (without any code needed in the driver's remove() method) when the
39device is removed.
40
41This feature is controlled by CONFIG_DEVRES so no useful output is obtained if
42this option is disabled.
43
44dm drivers
45~~~~~~~~~~
46
47This shows all the available drivers, their uclass and a list of devices that
48use that driver, each on its own line. Drivers with no devices are shown with
49`<none>` as the driver name.
50
51
52dm mem
53~~~~~~
54
55This subcommand is really just for debugging and exploration. It can be enabled
56with the `CONFIG_DM_STATS` option.
57
58All output is in hex except that in brackets which is decimal.
59
60The output consists of a header shows the size of the main device model
61structures (struct udevice, struct driver, struct uclass and struct uc_driver)
62and the count and memory used by each (number of devices, memory used by
63devices, memory used by device names, number of uclasses, memory used by
64uclasses).
65
66After that is a table of information about each type of data that can be
67attached to a device, showing the number that have non-null data for that type,
68the total size of all that data, the amount of memory used in total, the
69amount that would be used if this type uses tags instead and the amount that
70would be thus saved.
71
72The `driver_data` line shows the number of devices which have non-NULL driver
73data.
74
75The `tags` line shows the number of tags and the memory used by those.
76
77At the bottom is an indication of the total memory usage obtained by undertaking
78various changes, none of which is currently implemented in U-Boot:
79
80With tags
81 Using tags instead of all attached types
82
83Singly linked
84 Using a singly linked list
85
86driver index
87 Using a driver index instead of a pointer
88
89uclass index
90 Using a uclass index instead of a pointer
91
92Drop device name
93 Using empty device names
94
95
96dm static
97~~~~~~~~~
98
99This shows devices bound by platform data, i.e. not from the device tree. There
100are normally none of these, but some boards may use static devices for space
101reasons.
102
103
104dm tree
105~~~~~~~
106
107This shows the full tree of devices including the following fields:
108
109uclass
110 Shows the name of the uclass for the device
111
112Index
113 Shows the index number of the device, within the uclass. This shows the
114 ordering within the uclass, but not the sequence number.
115
116Probed
117 Shows `+` if the device is active
118
119Driver
120 Shows the name of the driver that this device uses
121
122Name
123 Shows the device name as well as the tree structure, since child devices are
124 shown attached to their parent.
125
126
127dm uclass
128~~~~~~~~~
129
130This shows each uclass along with a list of devices in that uclass. The uclass
131ID is shown (e.g. uclass 7) and its name.
132
133For each device, the format is::
134
135 n name @ a, seq s
136
137where `n` is the index within the uclass, `a` is the address of the device in
138memory and `s` is the sequence number of the device.
139
140
141Examples
142--------
143
144dm compat
145~~~~~~~~~
146
147This example shows an abridged version of the sandbox output::
148
149 => dm compat
150 Driver Compatible
151 --------------------------------
152 act8846_reg
153 sandbox_adder sandbox,adder
154 axi_sandbox_bus sandbox,axi
155 blk_partition
156 bootcount-rtc u-boot,bootcount-rtc
157 ...
158 rockchip_rk805 rockchip,rk805
159 rockchip,rk808
160 rockchip,rk809
161 rockchip,rk816
162 rockchip,rk817
163 rockchip,rk818
164 root_driver
165 rtc-rv8803 microcrystal,rv8803
166 epson,rx8803
167 epson,rx8900
168 ...
169 wdt_gpio linux,wdt-gpio
170 wdt_sandbox sandbox,wdt
171
172
173dm devres
174~~~~~~~~~
175
176This example shows an abridged version of the sandbox test output (running
177U-Boot with the -T flag)::
178
179 => dm devres
180 - root_driver
181 - demo_shape_drv
182 - demo_simple_drv
183 - demo_shape_drv
184 ...
185 - h-test
186 - devres-test
187 00000000130194e0 (100 byte) devm_kmalloc_release BIND
188 - another-test
189 ...
190 - syscon@3
191 - a-mux-controller
192 0000000013025e60 (96 byte) devm_kmalloc_release PROBE
193 0000000013025f00 (24 byte) devm_kmalloc_release PROBE
194 0000000013026010 (24 byte) devm_kmalloc_release PROBE
195 0000000013026070 (24 byte) devm_kmalloc_release PROBE
196 00000000130260d0 (24 byte) devm_kmalloc_release PROBE
197 - syscon@3
198 - a-mux-controller
199 0000000013026150 (96 byte) devm_kmalloc_release PROBE
200 00000000130261f0 (24 byte) devm_kmalloc_release PROBE
201 0000000013026300 (24 byte) devm_kmalloc_release PROBE
202 0000000013026360 (24 byte) devm_kmalloc_release PROBE
203 00000000130263c0 (24 byte) devm_kmalloc_release PROBE
204 - emul-mux-controller
205 0000000013025fa0 (32 byte) devm_kmalloc_release PROBE
206 - testfdtm0
207 - testfdtm1
208 ...
209 - pinmux_spi0_pins
210 - pinmux_uart0_pins
211 - pinctrl-single-bits
212 0000000013229180 (320 byte) devm_kmalloc_release PROBE
213 0000000013229300 (40 byte) devm_kmalloc_release PROBE
214 0000000013229370 (160 byte) devm_kmalloc_release PROBE
215 000000001322c190 (40 byte) devm_kmalloc_release PROBE
216 000000001322c200 (32 byte) devm_kmalloc_release PROBE
217 - pinmux_i2c0_pins
218 ...
219 - reg@0
220 - reg@1
221
222
223dm drivers
224~~~~~~~~~~
225
226This example shows an abridged version of the sandbox output::
227
228 => dm drivers
229 Driver uid uclass Devices
230 ----------------------------------------------------------
231 act8846_reg 087 regulator <none>
232 sandbox_adder 021 axi adder
233 adder
234 axi_sandbox_bus 021 axi axi@0
235 ...
236 da7219 061 misc <none>
237 demo_shape_drv 001 demo demo_shape_drv
238 demo_shape_drv
239 demo_shape_drv
240 demo_simple_drv 001 demo demo_simple_drv
241 demo_simple_drv
242 testfdt_drv 003 testfdt a-test
243 b-test
244 d-test
245 e-test
246 f-test
247 g-test
248 another-test
249 chosen-test
250 testbus_drv 005 testbus some-bus
251 mmio-bus@0
252 mmio-bus@1
253 dsa-port 039 ethernet lan0
254 lan1
255 dsa_sandbox 035 dsa dsa-test
256 eep_sandbox 121 w1_eeprom <none>
257 ...
258 pfuze100_regulator 087 regulator <none>
259 phy_sandbox 077 phy bind-test-child1
260 gen_phy@0
261 gen_phy@1
262 gen_phy@2
263 pinconfig 078 pinconfig gpios
264 gpio0
265 gpio1
266 gpio2
267 gpio3
268 i2c
269 groups
270 pins
271 i2s
272 spi
273 cs
274 pinmux_pwm_pins
275 pinmux_spi0_pins
276 pinmux_uart0_pins
277 pinmux_i2c0_pins
278 pinmux_lcd_pins
279 pmc_sandbox 017 power-mgr pci@1e,0
280 act8846 pmic 080 pmic <none>
281 max77686_pmic 080 pmic <none>
282 mc34708_pmic 080 pmic pmic@41
283 ...
284 wdt_gpio 122 watchdog gpio-wdt
285 wdt_sandbox 122 watchdog wdt@0
286 =>
287
288
289dm mem
290~~~~~~
291
292This example shows the sandbox output::
293
294 > dm mem
295 Struct sizes: udevice b0, driver 80, uclass 30, uc_driver 78
296 Memory: device fe:aea0, device names a16, uclass 5e:11a0
297
298 Attached type Count Size Cur Tags Save
299 --------------- ----- ----- ----- ----- -----
300 plat 45 a8f aea0 a7c4 6dc (1756)
301 parent_plat 1a 3b8 aea0 a718 788 (1928)
302 uclass_plat 3d 6b4 aea0 a7a4 6fc (1788)
303 priv 8a 68f3 aea0 a8d8 5c8 (1480)
304 parent_priv 8 38a0 aea0 a6d0 7d0 (2000)
305 uclass_priv 4e 14a6 aea0 a7e8 6b8 (1720)
306 driver_data f 0 aea0 a6ec 7b4 (1972)
307 uclass 6 20
308 Attached total 191 cb54 3164 (12644)
309 tags 0 0
310
311 Total size: 18b94 (101268)
312
313 With tags: 15a30 (88624)
314 - singly-linked: 14260 (82528)
315 - driver index: 13b6e (80750)
316 - uclass index: 1347c (78972)
317 Drop device name (not SRAM): a16 (2582)
318 =>
319
320
321dm static
322~~~~~~~~~
323
324This example shows the sandbox output::
325
326 => dm static
327 Driver Address
328 ---------------------------------
329 demo_shape_drv 0000562edab8dca0
330 demo_simple_drv 0000562edab8dca0
331 demo_shape_drv 0000562edab8dc90
332 demo_simple_drv 0000562edab8dc80
333 demo_shape_drv 0000562edab8dc80
334 test_drv 0000562edaae8840
335 test_drv 0000562edaae8848
336 test_drv 0000562edaae8850
337 sandbox_gpio 0000000000000000
338 mod_exp_sw 0000000000000000
339 sandbox_test_proc 0000562edabb5330
340 qfw_sandbox 0000000000000000
341 sandbox_timer 0000000000000000
342 sandbox_serial 0000562edaa8ed00
343 sysreset_sandbox 0000000000000000
344
345
346dm tree
347-------
348
349This example shows the abridged sandbox output::
350
351 => dm tree
352 Class Index Probed Driver Name
353 -----------------------------------------------------------
354 root 0 [ + ] root_driver root_driver
355 demo 0 [ ] demo_shape_drv |-- demo_shape_drv
356 demo 1 [ ] demo_simple_drv |-- demo_simple_drv
357 demo 2 [ ] demo_shape_drv |-- demo_shape_drv
358 demo 3 [ ] demo_simple_drv |-- demo_simple_drv
359 demo 4 [ ] demo_shape_drv |-- demo_shape_drv
360 test 0 [ ] test_drv |-- test_drv
361 test 1 [ ] test_drv |-- test_drv
362 test 2 [ ] test_drv |-- test_drv
363 ..
364 sysreset 0 [ ] sysreset_sandbox |-- sysreset_sandbox
365 bootstd 0 [ ] bootstd_drv |-- bootstd
366 bootmeth 0 [ ] bootmeth_distro | |-- syslinux
367 bootmeth 1 [ ] bootmeth_efi | `-- efi
368 reboot-mod 0 [ ] reboot-mode-gpio |-- reboot-mode0
369 reboot-mod 1 [ ] reboot-mode-rtc |-- reboot-mode@14
370 ...
371 ethernet 7 [ + ] dsa-port | `-- lan1
372 pinctrl 0 [ + ] sandbox_pinctrl_gpio |-- pinctrl-gpio
373 gpio 1 [ + ] sandbox_gpio | |-- base-gpios
374 nop 0 [ + ] gpio_hog | | |-- hog_input_active_low
375 nop 1 [ + ] gpio_hog | | |-- hog_input_active_high
376 nop 2 [ + ] gpio_hog | | |-- hog_output_low
377 nop 3 [ + ] gpio_hog | | `-- hog_output_high
378 gpio 2 [ ] sandbox_gpio | |-- extra-gpios
379 gpio 3 [ ] sandbox_gpio | `-- pinmux-gpios
380 i2c 0 [ + ] sandbox_i2c |-- i2c@0
381 i2c_eeprom 0 [ ] i2c_eeprom | |-- eeprom@2c
382 i2c_eeprom 1 [ ] i2c_eeprom_partition | | `-- bootcount@10
383 rtc 0 [ ] sandbox_rtc | |-- rtc@43
384 rtc 1 [ + ] sandbox_rtc | |-- rtc@61
385 i2c_emul_p 0 [ + ] sandbox_i2c_emul_par | |-- emul
386 i2c_emul 0 [ ] sandbox_i2c_eeprom_e | | |-- emul-eeprom
387 i2c_emul 1 [ ] sandbox_i2c_rtc_emul | | |-- emul0
388 i2c_emul 2 [ + ] sandbox_i2c_rtc_emul | | |-- emull
389 i2c_emul 3 [ ] sandbox_i2c_pmic_emu | | |-- pmic-emul0
390 i2c_emul 4 [ ] sandbox_i2c_pmic_emu | | `-- pmic-emul1
391 pmic 0 [ ] sandbox_pmic | |-- sandbox_pmic
392 regulator 0 [ ] sandbox_buck | | |-- buck1
393 regulator 1 [ ] sandbox_buck | | |-- buck2
394 regulator 2 [ ] sandbox_ldo | | |-- ldo1
395 regulator 3 [ ] sandbox_ldo | | |-- ldo2
396 regulator 4 [ ] sandbox_buck | | `-- no_match_by_nodename
397 pmic 1 [ ] mc34708_pmic | `-- pmic@41
398 bootcount 0 [ + ] bootcount-rtc |-- bootcount@0
399 bootcount 1 [ ] bootcount-i2c-eeprom |-- bootcount
400 ...
401 clk 4 [ ] fixed_clock |-- osc
402 firmware 0 [ ] sandbox_firmware |-- sandbox-firmware
403 scmi_agent 0 [ ] sandbox-scmi_agent `-- scmi
404 clk 5 [ ] scmi_clk |-- protocol@14
405 reset 2 [ ] scmi_reset_domain |-- protocol@16
406 nop 8 [ ] scmi_voltage_domain `-- regulators
407 regulator 5 [ ] scmi_regulator |-- reg@0
408 regulator 6 [ ] scmi_regulator `-- reg@1
409 =>
410
411
412dm uclass
413~~~~~~~~~
414
415This example shows the abridged sandbox output::
416
417 => dm uclass
418 uclass 0: root
419 0 * root_driver @ 03015460, seq 0
420
421 uclass 1: demo
422 0 demo_shape_drv @ 03015560, seq 0
423 1 demo_simple_drv @ 03015620, seq 1
424 2 demo_shape_drv @ 030156e0, seq 2
425 3 demo_simple_drv @ 030157a0, seq 3
426 4 demo_shape_drv @ 03015860, seq 4
427
428 uclass 2: test
429 0 test_drv @ 03015980, seq 0
430 1 test_drv @ 03015a60, seq 1
431 2 test_drv @ 03015b40, seq 2
432 ...
433 uclass 20: audio-codec
434 0 audio-codec @ 030168e0, seq 0
435
436 uclass 21: axi
437 0 adder @ 0301db60, seq 1
438 1 adder @ 0301dc40, seq 2
439 2 axi@0 @ 030217d0, seq 0
440
441 uclass 22: blk
442 0 mmc2.blk @ 0301ca00, seq 0
443 1 mmc1.blk @ 0301cee0, seq 1
444 2 mmc0.blk @ 0301d380, seq 2
445
446 uclass 23: bootcount
447 0 * bootcount@0 @ 0301b3f0, seq 0
448 1 bootcount @ 0301b4b0, seq 1
449 2 bootcount_4@0 @ 0301b570, seq 2
450 3 bootcount_2@0 @ 0301b630, seq 3
451
452 uclass 24: bootdev
453 0 mmc2.bootdev @ 0301cbb0, seq 0
454 1 mmc1.bootdev @ 0301d050, seq 1
455 2 mmc0.bootdev @ 0301d4f0, seq 2
456
457 ...
458 uclass 78: pinconfig
459 0 gpios @ 03022410, seq 0
460 1 gpio0 @ 030224d0, seq 1
461 2 gpio1 @ 03022590, seq 2
462 3 gpio2 @ 03022650, seq 3
463 4 gpio3 @ 03022710, seq 4
464 5 i2c @ 030227d0, seq 5
465 6 groups @ 03022890, seq 6
466 7 pins @ 03022950, seq 7
467 8 i2s @ 03022a10, seq 8
468 9 spi @ 03022ad0, seq 9
469 10 cs @ 03022b90, seq 10
470 11 pinmux_pwm_pins @ 03022e10, seq 11
471 12 pinmux_spi0_pins @ 03022ed0, seq 12
472 13 pinmux_uart0_pins @ 03022f90, seq 13
473 14 * pinmux_i2c0_pins @ 03023130, seq 14
474 15 * pinmux_lcd_pins @ 030231f0, seq 15
475
476 ...
477 uclass 119: virtio
478 0 sandbox_virtio1 @ 030220d0, seq 0
479 1 sandbox_virtio2 @ 03022190, seq 1
480
481 uclass 120: w1
482 uclass 121: w1_eeprom
483 uclass 122: watchdog
484 0 * gpio-wdt @ 0301c070, seq 0
485 1 * wdt@0 @ 03021710, seq 1
486
487 =>