xref: /rk3399_rockchip-uboot/include/clk.h (revision 8bdf9cfda04896c3ff6d704f398395776b69cba8)
1f26c8a8eSSimon Glass /*
2f26c8a8eSSimon Glass  * Copyright (c) 2015 Google, Inc
3f26c8a8eSSimon Glass  * Written by Simon Glass <sjg@chromium.org>
4f26c8a8eSSimon Glass  *
5f26c8a8eSSimon Glass  * SPDX-License-Identifier:	GPL-2.0+
6f26c8a8eSSimon Glass  */
7f26c8a8eSSimon Glass 
808d0d6f3SMichal Simek #ifndef _CLK_H_
908d0d6f3SMichal Simek #define _CLK_H_
1008d0d6f3SMichal Simek 
1108d0d6f3SMichal Simek int soc_clk_dump(void);
1208d0d6f3SMichal Simek 
13f26c8a8eSSimon Glass struct clk_ops {
14f26c8a8eSSimon Glass 	/**
15f26c8a8eSSimon Glass 	 * get_rate() - Get current clock rate
16f26c8a8eSSimon Glass 	 *
17f26c8a8eSSimon Glass 	 * @dev:	Device to check (UCLASS_CLK)
18f26c8a8eSSimon Glass 	 * @return clock rate in Hz, or -ve error code
19f26c8a8eSSimon Glass 	 */
20f26c8a8eSSimon Glass 	ulong (*get_rate)(struct udevice *dev);
21f26c8a8eSSimon Glass 
22f26c8a8eSSimon Glass 	/**
23f26c8a8eSSimon Glass 	 * set_rate() - Set current clock rate
24f26c8a8eSSimon Glass 	 *
25f26c8a8eSSimon Glass 	 * @dev:	Device to adjust
26f26c8a8eSSimon Glass 	 * @rate:	New clock rate in Hz
27f26c8a8eSSimon Glass 	 * @return new rate, or -ve error code
28f26c8a8eSSimon Glass 	 */
29f26c8a8eSSimon Glass 	ulong (*set_rate)(struct udevice *dev, ulong rate);
30f26c8a8eSSimon Glass 
31f26c8a8eSSimon Glass 	/**
32*8bdf9cfdSMasahiro Yamada 	 * get_periph_rate() - Get clock rate for a peripheral
33f26c8a8eSSimon Glass 	 *
34*8bdf9cfdSMasahiro Yamada 	 * @dev:	Device to check (UCLASS_CLK)
35*8bdf9cfdSMasahiro Yamada 	 * @periph:	Peripheral ID to check
36*8bdf9cfdSMasahiro Yamada 	 * @return clock rate in Hz, or -ve error code
37f26c8a8eSSimon Glass 	 */
38f26c8a8eSSimon Glass 	ulong (*get_periph_rate)(struct udevice *dev, int periph);
39f26c8a8eSSimon Glass 
40f26c8a8eSSimon Glass 	/**
41*8bdf9cfdSMasahiro Yamada 	 * set_periph_rate() - Set current clock rate for a peripheral
42f26c8a8eSSimon Glass 	 *
43f26c8a8eSSimon Glass 	 * @dev:	Device to update (UCLASS_CLK)
44*8bdf9cfdSMasahiro Yamada 	 * @periph:	Peripheral ID to update
45f26c8a8eSSimon Glass 	 * @return new clock rate in Hz, or -ve error code
46f26c8a8eSSimon Glass 	 */
47f26c8a8eSSimon Glass 	ulong (*set_periph_rate)(struct udevice *dev, int periph, ulong rate);
48f26c8a8eSSimon Glass };
49f26c8a8eSSimon Glass 
50f26c8a8eSSimon Glass #define clk_get_ops(dev)	((struct clk_ops *)(dev)->driver->ops)
51f26c8a8eSSimon Glass 
52f26c8a8eSSimon Glass /**
53f26c8a8eSSimon Glass  * clk_get_rate() - Get current clock rate
54f26c8a8eSSimon Glass  *
55f26c8a8eSSimon Glass  * @dev:	Device to check (UCLASS_CLK)
56f26c8a8eSSimon Glass  * @return clock rate in Hz, or -ve error code
57f26c8a8eSSimon Glass  */
58f26c8a8eSSimon Glass ulong clk_get_rate(struct udevice *dev);
59f26c8a8eSSimon Glass 
60f26c8a8eSSimon Glass /**
61*8bdf9cfdSMasahiro Yamada  * clk_set_rate() - Set current clock rate
62f26c8a8eSSimon Glass  *
63f26c8a8eSSimon Glass  * @dev:	Device to adjust
64f26c8a8eSSimon Glass  * @rate:	New clock rate in Hz
65f26c8a8eSSimon Glass  * @return new rate, or -ve error code
66f26c8a8eSSimon Glass  */
67f26c8a8eSSimon Glass ulong clk_set_rate(struct udevice *dev, ulong rate);
68f26c8a8eSSimon Glass 
69f26c8a8eSSimon Glass /**
70f26c8a8eSSimon Glass  * clk_get_periph_rate() - Get current clock rate for a peripheral
71f26c8a8eSSimon Glass  *
72f26c8a8eSSimon Glass  * @dev:	Device to check (UCLASS_CLK)
73f26c8a8eSSimon Glass  * @return clock rate in Hz, -ve error code
74f26c8a8eSSimon Glass  */
75f26c8a8eSSimon Glass ulong clk_get_periph_rate(struct udevice *dev, int periph);
76f26c8a8eSSimon Glass 
77f26c8a8eSSimon Glass /**
78f26c8a8eSSimon Glass  * clk_set_periph_rate() - Set current clock rate for a peripheral
79f26c8a8eSSimon Glass  *
80f26c8a8eSSimon Glass  * @dev:	Device to update (UCLASS_CLK)
81*8bdf9cfdSMasahiro Yamada  * @periph:	Peripheral ID to update
82f26c8a8eSSimon Glass  * @return new clock rate in Hz, or -ve error code
83f26c8a8eSSimon Glass  */
84f26c8a8eSSimon Glass ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate);
85f26c8a8eSSimon Glass 
8608d0d6f3SMichal Simek #endif /* _CLK_H_ */
87