Linux kernel 如何使用代码中的查找表将热传感器与冷却设备绑定

Linux kernel 如何使用代码中的查找表将热传感器与冷却设备绑定,linux-kernel,linux-device-driver,sensors,Linux Kernel,Linux Device Driver,Sensors,我想使用查找表将热传感器与冷却设备(风扇)绑定。我知道如何使用DTs(设备树)来实现这一点,但从未在代码中使用过相同的查找表。我需要关于如何使用查找表对代码执行相同操作的帮助,以及我们使用设备树执行的操作。 比如说 thermal-zones { cpu_thermal: cpu-thermal { polling-delay-passive = <250>; /* milliseconds */ polling-delay = <100

我想使用查找表将热传感器与冷却设备(风扇)绑定。我知道如何使用DTs(设备树)来实现这一点,但从未在代码中使用过相同的查找表。我需要关于如何使用查找表对代码执行相同操作的帮助,以及我们使用设备树执行的操作。 比如说

thermal-zones {
    cpu_thermal: cpu-thermal {
        polling-delay-passive = <250>; /* milliseconds */
        polling-delay = <1000>; /* milliseconds */

        thermal-sensors = <&bandgap0>;

        trips {
            cpu_alert0: cpu-alert0 {
                temperature = <90000>; /* millicelsius */
                hysteresis = <2000>; /* millicelsius */
                type = "active";
            };
            cpu_alert1: cpu-alert1 {
                temperature = <100000>; /* millicelsius */
                hysteresis = <2000>; /* millicelsius */
                type = "passive";
            };
            cpu_crit: cpu-crit {
                temperature = <125000>; /* millicelsius */
                hysteresis = <2000>; /* millicelsius */
                type = "critical";
            };
        };

        cooling-maps {
            map0 {
                trip = <&cpu_alert0>;
                cooling-device = <&fan0 THERMAL_NO_LIMIT 4>;
            };
            map1 {
                trip = <&cpu_alert1>;
                cooling-device = <&fan0 5 THERMAL_NO_LIMIT>, <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
            };
        };
    };
};
热区{
cpu_thermal:cpu thermal{
轮询延迟被动=;/*毫秒*/
轮询延迟=;/*毫秒*/
热传感器=;
旅行{
cpu_alert0:cpu-alert0{
温度=;/*毫摄氏度*/
滞后=;/*毫摄氏度*/
type=“活动”;
};
cpu_alert1:cpu-alert1{
温度=;/*毫摄氏度*/
滞后=;/*毫摄氏度*/
type=“被动”;
};
cpu临界值:cpu临界值{
温度=;/*毫摄氏度*/
滞后=;/*毫摄氏度*/
type=“临界”;
};
};
冷却图{
map0{
行程=;
冷却装置=;
};
map1{
行程=;
冷却装置=;
};
};
};
};

我如何在代码本身中进行相同的绑定呢?

只是不要使用devicetree绑定,而是使用非DT热驱动程序的示例,例如drivers/acpi/thermal.c、drivers/net/ethernet/mellanox/mlxsw/core_thermal.c

我甚至不确定这是否可行。如果你想通过设备属性来实现,你必须先将驱动程序/thermal/of thermal.c转换为设备属性(和swnode)API。嗨,我只想使用thermal framework。。但不希望从设备树中进行热绑定。我想从代码中绑定温度传感器和冷却设备,它自己更新了答案,mlxsw可能就是你们想要的