summaryrefslogtreecommitdiff
path: root/components/drivers/thermal/thermal_dm.c
blob: 9c1d81f417da62afacd401098222841011707ff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * Copyright (c) 2006-2022, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-3-08      GuEe-GUI     the first version
 */

#define DBG_TAG "rtdm.thermal"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>

#include "thermal_dm.h"

enum rt_thermal_trip_type thermal_type(const char *type)
{
    if (!type)
    {
        return RT_THERMAL_TRIP_TYPE_MAX;
    }

    if (!rt_strcmp(type, "active"))
    {
        return RT_THERMAL_TRIP_ACTIVE;
    }
    else if (!rt_strcmp(type, "passive"))
    {
        return RT_THERMAL_TRIP_PASSIVE;
    }
    else if (!rt_strcmp(type, "hot"))
    {
        return RT_THERMAL_TRIP_HOT;
    }
    else if (!rt_strcmp(type, "critical"))
    {
        return RT_THERMAL_TRIP_CRITICAL;
    }

    return RT_THERMAL_TRIP_TYPE_MAX;
}

rt_err_t thermal_bind(struct rt_thermal_cooling_device *cdev,
        struct rt_thermal_zone_device *zdev)
{
    if (cdev->ops->bind)
    {
        return cdev->ops->bind(cdev, zdev);
    }

    return RT_EOK;
}

rt_err_t thermal_unbind(struct rt_thermal_cooling_device *cdev,
        struct rt_thermal_zone_device *zdev)
{
    if (cdev->ops->unbind)
    {
        return cdev->ops->unbind(cdev, zdev);
    }

    return RT_EOK;
}