Merge remote-tracking branch 'moduleh/module.h-split'
[linux-2.6/next.git] / arch / sh / boards / mach-sdk7786 / nmi.c
blobedcfa1f568bae6efcf477ac8b1cce1e35f68d66f
1 /*
2 * SDK7786 FPGA NMI Support.
4 * Copyright (C) 2010 Paul Mundt
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10 #include <linux/init.h>
11 #include <linux/kernel.h>
12 #include <linux/string.h>
13 #include <mach/fpga.h>
15 enum {
16 NMI_MODE_MANUAL,
17 NMI_MODE_AUX,
18 NMI_MODE_MASKED,
19 NMI_MODE_ANY,
20 NMI_MODE_UNKNOWN,
24 * Default to the manual NMI switch.
26 static unsigned int __initdata nmi_mode = NMI_MODE_ANY;
28 static int __init nmi_mode_setup(char *str)
30 if (!str)
31 return 0;
33 if (strcmp(str, "manual") == 0)
34 nmi_mode = NMI_MODE_MANUAL;
35 else if (strcmp(str, "aux") == 0)
36 nmi_mode = NMI_MODE_AUX;
37 else if (strcmp(str, "masked") == 0)
38 nmi_mode = NMI_MODE_MASKED;
39 else if (strcmp(str, "any") == 0)
40 nmi_mode = NMI_MODE_ANY;
41 else {
42 nmi_mode = NMI_MODE_UNKNOWN;
43 pr_warning("Unknown NMI mode %s\n", str);
46 printk("Set NMI mode to %d\n", nmi_mode);
47 return 0;
49 early_param("nmi_mode", nmi_mode_setup);
51 void __init sdk7786_nmi_init(void)
53 unsigned int source, mask, tmp;
55 switch (nmi_mode) {
56 case NMI_MODE_MANUAL:
57 source = NMISR_MAN_NMI;
58 mask = NMIMR_MAN_NMIM;
59 break;
60 case NMI_MODE_AUX:
61 source = NMISR_AUX_NMI;
62 mask = NMIMR_AUX_NMIM;
63 break;
64 case NMI_MODE_ANY:
65 source = NMISR_MAN_NMI | NMISR_AUX_NMI;
66 mask = NMIMR_MAN_NMIM | NMIMR_AUX_NMIM;
67 break;
68 case NMI_MODE_MASKED:
69 case NMI_MODE_UNKNOWN:
70 default:
71 source = mask = 0;
72 break;
75 /* Set the NMI source */
76 tmp = fpga_read_reg(NMISR);
77 tmp &= ~NMISR_MASK;
78 tmp |= source;
79 fpga_write_reg(tmp, NMISR);
81 /* And the IRQ masking */
82 fpga_write_reg(NMIMR_MASK ^ mask, NMIMR);