From: Miao Wang via B4 Relay <devnull+shankerwangmiao.gmail.com@kernel.org>
To: Yinbo Zhu <zhuyinbo@loongson.cn>,
Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Miao Wang <shankerwangmiao@gmail.com>
Subject: [PATCH RFC v2 2/4] gpio: loongson-64bit: Generalize interrupt controller initialization
Date: Fri, 02 Oct 2026 02:13:20 +0800 [thread overview]
Message-ID: <20261002-loongsongpio-v2-2-6e3eb150a4ef@gmail.com> (raw)
In-Reply-To: <20261002-loongsongpio-v2-0-6e3eb150a4ef@gmail.com>
From: Miao Wang <shankerwangmiao@gmail.com>
This patch turns the interrupt controller initialization function into
a handler in struct loongson_gpio_chip_data, which will be called by
loongson_gpio_init(), so that we can add support for different types
of interrupt controllers.
Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
---
drivers/gpio/gpio-loongson-64bit.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/gpio/gpio-loongson-64bit.c b/drivers/gpio/gpio-loongson-64bit.c
index 64eb9f46ce31cc289f236af44311ff39f05de3b0..a1b23ba21f64162af2096131520d1dac27798983 100644
--- a/drivers/gpio/gpio-loongson-64bit.c
+++ b/drivers/gpio/gpio-loongson-64bit.c
@@ -39,6 +39,8 @@ struct loongson_gpio_chip_data {
unsigned int intr_num;
irq_flow_handler_t irq_handler;
const struct irq_chip *girqchip;
+ int (*irq_init)(struct platform_device *pdev,
+ struct loongson_gpio_chip *lgpio);
};
struct loongson_gpio_chip {
@@ -286,11 +288,6 @@ static int loongson_gpio_init_irqchip(struct platform_device *pdev,
writeb(0x1, lgpio->reg_base + data->intclr_offset + i);
}
- if (chip->irq.num_parents == 0) {
- dev_warn(&pdev->dev, "no parent IRQs have been found, GPIO IRQs will not be available\n");
- gpio_irq_chip_set_chip(&chip->irq, NULL);
- }
-
return 0;
}
@@ -329,9 +326,13 @@ static int loongson_gpio_init(struct platform_device *pdev, struct loongson_gpio
lgpio->chip.gc.label = lgpio->chip_data->label;
lgpio->chip.gc.can_sleep = false;
if (lgpio->chip_data->girqchip) {
- ret = loongson_gpio_init_irqchip(pdev, lgpio);
+ ret = lgpio->chip_data->irq_init(pdev, lgpio);
if (ret)
return dev_err_probe(&pdev->dev, ret, "failed to initialize irqchip\n");
+ if (lgpio->chip.gc.irq.num_parents == 0) {
+ dev_warn(&pdev->dev, "no parent IRQs ha been found, GPIO IRQs will not be available\n");
+ gpio_irq_chip_set_chip(&lgpio->chip.gc.irq, NULL);
+ }
} else if (lgpio->chip_data->inten_offset) {
lgpio->chip.gc.to_irq = loongson_gpio_to_irq;
}
@@ -387,6 +388,7 @@ static const struct loongson_gpio_chip_data loongson_gpio_ls2k0300_data = {
.intr_num = 7,
.irq_handler = loongson_gpio_ls2k0300_irq_handler,
.girqchip = &loongson_gpio_ls2k0300_irqchip,
+ .irq_init = loongson_gpio_init_irqchip,
};
static const struct loongson_gpio_chip_data loongson_gpio_ls2k0500_data0 = {
@@ -430,6 +432,7 @@ static const struct loongson_gpio_chip_data loongson_gpio_ls2k2000_data1 = {
.intr_num = 8,
.irq_handler = loongson_gpio_ls2k0300_irq_handler,
.girqchip = &loongson_gpio_ls2k0300_irqchip,
+ .irq_init = loongson_gpio_init_irqchip,
};
static const struct loongson_gpio_chip_data loongson_gpio_ls2k2000_data2 = {
@@ -473,6 +476,7 @@ static const struct loongson_gpio_chip_data loongson_gpio_ls7a2000_data0 = {
.intr_num = 5,
.irq_handler = loongson_gpio_ls2k0300_irq_handler,
.girqchip = &loongson_gpio_ls2k0300_irqchip,
+ .irq_init = loongson_gpio_init_irqchip,
};
/* LS7A2000 ACPI GPIO */
--
2.55.0
next prev parent reply other threads:[~2026-10-01 18:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 18:13 [PATCH RFC v2 0/4] gpio: loongson-64bit: add interrupt support for more models Miao Wang via B4 Relay
2026-10-01 18:13 ` [PATCH RFC v2 1/4] gpio: loongson-64bit: Support for irq controller on 2k2000 and 7a2000 Miao Wang via B4 Relay
2026-10-01 18:13 ` Miao Wang via B4 Relay [this message]
2026-10-01 18:13 ` [PATCH RFC v2 3/4] gpio: loongson-64bit: Add shared interrupt support Miao Wang via B4 Relay
2026-10-01 18:13 ` [PATCH RFC v2 4/4] gpio: loongson-64bit: remove gpio_to_irq() handler Miao Wang via B4 Relay
2026-10-08 10:04 ` [PATCH RFC v2 0/4] gpio: loongson-64bit: add interrupt support for more models Bartosz Golaszewski
2026-10-08 10:21 ` Miao Wang
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=20261002-loongsongpio-v2-2-6e3eb150a4ef@gmail.com \
--to=devnull+shankerwangmiao.gmail.com@kernel.org \
--cc=brgl@kernel.org \
--cc=jiaxun.yang@flygoat.com \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shankerwangmiao@gmail.com \
--cc=zhuyinbo@loongson.cn \
/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®