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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
#ifndef __IMX8_CLK_H
#define __IMX8_CLK_H
#include <linux/spinlock.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <soc/imx8/sc/sci.h>
extern spinlock_t imx_ccm_lock;
extern sc_ipc_t ccm_ipc_handle;
int imx8_clk_mu_init(void);
bool imx8_clk_is_resource_owned(sc_rsrc_t rsrc);
struct clk *imx_clk_divider_scu(const char *name,
sc_rsrc_t rsrc_id, sc_pm_clk_t clk_type);
struct clk *imx_clk_divider2_scu(const char *name, const char *parent_name,
sc_rsrc_t rsrc_id, sc_pm_clk_t clk_type);
struct clk *imx_clk_divider3_scu(const char *name, const char *parent_name,
sc_rsrc_t rsrc_id, sc_ctrl_t gpr_id);
struct clk *clk_register_gate_scu(struct device *dev, const char *name,
const char *parent_name, unsigned long flags,
u8 clk_gate_scu_flags, spinlock_t *lock,
sc_rsrc_t rsrc_id, sc_pm_clk_t clk_type,
void __iomem *reg, u8 bit_idx, bool hw_gate);
struct clk *clk_register_gate2_scu(struct device *dev, const char *name,
const char *parent_name, unsigned long flags,
void __iomem *reg, u8 bit_idx,
u8 clk_gate_flags, spinlock_t *lock, const char *pd_name);
struct clk *clk_register_mux_scu(struct device *dev, const char *name,
const char **parent_names, u8 num_parents, unsigned long flags,
void __iomem *reg, u8 shift, u8 width,
u8 clk_mux_flags, spinlock_t *lock,
const char *pd_name);
struct clk *clk_register_gate3_scu(struct device *dev, const char *name,
const char *parent_name, spinlock_t *lock,
sc_rsrc_t rsrc_id, sc_ctrl_t gpr_id, bool invert_flag);
struct clk *clk_register_mux_gpr_scu(struct device *dev, const char *name,
const char **parents, int num_parents, spinlock_t *lock,
sc_rsrc_t rsrc_id, sc_ctrl_t gpr_id);
struct clk *clk_register_mux2_scu(struct device *dev, const char *name,
const char **parents, int num_parents, unsigned long flags,
sc_rsrc_t rsrc_id, sc_pm_clk_t clk_type);
static inline struct clk *imx_clk_fixed(const char *name, int rate)
{
return clk_register_fixed_rate(NULL, name, NULL, 0, rate);
}
static inline struct clk *imx_clk_gate_scu(const char *name, const char *parent,
sc_rsrc_t rsrc_id, sc_pm_clk_t clk_type,
void __iomem *reg, u8 bit_idx, bool hw_gate)
{
return clk_register_gate_scu(NULL, name, parent,
CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, 0,
&imx_ccm_lock, rsrc_id, clk_type, reg,
bit_idx, hw_gate);
}
static inline struct clk *imx_clk_gate2_scu(const char *name, const char *parent,
void __iomem *reg, u8 bit_idx, const char *pd_name)
{
return clk_register_gate2_scu(NULL, name, parent, 0, reg,
bit_idx, 0, &imx_ccm_lock, pd_name);
}
static inline struct clk *imx_clk_gate3_scu(const char *name, const char *parent,
sc_rsrc_t rsrc_id, sc_ctrl_t gpr_id, bool invert_flag)
{
return clk_register_gate3_scu(NULL, name, parent,
&imx_ccm_lock, rsrc_id, gpr_id, invert_flag);
}
static inline struct clk *imx_clk_mux_gpr_scu(const char *name, const char **parents,
int num_parents, sc_rsrc_t rsrc_id, sc_ctrl_t gpr_id)
{
return clk_register_mux_gpr_scu(NULL, name, parents, num_parents,
&imx_ccm_lock, rsrc_id, gpr_id);
}
static inline struct clk *imx_clk_mux2_scu(const char *name,
const char **parents, int num_parents, sc_rsrc_t rsrc_id,
sc_pm_clk_t clk_type)
{
return clk_register_mux2_scu(NULL, name, parents, num_parents,
CLK_SET_RATE_NO_REPARENT, rsrc_id,
clk_type);
}
static inline void imx_clk_set_rate(struct clk *clk, unsigned long rate)
{
int ret = clk_set_rate(clk, rate);
if (ret)
pr_err("failed to set rate of clk %s to %ld: %d\n",
__clk_get_name(clk), rate, ret);
}
static inline struct clk *imx_clk_gate(const char *name, const char *parent,
void __iomem *reg, u8 shift)
{
return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
shift, 0, &imx_ccm_lock);
}
static inline struct clk *imx_clk_fixed_factor(const char *name,
const char *parent, unsigned int mult, unsigned int div)
{
return clk_register_fixed_factor(NULL, name, parent,
CLK_SET_RATE_PARENT, mult, div);
}
static inline struct clk *imx_clk_mux_scu(const char *name, void __iomem *reg,
u8 shift, u8 width, const char **parents, int num_parents, const char *pd_name)
{
return clk_register_mux_scu(NULL, name, parents, num_parents,
CLK_SET_RATE_NO_REPARENT, reg, shift,
width, 0, &imx_ccm_lock, pd_name);
}
#endif
|