/* * CCF assumes that neither the parent nor its rate will change during * ->set_rate(), so the parent rate passed in here was cached from the * parent before the ->set_rate() call. * * This can lead to wrong results being reported for the EMC clock if * the parent and/or parent rate have changed as part of the EMC rate * change sequence. Fix this by overriding the parent clock with what * we know to be the correct value after the rate change.
*/
parent_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
value = readl_relaxed(emc->regs + CLK_SOURCE_EMC);
div = FIELD_GET(CLK_SOURCE_EMC_2X_CLK_DIVISOR, value);
div += 2;
old = clk_hw_get_parent_by_index(hw, old_idx); new = clk_hw_get_parent_by_index(hw, new_idx);
/* if the rate has changed... */ if (config->parent_rate != clk_hw_get_rate(old)) { /* ... but the clock source remains the same ... */ if (new_idx == old_idx) { /* ... switch to the alternative clock source. */ switch (new_idx) { case CLK_SRC_PLLM:
new_idx = CLK_SRC_PLLMB; break;
case CLK_SRC_PLLM_UD:
new_idx = CLK_SRC_PLLMB_UD; break;
case CLK_SRC_PLLMB_UD:
new_idx = CLK_SRC_PLLM_UD; break;
case CLK_SRC_PLLMB:
new_idx = CLK_SRC_PLLM; break;
}
/* * This should never happen because we can't deal with * it.
*/ if (WARN_ON(new_idx == old_idx)) return -EINVAL;
new = clk_hw_get_parent_by_index(hw, new_idx);
}
index = new_idx;
parent = new;
} else {
index = old_idx;
parent = old;
}
clk = tegra210_clk_emc_find_parent(emc, index); if (IS_ERR(clk)) {
err = PTR_ERR(clk);
dev_err(dev, "failed to get parent clock for index %u: %d\n",
index, err); return err;
}
/* set the new parent clock to the required rate */ if (clk_get_rate(clk) != config->parent_rate) {
err = clk_set_rate(clk, config->parent_rate); if (err < 0) {
dev_err(dev, "failed to set rate %lu Hz for %pC: %d\n",
config->parent_rate, clk, err); return err;
}
}
/* enable the new parent clock */ if (parent != old) {
err = clk_prepare_enable(clk); if (err < 0) {
dev_err(dev, "failed to enable parent clock %pC: %d\n",
clk, err); return err;
}
}
/* update the EMC source configuration to reflect the new parent */
config->value &= ~CLK_SOURCE_EMC_2X_CLK_SRC;
config->value |= FIELD_PREP(CLK_SOURCE_EMC_2X_CLK_SRC, index);
/* * Finally, switch the EMC programming with both old and new parent * clocks enabled.
*/
err = provider->set_rate(dev, config); if (err < 0) {
dev_err(dev, "failed to set EMC rate to %lu Hz: %d\n", rate,
err);
/* * If we're unable to switch to the new EMC frequency, we no * longer need the new parent to be enabled.
*/ if (parent != old)
clk_disable_unprepare(clk);
return err;
}
/* reparent to new parent clock and disable the old parent clock */ if (parent != old) {
clk = tegra210_clk_emc_find_parent(emc, old_idx); if (IS_ERR(clk)) {
err = PTR_ERR(clk);
dev_err(dev, "failed to get parent clock for index %u: %d\n",
old_idx, err); return err;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.