linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] soc: fsl: qe: convert QE interrupt controller to platform_device
@ 2021-08-03 11:35 Maxim Kochetkov
  2021-08-03 17:51 ` Saravana Kannan
  2021-08-06 23:42 ` Leo Li
  0 siblings, 2 replies; 6+ messages in thread
From: Maxim Kochetkov @ 2021-08-03 11:35 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: qiang.zhao, leoyang.li, gregkh, saravanak, linux-arm-kernel,
	linux-kernel, Maxim Kochetkov, kernel test robot, Dan Carpenter

Since 5.13 QE's ucc nodes can't get interrupts from devicetree:

	ucc@2000 {
		cell-index = <1>;
		reg = <0x2000 0x200>;
		interrupts = <32>;
		interrupt-parent = <&qeic>;
	};

Now fw_devlink expects driver to create and probe a struct device
for interrupt controller.

So lets convert this driver to simple platform_device with probe().
Also use platform_get_ and devm_ family function to get/allocate
resources and drop unused .compatible = "qeic".

[1] - https://lore.kernel.org/lkml/CAGETcx9PiX==mLxB9PO8Myyk6u2vhPVwTMsA5NkD-ywH5xhusw@mail.gmail.com
Fixes: e590474768f1 ("driver core: Set fw_devlink=on by default")
Fixes: ea718c699055 ("Revert "Revert "driver core: Set fw_devlink=on by default""")
Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/soc/fsl/qe/qe_ic.c | 75 ++++++++++++++++++++++----------------
 1 file changed, 44 insertions(+), 31 deletions(-)

diff --git a/drivers/soc/fsl/qe/qe_ic.c b/drivers/soc/fsl/qe/qe_ic.c
index 3f711c1a0996..e710d554425d 100644
--- a/drivers/soc/fsl/qe/qe_ic.c
+++ b/drivers/soc/fsl/qe/qe_ic.c
@@ -23,6 +23,7 @@
 #include <linux/signal.h>
 #include <linux/device.h>
 #include <linux/spinlock.h>
+#include <linux/platform_device.h>
 #include <asm/irq.h>
 #include <asm/io.h>
 #include <soc/fsl/qe/qe.h>
@@ -404,41 +405,40 @@ static void qe_ic_cascade_muxed_mpic(struct irq_desc *desc)
 	chip->irq_eoi(&desc->irq_data);
 }
 
-static void __init qe_ic_init(struct device_node *node)
+static int qe_ic_init(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	void (*low_handler)(struct irq_desc *desc);
 	void (*high_handler)(struct irq_desc *desc);
 	struct qe_ic *qe_ic;
-	struct resource res;
-	u32 ret;
+	struct resource *res;
+	struct device_node *node = pdev->dev.of_node;
 
-	ret = of_address_to_resource(node, 0, &res);
-	if (ret)
-		return;
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (res == NULL) {
+		dev_err(dev, "no memory resource defined\n");
+		return -ENODEV;
+	}
 
-	qe_ic = kzalloc(sizeof(*qe_ic), GFP_KERNEL);
+	qe_ic = devm_kzalloc(dev, sizeof(*qe_ic), GFP_KERNEL);
 	if (qe_ic == NULL)
-		return;
+		return -ENOMEM;
 
-	qe_ic->irqhost = irq_domain_add_linear(node, NR_QE_IC_INTS,
-					       &qe_ic_host_ops, qe_ic);
-	if (qe_ic->irqhost == NULL) {
-		kfree(qe_ic);
-		return;
+	qe_ic->regs = devm_ioremap(dev, res->start, resource_size(res));
+	if (qe_ic->regs == NULL) {
+		dev_err(dev, "failed to ioremap() registers\n");
+		return -ENODEV;
 	}
 
-	qe_ic->regs = ioremap(res.start, resource_size(&res));
-
 	qe_ic->hc_irq = qe_ic_irq_chip;
 
-	qe_ic->virq_high = irq_of_parse_and_map(node, 0);
-	qe_ic->virq_low = irq_of_parse_and_map(node, 1);
+	qe_ic->virq_high = platform_get_irq(pdev, 0);
+	qe_ic->virq_low = platform_get_irq(pdev, 1);
 
-	if (!qe_ic->virq_low) {
-		printk(KERN_ERR "Failed to map QE_IC low IRQ\n");
-		kfree(qe_ic);
-		return;
+	if (qe_ic->virq_low < 0) {
+		return -ENODEV;
 	}
+
 	if (qe_ic->virq_high != qe_ic->virq_low) {
 		low_handler = qe_ic_cascade_low;
 		high_handler = qe_ic_cascade_high;
@@ -447,6 +447,13 @@ static void __init qe_ic_init(struct device_node *node)
 		high_handler = NULL;
 	}
 
+	qe_ic->irqhost = irq_domain_add_linear(node, NR_QE_IC_INTS,
+					       &qe_ic_host_ops, qe_ic);
+	if (qe_ic->irqhost == NULL) {
+		dev_err(dev, "failed to add irq domain\n");
+		return -ENODEV;
+	}
+
 	qe_ic_write(qe_ic->regs, QEIC_CICR, 0);
 
 	irq_set_handler_data(qe_ic->virq_low, qe_ic);
@@ -456,20 +463,26 @@ static void __init qe_ic_init(struct device_node *node)
 		irq_set_handler_data(qe_ic->virq_high, qe_ic);
 		irq_set_chained_handler(qe_ic->virq_high, high_handler);
 	}
+	return 0;
 }
+static const struct of_device_id qe_ic_ids[] = {
+	{ .compatible = "fsl,qe-ic"},
+	{ .type = "qeic"},
+	{},
+};
 
-static int __init qe_ic_of_init(void)
+static struct platform_driver qe_ic_driver =
 {
-	struct device_node *np;
+	.driver	= {
+		.name		= "qe-ic",
+		.of_match_table	= qe_ic_ids,
+	},
+	.probe	= qe_ic_init,
+};
 
-	np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
-	if (!np) {
-		np = of_find_node_by_type(NULL, "qeic");
-		if (!np)
-			return -ENODEV;
-	}
-	qe_ic_init(np);
-	of_node_put(np);
+static int __init qe_ic_of_init(void)
+{
+	platform_driver_register(&qe_ic_driver);
 	return 0;
 }
 subsys_initcall(qe_ic_of_init);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] soc: fsl: qe: convert QE interrupt controller to platform_device
  2021-08-03 11:35 [PATCH v4] soc: fsl: qe: convert QE interrupt controller to platform_device Maxim Kochetkov
@ 2021-08-03 17:51 ` Saravana Kannan
  2021-08-06  4:37   ` Maxim Kochetkov
  2021-08-06 23:42 ` Leo Li
  1 sibling, 1 reply; 6+ messages in thread
From: Saravana Kannan @ 2021-08-03 17:51 UTC (permalink / raw)
  To: Maxim Kochetkov
  Cc: linuxppc-dev, qiang.zhao, leoyang.li, gregkh, linux-arm-kernel,
	linux-kernel, kernel test robot, Dan Carpenter

On Tue, Aug 3, 2021 at 4:33 AM Maxim Kochetkov <fido_max@inbox.ru> wrote:
>
> Since 5.13 QE's ucc nodes can't get interrupts from devicetree:
>
>         ucc@2000 {
>                 cell-index = <1>;
>                 reg = <0x2000 0x200>;
>                 interrupts = <32>;
>                 interrupt-parent = <&qeic>;
>         };
>
> Now fw_devlink expects driver to create and probe a struct device
> for interrupt controller.
>
> So lets convert this driver to simple platform_device with probe().
> Also use platform_get_ and devm_ family function to get/allocate
> resources and drop unused .compatible = "qeic".

Yes, please!

Acked-by: Saravana Kannan <saravanak@google.com>

-Saravana

>
> [1] - https://lore.kernel.org/lkml/CAGETcx9PiX==mLxB9PO8Myyk6u2vhPVwTMsA5NkD-ywH5xhusw@mail.gmail.com
> Fixes: e590474768f1 ("driver core: Set fw_devlink=on by default")
> Fixes: ea718c699055 ("Revert "Revert "driver core: Set fw_devlink=on by default""")
> Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/soc/fsl/qe/qe_ic.c | 75 ++++++++++++++++++++++----------------
>  1 file changed, 44 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/soc/fsl/qe/qe_ic.c b/drivers/soc/fsl/qe/qe_ic.c
> index 3f711c1a0996..e710d554425d 100644
> --- a/drivers/soc/fsl/qe/qe_ic.c
> +++ b/drivers/soc/fsl/qe/qe_ic.c
> @@ -23,6 +23,7 @@
>  #include <linux/signal.h>
>  #include <linux/device.h>
>  #include <linux/spinlock.h>
> +#include <linux/platform_device.h>
>  #include <asm/irq.h>
>  #include <asm/io.h>
>  #include <soc/fsl/qe/qe.h>
> @@ -404,41 +405,40 @@ static void qe_ic_cascade_muxed_mpic(struct irq_desc *desc)
>         chip->irq_eoi(&desc->irq_data);
>  }
>
> -static void __init qe_ic_init(struct device_node *node)
> +static int qe_ic_init(struct platform_device *pdev)
>  {
> +       struct device *dev = &pdev->dev;
>         void (*low_handler)(struct irq_desc *desc);
>         void (*high_handler)(struct irq_desc *desc);
>         struct qe_ic *qe_ic;
> -       struct resource res;
> -       u32 ret;
> +       struct resource *res;
> +       struct device_node *node = pdev->dev.of_node;
>
> -       ret = of_address_to_resource(node, 0, &res);
> -       if (ret)
> -               return;
> +       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +       if (res == NULL) {
> +               dev_err(dev, "no memory resource defined\n");
> +               return -ENODEV;
> +       }
>
> -       qe_ic = kzalloc(sizeof(*qe_ic), GFP_KERNEL);
> +       qe_ic = devm_kzalloc(dev, sizeof(*qe_ic), GFP_KERNEL);
>         if (qe_ic == NULL)
> -               return;
> +               return -ENOMEM;
>
> -       qe_ic->irqhost = irq_domain_add_linear(node, NR_QE_IC_INTS,
> -                                              &qe_ic_host_ops, qe_ic);
> -       if (qe_ic->irqhost == NULL) {
> -               kfree(qe_ic);
> -               return;
> +       qe_ic->regs = devm_ioremap(dev, res->start, resource_size(res));
> +       if (qe_ic->regs == NULL) {
> +               dev_err(dev, "failed to ioremap() registers\n");
> +               return -ENODEV;
>         }
>
> -       qe_ic->regs = ioremap(res.start, resource_size(&res));
> -
>         qe_ic->hc_irq = qe_ic_irq_chip;
>
> -       qe_ic->virq_high = irq_of_parse_and_map(node, 0);
> -       qe_ic->virq_low = irq_of_parse_and_map(node, 1);
> +       qe_ic->virq_high = platform_get_irq(pdev, 0);
> +       qe_ic->virq_low = platform_get_irq(pdev, 1);
>
> -       if (!qe_ic->virq_low) {
> -               printk(KERN_ERR "Failed to map QE_IC low IRQ\n");
> -               kfree(qe_ic);
> -               return;
> +       if (qe_ic->virq_low < 0) {
> +               return -ENODEV;
>         }
> +
>         if (qe_ic->virq_high != qe_ic->virq_low) {
>                 low_handler = qe_ic_cascade_low;
>                 high_handler = qe_ic_cascade_high;
> @@ -447,6 +447,13 @@ static void __init qe_ic_init(struct device_node *node)
>                 high_handler = NULL;
>         }
>
> +       qe_ic->irqhost = irq_domain_add_linear(node, NR_QE_IC_INTS,
> +                                              &qe_ic_host_ops, qe_ic);
> +       if (qe_ic->irqhost == NULL) {
> +               dev_err(dev, "failed to add irq domain\n");
> +               return -ENODEV;
> +       }
> +
>         qe_ic_write(qe_ic->regs, QEIC_CICR, 0);
>
>         irq_set_handler_data(qe_ic->virq_low, qe_ic);
> @@ -456,20 +463,26 @@ static void __init qe_ic_init(struct device_node *node)
>                 irq_set_handler_data(qe_ic->virq_high, qe_ic);
>                 irq_set_chained_handler(qe_ic->virq_high, high_handler);
>         }
> +       return 0;
>  }
> +static const struct of_device_id qe_ic_ids[] = {
> +       { .compatible = "fsl,qe-ic"},
> +       { .type = "qeic"},
> +       {},
> +};
>
> -static int __init qe_ic_of_init(void)
> +static struct platform_driver qe_ic_driver =
>  {
> -       struct device_node *np;
> +       .driver = {
> +               .name           = "qe-ic",
> +               .of_match_table = qe_ic_ids,
> +       },
> +       .probe  = qe_ic_init,
> +};
>
> -       np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
> -       if (!np) {
> -               np = of_find_node_by_type(NULL, "qeic");
> -               if (!np)
> -                       return -ENODEV;
> -       }
> -       qe_ic_init(np);
> -       of_node_put(np);
> +static int __init qe_ic_of_init(void)
> +{
> +       platform_driver_register(&qe_ic_driver);
>         return 0;
>  }
>  subsys_initcall(qe_ic_of_init);
> --
> 2.31.1
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] soc: fsl: qe: convert QE interrupt controller to platform_device
  2021-08-03 17:51 ` Saravana Kannan
@ 2021-08-06  4:37   ` Maxim Kochetkov
  2021-08-06  4:39     ` Saravana Kannan
  0 siblings, 1 reply; 6+ messages in thread
From: Maxim Kochetkov @ 2021-08-06  4:37 UTC (permalink / raw)
  To: Saravana Kannan
  Cc: linuxppc-dev, qiang.zhao, leoyang.li, gregkh, linux-arm-kernel,
	linux-kernel, kernel test robot, Dan Carpenter

03.08.2021 20:51, Saravana Kannan wrote:
>> So lets convert this driver to simple platform_device with probe().
>> Also use platform_get_ and devm_ family function to get/allocate
>> resources and drop unused .compatible = "qeic".
> Yes, please!

Should I totally drop { .type = "qeic"}, or keep?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] soc: fsl: qe: convert QE interrupt controller to platform_device
  2021-08-06  4:37   ` Maxim Kochetkov
@ 2021-08-06  4:39     ` Saravana Kannan
  2021-08-06  4:53       ` Christophe Leroy
  0 siblings, 1 reply; 6+ messages in thread
From: Saravana Kannan @ 2021-08-06  4:39 UTC (permalink / raw)
  To: Maxim Kochetkov
  Cc: linuxppc-dev, qiang.zhao, leoyang.li, gregkh, linux-arm-kernel,
	linux-kernel, kernel test robot, Dan Carpenter

On Thu, Aug 5, 2021 at 9:35 PM Maxim Kochetkov <fido_max@inbox.ru> wrote:
>
> 03.08.2021 20:51, Saravana Kannan wrote:
> >> So lets convert this driver to simple platform_device with probe().
> >> Also use platform_get_ and devm_ family function to get/allocate
> >> resources and drop unused .compatible = "qeic".
> > Yes, please!
>
> Should I totally drop { .type = "qeic"}, or keep?

Sorry for the confusion. My "Yes, please"!" was a show of support for
switching this to a proper platform driver. Not a response to that
specific question.

I didn't look at the code/DT close enough to know/care about the "type" part.

-Saravana

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] soc: fsl: qe: convert QE interrupt controller to platform_device
  2021-08-06  4:39     ` Saravana Kannan
@ 2021-08-06  4:53       ` Christophe Leroy
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe Leroy @ 2021-08-06  4:53 UTC (permalink / raw)
  To: Saravana Kannan, Maxim Kochetkov
  Cc: kernel test robot, gregkh, linux-kernel, leoyang.li,
	Dan Carpenter, linuxppc-dev, linux-arm-kernel, qiang.zhao



Le 06/08/2021 à 06:39, Saravana Kannan a écrit :
> On Thu, Aug 5, 2021 at 9:35 PM Maxim Kochetkov <fido_max@inbox.ru> wrote:
>>
>> 03.08.2021 20:51, Saravana Kannan wrote:
>>>> So lets convert this driver to simple platform_device with probe().
>>>> Also use platform_get_ and devm_ family function to get/allocate
>>>> resources and drop unused .compatible = "qeic".
>>> Yes, please!
>>
>> Should I totally drop { .type = "qeic"}, or keep?
> 
> Sorry for the confusion. My "Yes, please"!" was a show of support for
> switching this to a proper platform driver. Not a response to that
> specific question.
> 
> I didn't look at the code/DT close enough to know/care about the "type" part.
> 

As far as I understand, Leo told it needs to remain, based on his answer below:

"From the original code, this should be type = "qeic".  It is not
defined in current binding but probably needed for backward
compatibility."


Christophe

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH v4] soc: fsl: qe: convert QE interrupt controller to platform_device
  2021-08-03 11:35 [PATCH v4] soc: fsl: qe: convert QE interrupt controller to platform_device Maxim Kochetkov
  2021-08-03 17:51 ` Saravana Kannan
@ 2021-08-06 23:42 ` Leo Li
  1 sibling, 0 replies; 6+ messages in thread
From: Leo Li @ 2021-08-06 23:42 UTC (permalink / raw)
  To: Maxim Kochetkov, linuxppc-dev
  Cc: Qiang Zhao, gregkh, saravanak, linux-arm-kernel, linux-kernel,
	kernel test robot, Dan Carpenter



> -----Original Message-----
> From: Maxim Kochetkov <fido_max@inbox.ru>
> Sent: Tuesday, August 3, 2021 6:36 AM
> To: linuxppc-dev@lists.ozlabs.org
> Cc: Qiang Zhao <qiang.zhao@nxp.com>; Leo Li <leoyang.li@nxp.com>;
> gregkh@linuxfoundation.org; saravanak@google.com; linux-arm-
> kernel@lists.infradead.org; linux-kernel@vger.kernel.org; Maxim Kochetkov
> <fido_max@inbox.ru>; kernel test robot <lkp@intel.com>; Dan Carpenter
> <dan.carpenter@oracle.com>
> Subject: [PATCH v4] soc: fsl: qe: convert QE interrupt controller to
> platform_device
> 
> Since 5.13 QE's ucc nodes can't get interrupts from devicetree:
> 
> 	ucc@2000 {
> 		cell-index = <1>;
> 		reg = <0x2000 0x200>;
> 		interrupts = <32>;
> 		interrupt-parent = <&qeic>;
> 	};
> 
> Now fw_devlink expects driver to create and probe a struct device for
> interrupt controller.
> 
> So lets convert this driver to simple platform_device with probe().
> Also use platform_get_ and devm_ family function to get/allocate resources
> and drop unused .compatible = "qeic".
> 
> [1] -
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.k
> ernel.org%2Flkml%2FCAGETcx9PiX%3D%3DmLxB9PO8Myyk6u2vhPVwTMsA
> 5NkD-
> ywH5xhusw%40mail.gmail.com&amp;data=04%7C01%7Cleoyang.li%40nxp.co
> m%7C1833b32e26de4ed7ef7908d956728eae%7C686ea1d3bc2b4c6fa92cd99c5
> c301635%7C0%7C0%7C637635872281355718%7CUnknown%7CTWFpbGZsb3d
> 8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%
> 3D%7C1000&amp;sdata=HrivK73GYFAwygPz24JtO%2BTdkicCVYXOl3uywjOqS
> %2BA%3D&amp;reserved=0
> Fixes: e590474768f1 ("driver core: Set fw_devlink=on by default")
> Fixes: ea718c699055 ("Revert "Revert "driver core: Set fw_devlink=on by
> default""")
> Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied to fix.  Thanks.

> ---
>  drivers/soc/fsl/qe/qe_ic.c | 75 ++++++++++++++++++++++----------------
>  1 file changed, 44 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/soc/fsl/qe/qe_ic.c b/drivers/soc/fsl/qe/qe_ic.c index
> 3f711c1a0996..e710d554425d 100644
> --- a/drivers/soc/fsl/qe/qe_ic.c
> +++ b/drivers/soc/fsl/qe/qe_ic.c
> @@ -23,6 +23,7 @@
>  #include <linux/signal.h>
>  #include <linux/device.h>
>  #include <linux/spinlock.h>
> +#include <linux/platform_device.h>
>  #include <asm/irq.h>
>  #include <asm/io.h>
>  #include <soc/fsl/qe/qe.h>
> @@ -404,41 +405,40 @@ static void qe_ic_cascade_muxed_mpic(struct
> irq_desc *desc)
>  	chip->irq_eoi(&desc->irq_data);
>  }
> 
> -static void __init qe_ic_init(struct device_node *node)
> +static int qe_ic_init(struct platform_device *pdev)
>  {
> +	struct device *dev = &pdev->dev;
>  	void (*low_handler)(struct irq_desc *desc);
>  	void (*high_handler)(struct irq_desc *desc);
>  	struct qe_ic *qe_ic;
> -	struct resource res;
> -	u32 ret;
> +	struct resource *res;
> +	struct device_node *node = pdev->dev.of_node;
> 
> -	ret = of_address_to_resource(node, 0, &res);
> -	if (ret)
> -		return;
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (res == NULL) {
> +		dev_err(dev, "no memory resource defined\n");
> +		return -ENODEV;
> +	}
> 
> -	qe_ic = kzalloc(sizeof(*qe_ic), GFP_KERNEL);
> +	qe_ic = devm_kzalloc(dev, sizeof(*qe_ic), GFP_KERNEL);
>  	if (qe_ic == NULL)
> -		return;
> +		return -ENOMEM;
> 
> -	qe_ic->irqhost = irq_domain_add_linear(node, NR_QE_IC_INTS,
> -					       &qe_ic_host_ops, qe_ic);
> -	if (qe_ic->irqhost == NULL) {
> -		kfree(qe_ic);
> -		return;
> +	qe_ic->regs = devm_ioremap(dev, res->start, resource_size(res));
> +	if (qe_ic->regs == NULL) {
> +		dev_err(dev, "failed to ioremap() registers\n");
> +		return -ENODEV;
>  	}
> 
> -	qe_ic->regs = ioremap(res.start, resource_size(&res));
> -
>  	qe_ic->hc_irq = qe_ic_irq_chip;
> 
> -	qe_ic->virq_high = irq_of_parse_and_map(node, 0);
> -	qe_ic->virq_low = irq_of_parse_and_map(node, 1);
> +	qe_ic->virq_high = platform_get_irq(pdev, 0);
> +	qe_ic->virq_low = platform_get_irq(pdev, 1);
> 
> -	if (!qe_ic->virq_low) {
> -		printk(KERN_ERR "Failed to map QE_IC low IRQ\n");
> -		kfree(qe_ic);
> -		return;
> +	if (qe_ic->virq_low < 0) {
> +		return -ENODEV;
>  	}
> +
>  	if (qe_ic->virq_high != qe_ic->virq_low) {
>  		low_handler = qe_ic_cascade_low;
>  		high_handler = qe_ic_cascade_high;
> @@ -447,6 +447,13 @@ static void __init qe_ic_init(struct device_node
> *node)
>  		high_handler = NULL;
>  	}
> 
> +	qe_ic->irqhost = irq_domain_add_linear(node, NR_QE_IC_INTS,
> +					       &qe_ic_host_ops, qe_ic);
> +	if (qe_ic->irqhost == NULL) {
> +		dev_err(dev, "failed to add irq domain\n");
> +		return -ENODEV;
> +	}
> +
>  	qe_ic_write(qe_ic->regs, QEIC_CICR, 0);
> 
>  	irq_set_handler_data(qe_ic->virq_low, qe_ic); @@ -456,20 +463,26
> @@ static void __init qe_ic_init(struct device_node *node)
>  		irq_set_handler_data(qe_ic->virq_high, qe_ic);
>  		irq_set_chained_handler(qe_ic->virq_high, high_handler);
>  	}
> +	return 0;
>  }
> +static const struct of_device_id qe_ic_ids[] = {
> +	{ .compatible = "fsl,qe-ic"},
> +	{ .type = "qeic"},
> +	{},
> +};
> 
> -static int __init qe_ic_of_init(void)
> +static struct platform_driver qe_ic_driver =
>  {
> -	struct device_node *np;
> +	.driver	= {
> +		.name		= "qe-ic",
> +		.of_match_table	= qe_ic_ids,
> +	},
> +	.probe	= qe_ic_init,
> +};
> 
> -	np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
> -	if (!np) {
> -		np = of_find_node_by_type(NULL, "qeic");
> -		if (!np)
> -			return -ENODEV;
> -	}
> -	qe_ic_init(np);
> -	of_node_put(np);
> +static int __init qe_ic_of_init(void)
> +{
> +	platform_driver_register(&qe_ic_driver);
>  	return 0;
>  }
>  subsys_initcall(qe_ic_of_init);
> --
> 2.31.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-06 23:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03 11:35 [PATCH v4] soc: fsl: qe: convert QE interrupt controller to platform_device Maxim Kochetkov
2021-08-03 17:51 ` Saravana Kannan
2021-08-06  4:37   ` Maxim Kochetkov
2021-08-06  4:39     ` Saravana Kannan
2021-08-06  4:53       ` Christophe Leroy
2021-08-06 23:42 ` Leo Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).