Lines Matching refs:sc
51 static int gdsc_check_status(struct gdsc *sc, enum gdsc_status status) in gdsc_check_status() argument
57 if (sc->flags & POLL_CFG_GDSCR) in gdsc_check_status()
58 reg = sc->gdscr + CFG_GDSCR_OFFSET; in gdsc_check_status()
59 else if (sc->gds_hw_ctrl) in gdsc_check_status()
60 reg = sc->gds_hw_ctrl; in gdsc_check_status()
62 reg = sc->gdscr; in gdsc_check_status()
64 ret = regmap_read(sc->regmap, reg, &val); in gdsc_check_status()
68 if (sc->flags & POLL_CFG_GDSCR) { in gdsc_check_status()
87 static int gdsc_hwctrl(struct gdsc *sc, bool en) in gdsc_hwctrl() argument
91 return regmap_update_bits(sc->regmap, sc->gdscr, HW_CONTROL_MASK, val); in gdsc_hwctrl()
94 static int gdsc_poll_status(struct gdsc *sc, enum gdsc_status status) in gdsc_poll_status() argument
100 if (gdsc_check_status(sc, status)) in gdsc_poll_status()
104 if (gdsc_check_status(sc, status)) in gdsc_poll_status()
110 static int gdsc_toggle_logic(struct gdsc *sc, enum gdsc_status status) in gdsc_toggle_logic() argument
115 ret = regmap_update_bits(sc->regmap, sc->gdscr, SW_COLLAPSE_MASK, val); in gdsc_toggle_logic()
120 if ((sc->flags & VOTABLE) && status == GDSC_OFF) { in gdsc_toggle_logic()
130 if (sc->gds_hw_ctrl) { in gdsc_toggle_logic()
144 ret = gdsc_poll_status(sc, status); in gdsc_toggle_logic()
145 WARN(ret, "%s status stuck at 'o%s'", sc->pd.name, status ? "ff" : "n"); in gdsc_toggle_logic()
149 static inline int gdsc_deassert_reset(struct gdsc *sc) in gdsc_deassert_reset() argument
153 for (i = 0; i < sc->reset_count; i++) in gdsc_deassert_reset()
154 sc->rcdev->ops->deassert(sc->rcdev, sc->resets[i]); in gdsc_deassert_reset()
158 static inline int gdsc_assert_reset(struct gdsc *sc) in gdsc_assert_reset() argument
162 for (i = 0; i < sc->reset_count; i++) in gdsc_assert_reset()
163 sc->rcdev->ops->assert(sc->rcdev, sc->resets[i]); in gdsc_assert_reset()
167 static inline void gdsc_force_mem_on(struct gdsc *sc) in gdsc_force_mem_on() argument
172 for (i = 0; i < sc->cxc_count; i++) in gdsc_force_mem_on()
173 regmap_update_bits(sc->regmap, sc->cxcs[i], mask, mask); in gdsc_force_mem_on()
176 static inline void gdsc_clear_mem_on(struct gdsc *sc) in gdsc_clear_mem_on() argument
181 for (i = 0; i < sc->cxc_count; i++) in gdsc_clear_mem_on()
182 regmap_update_bits(sc->regmap, sc->cxcs[i], mask, 0); in gdsc_clear_mem_on()
185 static inline void gdsc_deassert_clamp_io(struct gdsc *sc) in gdsc_deassert_clamp_io() argument
187 regmap_update_bits(sc->regmap, sc->clamp_io_ctrl, in gdsc_deassert_clamp_io()
191 static inline void gdsc_assert_clamp_io(struct gdsc *sc) in gdsc_assert_clamp_io() argument
193 regmap_update_bits(sc->regmap, sc->clamp_io_ctrl, in gdsc_assert_clamp_io()
197 static inline void gdsc_assert_reset_aon(struct gdsc *sc) in gdsc_assert_reset_aon() argument
199 regmap_update_bits(sc->regmap, sc->clamp_io_ctrl, in gdsc_assert_reset_aon()
202 regmap_update_bits(sc->regmap, sc->clamp_io_ctrl, in gdsc_assert_reset_aon()
207 struct gdsc *sc = domain_to_gdsc(domain); in gdsc_enable() local
210 if (sc->pwrsts == PWRSTS_ON) in gdsc_enable()
211 return gdsc_deassert_reset(sc); in gdsc_enable()
213 if (sc->flags & SW_RESET) { in gdsc_enable()
214 gdsc_assert_reset(sc); in gdsc_enable()
216 gdsc_deassert_reset(sc); in gdsc_enable()
219 if (sc->flags & CLAMP_IO) { in gdsc_enable()
220 if (sc->flags & AON_RESET) in gdsc_enable()
221 gdsc_assert_reset_aon(sc); in gdsc_enable()
222 gdsc_deassert_clamp_io(sc); in gdsc_enable()
225 ret = gdsc_toggle_logic(sc, GDSC_ON); in gdsc_enable()
229 if (sc->pwrsts & PWRSTS_OFF) in gdsc_enable()
230 gdsc_force_mem_on(sc); in gdsc_enable()
242 if (sc->flags & HW_CTRL) { in gdsc_enable()
243 ret = gdsc_hwctrl(sc, true); in gdsc_enable()
262 struct gdsc *sc = domain_to_gdsc(domain); in gdsc_disable() local
265 if (sc->pwrsts == PWRSTS_ON) in gdsc_disable()
266 return gdsc_assert_reset(sc); in gdsc_disable()
269 if (sc->flags & HW_CTRL) { in gdsc_disable()
270 ret = gdsc_hwctrl(sc, false); in gdsc_disable()
281 ret = gdsc_poll_status(sc, GDSC_ON); in gdsc_disable()
286 if (sc->pwrsts & PWRSTS_OFF) in gdsc_disable()
287 gdsc_clear_mem_on(sc); in gdsc_disable()
289 ret = gdsc_toggle_logic(sc, GDSC_OFF); in gdsc_disable()
293 if (sc->flags & CLAMP_IO) in gdsc_disable()
294 gdsc_assert_clamp_io(sc); in gdsc_disable()
299 static int gdsc_init(struct gdsc *sc) in gdsc_init() argument
312 ret = regmap_update_bits(sc->regmap, sc->gdscr, mask, val); in gdsc_init()
317 if (sc->pwrsts == PWRSTS_ON) { in gdsc_init()
318 ret = gdsc_toggle_logic(sc, GDSC_ON); in gdsc_init()
323 on = gdsc_check_status(sc, GDSC_ON); in gdsc_init()
331 if ((sc->flags & VOTABLE) && on) in gdsc_init()
332 gdsc_enable(&sc->pd); in gdsc_init()
335 if (sc->flags & ALWAYS_ON) { in gdsc_init()
337 gdsc_enable(&sc->pd); in gdsc_init()
339 sc->pd.flags |= GENPD_FLAG_ALWAYS_ON; in gdsc_init()
342 if (on || (sc->pwrsts & PWRSTS_RET)) in gdsc_init()
343 gdsc_force_mem_on(sc); in gdsc_init()
345 gdsc_clear_mem_on(sc); in gdsc_init()
347 if (!sc->pd.power_off) in gdsc_init()
348 sc->pd.power_off = gdsc_disable; in gdsc_init()
349 if (!sc->pd.power_on) in gdsc_init()
350 sc->pd.power_on = gdsc_enable; in gdsc_init()
351 pm_genpd_init(&sc->pd, NULL, !on); in gdsc_init()