layerscape: add ls1088ardb device support
[openwrt/staging/lynxis/omap.git] / target / linux / layerscape / patches-4.4 / 7150-staging-fsl-mc-set-MSI-domain-for-DPRC-objects.patch
1 From 15bfab2641c61fb50a876860e8909ab84d2b8701 Mon Sep 17 00:00:00 2001
2 From: "J. German Rivera" <German.Rivera@freescale.com>
3 Date: Wed, 6 Jan 2016 16:03:26 -0600
4 Subject: [PATCH 150/226] staging: fsl-mc: set MSI domain for DPRC objects
5
6 THE MSI domain associated with a root DPRC object is
7 obtained form the device tree. Child DPRCs inherit
8 the parent DPRC MSI domain.
9
10 Signed-off-by: J. German Rivera <German.Rivera@freescale.com>
11 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 ---
13 drivers/staging/fsl-mc/bus/dprc-driver.c | 39 ++++++++++++++++++++++++++++++
14 1 file changed, 39 insertions(+)
15
16 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c
17 +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
18 @@ -13,6 +13,7 @@
19 #include "../include/mc-sys.h"
20 #include <linux/module.h>
21 #include <linux/slab.h>
22 +#include <linux/interrupt.h>
23 #include "dprc-cmd.h"
24
25 struct dprc_child_objs {
26 @@ -398,11 +399,16 @@ static int dprc_probe(struct fsl_mc_devi
27 {
28 int error;
29 size_t region_size;
30 + struct device *parent_dev = mc_dev->dev.parent;
31 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
32 + bool msi_domain_set = false;
33
34 if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
35 return -EINVAL;
36
37 + if (WARN_ON(dev_get_msi_domain(&mc_dev->dev)))
38 + return -EINVAL;
39 +
40 if (!mc_dev->mc_io) {
41 /*
42 * This is a child DPRC:
43 @@ -421,6 +427,30 @@ static int dprc_probe(struct fsl_mc_devi
44 &mc_dev->mc_io);
45 if (error < 0)
46 return error;
47 + /*
48 + * Inherit parent MSI domain:
49 + */
50 + dev_set_msi_domain(&mc_dev->dev,
51 + dev_get_msi_domain(parent_dev));
52 + msi_domain_set = true;
53 + } else {
54 + /*
55 + * This is a root DPRC
56 + */
57 + struct irq_domain *mc_msi_domain;
58 +
59 + if (WARN_ON(parent_dev->bus == &fsl_mc_bus_type))
60 + return -EINVAL;
61 +
62 + error = fsl_mc_find_msi_domain(parent_dev,
63 + &mc_msi_domain);
64 + if (error < 0) {
65 + dev_warn(&mc_dev->dev,
66 + "WARNING: MC bus without interrupt support\n");
67 + } else {
68 + dev_set_msi_domain(&mc_dev->dev, mc_msi_domain);
69 + msi_domain_set = true;
70 + }
71 }
72
73 error = dprc_open(mc_dev->mc_io, 0, mc_dev->obj_desc.id,
74 @@ -446,6 +476,9 @@ error_cleanup_open:
75 (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
76
77 error_cleanup_mc_io:
78 + if (msi_domain_set)
79 + dev_set_msi_domain(&mc_dev->dev, NULL);
80 +
81 fsl_destroy_mc_io(mc_dev->mc_io);
82 return error;
83 }
84 @@ -463,6 +496,7 @@ error_cleanup_mc_io:
85 static int dprc_remove(struct fsl_mc_device *mc_dev)
86 {
87 int error;
88 + struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
89
90 if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
91 return -EINVAL;
92 @@ -475,6 +509,11 @@ static int dprc_remove(struct fsl_mc_dev
93 if (error < 0)
94 dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error);
95
96 + if (dev_get_msi_domain(&mc_dev->dev)) {
97 + fsl_mc_cleanup_irq_pool(mc_bus);
98 + dev_set_msi_domain(&mc_dev->dev, NULL);
99 + }
100 +
101 dev_info(&mc_dev->dev, "DPRC device unbound from driver");
102 return 0;
103 }