| 1 | /* |
| 2 | * arch/ubicom32/include/asm/delay.h |
| 3 | * Definition of delay routines for Ubicom32 architecture. |
| 4 | * |
| 5 | * (C) Copyright 2009, Ubicom, Inc. |
| 6 | * |
| 7 | * This file is part of the Ubicom32 Linux Kernel Port. |
| 8 | * |
| 9 | * The Ubicom32 Linux Kernel Port is free software: you can redistribute |
| 10 | * it and/or modify it under the terms of the GNU General Public License |
| 11 | * as published by the Free Software Foundation, either version 2 of the |
| 12 | * License, or (at your option) any later version. |
| 13 | * |
| 14 | * The Ubicom32 Linux Kernel Port is distributed in the hope that it |
| 15 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
| 16 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 17 | * the GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with the Ubicom32 Linux Kernel Port. If not, |
| 21 | * see <http://www.gnu.org/licenses/>. |
| 22 | * |
| 23 | * Ubicom32 implementation derived from (with many thanks): |
| 24 | * arch/m68knommu |
| 25 | * arch/blackfin |
| 26 | * arch/parisc |
| 27 | */ |
| 28 | #ifndef _ASM_UBICOM32_DELAY_H |
| 29 | #define _ASM_UBICOM32_DELAY_H |
| 30 | |
| 31 | #include <asm/param.h> |
| 32 | #include <asm/ip5000.h> |
| 33 | |
| 34 | static inline void __delay(unsigned long loops) |
| 35 | { |
| 36 | if (loops == 0) { |
| 37 | return; |
| 38 | } |
| 39 | |
| 40 | asm volatile ( |
| 41 | "1: add.4 %0, #-1, %0 \n\t" |
| 42 | " jmpne.t 1b \n\t" |
| 43 | : "+d" (loops) |
| 44 | ); |
| 45 | } |
| 46 | |
| 47 | /* |
| 48 | * Ubicom32 processor uses fixed 12MHz external OSC. |
| 49 | * So we use that as reference to count 12 cycles/us |
| 50 | */ |
| 51 | |
| 52 | extern unsigned long loops_per_jiffy; |
| 53 | |
| 54 | static inline void _udelay(unsigned long usecs) |
| 55 | { |
| 56 | #if defined(CONFIG_UBICOM32_V4) || defined(CONFIG_UBICOM32_V3) |
| 57 | asm volatile ( |
| 58 | " add.4 d15, 0(%0), %1 \n\t" |
| 59 | " sub.4 #0, 0(%0), d15 \n\t" |
| 60 | " jmpmi.w.f .-4 \n\t" |
| 61 | : |
| 62 | : "a"(TIMER_BASE + TIMER_MPTVAL), "d"(usecs * (12000000/1000000)) |
| 63 | : "d15" |
| 64 | ); |
| 65 | #else |
| 66 | BUG(); |
| 67 | #endif |
| 68 | } |
| 69 | |
| 70 | /* |
| 71 | * Moved the udelay() function into library code, no longer inlined. |
| 72 | */ |
| 73 | extern void udelay(unsigned long usecs); |
| 74 | |
| 75 | #endif /* _ASM_UBICOM32_DELAY_H */ |
| 76 | |