As I understand, platform device drivers could be autoloaded when "compatible" field in the device tree matches with "compatible" field in the kernel module. Here is pwm-overlay.dts
file from Raspberry Pi distro:
/ {
fragment@0 {
target = <&gpio>;
__overlay__ {
pwm_pins: pwm_pins {
brcm,pins = <18>;
brcm,function = <2>; /* Alt5 */
};
};
};
fragment@1 {
target = <&pwm>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&pwm_pins>;
status = "okay";
};
};
fragment@2 {
target = <&clk_pwm>;
frag2: __overlay__ {
clock-frequency = <100000000>;
};
};
__overrides__ {
pin = <&pwm_pins>,"brcm,pins:0";
func = <&pwm_pins>,"brcm,function:0";
clock = <&frag2>,"clock-frequency:0";
};
};
First of all, I do not see any "compatible" field, but in pwm-bcm2835.c
file there are such strings:
static const struct of_device_id bcm2835_pwm_of_match[] = {
{ .compatible = "brcm,bcm2835-pwm", },
{ /* sentinel */ }
};
Also, when I load overlay, driver successfully autoloaded too. How it works? How it knows what driver to load?