1d2912cb1SThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-only */ 2d0a533b1SWill Deacon/* 3d0a533b1SWill Deacon * linux/arch/arm/lib/delay.S 4d0a533b1SWill Deacon * 5d0a533b1SWill Deacon * Copyright (C) 1995, 1996 Russell King 6d0a533b1SWill Deacon */ 7d0a533b1SWill Deacon#include <linux/linkage.h> 8*7339fb11SLinus Walleij#include <linux/cfi_types.h> 9d0a533b1SWill Deacon#include <asm/assembler.h> 10d0a533b1SWill Deacon#include <asm/delay.h> 11215e362dSNicolas Pitre 12a2faac39SNick Desaulniers#ifdef CONFIG_ARCH_RPC 13a2faac39SNick Desaulniers .arch armv4 14a2faac39SNick Desaulniers#endif 15a2faac39SNick Desaulniers 16d0a533b1SWill Deacon .text 17d0a533b1SWill Deacon 18d0a533b1SWill Deacon.LC0: .word loops_per_jiffy 19d0a533b1SWill Deacon.LC1: .word UDELAY_MULT 20d0a533b1SWill Deacon 21d0a533b1SWill Deacon/* 22207b1150SNicolas Pitre * loops = r0 * HZ * loops_per_jiffy / 1000000 23207b1150SNicolas Pitre * 24d0a533b1SWill Deacon * r0 <= 2000 25d0a533b1SWill Deacon * HZ <= 1000 26d0a533b1SWill Deacon */ 27d0a533b1SWill Deacon 28*7339fb11SLinus WalleijSYM_TYPED_FUNC_START(__loop_udelay) 29d0a533b1SWill Deacon ldr r2, .LC1 30207b1150SNicolas Pitre mul r0, r2, r0 @ r0 = delay_us * UDELAY_MULT 31*7339fb11SLinus Walleij b __loop_const_udelay 32*7339fb11SLinus WalleijSYM_FUNC_END(__loop_udelay) 33*7339fb11SLinus Walleij 34*7339fb11SLinus WalleijSYM_TYPED_FUNC_START(__loop_const_udelay) @ 0 <= r0 <= 0xfffffaf0 35d0a533b1SWill Deacon ldr r2, .LC0 36215e362dSNicolas Pitre ldr r2, [r2] 37207b1150SNicolas Pitre umull r1, r0, r2, r0 @ r0-r1 = r0 * loops_per_jiffy 38207b1150SNicolas Pitre adds r1, r1, #0xffffffff @ rounding up ... 39207b1150SNicolas Pitre adcs r0, r0, r0 @ and right shift by 31 406ebbf2ceSRussell King reteq lr 41*7339fb11SLinus Walleij b __loop_delay 42*7339fb11SLinus WalleijSYM_FUNC_END(__loop_const_udelay) 43d0a533b1SWill Deacon 4411d4bb1bSFabio Estevam .align 3 45d0a533b1SWill Deacon 46d0a533b1SWill Deacon@ Delay routine 47*7339fb11SLinus WalleijSYM_TYPED_FUNC_START(__loop_delay) 48d0a533b1SWill Deacon subs r0, r0, #1 49d0a533b1SWill Deacon#if 0 506ebbf2ceSRussell King retls lr 51d0a533b1SWill Deacon subs r0, r0, #1 526ebbf2ceSRussell King retls lr 53d0a533b1SWill Deacon subs r0, r0, #1 546ebbf2ceSRussell King retls lr 55d0a533b1SWill Deacon subs r0, r0, #1 566ebbf2ceSRussell King retls lr 57d0a533b1SWill Deacon subs r0, r0, #1 586ebbf2ceSRussell King retls lr 59d0a533b1SWill Deacon subs r0, r0, #1 606ebbf2ceSRussell King retls lr 61d0a533b1SWill Deacon subs r0, r0, #1 626ebbf2ceSRussell King retls lr 63d0a533b1SWill Deacon subs r0, r0, #1 64d0a533b1SWill Deacon#endif 65d0a533b1SWill Deacon bhi __loop_delay 666ebbf2ceSRussell King ret lr 67*7339fb11SLinus WalleijSYM_FUNC_END(__loop_delay) 68