blob: 254ad2b8761bf4acef3a5b4b06b3c6bc4c11ac11 [file] [log] [blame]
Simon Glass36ad2342015-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
Michal Simeka0d28022013-11-21 13:39:02 -08008#ifndef _CLK_H_
9#define _CLK_H_
10
11int soc_clk_dump(void);
12
Simon Glass36ad2342015-06-23 15:39:15 -060013struct clk_ops {
14 /**
15 * get_rate() - Get current clock rate
16 *
17 * @dev: Device to check (UCLASS_CLK)
18 * @return clock rate in Hz, or -ve error code
19 */
20 ulong (*get_rate)(struct udevice *dev);
21
22 /**
23 * set_rate() - Set current clock rate
24 *
25 * @dev: Device to adjust
26 * @rate: New clock rate in Hz
27 * @return new rate, or -ve error code
28 */
29 ulong (*set_rate)(struct udevice *dev, ulong rate);
30
31 /**
32 * clk_set_periph_rate() - Set clock rate for a peripheral
33 *
34 * @dev: Device to adjust (UCLASS_CLK)
35 * @rate: New clock rate in Hz
36 * @return new clock rate in Hz, or -ve error code
37 */
38 ulong (*get_periph_rate)(struct udevice *dev, int periph);
39
40 /**
41 * clk_set_periph_rate() - Set current clock rate for a peripheral
42 *
43 * @dev: Device to update (UCLASS_CLK)
44 * @periph: Peripheral ID to cupdate
45 * @return new clock rate in Hz, or -ve error code
46 */
47 ulong (*set_periph_rate)(struct udevice *dev, int periph, ulong rate);
48};
49
50#define clk_get_ops(dev) ((struct clk_ops *)(dev)->driver->ops)
51
52/**
53 * clk_get_rate() - Get current clock rate
54 *
55 * @dev: Device to check (UCLASS_CLK)
56 * @return clock rate in Hz, or -ve error code
57 */
58ulong clk_get_rate(struct udevice *dev);
59
60/**
61 * set_rate() - Set current clock rate
62 *
63 * @dev: Device to adjust
64 * @rate: New clock rate in Hz
65 * @return new rate, or -ve error code
66 */
67ulong clk_set_rate(struct udevice *dev, ulong rate);
68
69/**
70 * clk_get_periph_rate() - Get current clock rate for a peripheral
71 *
72 * @dev: Device to check (UCLASS_CLK)
73 * @return clock rate in Hz, -ve error code
74 */
75ulong clk_get_periph_rate(struct udevice *dev, int periph);
76
77/**
78 * clk_set_periph_rate() - Set current clock rate for a peripheral
79 *
80 * @dev: Device to update (UCLASS_CLK)
81 * @periph: Peripheral ID to cupdate
82 * @return new clock rate in Hz, or -ve error code
83 */
84ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate);
85
Michal Simeka0d28022013-11-21 13:39:02 -080086#endif /* _CLK_H_ */