63
63
64
64
#define MAX_VCLK_FREQ (148500000)
65
65
66
- struct sd_hw_data {
66
+ /**
67
+ * struct clk_hw_data - clock hardware data
68
+ * @hw: clock hw
69
+ * @conf: clock configuration (register offset, shift, width)
70
+ * @priv: CPG private data structure
71
+ */
72
+ struct clk_hw_data {
67
73
struct clk_hw hw ;
68
74
u32 conf ;
69
75
struct rzg2l_cpg_priv * priv ;
70
76
};
71
77
72
- #define to_sd_hw_data (_hw ) container_of(_hw, struct sd_hw_data, hw)
78
+ #define to_clk_hw_data (_hw ) container_of(_hw, struct clk_hw_data, hw)
79
+
80
+ /**
81
+ * struct sd_hw_data - SD clock hardware data
82
+ * @hw_data: clock hw data
83
+ */
84
+ struct sd_hw_data {
85
+ struct clk_hw_data hw_data ;
86
+ };
87
+
88
+ #define to_sd_hw_data (_hw ) container_of(_hw, struct sd_hw_data, hw_data)
73
89
74
90
struct rzg2l_pll5_param {
75
91
u32 pl5_fracin ;
@@ -188,10 +204,10 @@ rzg2l_cpg_mux_clk_register(const struct cpg_core_clk *core,
188
204
189
205
static int rzg2l_cpg_sd_clk_mux_set_parent (struct clk_hw * hw , u8 index )
190
206
{
191
- struct sd_hw_data * hwdata = to_sd_hw_data (hw );
192
- struct rzg2l_cpg_priv * priv = hwdata -> priv ;
193
- u32 off = GET_REG_OFFSET (hwdata -> conf );
194
- u32 shift = GET_SHIFT (hwdata -> conf );
207
+ struct clk_hw_data * clk_hw_data = to_clk_hw_data (hw );
208
+ struct rzg2l_cpg_priv * priv = clk_hw_data -> priv ;
209
+ u32 off = GET_REG_OFFSET (clk_hw_data -> conf );
210
+ u32 shift = GET_SHIFT (clk_hw_data -> conf );
195
211
const u32 clk_src_266 = 2 ;
196
212
u32 msk , val , bitmask ;
197
213
unsigned long flags ;
@@ -208,7 +224,7 @@ static int rzg2l_cpg_sd_clk_mux_set_parent(struct clk_hw *hw, u8 index)
208
224
* The clock mux has 3 input clocks(533 MHz, 400 MHz, and 266 MHz), and
209
225
* the index to value mapping is done by adding 1 to the index.
210
226
*/
211
- bitmask = (GENMASK (GET_WIDTH (hwdata -> conf ) - 1 , 0 ) << shift ) << 16 ;
227
+ bitmask = (GENMASK (GET_WIDTH (clk_hw_data -> conf ) - 1 , 0 ) << shift ) << 16 ;
212
228
msk = off ? CPG_CLKSTATUS_SELSDHI1_STS : CPG_CLKSTATUS_SELSDHI0_STS ;
213
229
spin_lock_irqsave (& priv -> rmw_lock , flags );
214
230
if (index != clk_src_266 ) {
@@ -237,12 +253,12 @@ static int rzg2l_cpg_sd_clk_mux_set_parent(struct clk_hw *hw, u8 index)
237
253
238
254
static u8 rzg2l_cpg_sd_clk_mux_get_parent (struct clk_hw * hw )
239
255
{
240
- struct sd_hw_data * hwdata = to_sd_hw_data (hw );
241
- struct rzg2l_cpg_priv * priv = hwdata -> priv ;
242
- u32 val = readl (priv -> base + GET_REG_OFFSET (hwdata -> conf ));
256
+ struct clk_hw_data * clk_hw_data = to_clk_hw_data (hw );
257
+ struct rzg2l_cpg_priv * priv = clk_hw_data -> priv ;
258
+ u32 val = readl (priv -> base + GET_REG_OFFSET (clk_hw_data -> conf ));
243
259
244
- val >>= GET_SHIFT (hwdata -> conf );
245
- val &= GENMASK (GET_WIDTH (hwdata -> conf ) - 1 , 0 );
260
+ val >>= GET_SHIFT (clk_hw_data -> conf );
261
+ val &= GENMASK (GET_WIDTH (clk_hw_data -> conf ) - 1 , 0 );
246
262
247
263
return val ? val - 1 : 0 ;
248
264
}
@@ -258,25 +274,25 @@ rzg2l_cpg_sd_mux_clk_register(const struct cpg_core_clk *core,
258
274
void __iomem * base ,
259
275
struct rzg2l_cpg_priv * priv )
260
276
{
261
- struct sd_hw_data * clk_hw_data ;
277
+ struct sd_hw_data * sd_hw_data ;
262
278
struct clk_init_data init ;
263
279
struct clk_hw * clk_hw ;
264
280
int ret ;
265
281
266
- clk_hw_data = devm_kzalloc (priv -> dev , sizeof (* clk_hw_data ), GFP_KERNEL );
267
- if (!clk_hw_data )
282
+ sd_hw_data = devm_kzalloc (priv -> dev , sizeof (* sd_hw_data ), GFP_KERNEL );
283
+ if (!sd_hw_data )
268
284
return ERR_PTR (- ENOMEM );
269
285
270
- clk_hw_data -> priv = priv ;
271
- clk_hw_data -> conf = core -> conf ;
286
+ sd_hw_data -> hw_data . priv = priv ;
287
+ sd_hw_data -> hw_data . conf = core -> conf ;
272
288
273
289
init .name = core -> name ;
274
290
init .ops = & rzg2l_cpg_sd_clk_mux_ops ;
275
291
init .flags = 0 ;
276
292
init .num_parents = core -> num_parents ;
277
293
init .parent_names = core -> parent_names ;
278
294
279
- clk_hw = & clk_hw_data -> hw ;
295
+ clk_hw = & sd_hw_data -> hw_data . hw ;
280
296
clk_hw -> init = & init ;
281
297
282
298
ret = devm_clk_hw_register (priv -> dev , clk_hw );
0 commit comments