clk: qcom: branch: Extend the invert logic for branch2 clocks
authorImran Shaik <quic_imrashai@quicinc.com>
Fri, 12 May 2023 12:23:43 +0000 (17:53 +0530)
committerBjorn Andersson <andersson@kernel.org>
Thu, 25 May 2023 04:47:17 +0000 (21:47 -0700)
Add support to handle the invert logic for branch2 clocks.
Invert branch halt would indicate the clock ON when CLK_OFF
bit is '1' and OFF when CLK_OFF bit is '0'.

Signed-off-by: Imran Shaik <quic_imrashai@quicinc.com>
Signed-off-by: Taniya Das <quic_tdas@quicinc.com>
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20230512122347.1219-2-quic_tdas@quicinc.com
drivers/clk/qcom/clk-branch.c

index ca896ebf7e1ba959e1cb12e1a40e99ff4508b687..fc4735f74f0f1506fe227bb42ad346c643d1a190 100644 (file)
@@ -43,6 +43,7 @@ static bool clk_branch2_check_halt(const struct clk_branch *br, bool enabling)
 {
        u32 val;
        u32 mask;
+       bool invert = (br->halt_check == BRANCH_HALT_ENABLE);
 
        mask = CBCR_NOC_FSM_STATUS;
        mask |= CBCR_CLK_OFF;
@@ -51,11 +52,10 @@ static bool clk_branch2_check_halt(const struct clk_branch *br, bool enabling)
 
        if (enabling) {
                val &= mask;
-               return (val & CBCR_CLK_OFF) == 0 ||
+               return (val & CBCR_CLK_OFF) == (invert ? CBCR_CLK_OFF : 0) ||
                        FIELD_GET(CBCR_NOC_FSM_STATUS, val) == FSM_STATUS_ON;
-       } else {
-               return val & CBCR_CLK_OFF;
        }
+       return (val & CBCR_CLK_OFF) == (invert ? 0 : CBCR_CLK_OFF);
 }
 
 static int clk_branch_wait(const struct clk_branch *br, bool enabling,