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

clk: qcom: cpu-8996: use constant mask for pmux

Both pmux instances share the same width and shift. Specify the mask at
compile time to simplify functions.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20220714100351.1834711-7-dmitry.baryshkov@linaro.org

authored by

Dmitry Baryshkov and committed by
Bjorn Andersson
f9ea0f59 f387d1c4

+6 -13
+6 -13
drivers/clk/qcom/clk-cpu-8996.c
··· 49 49 * detect voltage droops. 50 50 */ 51 51 52 + #include <linux/bitfield.h> 52 53 #include <linux/clk.h> 53 54 #include <linux/clk-provider.h> 54 55 #include <linux/io.h> ··· 76 75 #define MUX_OFFSET 0x40 77 76 #define ALT_PLL_OFFSET 0x100 78 77 #define SSSCTL_OFFSET 0x160 78 + 79 + #define PMUX_MASK 0x3 79 80 80 81 static const u8 prim_pll_regs[PLL_OFF_MAX_REGS] = { 81 82 [PLL_OFF_L_VAL] = 0x04, ··· 247 244 248 245 struct clk_cpu_8996_pmux { 249 246 u32 reg; 250 - u8 shift; 251 - u8 width; 252 247 struct notifier_block nb; 253 248 struct clk_regmap clkr; 254 249 }; ··· 266 265 { 267 266 struct clk_regmap *clkr = to_clk_regmap(hw); 268 267 struct clk_cpu_8996_pmux *cpuclk = to_clk_cpu_8996_pmux_hw(hw); 269 - u32 mask = GENMASK(cpuclk->width - 1, 0); 270 268 u32 val; 271 269 272 270 regmap_read(clkr->regmap, cpuclk->reg, &val); 273 - val >>= cpuclk->shift; 274 271 275 - return val & mask; 272 + return FIELD_GET(PMUX_MASK, val); 276 273 } 277 274 278 275 static int clk_cpu_8996_pmux_set_parent(struct clk_hw *hw, u8 index) 279 276 { 280 277 struct clk_regmap *clkr = to_clk_regmap(hw); 281 278 struct clk_cpu_8996_pmux *cpuclk = to_clk_cpu_8996_pmux_hw(hw); 282 - u32 mask = GENMASK(cpuclk->width + cpuclk->shift - 1, cpuclk->shift); 283 279 u32 val; 284 280 285 - val = index; 286 - val <<= cpuclk->shift; 281 + val = FIELD_PREP(PMUX_MASK, index); 287 282 288 - return regmap_update_bits(clkr->regmap, cpuclk->reg, mask, val); 283 + return regmap_update_bits(clkr->regmap, cpuclk->reg, PMUX_MASK, val); 289 284 } 290 285 291 286 static int clk_cpu_8996_pmux_determine_rate(struct clk_hw *hw, ··· 363 366 364 367 static struct clk_cpu_8996_pmux pwrcl_pmux = { 365 368 .reg = PWRCL_REG_OFFSET + MUX_OFFSET, 366 - .shift = 0, 367 - .width = 2, 368 369 .nb.notifier_call = cpu_clk_notifier_cb, 369 370 .clkr.hw.init = &(struct clk_init_data) { 370 371 .name = "pwrcl_pmux", ··· 376 381 377 382 static struct clk_cpu_8996_pmux perfcl_pmux = { 378 383 .reg = PERFCL_REG_OFFSET + MUX_OFFSET, 379 - .shift = 0, 380 - .width = 2, 381 384 .nb.notifier_call = cpu_clk_notifier_cb, 382 385 .clkr.hw.init = &(struct clk_init_data) { 383 386 .name = "perfcl_pmux",