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