ec icon indicating copy to clipboard operation
ec copied to clipboard

Evaluate use of devicetree

Open crawfxrd opened this issue 1 month ago • 0 comments

Note: This refers to the devicetree specification, not coreboot devicetree.

Evaluate use of devicetree for declaring available/used hardware resources.

Determine if code generation can be done efficiently for MCS-51. Assembly output from SDCC must be inspected, not just any tool-generated C code. For example:

  • Avoiding pointer indirection and call depth due to limited stack space (<256 bytes)
  • Minimizing generated number of instructions due to limited code space (64 KiB without banking)

Would the fully generated DTS or DTB be useful to export? e.g. for:

  • Host tooling for configuring and validating boards
  • A board-specific UEFI driver for configuring the EC

Example

Because vendors make up their own 8051-based controllers and put most functionality in external registers, is it even worth adding architecture-level (8051/8052) devicetrees?

The EC/SoC would declare available resources and details on how to configure them in an include file (.dtsi).

// XXX: Use preprocessor so register names can be used instead of redeclaring the addresses?
//#include <registers.h>

/ {
    #address-cells = <0x1>;
    #size-cells = <0x1>;
    soc {
        #address-cells = <0x1>;
        #size-cells = <0x1>;
        pwm0: pwm@1802 {
            compatibile = "ite,it557x-pwm";
            reg = <0x1802 1     /* DCR */
                   0x180A 1     /* PWMPOL */
                   0x180C 1     /* PCSSG */
                   0x180F 1>;   /* PCSG */
            channel = <0>;
            status = "disabled";
        };
    };
};

The board would declare the full devicetree (.dts) by including relevant files and overriding resources (by alias) as needed.

/dts-v1/;

// XXX: Use C-style includes for preprocessor tool to generate path?
/include "../path/to/soc/ite/it5571.dtsi"

/ {
    model = "system76,darp10";
    compatible = "system76,darp10";
};

&pwm0 {
    // Keyboard brightness
    status = "okay";
};

What would generated code for this look like?

Resources

  • devicetree specification: https://github.com/devicetree-org/devicetree-specification
  • Linux docs: https://www.kernel.org/doc/html/latest/devicetree/
  • Zephyr docs: https://docs.zephyrproject.org/latest/build/dts/index.html

crawfxrd avatar Dec 06 '25 00:12 crawfxrd