2 * arch/arm/kernel/thumbee.c
4 * Copyright (C) 2008 ARM Limited
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.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <linux/kernel.h>
21 #include <linux/init.h>
23 #include <asm/system_info.h>
24 #include <asm/thread_notify.h>
27 * Access to the ThumbEE Handler Base register
29 static inline unsigned long teehbr_read(void)
32 asm("mrc p14, 6, %0, c1, c0, 0\n" : "=r" (v));
36 static inline void teehbr_write(unsigned long v)
38 asm("mcr p14, 6, %0, c1, c0, 0\n" : : "r" (v));
41 static int thumbee_notifier(struct notifier_block *self, unsigned long cmd, void *t)
43 struct thread_info *thread = t;
46 case THREAD_NOTIFY_FLUSH:
47 thread->thumbee_state = 0;
49 case THREAD_NOTIFY_SWITCH:
50 current_thread_info()->thumbee_state = teehbr_read();
51 teehbr_write(thread->thumbee_state);
58 static struct notifier_block thumbee_notifier_block = {
59 .notifier_call = thumbee_notifier,
62 static int __init thumbee_init(void)
65 unsigned int cpu_arch = cpu_architecture();
67 if (cpu_arch < CPU_ARCH_ARMv7)
70 /* processor feature register 0 */
71 asm("mrc p15, 0, %0, c0, c1, 0\n" : "=r" (pfr0));
72 if ((pfr0 & 0x0000f000) != 0x00001000)
75 printk(KERN_INFO "ThumbEE CPU extension supported.\n");
76 elf_hwcap |= HWCAP_THUMBEE;
77 thread_register_notifier(&thumbee_notifier_block);
82 late_initcall(thumbee_init);