|
27 | 27 | #include <linux/topology.h> |
28 | 28 | #include <linux/bitmap.h> |
29 | 29 | #include <linux/cpumask.h> |
| 30 | +#include <asm/sizes.h> |
30 | 31 |
|
31 | 32 | #define _INTC_MK(fn, mode, addr_e, addr_d, width, shift) \ |
32 | 33 | ((shift) | ((width) << 5) | ((fn) << 9) | ((mode) << 13) | \ |
@@ -94,7 +95,8 @@ static DEFINE_SPINLOCK(vector_lock); |
94 | 95 | #define SMP_NR(d, x) 1 |
95 | 96 | #endif |
96 | 97 |
|
97 | | -static unsigned int intc_prio_level[NR_IRQS]; /* for now */ |
| 98 | +static unsigned int intc_prio_level[NR_IRQS]; /* for now */ |
| 99 | +static unsigned int default_prio_level = 2; /* 2 - 16 */ |
98 | 100 | static unsigned long ack_handle[NR_IRQS]; |
99 | 101 |
|
100 | 102 | static inline struct intc_desc_int *get_intc_desc(unsigned int irq) |
@@ -787,7 +789,7 @@ static void __init intc_register_irq(struct intc_desc *desc, |
787 | 789 | /* set priority level |
788 | 790 | * - this needs to be at least 2 for 5-bit priorities on 7780 |
789 | 791 | */ |
790 | | - intc_prio_level[irq] = 2; |
| 792 | + intc_prio_level[irq] = default_prio_level; |
791 | 793 |
|
792 | 794 | /* enable secondary masking method if present */ |
793 | 795 | if (data[!primary]) |
@@ -1037,6 +1039,64 @@ int __init register_intc_controller(struct intc_desc *desc) |
1037 | 1039 | return -ENOMEM; |
1038 | 1040 | } |
1039 | 1041 |
|
| 1042 | +#ifdef CONFIG_INTC_USERIMASK |
| 1043 | +static void __iomem *uimask; |
| 1044 | + |
| 1045 | +int register_intc_userimask(unsigned long addr) |
| 1046 | +{ |
| 1047 | + if (unlikely(uimask)) |
| 1048 | + return -EBUSY; |
| 1049 | + |
| 1050 | + uimask = ioremap_nocache(addr, SZ_4K); |
| 1051 | + if (unlikely(!uimask)) |
| 1052 | + return -ENOMEM; |
| 1053 | + |
| 1054 | + pr_info("intc: userimask support registered for levels 0 -> %d\n", |
| 1055 | + default_prio_level - 1); |
| 1056 | + |
| 1057 | + return 0; |
| 1058 | +} |
| 1059 | + |
| 1060 | +static ssize_t |
| 1061 | +show_intc_userimask(struct sysdev_class *cls, |
| 1062 | + struct sysdev_class_attribute *attr, char *buf) |
| 1063 | +{ |
| 1064 | + return sprintf(buf, "%d\n", (__raw_readl(uimask) >> 4) & 0xf); |
| 1065 | +} |
| 1066 | + |
| 1067 | +static ssize_t |
| 1068 | +store_intc_userimask(struct sysdev_class *cls, |
| 1069 | + struct sysdev_class_attribute *attr, |
| 1070 | + const char *buf, size_t count) |
| 1071 | +{ |
| 1072 | + unsigned long level; |
| 1073 | + |
| 1074 | + level = simple_strtoul(buf, NULL, 10); |
| 1075 | + |
| 1076 | + /* |
| 1077 | + * Minimal acceptable IRQ levels are in the 2 - 16 range, but |
| 1078 | + * these are chomped so as to not interfere with normal IRQs. |
| 1079 | + * |
| 1080 | + * Level 1 is a special case on some CPUs in that it's not |
| 1081 | + * directly settable, but given that USERIMASK cuts off below a |
| 1082 | + * certain level, we don't care about this limitation here. |
| 1083 | + * Level 0 on the other hand equates to user masking disabled. |
| 1084 | + * |
| 1085 | + * We use default_prio_level as a cut off so that only special |
| 1086 | + * case opt-in IRQs can be mangled. |
| 1087 | + */ |
| 1088 | + if (level >= default_prio_level) |
| 1089 | + return -EINVAL; |
| 1090 | + |
| 1091 | + __raw_writel(0xa5 << 24 | level << 4, uimask); |
| 1092 | + |
| 1093 | + return count; |
| 1094 | +} |
| 1095 | + |
| 1096 | +static SYSDEV_CLASS_ATTR(userimask, S_IRUSR | S_IWUSR, |
| 1097 | + show_intc_userimask, store_intc_userimask); |
| 1098 | +#endif |
| 1099 | + |
1040 | 1100 | static ssize_t |
1041 | 1101 | show_intc_name(struct sys_device *dev, struct sysdev_attribute *attr, char *buf) |
1042 | 1102 | { |
@@ -1108,6 +1168,11 @@ static int __init register_intc_sysdevs(void) |
1108 | 1168 | int id = 0; |
1109 | 1169 |
|
1110 | 1170 | error = sysdev_class_register(&intc_sysdev_class); |
| 1171 | +#ifdef CONFIG_INTC_USERIMASK |
| 1172 | + if (!error && uimask) |
| 1173 | + error = sysdev_class_create_file(&intc_sysdev_class, |
| 1174 | + &attr_userimask); |
| 1175 | +#endif |
1111 | 1176 | if (!error) { |
1112 | 1177 | list_for_each_entry(d, &intc_list, list) { |
1113 | 1178 | d->sysdev.id = id; |
|
0 commit comments