Lines Matching refs:domain
133 struct imx_pgc_domain *domain = container_of(genpd,
139 const bool has_regulator = !IS_ERR(domain->regulator);
143 regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING,
144 domain->bits.map, domain->bits.map);
147 ret = regulator_enable(domain->regulator);
149 dev_err(domain->dev, "failed to enable regulator\n");
154 /* Enable reset clocks for all devices in the domain */
155 for (i = 0; i < domain->num_clks; i++)
156 clk_prepare_enable(domain->clk[i]);
159 regmap_update_bits(domain->regmap, GPC_PGC_CTRL(domain->pgc),
162 if (domain->bits.hsk)
163 regmap_update_bits(domain->regmap, GPC_PU_PWRHSK,
164 domain->bits.hsk, on ? domain->bits.hsk : 0);
166 regmap_update_bits(domain->regmap, offset,
167 domain->bits.pxx, domain->bits.pxx);
173 ret = regmap_read_poll_timeout(domain->regmap, offset, pxx_req,
174 !(pxx_req & domain->bits.pxx),
177 dev_err(domain->dev, "failed to command PGC\n");
180 * domain and failed we might as well disable
189 regmap_update_bits(domain->regmap, GPC_PGC_CTRL(domain->pgc),
192 /* Disable reset clocks for all devices in the domain */
193 for (i = 0; i < domain->num_clks; i++)
194 clk_disable_unprepare(domain->clk[i]);
199 err = regulator_disable(domain->regulator);
201 dev_err(domain->dev,
207 regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING,
208 domain->bits.map, 0);
446 static int imx_pgc_get_clocks(struct imx_pgc_domain *domain)
451 struct clk *clk = of_clk_get(domain->dev->of_node, i);
455 dev_err(domain->dev, "more than %d clocks\n",
460 domain->clk[i] = clk;
462 domain->num_clks = i;
468 clk_put(domain->clk[i]);
473 static void imx_pgc_put_clocks(struct imx_pgc_domain *domain)
477 for (i = domain->num_clks - 1; i >= 0; i--)
478 clk_put(domain->clk[i]);
483 struct imx_pgc_domain *domain = pdev->dev.platform_data;
486 domain->dev = &pdev->dev;
488 domain->regulator = devm_regulator_get_optional(domain->dev, "power");
489 if (IS_ERR(domain->regulator)) {
490 if (PTR_ERR(domain->regulator) != -ENODEV)
491 return dev_err_probe(domain->dev, PTR_ERR(domain->regulator),
492 "Failed to get domain's regulator\n");
493 } else if (domain->voltage) {
494 regulator_set_voltage(domain->regulator,
495 domain->voltage, domain->voltage);
498 ret = imx_pgc_get_clocks(domain);
500 return dev_err_probe(domain->dev, ret, "Failed to get domain's clocks\n");
502 ret = pm_genpd_init(&domain->genpd, NULL, true);
504 dev_err(domain->dev, "Failed to init power domain\n");
505 imx_pgc_put_clocks(domain);
509 ret = of_genpd_add_provider_simple(domain->dev->of_node,
510 &domain->genpd);
512 dev_err(domain->dev, "Failed to add genpd provider\n");
513 pm_genpd_remove(&domain->genpd);
514 imx_pgc_put_clocks(domain);
522 struct imx_pgc_domain *domain = pdev->dev.platform_data;
524 of_genpd_del_provider(domain->dev->of_node);
525 pm_genpd_remove(&domain->genpd);
526 imx_pgc_put_clocks(domain);
532 { "imx-pgc-domain", },
584 struct imx_pgc_domain *domain;
601 pd_pdev = platform_device_alloc("imx-pgc-domain",
618 domain = pd_pdev->dev.platform_data;
619 domain->regmap = regmap;
620 domain->genpd.power_on = imx_gpc_pu_pgc_sw_pup_req;
621 domain->genpd.power_off = imx_gpc_pu_pgc_sw_pdn_req;