/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 2007 by Ralf Baechle * Copyright (C) 2009, 2012 Cavium, Inc.
*/ #include <linux/clocksource.h> #include <linux/sched/clock.h> #include <linux/export.h> #include <linux/init.h> #include <linux/smp.h>
void __init octeon_setup_delays(void)
{
octeon_udelay_factor = octeon_get_clock_rate() / 1000000; /* * For __ndelay we divide by 2^16, so the factor is multiplied * by the same amount.
*/
octeon_ndelay_factor = (octeon_udelay_factor * 0x10000ull) / 1000ull;
preset_lpj = octeon_get_clock_rate() / HZ;
if (current_cpu_type() == CPU_CAVIUM_OCTEON2) { union cvmx_mio_rst_boot rst_boot;
/* * Set the current core's cvmcount counter to the value of the * IPD_CLK_COUNT. We do this on all cores as they are brought * on-line. This allows for a read from a local cpu register to * access a synchronized counter. * * On CPU_CAVIUM_OCTEON2 the IPD_CLK_COUNT is scaled by rdiv/sdiv.
*/ void octeon_init_cvmcount(void)
{
u64 clk_reg; unsignedlong flags; unsigned loops = 2;
/* Clobber loops so GCC will not unroll the following while loop. */ asm("" : "+r" (loops));
local_irq_save(flags); /* * Loop several times so we are executing from the cache, * which should give more deterministic timing.
*/ while (loops--) {
u64 clk_count = cvmx_read_csr(clk_reg); if (rdiv != 0) {
clk_count *= rdiv; if (f != 0) { asm("dmultu\t%[cnt],%[f]\n\t" "mfhi\t%[cnt]"
: [cnt] "+r" (clk_count)
: [f] "r" (f)
: "hi", "lo");
}
}
write_c0_cvmcount(clk_count);
}
local_irq_restore(flags);
}
inc = ((ns * octeon_ndelay_factor) >> 16);
end = cur + inc;
while (end > cur)
cur = read_c0_cvmcount();
}
EXPORT_SYMBOL(__ndelay);
void __delay(unsignedlong loops)
{
u64 cur, end;
cur = read_c0_cvmcount();
end = cur + loops;
while (end > cur)
cur = read_c0_cvmcount();
}
EXPORT_SYMBOL(__delay);
/** * octeon_io_clk_delay - wait for a given number of io clock cycles to pass. * * We scale the wait by the clock ratio, and then wait for the * corresponding number of core clocks. * * @count: The number of clocks to wait.
*/ void octeon_io_clk_delay(unsignedlong count)
{
u64 cur, end;
cur = read_c0_cvmcount(); if (rdiv != 0) {
end = count * rdiv; if (f != 0) { asm("dmultu\t%[cnt],%[f]\n\t" "mfhi\t%[cnt]"
: [cnt] "+r" (end)
: [f] "r" (f)
: "hi", "lo");
}
end = cur + end;
} else {
end = cur + count;
} while (end > cur)
cur = read_c0_cvmcount();
}
EXPORT_SYMBOL(octeon_io_clk_delay);
Messung V0.5
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet)
¤
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.