15
15
16
16
/* address offset of control registers */
17
17
#define REG_MSSPLL_REF_CR 0x08u
18
- #define REG_MSSPLL_POSTDIV_CR 0x10u
18
+ #define REG_MSSPLL_POSTDIV01_CR 0x10u
19
+ #define REG_MSSPLL_POSTDIV23_CR 0x14u
19
20
#define REG_MSSPLL_SSCG_2_CR 0x2Cu
20
21
#define REG_CLOCK_CONFIG_CR 0x08u
21
22
#define REG_RTC_CLOCK_CR 0x0Cu
26
27
#define MSSPLL_FBDIV_WIDTH 0x0Cu
27
28
#define MSSPLL_REFDIV_SHIFT 0x08u
28
29
#define MSSPLL_REFDIV_WIDTH 0x06u
29
- #define MSSPLL_POSTDIV_SHIFT 0x08u
30
+ #define MSSPLL_POSTDIV02_SHIFT 0x08u
30
31
#define MSSPLL_POSTDIV_WIDTH 0x07u
31
32
#define MSSPLL_FIXED_DIV 4u
32
33
@@ -62,6 +63,9 @@ struct mpfs_msspll_out_hw_clock {
62
63
struct clk_hw hw ;
63
64
struct clk_init_data init ;
64
65
unsigned int id ;
66
+ u32 reg_offset ;
67
+ u32 shift ;
68
+ u32 width ;
65
69
u32 flags ;
66
70
};
67
71
@@ -175,11 +179,11 @@ static int mpfs_clk_register_mssplls(struct device *dev, struct mpfs_msspll_hw_c
175
179
static unsigned long mpfs_clk_msspll_out_recalc_rate (struct clk_hw * hw , unsigned long prate )
176
180
{
177
181
struct mpfs_msspll_out_hw_clock * msspll_out_hw = to_mpfs_msspll_out_clk (hw );
178
- void __iomem * postdiv_addr = msspll_out_hw -> base + REG_MSSPLL_POSTDIV_CR ;
182
+ void __iomem * postdiv_addr = msspll_out_hw -> base + msspll_out_hw -> reg_offset ;
179
183
u32 postdiv ;
180
184
181
- postdiv = readl_relaxed (postdiv_addr ) >> MSSPLL_POSTDIV_SHIFT ;
182
- postdiv &= clk_div_mask (MSSPLL_POSTDIV_WIDTH );
185
+ postdiv = readl_relaxed (postdiv_addr ) >> msspll_out_hw -> shift ;
186
+ postdiv &= clk_div_mask (msspll_out_hw -> width );
183
187
184
188
return prate / postdiv ;
185
189
}
@@ -189,19 +193,19 @@ static long mpfs_clk_msspll_out_round_rate(struct clk_hw *hw, unsigned long rate
189
193
{
190
194
struct mpfs_msspll_out_hw_clock * msspll_out_hw = to_mpfs_msspll_out_clk (hw );
191
195
192
- return divider_round_rate (hw , rate , prate , NULL , MSSPLL_POSTDIV_WIDTH ,
196
+ return divider_round_rate (hw , rate , prate , NULL , msspll_out_hw -> width ,
193
197
msspll_out_hw -> flags );
194
198
}
195
199
196
200
static int mpfs_clk_msspll_out_set_rate (struct clk_hw * hw , unsigned long rate , unsigned long prate )
197
201
{
198
202
struct mpfs_msspll_out_hw_clock * msspll_out_hw = to_mpfs_msspll_out_clk (hw );
199
- void __iomem * postdiv_addr = msspll_out_hw -> base + REG_MSSPLL_POSTDIV_CR ;
203
+ void __iomem * postdiv_addr = msspll_out_hw -> base + msspll_out_hw -> reg_offset ;
200
204
u32 postdiv ;
201
205
int divider_setting ;
202
206
unsigned long flags ;
203
207
204
- divider_setting = divider_get_val (rate , prate , NULL , MSSPLL_POSTDIV_WIDTH ,
208
+ divider_setting = divider_get_val (rate , prate , NULL , msspll_out_hw -> width ,
205
209
msspll_out_hw -> flags );
206
210
207
211
if (divider_setting < 0 )
@@ -210,7 +214,7 @@ static int mpfs_clk_msspll_out_set_rate(struct clk_hw *hw, unsigned long rate, u
210
214
spin_lock_irqsave (& mpfs_clk_lock , flags );
211
215
212
216
postdiv = readl_relaxed (postdiv_addr );
213
- postdiv &= ~(clk_div_mask (MSSPLL_POSTDIV_WIDTH ) << MSSPLL_POSTDIV_SHIFT );
217
+ postdiv &= ~(clk_div_mask (msspll_out_hw -> width ) << msspll_out_hw -> shift );
214
218
writel_relaxed (postdiv , postdiv_addr );
215
219
216
220
spin_unlock_irqrestore (& mpfs_clk_lock , flags );
@@ -224,14 +228,18 @@ static const struct clk_ops mpfs_clk_msspll_out_ops = {
224
228
.set_rate = mpfs_clk_msspll_out_set_rate ,
225
229
};
226
230
227
- #define CLK_PLL_OUT (_id , _name , _parent , _flags ) { \
231
+ #define CLK_PLL_OUT (_id , _name , _parent , _flags , _shift , _width , _offset ) { \
228
232
.id = _id, \
233
+ .shift = _shift, \
234
+ .width = _width, \
235
+ .reg_offset = _offset, \
229
236
.flags = _flags, \
230
237
.hw.init = CLK_HW_INIT(_name, _parent, &mpfs_clk_msspll_out_ops, 0), \
231
238
}
232
239
233
240
static struct mpfs_msspll_out_hw_clock mpfs_msspll_out_clks [] = {
234
- CLK_PLL_OUT (CLK_MSSPLL0 , "clk_msspll" , "clk_msspll_internal" , 0 ),
241
+ CLK_PLL_OUT (CLK_MSSPLL0 , "clk_msspll" , "clk_msspll_internal" , 0 ,
242
+ MSSPLL_POSTDIV02_SHIFT , MSSPLL_POSTDIV_WIDTH , REG_MSSPLL_POSTDIV01_CR ),
235
243
};
236
244
237
245
static int mpfs_clk_register_msspll_outs (struct device * dev ,
0 commit comments