6363
6464#define MAX_VCLK_FREQ (148500000)
6565
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 {
6773 struct clk_hw hw ;
6874 u32 conf ;
6975 struct rzg2l_cpg_priv * priv ;
7076};
7177
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)
7389
7490struct rzg2l_pll5_param {
7591 u32 pl5_fracin ;
@@ -188,10 +204,10 @@ rzg2l_cpg_mux_clk_register(const struct cpg_core_clk *core,
188204
189205static int rzg2l_cpg_sd_clk_mux_set_parent (struct clk_hw * hw , u8 index )
190206{
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 );
195211 const u32 clk_src_266 = 2 ;
196212 u32 msk , val , bitmask ;
197213 unsigned long flags ;
@@ -208,7 +224,7 @@ static int rzg2l_cpg_sd_clk_mux_set_parent(struct clk_hw *hw, u8 index)
208224 * The clock mux has 3 input clocks(533 MHz, 400 MHz, and 266 MHz), and
209225 * the index to value mapping is done by adding 1 to the index.
210226 */
211- bitmask = (GENMASK (GET_WIDTH (hwdata -> conf ) - 1 , 0 ) << shift ) << 16 ;
227+ bitmask = (GENMASK (GET_WIDTH (clk_hw_data -> conf ) - 1 , 0 ) << shift ) << 16 ;
212228 msk = off ? CPG_CLKSTATUS_SELSDHI1_STS : CPG_CLKSTATUS_SELSDHI0_STS ;
213229 spin_lock_irqsave (& priv -> rmw_lock , flags );
214230 if (index != clk_src_266 ) {
@@ -237,12 +253,12 @@ static int rzg2l_cpg_sd_clk_mux_set_parent(struct clk_hw *hw, u8 index)
237253
238254static u8 rzg2l_cpg_sd_clk_mux_get_parent (struct clk_hw * hw )
239255{
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 ));
243259
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 );
246262
247263 return val ? val - 1 : 0 ;
248264}
@@ -258,25 +274,25 @@ rzg2l_cpg_sd_mux_clk_register(const struct cpg_core_clk *core,
258274 void __iomem * base ,
259275 struct rzg2l_cpg_priv * priv )
260276{
261- struct sd_hw_data * clk_hw_data ;
277+ struct sd_hw_data * sd_hw_data ;
262278 struct clk_init_data init ;
263279 struct clk_hw * clk_hw ;
264280 int ret ;
265281
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 )
268284 return ERR_PTR (- ENOMEM );
269285
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 ;
272288
273289 init .name = core -> name ;
274290 init .ops = & rzg2l_cpg_sd_clk_mux_ops ;
275291 init .flags = 0 ;
276292 init .num_parents = core -> num_parents ;
277293 init .parent_names = core -> parent_names ;
278294
279- clk_hw = & clk_hw_data -> hw ;
295+ clk_hw = & sd_hw_data -> hw_data . hw ;
280296 clk_hw -> init = & init ;
281297
282298 ret = devm_clk_hw_register (priv -> dev , clk_hw );
0 commit comments