Skip to content

Commit 779e7d4

Browse files
Manuel Laussralfbaechle
authored andcommitted
MIPS: make cp0 counter clocksource/event usable as fallback.
The current mips clock build infrastructure lets a system only use either the MIPS cp0 counter or a SoC specific timer as a clocksource / clockevent device. This patch renames the core cp0 counter clocksource / clockevent functions from mips_* to r4k_* and updates the wrappers in asm-mips/time.h to call these renamed functions instead. Chips which can detect whether it is safe to use a chip-specific timer can now fall back on the cp0 counter if necessary and possible (e.g. Alchemy with a follow-on patch). Existing behaviour is not changed in any way. Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 074cf65 commit 779e7d4

5 files changed

Lines changed: 28 additions & 12 deletions

File tree

‎arch/mips/Kconfig‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,11 @@ config CEVT_DS1287
721721
config CEVT_GT641XX
722722
bool
723723

724+
config CEVT_R4K_LIB
725+
bool
726+
724727
config CEVT_R4K
728+
select CEVT_R4K_LIB
725729
bool
726730

727731
config CEVT_SB1250
@@ -736,7 +740,11 @@ config CSRC_BCM1480
736740
config CSRC_IOASIC
737741
bool
738742

743+
config CSRC_R4K_LIB
744+
bool
745+
739746
config CSRC_R4K
747+
select CSRC_R4K_LIB
740748
bool
741749

742750
config CSRC_SB1250

‎arch/mips/include/asm/time.h‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,35 @@ extern int (*perf_irq)(void);
5050
/*
5151
* Initialize the calling CPU's compare interrupt as clockevent device
5252
*/
53-
#ifdef CONFIG_CEVT_R4K
54-
extern int mips_clockevent_init(void);
53+
#ifdef CONFIG_CEVT_R4K_LIB
5554
extern unsigned int __weak get_c0_compare_int(void);
56-
#else
55+
extern int r4k_clockevent_init(void);
56+
#endif
57+
5758
static inline int mips_clockevent_init(void)
5859
{
60+
#ifdef CONFIG_CEVT_R4K
61+
return r4k_clockevent_init();
62+
#else
5963
return -ENXIO;
60-
}
6164
#endif
65+
}
6266

6367
/*
6468
* Initialize the count register as a clocksource
6569
*/
66-
#ifdef CONFIG_CSRC_R4K
67-
extern int init_mips_clocksource(void);
68-
#else
70+
#ifdef CONFIG_CSRC_R4K_LIB
71+
extern int init_r4k_clocksource(void);
72+
#endif
73+
6974
static inline int init_mips_clocksource(void)
7075
{
76+
#ifdef CONFIG_CSRC_R4K
77+
return init_r4k_clocksource();
78+
#else
7179
return 0;
72-
}
7380
#endif
81+
}
7482

7583
extern void clocksource_set_clock(struct clocksource *cs, unsigned int clock);
7684
extern void clockevent_set_clock(struct clock_event_device *cd,

‎arch/mips/kernel/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \
99
time.o topology.o traps.o unaligned.o watch.o
1010

1111
obj-$(CONFIG_CEVT_BCM1480) += cevt-bcm1480.o
12-
obj-$(CONFIG_CEVT_R4K) += cevt-r4k.o
12+
obj-$(CONFIG_CEVT_R4K_LIB) += cevt-r4k.o
1313
obj-$(CONFIG_MIPS_MT_SMTC) += cevt-smtc.o
1414
obj-$(CONFIG_CEVT_DS1287) += cevt-ds1287.o
1515
obj-$(CONFIG_CEVT_GT641XX) += cevt-gt641xx.o
1616
obj-$(CONFIG_CEVT_SB1250) += cevt-sb1250.o
1717
obj-$(CONFIG_CEVT_TXX9) += cevt-txx9.o
1818
obj-$(CONFIG_CSRC_BCM1480) += csrc-bcm1480.o
1919
obj-$(CONFIG_CSRC_IOASIC) += csrc-ioasic.o
20-
obj-$(CONFIG_CSRC_R4K) += csrc-r4k.o
20+
obj-$(CONFIG_CSRC_R4K_LIB) += csrc-r4k.o
2121
obj-$(CONFIG_CSRC_SB1250) += csrc-sb1250.o
2222
obj-$(CONFIG_SYNC_R4K) += sync-r4k.o
2323

‎arch/mips/kernel/cevt-r4k.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ int c0_compare_int_usable(void)
160160

161161
#ifndef CONFIG_MIPS_MT_SMTC
162162

163-
int __cpuinit mips_clockevent_init(void)
163+
int __cpuinit r4k_clockevent_init(void)
164164
{
165165
uint64_t mips_freq = mips_hpt_frequency;
166166
unsigned int cpu = smp_processor_id();

‎arch/mips/kernel/csrc-r4k.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static struct clocksource clocksource_mips = {
2222
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
2323
};
2424

25-
int __init init_mips_clocksource(void)
25+
int __init init_r4k_clocksource(void)
2626
{
2727
if (!cpu_has_counter || !mips_hpt_frequency)
2828
return -ENXIO;

0 commit comments

Comments
 (0)