}
 }
 
+static bool fwspec_is_partitioned_ppi(struct irq_fwspec *fwspec,
+                                     irq_hw_number_t hwirq)
+{
+       enum gic_intid_range range;
+
+       if (!gic_data.ppi_descs)
+               return false;
+
+       if (!is_of_node(fwspec->fwnode))
+               return false;
+
+       if (fwspec->param_count < 4 || !fwspec->param[3])
+               return false;
+
+       range = __get_intid_range(hwirq);
+       if (range != PPI_RANGE && range != EPPI_RANGE)
+               return false;
+
+       return true;
+}
+
 static int gic_irq_domain_select(struct irq_domain *d,
                                 struct irq_fwspec *fwspec,
                                 enum irq_domain_bus_token bus_token)
 {
+       unsigned int type, ret, ppi_idx;
+       irq_hw_number_t hwirq;
+
        /* Not for us */
         if (fwspec->fwnode != d->fwnode)
                return 0;
        if (!is_of_node(fwspec->fwnode))
                return 1;
 
+       ret = gic_irq_domain_translate(d, fwspec, &hwirq, &type);
+       if (WARN_ON_ONCE(ret))
+               return 0;
+
+       if (!fwspec_is_partitioned_ppi(fwspec, hwirq))
+               return d == gic_data.domain;
+
        /*
         * If this is a PPI and we have a 4th (non-null) parameter,
         * then we need to match the partition domain.
         */
-       if (fwspec->param_count >= 4 &&
-           fwspec->param[0] == 1 && fwspec->param[3] != 0 &&
-           gic_data.ppi_descs)
-               return d == partition_get_domain(gic_data.ppi_descs[fwspec->param[1]]);
-
-       return d == gic_data.domain;
+       ppi_idx = __gic_get_ppi_index(hwirq);
+       return d == partition_get_domain(gic_data.ppi_descs[ppi_idx]);
 }
 
 static const struct irq_domain_ops gic_irq_domain_ops = {
                                      unsigned long *hwirq,
                                      unsigned int *type)
 {
+       unsigned long ppi_intid;
        struct device_node *np;
+       unsigned int ppi_idx;
        int ret;
 
        if (!gic_data.ppi_descs)
        if (WARN_ON(!np))
                return -EINVAL;
 
-       ret = partition_translate_id(gic_data.ppi_descs[fwspec->param[1]],
+       ret = gic_irq_domain_translate(d, fwspec, &ppi_intid, type);
+       if (WARN_ON_ONCE(ret))
+               return 0;
+
+       ppi_idx = __gic_get_ppi_index(ppi_intid);
+       ret = partition_translate_id(gic_data.ppi_descs[ppi_idx],
                                     of_node_to_fwnode(np));
        if (ret < 0)
                return ret;