Lines Matching +full:num +full:- +full:domains
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>
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 (sc->collapse_mask) { in gdsc_update_collapse_bit()
124 reg = sc->collapse_ctrl; in gdsc_update_collapse_bit()
125 mask = sc->collapse_mask; in gdsc_update_collapse_bit()
127 reg = sc->gdscr; in gdsc_update_collapse_bit()
131 ret = regmap_update_bits(sc->regmap, reg, mask, val ? mask : 0); in gdsc_update_collapse_bit()
142 if (status == GDSC_ON && sc->rsupply) { in gdsc_toggle_logic()
143 ret = regulator_enable(sc->rsupply); in gdsc_toggle_logic()
151 if ((sc->flags & VOTABLE) && status == GDSC_OFF) { in gdsc_toggle_logic()
161 if (sc->gds_hw_ctrl) { in gdsc_toggle_logic()
163 * The gds hw controller asserts/de-asserts the status bit soon in gdsc_toggle_logic()
176 WARN(ret, "%s status stuck at 'o%s'", sc->pd.name, status ? "ff" : "n"); in gdsc_toggle_logic()
178 if (!ret && status == GDSC_OFF && sc->rsupply) { in gdsc_toggle_logic()
179 ret = regulator_disable(sc->rsupply); in gdsc_toggle_logic()
191 for (i = 0; i < sc->reset_count; i++) in gdsc_deassert_reset()
192 sc->rcdev->ops->deassert(sc->rcdev, sc->resets[i]); in gdsc_deassert_reset()
200 for (i = 0; i < sc->reset_count; i++) in gdsc_assert_reset()
201 sc->rcdev->ops->assert(sc->rcdev, sc->resets[i]); in gdsc_assert_reset()
210 if (!(sc->flags & NO_RET_PERIPH)) in gdsc_force_mem_on()
213 for (i = 0; i < sc->cxc_count; i++) in gdsc_force_mem_on()
214 regmap_update_bits(sc->regmap, sc->cxcs[i], mask, mask); in gdsc_force_mem_on()
222 if (!(sc->flags & NO_RET_PERIPH)) in gdsc_clear_mem_on()
225 for (i = 0; i < sc->cxc_count; i++) in gdsc_clear_mem_on()
226 regmap_update_bits(sc->regmap, sc->cxcs[i], mask, 0); in gdsc_clear_mem_on()
231 regmap_update_bits(sc->regmap, sc->clamp_io_ctrl, in gdsc_deassert_clamp_io()
237 regmap_update_bits(sc->regmap, sc->clamp_io_ctrl, in gdsc_assert_clamp_io()
243 regmap_update_bits(sc->regmap, sc->clamp_io_ctrl, in gdsc_assert_reset_aon()
246 regmap_update_bits(sc->regmap, sc->clamp_io_ctrl, in gdsc_assert_reset_aon()
254 regmap_update_bits(sc->regmap, sc->gdscr, mask, mask); in gdsc_retain_ff_on()
262 if (sc->pwrsts == PWRSTS_ON) in gdsc_enable()
265 if (sc->flags & SW_RESET) { in gdsc_enable()
271 if (sc->flags & CLAMP_IO) { in gdsc_enable()
272 if (sc->flags & AON_RESET) in gdsc_enable()
281 if (sc->pwrsts & PWRSTS_OFF) in gdsc_enable()
286 * additional 4 clock cycles to re-enable after the power domain is in gdsc_enable()
294 if (sc->flags & HW_CTRL) { in gdsc_enable()
309 if (sc->flags & RETAIN_FF_ENABLE) in gdsc_enable()
320 if (sc->pwrsts == PWRSTS_ON) in gdsc_disable()
324 if (sc->flags & HW_CTRL) { in gdsc_disable()
341 if (sc->pwrsts & PWRSTS_OFF) in gdsc_disable()
351 if (sc->pwrsts == PWRSTS_RET_ON) in gdsc_disable()
358 if (sc->flags & CLAMP_IO) in gdsc_disable()
371 * Disable SW override: Use hardware state-machine for sequencing. in gdsc_init()
377 if (!sc->en_rest_wait_val) in gdsc_init()
378 sc->en_rest_wait_val = EN_REST_WAIT_VAL; in gdsc_init()
379 if (!sc->en_few_wait_val) in gdsc_init()
380 sc->en_few_wait_val = EN_FEW_WAIT_VAL; in gdsc_init()
381 if (!sc->clk_dis_wait_val) in gdsc_init()
382 sc->clk_dis_wait_val = CLK_DIS_WAIT_VAL; in gdsc_init()
384 val = sc->en_rest_wait_val << EN_REST_WAIT_SHIFT | in gdsc_init()
385 sc->en_few_wait_val << EN_FEW_WAIT_SHIFT | in gdsc_init()
386 sc->clk_dis_wait_val << CLK_DIS_WAIT_SHIFT; in gdsc_init()
388 ret = regmap_update_bits(sc->regmap, sc->gdscr, mask, val); in gdsc_init()
393 if (sc->pwrsts == PWRSTS_ON) { in gdsc_init()
405 if (sc->rsupply) { in gdsc_init()
406 ret = regulator_enable(sc->rsupply); in gdsc_init()
415 if (sc->flags & VOTABLE) { in gdsc_init()
422 if (sc->flags & HW_CTRL) { in gdsc_init()
433 if (sc->flags & RETAIN_FF_ENABLE) in gdsc_init()
435 } else if (sc->flags & ALWAYS_ON) { in gdsc_init()
437 gdsc_enable(&sc->pd); in gdsc_init()
441 if (on || (sc->pwrsts & PWRSTS_RET)) in gdsc_init()
446 if (sc->flags & ALWAYS_ON) in gdsc_init()
447 sc->pd.flags |= GENPD_FLAG_ALWAYS_ON; in gdsc_init()
448 if (!sc->pd.power_off) in gdsc_init()
449 sc->pd.power_off = gdsc_disable; in gdsc_init()
450 if (!sc->pd.power_on) in gdsc_init()
451 sc->pd.power_on = gdsc_enable; in gdsc_init()
453 ret = pm_genpd_init(&sc->pd, NULL, !on); in gdsc_init()
460 if (on && sc->rsupply) in gdsc_init()
461 regulator_disable(sc->rsupply); in gdsc_init()
471 struct device *dev = desc->dev; in gdsc_register()
472 struct gdsc **scs = desc->scs; in gdsc_register()
473 size_t num = desc->num; in gdsc_register() local
477 return -ENOMEM; in gdsc_register()
479 data->domains = devm_kcalloc(dev, num, sizeof(*data->domains), in gdsc_register()
481 if (!data->domains) in gdsc_register()
482 return -ENOMEM; in gdsc_register()
484 for (i = 0; i < num; i++) { in gdsc_register()
485 if (!scs[i] || !scs[i]->supply) in gdsc_register()
488 scs[i]->rsupply = devm_regulator_get(dev, scs[i]->supply); in gdsc_register()
489 if (IS_ERR(scs[i]->rsupply)) in gdsc_register()
490 return PTR_ERR(scs[i]->rsupply); in gdsc_register()
493 data->num_domains = num; in gdsc_register()
494 for (i = 0; i < num; i++) { in gdsc_register()
497 scs[i]->regmap = regmap; in gdsc_register()
498 scs[i]->rcdev = rcdev; in gdsc_register()
502 data->domains[i] = &scs[i]->pd; in gdsc_register()
506 for (i = 0; i < num; i++) { in gdsc_register()
509 if (scs[i]->parent) in gdsc_register()
510 pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd); in gdsc_register()
511 else if (!IS_ERR_OR_NULL(dev->pm_domain)) in gdsc_register()
512 pm_genpd_add_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd); in gdsc_register()
515 return of_genpd_add_provider_onecell(dev->of_node, data); in gdsc_register()
521 struct device *dev = desc->dev; in gdsc_unregister()
522 struct gdsc **scs = desc->scs; in gdsc_unregister()
523 size_t num = desc->num; in gdsc_unregister() local
526 for (i = 0; i < num; i++) { in gdsc_unregister()
529 if (scs[i]->parent) in gdsc_unregister()
530 pm_genpd_remove_subdomain(scs[i]->parent, &scs[i]->pd); in gdsc_unregister()
531 else if (!IS_ERR_OR_NULL(dev->pm_domain)) in gdsc_unregister()
532 pm_genpd_remove_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd); in gdsc_unregister()
534 of_genpd_del_provider(dev->of_node); in gdsc_unregister()
554 * is *really* off - this gives us a semi standard way of doing what we need.