2 * Copyright (C) 2016 Socionext Inc.
3 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #ifndef __CLK_UNIPHIER_H__
17 #define __CLK_UNIPHIER_H__
23 #define UNIPHIER_CLK_MUX_MAX_PARENTS 8
25 enum uniphier_clk_type
{
26 UNIPHIER_CLK_TYPE_FIXED_FACTOR
,
27 UNIPHIER_CLK_TYPE_FIXED_RATE
,
28 UNIPHIER_CLK_TYPE_GATE
,
29 UNIPHIER_CLK_TYPE_MUX
,
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_fixed_factor_data factor
;
62 struct uniphier_clk_fixed_rate_data rate
;
63 struct uniphier_clk_gate_data gate
;
64 struct uniphier_clk_mux_data mux
;
68 #define UNIPHIER_CLK_FACTOR(_name, _idx, _parent, _mult, _div) \
71 .type = UNIPHIER_CLK_TYPE_FIXED_FACTOR, \
74 .parent_name = (_parent), \
81 #define UNIPHIER_CLK_GATE(_name, _idx, _parent, _reg, _bit) \
84 .type = UNIPHIER_CLK_TYPE_GATE, \
87 .parent_name = (_parent), \
94 struct clk_hw
*uniphier_clk_register_fixed_factor(struct device
*dev
,
96 const struct uniphier_clk_fixed_factor_data
*data
);
97 struct clk_hw
*uniphier_clk_register_fixed_rate(struct device
*dev
,
99 const struct uniphier_clk_fixed_rate_data
*data
);
100 struct clk_hw
*uniphier_clk_register_gate(struct device
*dev
,
101 struct regmap
*regmap
,
103 const struct uniphier_clk_gate_data
*data
);
104 struct clk_hw
*uniphier_clk_register_mux(struct device
*dev
,
105 struct regmap
*regmap
,
107 const struct uniphier_clk_mux_data
*data
);
109 extern const struct uniphier_clk_data uniphier_sld3_sys_clk_data
[];
110 extern const struct uniphier_clk_data uniphier_ld4_sys_clk_data
[];
111 extern const struct uniphier_clk_data uniphier_pro4_sys_clk_data
[];
112 extern const struct uniphier_clk_data uniphier_sld8_sys_clk_data
[];
113 extern const struct uniphier_clk_data uniphier_pro5_sys_clk_data
[];
114 extern const struct uniphier_clk_data uniphier_pxs2_sys_clk_data
[];
115 extern const struct uniphier_clk_data uniphier_ld11_sys_clk_data
[];
116 extern const struct uniphier_clk_data uniphier_ld20_sys_clk_data
[];
117 extern const struct uniphier_clk_data uniphier_sld3_mio_clk_data
[];
118 extern const struct uniphier_clk_data uniphier_pro5_sd_clk_data
[];
119 extern const struct uniphier_clk_data uniphier_ld4_peri_clk_data
[];
120 extern const struct uniphier_clk_data uniphier_pro4_peri_clk_data
[];
122 #endif /* __CLK_UNIPHIER_H__ */