1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copied from <file:arch/powerpc/kernel/misc_32.S>
5 * This file contains miscellaneous low-level functions.
6 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
8 * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
12 * Copyright (C) 2002-2003 Eric Biederman <ebiederm@xmission.com>
13 * GameCube/ppc32 port Copyright (C) 2004 Albert Herranz
17 #define SPRN_PVR 0x11F /* Processor Version Register */
21 /* udelay (on non-601 processors) needs to know the period of the
22 * timebase in nanoseconds. This used to be hardcoded to be 60ns
23 * (period of 66MHz/4). Now a variable is used that is initialized to
24 * 60 for backward compatibility, but it can be overridden as necessary
25 * with code something like this:
26 * extern unsigned long timebase_period_ns;
27 * timebase_period_ns = 1000000000 / bd->bi_tbfreq;
30 .globl timebase_period_ns
36 * Delay for a number of microseconds
42 cmpwi 0,r4,1 /* 601 ? */
44 00: li r0,86 /* Instructions / microsecond? */
46 10: addi r0,r0,0 /* NOP */
53 mulli r4,r3,1000 /* nanoseconds */
54 /* Change r4 to be the number of ticks using:
55 * (nanoseconds + (timebase_period_ns - 1 )) / timebase_period_ns
56 * timebase_period_ns defaults to 60 (16.6MHz) */
63 subf r5,r5,r6 /* In case we're relocated */
64 addis r5,r5,timebase_period_ns@ha
65 lwz r5,timebase_period_ns@l(r5)
68 divw r4,r4,r5 /* BUS ticks */
73 bne 1b /* Get [synced] base time */
74 addc r9,r6,r4 /* Compute end time */