summaryrefslogtreecommitdiff
path: root/bsp/rockchip/dm/clk/clk-rk-half-divider.h
blob: 088bf50611d37215d789e9615adae5b715c43fff (plain)
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
/*
 * Copyright (c) 2006-2022, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-3-08      GuEe-GUI     the first version
 */

#ifndef __CLK_RK_HALF_DIVIDER_H__
#define __CLK_RK_HALF_DIVIDER_H__

#include "clk-rk.h"

struct rockchip_half_divider_clk_cell
{
    struct rockchip_clk_cell rk_cell;

    struct rt_clk_ops ops;
};

#define COMPOSITE_HALFDIV(_id, cname, pnames, f, mo, ms, mw, mf, ds, dw, df, go, gs, gf) \
(void *)&(struct rockchip_half_divider_clk_cell)        \
{                                                       \
    .rk_cell.cell.name = cname,                         \
    .rk_cell.cell.parent_names = pnames,                \
    .rk_cell.cell.parents_nr = RT_ARRAY_SIZE(pnames),   \
    .rk_cell.cell.flags = f,                            \
    .rk_cell.id = _id,                                  \
    .rk_cell.muxdiv_offset = mo,                        \
    .rk_cell.mux_shift = ms,                            \
    .rk_cell.mux_width = mw,                            \
    .rk_cell.mux_flags = mf,                            \
    .rk_cell.div_shift = ds,                            \
    .rk_cell.div_width = dw,                            \
    .rk_cell.div_flags = df,                            \
    .rk_cell.gate_offset = go,                          \
    .rk_cell.gate_shift = gs,                           \
    .rk_cell.gate_flags = gf,                           \
    .rk_cell.init = rockchip_half_divider_clk_cell_init,\
}

#define COMPOSITE_HALFDIV_OFFSET(_id, cname, pnames, f, mo, ms, mw, mf, do, ds, dw, df, go, gs, gf) \
(void *)&(struct rockchip_half_divider_clk_cell)        \
{                                                       \
    .rk_cell.cell.name = cname,                         \
    .rk_cell.cell.parent_names = pnames,                \
    .rk_cell.cell.parents_nr = RT_ARRAY_SIZE(pnames),   \
    .rk_cell.cell.flags = f,                            \
    .rk_cell.id = _id,                                  \
    .rk_cell.muxdiv_offset = mo,                        \
    .rk_cell.mux_shift = ms,                            \
    .rk_cell.mux_width = mw,                            \
    .rk_cell.mux_flags = mf,                            \
    .rk_cell.div_offset = do,                           \
    .rk_cell.div_shift = ds,                            \
    .rk_cell.div_width = dw,                            \
    .rk_cell.div_flags = df,                            \
    .rk_cell.gate_offset = go,                          \
    .rk_cell.gate_shift = gs,                           \
    .rk_cell.gate_flags = gf,                           \
    .rk_cell.init = rockchip_half_divider_clk_cell_init,\
}

#define COMPOSITE_NOGATE_HALFDIV(_id, cname, pnames, f, mo, ms, mw, mf, ds, dw, df) \
(void *)&(struct rockchip_half_divider_clk_cell)        \
{                                                       \
    .rk_cell.cell.name = cname,                         \
    .rk_cell.cell.parent_names = pnames,                \
    .rk_cell.cell.parents_nr = RT_ARRAY_SIZE(pnames),   \
    .rk_cell.cell.flags = f,                            \
    .rk_cell.id = _id,                                  \
    .rk_cell.muxdiv_offset = mo,                        \
    .rk_cell.mux_shift = ms,                            \
    .rk_cell.mux_width = mw,                            \
    .rk_cell.mux_flags = mf,                            \
    .rk_cell.div_shift = ds,                            \
    .rk_cell.div_width = dw,                            \
    .rk_cell.div_flags = df,                            \
    .rk_cell.gate_offset = -1,                          \
    .rk_cell.init = rockchip_half_divider_clk_cell_init,\
}

#define COMPOSITE_NOMUX_HALFDIV(_id, cname, pname, f, mo, ds, dw, df, go, gs, gf) \
(void *)&(struct rockchip_half_divider_clk_cell)        \
{                                                       \
    .rk_cell.cell.name = cname,                         \
    .rk_cell.cell.parent_name = pname,                  \
    .rk_cell.cell.parents_nr = 1,                       \
    .rk_cell.cell.flags = f,                            \
    .rk_cell.id = _id,                                  \
    .rk_cell.muxdiv_offset = mo,                        \
    .rk_cell.div_shift = ds,                            \
    .rk_cell.div_width = dw,                            \
    .rk_cell.div_flags = df,                            \
    .rk_cell.gate_offset = go,                          \
    .rk_cell.gate_shift = gs,                           \
    .rk_cell.gate_flags = gf,                           \
    .rk_cell.init = rockchip_half_divider_clk_cell_init,\
}

#define DIV_HALF(_id, cname, pname, f, o, s, w, df)     \
{                                                       \
    .rk_cell.cell.name = cname,                         \
    .rk_cell.cell.parent_name = pname,                  \
    .rk_cell.cell.parents_nr = 1,                       \
    .rk_cell.cell.flags = f,                            \
    .rk_cell.id = _id,                                  \
    .rk_cell.muxdiv_offset = o,                         \
    .rk_cell.div_shift = s,                             \
    .rk_cell.div_width = w,                             \
    .rk_cell.div_flags = df,                            \
    .rk_cell.gate_offset = -1,                          \
    .rk_cell.init = rockchip_half_divider_clk_cell_init,\
}

rt_inline struct rockchip_half_divider_clk_cell *cell_to_rockchip_half_divider_clk_cell(struct rt_clk_cell *cell)
{
    struct rockchip_clk_cell *rk_cell = cell_to_rockchip_clk_cell(cell);

    return rt_container_of(rk_cell, struct rockchip_half_divider_clk_cell, rk_cell);
}

void rockchip_half_divider_clk_cell_init(struct rockchip_clk_cell *rk_cell);

#endif /* __CLK_RK_HALF_DIVIDER_H__ */