Merge tag 'u-boot-at91-2022.01-b' of https://source.denx.de/u-boot/custodians/u-boot...
[platform/kernel/u-boot.git] / include / clk / sunxi.h
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2018 Amarula Solutions.
4  * Author: Jagan Teki <jagan@amarulasolutions.com>
5  */
6
7 #ifndef _CLK_SUNXI_H
8 #define _CLK_SUNXI_H
9
10 #include <linux/bitops.h>
11
12 /**
13  * enum ccu_flags - ccu clock/reset flags
14  *
15  * @CCU_CLK_F_IS_VALID:         is given clock gate is valid?
16  * @CCU_RST_F_IS_VALID:         is given reset control is valid?
17  */
18 enum ccu_flags {
19         CCU_CLK_F_IS_VALID              = BIT(0),
20         CCU_RST_F_IS_VALID              = BIT(1),
21 };
22
23 /**
24  * struct ccu_clk_gate - ccu clock gate
25  * @off:        gate offset
26  * @bit:        gate bit
27  * @flags:      ccu clock gate flags
28  */
29 struct ccu_clk_gate {
30         u16 off;
31         u32 bit;
32         enum ccu_flags flags;
33 };
34
35 #define GATE(_off, _bit) {                      \
36         .off = _off,                            \
37         .bit = _bit,                            \
38         .flags = CCU_CLK_F_IS_VALID,            \
39 }
40
41 /**
42  * struct ccu_reset - ccu reset
43  * @off:        reset offset
44  * @bit:        reset bit
45  * @flags:      ccu reset control flags
46  */
47 struct ccu_reset {
48         u16 off;
49         u32 bit;
50         enum ccu_flags flags;
51 };
52
53 #define RESET(_off, _bit) {                     \
54         .off = _off,                            \
55         .bit = _bit,                            \
56         .flags = CCU_RST_F_IS_VALID,            \
57 }
58
59 /**
60  * struct ccu_desc - clock control unit descriptor
61  *
62  * @gates:      clock gates
63  * @resets:     reset unit
64  */
65 struct ccu_desc {
66         const struct ccu_clk_gate *gates;
67         const struct ccu_reset *resets;
68 };
69
70 /**
71  * struct ccu_priv - sunxi clock control unit
72  *
73  * @base:       base address
74  * @desc:       ccu descriptor
75  */
76 struct ccu_priv {
77         void *base;
78         const struct ccu_desc *desc;
79 };
80
81 /**
82  * sunxi_clk_probe - common sunxi clock probe
83  * @dev:        clock device
84  */
85 int sunxi_clk_probe(struct udevice *dev);
86
87 extern struct clk_ops sunxi_clk_ops;
88
89 /**
90  * sunxi_reset_bind() - reset binding
91  *
92  * @dev:       reset device
93  * @count:     reset count
94  * @return 0 success, or error value
95  */
96 int sunxi_reset_bind(struct udevice *dev, ulong count);
97
98 #endif /* _CLK_SUNXI_H */