From 35751c7f3f01a6123e2965ad1b71a8e6a7a9c90d Mon Sep 17 00:00:00 2001 From: William Zhang Date: Tue, 23 Aug 2022 21:44:32 -0700 Subject: timer: sti: convert sti-timer to arm a9 global timer STI timer is actually ARM Cortex A9 global timer. Convert the driver to use generic global timer name and make it consistent with Linux kernel global timer driver. This also allows any A9 based device to use this driver. Signed-off-by: William Zhang Reviewed-by: Patrice Chotard Tested-by: Patrice Chotard --- drivers/timer/sti-timer.c | 85 ----------------------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 drivers/timer/sti-timer.c (limited to 'drivers/timer/sti-timer.c') diff --git a/drivers/timer/sti-timer.c b/drivers/timer/sti-timer.c deleted file mode 100644 index 87444a0650f..00000000000 --- a/drivers/timer/sti-timer.c +++ /dev/null @@ -1,85 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright (C) 2017, STMicroelectronics - All Rights Reserved - * Author(s): Patrice Chotard, for STMicroelectronics. - */ - -#include -#include -#include -#include -#include - -#include -#include - -struct sti_timer_priv { - struct globaltimer *global_timer; -}; - -static u64 sti_timer_get_count(struct udevice *dev) -{ - struct sti_timer_priv *priv = dev_get_priv(dev); - struct globaltimer *global_timer = priv->global_timer; - u32 low, high; - u64 timer; - u32 old = readl(&global_timer->cnt_h); - - while (1) { - low = readl(&global_timer->cnt_l); - high = readl(&global_timer->cnt_h); - if (old == high) - break; - else - old = high; - } - timer = high; - return (u64)((timer << 32) | low); -} - -static int sti_timer_probe(struct udevice *dev) -{ - struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); - struct sti_timer_priv *priv = dev_get_priv(dev); - struct clk clk; - int err; - ulong ret; - - /* get arm global timer base address */ - priv->global_timer = (struct globaltimer *)dev_read_addr_ptr(dev); - if (!priv->global_timer) - return -ENOENT; - - err = clk_get_by_index(dev, 0, &clk); - if (!err) { - ret = clk_get_rate(&clk); - if (IS_ERR_VALUE(ret)) - return ret; - uc_priv->clock_rate = ret; - } else { - uc_priv->clock_rate = CONFIG_SYS_HZ_CLOCK; - } - - /* init timer */ - writel(0x01, &priv->global_timer->ctl); - - return 0; -} - -static const struct timer_ops sti_timer_ops = { - .get_count = sti_timer_get_count, -}; - -static const struct udevice_id sti_timer_ids[] = { - { .compatible = "arm,cortex-a9-global-timer" }, - {} -}; - -U_BOOT_DRIVER(sti_timer) = { - .name = "sti_timer", - .id = UCLASS_TIMER, - .of_match = sti_timer_ids, - .priv_auto = sizeof(struct sti_timer_priv), - .probe = sti_timer_probe, - .ops = &sti_timer_ops, -}; -- cgit v1.2.3