Merge tag 'xilinx-for-v2022.07-rc4' of https://source.denx.de/u-boot/custodians/u...
[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         CCU_CLK_F_DUMMY_GATE            = BIT(2),
22 };
23
24 /**
25  * struct ccu_clk_gate - ccu clock gate
26  * @off:        gate offset
27  * @bit:        gate bit
28  * @flags:      ccu clock gate flags
29  */
30 struct ccu_clk_gate {
31         u16 off;
32         u32 bit;
33         enum ccu_flags flags;
34 };
35
36 #define GATE(_off, _bit) {                      \
37         .off = _off,                            \
38         .bit = _bit,                            \
39         .flags = CCU_CLK_F_IS_VALID,            \
40 }
41
42 #define GATE_DUMMY {                            \
43         .flags = CCU_CLK_F_DUMMY_GATE,          \
44 }
45
46 /**
47  * struct ccu_reset - ccu reset
48  * @off:        reset offset
49  * @bit:        reset bit
50  * @flags:      ccu reset control flags
51  */
52 struct ccu_reset {
53         u16 off;
54         u32 bit;
55         enum ccu_flags flags;
56 };
57
58 #define RESET(_off, _bit) {                     \
59         .off = _off,                            \
60         .bit = _bit,                            \
61         .flags = CCU_RST_F_IS_VALID,            \
62 }
63
64 /**
65  * struct ccu_desc - clock control unit descriptor
66  *
67  * @gates:      clock gates
68  * @resets:     reset unit
69  */
70 struct ccu_desc {
71         const struct ccu_clk_gate *gates;
72         const struct ccu_reset *resets;
73 };
74
75 /**
76  * struct ccu_priv - sunxi clock control unit
77  *
78  * @base:       base address
79  * @desc:       ccu descriptor
80  */
81 struct ccu_priv {
82         void *base;
83         const struct ccu_desc *desc;
84 };
85
86 /**
87  * sunxi_clk_probe - common sunxi clock probe
88  * @dev:        clock device
89  */
90 int sunxi_clk_probe(struct udevice *dev);
91
92 extern struct clk_ops sunxi_clk_ops;
93
94 /**
95  * sunxi_reset_bind() - reset binding
96  *
97  * @dev:       reset device
98  * @count:     reset count
99  * Return: 0 success, or error value
100  */
101 int sunxi_reset_bind(struct udevice *dev, ulong count);
102
103 #endif /* _CLK_SUNXI_H */