summaryrefslogtreecommitdiff
path: root/bsp/spacemit/dm/clk/ccu_ddr.h
blob: f11dce6de44f4f179bb53814b79272f2b2163767 (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
/*
 * Copyright (c) 2006-2024, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-5-1       GuEe-GUI     first version
 */

#ifndef __CCU_DDR_H__
#define __CCU_DDR_H__

#include "ccu.h"
#include "ccu_mix.h"

struct ccu_ddr
{
    struct ccu_common common;
    struct ccu_mux_config *mux;
};

#define MAX_FREQ_LV 7  /* level 0~7 */

#define SPACEMIT_CCU_DDR_FC(_struct, _name, _parents, _base_type, \
                            _reg, _fc, _shift, _width, _flags) \
struct ccu_ddr _struct =                            \
{                                                   \
    .mux = CCU_MUX_INIT(_shift, _width, RT_NULL),   \
    .common =                                       \
    {                                               \
        .reg_sel = _reg,                            \
        .fc = _fc,                                  \
        .base_type = _base_type,                    \
        .cell.name = _name,                         \
        .cell.parent_names = _parents,              \
        .cell.parents_nr = RT_ARRAY_SIZE(_parents), \
        .cell.ops = &ccu_ddr_ops,                   \
        .cell.flags = _flags,                       \
    },                                              \
}

extern const struct rt_clk_ops ccu_ddr_ops;

rt_inline struct ccu_ddr *cell_to_ccu_ddr(struct rt_clk_cell *cell)
{
    struct ccu_common *common = cell_to_ccu_common(cell);

    return rt_container_of(common, struct ccu_ddr, common);
}

#endif /* __CCU_DDR_H__ */