dm.rst 17 KB

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