2 * Copied from <file:arch/powerpc/kernel/misc_32.S>
4 * This file contains miscellaneous low-level functions.
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
7 * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
11 * Copyright (C) 2002-2003 Eric Biederman <ebiederm@xmission.com>
12 * GameCube/ppc32 port Copyright (C) 2004 Albert Herranz
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
22 #define SPRN_PVR 0x11F /* Processor Version Register */
26 /* udelay (on non-601 processors) needs to know the period of the
27 * timebase in nanoseconds. This used to be hardcoded to be 60ns
28 * (period of 66MHz/4). Now a variable is used that is initialized to
29 * 60 for backward compatibility, but it can be overridden as necessary
30 * with code something like this:
31 * extern unsigned long timebase_period_ns;
32 * timebase_period_ns = 1000000000 / bd->bi_tbfreq;
35 .globl timebase_period_ns
41 * Delay for a number of microseconds
47 cmpwi 0,r4,1 /* 601 ? */
49 00: li r0,86 /* Instructions / microsecond? */
51 10: addi r0,r0,0 /* NOP */
58 mulli r4,r3,1000 /* nanoseconds */
59 /* Change r4 to be the number of ticks using:
60 * (nanoseconds + (timebase_period_ns - 1 )) / timebase_period_ns
61 * timebase_period_ns defaults to 60 (16.6MHz) */
68 subf r5,r5,r6 /* In case we're relocated */
69 addis r5,r5,timebase_period_ns@ha
70 lwz r5,timebase_period_ns@l(r5)
73 divw r4,r4,r5 /* BUS ticks */
79 1: mfspr r5, SPRN_TBRU
84 bne 1b /* Get [synced] base time */
85 addc r9,r6,r4 /* Compute end time */
90 2: mfspr r5, SPRN_TBRU