1d0a533b1SWill Deacon/* 2d0a533b1SWill Deacon * linux/arch/arm/lib/delay.S 3d0a533b1SWill Deacon * 4d0a533b1SWill Deacon * Copyright (C) 1995, 1996 Russell King 5d0a533b1SWill Deacon * 6d0a533b1SWill Deacon * This program is free software; you can redistribute it and/or modify 7d0a533b1SWill Deacon * it under the terms of the GNU General Public License version 2 as 8d0a533b1SWill Deacon * published by the Free Software Foundation. 9d0a533b1SWill Deacon */ 10d0a533b1SWill Deacon#include <linux/linkage.h> 11d0a533b1SWill Deacon#include <asm/assembler.h> 12d0a533b1SWill Deacon#include <asm/delay.h> 13d0a533b1SWill Deacon .text 14d0a533b1SWill Deacon 15d0a533b1SWill Deacon.LC0: .word loops_per_jiffy 16d0a533b1SWill Deacon.LC1: .word UDELAY_MULT 17d0a533b1SWill Deacon 18d0a533b1SWill Deacon/* 19d0a533b1SWill Deacon * r0 <= 2000 20d0a533b1SWill Deacon * lpj <= 0x01ffffff (max. 3355 bogomips) 21d0a533b1SWill Deacon * HZ <= 1000 22d0a533b1SWill Deacon */ 23d0a533b1SWill Deacon 24d0a533b1SWill DeaconENTRY(__loop_udelay) 25d0a533b1SWill Deacon ldr r2, .LC1 26d0a533b1SWill Deacon mul r0, r2, r0 27d0a533b1SWill DeaconENTRY(__loop_const_udelay) @ 0 <= r0 <= 0x7fffff06 28d0a533b1SWill Deacon mov r1, #-1 29d0a533b1SWill Deacon ldr r2, .LC0 30d0a533b1SWill Deacon ldr r2, [r2] @ max = 0x01ffffff 31d0a533b1SWill Deacon add r0, r0, r1, lsr #32-14 32d0a533b1SWill Deacon mov r0, r0, lsr #14 @ max = 0x0001ffff 33d0a533b1SWill Deacon add r2, r2, r1, lsr #32-10 34d0a533b1SWill Deacon mov r2, r2, lsr #10 @ max = 0x00007fff 35d0a533b1SWill Deacon mul r0, r2, r0 @ max = 2^32-1 36d0a533b1SWill Deacon add r0, r0, r1, lsr #32-6 37d0a533b1SWill Deacon movs r0, r0, lsr #6 38d0a533b1SWill Deacon moveq pc, lr 39d0a533b1SWill Deacon 40d0a533b1SWill Deacon/* 41d0a533b1SWill Deacon * loops = r0 * HZ * loops_per_jiffy / 1000000 42d0a533b1SWill Deacon */ 43*11d4bb1bSFabio Estevam .align 3 44d0a533b1SWill Deacon 45d0a533b1SWill Deacon@ Delay routine 46d0a533b1SWill DeaconENTRY(__loop_delay) 47d0a533b1SWill Deacon subs r0, r0, #1 48d0a533b1SWill Deacon#if 0 49d0a533b1SWill Deacon movls pc, lr 50d0a533b1SWill Deacon subs r0, r0, #1 51d0a533b1SWill Deacon movls pc, lr 52d0a533b1SWill Deacon subs r0, r0, #1 53d0a533b1SWill Deacon movls pc, lr 54d0a533b1SWill Deacon subs r0, r0, #1 55d0a533b1SWill Deacon movls pc, lr 56d0a533b1SWill Deacon subs r0, r0, #1 57d0a533b1SWill Deacon movls pc, lr 58d0a533b1SWill Deacon subs r0, r0, #1 59d0a533b1SWill Deacon movls pc, lr 60d0a533b1SWill Deacon subs r0, r0, #1 61d0a533b1SWill Deacon movls pc, lr 62d0a533b1SWill Deacon subs r0, r0, #1 63d0a533b1SWill Deacon#endif 64d0a533b1SWill Deacon bhi __loop_delay 65d0a533b1SWill Deacon mov pc, lr 66d0a533b1SWill DeaconENDPROC(__loop_udelay) 67d0a533b1SWill DeaconENDPROC(__loop_const_udelay) 68d0a533b1SWill DeaconENDPROC(__loop_delay) 69