diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 43c5bfc..39ddd15 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -70,7 +70,7 @@ config CLOCKSOURCE_ATMEL_PIT bool -config CLOCKSOURCE_ARMV8_TIMER +config CLOCKSOURCE_ARM_ARCHITECTED_TIMER bool default y depends on ARM && (CPU_64v8 || CPU_V7) diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index 8dbf91f..cba6344 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile @@ -11,9 +11,9 @@ obj-$(CONFIG_CLOCKSOURCE_UEMD) += uemd.o obj-$(CONFIG_CLOCKSOURCE_ROCKCHIP)+= rk_timer.o obj-$(CONFIG_CLOCKSOURCE_ATMEL_PIT) += timer-atmel-pit.o -obj-$(CONFIG_CLOCKSOURCE_ARMV8_TIMER) += armv8-timer.o +obj-$(CONFIG_CLOCKSOURCE_ARM_ARCHITECTED_TIMER) += arm_architected_timer.o ifneq ($(CONFIG_CPU_V8),y) -CFLAGS_armv8-timer.o := -march=armv7-a +CFLAGS_arm_architected_timer.o := -march=armv7-a endif obj-$(CONFIG_CLOCKSOURCE_ARM_GLOBAL_TIMER) += arm_global_timer.o obj-$(CONFIG_CLOCKSOURCE_IMX_GPT) += timer-imx-gpt.o diff --git a/drivers/clocksource/arm_architected_timer.c b/drivers/clocksource/arm_architected_timer.c new file mode 100644 index 0000000..3ca7dfd --- /dev/null +++ b/drivers/clocksource/arm_architected_timer.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2018 Sascha Hauer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include +#include +#include + +static uint64_t arm_arch_clocksource_read(void) +{ + return get_cntpct(); +} + +static struct clocksource cs = { + .read = arm_arch_clocksource_read, + .mask = CLOCKSOURCE_MASK(64), + .shift = 0, +}; + +static int arm_arch_timer_probe(struct device_d *dev) +{ + cs.mult = clocksource_hz2mult(get_cntfrq(), cs.shift); + + return init_clock(&cs); +} + +static struct of_device_id arm_arch_timer_dt_ids[] = { + { .compatible = "arm,armv7-timer", }, + { .compatible = "arm,armv8-timer", }, + { } +}; + +static struct driver_d arm_arch_timer_driver = { + .name = "arm-architected-timer", + .probe = arm_arch_timer_probe, + .of_compatible = DRV_OF_COMPAT(arm_arch_timer_dt_ids), +}; +postcore_platform_driver(arm_arch_timer_driver); diff --git a/drivers/clocksource/armv8-timer.c b/drivers/clocksource/armv8-timer.c deleted file mode 100644 index 3095f8c..0000000 --- a/drivers/clocksource/armv8-timer.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2018 Sascha Hauer - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include -#include -#include -#include -#include -#include - -static uint64_t armv8_clocksource_read(void) -{ - return get_cntpct(); -} - -static struct clocksource cs = { - .read = armv8_clocksource_read, - .mask = CLOCKSOURCE_MASK(64), - .shift = 0, -}; - -static int armv8_timer_probe(struct device_d *dev) -{ - cs.mult = clocksource_hz2mult(get_cntfrq(), cs.shift); - - return init_clock(&cs); -} - -static struct of_device_id armv8_timer_dt_ids[] = { - { .compatible = "arm,armv7-timer", }, - { .compatible = "arm,armv8-timer", }, - { } -}; - -static struct driver_d armv8_timer_driver = { - .name = "armv8-timer", - .probe = armv8_timer_probe, - .of_compatible = DRV_OF_COMPAT(armv8_timer_dt_ids), -}; -postcore_platform_driver(armv8_timer_driver); -