/* Fetch the register value */
reg = readl(cpus->reg);
/* apply pre-divider first if parent is pll4 */ if (SUN9I_CPUS_MUX_GET_PARENT(reg) == SUN9I_CPUS_MUX_PARENT_PLL4)
parent_rate /= SUN9I_CPUS_PLL4_DIV_GET(reg) + 1;
/* * clock can only divide, so we will never be able to achieve * frequencies higher than the parent frequency
*/ if (parent_rate && rate > parent_rate)
rate = parent_rate;
div = DIV_ROUND_UP(parent_rate, rate);
/* calculate pre-divider if parent is pll4 */ if (parent == SUN9I_CPUS_MUX_PARENT_PLL4 && div > 4) { /* pre-divider is 1 ~ 32 */ if (div < 32) {
pre_div = div;
div = 1;
} elseif (div < 64) {
pre_div = DIV_ROUND_UP(div, 2);
div = 2;
} elseif (div < 96) {
pre_div = DIV_ROUND_UP(div, 3);
div = 3;
} else {
pre_div = DIV_ROUND_UP(div, 4);
div = 4;
}
}
/* we were asked to pass back divider values */ if (divp) {
*divp = div - 1;
*pre_divp = pre_div - 1;
}
return parent_rate / pre_div / div;
}
staticint sun9i_a80_cpus_clk_determine_rate(struct clk_hw *clk, struct clk_rate_request *req)
{ struct clk_hw *parent, *best_parent = NULL; int i, num_parents; unsignedlong parent_rate, best = 0, child_rate, best_child_rate = 0; unsignedlong rate = req->rate;
/* find the parent that can help provide the fastest rate <= rate */
num_parents = clk_hw_get_num_parents(clk); for (i = 0; i < num_parents; i++) {
parent = clk_hw_get_parent_by_index(clk, i); if (!parent) continue; if (clk_hw_get_flags(clk) & CLK_SET_RATE_PARENT)
parent_rate = clk_hw_round_rate(parent, rate); else
parent_rate = clk_hw_get_rate(parent);
child_rate = sun9i_a80_cpus_clk_round(rate, NULL, NULL, i,
parent_rate);
if (child_rate <= rate && child_rate > best_child_rate) {
best_parent = parent;
best = parent_rate;
best_child_rate = child_rate;
}
}
/* need to know which parent is used to apply pre-divider */
parent = SUN9I_CPUS_MUX_GET_PARENT(reg);
sun9i_a80_cpus_clk_round(rate, &div, &pre_div, parent, parent_rate);
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.