Debian Codegraph @

Documentation/internals/devicetree_language.md

raw symbols SCIP
1 # Devicetree Language
2
3 Devicetrees use what's called a Domain Specific Language, so you need to
4 follow the rules of the language when you're writing a devicetree.
5 Fortunately, it's a relatively simple language, and because its use is
6 so limited, it can frequently be learned just by following existing
7 examples.
8
9
10 ## Comments
11
12 Comments in the devicetree are all single line style. They use the '#'
13 character to start the comment, and go to the end of the line.
14
15
16 ### Comment Style
17
18 * Put a space between the pound sign and the comment.
19 * \# Good
20 * \#Bad
21 * Sentence fragments are fine, but don't end them with a period.
22
23
24 ### When to use comments
25
26 There are standard locations where comments are typically used and
27 expected.
28
29
30 #### Starting a group of settings
31
32 Similar to commenting a function with the intent of the function, it can
33 be useful to describe at the top of a block of settings with what's
34 being configured.
35
36 Below is a good example.
37
38 ```text
39 # VR Settings Configuration for 4 Domains
40 # +----------------+-----------+-----------+-------------+----------+
41 # | Domain/Setting | SA | IA | GT Unsliced | GT |
42 # +----------------+-----------+-----------+-------------+----------+
43 # | Psi1Threshold | 20A | 20A | 20A | 20A |
44 # | Psi2Threshold | 4A | 5A | 5A | 5A |
45 # | Psi3Threshold | 1A | 1A | 1A | 1A |
46 # | Psi3Enable | 1 | 1 | 1 | 1 |
47 # | Psi4Enable | 1 | 1 | 1 | 1 |
48 # | ImonSlope | 0 | 0 | 0 | 0 |
49 # | ImonOffset | 0 | 0 | 0 | 0 |
50 # | IccMax | 7A | 34A | 35A | 35A |
51 # | VrVoltageLimit | 1.52V | 1.52V | 1.52V | 1.52V |
52 # | AC LoadLine | 15 mOhm | 5.7 mOhm | 5.2 mOhm | 5.2 mOhm |
53 # | DC LoadLine | 14.3 mOhm | 4.83 mOhm | 4.2 mOhm | 4.2 mOhm |
54 # +----------------+-----------+-----------+-------------+----------+
55 ```
56
57
58 #### End of keyword blocks
59
60 If there are multiple end statements in a row, and it's not instantly
61 obvious which end statement closes which keyword block, It's useful to
62 add a comment to say what's being ended.
63
64 Below, we have three end statements in a row and the start of these
65 blocks are probably close to the top of the file. Identifying what the
66 'end' statement is closing can be determined by the spacing, but it's
67 still useful to note it with a comment.
68
69 ```text
70 end # agesa northbridge
71 end # domain
72 end # northbridge/amd/agesa/family14/root_complex
73 ```
74
75
76 #### Identifying the reason for a setting
77
78 Registers which don't have a name that makes it obvious what is being
79 set, or don't have a macro that identifies what it's being set to should
80 be commented.
81
82 The register setting and macro below both describe what the setting is,
83 but don't describe what they're being used for. Adding the comment of
84 "Camera", gives the reader the extra information to know what's on that
85 USB port, and understand that you (generally) don't need overcurrent
86 protection for an internal camera.
87
88 ```text
89 register "usb2_ports[7]" = "USB2_PORT_MID(OC_SKIP)" # Camera
90 ```
91
92 This below register is well named and tells you that there's going to be
93 a delay of 12ms, but without the comment, you don't know why.
94
95 ```text
96 register "stop_delay_ms" = "12" # NIC needs time to quiesce
97 ```
98
99
100 #### Devices without aliases
101
102 It's been common in the past to comment device identifiers with what the
103 device is, but this may be less needed now with aliases, which allow
104 devices to be named in a meaningful way.
105
106 For older platforms which don't have aliases set in the chipset.cb file,
107 or for non chipset devices, it's still useful to add a comment after the
108 device is set.
109
110
111 ### When not to use comments
112
113 #### Magic numbers
114
115 This overlaps somewhat with the next section, but if you find yourself
116 having to put in a comment to explain what's being set, evaluate whether
117 it can be expressed as a macro instead.
118
119 ```
120 register "PmConfigSlpS3MinAssert" = "2" # 50ms
121 ```
122
123 Instead of using the magic number 2, use a macro, just as you'd be
124 expected to do in your code. It's not obvious without the comment what
125 2 means, so use a macro instead.
126
127 If there's some reason that a macro cannot be used, then sure, add a
128 comment, but this should be very unusual.
129
130 #### Redundant comments
131
132 With good naming, comments may not be needed.
133
134 Example of redundant comments:
135
136 ```text
137 register "ipc1" = "0x00000000" # IPC1
138 ```
139
140 ```text
141 register "link_freq[0]" = "360 * MHz" # 360 MHz
142 ```
143
144 #### Devices with aliases
145
146 For older chipset or SoC devices, or for non chipset devices that don't
147 have a chipset.cb file, it's still desirable to use comments on the
148 'device' line, but if the device has an alias, it should be used.
149
150
151 ## Registers
152
153 ### Register Names
154
155 Any registers which encode a value that has any sort of unit should
156 include the unit in the name instead of in a comment.
157
158 The name "tFAW" in the register below is taken directly from the name in
159 the spec, but adding the units makes it a lot easier to understand.
160
161 ```text
162 register "tFAW" = "40000" # picoseconds
163 ```
164
165 ### Use Macros for encoded values
166
167 If the value associated with the register encodes the unit, instead of
168 entering the value directly, add a macro for the value.
169
170 ```text
171 register "PchPmSlpS3MinAssert" = "3" # 50ms
172 ```
173
174 This would be easier to understand if it had a macro, not just a magic
175 number, as seen below.
176
177 ```text
178 register "PchPmSlpS3MinAssert" = "ASSERT_50_MILLISEC"
179 ```
180
181 ## Devicetree Keywords
182
183 alias, as, chip, cpu, cpu_cluster, device, domain, drq, end, field,
184 fw_config, generic, gpio, hidden, i2c, inherit, io, ioapic, ioapic_irq,
185 lapic, mandatory, mmio, off, on, option, pci, pnp, probe, ref, register,
186 smbios_dev_info, smbios_slot_desc, spi, subsystemid, usb, use
187
188
189 ## Keyword Types
190
191 The keywords are divided into a number of different categories. A few
192 keywords fall into more than one of these categories.
193
194
195 ### Alias Types
196
197 The alias type keywords are used to give human readable names to
198 devices, then later update that name for a specific usage.
199
200 * alias, as, use
201
202
203 ### Containers
204
205 These keywords act to group information into logical units of different
206 sorts.
207
208 * chip, device, domain, field, fw_config, end
209
210
211 ### Device/Bus Types
212
213 These keywords are used to identify the type of device being configured
214 and select the appropriate structure for configuration.
215
216 * cpu, cpu_cluster, domain, generic, gpio, i2c, ioapic, lapic, mmio,
217 pci, pnp, ref, spi, usb
218
219
220 ### Enumeration Status Modifiers
221
222 The status modifiers determine how a device should be treated during
223 enumeration.
224
225 * on, off, hidden, mandatory
226
227
228 ### Firmware configuration
229
230 * field, fw_config, option, probe, ref
231
232
233 ### Resource allocation
234
235 * drq, io, irq
236
237
238 ### SMBIOS
239
240 * smbios_dev_info, smbios_slot_desc
241
242
243 ### Subsystem
244
245 * inherit, subsystemid
246
247
248 ### Register
249
250 * register
251
252
253 ### MPTABLE
254
255 * ioapic_irq
256
257
258 ## Keyword Definitions
259
260 ### alias
261
262 * Keyword type: Alias
263 * Introduced in June of 2020, coreboot version 4.12
264 * Usage: `device <device type> <device address> **alias** <ALIAS ID> <status modifier> ... end`
265
266 Sometimes, the driver of one device needs to know about another device
267 that can be anywhere in the device hierarchy. Current applications boil
268 down to EEPROMs that store information that is consumed by some code
269 (e.g. MAC address).
270
271 The idea is to give device nodes in the `devicetree.cb` an alias that
272 can later be used to link it to a device driver's `config` structure.
273 The driver has to declare a field of type `struct device *`, e.g.
274
275 Override devices can add an alias if it does not exist, but cannot
276 change the alias for a device that already exists.
277
278 Alias names are checked for conflicts both in the base tree and in the
279 override tree.
280
281 References are resolved after the tree is parsed so aliases and
282 references do not need to be in a specific order in the tree.
283
284 Example:
285 ```text
286 device i2c 0x50 alias my_eeprom on end
287 ```
288
289 static.c:
290
291 ```C
292 struct some_chip_driver_config {
293 DEVTREE_CONST struct device *needed_eeprom;
294 };
295 ```
296
297 ### as
298
299 * Keyword type: Alias
300 * Introduced in June of 2020, coreboot version 4.12
301 * Usage: `use <Alias ID> as <Alias ID 2>`
302
303 This keyword is used along with the 'use' keyword to give a more
304 specific name to a generic alias.
305
306 The author of the devicetree is free to choose any alias name that is
307 unique in the devicetree. Later, when configuring the driver the alias
308 can be used to link the device with the field of a driver's config as in
309 the following example.
310
311
312 Example:
313
314 ```text
315 chip some/chip/driver
316 use my_eeprom as needed_eeprom
317 end
318 ```
319
320
321 ### chip
322
323 * Keyword type: Component type
324 * Introduced in initial sconfig implementation, pre coreboot 4.0
325 * Usage: `**chip** <path to chip.h file> ... end`
326
327 The chip keyword defines a section for a device inside a hierarchy of
328 devices.
329
330 Following the chip keyword is a path to an optional chip.h file. If
331 this file exists, it should contain a structure of all register settings
332 available for this device.
333
334 The section started with "chip" is closed with the "end" keyword.
335
336 Note that register commands are chip based, not device based.
337
338 Example:
339 ```text
340 chip some/chip/driver # comment as desired
341 # A chip section must have at least one device inside it
342 ...
343 end # some/chip/driver
344 ```
345
346
347 ### cpu
348
349 * Keyword type: Device type
350 * Introduced in October of 2014, coreboot version 4.0
351 * Usage: `device **cpu** <Identifier> [alias <alias ID>] <status modifier> ... end`
352
353 The cpu device type was introduced In order to enumerate CPU devices
354 that are non-x86 (read: no lapic).
355
356 This device type is not used very much, as most non-x86 platforms just
357 handle all the CPU configuration at the cpu_cluster level.
358
359 Example:
360
361 ```text
362 device cpu 0 on end
363 ```
364
365
366 ### cpu_cluster
367
368 * Keyword type: Device type
369 * Introduced in initial sconfig implementation, pre coreboot 4.0 as apic_cluster
370 * Updated in May of 2010 - renamed from apic_cluster to lapic_cluster
371 * Updated in February of 2013 - Renamed from from lapic_cluster to cpu_cluster
372 * Usage: `device cpu_cluster <Identifier> [alias <alias ID>] <status modifier> …. end`
373
374 The CPU Cluster is typically one of the two top-level devices in a
375 devicetree, with the other being the PCI Domain. Like the domain
376 keyword, the cpu_cluster acts as a bridge device to contain any CPU and
377 lapic devices.
378
379 On x86 type devices, the CPU Cluster contains CPU chip entries for each
380 socket which then contain any lapics on the system.
381
382 On ARM or other non-x86 devices, the CPU Cluster can either contain
383 multiple CPUs or it can just be marked 'on', leaving all CPU
384 configuration to be handled at the CPU Cluster level.
385
386 Example:
387
388 ```text
389 device cpu_cluster 0 on
390 device lapic 0 on end
391 end
392 ```
393
394 ### device
395
396 * Keyword type: Component type
397 * Introduced in: Initial sconfig implementation, pre coreboot 4.0
398 * Usage: `device <device type> <Identifier> [alias <alias ID>] <status modifier>…. end`
399
400 A chip defines a collection of one or more devices, and as such, the
401 device is the fundamental building block of devicetree.
402
403 The device block tells coreboot that a device is present on the
404 mainboard, gives some information on how to find, access, and work with
405 the device based on the device type.
406
407 Examples:
408
409 ```text
410 device cpu_cluster 0 on
411 device lapic 0 on end
412 end
413 ```
414
415 ### domain
416
417 * Keyword type: Device type
418 * Introduced in: Initial sconfig implementation, pre coreboot 4.0
419 * Updated in: February of 2013: Renamed pci_domain to domain
420 * Usage: `device domain <identifier> [alias <alias ID>] <status modifier> ... end`
421
422 The domain type device acts as a container for one or more chips,
423 defining a logical bus segment.
424
425 As of 2022-04-29, the domain keyword is still used exclusively to define
426 PCI bus segments.
427
428 Example:
429
430 ```text
431 device domain 0 on
432 device generic 0 alias dptf_policy on end
433 device pci 1f.0 on # 8086 229c - LPC bridge
434 device pnp 2e.209 off end # GPIO 4
435 end
436 end
437 ```
438
439
440 ### drq
441
442 * Keyword type: Resource type
443 * Introduced in: Initial sconfig implementation, pre coreboot 4.0
444 * Usage: `drq 0x<register #> = <drq line>`
445
446 Drq is used to configure a legacy DMA Request line register for a device
447 on a legacy bus - ISA/LPC.
448
449 The drq configuration is only allowed inside a pnp block.
450
451 Example:
452
453 ```text
454 device pnp 2e.1 on # Parallel port
455 io 0x60 = 0x378
456 irq 0x70 = 7
457 drq 0x74 = 3
458 end
459 ```
460
461 ### end
462
463 * Keyword type: Component type
464 * Introduced in: Initial sconfig implementation, pre coreboot 4.0
465 * Usage: `<device | chip | domain | field | fw_config> ... end`
466
467 End is used to close a chip, device, field, or fw_config block.
468
469 Example:
470
471 ```text
472 chip northbridge/intel/x4x
473 device domain 0 on
474 chip southbridge/intel/i82801gx
475 device pci 1f.0 on # ISA bridge
476 chip superio/winbond/w83627dhg
477 device pnp 2e.1 on # LPT
478 io 0x60 = 0x378
479 irq 0x70 = 7
480 drq 0x74 = 3
481 end # LPT
482 end # superio/winbond/w83627dhg
483 end # ISA Bridge
484 end # Southbridge
485 end # domain 0
486 end # Northbridge
487 ```
488
489 ### field
490
491 * Keyword type: Firmware config
492 * Introduced in: May of 2020, coreboot version 4.12
493 * Usage: `field <Identifier string> <low bit> <high bit> [ | <low bit> <high bit> …] ... end`
494
495 Fields define the bits used in the Firmware config runtime options.
496 Note that the bits in a field can be discontiguous.
497
498 All field definitions must be inside a fw_config block.
499
500 Example:
501
502 ```text
503 field AUDIO 8 10 | 29 29
504 option NONE 0
505 option MAX98357_ALC5682I_I2S 1
506 option MAX98373_ALC5682I_I2S 2
507 option MAX98373_ALC5682_SNDW 3
508 option MAX98373_ALC5682I_I2S_UP4 4
509 option MAX98360_ALC5682I_I2S 5
510 option RT1011_ALC5682I_I2S 6
511 option AUDIO_FOO 7
512 option AUDIO_BAR 8
513 option AUDIO_QUUX 9
514 option AUDIO_BLAH1 10
515 option AUDIO_BLAH2 15
516 end
517 ```
518
519 static_fw_config.h:
520
521 ```C
522 FW_CONFIG_FIELD_AUDIO_MASK 0x20000700
523 FW_CONFIG_FIELD_AUDIO_OPTION_NONE_VALUE 0x0
524 FW_CONFIG_FIELD_AUDIO_OPTION_MAX98357_ALC5682I_I2S_VALUE 0x100
525 FW_CONFIG_FIELD_AUDIO_OPTION_MAX98373_ALC5682I_I2S_VALUE 0x200
526 FW_CONFIG_FIELD_AUDIO_OPTION_MAX98373_ALC5682_SNDW_VALUE 0x300
527 FW_CONFIG_FIELD_AUDIO_OPTION_MAX98373_ALC5682I_I2S_UP4_VALUE 0x400
528 FW_CONFIG_FIELD_AUDIO_OPTION_MAX98360_ALC5682I_I2S_VALUE 0x500
529 FW_CONFIG_FIELD_AUDIO_OPTION_RT1011_ALC5682I_I2S_VALUE 0x600
530 FW_CONFIG_FIELD_AUDIO_OPTION_AUDIO_FOO_VALUE 0x700
531 FW_CONFIG_FIELD_AUDIO_OPTION_AUDIO_BAR_VALUE 0x20000000
532 FW_CONFIG_FIELD_AUDIO_OPTION_AUDIO_QUUX_VALUE 0x20000100
533 FW_CONFIG_FIELD_AUDIO_OPTION_AUDIO_BLAH1_VALUE 0x20000200
534 FW_CONFIG_FIELD_AUDIO_OPTION_AUDIO_BLAH2_VALUE 0x20000700
535 ```
536
537 ### fw_config
538
539 * Keyword type: Firmware config
540 * Introduced in: May of 2020, coreboot version 4.12
541 * Usage: fw_config
542
543 Fw_config is the top level token for defining firmware config fields.
544 All field and option definitions must be inside the fw_config block.
545 Note that the table can be defined before any chips are configured.
546
547 Example:
548 ```text
549 fw_config
550 field USB_DB 0 1
551 option USB_DB_A1_PS8811_C1_PS8818 0
552 option USB_DB_A1_ANX7491_C1_ANX7451 1
553 end
554 field FORM_FACTOR 2
555 option FORM_FACTOR_CLAMSHELL 0
556 option FORM_FACTOR_CONVERTIBLE 1
557 end
558 end
559 ```
560
561
562 ### generic
563
564 * Keyword type: Device type
565 * Introduced in: May of 2016, coreboot version 4.4
566 * Usage: `device generic <identifier> [alias <alias ID>] <status modifier> ... end`
567
568 This allows the devicetree to describe a device that does not have a
569 specific bus, but may need to be described in tables for the operating
570 system. For instance some chips may have various GPIO connections that
571 need to be described but do not fall under any other device.
572
573 Example:
574 ```text
575 device pci 0c.0 on # CNVi
576 chip drivers/wifi/generic
577 register "wake" = "GPE0A_CNVI_PME_STS"
578 device generic 0 on end
579 end
580 end
581 ```
582
583
584 ### gpio
585
586 * Keyword type: Device type
587 * Introduced in: December 2020, coreboot version 4.13
588 * Usage: `device **gpio** <identifier> [alias <alias ID>] <status modifier> ... end`
589
590 The general idea behind this is that every chip can have gpios that
591 shall be accessible in a very generic way by any driver through the
592 devicetree.
593
594 The chip that implements the chip-specific gpio operations has to assign
595 them to the generic device operations struct, which then gets assigned
596 to the gpio device during device probing. See CB:48583 for how this gets
597 done for the SoCs using intel/blocks/gpio.
598
599 The gpio device then can be added to the devicetree with an alias name
600 like in the following example:
601
602 ```text
603 chip soc/whateverlake
604 device gpio 0 alias soc_gpio on end
605 ...
606 end
607 ```
608
609 Any driver that requires access to this gpio device needs to have a
610 device pointer (or multiple) and an option for specifying the gpio to be
611 used in its chip config like this:
612
613 ```C
614 struct drivers_ipmi_config {
615 ...
616 DEVTREE_CONST struct device *gpio_dev;
617 u16 post_complete_gpio;
618 ...
619 };
620 ```
621
622 The device `soc_gpio` can then be linked to the chip driver's `gpio_dev`
623 above by using the syntax `use ... as ...`, which was introduced in
624 commit 8e1ea52:
625
626 ```text
627 chip drivers/ipmi
628 use soc_gpio as gpio_dev
629 register "bmc_jumper_gpio" = "GPP_D22"
630 ...
631 end
632 ```
633
634 The IPMI driver can then use the generic gpio operations without any
635 knowlege of the chip's specifics:
636
637 ```C
638 unsigned int gpio_val;
639 const struct gpio_operations *gpio_ops;
640 gpio_ops = dev_get_gpio_ops(conf->gpio_dev);
641 gpio_val = gpio_ops->get(conf->bmc_jumper_gpio);
642 ```
643
644 For a full example have a look at CB:48096 and CB:48095.
645
646
647 ### hidden
648
649 * Keyword type: Enumeration Status Modifier
650 * Introduced in: September 2018, coreboot version 4.8
651 * Updated in: February of 2020, coreboot version 4.11
652 * Usage: `device <device type> <identifier> [alias <alias ID>] hidden ... end`
653
654 The "Hidden" keyword was added to support devices sharing the same
655 driver to update their ACPI status with different values. If a device
656 is marked as Hidden, it omits the "SHOW_IN_UI" field, which prevents the
657 device from showing up in the OSPM user interface. This was added to
658 prevent ChromeOS specific devices from showing up in Windows, for
659 example. It does not look like this keyword was ever actually used in
660 this capacity, but the code for this is still present.
661
662 In 2020, the "Hidden" keyword's use was expanded to fix the problem of
663 PCI devices which have been hidden by disabling access to the config
664 space. Because the Device/Vendor IDs read back as 0xffffffff from the
665 hidden device, it appears that there is no PCI device located at that
666 Bus/Device/Function. This causes coreboot to remove the device at the
667 end of PCI enumeration. To fix this, if a device uses 'hidden' instead
668 of 'on', then it will be assumed during PCI enumeration that the device
669 indeed does exist, and it will not be removed. This allows coreboot to
670 manually assign resources to the device even though it doesn't appear to
671 exist.
672
673 Example:
674 ```text
675 device pci 1f.2 alias pmc hidden end
676 ```
677
678 static.c:
679
680 ```C
681 .enabled = 1,
682 .hidden = 1,
683 .mandatory = 0,
684 ```
685
686
687 ### i2c
688
689 * Keyword type: Device type
690 * Introduced in: Initial sconfig implementation, pre coreboot 4.0
691 * Usage: `device I2c <identifier> [alias <alias ID>] <status modifier> ... end`
692
693 The identifier is the device's address encoded as hexadecimal number.
694
695 Example:
696
697 ```text
698 device i2c 2c on end
699 chip drivers/i2c/generic
700 register "hid" = ""ELAN0000""
701 register "desc" = ""ELAN Touchpad""
702 register "irq_gpio" = "ACPI_GPIO_IRQ_LEVEL_LOW(GPIO_9)"
703 register "wake" = "GEVENT_22"
704 register "probed" = "1"
705 device i2c 15 on end
706 end
707 ```
708
709 ### inherit
710
711 * Keyword type: subsystem
712 * Introduced in: March of 2011, coreboot version 4.0
713 * Usage: `subsystemid beee c001 inherit`
714
715 Used to modify the subsystemid keyword, inherit makes the ID apply to
716 all subdevices and functions.
717
718 Example:
719 ```text
720 device pci 00.0 on
721 subsystemid 0xdead 0xbeef inherit
722 end
723 ```
724
725
726 ### io
727
728 * Keyword type: Resource
729 * Introduced in: Initial sconfig implementation, pre coreboot 4.0
730 * Usage: `io 0x<address> = 0x<value>`
731
732 The io command is used to set an legacy device's io register to a value.
733
734 Example:
735
736 ```text
737 device pnp 4e.06 on # Keyboard
738 io 0x60 = 0x0060
739 io 0x62 = 0x0064
740 irq 0x70 = 1
741 end
742 ```
743
744 ### ioapic
745
746 * Keyword type: Device type
747
748 * Usage: `device ioapic <identifier> [alias <alias ID>] <status modifier> ... end`
749
750
751 ### ioapic_irq
752
753 * Keyword type: Mpinit type
754 * Introduced in: June of 2012, coreboot version 4.0
755 * Usage: `ioapic_irq <APICID> <INTA|INTB|INTC|INTD> <INTPIN>`
756
757 This keyword is used to support autogeneration of the MPTABLE from
758 devicetree.cb. This is done by a write_smp_table() declared weak in
759 mpspec.c. If the mainboard doesn't provide its own function, this
760 generic implementation is called.
761
762 The ioapic_irq directive can be used in pci and pci_domain devices. If
763 there's no directive, the autogen code traverses the tree back to the
764 pci_domain and stops at the first device which sets such a directive,
765 and uses that information to generate the entry according to PCI IRQ
766 routing rules.
767
768 ```text
769 ```
770
771
772 ### irq
773
774 * Keyword type: Resource type
775 * Introduced in initial sconfig implementation, pre coreboot 4.0
776 * Usage: `irq 0x<address> = 0x<value>`
777
778 Irq is used to configure a legacy interrupt Request line register for a
779 device on a legacy bus - ISA/LPC/eSPI.
780
781 The irq configuration is only allowed inside a pnp block.
782
783 Example:
784
785 ```text
786 irq 0xc5 = 0x1f
787 ```
788
789 ```text
790 chip superio/fintek/f71808a
791 device pnp 4e.4 on # Hardware monitor
792 io 0x60 = 0x295
793 irq 0x70 = 0
794 end
795 end
796 ```
797
798 ### lapic
799
800 * Keyword type: Device type
801 * Introduced in initial sconfig implementation, pre coreboot 4.0
802 * Updated in May of 2010 - Renamed apic to lapic
803 * Usage: `device lapic <identifier> [alias <alias ID>] <status modifier> ... end`
804
805 Defines an lapic device on an x86 mainboard.
806
807 Example:
808
809 ```text
810 device cpu_cluster 0 on # (L)APIC cluster
811 chip cpu/intel/slot_1 # CPU socket 0
812 device lapic 0 on end # Local APIC of CPU 0
813 end
814 chip cpu/intel/slot_1 # CPU socket 1
815 device lapic 1 on end # Local APIC of CPU 1
816 end
817 end
818 ```
819
820 ### mandatory
821
822 * Keyword type: Enumeration Status Modifier
823 * Introduced in: February of 2020, coreboot version 4.11
824 * Usage: `device <device type> <identifier> [alias <alias ID>] mandatory ... end`
825
826 The Mandatory keyword allows for minimal PCI scanning which speeds up the
827 boot process. Only devices marked "mandatory" get enabled and scanned
828 during PCI enumeration when the MINIMAL_PCI_SCANNING Kconfig option is
829 enabled.
830
831 If MINIMAL_PCI_SCANNING is not enabled, this means the same as 'on'.
832
833 static.c:
834
835 ```C
836 .enabled = 1,
837 .hidden = 0,
838 .mandatory = 1,
839 ```
840
841 example:
842
843 ```text
844 device pci 1f.0 mandatory # LPC
845 chip drivers/pc80/tpm
846 device pnp 0c31.0 on end
847 end # tpm
848 end # LPC
849 ```
850
851
852 ### mmio
853
854 * Keyword type: Device type
855 * Introduced in January of 2018, coreboot version 4.7
856 * Usage: `device mmio 0x<address> [alias <alias ID>] <status modifier> ... end`
857
858 The mmio keyword allows fixed memory-mapped IO addressed devices to be
859 assigned to given values.
860
861 AMD platforms perform a significant amount of configuration through these
862 MMIO addresses, including I2C bus configuration.
863
864 example:
865
866 ```text
867 device mmio 0xfedc9000 alias uart_0 off end
868 device mmio 0xfedca000 alias uart_1 off end
869 device mmio 0xfedc2000 on # I2C 0
870
871 chip drivers/generic/adau7002
872 device generic 0.0 on end
873 end
874
875 chip drivers/i2c/da7219
876 register "irq_gpio" = "ACPI_GPIO_IRQ_EDGE_LOW(GPIO_14)"
877 end
878
879 chip drivers/generic/max98357a
880 register "hid" = ""MX98357A""
881 register "sdmode_delay" = "5"
882 device generic 0.1 on end
883 end
884
885 end # I2C 0
886 ```
887
888
889 ### off
890
891 * Keyword type: Enumeration Status Modifier
892 * Introduced in: Initial sconfig implementation, pre coreboot 4.0
893 * Usage: `device <device type> <identifier> [alias <alias ID>] off ... end`
894
895 Indicates that the device should be disabled if possible and should not
896 be enumerated or configured. To disable a device, the code to disable it
897 must be present in the chipset/SoC code, though it isn't always possible
898 to actually disable the device.
899
900 Note that If a device (especially PCI devices) is marked as 'off', but
901 does not get disabled, the OS or a driver may discover the device during
902 its enumeration sequence and assign it resources anyway.
903
904 static.c:
905
906 ```C
907 .enabled = 0
908 .hidden = 0,
909 .mandatory = 0,
910 ```
911
912 example:
913
914 ```text
915 device usb 2.6 off end
916 device pnp 2e.0 off end # FDC
917 device pci 15.2 off end
918 ```
919
920 ### on
921
922 * Keyword type: Enumeration Status Modifier
923 * Introduced in: Initial sconfig implementation, pre coreboot 4.0
924 * Usage: `device <device type> <identifier> [alias <alias ID>] on ... end`
925
926 Marks a device as present and enabled. This indicates that the device
927 should be enumerated and configured.
928
929 static.c:
930
931 ```C
932 .enabled = 1
933 .hidden = 0,
934 .mandatory = 0,
935 ```
936
937 Example:
938
939 ```text
940 device lapic 0 on end
941 device pci 00.0 on end # Host Bridge
942 device pnp 0c31.0 on end
943 ```
944
945 ### option
946
947 * Keyword type: Firmware config
948 * Usage: `option <name> <value>`
949
950 Options define the values which may be used in a firmware config field.
951 The option keyword may only be used inside a field, which may only be
952 used inside an fw_config block.
953
954 Example:
955
956 ```text
957 fw_config
958 field OLED_SCREEN 28
959 option OLED_NOT_PRESENT 0
960 option OLED_PRESENT 1
961 end
962 end
963 ```
964
965 ### pci
966
967 * Keyword type: Device type
968 * Introduced in: Initial sconfig implementation, pre coreboot 4.0
969 * Usage: `device pci <dev.func> [alias <alias ID>] <status modifier> …. end`
970
971 The pci device type defines a PCI or PCIe device on the PCI logical bus.
972
973 Resources for all PCI devices are assigned automatically, or must be
974 assigned in code if they're non-standard.
975
976 Only a single segment group is supported per domain, but there can be multiple
977 domains to support the case of multiple segment groups, each with a bus 0.
978 Because the bus is not specified, It's assumed that all pci devices that are
979 not behind a pci bridge device are on bus 0. If there are additional pci busses
980 in a chip, they can be added behind their bridge device.
981
982 Examples:
983
984 ```text
985 device pci 1a.0 on end # USB2 EHCI #2
986 device pci 1b.0 on # High Definition Audio
987 subsystemid 0x1a86 0x4352
988 end
989 ```
990
991 Example - ISA bus under PCI to ISA bridge:
992
993 ```text
994 device pci 4.0 on # ISA bridge
995 chip superio/winbond/w83977tf # Super I/O
996 device pnp 3f0.2 on # COM1
997 io 0x60 = 0x3f8
998 irq 0x70 = 4
999 end
1000 end
1001 end
1002 ```
1003
1004 Example - PCI Bus under a PCI to PCI bridge:
1005
1006 ```text
1007 device pci 08.0 on end # Dummy Host Bridge, do not disable
1008 device pci 08.1 alias gpp_bridge_a off # Internal GPP Bridge 0 to Bus A
1009 device pci 0.0 alias gfx off end # Internal GPU (GFX)
1010 device pci 0.1 alias gfx_hda off end # Display HDA (GFXAZ)
1011 end
1012 ```
1013
1014
1015 ### pnp
1016
1017 * Keyword type: Device type
1018 * Introduced in: Initial sconfig implementation, pre coreboot 4.0
1019 * Usage: `device pnp <Identifier> [alias <alias ID>] <status modifier>…. end`
1020
1021 pnp is used to define an IO addressed device within a chip on a legacy
1022 bus - ISA, LPC, or eSPI. The identifier is the IO address used to
1023 access the chip, followed by the identifier for the device within the
1024 chip.
1025
1026 The io, irq, and drq resource identifiers are allowed only inside a pnp
1027 device.
1028
1029 Example:
1030
1031 ```text
1032 chip superio/ite/it8783ef
1033 device pnp 2e.0 off end # Floppy
1034 device pnp 2e.1 on # COM 1
1035 io 0x60 = 0x3f8
1036 irq 0x70 = 4
1037 end
1038 end
1039 ```
1040
1041 ### probe
1042
1043 * Keyword type: Firmware config
1044 * Introduced in May of 2020, coreboot version 4.12
1045 * Usage: `probe <Field Name> <Option Name>`
1046
1047 The fields and options can be used to probe for a device and have that
1048 device be disabled if it is not found at boot time.
1049
1050 Example:
1051
1052 ```text
1053 fw_config
1054 field FEATURE 0 0
1055 option DISABLE 0
1056 option ENABLE 1
1057 end
1058 end
1059
1060 chip drivers/generic/feature
1061 device generic 0 on
1062 probe FEATURE ENABLE
1063 end
1064 end
1065 ```
1066
1067
1068 ### ref
1069
1070 * Keyword type: Device type (alias)
1071 * Introduced in July of 2020, coreboot version 4.12
1072 * Usage: `device REF <Identifier> <status modifier>…. end`
1073
1074 This allows the chipset to assign alias names to devices as well as set
1075 default register values. This works for both the baseboard devicetree.cb
1076 as well as variant overridetree.cb.
1077
1078 Example:
1079
1080 chipset.cb:
1081
1082 ```text
1083 device pci 15.0 alias i2c0 off end
1084 ```
1085
1086 devicetree.cb:
1087
1088 ```text
1089 device ref i2c0 on end
1090 ```
1091
1092 ### register
1093
1094 * Keyword type: Register
1095 * Introduced in: Initial sconfig implementation, pre coreboot 4.0
1096 * Usage: `register "name" = "value"`
1097
1098 The register keyword was initially intended to supply just that -
1099 information for device register values. Over the years, its use has been
1100 expanded to much more than this, becoming a general configuration
1101 mechanism.
1102
1103 All values set by the register keyword MUST be defined in the chip.h
1104 file. The register keyword only works at the chip level, not at the
1105 device level.
1106
1107 Any register defined in the chip.h file that is not set in the
1108 devicetree file gets set to zero.
1109
1110 To double quote a value, use two sets of quotes: `register "name" = ""string""`
1111
1112 Examples:
1113
1114 ```text
1115 register "desc" = ""USB2 Type-A Rear Lower""
1116 register "pcie_power_limits" = "{ { 10, 0 }, { 0, 0 }, { 0, 0 },
1117 { 0, 0 }, { 10, 0 }, { 0, 0 } }"
1118 register "SataPortsEnable[0]" = "1"
1119 register "generic.irq" = "ACPI_IRQ_LEVEL_LOW(GPP_B3_IRQ)"
1120 register "common_soc_config" = "{
1121 // Touchpad I2C bus
1122 .i2c[0] = {
1123 .speed = I2C_SPEED_FAST,
1124 .rise_time_ns = 80,
1125 .fall_time_ns = 110,
1126 },
1127 }"
1128 ```
1129
1130
1131 ### smbios_dev_info
1132
1133 * Keyword type: smbios
1134 * Introduced in: May of 2019, coreboot version 4.9
1135 * Usage: `smbios_dev_info <Identifier>`
1136
1137 Specify the instance ID and RefDes (Reference Designation) of onboard
1138 devices.
1139
1140 The `SMBIOS_TYPE41_PROVIDED_BY_DEVTREE` Kconfig option enables using
1141 this syntax to control the generated Type 41 entries (Onboard Devices
1142 Extended Information). When this option is enabled, Type 41 entries are
1143 only autogenerated for devices with a defined instance ID. This avoids
1144 having to keep track of which instance IDs have been used for every
1145 device class.
1146
1147 Using `smbios_dev_info` when `SMBIOS_TYPE41_PROVIDED_BY_DEVTREE` is not
1148 enabled will result in a build-time error, as the syntax is meaningless
1149 in this case. This is done with preprocessor guards around the Type 41
1150 members in `struct device` and the code which uses the guarded members.
1151 Although the preprocessor usage isn't particularly elegant, adjusting the
1152 devicetree syntax and/or grammar depending on a Kconfig option is
1153 probably even worse.
1154
1155 Example:
1156
1157 ```text
1158 device pci 1c.0 on # PCIe Port #1
1159 device pci 00.0 on
1160 smbios_dev_info 6
1161 end
1162 end
1163 device pci 1c.1 on # PCIe Port #2
1164 device pci 00.0 on
1165 smbios_dev_info 42 "PCIe-PCI Time Machine"
1166 end
1167 end
1168 ```
1169
1170 ### smbios_slot_desc
1171
1172 * Keyword type: smbios
1173 * Introduced in: May of 2019, coreboot version 4.9
1174 * Usage: `smbios_slot_desc** <type> <length> [designation] [data width]`
1175
1176 Add the new field 'smbios_slot_desc', which takes 2 to 4 arguments.
1177 The field is only valid for PCI devices and only compiled if SMBIOS
1178 table generation is enabled.
1179
1180 smbios_slot_desc arguments - described in src/include/smbios.h:
1181
1182 1. slot type: enum misc_slot_type
1183 2. slot length: enum misc_slot_length
1184 3. slot designation (optional): text string
1185 4. slot data width (optional): enum slot_data_bus_bandwidth
1186
1187 Example:
1188
1189 ```text
1190 device pci 1c.1 on
1191 smbios_slot_desc "SlotTypePciExpressGen3X16" "SlotLengthOther" "SLOT2" "SlotDataBusWidth8X"
1192 end # PCIe Port #2 Integrated Wireless LAN
1193 ```
1194
1195 ### spi
1196
1197 * Keyword type: Device type
1198 * Introduced in: February of 2017, coreboot version 4.5
1199 * Usage: device **SPI** <Identifier> [alias <alias ID>] <status modifier>…. end
1200
1201 The SPI device takes only one parameter, the chip-select for the device
1202 on the SPI bus.
1203
1204 Example:
1205
1206 ```text
1207 device spi 0 alias spi_tpm on end
1208 ```
1209
1210
1211 ### subsystemid
1212
1213 * Keyword type: Subsystem
1214 * Introduced in: March of 2011, coreboot version 4.0
1215 * Usage: `subsystemid <vendor> <device> [inherit]`
1216
1217 Sets a PCI subsystem ID.
1218
1219 If the user wants to have this ID inherited to all subdevices/functions,
1220 they can add the keyword 'inherit' after the ID.
1221
1222 If the user doesn't want to inherit the subsystem value for a single
1223 device, they can specify 'subsystemid 0 0' on this particular device.
1224
1225 Example:
1226
1227 ```text
1228 device pci 00.0 on
1229 subsystemid 0xdead 0xbeef
1230 end
1231 ```
1232
1233 or
1234
1235 ```text
1236 device pci 00.0 on
1237 subsystemid 0xdead 0xbeef inherit
1238 end
1239 ```
1240
1241 ### usb
1242
1243 * Keyword type: Device type
1244 * Introduced in: May of 2018, coreboot version 4.7
1245 * Usage: `device usb <Identifier> [alias <alias ID>] <status modifier> ... end`
1246
1247 This supports describing USB ports in the devicetree. It allows a USB
1248 port location to be described in the tree with configuration
1249 information, and ACPI code to be generated that provides this
1250 information to the OS.
1251
1252 The usb symbol works with the scan_usb_bus() operation to scan bridges
1253 for devices so a tree of ports and hubs can be created.
1254
1255 The device address is computed with a 'port type' and a 'port id' which
1256 is flexible for the SOC to handle depending on their specific USB setup
1257 This also allows USB2 and USB3 ports to be described separately.
1258
1259 For example a board may have devices on two ports, one with a USB2
1260 device and one with a USB3 device, both of which are connected to an
1261 xHCI controller with a root hub:
1262
1263 ```text
1264 xHCI
1265 |
1266 RootHub
1267 | |
1268 USB2[0] USB3[2]
1269 ```
1270
1271 This is described by the following example:
1272
1273 ```text
1274 device pci 14.0 on
1275 chip drivers/usb/acpi
1276 register "name" = ""Root Hub""
1277 device usb 0.0 on
1278
1279 chip drivers/usb/acpi
1280 register "name" = ""USB 2.0 Port 0""
1281 device usb 2.0 on end
1282 end
1283
1284 chip drivers/usb/acpi
1285 register "name" = ""USB 3.0 Port 2""
1286 device usb 3.2 on end
1287 end
1288
1289 end # device usb 0.0
1290 end # chip drivers/usb/acpi
1291 end # device pci 14.0
1292 ```
1293
1294 ### use
1295
1296 * Keyword type: Alias
1297 * Introduced in September of 2020, coreboot version 4.12
1298 * Usage: `use <Alias ID> as <Alias ID2>`
1299
1300 The author of the devicetree is free to choose any alias name that is
1301 unique in the devicetree. Later, when configuring the driver for a
1302 board, the alias can be used to link the device with the field of a
1303 driver's config, giving it a specific name.
1304
1305 Example:
1306
1307 ```text
1308 chip some/chip/driver
1309 use my_eeprom as needed_eeprom
1310 end
1311 ```