/* MN10300 Short delay interpolation routines1*2* Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.3* Written by David Howells ([email protected])4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of the GNU General Public Licence7* as published by the Free Software Foundation; either version8* 2 of the Licence, or (at your option) any later version.9*/10#include <linux/module.h>11#include <linux/sched.h>12#include <linux/delay.h>13#include <asm/div64.h>1415/*16* basic delay loop17*/18void __delay(unsigned long loops)19{20int d0;2122asm volatile(23" bra 1f \n"24" .align 4 \n"25"1: bra 2f \n"26" .align 4 \n"27"2: add -1,%0 \n"28" bne 2b \n"29: "=&d" (d0)30: "0" (loops)31: "cc");32}33EXPORT_SYMBOL(__delay);3435/*36* handle a delay specified in terms of microseconds37*/38void __udelay(unsigned long usecs)39{40unsigned long start, stop, cnt;4142/* usecs * CLK / 1E6 */43stop = __muldiv64u(usecs, MN10300_TSCCLK, 1000000);44start = TMTSCBC;4546do {47cnt = start - TMTSCBC;48} while (cnt < stop);49}50EXPORT_SYMBOL(__udelay);515253