1 /*
2  * Copyright (c) 2006-2022, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2022-3-08      GuEe-GUI     the first version
9  */
10 
11 #define DBG_TAG "rtdm.thermal"
12 #define DBG_LVL DBG_INFO
13 #include <rtdbg.h>
14 
15 #include "thermal_dm.h"
16 
thermal_type(const char * type)17 enum rt_thermal_trip_type thermal_type(const char *type)
18 {
19     if (!type)
20     {
21         return RT_THERMAL_TRIP_TYPE_MAX;
22     }
23 
24     if (!rt_strcmp(type, "active"))
25     {
26         return RT_THERMAL_TRIP_ACTIVE;
27     }
28     else if (!rt_strcmp(type, "passive"))
29     {
30         return RT_THERMAL_TRIP_PASSIVE;
31     }
32     else if (!rt_strcmp(type, "hot"))
33     {
34         return RT_THERMAL_TRIP_HOT;
35     }
36     else if (!rt_strcmp(type, "critical"))
37     {
38         return RT_THERMAL_TRIP_CRITICAL;
39     }
40 
41     return RT_THERMAL_TRIP_TYPE_MAX;
42 }
43 
thermal_bind(struct rt_thermal_cooling_device * cdev,struct rt_thermal_zone_device * zdev)44 rt_err_t thermal_bind(struct rt_thermal_cooling_device *cdev,
45         struct rt_thermal_zone_device *zdev)
46 {
47     if (cdev->ops->bind)
48     {
49         return cdev->ops->bind(cdev, zdev);
50     }
51 
52     return RT_EOK;
53 }
54 
thermal_unbind(struct rt_thermal_cooling_device * cdev,struct rt_thermal_zone_device * zdev)55 rt_err_t thermal_unbind(struct rt_thermal_cooling_device *cdev,
56         struct rt_thermal_zone_device *zdev)
57 {
58     if (cdev->ops->unbind)
59     {
60         return cdev->ops->unbind(cdev, zdev);
61     }
62 
63     return RT_EOK;
64 }
65