Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: at91: clk-utmi: add support for parent_hw

Add support for parent_hw in utmi clock drivers.
With this parent-child relation is described with pointers rather
than strings making registration a bit faster.

All the SoC based drivers that rely on clk-utmi were adapted
to the new API change. The switch itself for SoCs will be done
in subsequent patches.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20230615093227.576102-8-claudiu.beznea@microchip.com

+28 -17
+1 -1
drivers/clk/at91/at91sam9g45.c
··· 145 145 146 146 at91sam9g45_pmc->chws[PMC_PLLACK] = hw; 147 147 148 - hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck"); 148 + hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL); 149 149 if (IS_ERR(hw)) 150 150 goto err_free; 151 151
+1 -1
drivers/clk/at91/at91sam9rl.c
··· 109 109 110 110 at91sam9rl_pmc->chws[PMC_PLLACK] = hw; 111 111 112 - hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck"); 112 + hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL); 113 113 if (IS_ERR(hw)) 114 114 goto err_free; 115 115
+1 -1
drivers/clk/at91/at91sam9x5.c
··· 193 193 194 194 at91sam9x5_pmc->chws[PMC_PLLACK] = hw; 195 195 196 - hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck"); 196 + hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL); 197 197 if (IS_ERR(hw)) 198 198 goto err_free; 199 199
+17 -7
drivers/clk/at91/clk-utmi.c
··· 144 144 at91_clk_register_utmi_internal(struct regmap *regmap_pmc, 145 145 struct regmap *regmap_sfr, 146 146 const char *name, const char *parent_name, 147 + struct clk_hw *parent_hw, 147 148 const struct clk_ops *ops, unsigned long flags) 148 149 { 149 150 struct clk_utmi *utmi; 150 151 struct clk_hw *hw; 151 - struct clk_init_data init; 152 + struct clk_init_data init = {}; 152 153 int ret; 154 + 155 + if (!(parent_name || parent_hw)) 156 + return ERR_PTR(-EINVAL); 153 157 154 158 utmi = kzalloc(sizeof(*utmi), GFP_KERNEL); 155 159 if (!utmi) ··· 161 157 162 158 init.name = name; 163 159 init.ops = ops; 164 - init.parent_names = parent_name ? &parent_name : NULL; 165 - init.num_parents = parent_name ? 1 : 0; 160 + if (parent_hw) { 161 + init.parent_hws = parent_hw ? (const struct clk_hw **)&parent_hw : NULL; 162 + init.num_parents = parent_hw ? 1 : 0; 163 + } else { 164 + init.parent_names = parent_name ? &parent_name : NULL; 165 + init.num_parents = parent_name ? 1 : 0; 166 + } 166 167 init.flags = flags; 167 168 168 169 utmi->hw.init = &init; ··· 186 177 187 178 struct clk_hw * __init 188 179 at91_clk_register_utmi(struct regmap *regmap_pmc, struct regmap *regmap_sfr, 189 - const char *name, const char *parent_name) 180 + const char *name, const char *parent_name, 181 + struct clk_hw *parent_hw) 190 182 { 191 183 return at91_clk_register_utmi_internal(regmap_pmc, regmap_sfr, name, 192 - parent_name, &utmi_ops, CLK_SET_RATE_GATE); 184 + parent_name, parent_hw, &utmi_ops, CLK_SET_RATE_GATE); 193 185 } 194 186 195 187 static int clk_utmi_sama7g5_prepare(struct clk_hw *hw) ··· 289 279 290 280 struct clk_hw * __init 291 281 at91_clk_sama7g5_register_utmi(struct regmap *regmap_pmc, const char *name, 292 - const char *parent_name) 282 + const char *parent_name, struct clk_hw *parent_hw) 293 283 { 294 284 return at91_clk_register_utmi_internal(regmap_pmc, NULL, name, 295 - parent_name, &sama7g5_utmi_ops, 0); 285 + parent_name, parent_hw, &sama7g5_utmi_ops, 0); 296 286 }
+1 -1
drivers/clk/at91/dt-compat.c
··· 1055 1055 regmap_sfr = NULL; 1056 1056 } 1057 1057 1058 - hw = at91_clk_register_utmi(regmap_pmc, regmap_sfr, name, parent_name); 1058 + hw = at91_clk_register_utmi(regmap_pmc, regmap_sfr, name, parent_name, NULL); 1059 1059 if (IS_ERR(hw)) 1060 1060 return; 1061 1061
+3 -2
drivers/clk/at91/pmc.h
··· 269 269 270 270 struct clk_hw * __init 271 271 at91_clk_register_utmi(struct regmap *regmap_pmc, struct regmap *regmap_sfr, 272 - const char *name, const char *parent_name); 272 + const char *name, const char *parent_name, 273 + struct clk_hw *parent_hw); 273 274 274 275 struct clk_hw * __init 275 276 at91_clk_sama7g5_register_utmi(struct regmap *regmap, const char *name, 276 - const char *parent_name); 277 + const char *parent_name, struct clk_hw *parent_hw); 277 278 278 279 #endif /* __PMC_H_ */
+1 -1
drivers/clk/at91/sama5d2.c
··· 249 249 if (IS_ERR(regmap_sfr)) 250 250 regmap_sfr = NULL; 251 251 252 - hw = at91_clk_register_utmi(regmap, regmap_sfr, "utmick", "mainck"); 252 + hw = at91_clk_register_utmi(regmap, regmap_sfr, "utmick", "mainck", NULL); 253 253 if (IS_ERR(hw)) 254 254 goto err_free; 255 255
+1 -1
drivers/clk/at91/sama5d3.c
··· 172 172 173 173 sama5d3_pmc->chws[PMC_PLLACK] = hw; 174 174 175 - hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck"); 175 + hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL); 176 176 if (IS_ERR(hw)) 177 177 goto err_free; 178 178
+1 -1
drivers/clk/at91/sama5d4.c
··· 187 187 188 188 sama5d4_pmc->chws[PMC_PLLACK] = hw; 189 189 190 - hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck"); 190 + hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL); 191 191 if (IS_ERR(hw)) 192 192 goto err_free; 193 193
+1 -1
drivers/clk/at91/sama7g5.c
··· 1035 1035 sama7g5_pmc->chws[sama7g5_mckx[i].eid] = hw; 1036 1036 } 1037 1037 1038 - hw = at91_clk_sama7g5_register_utmi(regmap, "utmick", "main_xtal"); 1038 + hw = at91_clk_sama7g5_register_utmi(regmap, "utmick", "main_xtal", NULL); 1039 1039 if (IS_ERR(hw)) 1040 1040 goto err_free; 1041 1041