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