From: "J, KEERTHY" <j-keerthy@ti.com>
To: Grygorii Strashko <grygorii.strashko@ti.com>, <linus.walleij@linaro.org>
Cc: <linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<t-kristo@ti.com>
Subject: Re: [PATCH v3 2/2] gpio: davinci: Do not assume continuous IRQ numbering
Date: Wed, 13 Jun 2018 06:36:36 +0530 [thread overview]
Message-ID: <af41c620-6c3c-a348-80c1-89918d0db898@ti.com> (raw)
In-Reply-To: <4ef40eb2-774e-925c-f4f1-5ed431ec1268@ti.com>
On 6/13/2018 1:36 AM, Grygorii Strashko wrote:
>
>
> On 06/12/2018 02:59 AM, Keerthy wrote:
>> Currently the driver assumes that the interrupts are continuous
>> and does platform_get_irq only once and assumes the rest are continuous,
>> instead call platform_get_irq for all the interrupts and store them
>> in an array for later use.
>>
>> Signed-off-by: Keerthy <j-keerthy@ti.com>
>> ---
>>
>> Tested for GPIO Interrupts on da850-lcdk board.
>>
>> Changes in v3:
>>
>> * Changed irqs type from unsigned to int
>>
>> Changes in v2:
>>
>> * Extended the logic of using saved IRQs to unbanked IRQs
>> as per Grygorii's suggestion.
>>
>> drivers/gpio/gpio-davinci.c | 54 +++++++++++++++++++-----------
>> include/linux/platform_data/gpio-davinci.h | 3 +-
>> 2 files changed, 36 insertions(+), 21 deletions(-)
>>
>
> [...]
>
>>
>> @@ -383,7 +396,7 @@ static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset)
>> * can provide direct-mapped IRQs to AINTC (up to 32 GPIOs).
>> */
>> if (offset < d->gpio_unbanked)
>> - return d->base_irq + offset;
>> + return d->irqs[offset];
>
> this one seems right
>
>> else
>> return -ENODEV;
>> }
>> @@ -396,7 +409,7 @@ static int gpio_irq_type_unbanked(struct irq_data *data, unsigned trigger)
>>
>> d = (struct davinci_gpio_controller *)irq_data_get_irq_handler_data(data);
>> g = (struct davinci_gpio_regs __iomem *)d->regs[0];
>> - mask = __gpio_mask(data->irq - d->base_irq);
>> + mask = __gpio_mask(data->irq - d->irqs[0]);
>
> but this one is not. You can't do "base + offset" or "irq - base" ops
> if Irqs range is not sequential. So, in my opinion, here you need to
> convert irq to gpio bank offset (hwirq value in irq_data is not offset
> - gic specific value) which means - walk through d->irqs[x] and find
> item with d->irqs[x] == irq which will give gpio bank offset.
> Than offset can be used to build mask.
Agreed.
>
>>
>> if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
>> return -EINVAL;
>> @@ -458,7 +471,7 @@ static struct irq_chip *keystone_gpio_get_irq_chip(unsigned int irq)
>> * (dm6446) can be set appropriately for GPIOV33 pins.
>> */
>>
>> -static int davinci_gpio_irq_setup(struct platform_device *pdev, int bank_irq)
>
>
> [...]
>
>> #include <asm-generic/gpio.h>
>>
>> #define MAX_REGS_BANKS 5
>> +#define MAX_INT_PER_BANK 32
>>
>> struct davinci_gpio_platform_data {
>> u32 ngpio;
>> @@ -41,7 +42,7 @@ struct davinci_gpio_controller {
>> spinlock_t lock;
>> void __iomem *regs[MAX_REGS_BANKS];
>> int gpio_unbanked;
>> - unsigned int base_irq;
>> + int irqs[MAX_INT_PER_BANK];
>> unsigned int base;
>> };
>>
>>
>
next prev parent reply other threads:[~2018-06-13 1:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-12 7:59 [PATCH v3 1/2] gpio: davinci: Shuffle IRQ resource fetching from DT to beginning of probe Keerthy
2018-06-12 7:59 ` [PATCH v3 2/2] gpio: davinci: Do not assume continuous IRQ numbering Keerthy
2018-06-12 20:06 ` Grygorii Strashko
2018-06-13 1:06 ` J, KEERTHY [this message]
2018-06-13 1:18 ` J, KEERTHY
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=af41c620-6c3c-a348-80c1-89918d0db898@ti.com \
--to=j-keerthy@ti.com \
--cc=grygorii.strashko@ti.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=t-kristo@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®