1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2024 SpacemiT Technology Co. Ltd
* Copyright (c) 2024-2025 Haylen Chu <[email protected]>
* Copyright (c) 2025 Junhui Liu <[email protected]>
* Copyright (c) 2025-2026 RISCstar Ltd.
*
* Authors: Haylen Chu <[email protected]>
*/
#ifndef _CLK_COMMON_H_
#define _CLK_COMMON_H_
#include <linux/clk-provider.h>
struct ccu_common;
typedef int (*ccu_init_fn)(struct ccu_common *common);
struct ccu_common {
struct regmap *regmap;
struct regmap *lock_regmap;
const char *name;
const char * const *parents;
size_t num_parents;
ccu_init_fn init;
union {
/* For DDN and MIX */
struct {
u32 reg_ctrl;
u32 reg_fc;
u32 mask_fc;
};
/* For PLL */
struct {
u32 reg_swcr1;
u32 reg_swcr3;
};
};
struct clk clk;
};
#define CCU_COMMON(_id, _name, _parent, _init, _flags) \
.name = #_name, \
.parents = (const char *[]) { _parent }, \
.num_parents = 1, \
.init = _init, \
.clk = { .flags = _flags, .id = _id, } \
#define CCU_COMMON_PARENTS(_id, _name, _parents, _num_p, _init, _flags) \
.name = #_name, \
.parents = _parents, \
.num_parents = _num_p, \
.init = _init, \
.clk = { .flags = _flags, .id = _id, } \
static inline struct ccu_common *clk_to_ccu_common(struct clk *clk)
{
return container_of(clk, struct ccu_common, clk);
}
#define ccu_read(c, reg) \
({ \
struct ccu_common * const __ccu = (c); \
u32 tmp; \
regmap_read(__ccu->regmap, __ccu->reg_##reg, &tmp); \
tmp; \
})
#define ccu_update(c, reg, mask, val) \
({ \
struct ccu_common * const __ccu = (c); \
regmap_update_bits(__ccu->regmap, __ccu->reg_##reg, \
mask, val); \
})
#endif /* _CLK_COMMON_H_ */
|