struct device 中的 of_node 参数是什么?

Sag*_*ain 3 linux linux-device-driver linux-kernel device-tree

struct device 中的解释说

关联的设备树节点。

但是,我并没有清楚地理解这一点。

谁能提供一个例子?

Sas*_*i V 5

of_node 与 Open Firmware 相关,它保存设备树的信息。

设备树就像配置文件(命名节点和属性),它详细描述了硬件。

设备树的主要优点是您不必为特定硬件不断修改内核。您所要做的就是在设备树 fmt 中定义您的硬件并将其提供给引导加载程序。引导加载程序,例如 uboot,将设备树信息传递给内核,内核根据从引导加载程序收到的这些信息初始化设备。

下面是设备树的例子。

{
    compatible = "acme,coyotes-revenge";

    cpus {
        cpu@0 {
            compatible = "arm,cortex-a9";
        };
        cpu@1 {
            compatible = "arm,cortex-a9";
        };
    };

    serial@101F0000 {
        compatible = "arm,pl011";
    };

    serial@101F2000 {
        compatible = "arm,pl011";
    };

    interrupt-controller@10140000 {
        compatible = "arm,pl190";
    };

    external-bus {
        ethernet@0,0 {
            compatible = "smc,smc91c111";
        };

        i2c@1,0 {
            compatible = "acme,a1234-i2c-bus";
            rtc@58 {
                compatible = "maxim,ds1338";
            };
        };

        flash@2,0 {
            compatible = "samsung,k8f1315ebm", "cfi-flash";
        };
    };
};
Run Code Online (Sandbox Code Playgroud)