* [PATCH v3] gpio: sifive: To get gpio irq offset from device tree data
@ 2020-11-13 2:33 Greentime Hu
2020-11-13 9:00 ` Bartosz Golaszewski
2020-11-18 8:29 ` Bartosz Golaszewski
0 siblings, 2 replies; 4+ messages in thread
From: Greentime Hu @ 2020-11-13 2:33 UTC (permalink / raw)
To: greentime.hu, linux-kernel, linus.walleij, bgolaszewski,
linux-gpio, linux-riscv, palmer, paul.walmsley, andy.shevchenko,
yash.shah
We can get hwirq number of the gpio by its irq_data->hwirq so that we don't
need to add more macros for different platforms. This patch is tested in
SiFive Unleashed board and SiFive Unmatched board.
Signed-off-by: Greentime Hu <greentime.hu@sifive.com>
---
drivers/gpio/gpio-sifive.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
index c54dd08f2cbf..630bddec48e5 100644
--- a/drivers/gpio/gpio-sifive.c
+++ b/drivers/gpio/gpio-sifive.c
@@ -29,7 +29,6 @@
#define SIFIVE_GPIO_OUTPUT_XOR 0x40
#define SIFIVE_GPIO_MAX 32
-#define SIFIVE_GPIO_IRQ_OFFSET 7
struct sifive_gpio {
void __iomem *base;
@@ -37,7 +36,7 @@ struct sifive_gpio {
struct regmap *regs;
unsigned long irq_state;
unsigned int trigger[SIFIVE_GPIO_MAX];
- unsigned int irq_parent[SIFIVE_GPIO_MAX];
+ unsigned int irq_number[SIFIVE_GPIO_MAX];
};
static void sifive_gpio_set_ie(struct sifive_gpio *chip, unsigned int offset)
@@ -144,8 +143,12 @@ static int sifive_gpio_child_to_parent_hwirq(struct gpio_chip *gc,
unsigned int *parent,
unsigned int *parent_type)
{
+ struct sifive_gpio *chip = gpiochip_get_data(gc);
+ struct irq_data *d = irq_get_irq_data(chip->irq_number[child]);
+
*parent_type = IRQ_TYPE_NONE;
- *parent = child + SIFIVE_GPIO_IRQ_OFFSET;
+ *parent = irqd_to_hwirq(d);
+
return 0;
}
@@ -165,7 +168,7 @@ static int sifive_gpio_probe(struct platform_device *pdev)
struct irq_domain *parent;
struct gpio_irq_chip *girq;
struct sifive_gpio *chip;
- int ret, ngpio;
+ int ret, ngpio, i;
chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
@@ -200,6 +203,9 @@ static int sifive_gpio_probe(struct platform_device *pdev)
return -ENODEV;
}
+ for (i = 0; i < ngpio; i++)
+ chip->irq_number[i] = platform_get_irq(pdev, i);
+
ret = bgpio_init(&chip->gc, dev, 4,
chip->base + SIFIVE_GPIO_INPUT_VAL,
chip->base + SIFIVE_GPIO_OUTPUT_VAL,
--
2.29.2
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] gpio: sifive: To get gpio irq offset from device tree data
2020-11-13 2:33 [PATCH v3] gpio: sifive: To get gpio irq offset from device tree data Greentime Hu
@ 2020-11-13 9:00 ` Bartosz Golaszewski
2020-11-13 9:20 ` Greentime Hu
2020-11-18 8:29 ` Bartosz Golaszewski
1 sibling, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2020-11-13 9:00 UTC (permalink / raw)
To: Greentime Hu
Cc: Linus Walleij, LKML, linux-gpio, Andy Shevchenko, Palmer Dabbelt,
Yash Shah, Paul Walmsley, linux-riscv
On Fri, Nov 13, 2020 at 3:34 AM Greentime Hu <greentime.hu@sifive.com> wrote:
>
> We can get hwirq number of the gpio by its irq_data->hwirq so that we don't
> need to add more macros for different platforms. This patch is tested in
> SiFive Unleashed board and SiFive Unmatched board.
>
> Signed-off-by: Greentime Hu <greentime.hu@sifive.com>
> ---
Please list the changes between versions of patches. What has changed since v2?
Bartosz
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] gpio: sifive: To get gpio irq offset from device tree data
2020-11-13 9:00 ` Bartosz Golaszewski
@ 2020-11-13 9:20 ` Greentime Hu
0 siblings, 0 replies; 4+ messages in thread
From: Greentime Hu @ 2020-11-13 9:20 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Linus Walleij, LKML, linux-gpio, Andy Shevchenko, Palmer Dabbelt,
Yash Shah, Paul Walmsley, linux-riscv
Bartosz Golaszewski <bgolaszewski@baylibre.com> 於 2020年11月13日 週五 下午5:00寫道:
>
> On Fri, Nov 13, 2020 at 3:34 AM Greentime Hu <greentime.hu@sifive.com> wrote:
> >
> > We can get hwirq number of the gpio by its irq_data->hwirq so that we don't
> > need to add more macros for different platforms. This patch is tested in
> > SiFive Unleashed board and SiFive Unmatched board.
> >
> > Signed-off-by: Greentime Hu <greentime.hu@sifive.com>
> > ---
>
> Please list the changes between versions of patches. What has changed since v2?
changes in v3:
Add 2 newlines
changes in v2:
Use irqd_to_hwirq() instead of d->hwirq and platform_get_irq()
instead of irq_of_parse_and_map()
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] gpio: sifive: To get gpio irq offset from device tree data
2020-11-13 2:33 [PATCH v3] gpio: sifive: To get gpio irq offset from device tree data Greentime Hu
2020-11-13 9:00 ` Bartosz Golaszewski
@ 2020-11-18 8:29 ` Bartosz Golaszewski
1 sibling, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2020-11-18 8:29 UTC (permalink / raw)
To: Greentime Hu
Cc: Linus Walleij, LKML, linux-gpio, Andy Shevchenko, Palmer Dabbelt,
Yash Shah, Paul Walmsley, linux-riscv
On Fri, Nov 13, 2020 at 3:34 AM Greentime Hu <greentime.hu@sifive.com> wrote:
>
> We can get hwirq number of the gpio by its irq_data->hwirq so that we don't
> need to add more macros for different platforms. This patch is tested in
> SiFive Unleashed board and SiFive Unmatched board.
>
> Signed-off-by: Greentime Hu <greentime.hu@sifive.com>
> ---
> drivers/gpio/gpio-sifive.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
> index c54dd08f2cbf..630bddec48e5 100644
> --- a/drivers/gpio/gpio-sifive.c
> +++ b/drivers/gpio/gpio-sifive.c
> @@ -29,7 +29,6 @@
> #define SIFIVE_GPIO_OUTPUT_XOR 0x40
>
> #define SIFIVE_GPIO_MAX 32
> -#define SIFIVE_GPIO_IRQ_OFFSET 7
>
> struct sifive_gpio {
> void __iomem *base;
> @@ -37,7 +36,7 @@ struct sifive_gpio {
> struct regmap *regs;
> unsigned long irq_state;
> unsigned int trigger[SIFIVE_GPIO_MAX];
> - unsigned int irq_parent[SIFIVE_GPIO_MAX];
> + unsigned int irq_number[SIFIVE_GPIO_MAX];
> };
>
> static void sifive_gpio_set_ie(struct sifive_gpio *chip, unsigned int offset)
> @@ -144,8 +143,12 @@ static int sifive_gpio_child_to_parent_hwirq(struct gpio_chip *gc,
> unsigned int *parent,
> unsigned int *parent_type)
> {
> + struct sifive_gpio *chip = gpiochip_get_data(gc);
> + struct irq_data *d = irq_get_irq_data(chip->irq_number[child]);
> +
> *parent_type = IRQ_TYPE_NONE;
> - *parent = child + SIFIVE_GPIO_IRQ_OFFSET;
> + *parent = irqd_to_hwirq(d);
> +
> return 0;
> }
>
> @@ -165,7 +168,7 @@ static int sifive_gpio_probe(struct platform_device *pdev)
> struct irq_domain *parent;
> struct gpio_irq_chip *girq;
> struct sifive_gpio *chip;
> - int ret, ngpio;
> + int ret, ngpio, i;
>
> chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
> if (!chip)
> @@ -200,6 +203,9 @@ static int sifive_gpio_probe(struct platform_device *pdev)
> return -ENODEV;
> }
>
> + for (i = 0; i < ngpio; i++)
> + chip->irq_number[i] = platform_get_irq(pdev, i);
> +
> ret = bgpio_init(&chip->gc, dev, 4,
> chip->base + SIFIVE_GPIO_INPUT_VAL,
> chip->base + SIFIVE_GPIO_OUTPUT_VAL,
> --
> 2.29.2
>
Applied, thanks!
Bart
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-18 8:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13 2:33 [PATCH v3] gpio: sifive: To get gpio irq offset from device tree data Greentime Hu
2020-11-13 9:00 ` Bartosz Golaszewski
2020-11-13 9:20 ` Greentime Hu
2020-11-18 8:29 ` Bartosz Golaszewski
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).