/* * List of clock sources for various parents the EMC clock can have. * When we change the timing to a timing with a parent that has the same * clock source as the current parent, we must first change to a backup * timing that has a different clock source.
*/
/* * CCF wrongly assumes that the parent won't change during set_rate, * so get the parent rate explicitly.
*/
parent_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
val = readl(tegra->clk_regs + CLK_SOURCE_EMC);
div = val & CLK_SOURCE_EMC_EMC_2X_CLK_DIVISOR_MASK;
return parent_rate / (div + 2) * 2;
}
/* * Rounds up unless no higher rate exists, in which case down. This way is * safer since things have EMC rate floors. Also don't touch parent_rate * since we don't want the CCF to play with our parent clocks.
*/ staticint emc_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
{ struct tegra_clk_emc *tegra;
u8 ram_code = tegra_read_ram_code(); struct emc_timing *timing = NULL; int i, k, t;
/* * Get backup timing to use as an intermediate step when a change between * two timings with the same clock source has been requested. First try to * find a timing with a higher clock rate to avoid a rate below any set rate * floors. If that is not possible, find a lower rate.
*/ staticstruct emc_timing *get_backup_timing(struct tegra_clk_emc *tegra, int timing_index)
{ int i;
u32 ram_code = tegra_read_ram_code(); struct emc_timing *timing;
for (i = timing_index+1; i < tegra->num_timings; i++) {
timing = tegra->timings + i; if (timing->ram_code != ram_code) break;
if (emc_parent_clk_sources[timing->parent_index] !=
emc_parent_clk_sources[
tegra->timings[timing_index].parent_index]) return timing;
}
for (i = timing_index-1; i >= 0; --i) {
timing = tegra->timings + i; if (timing->ram_code != ram_code) break;
if (emc_parent_clk_sources[timing->parent_index] !=
emc_parent_clk_sources[
tegra->timings[timing_index].parent_index]) return timing;
}
/* * When emc_set_timing changes the parent rate, CCF will propagate * that downward to us, so ignore any set_rate calls while a rate * change is already going on.
*/ if (tegra->changing_timing) return 0;
for (i = 0; i < tegra->num_timings; i++) { if (tegra->timings[i].rate == rate &&
tegra->timings[i].ram_code == ram_code) {
timing = tegra->timings + i; break;
}
}
if (!timing) {
pr_err("cannot switch to rate %ld without emc table\n", rate); return -EINVAL;
}
if (emc_parent_clk_sources[emc_get_parent(hw)] ==
emc_parent_clk_sources[timing->parent_index] &&
clk_get_rate(timing->parent) != timing->parent_rate) { /* * Parent clock source not changed but parent rate has changed, * need to temporarily switch to another parent
*/
err = of_property_read_u32(node, "clock-frequency", &tmp); if (err) {
pr_err("timing %pOF: failed to read rate\n", node); return err;
}
timing->rate = tmp;
err = of_property_read_u32(node, "nvidia,parent-clock-frequency", &tmp); if (err) {
pr_err("timing %pOF: failed to read parent rate\n", node); return err;
}
timing->parent_rate = tmp;
timing->parent = of_clk_get_by_name(node, "emc-parent"); if (IS_ERR(timing->parent)) {
pr_err("timing %pOF: failed to get parent clock\n", node); return PTR_ERR(timing->parent);
}
timing->parent_index = 0xff;
i = match_string(emc_parent_clk_names, ARRAY_SIZE(emc_parent_clk_names),
__clk_get_name(timing->parent)); if (i < 0) {
pr_err("timing %pOF: %s is not a valid parent\n",
node, __clk_get_name(timing->parent));
clk_put(timing->parent); return -EINVAL;
}
/* * Store timings for all ram codes as we cannot read the * fuses until the apbmisc driver is loaded.
*/
err = load_timings_from_dt(tegra, node, node_ram_code); if (err) {
of_node_put(node);
kfree(tegra); return ERR_PTR(err);
}
}
if (tegra->num_timings == 0)
pr_warn("%s: no memory timings registered\n", __func__);
tegra->emc_node = of_parse_phandle(np, "nvidia,external-memory-controller", 0); if (!tegra->emc_node)
pr_warn("%s: couldn't find node for EMC driver\n", __func__);
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.