Lines Matching full:pg

589 static void tegra_powergate_disable_clocks(struct tegra_powergate *pg)  in tegra_powergate_disable_clocks()  argument
593 for (i = 0; i < pg->num_clks; i++) in tegra_powergate_disable_clocks()
594 clk_disable_unprepare(pg->clks[i]); in tegra_powergate_disable_clocks()
597 static int tegra_powergate_enable_clocks(struct tegra_powergate *pg) in tegra_powergate_enable_clocks() argument
602 for (i = 0; i < pg->num_clks; i++) { in tegra_powergate_enable_clocks()
603 err = clk_prepare_enable(pg->clks[i]); in tegra_powergate_enable_clocks()
612 clk_disable_unprepare(pg->clks[i]); in tegra_powergate_enable_clocks()
622 static int tegra_powergate_power_up(struct tegra_powergate *pg, in tegra_powergate_power_up() argument
627 err = reset_control_assert(pg->reset); in tegra_powergate_power_up()
633 err = tegra_powergate_set(pg->pmc, pg->id, true); in tegra_powergate_power_up()
639 err = tegra_powergate_enable_clocks(pg); in tegra_powergate_power_up()
645 err = __tegra_powergate_remove_clamping(pg->pmc, pg->id); in tegra_powergate_power_up()
651 err = reset_control_deassert(pg->reset); in tegra_powergate_power_up()
657 if (pg->pmc->soc->needs_mbist_war) in tegra_powergate_power_up()
658 err = tegra210_clk_handle_mbist_war(pg->id); in tegra_powergate_power_up()
663 tegra_powergate_disable_clocks(pg); in tegra_powergate_power_up()
668 tegra_powergate_disable_clocks(pg); in tegra_powergate_power_up()
672 tegra_powergate_set(pg->pmc, pg->id, false); in tegra_powergate_power_up()
677 static int tegra_powergate_power_down(struct tegra_powergate *pg) in tegra_powergate_power_down() argument
681 err = tegra_powergate_enable_clocks(pg); in tegra_powergate_power_down()
687 err = reset_control_assert(pg->reset); in tegra_powergate_power_down()
693 tegra_powergate_disable_clocks(pg); in tegra_powergate_power_down()
697 err = tegra_powergate_set(pg->pmc, pg->id, false); in tegra_powergate_power_down()
704 tegra_powergate_enable_clocks(pg); in tegra_powergate_power_down()
706 reset_control_deassert(pg->reset); in tegra_powergate_power_down()
710 tegra_powergate_disable_clocks(pg); in tegra_powergate_power_down()
717 struct tegra_powergate *pg = to_powergate(domain); in tegra_genpd_power_on() local
718 struct device *dev = pg->pmc->dev; in tegra_genpd_power_on()
721 err = tegra_powergate_power_up(pg, true); in tegra_genpd_power_on()
724 pg->genpd.name, err); in tegra_genpd_power_on()
728 reset_control_release(pg->reset); in tegra_genpd_power_on()
736 struct tegra_powergate *pg = to_powergate(domain); in tegra_genpd_power_off() local
737 struct device *dev = pg->pmc->dev; in tegra_genpd_power_off()
740 err = reset_control_acquire(pg->reset); in tegra_genpd_power_off()
746 err = tegra_powergate_power_down(pg); in tegra_genpd_power_off()
749 pg->genpd.name, err); in tegra_genpd_power_off()
750 reset_control_release(pg->reset); in tegra_genpd_power_off()
819 struct tegra_powergate *pg; in tegra_powergate_sequence_power_up() local
825 pg = kzalloc(sizeof(*pg), GFP_KERNEL); in tegra_powergate_sequence_power_up()
826 if (!pg) in tegra_powergate_sequence_power_up()
829 pg->id = id; in tegra_powergate_sequence_power_up()
830 pg->clks = &clk; in tegra_powergate_sequence_power_up()
831 pg->num_clks = 1; in tegra_powergate_sequence_power_up()
832 pg->reset = rst; in tegra_powergate_sequence_power_up()
833 pg->pmc = pmc; in tegra_powergate_sequence_power_up()
835 err = tegra_powergate_power_up(pg, false); in tegra_powergate_sequence_power_up()
840 kfree(pg); in tegra_powergate_sequence_power_up()
975 static int tegra_powergate_of_get_clks(struct tegra_powergate *pg, in tegra_powergate_of_get_clks() argument
986 pg->clks = kcalloc(count, sizeof(clk), GFP_KERNEL); in tegra_powergate_of_get_clks()
987 if (!pg->clks) in tegra_powergate_of_get_clks()
991 pg->clks[i] = of_clk_get(np, i); in tegra_powergate_of_get_clks()
992 if (IS_ERR(pg->clks[i])) { in tegra_powergate_of_get_clks()
993 err = PTR_ERR(pg->clks[i]); in tegra_powergate_of_get_clks()
998 pg->num_clks = count; in tegra_powergate_of_get_clks()
1004 clk_put(pg->clks[i]); in tegra_powergate_of_get_clks()
1006 kfree(pg->clks); in tegra_powergate_of_get_clks()
1011 static int tegra_powergate_of_get_resets(struct tegra_powergate *pg, in tegra_powergate_of_get_resets() argument
1014 struct device *dev = pg->pmc->dev; in tegra_powergate_of_get_resets()
1017 pg->reset = of_reset_control_array_get_exclusive_released(np); in tegra_powergate_of_get_resets()
1018 if (IS_ERR(pg->reset)) { in tegra_powergate_of_get_resets()
1019 err = PTR_ERR(pg->reset); in tegra_powergate_of_get_resets()
1024 err = reset_control_acquire(pg->reset); in tegra_powergate_of_get_resets()
1031 err = reset_control_assert(pg->reset); in tegra_powergate_of_get_resets()
1033 err = reset_control_deassert(pg->reset); in tegra_powergate_of_get_resets()
1037 reset_control_release(pg->reset); in tegra_powergate_of_get_resets()
1042 reset_control_release(pg->reset); in tegra_powergate_of_get_resets()
1043 reset_control_put(pg->reset); in tegra_powergate_of_get_resets()
1052 struct tegra_powergate *pg; in tegra_powergate_add() local
1056 pg = kzalloc(sizeof(*pg), GFP_KERNEL); in tegra_powergate_add()
1057 if (!pg) in tegra_powergate_add()
1073 pg->id = id; in tegra_powergate_add()
1074 pg->genpd.name = np->name; in tegra_powergate_add()
1075 pg->genpd.power_off = tegra_genpd_power_off; in tegra_powergate_add()
1076 pg->genpd.power_on = tegra_genpd_power_on; in tegra_powergate_add()
1077 pg->pmc = pmc; in tegra_powergate_add()
1079 off = !tegra_powergate_is_powered(pmc, pg->id); in tegra_powergate_add()
1081 err = tegra_powergate_of_get_clks(pg, np); in tegra_powergate_add()
1087 err = tegra_powergate_of_get_resets(pg, np, off); in tegra_powergate_add()
1095 WARN_ON(tegra_powergate_power_up(pg, true)); in tegra_powergate_add()
1100 err = pm_genpd_init(&pg->genpd, NULL, off); in tegra_powergate_add()
1107 err = of_genpd_add_provider_simple(np, &pg->genpd); in tegra_powergate_add()
1114 dev_dbg(dev, "added PM domain %s\n", pg->genpd.name); in tegra_powergate_add()
1119 pm_genpd_remove(&pg->genpd); in tegra_powergate_add()
1122 reset_control_put(pg->reset); in tegra_powergate_add()
1125 while (pg->num_clks--) in tegra_powergate_add()
1126 clk_put(pg->clks[pg->num_clks]); in tegra_powergate_add()
1128 kfree(pg->clks); in tegra_powergate_add()
1134 kfree(pg); in tegra_powergate_add()
1164 struct tegra_powergate *pg = to_powergate(genpd); in tegra_powergate_remove() local
1166 reset_control_put(pg->reset); in tegra_powergate_remove()
1168 while (pg->num_clks--) in tegra_powergate_remove()
1169 clk_put(pg->clks[pg->num_clks]); in tegra_powergate_remove()
1171 kfree(pg->clks); in tegra_powergate_remove()
1173 set_bit(pg->id, pmc->powergates_available); in tegra_powergate_remove()
1175 kfree(pg); in tegra_powergate_remove()