From: Billy Tsai <billy_tsai@aspeedtech.com>
To: Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Joel Stanley <joel@jms.id.au>,
Andrew Jeffery <andrew@codeconstruct.com.au>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: <linux-gpio@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-aspeed@lists.ozlabs.org>, <linux-kernel@vger.kernel.org>,
"Andrew Jeffery" <andrew@aj.id.au>, <devicetree@vger.kernel.org>,
<bmc-sw@aspeedtech.com>, Billy Tsai <billy_tsai@aspeedtech.com>
Subject: [PATCH v2 4/6] gpio: aspeed-sgpio: Convert IRQ functions to use llops callbacks
Date: Fri, 23 Jan 2026 17:26:29 +0800 [thread overview]
Message-ID: <20260123-upstream_sgpio-v2-4-69cfd1631400@aspeedtech.com> (raw)
In-Reply-To: <20260123-upstream_sgpio-v2-0-69cfd1631400@aspeedtech.com>
Update aspeed_sgpio_irq_handler() and aspeed_sgpio_setup_irqs() to use
the llops callbacks for register access instead of direct iowrite32().
This creates a unified hardware access layer, which is essential for
supporting SoCs with different register layouts like the AST2700.
Additionally, change the loop bounds to use ngpio instead of the static
ARRAY_SIZE(aspeed_sgpio_banks). This allows the driver to adapt to the
actual number of supported pins on the running SoC.
Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
---
drivers/gpio/gpio-aspeed-sgpio.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/gpio/gpio-aspeed-sgpio.c b/drivers/gpio/gpio-aspeed-sgpio.c
index 33a830ea7d28..b5270e11b153 100644
--- a/drivers/gpio/gpio-aspeed-sgpio.c
+++ b/drivers/gpio/gpio-aspeed-sgpio.c
@@ -319,12 +319,13 @@ static void aspeed_sgpio_irq_handler(struct irq_desc *desc)
struct gpio_chip *gc = irq_desc_get_handler_data(desc);
struct irq_chip *ic = irq_desc_get_chip(desc);
struct aspeed_sgpio *data = gpiochip_get_data(gc);
- unsigned int i, p;
+ unsigned int i, p, banks;
unsigned long reg;
chained_irq_enter(ic, desc);
- for (i = 0; i < ARRAY_SIZE(aspeed_sgpio_banks); i++) {
+ banks = DIV_ROUND_UP(gc->ngpio, 64);
+ for (i = 0; i < banks; i++) {
reg = data->pdata->llops->reg_bank_get(data, i << 6, reg_irq_status);
for_each_set_bit(p, ®, 32)
@@ -355,7 +356,6 @@ static int aspeed_sgpio_setup_irqs(struct aspeed_sgpio *gpio,
struct platform_device *pdev)
{
int rc, i;
- const struct aspeed_sgpio_bank *bank;
struct gpio_irq_chip *irq;
rc = platform_get_irq(pdev, 0);
@@ -365,12 +365,11 @@ static int aspeed_sgpio_setup_irqs(struct aspeed_sgpio *gpio,
gpio->irq = rc;
/* Disable IRQ and clear Interrupt status registers for all SGPIO Pins. */
- for (i = 0; i < ARRAY_SIZE(aspeed_sgpio_banks); i++) {
- bank = &aspeed_sgpio_banks[i];
+ for (i = 0; i < gpio->chip.ngpio; i += 2) {
/* disable irq enable bits */
- iowrite32(0x00000000, bank_reg(gpio, bank, reg_irq_enable));
+ gpio->pdata->llops->reg_bit_set(gpio, i, reg_irq_enable, 0);
/* clear status bits */
- iowrite32(0xffffffff, bank_reg(gpio, bank, reg_irq_status));
+ gpio->pdata->llops->reg_bit_set(gpio, i, reg_irq_status, 1);
}
irq = &gpio->chip.irq;
@@ -384,14 +383,13 @@ static int aspeed_sgpio_setup_irqs(struct aspeed_sgpio *gpio,
irq->num_parents = 1;
/* Apply default IRQ settings */
- for (i = 0; i < ARRAY_SIZE(aspeed_sgpio_banks); i++) {
- bank = &aspeed_sgpio_banks[i];
+ for (i = 0; i < gpio->chip.ngpio; i += 2) {
/* set falling or level-low irq */
- iowrite32(0x00000000, bank_reg(gpio, bank, reg_irq_type0));
+ gpio->pdata->llops->reg_bit_set(gpio, i, reg_irq_type0, 0);
/* trigger type is edge */
- iowrite32(0x00000000, bank_reg(gpio, bank, reg_irq_type1));
+ gpio->pdata->llops->reg_bit_set(gpio, i, reg_irq_type1, 0);
/* single edge trigger */
- iowrite32(0x00000000, bank_reg(gpio, bank, reg_irq_type2));
+ gpio->pdata->llops->reg_bit_set(gpio, i, reg_irq_type2, 0);
}
return 0;
--
2.34.1
next prev parent reply other threads:[~2026-01-23 9:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 9:26 [PATCH v2 0/6] Add Aspeed G7 sgpio support Billy Tsai
2026-01-23 9:26 ` [PATCH v2 1/6] gpio: aspeed-sgpio: Change the macro to support deferred probe Billy Tsai
2026-01-23 9:26 ` [PATCH v2 2/6] gpio: aspeed-sgpio: Remove unused bank name field Billy Tsai
2026-01-23 9:26 ` [PATCH v2 3/6] gpio: aspeed-sgpio: Create llops to handle hardware access Billy Tsai
2026-01-23 9:26 ` Billy Tsai [this message]
2026-01-23 9:26 ` [PATCH v2 5/6] dt-bindings: gpio: aspeed,sgpio: Support ast2700 Billy Tsai
2026-01-23 9:26 ` [PATCH v2 6/6] gpio: aspeed-sgpio: Support G7 Aspeed sgpiom controller Billy Tsai
2026-01-27 10:18 ` [PATCH v2 0/6] Add Aspeed G7 sgpio support Bartosz Golaszewski
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=20260123-upstream_sgpio-v2-4-69cfd1631400@aspeedtech.com \
--to=billy_tsai@aspeedtech.com \
--cc=andrew@aj.id.au \
--cc=andrew@codeconstruct.com.au \
--cc=bmc-sw@aspeedtech.com \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=joel@jms.id.au \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
/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®