[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen staging] xen/device-tree: Add ability to handle nodes with interrupts-extended prop



commit 2e9f5f726285deee96d7d9f89ce5680a0101111a
Author:     Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
AuthorDate: Tue May 21 20:37:34 2019 +0300
Commit:     Julien Grall <julien.grall@xxxxxxx>
CommitDate: Mon Jun 10 20:40:38 2019 +0100

    xen/device-tree: Add ability to handle nodes with interrupts-extended prop
    
    The "interrupts-extended" property is a special form for use when
    a node needs to reference multiple interrupt parents.
    
    According to:
    Linux/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
    
    But, there are cases when "interrupts-extended" property is used for
    "outside /soc node" with a single interrupt parent as an equivalent of
    pairs ("interrupt-parent" + "interrupts").
    
    A good example here is ARCH timer node for R-Car Gen3/Gen2 family,
    which is mandatory device for Xen usage on ARM. And without ability
    to handle such nodes, Xen fails to operate.
    
    So, this patch adds required support for Xen to be able to handle
    nodes with that property.
    
    Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
    Reviewed-by: Julien Grall <julien.grall@xxxxxxx>
---
 xen/common/device_tree.c | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 65862b58bb..e107c6f89f 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -987,15 +987,27 @@ unsigned int dt_number_of_irq(const struct dt_device_node 
*device)
     const struct dt_device_node *p;
     const __be32 *intspec, *tmp;
     u32 intsize, intlen;
+    int intnum;
 
     dt_dprintk("dt_irq_number: dev=%s\n", device->full_name);
 
+    /* Try the new-style interrupts-extended first */
+    intnum = dt_count_phandle_with_args(device, "interrupts-extended",
+                                        "#interrupt-cells");
+    if ( intnum >= 0 )
+    {
+        dt_dprintk(" using 'interrupts-extended' property\n");
+        dt_dprintk(" intnum=%d\n", intnum);
+        return intnum;
+    }
+
     /* Get the interrupts property */
     intspec = dt_get_property(device, "interrupts", &intlen);
     if ( intspec == NULL )
         return 0;
     intlen /= sizeof(*intspec);
 
+    dt_dprintk(" using 'interrupts' property\n");
     dt_dprintk(" intspec=%d intlen=%d\n", be32_to_cpup(intspec), intlen);
 
     /* Look for the interrupt parent. */
@@ -1420,21 +1432,39 @@ int dt_device_get_raw_irq(const struct dt_device_node 
*device,
     const __be32 *intspec, *tmp, *addr;
     u32 intsize, intlen;
     int res = -EINVAL;
+    struct dt_phandle_args args;
+    int i;
 
     dt_dprintk("dt_device_get_raw_irq: dev=%s, index=%u\n",
                device->full_name, index);
 
+    /* Get the reg property (if any) */
+    addr = dt_get_property(device, "reg", NULL);
+
+    /* Try the new-style interrupts-extended first */
+    res = dt_parse_phandle_with_args(device, "interrupts-extended",
+                                     "#interrupt-cells", index, &args);
+    if ( !res )
+    {
+        dt_dprintk(" using 'interrupts-extended' property\n");
+        dt_dprintk(" intspec=%d intsize=%d\n", args.args[0], args.args_count);
+
+        for ( i = 0; i < args.args_count; i++ )
+            args.args[i] = cpu_to_be32(args.args[i]);
+
+        return dt_irq_map_raw(args.np, args.args, args.args_count,
+                              addr, out_irq);
+    }
+
     /* Get the interrupts property */
     intspec = dt_get_property(device, "interrupts", &intlen);
     if ( intspec == NULL )
         return -EINVAL;
     intlen /= sizeof(*intspec);
 
+    dt_dprintk(" using 'interrupts' property\n");
     dt_dprintk(" intspec=%d intlen=%d\n", be32_to_cpup(intspec), intlen);
 
-    /* Get the reg property (if any) */
-    addr = dt_get_property(device, "reg", NULL);
-
     /* Look for the interrupt parent. */
     p = dt_irq_find_parent(device);
     if ( p == NULL )
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.