Zephyr RTOS

Zephyr RTOS: Does a child node's compatible override its parent's?

6 Nov 20261 min readLalith

Short answer: not quite, and this trips up a lot of people writing devicetree bindings. A child node's compatible doesn't override the parent's compatible. What it overrides is which binding validates the child.

How Zephyr finds a child node's binding

Zephyr finds a node's binding in one of two ways.

1. The child has no compatible

It's validated against the parent's child-binding: block. This is how gpio-leds, gpio-keys and pwm-leds work.

controller@40000000 {
    compatible = "vendor,my-controller";
    channel_0 {
        channel-id = <0>;
    };
};

2. The child has its own compatible

It's validated only against its own binding file. The parent's child-binding is ignored for that node.

controller@40000000 {
    compatible = "vendor,my-controller";
    special_channel {
        compatible = "vendor,special-channel";
        channel-id = <2>;
    };
};

Key takeaways

Rule of thumb: child-binding is the default description for children. An explicit compatible opts a child out of it.

Have you run into this while writing custom bindings? I'd like to hear about your experience.

Have a firmware project? Get in touch →