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

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

Add support for parent_hw in peripheral 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-peripheral 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-5-claudiu.beznea@microchip.com

+34 -23
+1 -1
drivers/clk/at91/at91rm9200.c
··· 193 193 for (i = 0; i < ARRAY_SIZE(at91rm9200_periphck); i++) { 194 194 hw = at91_clk_register_peripheral(regmap, 195 195 at91rm9200_periphck[i].n, 196 - "masterck_div", 196 + "masterck_div", NULL, 197 197 at91rm9200_periphck[i].id); 198 198 if (IS_ERR(hw)) 199 199 goto err_free;
+1 -1
drivers/clk/at91/at91sam9260.c
··· 470 470 for (i = 0; i < data->num_pck; i++) { 471 471 hw = at91_clk_register_peripheral(regmap, 472 472 data->pck[i].n, 473 - "masterck_div", 473 + "masterck_div", NULL, 474 474 data->pck[i].id); 475 475 if (IS_ERR(hw)) 476 476 goto err_free;
+1 -1
drivers/clk/at91/at91sam9g45.c
··· 214 214 for (i = 0; i < ARRAY_SIZE(at91sam9g45_periphck); i++) { 215 215 hw = at91_clk_register_peripheral(regmap, 216 216 at91sam9g45_periphck[i].n, 217 - "masterck_div", 217 + "masterck_div", NULL, 218 218 at91sam9g45_periphck[i].id); 219 219 if (IS_ERR(hw)) 220 220 goto err_free;
+1 -1
drivers/clk/at91/at91sam9n12.c
··· 240 240 hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock, 241 241 &at91sam9n12_pcr_layout, 242 242 at91sam9n12_periphck[i].n, 243 - "masterck_div", 243 + "masterck_div", NULL, 244 244 at91sam9n12_periphck[i].id, 245 245 &range, INT_MIN, 0); 246 246 if (IS_ERR(hw))
+1 -1
drivers/clk/at91/at91sam9rl.c
··· 170 170 for (i = 0; i < ARRAY_SIZE(at91sam9rl_periphck); i++) { 171 171 hw = at91_clk_register_peripheral(regmap, 172 172 at91sam9rl_periphck[i].n, 173 - "masterck_div", 173 + "masterck_div", NULL, 174 174 at91sam9rl_periphck[i].id); 175 175 if (IS_ERR(hw)) 176 176 goto err_free;
+2 -2
drivers/clk/at91/at91sam9x5.c
··· 274 274 hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock, 275 275 &at91sam9x5_pcr_layout, 276 276 at91sam9x5_periphck[i].n, 277 - "masterck_div", 277 + "masterck_div", NULL, 278 278 at91sam9x5_periphck[i].id, 279 279 &range, INT_MIN, 0); 280 280 if (IS_ERR(hw)) ··· 287 287 hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock, 288 288 &at91sam9x5_pcr_layout, 289 289 extra_pcks[i].n, 290 - "masterck_div", 290 + "masterck_div", NULL, 291 291 extra_pcks[i].id, 292 292 &range, INT_MIN, 0); 293 293 if (IS_ERR(hw))
+15 -7
drivers/clk/at91/clk-peripheral.c
··· 97 97 98 98 struct clk_hw * __init 99 99 at91_clk_register_peripheral(struct regmap *regmap, const char *name, 100 - const char *parent_name, u32 id) 100 + const char *parent_name, struct clk_hw *parent_hw, 101 + u32 id) 101 102 { 102 103 struct clk_peripheral *periph; 103 - struct clk_init_data init; 104 + struct clk_init_data init = {}; 104 105 struct clk_hw *hw; 105 106 int ret; 106 107 107 - if (!name || !parent_name || id > PERIPHERAL_ID_MAX) 108 + if (!name || !(parent_name || parent_hw) || id > PERIPHERAL_ID_MAX) 108 109 return ERR_PTR(-EINVAL); 109 110 110 111 periph = kzalloc(sizeof(*periph), GFP_KERNEL); ··· 114 113 115 114 init.name = name; 116 115 init.ops = &peripheral_ops; 117 - init.parent_names = &parent_name; 116 + if (parent_hw) 117 + init.parent_hws = (const struct clk_hw **)&parent_hw; 118 + else 119 + init.parent_names = &parent_name; 118 120 init.num_parents = 1; 119 121 init.flags = 0; 120 122 ··· 448 444 at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock, 449 445 const struct clk_pcr_layout *layout, 450 446 const char *name, const char *parent_name, 447 + struct clk_hw *parent_hw, 451 448 u32 id, const struct clk_range *range, 452 449 int chg_pid, unsigned long flags) 453 450 { 454 451 struct clk_sam9x5_peripheral *periph; 455 - struct clk_init_data init; 452 + struct clk_init_data init = {}; 456 453 struct clk_hw *hw; 457 454 int ret; 458 455 459 - if (!name || !parent_name) 456 + if (!name || !(parent_name || parent_hw)) 460 457 return ERR_PTR(-EINVAL); 461 458 462 459 periph = kzalloc(sizeof(*periph), GFP_KERNEL); ··· 465 460 return ERR_PTR(-ENOMEM); 466 461 467 462 init.name = name; 468 - init.parent_names = &parent_name; 463 + if (parent_hw) 464 + init.parent_hws = (const struct clk_hw **)&parent_hw; 465 + else 466 + init.parent_names = &parent_name; 469 467 init.num_parents = 1; 470 468 init.flags = flags; 471 469 if (chg_pid < 0) {
+2 -1
drivers/clk/at91/dt-compat.c
··· 490 490 491 491 if (type == PERIPHERAL_AT91RM9200) { 492 492 hw = at91_clk_register_peripheral(regmap, name, 493 - parent_name, id); 493 + parent_name, NULL, id); 494 494 } else { 495 495 struct clk_range range = CLK_RANGE(0, 0); 496 496 unsigned long flags = 0; ··· 512 512 &dt_pcr_layout, 513 513 name, 514 514 parent_name, 515 + NULL, 515 516 id, &range, 516 517 INT_MIN, 517 518 flags);
+3 -1
drivers/clk/at91/pmc.h
··· 199 199 200 200 struct clk_hw * __init 201 201 at91_clk_register_peripheral(struct regmap *regmap, const char *name, 202 - const char *parent_name, u32 id); 202 + const char *parent_name, struct clk_hw *parent_hw, 203 + u32 id); 203 204 struct clk_hw * __init 204 205 at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock, 205 206 const struct clk_pcr_layout *layout, 206 207 const char *name, const char *parent_name, 208 + struct clk_hw *parent_hw, 207 209 u32 id, const struct clk_range *range, 208 210 int chg_pid, unsigned long flags); 209 211
+1 -1
drivers/clk/at91/sam9x60.c
··· 337 337 hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock, 338 338 &sam9x60_pcr_layout, 339 339 sam9x60_periphck[i].n, 340 - "masterck_div", 340 + "masterck_div", NULL, 341 341 sam9x60_periphck[i].id, 342 342 &range, INT_MIN, 343 343 sam9x60_periphck[i].flags);
+2 -2
drivers/clk/at91/sama5d2.c
··· 324 324 hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock, 325 325 &sama5d2_pcr_layout, 326 326 sama5d2_periphck[i].n, 327 - "masterck_div", 327 + "masterck_div", NULL, 328 328 sama5d2_periphck[i].id, 329 329 &range, INT_MIN, 330 330 sama5d2_periphck[i].flags); ··· 338 338 hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock, 339 339 &sama5d2_pcr_layout, 340 340 sama5d2_periph32ck[i].n, 341 - "h32mxck", 341 + "h32mxck", NULL, 342 342 sama5d2_periph32ck[i].id, 343 343 &sama5d2_periph32ck[i].r, 344 344 INT_MIN, 0);
+1 -1
drivers/clk/at91/sama5d3.c
··· 244 244 hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock, 245 245 &sama5d3_pcr_layout, 246 246 sama5d3_periphck[i].n, 247 - "masterck_div", 247 + "masterck_div", NULL, 248 248 sama5d3_periphck[i].id, 249 249 &sama5d3_periphck[i].r, 250 250 INT_MIN,
+2 -2
drivers/clk/at91/sama5d4.c
··· 267 267 hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock, 268 268 &sama5d4_pcr_layout, 269 269 sama5d4_periphck[i].n, 270 - "masterck_div", 270 + "masterck_div", NULL, 271 271 sama5d4_periphck[i].id, 272 272 &range, INT_MIN, 273 273 sama5d4_periphck[i].flags); ··· 281 281 hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock, 282 282 &sama5d4_pcr_layout, 283 283 sama5d4_periph32ck[i].n, 284 - "h32mxck", 284 + "h32mxck", NULL, 285 285 sama5d4_periph32ck[i].id, 286 286 &range, INT_MIN, 0); 287 287 if (IS_ERR(hw))
+1 -1
drivers/clk/at91/sama7g5.c
··· 1079 1079 hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock, 1080 1080 &sama7g5_pcr_layout, 1081 1081 sama7g5_periphck[i].n, 1082 - sama7g5_periphck[i].p, 1082 + sama7g5_periphck[i].p, NULL, 1083 1083 sama7g5_periphck[i].id, 1084 1084 &sama7g5_periphck[i].r, 1085 1085 sama7g5_periphck[i].chgp ? 0 :