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

clk: qcom: gdsc: Add support for votable gdscs

Some gdscs might be controlled via voting registers and might not
really disable when the kernel intends to disable them (due to other
votes keeping them enabled)
Mark these gdscs with a flag for we do not check/wait on a disable
status for these gdscs within the kernel disable callback.

Also at boot, if these GDSCs are found to be ON, we make sure we
vote for them before we inform the genpd framework about their
status. If genpd gets no users, it then disables (removes the vote)
them as part of genpd_poweroff_unused()

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

authored by

Rajendra Nayak and committed by
Stephen Boyd
a823bb9f 77b1067a

+26 -7
+18
drivers/clk/qcom/gdsc.c
··· 66 66 if (ret) 67 67 return ret; 68 68 69 + /* If disabling votable gdscs, don't poll on status */ 70 + if ((sc->flags & VOTABLE) && !en) { 71 + /* 72 + * Add a short delay here to ensure that an enable 73 + * right after it was disabled does not put it in an 74 + * unknown state 75 + */ 76 + udelay(TIMEOUT_US); 77 + return 0; 78 + } 79 + 69 80 if (sc->gds_hw_ctrl) { 70 81 status_reg = sc->gds_hw_ctrl; 71 82 /* ··· 209 198 on = gdsc_is_enabled(sc, reg); 210 199 if (on < 0) 211 200 return on; 201 + 202 + /* 203 + * Votable GDSCs can be ON due to Vote from other masters. 204 + * If a Votable GDSC is ON, make sure we have a Vote. 205 + */ 206 + if ((sc->flags & VOTABLE) && on) 207 + gdsc_enable(&sc->pd); 212 208 213 209 if (on || (sc->pwrsts & PWRSTS_RET)) 214 210 gdsc_force_mem_on(sc);
+8 -7
drivers/clk/qcom/gdsc.h
··· 20 20 struct regmap; 21 21 struct reset_controller_dev; 22 22 23 - /* Powerdomain allowable state bitfields */ 24 - #define PWRSTS_OFF BIT(0) 25 - #define PWRSTS_RET BIT(1) 26 - #define PWRSTS_ON BIT(2) 27 - #define PWRSTS_OFF_ON (PWRSTS_OFF | PWRSTS_ON) 28 - #define PWRSTS_RET_ON (PWRSTS_RET | PWRSTS_ON) 29 - 30 23 /** 31 24 * struct gdsc - Globally Distributed Switch Controller 32 25 * @pd: generic power domain ··· 42 49 unsigned int *cxcs; 43 50 unsigned int cxc_count; 44 51 const u8 pwrsts; 52 + /* Powerdomain allowable state bitfields */ 53 + #define PWRSTS_OFF BIT(0) 54 + #define PWRSTS_RET BIT(1) 55 + #define PWRSTS_ON BIT(2) 56 + #define PWRSTS_OFF_ON (PWRSTS_OFF | PWRSTS_ON) 57 + #define PWRSTS_RET_ON (PWRSTS_RET | PWRSTS_ON) 58 + const u8 flags; 59 + #define VOTABLE BIT(0) 45 60 struct reset_controller_dev *rcdev; 46 61 unsigned int *resets; 47 62 unsigned int reset_count;