Daniel Hellstrom | c2f02da | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000, 2001 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * (C) Copyright 2007 |
| 6 | * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com. |
| 7 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
Daniel Hellstrom | c2f02da | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <common.h> |
| 12 | |
| 13 | /* Implemented by SPARC CPUs */ |
| 14 | extern void cpu_wait_ticks(unsigned long ticks); |
| 15 | extern unsigned long cpu_usec2ticks(unsigned long usec); |
| 16 | extern unsigned long cpu_ticks2usec(unsigned long ticks); |
| 17 | |
| 18 | /* ------------------------------------------------------------------------- */ |
| 19 | |
| 20 | void wait_ticks(unsigned long ticks) |
| 21 | { |
| 22 | cpu_wait_ticks(ticks); |
| 23 | } |
| 24 | |
| 25 | /* |
| 26 | * This function is intended for SHORT delays only. |
| 27 | */ |
| 28 | unsigned long usec2ticks(unsigned long usec) |
| 29 | { |
| 30 | return cpu_usec2ticks(usec); |
| 31 | } |
| 32 | |
| 33 | /* ------------------------------------------------------------------------- */ |
| 34 | |
| 35 | /* |
| 36 | * We implement the delay by converting the delay (the number of |
| 37 | * microseconds to wait) into a number of time base ticks; then we |
| 38 | * watch the time base until it has incremented by that amount. |
| 39 | */ |
Ingo van Lil | 3eb90ba | 2009-11-24 14:09:21 +0100 | [diff] [blame] | 40 | void __udelay(unsigned long usec) |
Daniel Hellstrom | c2f02da | 2008-03-28 09:47:00 +0100 | [diff] [blame] | 41 | { |
| 42 | ulong ticks = usec2ticks(usec); |
| 43 | |
| 44 | wait_ticks(ticks); |
| 45 | } |
| 46 | |
| 47 | /* ------------------------------------------------------------------------- */ |
| 48 | |
| 49 | unsigned long ticks2usec(unsigned long ticks) |
| 50 | { |
| 51 | return cpu_ticks2usec(ticks); |
| 52 | } |
| 53 | |
| 54 | /* ------------------------------------------------------------------------- */ |
| 55 | |
| 56 | int init_timebase(void) |
| 57 | { |
| 58 | |
| 59 | return (0); |
| 60 | } |
| 61 | |
| 62 | /* ------------------------------------------------------------------------- */ |