From 102a0743326a03cd1a1202ceda21e175b7d3575c Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Tue, 20 Feb 2024 01:20:52 +0000 Subject: [PATCH] add new system file --- kernel/drivers/clocksource/arm_global_timer.c | 98 +------------------------------------------------ 1 files changed, 2 insertions(+), 96 deletions(-) diff --git a/kernel/drivers/clocksource/arm_global_timer.c b/kernel/drivers/clocksource/arm_global_timer.c index f60e772..88b2d38 100644 --- a/kernel/drivers/clocksource/arm_global_timer.c +++ b/kernel/drivers/clocksource/arm_global_timer.c @@ -1,13 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * drivers/clocksource/arm_global_timer.c * * Copyright (C) 2013 STMicroelectronics (R&D) Limited. * Author: Stuart Menefy <stuart.menefy@st.com> * Author: Srinivas Kandagatla <srinivas.kandagatla@st.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #include <linux/init.h> @@ -49,7 +46,6 @@ * the units for all operations. */ static void __iomem *gt_base; -static struct clk *gt_clk; static unsigned long gt_clk_rate; static int gt_ppi; static struct clock_event_device __percpu *gt_evt; @@ -137,97 +133,6 @@ gt_compare_set(evt, 0); return 0; } - -#ifdef CONFIG_COMMON_CLK - -/* - * Updates clockevent frequency when the cpu frequency changes. - * Called on the cpu that is changing frequency with interrupts disabled. - */ -static void gt_update_frequency(void *new_rate) -{ - gt_clk_rate = *((unsigned long *) new_rate); - - clockevents_update_freq(raw_cpu_ptr(gt_evt), gt_clk_rate); -} - -static int gt_rate_change(struct notifier_block *nb, - unsigned long flags, void *data) -{ - struct clk_notifier_data *cnd = data; - - /* - * The gt clock events must be reprogrammed to account for the new - * frequency. The timer is local to a cpu, so cross-call to the - * changing cpu. - */ - if (flags == POST_RATE_CHANGE) - on_each_cpu(gt_update_frequency, - (void *)&cnd->new_rate, 1); - - return NOTIFY_OK; -} - -static struct notifier_block gt_clk_nb = { - .notifier_call = gt_rate_change, -}; - -static int gt_clk_init(void) -{ - if (gt_evt && raw_cpu_ptr(gt_evt) && !IS_ERR(gt_clk)) - return clk_notifier_register(gt_clk, >_clk_nb); - - return 0; -} -core_initcall(gt_clk_init); - -#elif defined (CONFIG_CPU_FREQ) - -#include <linux/cpufreq.h> - -/* - * Updates clockevent frequency when the cpu frequency changes. - * Called on the cpu that is changing frequency with interrupts disabled. - */ -static void gt_update_frequency(void *data) -{ - gt_clk_rate = clk_get_rate(gt_clk); - - clockevents_update_freq(raw_cpu_ptr(gt_evt), gt_clk_rate); -} - -static int gt_cpufreq_transition(struct notifier_block *nb, - unsigned long state, void *data) -{ - struct cpufreq_freqs *freqs = data; - - /* - * The gt clock events must be reprogrammed to account for the new - * frequency. The timer is local to a cpu, so cross-call to the - * changing cpu. - */ - if (state == CPUFREQ_POSTCHANGE) - smp_call_function_single(freqs->cpu, gt_update_frequency, - NULL, 1); - - return NOTIFY_OK; -} - -static struct notifier_block gt_cpufreq_nb = { - .notifier_call = gt_cpufreq_transition, -}; - -static int gt_cpufreq_init(void) -{ - if (gt_evt && raw_cpu_ptr(gt_evt) && !IS_ERR(gt_clk)) - return cpufreq_register_notifier(>_cpufreq_nb, - CPUFREQ_TRANSITION_NOTIFIER); - - return 0; -} -core_initcall(gt_cpufreq_init); - -#endif static irqreturn_t gt_clockevent_interrupt(int irq, void *dev_id) { @@ -349,6 +254,7 @@ static int __init global_timer_of_register(struct device_node *np) { + struct clk *gt_clk; int err = 0; /* -- Gitblit v1.6.2