1 // SPDX-License-Identifier: GPL-2.0-only
3 * arch/arm/kernel/thumbee.c
5 * Copyright (C) 2008 ARM Limited
8 #include <linux/kernel.h>
9 #include <linux/init.h>
11 #include <asm/cputype.h>
12 #include <asm/system_info.h>
13 #include <asm/thread_notify.h>
16 * Access to the ThumbEE Handler Base register
18 static inline unsigned long teehbr_read(void)
21 asm("mrc p14, 6, %0, c1, c0, 0\n" : "=r" (v
));
25 static inline void teehbr_write(unsigned long v
)
27 asm("mcr p14, 6, %0, c1, c0, 0\n" : : "r" (v
));
30 static int thumbee_notifier(struct notifier_block
*self
, unsigned long cmd
, void *t
)
32 struct thread_info
*thread
= t
;
35 case THREAD_NOTIFY_FLUSH
:
38 case THREAD_NOTIFY_SWITCH
:
39 current_thread_info()->thumbee_state
= teehbr_read();
40 teehbr_write(thread
->thumbee_state
);
47 static struct notifier_block thumbee_notifier_block
= {
48 .notifier_call
= thumbee_notifier
,
51 static int __init
thumbee_init(void)
54 unsigned int cpu_arch
= cpu_architecture();
56 if (cpu_arch
< CPU_ARCH_ARMv7
)
59 pfr0
= read_cpuid_ext(CPUID_EXT_PFR0
);
60 if ((pfr0
& 0x0000f000) != 0x00001000)
63 pr_info("ThumbEE CPU extension supported.\n");
64 elf_hwcap
|= HWCAP_THUMBEE
;
65 thread_register_notifier(&thumbee_notifier_block
);
70 late_initcall(thumbee_init
);