2019-12-04 16:13:19

by Guillaume LA ROQUE

[permalink] [raw]
Subject: [PATCH v2] bluetooth: hci_bcm: enable IRQ capability from node

Actually IRQ can be found from GPIO but all platorms don't support
gpiod_to_irq, it's the case on amlogic chip.
so to have possibility to use interrupt mode we need to add interrupts
field in node and support it in driver.

Signed-off-by: Guillaume La Roque <[email protected]>
---
sorry for noise,

v2 is for rebasing on master branch

guillaume

drivers/bluetooth/hci_bcm.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index f8f5c593a05c..9f52d57c56de 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -1409,6 +1409,7 @@ static int bcm_serdev_probe(struct serdev_device *serdev)
{
struct bcm_device *bcmdev;
const struct bcm_device_data *data;
+ struct platform_device *pdev;
int err;

bcmdev = devm_kzalloc(&serdev->dev, sizeof(*bcmdev), GFP_KERNEL);
@@ -1421,6 +1422,8 @@ static int bcm_serdev_probe(struct serdev_device *serdev)
#endif
bcmdev->serdev_hu.serdev = serdev;
serdev_device_set_drvdata(serdev, bcmdev);
+ pdev = to_platform_device(bcmdev->dev);
+ bcmdev->irq = platform_get_irq(pdev, 0);

/* Initialize routing field to an unused value */
bcmdev->pcm_int_params[0] = 0xff;
--
2.17.1


2019-12-06 00:59:10

by Kevin Hilman

[permalink] [raw]
Subject: Re: [PATCH v2] bluetooth: hci_bcm: enable IRQ capability from node

Guillaume La Roque <[email protected]> writes:

> Actually IRQ can be found from GPIO but all platorms don't support

nit: s/platorms/platforms/

> gpiod_to_irq, it's the case on amlogic chip.
> so to have possibility to use interrupt mode we need to add interrupts
> field in node and support it in driver.
>
> Signed-off-by: Guillaume La Roque <[email protected]>
> ---
> sorry for noise,
>
> v2 is for rebasing on master branch
>
> guillaume
>
> drivers/bluetooth/hci_bcm.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
> index f8f5c593a05c..9f52d57c56de 100644
> --- a/drivers/bluetooth/hci_bcm.c
> +++ b/drivers/bluetooth/hci_bcm.c
> @@ -1409,6 +1409,7 @@ static int bcm_serdev_probe(struct serdev_device *serdev)
> {
> struct bcm_device *bcmdev;
> const struct bcm_device_data *data;
> + struct platform_device *pdev;
> int err;
>
> bcmdev = devm_kzalloc(&serdev->dev, sizeof(*bcmdev), GFP_KERNEL);
> @@ -1421,6 +1422,8 @@ static int bcm_serdev_probe(struct serdev_device *serdev)
> #endif
> bcmdev->serdev_hu.serdev = serdev;
> serdev_device_set_drvdata(serdev, bcmdev);
> + pdev = to_platform_device(bcmdev->dev);
> + bcmdev->irq = platform_get_irq(pdev, 0);

I don't know this driver well enough to be sure, but don't you need some
error checking here?

If this fails (on platforms with no IRQ defined), is an error code in
bcmdev->irq going to affect later code that tries to setup IRQs?

Kevin

2019-12-06 09:08:40

by Guillaume LA ROQUE

[permalink] [raw]
Subject: Re: [PATCH v2] bluetooth: hci_bcm: enable IRQ capability from node

hi Kevin,


On 12/6/19 1:58 AM, Kevin Hilman wrote:
> Guillaume La Roque <[email protected]> writes:
>
>> Actually IRQ can be found from GPIO but all platorms don't support
> nit: s/platorms/platforms/
will fix in v3
>> gpiod_to_irq, it's the case on amlogic chip.
>> so to have possibility to use interrupt mode we need to add interrupts
>> field in node and support it in driver.
>>
>> Signed-off-by: Guillaume La Roque <[email protected]>
>> ---
>> sorry for noise,
>>
>> v2 is for rebasing on master branch
>>
>> guillaume
>>
>> drivers/bluetooth/hci_bcm.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
>> index f8f5c593a05c..9f52d57c56de 100644
>> --- a/drivers/bluetooth/hci_bcm.c
>> +++ b/drivers/bluetooth/hci_bcm.c
>> @@ -1409,6 +1409,7 @@ static int bcm_serdev_probe(struct serdev_device *serdev)
>> {
>> struct bcm_device *bcmdev;
>> const struct bcm_device_data *data;
>> + struct platform_device *pdev;
>> int err;
>>
>> bcmdev = devm_kzalloc(&serdev->dev, sizeof(*bcmdev), GFP_KERNEL);
>> @@ -1421,6 +1422,8 @@ static int bcm_serdev_probe(struct serdev_device *serdev)
>> #endif
>> bcmdev->serdev_hu.serdev = serdev;
>> serdev_device_set_drvdata(serdev, bcmdev);
>> + pdev = to_platform_device(bcmdev->dev);
>> + bcmdev->irq = platform_get_irq(pdev, 0);
> I don't know this driver well enough to be sure, but don't you need some
> error checking here?
>
> If this fails (on platforms with no IRQ defined), is an error code in
> bcmdev->irq going to affect later code that tries to setup IRQs?

not needed to do something here becauseĀ  bcm_get_resources function check irq <=0 if yes it check if host-wakeup gpio was defined in node and try a gpiod_to_irq.

at the end in bcm_request_irq function i check if irq <=0 if yes return EOPNOTSUPP


> Kevin
>

Guillaume