blob: 19f6f07c6f43ead3c12813afe6bb6d3a15b7073b [file] [log] [blame]
Simon Glassf26c8a82015-06-23 15:39:15 -06001/*
2 * Copyright (C) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
9#include <clk.h>
10#include <dm.h>
11#include <errno.h>
12#include <dm/lists.h>
13#include <dm/root.h>
14
15ulong clk_get_rate(struct udevice *dev)
16{
17 struct clk_ops *ops = clk_get_ops(dev);
18
19 if (!ops->get_rate)
20 return -ENOSYS;
21
22 return ops->get_rate(dev);
23}
24
25ulong clk_set_rate(struct udevice *dev, ulong rate)
26{
27 struct clk_ops *ops = clk_get_ops(dev);
28
29 if (!ops->set_rate)
30 return -ENOSYS;
31
32 return ops->set_rate(dev, rate);
33}
34
Masahiro Yamadaf0e07512016-01-13 13:16:12 +090035int clk_enable(struct udevice *dev, int periph)
36{
37 struct clk_ops *ops = clk_get_ops(dev);
38
39 if (!ops->enable)
40 return -ENOSYS;
41
42 return ops->enable(dev, periph);
43}
44
Simon Glassf26c8a82015-06-23 15:39:15 -060045ulong clk_get_periph_rate(struct udevice *dev, int periph)
46{
47 struct clk_ops *ops = clk_get_ops(dev);
48
49 if (!ops->get_periph_rate)
50 return -ENOSYS;
51
52 return ops->get_periph_rate(dev, periph);
53}
54
55ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate)
56{
57 struct clk_ops *ops = clk_get_ops(dev);
58
59 if (!ops->set_periph_rate)
60 return -ENOSYS;
61
62 return ops->set_periph_rate(dev, periph, rate);
63}
64
65UCLASS_DRIVER(clk) = {
66 .id = UCLASS_CLK,
67 .name = "clk",
68};