blob: 5dd97ab227303d6b340196f9c8681f70616e7507 [file] [log] [blame]
Jagan Teki1d150b42018-12-22 21:32:49 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018 Amarula Solutions.
4 * Author: Jagan Teki <jagan@amarulasolutions.com>
5 */
6
7#ifndef _ASM_ARCH_CCU_H
8#define _ASM_ARCH_CCU_H
9
10/**
Jagan Teki7f6c2a82019-01-18 22:18:13 +053011 * enum ccu_flags - ccu clock/reset flags
Jagan Teki1d150b42018-12-22 21:32:49 +053012 *
13 * @CCU_CLK_F_IS_VALID: is given clock gate is valid?
Jagan Teki7f6c2a82019-01-18 22:18:13 +053014 * @CCU_RST_F_IS_VALID: is given reset control is valid?
Jagan Teki1d150b42018-12-22 21:32:49 +053015 */
16enum ccu_flags {
17 CCU_CLK_F_IS_VALID = BIT(0),
Jagan Teki7f6c2a82019-01-18 22:18:13 +053018 CCU_RST_F_IS_VALID = BIT(1),
Jagan Teki1d150b42018-12-22 21:32:49 +053019};
20
21/**
22 * struct ccu_clk_gate - ccu clock gate
23 * @off: gate offset
24 * @bit: gate bit
25 * @flags: ccu clock gate flags
26 */
27struct ccu_clk_gate {
28 u16 off;
29 u32 bit;
30 enum ccu_flags flags;
31};
32
33#define GATE(_off, _bit) { \
34 .off = _off, \
35 .bit = _bit, \
36 .flags = CCU_CLK_F_IS_VALID, \
37}
38
39/**
Jagan Teki7f6c2a82019-01-18 22:18:13 +053040 * struct ccu_reset - ccu reset
41 * @off: reset offset
42 * @bit: reset bit
43 * @flags: ccu reset control flags
44 */
45struct ccu_reset {
46 u16 off;
47 u32 bit;
48 enum ccu_flags flags;
49};
50
51#define RESET(_off, _bit) { \
52 .off = _off, \
53 .bit = _bit, \
54 .flags = CCU_RST_F_IS_VALID, \
55}
56
57/**
Jagan Teki1d150b42018-12-22 21:32:49 +053058 * struct ccu_desc - clock control unit descriptor
59 *
60 * @gates: clock gates
Jagan Teki7f6c2a82019-01-18 22:18:13 +053061 * @resets: reset unit
Jagan Teki1d150b42018-12-22 21:32:49 +053062 */
63struct ccu_desc {
64 const struct ccu_clk_gate *gates;
Jagan Teki7f6c2a82019-01-18 22:18:13 +053065 const struct ccu_reset *resets;
Jagan Teki1d150b42018-12-22 21:32:49 +053066};
67
68/**
69 * struct ccu_priv - sunxi clock control unit
70 *
71 * @base: base address
72 * @desc: ccu descriptor
73 */
74struct ccu_priv {
75 void *base;
76 const struct ccu_desc *desc;
77};
78
79/**
80 * sunxi_clk_probe - common sunxi clock probe
81 * @dev: clock device
82 */
83int sunxi_clk_probe(struct udevice *dev);
84
85extern struct clk_ops sunxi_clk_ops;
86
Jagan Teki7f6c2a82019-01-18 22:18:13 +053087/**
88 * sunxi_reset_bind() - reset binding
89 *
90 * @dev: reset device
91 * @count: reset count
92 * @return 0 success, or error value
93 */
94int sunxi_reset_bind(struct udevice *dev, ulong count);
95
Jagan Teki1d150b42018-12-22 21:32:49 +053096#endif /* _ASM_ARCH_CCU_H */