Merge tag 'platform-drivers-x86-v3.20-1' of git://git.infradead.org/users/dvhart...
[firefly-linux-kernel-4.4.55.git] / drivers / irqchip / irq-gic-v3.c
index 1a146ccee7017d4b344763c5f5d2cf45af1d9e4f..1c6dea2fbc34ce2d7b00007250111166315d8b78 100644 (file)
@@ -238,7 +238,9 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
        if (irq < 16)
                return -EINVAL;
 
-       if (type != IRQ_TYPE_LEVEL_HIGH && type != IRQ_TYPE_EDGE_RISING)
+       /* SPIs have restrictions on the supported types */
+       if (irq >= 32 && type != IRQ_TYPE_LEVEL_HIGH &&
+                        type != IRQ_TYPE_EDGE_RISING)
                return -EINVAL;
 
        if (gic_irq_in_rdist(d)) {
@@ -249,9 +251,7 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
                rwp_wait = gic_dist_wait_for_rwp;
        }
 
-       gic_configure_irq(irq, type, base, rwp_wait);
-
-       return 0;
+       return gic_configure_irq(irq, type, base, rwp_wait);
 }
 
 static u64 gic_mpidr_to_affinity(u64 mpidr)
@@ -481,15 +481,19 @@ out:
        return tlist;
 }
 
+#define MPIDR_TO_SGI_AFFINITY(cluster_id, level) \
+       (MPIDR_AFFINITY_LEVEL(cluster_id, level) \
+               << ICC_SGI1R_AFFINITY_## level ##_SHIFT)
+
 static void gic_send_sgi(u64 cluster_id, u16 tlist, unsigned int irq)
 {
        u64 val;
 
-       val = (MPIDR_AFFINITY_LEVEL(cluster_id, 3) << 48        |
-              MPIDR_AFFINITY_LEVEL(cluster_id, 2) << 32        |
-              irq << 24                                        |
-              MPIDR_AFFINITY_LEVEL(cluster_id, 1) << 16        |
-              tlist);
+       val = (MPIDR_TO_SGI_AFFINITY(cluster_id, 3)     |
+              MPIDR_TO_SGI_AFFINITY(cluster_id, 2)     |
+              irq << ICC_SGI1R_SGI_ID_SHIFT            |
+              MPIDR_TO_SGI_AFFINITY(cluster_id, 1)     |
+              tlist << ICC_SGI1R_TARGET_LIST_SHIFT);
 
        pr_debug("CPU%d: ICC_SGI1R_EL1 %llx\n", smp_processor_id(), val);
        gic_write_sgi1r(val);