1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2016 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
7 #ifndef __CLK_UNIPHIER_H__
8 #define __CLK_UNIPHIER_H__
14 #define UNIPHIER_CLK_CPUGEAR_MAX_PARENTS 16
15 #define UNIPHIER_CLK_MUX_MAX_PARENTS 8
17 enum uniphier_clk_type
{
18 UNIPHIER_CLK_TYPE_CPUGEAR
,
19 UNIPHIER_CLK_TYPE_FIXED_FACTOR
,
20 UNIPHIER_CLK_TYPE_FIXED_RATE
,
21 UNIPHIER_CLK_TYPE_GATE
,
22 UNIPHIER_CLK_TYPE_MUX
,
25 struct uniphier_clk_cpugear_data
{
26 const char *parent_names
[UNIPHIER_CLK_CPUGEAR_MAX_PARENTS
];
27 unsigned int num_parents
;
32 struct uniphier_clk_fixed_factor_data
{
33 const char *parent_name
;
38 struct uniphier_clk_fixed_rate_data
{
39 unsigned long fixed_rate
;
42 struct uniphier_clk_gate_data
{
43 const char *parent_name
;
48 struct uniphier_clk_mux_data
{
49 const char *parent_names
[UNIPHIER_CLK_MUX_MAX_PARENTS
];
50 unsigned int num_parents
;
52 unsigned int masks
[UNIPHIER_CLK_MUX_MAX_PARENTS
];
53 unsigned int vals
[UNIPHIER_CLK_MUX_MAX_PARENTS
];
56 struct uniphier_clk_data
{
58 enum uniphier_clk_type type
;
61 struct uniphier_clk_cpugear_data cpugear
;
62 struct uniphier_clk_fixed_factor_data factor
;
63 struct uniphier_clk_fixed_rate_data rate
;
64 struct uniphier_clk_gate_data gate
;
65 struct uniphier_clk_mux_data mux
;
69 #define UNIPHIER_CLK_CPUGEAR(_name, _idx, _regbase, _mask, \
73 .type = UNIPHIER_CLK_TYPE_CPUGEAR, \
76 .parent_names = { __VA_ARGS__ }, \
77 .num_parents = (_num_parents), \
78 .regbase = (_regbase), \
83 #define UNIPHIER_CLK_FACTOR(_name, _idx, _parent, _mult, _div) \
86 .type = UNIPHIER_CLK_TYPE_FIXED_FACTOR, \
89 .parent_name = (_parent), \
95 #define UNIPHIER_CLK_GATE(_name, _idx, _parent, _reg, _bit) \
98 .type = UNIPHIER_CLK_TYPE_GATE, \
101 .parent_name = (_parent), \
107 #define UNIPHIER_CLK_DIV(parent, div) \
108 UNIPHIER_CLK_FACTOR(parent "/" #div, -1, parent, 1, div)
110 #define UNIPHIER_CLK_DIV2(parent, div0, div1) \
111 UNIPHIER_CLK_DIV(parent, div0), \
112 UNIPHIER_CLK_DIV(parent, div1)
114 #define UNIPHIER_CLK_DIV3(parent, div0, div1, div2) \
115 UNIPHIER_CLK_DIV2(parent, div0, div1), \
116 UNIPHIER_CLK_DIV(parent, div2)
118 #define UNIPHIER_CLK_DIV4(parent, div0, div1, div2, div3) \
119 UNIPHIER_CLK_DIV2(parent, div0, div1), \
120 UNIPHIER_CLK_DIV2(parent, div2, div3)
122 struct clk_hw
*uniphier_clk_register_cpugear(struct device
*dev
,
123 struct regmap
*regmap
,
125 const struct uniphier_clk_cpugear_data
*data
);
126 struct clk_hw
*uniphier_clk_register_fixed_factor(struct device
*dev
,
128 const struct uniphier_clk_fixed_factor_data
*data
);
129 struct clk_hw
*uniphier_clk_register_fixed_rate(struct device
*dev
,
131 const struct uniphier_clk_fixed_rate_data
*data
);
132 struct clk_hw
*uniphier_clk_register_gate(struct device
*dev
,
133 struct regmap
*regmap
,
135 const struct uniphier_clk_gate_data
*data
);
136 struct clk_hw
*uniphier_clk_register_mux(struct device
*dev
,
137 struct regmap
*regmap
,
139 const struct uniphier_clk_mux_data
*data
);
141 extern const struct uniphier_clk_data uniphier_ld4_sys_clk_data
[];
142 extern const struct uniphier_clk_data uniphier_pro4_sys_clk_data
[];
143 extern const struct uniphier_clk_data uniphier_sld8_sys_clk_data
[];
144 extern const struct uniphier_clk_data uniphier_pro5_sys_clk_data
[];
145 extern const struct uniphier_clk_data uniphier_pxs2_sys_clk_data
[];
146 extern const struct uniphier_clk_data uniphier_ld11_sys_clk_data
[];
147 extern const struct uniphier_clk_data uniphier_ld20_sys_clk_data
[];
148 extern const struct uniphier_clk_data uniphier_pxs3_sys_clk_data
[];
149 extern const struct uniphier_clk_data uniphier_ld4_mio_clk_data
[];
150 extern const struct uniphier_clk_data uniphier_pro5_sd_clk_data
[];
151 extern const struct uniphier_clk_data uniphier_ld4_peri_clk_data
[];
152 extern const struct uniphier_clk_data uniphier_pro4_peri_clk_data
[];
154 #endif /* __CLK_UNIPHIER_H__ */