forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/clocksource/nomadik-mtu.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2008 STMicroelectronics
34 * Copyright (C) 2010 Alessandro Rubini
45 * Copyright (C) 2010 Linus Walleij for ST-Ericsson
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2, as
8
- * published by the Free Software Foundation.
96 */
107 #include <linux/init.h>
118 #include <linux/interrupt.h>
....@@ -69,7 +66,6 @@
6966 static u32 nmdk_cycle; /* write-once */
7067 static struct delay_timer mtu_delay_timer;
7168
72
-#ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK
7369 /*
7470 * Override the global weak sched_clock symbol with this
7571 * local implementation which uses the clocksource to get some
....@@ -82,7 +78,6 @@
8278
8379 return -readl(mtu_base + MTU_VAL(0));
8480 }
85
-#endif
8681
8782 static unsigned long nmdk_timer_read_current_timer(void)
8883 {
....@@ -186,18 +181,12 @@
186181 return IRQ_HANDLED;
187182 }
188183
189
-static struct irqaction nmdk_timer_irq = {
190
- .name = "Nomadik Timer Tick",
191
- .flags = IRQF_TIMER,
192
- .handler = nmdk_timer_interrupt,
193
- .dev_id = &nmdk_clkevt,
194
-};
195
-
196184 static int __init nmdk_timer_init(void __iomem *base, int irq,
197185 struct clk *pclk, struct clk *clk)
198186 {
199187 unsigned long rate;
200188 int ret;
189
+ int min_ticks;
201190
202191 mtu_base = base;
203192
....@@ -206,7 +195,8 @@
206195
207196 /*
208197 * Tick rate is 2.4MHz for Nomadik and 2.4Mhz, 100MHz or 133 MHz
209
- * for ux500.
198
+ * for ux500, and in one specific Ux500 case 32768 Hz.
199
+ *
210200 * Use a divide-by-16 counter if the tick rate is more than 32MHz.
211201 * At 32 MHz, the timer (with 32 bit counter) can be programmed
212202 * to wake-up at a max 127s a head in time. Dividing a 2.4 MHz timer
....@@ -234,15 +224,20 @@
234224 return ret;
235225 }
236226
237
-#ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK
238227 sched_clock_register(nomadik_read_sched_clock, 32, rate);
239
-#endif
240228
241229 /* Timer 1 is used for events, register irq and clockevents */
242
- setup_irq(irq, &nmdk_timer_irq);
230
+ if (request_irq(irq, nmdk_timer_interrupt, IRQF_TIMER,
231
+ "Nomadik Timer Tick", &nmdk_clkevt))
232
+ pr_err("%s: request_irq() failed\n", "Nomadik Timer Tick");
243233 nmdk_clkevt.cpumask = cpumask_of(0);
244234 nmdk_clkevt.irq = irq;
245
- clockevents_config_and_register(&nmdk_clkevt, rate, 2, 0xffffffffU);
235
+ if (rate < 100000)
236
+ min_ticks = 5;
237
+ else
238
+ min_ticks = 2;
239
+ clockevents_config_and_register(&nmdk_clkevt, rate, min_ticks,
240
+ 0xffffffffU);
246241
247242 mtu_delay_timer.read_current_timer = &nmdk_timer_read_current_timer;
248243 mtu_delay_timer.freq = rate;