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

Configure Feed

Select the types of activity you want to include in your feed.

clk: qcom: msm8996-cpu: Convert secondary muxes to clk_regmap_mux

There is nothing special about the secondary muxes, unlike the
primary muxes which need some extra logic to handle ACD and
switching between primary PLL and secondary mux sources. Turn
them into clk_regmap_mux and rename cpu_clk_msm8996_mux into
cpu_clk_msm8996_pmux to make it specific to primary muxes.

Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20220621160621.24415-5-y.oudjana@protonmail.com

authored by

Yassine Oudjana and committed by
Bjorn Andersson
9a9f5f9a 382139bf

+30 -32
+30 -32
drivers/clk/qcom/clk-cpu-8996.c
··· 59 59 60 60 #include "clk-alpha-pll.h" 61 61 #include "clk-regmap.h" 62 + #include "clk-regmap-mux.h" 62 63 63 64 enum _pmux_input { 64 65 SMUX_INDEX = 0, ··· 210 209 }, 211 210 }; 212 211 213 - struct clk_cpu_8996_mux { 212 + struct clk_cpu_8996_pmux { 214 213 u32 reg; 215 214 u8 shift; 216 215 u8 width; ··· 223 222 static int cpu_clk_notifier_cb(struct notifier_block *nb, unsigned long event, 224 223 void *data); 225 224 226 - #define to_clk_cpu_8996_mux_nb(_nb) \ 227 - container_of(_nb, struct clk_cpu_8996_mux, nb) 225 + #define to_clk_cpu_8996_pmux_nb(_nb) \ 226 + container_of(_nb, struct clk_cpu_8996_pmux, nb) 228 227 229 - static inline struct clk_cpu_8996_mux *to_clk_cpu_8996_mux_hw(struct clk_hw *hw) 228 + static inline struct clk_cpu_8996_pmux *to_clk_cpu_8996_pmux_hw(struct clk_hw *hw) 230 229 { 231 - return container_of(to_clk_regmap(hw), struct clk_cpu_8996_mux, clkr); 230 + return container_of(to_clk_regmap(hw), struct clk_cpu_8996_pmux, clkr); 232 231 } 233 232 234 - static u8 clk_cpu_8996_mux_get_parent(struct clk_hw *hw) 233 + static u8 clk_cpu_8996_pmux_get_parent(struct clk_hw *hw) 235 234 { 236 235 struct clk_regmap *clkr = to_clk_regmap(hw); 237 - struct clk_cpu_8996_mux *cpuclk = to_clk_cpu_8996_mux_hw(hw); 236 + struct clk_cpu_8996_pmux *cpuclk = to_clk_cpu_8996_pmux_hw(hw); 238 237 u32 mask = GENMASK(cpuclk->width - 1, 0); 239 238 u32 val; 240 239 ··· 244 243 return val & mask; 245 244 } 246 245 247 - static int clk_cpu_8996_mux_set_parent(struct clk_hw *hw, u8 index) 246 + static int clk_cpu_8996_pmux_set_parent(struct clk_hw *hw, u8 index) 248 247 { 249 248 struct clk_regmap *clkr = to_clk_regmap(hw); 250 - struct clk_cpu_8996_mux *cpuclk = to_clk_cpu_8996_mux_hw(hw); 249 + struct clk_cpu_8996_pmux *cpuclk = to_clk_cpu_8996_pmux_hw(hw); 251 250 u32 mask = GENMASK(cpuclk->width + cpuclk->shift - 1, cpuclk->shift); 252 251 u32 val; 253 252 ··· 257 256 return regmap_update_bits(clkr->regmap, cpuclk->reg, mask, val); 258 257 } 259 258 260 - static int clk_cpu_8996_mux_determine_rate(struct clk_hw *hw, 259 + static int clk_cpu_8996_pmux_determine_rate(struct clk_hw *hw, 261 260 struct clk_rate_request *req) 262 261 { 263 - struct clk_cpu_8996_mux *cpuclk = to_clk_cpu_8996_mux_hw(hw); 262 + struct clk_cpu_8996_pmux *cpuclk = to_clk_cpu_8996_pmux_hw(hw); 264 263 struct clk_hw *parent = cpuclk->pll; 265 264 266 265 if (cpuclk->pll_div_2 && req->rate < DIV_2_THRESHOLD) { ··· 276 275 return 0; 277 276 } 278 277 279 - static const struct clk_ops clk_cpu_8996_mux_ops = { 280 - .set_parent = clk_cpu_8996_mux_set_parent, 281 - .get_parent = clk_cpu_8996_mux_get_parent, 282 - .determine_rate = clk_cpu_8996_mux_determine_rate, 278 + static const struct clk_ops clk_cpu_8996_pmux_ops = { 279 + .set_parent = clk_cpu_8996_pmux_set_parent, 280 + .get_parent = clk_cpu_8996_pmux_get_parent, 281 + .determine_rate = clk_cpu_8996_pmux_determine_rate, 283 282 }; 284 283 285 - static struct clk_cpu_8996_mux pwrcl_smux = { 284 + static struct clk_regmap_mux pwrcl_smux = { 286 285 .reg = PWRCL_REG_OFFSET + MUX_OFFSET, 287 286 .shift = 2, 288 287 .width = 2, ··· 293 292 "pwrcl_pll_postdiv", 294 293 }, 295 294 .num_parents = 2, 296 - .ops = &clk_cpu_8996_mux_ops, 295 + .ops = &clk_regmap_mux_closest_ops, 297 296 .flags = CLK_SET_RATE_PARENT, 298 297 }, 299 298 }; 300 299 301 - static struct clk_cpu_8996_mux perfcl_smux = { 300 + static struct clk_regmap_mux perfcl_smux = { 302 301 .reg = PERFCL_REG_OFFSET + MUX_OFFSET, 303 302 .shift = 2, 304 303 .width = 2, ··· 309 308 "perfcl_pll_postdiv", 310 309 }, 311 310 .num_parents = 2, 312 - .ops = &clk_cpu_8996_mux_ops, 311 + .ops = &clk_regmap_mux_closest_ops, 313 312 .flags = CLK_SET_RATE_PARENT, 314 313 }, 315 314 }; 316 315 317 - static struct clk_cpu_8996_mux pwrcl_pmux = { 316 + static struct clk_cpu_8996_pmux pwrcl_pmux = { 318 317 .reg = PWRCL_REG_OFFSET + MUX_OFFSET, 319 318 .shift = 0, 320 319 .width = 2, ··· 330 329 "pwrcl_alt_pll", 331 330 }, 332 331 .num_parents = 4, 333 - .ops = &clk_cpu_8996_mux_ops, 332 + .ops = &clk_cpu_8996_pmux_ops, 334 333 /* CPU clock is critical and should never be gated */ 335 334 .flags = CLK_SET_RATE_PARENT | CLK_IS_CRITICAL, 336 335 }, 337 336 }; 338 337 339 - static struct clk_cpu_8996_mux perfcl_pmux = { 338 + static struct clk_cpu_8996_pmux perfcl_pmux = { 340 339 .reg = PERFCL_REG_OFFSET + MUX_OFFSET, 341 340 .shift = 0, 342 341 .width = 2, ··· 352 351 "perfcl_alt_pll", 353 352 }, 354 353 .num_parents = 4, 355 - .ops = &clk_cpu_8996_mux_ops, 354 + .ops = &clk_cpu_8996_pmux_ops, 356 355 /* CPU clock is critical and should never be gated */ 357 356 .flags = CLK_SET_RATE_PARENT | CLK_IS_CRITICAL, 358 357 }, ··· 394 393 dev_err(dev, "Failed to register perfcl_pll_postdiv: %d", ret); 395 394 return ret; 396 395 } 397 - 398 - pwrcl_smux.pll = &pwrcl_pll_postdiv.hw; 399 - perfcl_smux.pll = &perfcl_pll_postdiv.hw; 400 396 401 397 for (i = 0; i < ARRAY_SIZE(cpu_msm8996_clks); i++) { 402 398 ret = devm_clk_register_regmap(dev, cpu_msm8996_clks[i]); ··· 472 474 static int cpu_clk_notifier_cb(struct notifier_block *nb, unsigned long event, 473 475 void *data) 474 476 { 475 - struct clk_cpu_8996_mux *cpuclk = to_clk_cpu_8996_mux_nb(nb); 477 + struct clk_cpu_8996_pmux *cpuclk = to_clk_cpu_8996_pmux_nb(nb); 476 478 struct clk_notifier_data *cnd = data; 477 479 int ret; 478 480 479 481 switch (event) { 480 482 case PRE_RATE_CHANGE: 481 - ret = clk_cpu_8996_mux_set_parent(&cpuclk->clkr.hw, ALT_INDEX); 483 + ret = clk_cpu_8996_pmux_set_parent(&cpuclk->clkr.hw, ALT_INDEX); 482 484 qcom_cpu_clk_msm8996_acd_init(base); 483 485 break; 484 486 case POST_RATE_CHANGE: 485 487 if (cnd->new_rate < DIV_2_THRESHOLD) 486 - ret = clk_cpu_8996_mux_set_parent(&cpuclk->clkr.hw, 487 - SMUX_INDEX); 488 + ret = clk_cpu_8996_pmux_set_parent(&cpuclk->clkr.hw, 489 + SMUX_INDEX); 488 490 else 489 - ret = clk_cpu_8996_mux_set_parent(&cpuclk->clkr.hw, 490 - ACD_INDEX); 491 + ret = clk_cpu_8996_pmux_set_parent(&cpuclk->clkr.hw, 492 + ACD_INDEX); 491 493 break; 492 494 default: 493 495 ret = 0;