hc
2023-11-22 f743a7adbd6e230d66a6206fa115b59fec2d88eb
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
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2018 Fuzhou Rockchip Electronics Co., Ltd
 */
 
#include <common.h>
#include <console.h>
#include <dvfs.h>
 
int dvfs_apply(struct udevice *dev)
{
   const struct dm_dvfs_ops *ops = device_get_ops(dev);
 
   if (!ops->apply)
       return -ENOSYS;
 
   return ops->apply(dev);
}
 
int dvfs_repeat_apply(struct udevice *dev)
{
   const struct dm_dvfs_ops *ops = device_get_ops(dev);
 
   if (!ops->repeat_apply)
       return -ENOSYS;
 
   return ops->repeat_apply(dev);
}
 
int dvfs_init(bool apply)
{
   struct udevice *dev;
   int ret;
 
   ret = uclass_get_device(UCLASS_DVFS, 0, &dev);
   if (ret) {
       if (ret != -ENODEV)
           printf("DVFS: Get dvfs device failed, ret=%d\n", ret);
       return ret;
   }
 
   if (apply)
       return dvfs_apply(dev);
 
   return 0;
}
 
UCLASS_DRIVER(dvfs) = {
   .id    = UCLASS_DVFS,
   .name    = "dvfs",
};