Linux Audio

Check our new training course

Loading...
v3.1
 
 1/*
 2 * arch/arm/kernel/thumbee.c
 3 *
 4 * Copyright (C) 2008 ARM Limited
 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.
 9 *
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.
14 *
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
18 */
19
20#include <linux/kernel.h>
21#include <linux/init.h>
22
 
 
23#include <asm/thread_notify.h>
24
25/*
26 * Access to the ThumbEE Handler Base register
27 */
28static inline unsigned long teehbr_read(void)
29{
30	unsigned long v;
31	asm("mrc	p14, 6, %0, c1, c0, 0\n" : "=r" (v));
32	return v;
33}
34
35static inline void teehbr_write(unsigned long v)
36{
37	asm("mcr	p14, 6, %0, c1, c0, 0\n" : : "r" (v));
38}
39
40static int thumbee_notifier(struct notifier_block *self, unsigned long cmd, void *t)
41{
42	struct thread_info *thread = t;
43
44	switch (cmd) {
45	case THREAD_NOTIFY_FLUSH:
46		thread->thumbee_state = 0;
47		break;
48	case THREAD_NOTIFY_SWITCH:
49		current_thread_info()->thumbee_state = teehbr_read();
50		teehbr_write(thread->thumbee_state);
51		break;
52	}
53
54	return NOTIFY_DONE;
55}
56
57static struct notifier_block thumbee_notifier_block = {
58	.notifier_call	= thumbee_notifier,
59};
60
61static int __init thumbee_init(void)
62{
63	unsigned long pfr0;
64	unsigned int cpu_arch = cpu_architecture();
65
66	if (cpu_arch < CPU_ARCH_ARMv7)
67		return 0;
68
69	/* processor feature register 0 */
70	asm("mrc	p15, 0, %0, c0, c1, 0\n" : "=r" (pfr0));
71	if ((pfr0 & 0x0000f000) != 0x00001000)
72		return 0;
73
74	printk(KERN_INFO "ThumbEE CPU extension supported.\n");
75	elf_hwcap |= HWCAP_THUMBEE;
76	thread_register_notifier(&thumbee_notifier_block);
77
78	return 0;
79}
80
81late_initcall(thumbee_init);
v6.8
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 * arch/arm/kernel/thumbee.c
 4 *
 5 * Copyright (C) 2008 ARM Limited
 
 
 
 
 
 
 
 
 
 
 
 
 
 6 */
 7
 8#include <linux/kernel.h>
 9#include <linux/init.h>
10
11#include <asm/cputype.h>
12#include <asm/system_info.h>
13#include <asm/thread_notify.h>
14
15/*
16 * Access to the ThumbEE Handler Base register
17 */
18static inline unsigned long teehbr_read(void)
19{
20	unsigned long v;
21	asm("mrc	p14, 6, %0, c1, c0, 0\n" : "=r" (v));
22	return v;
23}
24
25static inline void teehbr_write(unsigned long v)
26{
27	asm("mcr	p14, 6, %0, c1, c0, 0\n" : : "r" (v));
28}
29
30static int thumbee_notifier(struct notifier_block *self, unsigned long cmd, void *t)
31{
32	struct thread_info *thread = t;
33
34	switch (cmd) {
35	case THREAD_NOTIFY_FLUSH:
36		teehbr_write(0);
37		break;
38	case THREAD_NOTIFY_SWITCH:
39		current_thread_info()->thumbee_state = teehbr_read();
40		teehbr_write(thread->thumbee_state);
41		break;
42	}
43
44	return NOTIFY_DONE;
45}
46
47static struct notifier_block thumbee_notifier_block = {
48	.notifier_call	= thumbee_notifier,
49};
50
51static int __init thumbee_init(void)
52{
53	unsigned long pfr0;
54	unsigned int cpu_arch = cpu_architecture();
55
56	if (cpu_arch < CPU_ARCH_ARMv7)
57		return 0;
58
59	pfr0 = read_cpuid_ext(CPUID_EXT_PFR0);
 
60	if ((pfr0 & 0x0000f000) != 0x00001000)
61		return 0;
62
63	pr_info("ThumbEE CPU extension supported.\n");
64	elf_hwcap |= HWCAP_THUMBEE;
65	thread_register_notifier(&thumbee_notifier_block);
66
67	return 0;
68}
69
70late_initcall(thumbee_init);