clk: sunxi: Use a single driver for all variants
[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         u8 num_gates;
74         u8 num_resets;
75 };
76
77 /**
78  * struct ccu_priv - sunxi clock control unit
79  *
80  * @base:       base address
81  * @desc:       ccu descriptor
82  */
83 struct ccu_priv {
84         void *base;
85         const struct ccu_desc *desc;
86 };
87
88 extern struct clk_ops sunxi_clk_ops;
89
90 /**
91  * sunxi_reset_bind() - reset binding
92  *
93  * @dev:       reset device
94  * Return: 0 success, or error value
95  */
96 int sunxi_reset_bind(struct udevice *dev);
97
98 #endif /* _CLK_SUNXI_H */