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

1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2015-2017 Pengutronix, Lucas Stach <kernel@pengutronix.de>
4 * Copyright 2011-2013 Freescale Semiconductor, Inc.
62 struct imx_pm_domain *pd = to_imx_pm_domain(genpd); in imx6_pm_domain_power_off() local
67 regmap_read(pd->regmap, pd->reg_offs + GPC_PGC_PDNSCR_OFFS, &val); in imx6_pm_domain_power_off()
72 regmap_update_bits(pd->regmap, pd->reg_offs + GPC_PGC_CTRL_OFFS, in imx6_pm_domain_power_off()
76 val = BIT(pd->cntr_pdn_bit); in imx6_pm_domain_power_off()
77 regmap_update_bits(pd->regmap, GPC_CNTR, val, val); in imx6_pm_domain_power_off()
80 udelay(DIV_ROUND_UP(iso + iso2sw, pd->ipg_rate_mhz)); in imx6_pm_domain_power_off()
82 if (pd->supply) in imx6_pm_domain_power_off()
83 regulator_disable(pd->supply); in imx6_pm_domain_power_off()
90 struct imx_pm_domain *pd = to_imx_pm_domain(genpd); in imx6_pm_domain_power_on() local
94 if (pd->supply) { in imx6_pm_domain_power_on()
95 ret = regulator_enable(pd->supply); in imx6_pm_domain_power_on()
104 for (i = 0; i < pd->num_clks; i++) in imx6_pm_domain_power_on()
105 clk_prepare_enable(pd->clk[i]); in imx6_pm_domain_power_on()
108 regmap_update_bits(pd->regmap, pd->reg_offs + GPC_PGC_CTRL_OFFS, in imx6_pm_domain_power_on()
112 req = BIT(pd->cntr_pdn_bit + 1); in imx6_pm_domain_power_on()
113 regmap_update_bits(pd->regmap, GPC_CNTR, req, req); in imx6_pm_domain_power_on()
116 ret = regmap_read_poll_timeout(pd->regmap, GPC_CNTR, val, !(val & req), in imx6_pm_domain_power_on()
119 pr_err("powerup request on domain %s timed out\n", genpd->name); in imx6_pm_domain_power_on()
124 /* Disable reset clocks for all devices in the domain */ in imx6_pm_domain_power_on()
125 for (i = 0; i < pd->num_clks; i++) in imx6_pm_domain_power_on()
126 clk_disable_unprepare(pd->clk[i]); in imx6_pm_domain_power_on()
136 struct clk *clk = of_clk_get(dev->of_node, i); in imx_pgc_get_clocks()
141 ret = -EINVAL; in imx_pgc_get_clocks()
144 domain->clk[i] = clk; in imx_pgc_get_clocks()
146 domain->num_clks = i; in imx_pgc_get_clocks()
151 while (i--) in imx_pgc_get_clocks()
152 clk_put(domain->clk[i]); in imx_pgc_get_clocks()
161 for (i = domain->num_clks - 1; i >= 0; i--) in imx_pgc_put_clocks()
162 clk_put(domain->clk[i]); in imx_pgc_put_clocks()
168 domain->supply = devm_regulator_get_optional(dev, "power"); in imx_pgc_parse_dt()
169 if (IS_ERR(domain->supply)) { in imx_pgc_parse_dt()
170 if (PTR_ERR(domain->supply) == -ENODEV) in imx_pgc_parse_dt()
171 domain->supply = NULL; in imx_pgc_parse_dt()
173 return PTR_ERR(domain->supply); in imx_pgc_parse_dt()
182 struct imx_pm_domain *domain = pdev->dev.platform_data; in imx_pgc_power_domain_probe()
183 struct device *dev = &pdev->dev; in imx_pgc_power_domain_probe()
186 /* if this PD is associated with a DT node try to parse it */ in imx_pgc_power_domain_probe()
187 if (dev->of_node) { in imx_pgc_power_domain_probe()
194 if (domain->base.power_on) in imx_pgc_power_domain_probe()
195 domain->base.power_on(&domain->base); in imx_pgc_power_domain_probe()
198 pm_genpd_init(&domain->base, NULL, false); in imx_pgc_power_domain_probe()
199 ret = of_genpd_add_provider_simple(dev->of_node, &domain->base); in imx_pgc_power_domain_probe()
204 device_link_add(dev, dev->parent, DL_FLAG_AUTOREMOVE_CONSUMER); in imx_pgc_power_domain_probe()
209 pm_genpd_remove(&domain->base); in imx_pgc_power_domain_probe()
217 struct imx_pm_domain *domain = pdev->dev.platform_data; in imx_pgc_power_domain_remove()
220 of_genpd_del_provider(pdev->dev.of_node); in imx_pgc_power_domain_remove()
221 pm_genpd_remove(&domain->base); in imx_pgc_power_domain_remove()
227 { "imx-pgc-power-domain"},
233 .name = "imx-pgc-pd",
320 { .compatible = "fsl,imx6q-gpc", .data = &imx6q_dt_data },
321 { .compatible = "fsl,imx6qp-gpc", .data = &imx6qp_dt_data },
322 { .compatible = "fsl,imx6sl-gpc", .data = &imx6sl_dt_data },
323 { .compatible = "fsl,imx6sx-gpc", .data = &imx6sx_dt_data },
367 domain->regmap = regmap; in imx_gpc_old_dt_init()
368 domain->ipg_rate_mhz = 66; in imx_gpc_old_dt_init()
371 domain->supply = devm_regulator_get(dev, "pu"); in imx_gpc_old_dt_init()
372 if (IS_ERR(domain->supply)) in imx_gpc_old_dt_init()
373 return PTR_ERR(domain->supply); in imx_gpc_old_dt_init()
379 domain->base.power_on(&domain->base); in imx_gpc_old_dt_init()
387 ret = of_genpd_add_provider_onecell(dev->of_node, in imx_gpc_old_dt_init()
405 const struct imx_gpc_dt_data *of_id_data = device_get_match_data(&pdev->dev); in imx_gpc_probe()
411 pgc_node = of_get_child_by_name(pdev->dev.of_node, "pgc"); in imx_gpc_probe()
414 if (!of_property_read_bool(pdev->dev.of_node, "#power-domain-cells") && in imx_gpc_probe()
422 regmap = devm_regmap_init_mmio_clk(&pdev->dev, NULL, base, in imx_gpc_probe()
426 dev_err(&pdev->dev, "failed to init regmap: %d\n", in imx_gpc_probe()
432 * Disable PU power down by runtime PM if ERR009619 is present. in imx_gpc_probe()
441 if (of_id_data->err009619_present) in imx_gpc_probe()
446 if (of_id_data->err006287_present) in imx_gpc_probe()
451 ret = imx_gpc_old_dt_init(&pdev->dev, regmap, in imx_gpc_probe()
452 of_id_data->num_domains); in imx_gpc_probe()
462 ipg_clk = devm_clk_get(&pdev->dev, "ipg"); in imx_gpc_probe()
472 if (domain_index >= of_id_data->num_domains) in imx_gpc_probe()
475 pd_pdev = platform_device_alloc("imx-pgc-power-domain", in imx_gpc_probe()
478 return -ENOMEM; in imx_gpc_probe()
487 domain = pd_pdev->dev.platform_data; in imx_gpc_probe()
488 domain->regmap = regmap; in imx_gpc_probe()
489 domain->ipg_rate_mhz = ipg_rate_mhz; in imx_gpc_probe()
491 pd_pdev->dev.parent = &pdev->dev; in imx_gpc_probe()
492 pd_pdev->dev.of_node = np; in imx_gpc_probe()
493 pd_pdev->dev.fwnode = of_fwnode_handle(np); in imx_gpc_probe()
511 pgc_node = of_get_child_by_name(pdev->dev.of_node, "pgc"); in imx_gpc_remove()
514 if (!of_property_read_bool(pdev->dev.of_node, "#power-domain-cells") && in imx_gpc_remove()
520 * de-register the power domains in imx_gpc_remove()
523 of_genpd_del_provider(pdev->dev.of_node); in imx_gpc_remove()
527 dev_err(&pdev->dev, "Failed to remove PU power domain (%pe)\n", in imx_gpc_remove()
535 dev_err(&pdev->dev, "Failed to remove ARM power domain (%pe)\n", in imx_gpc_remove()
544 .name = "imx-gpc",