1 /* SPDX-License-Identifier: GPL-2.0+ */
2 #define LITEX_UNUSED(var) (void)(var)
5 #define NS_IN_SEC 1000000000
9 /* MMCM specific numbers */
11 #define DELAY_TIME_MAX 63
12 #define PHASE_MUX_MAX 7
13 #define HIGH_LOW_TIME_SAFE_MAX 62
14 #define HIGH_LOW_TIME_REG_MAX 63
15 #define MAX_DIVIDER 126
16 #define MAX_DIVIDER_F 126000
18 #define MIN_DIVIDER_F 2000
19 #define PHASE_MUX_RES_FACTOR 8
20 /* Fractional divider resolution multiplied by 1000 to keep precision */
21 #define FRACT_DIV_RES 125
22 /* Minimal value when div is odd and fract is on */
23 #define ODD_AND_FRAC 9
24 /* Odd div and no frac or even div and enabled fract max value */
25 #define EVEN_AND_FRAC 8
27 /* DRP registers index */
28 /* Additional register */
40 /* Register space offsets */
41 #define DRP_OF_RESET 0x0
42 #define DRP_OF_LOCKED 0x4
43 #define DRP_OF_READ 0x8
44 #define DRP_OF_WRITE 0xc
45 #define DRP_OF_DRDY 0x10
46 #define DRP_OF_ADR 0x14
47 #define DRP_OF_DAT_W 0x18
48 #define DRP_OF_DAT_R 0x20
51 #define DRP_SIZE_RESET 0x1
52 #define DRP_SIZE_READ 0x1
53 #define DRP_SIZE_WRITE 0x1
54 #define DRP_SIZE_DRDY 0x1
55 #define DRP_SIZE_ADR 0x1
56 #define DRP_SIZE_DAT_W 0x2
57 #define DRP_SIZE_DAT_R 0x2
58 #define DRP_SIZE_LOCKED 0x1
61 #define GLOB_DIV_VAL 0x41
62 #define GLOB_MUL_VAL 0x82
63 #define FULL_REG_16 0xFFFF
64 #define KEEP_REG_16 FULL_REG_16
65 #define KEEP_IN_MUL 0xF000
66 #define KEEP_IN_DIV 0xE000
68 #define REG1_MASK 0x1000
69 #define REG2_MASK 0x8000
70 #define REG1_BITSET 0x41
71 #define REG2_BITSET 0x40
72 #define CLKOUT5_FRAC_MASK 0xC3FF
73 #define CLKOUT5_FRAC_MASK_F 0xFBFF
74 #define CLKOUT5_FRAC_MASK_P 0xC7FF
75 #define REG1_FREQ_MASK 0xF000
76 #define REG2_FREQ_MASK 0x803F
77 #define REG1_DUTY_MASK 0xF000
78 #define REG2_DUTY_MASK 0xFF7F
79 #define REG1_PHASE_MASK 0x1FFF
80 #define REG2_PHASE_MASK 0xFCC0
81 #define REG2_PHASE_F_MASK 0x80C0
82 #define FILT_MASK 0x9900
83 #define LOCK1_MASK 0x03FF
84 #define LOCK23_MASK 0x7FFF
85 /* Control bits extraction masks */
86 #define HL_TIME_MASK 0x3F
89 #define NO_CNT_MASK 0x1
90 #define FRAC_EN_MASK 0x1
91 #define PHASE_MUX_MASK 0x7
92 #define PHASE_MUX_F_MASK 0x7
93 #define F_FRAC_MASK 0xF8
94 #define TWO_LSBITS 0x3
96 /* Bit groups start position in DRP registers */
97 #define HIGH_TIME_POS 6
98 #define LOW_TIME_POS 0
99 #define PHASE_MUX_POS 13
100 #define PHASE_MUX_F_POS 11
102 #define FRAC_EN_POS 11
103 #define FRAC_WF_R_POS 10
104 #define FRAC_WF_F_POS 10
107 #define DELAY_TIME_POS 0
109 /* MMCM Register addresses */
110 #define POWER_REG 0x28
112 #define LOCK_REG1 0x18
113 #define LOCK_REG2 0x19
114 #define LOCK_REG3 0x1A
115 #define FILT_REG1 0x4E
116 #define FILT_REG2 0x4F
117 #define CLKOUT0_REG1 0x08
118 #define CLKOUT0_REG2 0x09
119 #define CLKOUT1_REG1 0x0A
120 #define CLKOUT1_REG2 0x0B
121 #define CLKOUT2_REG1 0x0C
122 #define CLKOUT2_REG2 0x0D
123 #define CLKOUT3_REG1 0x0E
124 #define CLKOUT3_REG2 0x0F
125 #define CLKOUT4_REG1 0x10
126 #define CLKOUT4_REG2 0x11
127 #define CLKOUT5_REG1 0x06
128 #define CLKOUT5_REG2 0x07
129 #define CLKOUT6_REG1 0x12
130 #define CLKOUT6_REG2 0x13
131 #define CLKFBOUT_REG1 0x14
132 #define CLKFBOUT_REG2 0x15