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

clk: imx: clk-composite-93: check white_list

The CCM ROOT AUTHEN register WHITE_LIST indicate:
Each bit in this field represent for one domain. Bit16~Bit31 represent
for DOMAIN0~DOMAIN15 respectively. Only corresponding bit of the domains
is set to 1 can change the registers of this Clock Root.

i.MX93 DID is 3, so if BIT(3 + WHITE_LIST_SHIFT) is 0, the clk should be
set to read only. To make the imx93_clk_composite_flags be reusable,
add a new parameter named did(domain id);

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Link: https://lore.kernel.org/r/20220830033137.4149542-5-peng.fan@oss.nxp.com

authored by

Peng Fan and committed by
Abel Vesa
2b66f02e 4a3de5aa

+10 -5
+6 -2
drivers/clk/imx/clk-composite-93.c
··· 28 28 #define TZ_NS_SHIFT 9 29 29 #define TZ_NS_MASK BIT(9) 30 30 31 + #define WHITE_LIST_SHIFT 16 32 + 31 33 static int imx93_clk_composite_wait_ready(struct clk_hw *hw, void __iomem *reg) 32 34 { 33 35 int ret; ··· 182 180 }; 183 181 184 182 struct clk_hw *imx93_clk_composite_flags(const char *name, const char * const *parent_names, 185 - int num_parents, void __iomem *reg, 183 + int num_parents, void __iomem *reg, u32 domain_id, 186 184 unsigned long flags) 187 185 { 188 186 struct clk_hw *hw = ERR_PTR(-ENOMEM), *mux_hw; ··· 191 189 struct clk_gate *gate = NULL; 192 190 struct clk_mux *mux = NULL; 193 191 bool clk_ro = false; 192 + u32 authen; 194 193 195 194 mux = kzalloc(sizeof(*mux), GFP_KERNEL); 196 195 if (!mux) ··· 214 211 div->lock = &imx_ccm_lock; 215 212 div->flags = CLK_DIVIDER_ROUND_CLOSEST; 216 213 217 - if (!(readl(reg + AUTHEN_OFFSET) & TZ_NS_MASK)) 214 + authen = readl(reg + AUTHEN_OFFSET); 215 + if (!(authen & TZ_NS_MASK) || !(authen & BIT(WHITE_LIST_SHIFT + domain_id))) 218 216 clk_ro = true; 219 217 220 218 if (clk_ro) {
+1 -1
drivers/clk/imx/clk-imx93.c
··· 293 293 root = &root_array[i]; 294 294 clks[root->clk] = imx93_clk_composite_flags(root->name, 295 295 parent_names[root->sel], 296 - 4, base + root->off, 296 + 4, base + root->off, 3, 297 297 root->flags); 298 298 } 299 299
+3 -2
drivers/clk/imx/clk.h
··· 445 445 const char * const *parent_names, 446 446 int num_parents, 447 447 void __iomem *reg, 448 + u32 domain_id, 448 449 unsigned long flags); 449 - #define imx93_clk_composite(name, parent_names, num_parents, reg) \ 450 - imx93_clk_composite_flags(name, parent_names, num_parents, reg, \ 450 + #define imx93_clk_composite(name, parent_names, num_parents, reg, domain_id) \ 451 + imx93_clk_composite_flags(name, parent_names, num_parents, reg, domain_id \ 451 452 CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE) 452 453 453 454 struct clk_hw *imx_clk_hw_divider_gate(const char *name, const char *parent_name,