blob: 236cd02bd624cb6dffec53f416cc63673047fda0 [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
Simon Glass3d012542023-01-17 10:47:12 -070015 dm tree [-s]
Simon Glassd32f62f2022-05-08 04:39:22 -060016 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
Simon Glass3d012542023-01-17 10:47:12 -0700126If -s is given, the top-level devices (those which are children of the root
127device) are shown sorted in order of uclass ID, so it is easier to find a
128particular device type.
Simon Glassd32f62f2022-05-08 04:39:22 -0600129
130dm uclass
131~~~~~~~~~
132
133This shows each uclass along with a list of devices in that uclass. The uclass
134ID is shown (e.g. uclass 7) and its name.
135
136For each device, the format is::
137
138 n name @ a, seq s
139
140where `n` is the index within the uclass, `a` is the address of the device in
141memory and `s` is the sequence number of the device.
142
143
144Examples
145--------
146
147dm compat
148~~~~~~~~~
149
150This example shows an abridged version of the sandbox output::
151
152 => dm compat
153 Driver Compatible
154 --------------------------------
155 act8846_reg
156 sandbox_adder sandbox,adder
157 axi_sandbox_bus sandbox,axi
158 blk_partition
159 bootcount-rtc u-boot,bootcount-rtc
160 ...
161 rockchip_rk805 rockchip,rk805
162 rockchip,rk808
163 rockchip,rk809
164 rockchip,rk816
165 rockchip,rk817
166 rockchip,rk818
167 root_driver
168 rtc-rv8803 microcrystal,rv8803
169 epson,rx8803
170 epson,rx8900
171 ...
172 wdt_gpio linux,wdt-gpio
173 wdt_sandbox sandbox,wdt
174
175
176dm devres
177~~~~~~~~~
178
179This example shows an abridged version of the sandbox test output (running
180U-Boot with the -T flag)::
181
182 => dm devres
183 - root_driver
184 - demo_shape_drv
185 - demo_simple_drv
186 - demo_shape_drv
187 ...
188 - h-test
189 - devres-test
190 00000000130194e0 (100 byte) devm_kmalloc_release BIND
191 - another-test
192 ...
193 - syscon@3
194 - a-mux-controller
195 0000000013025e60 (96 byte) devm_kmalloc_release PROBE
196 0000000013025f00 (24 byte) devm_kmalloc_release PROBE
197 0000000013026010 (24 byte) devm_kmalloc_release PROBE
198 0000000013026070 (24 byte) devm_kmalloc_release PROBE
199 00000000130260d0 (24 byte) devm_kmalloc_release PROBE
200 - syscon@3
201 - a-mux-controller
202 0000000013026150 (96 byte) devm_kmalloc_release PROBE
203 00000000130261f0 (24 byte) devm_kmalloc_release PROBE
204 0000000013026300 (24 byte) devm_kmalloc_release PROBE
205 0000000013026360 (24 byte) devm_kmalloc_release PROBE
206 00000000130263c0 (24 byte) devm_kmalloc_release PROBE
207 - emul-mux-controller
208 0000000013025fa0 (32 byte) devm_kmalloc_release PROBE
209 - testfdtm0
210 - testfdtm1
211 ...
212 - pinmux_spi0_pins
213 - pinmux_uart0_pins
214 - pinctrl-single-bits
215 0000000013229180 (320 byte) devm_kmalloc_release PROBE
216 0000000013229300 (40 byte) devm_kmalloc_release PROBE
217 0000000013229370 (160 byte) devm_kmalloc_release PROBE
218 000000001322c190 (40 byte) devm_kmalloc_release PROBE
219 000000001322c200 (32 byte) devm_kmalloc_release PROBE
220 - pinmux_i2c0_pins
221 ...
222 - reg@0
223 - reg@1
224
225
226dm drivers
227~~~~~~~~~~
228
229This example shows an abridged version of the sandbox output::
230
231 => dm drivers
232 Driver uid uclass Devices
233 ----------------------------------------------------------
234 act8846_reg 087 regulator <none>
235 sandbox_adder 021 axi adder
236 adder
237 axi_sandbox_bus 021 axi axi@0
238 ...
239 da7219 061 misc <none>
240 demo_shape_drv 001 demo demo_shape_drv
241 demo_shape_drv
242 demo_shape_drv
243 demo_simple_drv 001 demo demo_simple_drv
244 demo_simple_drv
245 testfdt_drv 003 testfdt a-test
246 b-test
247 d-test
248 e-test
249 f-test
250 g-test
251 another-test
252 chosen-test
253 testbus_drv 005 testbus some-bus
254 mmio-bus@0
255 mmio-bus@1
256 dsa-port 039 ethernet lan0
257 lan1
258 dsa_sandbox 035 dsa dsa-test
259 eep_sandbox 121 w1_eeprom <none>
260 ...
261 pfuze100_regulator 087 regulator <none>
262 phy_sandbox 077 phy bind-test-child1
263 gen_phy@0
264 gen_phy@1
265 gen_phy@2
266 pinconfig 078 pinconfig gpios
267 gpio0
268 gpio1
269 gpio2
270 gpio3
271 i2c
272 groups
273 pins
274 i2s
275 spi
276 cs
277 pinmux_pwm_pins
278 pinmux_spi0_pins
279 pinmux_uart0_pins
280 pinmux_i2c0_pins
281 pinmux_lcd_pins
282 pmc_sandbox 017 power-mgr pci@1e,0
283 act8846 pmic 080 pmic <none>
284 max77686_pmic 080 pmic <none>
285 mc34708_pmic 080 pmic pmic@41
286 ...
287 wdt_gpio 122 watchdog gpio-wdt
288 wdt_sandbox 122 watchdog wdt@0
289 =>
290
291
292dm mem
293~~~~~~
294
295This example shows the sandbox output::
296
297 > dm mem
298 Struct sizes: udevice b0, driver 80, uclass 30, uc_driver 78
299 Memory: device fe:aea0, device names a16, uclass 5e:11a0
300
301 Attached type Count Size Cur Tags Save
302 --------------- ----- ----- ----- ----- -----
303 plat 45 a8f aea0 a7c4 6dc (1756)
304 parent_plat 1a 3b8 aea0 a718 788 (1928)
305 uclass_plat 3d 6b4 aea0 a7a4 6fc (1788)
306 priv 8a 68f3 aea0 a8d8 5c8 (1480)
307 parent_priv 8 38a0 aea0 a6d0 7d0 (2000)
308 uclass_priv 4e 14a6 aea0 a7e8 6b8 (1720)
309 driver_data f 0 aea0 a6ec 7b4 (1972)
310 uclass 6 20
311 Attached total 191 cb54 3164 (12644)
312 tags 0 0
313
314 Total size: 18b94 (101268)
315
316 With tags: 15a30 (88624)
317 - singly-linked: 14260 (82528)
318 - driver index: 13b6e (80750)
319 - uclass index: 1347c (78972)
320 Drop device name (not SRAM): a16 (2582)
321 =>
322
323
324dm static
325~~~~~~~~~
326
327This example shows the sandbox output::
328
329 => dm static
330 Driver Address
331 ---------------------------------
332 demo_shape_drv 0000562edab8dca0
333 demo_simple_drv 0000562edab8dca0
334 demo_shape_drv 0000562edab8dc90
335 demo_simple_drv 0000562edab8dc80
336 demo_shape_drv 0000562edab8dc80
337 test_drv 0000562edaae8840
338 test_drv 0000562edaae8848
339 test_drv 0000562edaae8850
340 sandbox_gpio 0000000000000000
341 mod_exp_sw 0000000000000000
342 sandbox_test_proc 0000562edabb5330
343 qfw_sandbox 0000000000000000
344 sandbox_timer 0000000000000000
345 sandbox_serial 0000562edaa8ed00
346 sysreset_sandbox 0000000000000000
347
348
349dm tree
350-------
351
352This example shows the abridged sandbox output::
353
354 => dm tree
355 Class Index Probed Driver Name
356 -----------------------------------------------------------
357 root 0 [ + ] root_driver root_driver
358 demo 0 [ ] demo_shape_drv |-- demo_shape_drv
359 demo 1 [ ] demo_simple_drv |-- demo_simple_drv
360 demo 2 [ ] demo_shape_drv |-- demo_shape_drv
361 demo 3 [ ] demo_simple_drv |-- demo_simple_drv
362 demo 4 [ ] demo_shape_drv |-- demo_shape_drv
363 test 0 [ ] test_drv |-- test_drv
364 test 1 [ ] test_drv |-- test_drv
365 test 2 [ ] test_drv |-- test_drv
366 ..
367 sysreset 0 [ ] sysreset_sandbox |-- sysreset_sandbox
368 bootstd 0 [ ] bootstd_drv |-- bootstd
369 bootmeth 0 [ ] bootmeth_distro | |-- syslinux
370 bootmeth 1 [ ] bootmeth_efi | `-- efi
371 reboot-mod 0 [ ] reboot-mode-gpio |-- reboot-mode0
372 reboot-mod 1 [ ] reboot-mode-rtc |-- reboot-mode@14
373 ...
374 ethernet 7 [ + ] dsa-port | `-- lan1
375 pinctrl 0 [ + ] sandbox_pinctrl_gpio |-- pinctrl-gpio
376 gpio 1 [ + ] sandbox_gpio | |-- base-gpios
377 nop 0 [ + ] gpio_hog | | |-- hog_input_active_low
378 nop 1 [ + ] gpio_hog | | |-- hog_input_active_high
379 nop 2 [ + ] gpio_hog | | |-- hog_output_low
380 nop 3 [ + ] gpio_hog | | `-- hog_output_high
381 gpio 2 [ ] sandbox_gpio | |-- extra-gpios
382 gpio 3 [ ] sandbox_gpio | `-- pinmux-gpios
383 i2c 0 [ + ] sandbox_i2c |-- i2c@0
384 i2c_eeprom 0 [ ] i2c_eeprom | |-- eeprom@2c
385 i2c_eeprom 1 [ ] i2c_eeprom_partition | | `-- bootcount@10
386 rtc 0 [ ] sandbox_rtc | |-- rtc@43
387 rtc 1 [ + ] sandbox_rtc | |-- rtc@61
388 i2c_emul_p 0 [ + ] sandbox_i2c_emul_par | |-- emul
389 i2c_emul 0 [ ] sandbox_i2c_eeprom_e | | |-- emul-eeprom
390 i2c_emul 1 [ ] sandbox_i2c_rtc_emul | | |-- emul0
391 i2c_emul 2 [ + ] sandbox_i2c_rtc_emul | | |-- emull
392 i2c_emul 3 [ ] sandbox_i2c_pmic_emu | | |-- pmic-emul0
393 i2c_emul 4 [ ] sandbox_i2c_pmic_emu | | `-- pmic-emul1
394 pmic 0 [ ] sandbox_pmic | |-- sandbox_pmic
395 regulator 0 [ ] sandbox_buck | | |-- buck1
396 regulator 1 [ ] sandbox_buck | | |-- buck2
397 regulator 2 [ ] sandbox_ldo | | |-- ldo1
398 regulator 3 [ ] sandbox_ldo | | |-- ldo2
399 regulator 4 [ ] sandbox_buck | | `-- no_match_by_nodename
400 pmic 1 [ ] mc34708_pmic | `-- pmic@41
401 bootcount 0 [ + ] bootcount-rtc |-- bootcount@0
402 bootcount 1 [ ] bootcount-i2c-eeprom |-- bootcount
403 ...
404 clk 4 [ ] fixed_clock |-- osc
405 firmware 0 [ ] sandbox_firmware |-- sandbox-firmware
406 scmi_agent 0 [ ] sandbox-scmi_agent `-- scmi
407 clk 5 [ ] scmi_clk |-- protocol@14
408 reset 2 [ ] scmi_reset_domain |-- protocol@16
409 nop 8 [ ] scmi_voltage_domain `-- regulators
410 regulator 5 [ ] scmi_regulator |-- reg@0
411 regulator 6 [ ] scmi_regulator `-- reg@1
412 =>
413
414
415dm uclass
416~~~~~~~~~
417
418This example shows the abridged sandbox output::
419
420 => dm uclass
421 uclass 0: root
422 0 * root_driver @ 03015460, seq 0
423
424 uclass 1: demo
425 0 demo_shape_drv @ 03015560, seq 0
426 1 demo_simple_drv @ 03015620, seq 1
427 2 demo_shape_drv @ 030156e0, seq 2
428 3 demo_simple_drv @ 030157a0, seq 3
429 4 demo_shape_drv @ 03015860, seq 4
430
431 uclass 2: test
432 0 test_drv @ 03015980, seq 0
433 1 test_drv @ 03015a60, seq 1
434 2 test_drv @ 03015b40, seq 2
435 ...
436 uclass 20: audio-codec
437 0 audio-codec @ 030168e0, seq 0
438
439 uclass 21: axi
440 0 adder @ 0301db60, seq 1
441 1 adder @ 0301dc40, seq 2
442 2 axi@0 @ 030217d0, seq 0
443
444 uclass 22: blk
445 0 mmc2.blk @ 0301ca00, seq 0
446 1 mmc1.blk @ 0301cee0, seq 1
447 2 mmc0.blk @ 0301d380, seq 2
448
449 uclass 23: bootcount
450 0 * bootcount@0 @ 0301b3f0, seq 0
451 1 bootcount @ 0301b4b0, seq 1
452 2 bootcount_4@0 @ 0301b570, seq 2
453 3 bootcount_2@0 @ 0301b630, seq 3
454
455 uclass 24: bootdev
456 0 mmc2.bootdev @ 0301cbb0, seq 0
457 1 mmc1.bootdev @ 0301d050, seq 1
458 2 mmc0.bootdev @ 0301d4f0, seq 2
459
460 ...
461 uclass 78: pinconfig
462 0 gpios @ 03022410, seq 0
463 1 gpio0 @ 030224d0, seq 1
464 2 gpio1 @ 03022590, seq 2
465 3 gpio2 @ 03022650, seq 3
466 4 gpio3 @ 03022710, seq 4
467 5 i2c @ 030227d0, seq 5
468 6 groups @ 03022890, seq 6
469 7 pins @ 03022950, seq 7
470 8 i2s @ 03022a10, seq 8
471 9 spi @ 03022ad0, seq 9
472 10 cs @ 03022b90, seq 10
473 11 pinmux_pwm_pins @ 03022e10, seq 11
474 12 pinmux_spi0_pins @ 03022ed0, seq 12
475 13 pinmux_uart0_pins @ 03022f90, seq 13
476 14 * pinmux_i2c0_pins @ 03023130, seq 14
477 15 * pinmux_lcd_pins @ 030231f0, seq 15
478
479 ...
480 uclass 119: virtio
481 0 sandbox_virtio1 @ 030220d0, seq 0
482 1 sandbox_virtio2 @ 03022190, seq 1
483
484 uclass 120: w1
485 uclass 121: w1_eeprom
486 uclass 122: watchdog
487 0 * gpio-wdt @ 0301c070, seq 0
488 1 * wdt@0 @ 03021710, seq 1
489
490 =>