• Home
  • Raw
  • Download

Lines Matching +full:pd +full:- +full:disable

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2015, 2017-2018, 2022, The Linux Foundation. All rights reserved.
16 #include <linux/reset-controller.h>
51 #define domain_to_gdsc(domain) container_of(domain, struct gdsc, pd)
65 if (sc->flags & POLL_CFG_GDSCR) in gdsc_check_status()
66 reg = sc->gdscr + CFG_GDSCR_OFFSET; in gdsc_check_status()
67 else if (sc->gds_hw_ctrl) in gdsc_check_status()
68 reg = sc->gds_hw_ctrl; in gdsc_check_status()
70 reg = sc->gdscr; in gdsc_check_status()
72 ret = regmap_read(sc->regmap, reg, &val); in gdsc_check_status()
76 if (sc->flags & POLL_CFG_GDSCR) { in gdsc_check_status()
92 return -EINVAL; in gdsc_check_status()
99 return regmap_update_bits(sc->regmap, sc->gdscr, HW_CONTROL_MASK, val); in gdsc_hwctrl()
115 return -ETIMEDOUT; in gdsc_poll_status()
123 if (status == GDSC_ON && sc->rsupply) { in gdsc_toggle_logic()
124 ret = regulator_enable(sc->rsupply); in gdsc_toggle_logic()
129 ret = regmap_update_bits(sc->regmap, sc->gdscr, SW_COLLAPSE_MASK, val); in gdsc_toggle_logic()
134 if ((sc->flags & VOTABLE) && status == GDSC_OFF) { in gdsc_toggle_logic()
144 if (sc->gds_hw_ctrl) { in gdsc_toggle_logic()
146 * The gds hw controller asserts/de-asserts the status bit soon in gdsc_toggle_logic()
159 WARN(ret, "%s status stuck at 'o%s'", sc->pd.name, status ? "ff" : "n"); in gdsc_toggle_logic()
161 if (!ret && status == GDSC_OFF && sc->rsupply) { in gdsc_toggle_logic()
162 ret = regulator_disable(sc->rsupply); in gdsc_toggle_logic()
174 for (i = 0; i < sc->reset_count; i++) in gdsc_deassert_reset()
175 sc->rcdev->ops->deassert(sc->rcdev, sc->resets[i]); in gdsc_deassert_reset()
183 for (i = 0; i < sc->reset_count; i++) in gdsc_assert_reset()
184 sc->rcdev->ops->assert(sc->rcdev, sc->resets[i]); in gdsc_assert_reset()
193 if (!(sc->flags & NO_RET_PERIPH)) in gdsc_force_mem_on()
196 for (i = 0; i < sc->cxc_count; i++) in gdsc_force_mem_on()
197 regmap_update_bits(sc->regmap, sc->cxcs[i], mask, mask); in gdsc_force_mem_on()
205 if (!(sc->flags & NO_RET_PERIPH)) in gdsc_clear_mem_on()
208 for (i = 0; i < sc->cxc_count; i++) in gdsc_clear_mem_on()
209 regmap_update_bits(sc->regmap, sc->cxcs[i], mask, 0); in gdsc_clear_mem_on()
214 regmap_update_bits(sc->regmap, sc->clamp_io_ctrl, in gdsc_deassert_clamp_io()
220 regmap_update_bits(sc->regmap, sc->clamp_io_ctrl, in gdsc_assert_clamp_io()
226 regmap_update_bits(sc->regmap, sc->clamp_io_ctrl, in gdsc_assert_reset_aon()
229 regmap_update_bits(sc->regmap, sc->clamp_io_ctrl, in gdsc_assert_reset_aon()
237 regmap_update_bits(sc->regmap, sc->gdscr, mask, mask); in gdsc_retain_ff_on()
245 if (sc->pwrsts == PWRSTS_ON) in gdsc_enable()
248 if (sc->flags & SW_RESET) { in gdsc_enable()
254 if (sc->flags & CLAMP_IO) { in gdsc_enable()
255 if (sc->flags & AON_RESET) in gdsc_enable()
264 if (sc->pwrsts & PWRSTS_OFF) in gdsc_enable()
269 * additional 4 clock cycles to re-enable after the power domain is in gdsc_enable()
277 if (sc->flags & HW_CTRL) { in gdsc_enable()
292 if (sc->flags & RETAIN_FF_ENABLE) in gdsc_enable()
303 if (sc->pwrsts == PWRSTS_ON) in gdsc_disable()
307 if (sc->flags & HW_CTRL) { in gdsc_disable()
324 if (sc->pwrsts & PWRSTS_OFF) in gdsc_disable()
331 if (sc->flags & CLAMP_IO) in gdsc_disable()
343 * Disable HW trigger: collapse/restore occur based on registers writes. in gdsc_init()
344 * Disable SW override: Use hardware state-machine for sequencing. in gdsc_init()
350 if (!sc->en_rest_wait_val) in gdsc_init()
351 sc->en_rest_wait_val = EN_REST_WAIT_VAL; in gdsc_init()
352 if (!sc->en_few_wait_val) in gdsc_init()
353 sc->en_few_wait_val = EN_FEW_WAIT_VAL; in gdsc_init()
354 if (!sc->clk_dis_wait_val) in gdsc_init()
355 sc->clk_dis_wait_val = CLK_DIS_WAIT_VAL; in gdsc_init()
357 val = sc->en_rest_wait_val << EN_REST_WAIT_SHIFT | in gdsc_init()
358 sc->en_few_wait_val << EN_FEW_WAIT_SHIFT | in gdsc_init()
359 sc->clk_dis_wait_val << CLK_DIS_WAIT_SHIFT; in gdsc_init()
361 ret = regmap_update_bits(sc->regmap, sc->gdscr, mask, val); in gdsc_init()
366 if (sc->pwrsts == PWRSTS_ON) { in gdsc_init()
378 if (sc->rsupply) { in gdsc_init()
379 ret = regulator_enable(sc->rsupply); in gdsc_init()
388 if (sc->flags & VOTABLE) { in gdsc_init()
389 ret = regmap_update_bits(sc->regmap, sc->gdscr, in gdsc_init()
396 if (sc->flags & HW_CTRL) { in gdsc_init()
407 if (sc->flags & RETAIN_FF_ENABLE) in gdsc_init()
409 } else if (sc->flags & ALWAYS_ON) { in gdsc_init()
411 gdsc_enable(&sc->pd); in gdsc_init()
415 if (on || (sc->pwrsts & PWRSTS_RET)) in gdsc_init()
420 if (sc->flags & ALWAYS_ON) in gdsc_init()
421 sc->pd.flags |= GENPD_FLAG_ALWAYS_ON; in gdsc_init()
422 if (!sc->pd.power_off) in gdsc_init()
423 sc->pd.power_off = gdsc_disable; in gdsc_init()
424 if (!sc->pd.power_on) in gdsc_init()
425 sc->pd.power_on = gdsc_enable; in gdsc_init()
426 pm_genpd_init(&sc->pd, NULL, !on); in gdsc_init()
436 struct device *dev = desc->dev; in gdsc_register()
437 struct gdsc **scs = desc->scs; in gdsc_register()
438 size_t num = desc->num; in gdsc_register()
442 return -ENOMEM; in gdsc_register()
444 data->domains = devm_kcalloc(dev, num, sizeof(*data->domains), in gdsc_register()
446 if (!data->domains) in gdsc_register()
447 return -ENOMEM; in gdsc_register()
450 if (!scs[i] || !scs[i]->supply) in gdsc_register()
453 scs[i]->rsupply = devm_regulator_get(dev, scs[i]->supply); in gdsc_register()
454 if (IS_ERR(scs[i]->rsupply)) in gdsc_register()
455 return PTR_ERR(scs[i]->rsupply); in gdsc_register()
458 data->num_domains = num; in gdsc_register()
462 scs[i]->regmap = regmap; in gdsc_register()
463 scs[i]->rcdev = rcdev; in gdsc_register()
467 data->domains[i] = &scs[i]->pd; in gdsc_register()
474 if (scs[i]->parent) in gdsc_register()
475 pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd); in gdsc_register()
478 return of_genpd_add_provider_onecell(dev->of_node, data); in gdsc_register()
484 struct device *dev = desc->dev; in gdsc_unregister()
485 struct gdsc **scs = desc->scs; in gdsc_unregister()
486 size_t num = desc->num; in gdsc_unregister()
492 if (scs[i]->parent) in gdsc_unregister()
493 pm_genpd_remove_subdomain(scs[i]->parent, &scs[i]->pd); in gdsc_unregister()
495 of_genpd_del_provider(dev->of_node); in gdsc_unregister()
505 * the device the CPU needs to disable the GX headswitch. There being no sane
509 * defining a GX gdsc with a dummy enable function and a "default" disable
515 * is *really* off - this gives us a semi standard way of doing what we need.