// SPDX-License-Identifier: GPL-2.0-only OR MIT /* * Driver for an SoC block (Numerically Controlled Oscillator) * found on t8103 (M1) and other Apple chips * * Copyright (C) The Asahi Linux Contributors
*/
/* * Theory of operation (postulated) * * The REG_DIV register indirectly expresses a base integer divisor, roughly * corresponding to twice the desired ratio of input to output clock. This * base divisor is adjusted on a cycle-by-cycle basis based on the state of a * 32-bit phase accumulator to achieve a desired precise clock ratio over the * long term. * * Specifically an output clock cycle is produced after (REG_DIV divisor)/2 * or (REG_DIV divisor + 1)/2 input cycles, the latter taking effect when top * bit of the 32-bit accumulator is set. The accumulator is incremented each * produced output cycle, by the value from either REG_INC1 or REG_INC2, which * of the two is selected depending again on the accumulator's current top bit. * * Because the NCO hardware implements counting of input clock cycles in part * in a Galois linear-feedback shift register, the higher bits of divisor * are programmed into REG_DIV by picking an appropriate LFSR state. See * applnco_compute_tables/applnco_div_translate for details on this.
*/
staticvoid applnco_compute_tables(struct applnco_tables *tbl)
{ int i;
u32 state = LFSR_INIT;
/* * Go through the states of a Galois LFSR and build * a coarse divisor translation table.
*/ for (i = LFSR_PERIOD; i > 0; i--) { if (state & 1)
state = (state >> 1) ^ (LFSR_POLY >> 1); else
state = (state >> 1);
tbl->fwd[i] = state;
tbl->inv[state] = i;
}
/* Zero value is special-cased */
tbl->fwd[0] = 0;
tbl->inv[0] = 0;
}
staticbool applnco_div_out_of_range(unsignedint div)
{ unsignedint coarse = div / 4;
/* * We don't support wraparound of accumulator * nor the edge case of both increments being zero
*/ if (inc1 >= (1 << 31) || inc2 < (1 << 31) || (inc1 == 0 && inc2 == 0)) return 0;
/* Scale both sides of division by incbase to maintain precision */
incbase = inc1 - inc2;
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.