| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * linux/arch/arm/kernel/smp_twd.c |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2002 ARM Ltd. |
|---|
| 5 | 6 | * All Rights Reserved |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 9 | | - * published by the Free Software Foundation. |
|---|
| 10 | 7 | */ |
|---|
| 11 | 8 | #include <linux/init.h> |
|---|
| 12 | 9 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 100 | 97 | disable_percpu_irq(clk->irq); |
|---|
| 101 | 98 | } |
|---|
| 102 | 99 | |
|---|
| 103 | | -#ifdef CONFIG_COMMON_CLK |
|---|
| 104 | | - |
|---|
| 105 | 100 | /* |
|---|
| 106 | 101 | * Updates clockevent frequency when the cpu frequency changes. |
|---|
| 107 | 102 | * Called on the cpu that is changing frequency with interrupts disabled. |
|---|
| .. | .. |
|---|
| 142 | 137 | return 0; |
|---|
| 143 | 138 | } |
|---|
| 144 | 139 | core_initcall(twd_clk_init); |
|---|
| 145 | | - |
|---|
| 146 | | -#elif defined (CONFIG_CPU_FREQ) |
|---|
| 147 | | - |
|---|
| 148 | | -#include <linux/cpufreq.h> |
|---|
| 149 | | - |
|---|
| 150 | | -/* |
|---|
| 151 | | - * Updates clockevent frequency when the cpu frequency changes. |
|---|
| 152 | | - * Called on the cpu that is changing frequency with interrupts disabled. |
|---|
| 153 | | - */ |
|---|
| 154 | | -static void twd_update_frequency(void *data) |
|---|
| 155 | | -{ |
|---|
| 156 | | - twd_timer_rate = clk_get_rate(twd_clk); |
|---|
| 157 | | - |
|---|
| 158 | | - clockevents_update_freq(raw_cpu_ptr(twd_evt), twd_timer_rate); |
|---|
| 159 | | -} |
|---|
| 160 | | - |
|---|
| 161 | | -static int twd_cpufreq_transition(struct notifier_block *nb, |
|---|
| 162 | | - unsigned long state, void *data) |
|---|
| 163 | | -{ |
|---|
| 164 | | - struct cpufreq_freqs *freqs = data; |
|---|
| 165 | | - |
|---|
| 166 | | - /* |
|---|
| 167 | | - * The twd clock events must be reprogrammed to account for the new |
|---|
| 168 | | - * frequency. The timer is local to a cpu, so cross-call to the |
|---|
| 169 | | - * changing cpu. |
|---|
| 170 | | - */ |
|---|
| 171 | | - if (state == CPUFREQ_POSTCHANGE) |
|---|
| 172 | | - smp_call_function_single(freqs->cpu, twd_update_frequency, |
|---|
| 173 | | - NULL, 1); |
|---|
| 174 | | - |
|---|
| 175 | | - return NOTIFY_OK; |
|---|
| 176 | | -} |
|---|
| 177 | | - |
|---|
| 178 | | -static struct notifier_block twd_cpufreq_nb = { |
|---|
| 179 | | - .notifier_call = twd_cpufreq_transition, |
|---|
| 180 | | -}; |
|---|
| 181 | | - |
|---|
| 182 | | -static int twd_cpufreq_init(void) |
|---|
| 183 | | -{ |
|---|
| 184 | | - if (twd_evt && raw_cpu_ptr(twd_evt) && !IS_ERR(twd_clk)) |
|---|
| 185 | | - return cpufreq_register_notifier(&twd_cpufreq_nb, |
|---|
| 186 | | - CPUFREQ_TRANSITION_NOTIFIER); |
|---|
| 187 | | - |
|---|
| 188 | | - return 0; |
|---|
| 189 | | -} |
|---|
| 190 | | -core_initcall(twd_cpufreq_init); |
|---|
| 191 | | - |
|---|
| 192 | | -#endif |
|---|
| 193 | 140 | |
|---|
| 194 | 141 | static void twd_calibrate_rate(void) |
|---|
| 195 | 142 | { |
|---|
| .. | .. |
|---|
| 366 | 313 | return err; |
|---|
| 367 | 314 | } |
|---|
| 368 | 315 | |
|---|
| 369 | | -int __init twd_local_timer_register(struct twd_local_timer *tlt) |
|---|
| 370 | | -{ |
|---|
| 371 | | - if (twd_base || twd_evt) |
|---|
| 372 | | - return -EBUSY; |
|---|
| 373 | | - |
|---|
| 374 | | - twd_ppi = tlt->res[1].start; |
|---|
| 375 | | - |
|---|
| 376 | | - twd_base = ioremap(tlt->res[0].start, resource_size(&tlt->res[0])); |
|---|
| 377 | | - if (!twd_base) |
|---|
| 378 | | - return -ENOMEM; |
|---|
| 379 | | - |
|---|
| 380 | | - return twd_local_timer_common_register(NULL); |
|---|
| 381 | | -} |
|---|
| 382 | | - |
|---|
| 383 | | -#ifdef CONFIG_OF |
|---|
| 384 | 316 | static int __init twd_local_timer_of_register(struct device_node *np) |
|---|
| 385 | 317 | { |
|---|
| 386 | 318 | int err; |
|---|
| .. | .. |
|---|
| 406 | 338 | TIMER_OF_DECLARE(arm_twd_a9, "arm,cortex-a9-twd-timer", twd_local_timer_of_register); |
|---|
| 407 | 339 | TIMER_OF_DECLARE(arm_twd_a5, "arm,cortex-a5-twd-timer", twd_local_timer_of_register); |
|---|
| 408 | 340 | TIMER_OF_DECLARE(arm_twd_11mp, "arm,arm11mp-twd-timer", twd_local_timer_of_register); |
|---|
| 409 | | -#endif |
|---|