Linux 4.18.10
[linux/fpc-iii.git] / drivers / clk / sunxi-ng / ccu_sdm.h
blob2a9b4a2584d6b98dd95b8ec7eff84306325e8ca2
1 /*
2 * Copyright (c) 2017 Chen-Yu Tsai. All rights reserved.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef _CCU_SDM_H
15 #define _CCU_SDM_H
17 #include <linux/clk-provider.h>
19 #include "ccu_common.h"
21 struct ccu_sdm_setting {
22 unsigned long rate;
25 * XXX We don't know what the step and bottom register fields
26 * mean. Just copy the whole register value from the vendor
27 * kernel for now.
29 u32 pattern;
32 * M and N factors here should be the values used in
33 * calculation, not the raw values written to registers
35 u32 m;
36 u32 n;
39 struct ccu_sdm_internal {
40 struct ccu_sdm_setting *table;
41 u32 table_size;
42 /* early SoCs don't have the SDM enable bit in the PLL register */
43 u32 enable;
44 /* second enable bit in tuning register */
45 u32 tuning_enable;
46 u16 tuning_reg;
49 #define _SUNXI_CCU_SDM(_table, _enable, \
50 _reg, _reg_enable) \
51 { \
52 .table = _table, \
53 .table_size = ARRAY_SIZE(_table), \
54 .enable = _enable, \
55 .tuning_enable = _reg_enable, \
56 .tuning_reg = _reg, \
59 bool ccu_sdm_helper_is_enabled(struct ccu_common *common,
60 struct ccu_sdm_internal *sdm);
61 void ccu_sdm_helper_enable(struct ccu_common *common,
62 struct ccu_sdm_internal *sdm,
63 unsigned long rate);
64 void ccu_sdm_helper_disable(struct ccu_common *common,
65 struct ccu_sdm_internal *sdm);
67 bool ccu_sdm_helper_has_rate(struct ccu_common *common,
68 struct ccu_sdm_internal *sdm,
69 unsigned long rate);
71 unsigned long ccu_sdm_helper_read_rate(struct ccu_common *common,
72 struct ccu_sdm_internal *sdm,
73 u32 m, u32 n);
75 int ccu_sdm_helper_get_factors(struct ccu_common *common,
76 struct ccu_sdm_internal *sdm,
77 unsigned long rate,
78 unsigned long *m, unsigned long *n);
80 #endif