Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Copyright (C) 2007 Atmel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include <linux/kdebug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/notifier.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/sched/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/hardirq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) enum nmi_action {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 	NMI_SHOW_STATE	= 1 << 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 	NMI_SHOW_REGS	= 1 << 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	NMI_DIE		= 1 << 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	NMI_DEBOUNCE	= 1 << 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static unsigned long nmi_actions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static int nmi_debug_notify(struct notifier_block *self,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 		unsigned long val, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	struct die_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	if (likely(val != DIE_NMI))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	if (nmi_actions & NMI_SHOW_STATE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		show_state();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	if (nmi_actions & NMI_SHOW_REGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		show_regs(args->regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	if (nmi_actions & NMI_DEBOUNCE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		mdelay(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	if (nmi_actions & NMI_DIE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		return NOTIFY_BAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	return NOTIFY_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static struct notifier_block nmi_debug_nb = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	.notifier_call = nmi_debug_notify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static int __init nmi_debug_setup(char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	char *p, *sep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	register_die_notifier(&nmi_debug_nb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	if (*str != '=')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	for (p = str + 1; *p; p = sep + 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 		sep = strchr(p, ',');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		if (sep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 			*sep = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 		if (strcmp(p, "state") == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 			nmi_actions |= NMI_SHOW_STATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		else if (strcmp(p, "regs") == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 			nmi_actions |= NMI_SHOW_REGS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 		else if (strcmp(p, "debounce") == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 			nmi_actions |= NMI_DEBOUNCE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 		else if (strcmp(p, "die") == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 			nmi_actions |= NMI_DIE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 			printk(KERN_WARNING "NMI: Unrecognized action `%s'\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 				p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		if (!sep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) __setup("nmi_debug", nmi_debug_setup);