blob: 371784a56e0fc54e0a6c084723480603da5d1cb6 [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
Michal Simek08d0d6f2013-11-21 13:39:02 -08008#ifndef _CLK_H_
9#define _CLK_H_
10
Masahiro Yamadaad1cf782016-01-13 13:16:09 +090011#include <linux/types.h>
12
13struct udevice;
14
Michal Simek08d0d6f2013-11-21 13:39:02 -080015int soc_clk_dump(void);
16
Simon Glassf26c8a82015-06-23 15:39:15 -060017struct clk_ops {
18 /**
19 * get_rate() - Get current clock rate
20 *
21 * @dev: Device to check (UCLASS_CLK)
22 * @return clock rate in Hz, or -ve error code
23 */
24 ulong (*get_rate)(struct udevice *dev);
25
26 /**
27 * set_rate() - Set current clock rate
28 *
29 * @dev: Device to adjust
30 * @rate: New clock rate in Hz
31 * @return new rate, or -ve error code
32 */
33 ulong (*set_rate)(struct udevice *dev, ulong rate);
34
35 /**
Masahiro Yamada8bdf9cf2016-01-13 13:16:08 +090036 * get_periph_rate() - Get clock rate for a peripheral
37 *
38 * @dev: Device to check (UCLASS_CLK)
39 * @periph: Peripheral ID to check
40 * @return clock rate in Hz, or -ve error code
41 */
Simon Glassf26c8a82015-06-23 15:39:15 -060042 ulong (*get_periph_rate)(struct udevice *dev, int periph);
43
44 /**
Masahiro Yamada8bdf9cf2016-01-13 13:16:08 +090045 * set_periph_rate() - Set current clock rate for a peripheral
Simon Glassf26c8a82015-06-23 15:39:15 -060046 *
47 * @dev: Device to update (UCLASS_CLK)
Masahiro Yamada8bdf9cf2016-01-13 13:16:08 +090048 * @periph: Peripheral ID to update
Simon Glassf26c8a82015-06-23 15:39:15 -060049 * @return new clock rate in Hz, or -ve error code
50 */
51 ulong (*set_periph_rate)(struct udevice *dev, int periph, ulong rate);
52};
53
54#define clk_get_ops(dev) ((struct clk_ops *)(dev)->driver->ops)
55
56/**
57 * clk_get_rate() - Get current clock rate
58 *
59 * @dev: Device to check (UCLASS_CLK)
60 * @return clock rate in Hz, or -ve error code
61 */
62ulong clk_get_rate(struct udevice *dev);
63
64/**
Masahiro Yamada8bdf9cf2016-01-13 13:16:08 +090065 * clk_set_rate() - Set current clock rate
Simon Glassf26c8a82015-06-23 15:39:15 -060066 *
67 * @dev: Device to adjust
68 * @rate: New clock rate in Hz
69 * @return new rate, or -ve error code
70 */
71ulong clk_set_rate(struct udevice *dev, ulong rate);
72
73/**
74 * clk_get_periph_rate() - Get current clock rate for a peripheral
75 *
76 * @dev: Device to check (UCLASS_CLK)
77 * @return clock rate in Hz, -ve error code
78 */
79ulong clk_get_periph_rate(struct udevice *dev, int periph);
80
81/**
82 * clk_set_periph_rate() - Set current clock rate for a peripheral
83 *
84 * @dev: Device to update (UCLASS_CLK)
Masahiro Yamada8bdf9cf2016-01-13 13:16:08 +090085 * @periph: Peripheral ID to update
Simon Glassf26c8a82015-06-23 15:39:15 -060086 * @return new clock rate in Hz, or -ve error code
87 */
88ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate);
89
Michal Simek08d0d6f2013-11-21 13:39:02 -080090#endif /* _CLK_H_ */