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