diff mbox series

[RESEND,v1,8/9] spmi: pmic-arb: make interrupt support optional

Message ID 1631860384-26608-9-git-send-email-quic_fenglinw@quicinc.com (mailing list archive)
State Superseded
Headers show
Series A bunch of fix and optimization patches in spmi-pmic-arb.c | expand

Commit Message

Fenglin Wu Sept. 17, 2021, 6:33 a.m. UTC
From: David Collins <collinsd@codeaurora.org>

Make the support of PMIC peripheral interrupts optional for
spmi-pmic-arb devices.  This is useful in situations where
SPMI address mapping is required without the need for IRQ
support.

Signed-off-by: David Collins <collinsd@codeaurora.org>
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
---
 drivers/spmi/spmi-pmic-arb.c | 45 +++++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 17 deletions(-)

Comments

Stephen Boyd Oct. 12, 2021, 5:41 p.m. UTC | #1
Quoting Fenglin Wu (2021-09-16 23:33:03)
> From: David Collins <collinsd@codeaurora.org>
> 
> Make the support of PMIC peripheral interrupts optional for
> spmi-pmic-arb devices.  This is useful in situations where
> SPMI address mapping is required without the need for IRQ
> support.
> 
> Signed-off-by: David Collins <collinsd@codeaurora.org>
> Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
> ---
>  drivers/spmi/spmi-pmic-arb.c | 45 +++++++++++++++++++++++++++-----------------

Is there a binding update? Can the binding be converted to YAML as well?

>  1 file changed, 28 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
> index 988204c..55fa981 100644
> --- a/drivers/spmi/spmi-pmic-arb.c
> +++ b/drivers/spmi/spmi-pmic-arb.c
> @@ -1280,10 +1280,12 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
>                 goto err_put_ctrl;
>         }
>  
> -       pmic_arb->irq = platform_get_irq_byname(pdev, "periph_irq");
> -       if (pmic_arb->irq < 0) {
> -               err = pmic_arb->irq;
> -               goto err_put_ctrl;
> +       if (of_find_property(pdev->dev.of_node, "interrupt-names", NULL)) {

I don't think we should be keying off of interrupt-names. Instead we
should be checking for something else. Maybe interrupt-controller
property?

> +               pmic_arb->irq = platform_get_irq_byname(pdev, "periph_irq");
> +               if (pmic_arb->irq < 0) {
> +                       err = pmic_arb->irq;
> +                       goto err_put_ctrl;
Fenglin Wu Oct. 13, 2021, 8:36 a.m. UTC | #2
On 10/13/2021 1:41 AM, Stephen Boyd wrote:
> Quoting Fenglin Wu (2021-09-16 23:33:03)
>> From: David Collins <collinsd@codeaurora.org>
>>
>> Make the support of PMIC peripheral interrupts optional for
>> spmi-pmic-arb devices.  This is useful in situations where
>> SPMI address mapping is required without the need for IRQ
>> support.
>>
>> Signed-off-by: David Collins <collinsd@codeaurora.org>
>> Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
>> ---
>>   drivers/spmi/spmi-pmic-arb.c | 45 +++++++++++++++++++++++++++-----------------
> Is there a binding update? Can the binding be converted to YAML as well?
This change doesn't add/update any dtsi properties but just checking if an
existing property is present to decide if IRQ support is required, so no
binding change is needed.
>
>>   1 file changed, 28 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
>> index 988204c..55fa981 100644
>> --- a/drivers/spmi/spmi-pmic-arb.c
>> +++ b/drivers/spmi/spmi-pmic-arb.c
>> @@ -1280,10 +1280,12 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
>>                  goto err_put_ctrl;
>>          }
>>   
>> -       pmic_arb->irq = platform_get_irq_byname(pdev, "periph_irq");
>> -       if (pmic_arb->irq < 0) {
>> -               err = pmic_arb->irq;
>> -               goto err_put_ctrl;
>> +       if (of_find_property(pdev->dev.of_node, "interrupt-names", NULL)) {
> I don't think we should be keying off of interrupt-names. Instead we
> should be checking for something else. Maybe interrupt-controller
> property?
Sure, I can update it to check the presence of "interrupt-controller" 
property.
>> +               pmic_arb->irq = platform_get_irq_byname(pdev, "periph_irq");
>> +               if (pmic_arb->irq < 0) {
>> +                       err = pmic_arb->irq;
>> +                       goto err_put_ctrl;
Stephen Boyd Oct. 13, 2021, 7:38 p.m. UTC | #3
Quoting Fenglin Wu (2021-10-13 01:36:54)
> 
> On 10/13/2021 1:41 AM, Stephen Boyd wrote:
> > Quoting Fenglin Wu (2021-09-16 23:33:03)
> >> From: David Collins <collinsd@codeaurora.org>
> >>
> >> Make the support of PMIC peripheral interrupts optional for
> >> spmi-pmic-arb devices.  This is useful in situations where
> >> SPMI address mapping is required without the need for IRQ
> >> support.
> >>
> >> Signed-off-by: David Collins <collinsd@codeaurora.org>
> >> Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
> >> ---
> >>   drivers/spmi/spmi-pmic-arb.c | 45 +++++++++++++++++++++++++++-----------------
> > Is there a binding update? Can the binding be converted to YAML as well?
> This change doesn't add/update any dtsi properties but just checking if an
> existing property is present to decide if IRQ support is required, so no
> binding change is needed.

The property is now optional in the binding. Please update the binding.

> >
> >>   1 file changed, 28 insertions(+), 17 deletions(-)
> >>
> >> diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
> >> index 988204c..55fa981 100644
> >> --- a/drivers/spmi/spmi-pmic-arb.c
> >> +++ b/drivers/spmi/spmi-pmic-arb.c
> >> @@ -1280,10 +1280,12 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
> >>                  goto err_put_ctrl;
> >>          }
> >>   
> >> -       pmic_arb->irq = platform_get_irq_byname(pdev, "periph_irq");
> >> -       if (pmic_arb->irq < 0) {
> >> -               err = pmic_arb->irq;
> >> -               goto err_put_ctrl;
> >> +       if (of_find_property(pdev->dev.of_node, "interrupt-names", NULL)) {
> > I don't think we should be keying off of interrupt-names. Instead we
> > should be checking for something else. Maybe interrupt-controller
> > property?
> Sure, I can update it to check the presence of "interrupt-controller" 
> property.

Ok.
Fenglin Wu Oct. 14, 2021, 3:20 a.m. UTC | #4
On 10/14/2021 3:38 AM, Stephen Boyd wrote:
> Quoting Fenglin Wu (2021-10-13 01:36:54)
>> On 10/13/2021 1:41 AM, Stephen Boyd wrote:
>>> Quoting Fenglin Wu (2021-09-16 23:33:03)
>>>> From: David Collins <collinsd@codeaurora.org>
>>>>
>>>> Make the support of PMIC peripheral interrupts optional for
>>>> spmi-pmic-arb devices.  This is useful in situations where
>>>> SPMI address mapping is required without the need for IRQ
>>>> support.
>>>>
>>>> Signed-off-by: David Collins <collinsd@codeaurora.org>
>>>> Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
>>>> ---
>>>>    drivers/spmi/spmi-pmic-arb.c | 45 +++++++++++++++++++++++++++-----------------
>>> Is there a binding update? Can the binding be converted to YAML as well?
>> This change doesn't add/update any dtsi properties but just checking if an
>> existing property is present to decide if IRQ support is required, so no
>> binding change is needed.
> The property is now optional in the binding. Please update the binding.
Right, thanks for pointing it out. I forgot that part.
I will update the binding. How about only update the interrupt properties as
optional in this series then I can come up with following patch to convert
the binding to YAML format?
>
>>>>    1 file changed, 28 insertions(+), 17 deletions(-)
>>>>
>>>> diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
>>>> index 988204c..55fa981 100644
>>>> --- a/drivers/spmi/spmi-pmic-arb.c
>>>> +++ b/drivers/spmi/spmi-pmic-arb.c
>>>> @@ -1280,10 +1280,12 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
>>>>                   goto err_put_ctrl;
>>>>           }
>>>>    
>>>> -       pmic_arb->irq = platform_get_irq_byname(pdev, "periph_irq");
>>>> -       if (pmic_arb->irq < 0) {
>>>> -               err = pmic_arb->irq;
>>>> -               goto err_put_ctrl;
>>>> +       if (of_find_property(pdev->dev.of_node, "interrupt-names", NULL)) {
>>> I don't think we should be keying off of interrupt-names. Instead we
>>> should be checking for something else. Maybe interrupt-controller
>>> property?
>> Sure, I can update it to check the presence of "interrupt-controller"
>> property.
> Ok.
Stephen Boyd Oct. 15, 2021, 1:17 a.m. UTC | #5
Quoting Fenglin Wu (2021-10-13 20:20:57)
> 
> On 10/14/2021 3:38 AM, Stephen Boyd wrote:
> > Quoting Fenglin Wu (2021-10-13 01:36:54)
> >> On 10/13/2021 1:41 AM, Stephen Boyd wrote:
> >>> Quoting Fenglin Wu (2021-09-16 23:33:03)
> >>>> From: David Collins <collinsd@codeaurora.org>
> >>>>
> >>>> Make the support of PMIC peripheral interrupts optional for
> >>>> spmi-pmic-arb devices.  This is useful in situations where
> >>>> SPMI address mapping is required without the need for IRQ
> >>>> support.
> >>>>
> >>>> Signed-off-by: David Collins <collinsd@codeaurora.org>
> >>>> Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
> >>>> ---
> >>>>    drivers/spmi/spmi-pmic-arb.c | 45 +++++++++++++++++++++++++++-----------------
> >>> Is there a binding update? Can the binding be converted to YAML as well?
> >> This change doesn't add/update any dtsi properties but just checking if an
> >> existing property is present to decide if IRQ support is required, so no
> >> binding change is needed.
> > The property is now optional in the binding. Please update the binding.
> Right, thanks for pointing it out. I forgot that part.
> I will update the binding. How about only update the interrupt properties as
> optional in this series then I can come up with following patch to convert
> the binding to YAML format?

Sure. The benefit of converting it to YAML is that we can use the
checker to quickly validate the binding vs. having to read the whole
thing to understand that it's correct. Converting an existing binding to
YAML shouldn't be that hard.
Fenglin Wu Oct. 15, 2021, 1:30 a.m. UTC | #6
On 10/15/2021 9:17 AM, Stephen Boyd wrote:
> Quoting Fenglin Wu (2021-10-13 20:20:57)
>> On 10/14/2021 3:38 AM, Stephen Boyd wrote:
>>> Quoting Fenglin Wu (2021-10-13 01:36:54)
>>>> On 10/13/2021 1:41 AM, Stephen Boyd wrote:
>>>>> Quoting Fenglin Wu (2021-09-16 23:33:03)
>>>>>> From: David Collins <collinsd@codeaurora.org>
>>>>>>
>>>>>> Make the support of PMIC peripheral interrupts optional for
>>>>>> spmi-pmic-arb devices.  This is useful in situations where
>>>>>> SPMI address mapping is required without the need for IRQ
>>>>>> support.
>>>>>>
>>>>>> Signed-off-by: David Collins <collinsd@codeaurora.org>
>>>>>> Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
>>>>>> ---
>>>>>>     drivers/spmi/spmi-pmic-arb.c | 45 +++++++++++++++++++++++++++-----------------
>>>>> Is there a binding update? Can the binding be converted to YAML as well?
>>>> This change doesn't add/update any dtsi properties but just checking if an
>>>> existing property is present to decide if IRQ support is required, so no
>>>> binding change is needed.
>>> The property is now optional in the binding. Please update the binding.
>> Right, thanks for pointing it out. I forgot that part.
>> I will update the binding. How about only update the interrupt properties as
>> optional in this series then I can come up with following patch to convert
>> the binding to YAML format?
> Sure. The benefit of converting it to YAML is that we can use the
> checker to quickly validate the binding vs. having to read the whole
> thing to understand that it's correct. Converting an existing binding to
> YAML shouldn't be that hard.
Thanks, will do that for sure after this series of the changes.
diff mbox series

Patch

diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
index 988204c..55fa981 100644
--- a/drivers/spmi/spmi-pmic-arb.c
+++ b/drivers/spmi/spmi-pmic-arb.c
@@ -1280,10 +1280,12 @@  static int spmi_pmic_arb_probe(struct platform_device *pdev)
 		goto err_put_ctrl;
 	}
 
-	pmic_arb->irq = platform_get_irq_byname(pdev, "periph_irq");
-	if (pmic_arb->irq < 0) {
-		err = pmic_arb->irq;
-		goto err_put_ctrl;
+	if (of_find_property(pdev->dev.of_node, "interrupt-names", NULL)) {
+		pmic_arb->irq = platform_get_irq_byname(pdev, "periph_irq");
+		if (pmic_arb->irq < 0) {
+			err = pmic_arb->irq;
+			goto err_put_ctrl;
+		}
 	}
 
 	err = of_property_read_u32(pdev->dev.of_node, "qcom,channel", &channel);
@@ -1343,17 +1345,22 @@  static int spmi_pmic_arb_probe(struct platform_device *pdev)
 		}
 	}
 
-	dev_dbg(&pdev->dev, "adding irq domain\n");
-	pmic_arb->domain = irq_domain_add_tree(pdev->dev.of_node,
-					 &pmic_arb_irq_domain_ops, pmic_arb);
-	if (!pmic_arb->domain) {
-		dev_err(&pdev->dev, "unable to create irq_domain\n");
-		err = -ENOMEM;
-		goto err_put_ctrl;
+	if (pmic_arb->irq > 0) {
+		dev_dbg(&pdev->dev, "adding irq domain\n");
+		pmic_arb->domain = irq_domain_add_tree(pdev->dev.of_node,
+					    &pmic_arb_irq_domain_ops, pmic_arb);
+		if (!pmic_arb->domain) {
+			dev_err(&pdev->dev, "unable to create irq_domain\n");
+			err = -ENOMEM;
+			goto err_put_ctrl;
+		}
+
+		irq_set_chained_handler_and_data(pmic_arb->irq,
+						pmic_arb_chained_irq, pmic_arb);
+	} else {
+		dev_dbg(&pdev->dev, "not supporting PMIC interrupts\n");
 	}
 
-	irq_set_chained_handler_and_data(pmic_arb->irq, pmic_arb_chained_irq,
-					pmic_arb);
 	err = spmi_controller_add(ctrl);
 	if (err)
 		goto err_domain_remove;
@@ -1361,8 +1368,10 @@  static int spmi_pmic_arb_probe(struct platform_device *pdev)
 	return 0;
 
 err_domain_remove:
-	irq_set_chained_handler_and_data(pmic_arb->irq, NULL, NULL);
-	irq_domain_remove(pmic_arb->domain);
+	if (pmic_arb->irq > 0) {
+		irq_set_chained_handler_and_data(pmic_arb->irq, NULL, NULL);
+		irq_domain_remove(pmic_arb->domain);
+	}
 err_put_ctrl:
 	spmi_controller_put(ctrl);
 	return err;
@@ -1373,8 +1382,10 @@  static int spmi_pmic_arb_remove(struct platform_device *pdev)
 	struct spmi_controller *ctrl = platform_get_drvdata(pdev);
 	struct spmi_pmic_arb *pmic_arb = spmi_controller_get_drvdata(ctrl);
 	spmi_controller_remove(ctrl);
-	irq_set_chained_handler_and_data(pmic_arb->irq, NULL, NULL);
-	irq_domain_remove(pmic_arb->domain);
+	if (pmic_arb->irq > 0) {
+		irq_set_chained_handler_and_data(pmic_arb->irq, NULL, NULL);
+		irq_domain_remove(pmic_arb->domain);
+	}
 	spmi_controller_put(ctrl);
 	return 0;
 }