diff options
author | Nicolas Pitre <nicolas.pitre@linaro.org> | 2016-10-07 05:38:35 +0100 |
---|---|---|
committer | Russell King <rmk+kernel@armlinux.org.uk> | 2016-10-19 10:52:36 +0100 |
commit | 207b1150c00d0471c11669cd3f249d81909b3ac8 (patch) | |
tree | 15b52a6047ac5b4c86f5bd079841f777f3377ffd /arch/arm/include | |
parent | 1001354ca34179f3db924eb66672442a173147dc (diff) | |
download | linux-207b1150c00d0471c11669cd3f249d81909b3ac8.tar.bz2 |
ARM: 8619/1: udelay: document the various constants
Explain where the value for UDELAY_MULT and UDELAY_SHIFT come from.
Also fix/clarify some comments pertaining to their usage in the
assembly code.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/include')
-rw-r--r-- | arch/arm/include/asm/delay.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/arm/include/asm/delay.h b/arch/arm/include/asm/delay.h index b1ce037e4380..e986b7f717c4 100644 --- a/arch/arm/include/asm/delay.h +++ b/arch/arm/include/asm/delay.h @@ -9,6 +9,33 @@ #include <asm/memory.h> #include <asm/param.h> /* HZ */ +/* + * Loop (or tick) based delay: + * + * loops = loops_per_jiffy * jiffies_per_sec * delay_us / us_per_sec + * + * where: + * + * jiffies_per_sec = HZ + * us_per_sec = 1000000 + * + * Therefore the constant part is HZ / 1000000 which is a small + * fractional number. To make this usable with integer math, we + * scale up this constant by 2^31, perform the actual multiplication, + * and scale the result back down by 2^31 with a simple shift: + * + * loops = (loops_per_jiffy * delay_us * UDELAY_MULT) >> 31 + * + * where: + * + * UDELAY_MULT = 2^31 * HZ / 1000000 + * = (2^31 / 1000000) * HZ + * = 2147.483648 * HZ + * = 2147 * HZ + 483648 * HZ / 1000000 + * + * 31 is the biggest scale shift value that won't overflow 32 bits for + * delay_us * UDELAY_MULT assuming HZ <= 1000 and delay_us <= 2000. + */ #define MAX_UDELAY_MS 2 #define UDELAY_MULT UL(2147 * HZ + 483648 * HZ / 1000000) #define UDELAY_SHIFT 31 |