VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
b24413180f560 (Greg Kroah-Hartman 2017-11-01 15:07:57 +0100  1) // SPDX-License-Identifier: GPL-2.0
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  2) /*
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  3)  * delay loops
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  4)  *
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  5)  * Copyright (C) 2015 Yoshinori Sato
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  6)  */
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  7) 
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  8) #include <linux/module.h>
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  9) #include <linux/delay.h>
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 10) #include <asm/param.h>
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 11) #include <asm/processor.h>
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 12) #include <asm/timex.h>
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 13) 
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 14) void __delay(unsigned long cycles)
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 15) {
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 16) 	__asm__ volatile ("1: dec.l #1,%0\n\t"
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 17) 			  "bne 1b":"=r"(cycles):"0"(cycles));
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 18) }
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 19) EXPORT_SYMBOL(__delay);
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 20) 
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 21) void __const_udelay(unsigned long xloops)
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 22) {
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 23) 	u64 loops;
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 24) 
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 25) 	loops = (u64)xloops * loops_per_jiffy * HZ;
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 26) 
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 27) 	__delay(loops >> 32);
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 28) }
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 29) EXPORT_SYMBOL(__const_udelay);
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 30) 
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 31) void __udelay(unsigned long usecs)
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 32) {
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 33) 	__const_udelay(usecs * 0x10C7UL); /* 2**32 / 1000000 (rounded up) */
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 34) }
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 35) EXPORT_SYMBOL(__udelay);
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 36) 
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 37) void __ndelay(unsigned long nsecs)
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 38) {
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 39) 	__const_udelay(nsecs * 0x5UL); /* 2**32 / 1000000000 (rounded up) */
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 40) }
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 41) EXPORT_SYMBOL(__ndelay);