Author: wma
Date: Wed Sep 21 05:22:49 2016
New Revision: 306069
URL: https://svnweb.freebsd.org/changeset/base/306069

Log:
  Add support for SPI-mapped MSI interrupts in GICv3.
  
  PIC_SETUP_INTR implementation in GICv3 did not allow
  for setting up interrupts without included FDT
  description. GICv2m-like MSI interrupts, which map
  MSI messages to SPI interrupt lines, may not have
  a description in FDT. Add support for such interrupts
  by setting the trigger and polarity to the appropriate
  values for MSI (edge, high) and get the hardware
  IRQ number from the corresponding ISRC.
  
  Obtained from:         Semihalf
  Submitted by:          Michal Stanek <m...@semihalf.com>
  Sponsored by:          Annapurna Labs
  Reviewed by:           wma
  Differential Revision: https://reviews.freebsd.org/D7662

Modified:
  head/sys/arm64/arm64/gic_v3.c

Modified: head/sys/arm64/arm64/gic_v3.c
==============================================================================
--- head/sys/arm64/arm64/gic_v3.c       Wed Sep 21 05:15:50 2016        
(r306068)
+++ head/sys/arm64/arm64/gic_v3.c       Wed Sep 21 05:22:49 2016        
(r306069)
@@ -503,12 +503,33 @@ gic_map_fdt(device_t dev, u_int ncells, 
 #endif
 
 static int
+gic_map_msi(device_t dev, struct intr_map_data_msi *msi_data, u_int *irqp,
+    enum intr_polarity *polp, enum intr_trigger *trigp)
+{
+       struct gic_v3_irqsrc *gi;
+
+       /* SPI-mapped MSI */
+       gi = (struct gic_v3_irqsrc *)msi_data->isrc;
+       if (gi == NULL)
+               return (ENXIO);
+
+       *irqp = gi->gi_irq;
+
+       /* MSI/MSI-X interrupts are always edge triggered with high polarity */
+       *polp = INTR_POLARITY_HIGH;
+       *trigp = INTR_TRIGGER_EDGE;
+
+       return (0);
+}
+
+static int
 do_gic_v3_map_intr(device_t dev, struct intr_map_data *data, u_int *irqp,
     enum intr_polarity *polp, enum intr_trigger *trigp)
 {
        struct gic_v3_softc *sc;
        enum intr_polarity pol;
        enum intr_trigger trig;
+       struct intr_map_data_msi *dam;
 #ifdef FDT
        struct intr_map_data_fdt *daf;
 #endif
@@ -525,6 +546,12 @@ do_gic_v3_map_intr(device_t dev, struct 
                        return (EINVAL);
                break;
 #endif
+       case INTR_MAP_DATA_MSI:
+               /* SPI-mapped MSI */
+               dam = (struct intr_map_data_msi *)data;
+               if (gic_map_msi(dev, dam, &irq, &pol, &trig) != 0)
+                       return (EINVAL);
+               break;
        default:
                return (EINVAL);
        }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to