diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2017-02-15 20:34:10 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-02-24 08:21:33 +0100 |
commit | 5596f405ff03cd5de12ad592a6d696e112fed0c1 (patch) | |
tree | 815c9bfaff0e54e0179553bf2bfc5b91747335b8 /arch/efi | |
parent | 40c5c3f8fcf8913c630329f45eead1fd5ec7fcbb (diff) | |
download | barebox-5596f405ff03cd5de12ad592a6d696e112fed0c1.tar.gz barebox-5596f405ff03cd5de12ad592a6d696e112fed0c1.tar.xz |
efi: move clocksource out of arch
as efi is not an arch but a boot mode from where barebox is started
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/efi')
-rw-r--r-- | arch/efi/Kconfig | 1 | ||||
-rw-r--r-- | arch/efi/efi/Makefile | 1 | ||||
-rw-r--r-- | arch/efi/efi/clocksource.c | 58 |
3 files changed, 1 insertions, 59 deletions
diff --git a/arch/efi/Kconfig b/arch/efi/Kconfig index d8d0592e51..01301c04f7 100644 --- a/arch/efi/Kconfig +++ b/arch/efi/Kconfig @@ -7,6 +7,7 @@ config ARCH_EFI select EFI_DEVICEPATH select PRINTF_UUID select GENERIC_FIND_NEXT_BIT + select CLOCKSOURCE_EFI config ARCH_TEXT_BASE hex diff --git a/arch/efi/efi/Makefile b/arch/efi/efi/Makefile index f088c7a942..51db60b881 100644 --- a/arch/efi/efi/Makefile +++ b/arch/efi/efi/Makefile @@ -1,4 +1,3 @@ -obj-y += clocksource.o obj-y += efi.o obj-y += efi-device.o obj-y += efi-image.o diff --git a/arch/efi/efi/clocksource.c b/arch/efi/efi/clocksource.c deleted file mode 100644 index c92c35b112..0000000000 --- a/arch/efi/efi/clocksource.c +++ /dev/null @@ -1,58 +0,0 @@ -#include <common.h> -#include <efi.h> -#include <mach/efi.h> -#include <clock.h> - -#ifdef __x86_64__ -uint64_t ticks_read(void) -{ - uint64_t a, d; - - __asm__ volatile ("rdtsc" : "=a" (a), "=d" (d)); - - return (d << 32) | a; -} -#else -uint64_t ticks_read(void) -{ - uint64_t val; - - __asm__ volatile ("rdtsc" : "=A" (val)); - - return val; -} -#endif - -static uint64_t freq; - -/* count TSC ticks during a millisecond delay */ -static uint64_t ticks_freq(void) -{ - uint64_t ticks_start, ticks_end; - - ticks_start = ticks_read(); - BS->stall(1000); - ticks_end = ticks_read(); - - return (ticks_end - ticks_start) * 1000; -} - -static uint64_t efi_clocksource_read(void) -{ - return 1000 * 1000 * ticks_read() / freq; -} - -static struct clocksource cs = { - .read = efi_clocksource_read, - .mask = CLOCKSOURCE_MASK(64), - .shift = 0, -}; - -int efi_clocksource_init(void) -{ - cs.mult = clocksource_hz2mult(1000 * 1000, cs.shift); - - freq = ticks_freq(); - - return init_clock(&cs); -} |