Lines Matching full:pg
644 static void tegra_powergate_disable_clocks(struct tegra_powergate *pg) in tegra_powergate_disable_clocks() argument
648 for (i = 0; i < pg->num_clks; i++) in tegra_powergate_disable_clocks()
649 clk_disable_unprepare(pg->clks[i]); in tegra_powergate_disable_clocks()
652 static int tegra_powergate_enable_clocks(struct tegra_powergate *pg) in tegra_powergate_enable_clocks() argument
657 for (i = 0; i < pg->num_clks; i++) { in tegra_powergate_enable_clocks()
658 err = clk_prepare_enable(pg->clks[i]); in tegra_powergate_enable_clocks()
667 clk_disable_unprepare(pg->clks[i]); in tegra_powergate_enable_clocks()
677 static int tegra_powergate_power_up(struct tegra_powergate *pg, in tegra_powergate_power_up() argument
682 err = reset_control_assert(pg->reset); in tegra_powergate_power_up()
688 err = tegra_powergate_set(pg->pmc, pg->id, true); in tegra_powergate_power_up()
694 err = tegra_powergate_enable_clocks(pg); in tegra_powergate_power_up()
700 err = __tegra_powergate_remove_clamping(pg->pmc, pg->id); in tegra_powergate_power_up()
706 err = reset_control_deassert(pg->reset); in tegra_powergate_power_up()
712 if (pg->pmc->soc->needs_mbist_war) in tegra_powergate_power_up()
713 err = tegra210_clk_handle_mbist_war(pg->id); in tegra_powergate_power_up()
718 tegra_powergate_disable_clocks(pg); in tegra_powergate_power_up()
723 tegra_powergate_disable_clocks(pg); in tegra_powergate_power_up()
727 tegra_powergate_set(pg->pmc, pg->id, false); in tegra_powergate_power_up()
732 static int tegra_powergate_power_down(struct tegra_powergate *pg) in tegra_powergate_power_down() argument
736 err = tegra_powergate_enable_clocks(pg); in tegra_powergate_power_down()
742 err = reset_control_assert(pg->reset); in tegra_powergate_power_down()
748 tegra_powergate_disable_clocks(pg); in tegra_powergate_power_down()
752 err = tegra_powergate_set(pg->pmc, pg->id, false); in tegra_powergate_power_down()
759 tegra_powergate_enable_clocks(pg); in tegra_powergate_power_down()
761 reset_control_deassert(pg->reset); in tegra_powergate_power_down()
765 tegra_powergate_disable_clocks(pg); in tegra_powergate_power_down()
772 struct tegra_powergate *pg = to_powergate(domain); in tegra_genpd_power_on() local
773 struct device *dev = pg->pmc->dev; in tegra_genpd_power_on()
776 err = tegra_powergate_power_up(pg, true); in tegra_genpd_power_on()
779 pg->genpd.name, err); in tegra_genpd_power_on()
783 reset_control_release(pg->reset); in tegra_genpd_power_on()
791 struct tegra_powergate *pg = to_powergate(domain); in tegra_genpd_power_off() local
792 struct device *dev = pg->pmc->dev; in tegra_genpd_power_off()
795 err = reset_control_acquire(pg->reset); in tegra_genpd_power_off()
801 err = tegra_powergate_power_down(pg); in tegra_genpd_power_off()
804 pg->genpd.name, err); in tegra_genpd_power_off()
805 reset_control_release(pg->reset); in tegra_genpd_power_off()
874 struct tegra_powergate *pg; in tegra_powergate_sequence_power_up() local
880 pg = kzalloc(sizeof(*pg), GFP_KERNEL); in tegra_powergate_sequence_power_up()
881 if (!pg) in tegra_powergate_sequence_power_up()
884 pg->id = id; in tegra_powergate_sequence_power_up()
885 pg->clks = &clk; in tegra_powergate_sequence_power_up()
886 pg->num_clks = 1; in tegra_powergate_sequence_power_up()
887 pg->reset = rst; in tegra_powergate_sequence_power_up()
888 pg->pmc = pmc; in tegra_powergate_sequence_power_up()
890 err = tegra_powergate_power_up(pg, false); in tegra_powergate_sequence_power_up()
895 kfree(pg); in tegra_powergate_sequence_power_up()
1030 static int tegra_powergate_of_get_clks(struct tegra_powergate *pg, in tegra_powergate_of_get_clks() argument
1041 pg->clks = kcalloc(count, sizeof(clk), GFP_KERNEL); in tegra_powergate_of_get_clks()
1042 if (!pg->clks) in tegra_powergate_of_get_clks()
1046 pg->clks[i] = of_clk_get(np, i); in tegra_powergate_of_get_clks()
1047 if (IS_ERR(pg->clks[i])) { in tegra_powergate_of_get_clks()
1048 err = PTR_ERR(pg->clks[i]); in tegra_powergate_of_get_clks()
1053 pg->num_clks = count; in tegra_powergate_of_get_clks()
1059 clk_put(pg->clks[i]); in tegra_powergate_of_get_clks()
1061 kfree(pg->clks); in tegra_powergate_of_get_clks()
1066 static int tegra_powergate_of_get_resets(struct tegra_powergate *pg, in tegra_powergate_of_get_resets() argument
1069 struct device *dev = pg->pmc->dev; in tegra_powergate_of_get_resets()
1072 pg->reset = of_reset_control_array_get_exclusive_released(np); in tegra_powergate_of_get_resets()
1073 if (IS_ERR(pg->reset)) { in tegra_powergate_of_get_resets()
1074 err = PTR_ERR(pg->reset); in tegra_powergate_of_get_resets()
1079 err = reset_control_acquire(pg->reset); in tegra_powergate_of_get_resets()
1086 err = reset_control_assert(pg->reset); in tegra_powergate_of_get_resets()
1088 err = reset_control_deassert(pg->reset); in tegra_powergate_of_get_resets()
1092 reset_control_release(pg->reset); in tegra_powergate_of_get_resets()
1097 reset_control_release(pg->reset); in tegra_powergate_of_get_resets()
1098 reset_control_put(pg->reset); in tegra_powergate_of_get_resets()
1107 struct tegra_powergate *pg; in tegra_powergate_add() local
1111 pg = kzalloc(sizeof(*pg), GFP_KERNEL); in tegra_powergate_add()
1112 if (!pg) in tegra_powergate_add()
1128 pg->id = id; in tegra_powergate_add()
1129 pg->genpd.name = np->name; in tegra_powergate_add()
1130 pg->genpd.power_off = tegra_genpd_power_off; in tegra_powergate_add()
1131 pg->genpd.power_on = tegra_genpd_power_on; in tegra_powergate_add()
1132 pg->pmc = pmc; in tegra_powergate_add()
1134 off = !tegra_powergate_is_powered(pmc, pg->id); in tegra_powergate_add()
1136 err = tegra_powergate_of_get_clks(pg, np); in tegra_powergate_add()
1142 err = tegra_powergate_of_get_resets(pg, np, off); in tegra_powergate_add()
1150 WARN_ON(tegra_powergate_power_up(pg, true)); in tegra_powergate_add()
1155 err = pm_genpd_init(&pg->genpd, NULL, off); in tegra_powergate_add()
1162 err = of_genpd_add_provider_simple(np, &pg->genpd); in tegra_powergate_add()
1169 dev_dbg(dev, "added PM domain %s\n", pg->genpd.name); in tegra_powergate_add()
1174 pm_genpd_remove(&pg->genpd); in tegra_powergate_add()
1177 reset_control_put(pg->reset); in tegra_powergate_add()
1180 while (pg->num_clks--) in tegra_powergate_add()
1181 clk_put(pg->clks[pg->num_clks]); in tegra_powergate_add()
1183 kfree(pg->clks); in tegra_powergate_add()
1189 kfree(pg); in tegra_powergate_add()
1219 struct tegra_powergate *pg = to_powergate(genpd); in tegra_powergate_remove() local
1221 reset_control_put(pg->reset); in tegra_powergate_remove()
1223 while (pg->num_clks--) in tegra_powergate_remove()
1224 clk_put(pg->clks[pg->num_clks]); in tegra_powergate_remove()
1226 kfree(pg->clks); in tegra_powergate_remove()
1228 set_bit(pg->id, pmc->powergates_available); in tegra_powergate_remove()
1230 kfree(pg); in tegra_powergate_remove()