From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f49.google.com (mail-dl1-f49.google.com [74.125.82.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 593552F8E90 for ; Sun, 28 Jun 2026 23:02:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782687726; cv=none; b=RBxmGGYm4ZELNE3gqhDY3/EjtPruTK4/1R84H/UQsDDgUz+HsvgeMs6/46wHAKSAwHdSdk9g3OOcacm7wtQmOH+ngwf2Jxjz3xSe7daK6SKbYVUYIKH4TpvavnlGQIp+b+WwDn0t6HDCZ099hLFSxWJpGkV4R0tuNnAucQx53z4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782687726; c=relaxed/simple; bh=CNHUAK/S24oDKcBpryQESBqdNmm6Qn/xKxs0WrC9iSA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rR8Fm/ZqApcm8J1LZ+cx0Mpw3drq5PIJ9WvoMvfmMSFBqD0Bb5C/nynTw68T1rDYyDOmKbiMyF6URy1ihMLQOyjc8Jr5/BPJT7ktx+5jDV/DR/xCwRXxe1VOgnY36rbeqo3rJCI84LQqkRHbt3dwwEQ1z+rjUARq/40FYisY93E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IMWgbM9D; arc=none smtp.client-ip=74.125.82.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IMWgbM9D" Received: by mail-dl1-f49.google.com with SMTP id a92af1059eb24-139f1dfc9faso1633194c88.0 for ; Sun, 28 Jun 2026 16:02:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782687724; x=1783292524; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YMZ10IYFKNLnYKr+gx1rVCyYcTm3FWyqJhOk5IPgR8w=; b=IMWgbM9D92XEq7+Dx6g4tATkmly/LJiEElhHkb4X1CERuG+1Gs7V48pKBtWmtzaCRs UYIo7HuuiqnSR3MnG8SLqUxzN7ruon7+qMmLGmPHkSdZFdjqw73ton4VswwMdnGApeOp vAQUDcjYLM2FyePggCZ7yj76CMTjh77iz/KQnWx10zDAXwVHoWFmFrusZV7uxIxUqRbB 9Zmw02wIhdzuBBKSMcqY7VrHwyjzV9wP5Br6pxEJf/BtrkDO00q3JDmWV622ZiRZ6WqI 9efHmhxloaE0BTIqZg975XLUjsrHaNnMa+x2DvKHfQMglaah8xSD7fJ4gh4+ry4TeCz8 BBCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782687724; x=1783292524; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YMZ10IYFKNLnYKr+gx1rVCyYcTm3FWyqJhOk5IPgR8w=; b=FqAtbuPzmOHMxpNZyBjtHZG0rD1GUDuCUY580Vud6WBMwRCEjrDLdqfwIf/1frpIH/ 7Sh7/99SFHCOqriDKO1pQbcVCjdufPzs+ubRy/F29l2zV+p75gOj07DYeRJzT3pdfIAH thwVJS5UsWPGx3Q45SYGer6jDFI8dzaFhtuqSIgP13XPDiiXgyxkncoGgvdHdezIq3Ov CU1wZO1lC6tAPT3kl9S5IgwgBB28ROLetGli4913Bqt+fyYP8ZBu5poh4gWU0iA5bgJa YVM7mN2DeAhvLr4Ak6U6WyK11CAZ0pPLgT2Iz5s0YFoOS56qD8ooE6d0tB9CeqRulz2A hOMQ== X-Forwarded-Encrypted: i=1; AFNElJ+Y3LGjpHd48KUCv0NdllHc88Pvv9uWUeNR7xcytMRNb9xlpc7cRNFs30GYUQw3afCKG77hsixUi1WNJKE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxrym+d3D03OKz63gx7IsRY97rkcAZBUAscDE6ZNf/ClCidYhzD UnuqiR8zkIS9pH3xF84SHjsC7GKFnGrGWyi/ndQfFkrKR0Z9M94fvxWO X-Gm-Gg: AfdE7ckENdf7XpiFo0pPTBWXIZ+nRFlu4kf82fE0awELPKw/OHdiCoe9cJQkdNB8kSK YP2QXTv332oC+V2qc0XGqurMz9QFrNnZFhnbbGIrvkdN2vEzQqBAdRNDlthQ0H1NIt3IzKvlrFR RDsQHFNt57bbyiIKRc2DlERYh2o+bGAVkZ7eUy++DgdygKpR5bw4xHwdkiwdJy6qsV63d5pcisZ JvCdek5I2lqtFlicTImIFpxlsprtaH2mzdKuy6V/2oNzqVjLdt2AswUUOXGu5DxvCyCamPzLuyu vRrYXGzmvlwdBOx8fVrS7ccxCQ8hwQQLjQtc5TbOYJz2IRaubETSZ+6alsGQQZ3icEufIaltqqG F03Y655kNKog07RFSya70Xhjj++42L2h496sQG+FJi9m0T6CHbROlgxo4+6VlLH00AnGHe/8ZNb yFfKk30k0okaf8/7Q1I6H3/ow7AFpyvA0uaVThpVwHIDJFIEs7GDUXIrQDElTMrx94aWNgPvwRr HynI0AY+g== X-Received: by 2002:a05:7022:e0e:b0:139:c724:79e5 with SMTP id a92af1059eb24-139dbac7a8cmr11480937c88.35.1782687724240; Sun, 28 Jun 2026 16:02:04 -0700 (PDT) Received: from ryzen.lan ([2601:644:8000:7a86::e34]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-139d8f318e7sm41365965c88.3.2026.06.28.16.02.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jun 2026 16:02:03 -0700 (PDT) From: Rosen Penev To: linux-gpio@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] gpio: mvebu: add wake-up interrupt support Date: Sun, 28 Jun 2026 16:02:02 -0700 Message-ID: <20260628230202.1209991-1-rosenp@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Implement wake IRQ support for the mvebu GPIO controller: - Replace unused irqbase field with bank_irq[4] to store per-bank IRQ numbers for use in the wake-up callback. - Add mvebu_gpio_set_wake_irq() that forwards enable_irq_wake / disable_irq_wake to the correct parent IRQ based on hwirq. - Set IRQCHIP_SET_TYPE_MASKED and IRQCHIP_MASK_ON_SUSPEND flags on both level and edge chip types. - Set IRQ_GC_INIT_NESTED_LOCK for the nested irq domain. - Add missing include. Assisted-by: opencode:big-pickle Signed-off-by: Rosen Penev --- drivers/gpio/gpio-mvebu.c | 40 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index c030d1f00abc..26092b223be5 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -114,7 +115,7 @@ struct mvebu_gpio_chip { struct regmap *regs; u32 offset; struct regmap *percpu_regs; - int irqbase; + int bank_irq[4]; struct irq_domain *domain; int soc_variant; @@ -603,6 +604,34 @@ static const struct regmap_config mvebu_gpio_regmap_config = { .val_bits = 32, }; +/* + * Forward wake-up configuration to the parent bank IRQ. + * @d: interrupt data + * @enable: enable as wake-up if non-zero + * + * Return: 0 on success, or a negative error code. + */ +static int mvebu_gpio_set_wake_irq(struct irq_data *d, unsigned int enable) +{ + struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); + struct mvebu_gpio_chip *mvchip = gc->private; + int bank; + int irq; + + bank = d->hwirq / 8; + if (bank >= ARRAY_SIZE(mvchip->bank_irq)) + return -EINVAL; + + irq = mvchip->bank_irq[bank]; + if (irq <= 0) + return -EINVAL; + + if (enable) + return enable_irq_wake(irq); + + return disable_irq_wake(irq); +} + /* * Functions implementing the pwm_chip methods */ @@ -1249,7 +1278,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev) err = irq_alloc_domain_generic_chips( mvchip->domain, ngpios, 2, np->name, handle_level_irq, - IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_LEVEL, 0, 0); + IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_LEVEL, 0, IRQ_GC_INIT_NESTED_LOCK); if (err) { dev_err(&pdev->dev, "couldn't allocate irq chips %s (DT).\n", mvchip->chip.label); @@ -1267,6 +1296,8 @@ static int mvebu_gpio_probe(struct platform_device *pdev) ct->chip.irq_mask = mvebu_gpio_level_irq_mask; ct->chip.irq_unmask = mvebu_gpio_level_irq_unmask; ct->chip.irq_set_type = mvebu_gpio_irq_set_type; + ct->chip.irq_set_wake = mvebu_gpio_set_wake_irq; + ct->chip.flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; ct->chip.name = mvchip->chip.label; ct = &gc->chip_types[1]; @@ -1275,6 +1306,8 @@ static int mvebu_gpio_probe(struct platform_device *pdev) ct->chip.irq_mask = mvebu_gpio_edge_irq_mask; ct->chip.irq_unmask = mvebu_gpio_edge_irq_unmask; ct->chip.irq_set_type = mvebu_gpio_irq_set_type; + ct->chip.irq_set_wake = mvebu_gpio_set_wake_irq; + ct->chip.flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; ct->handler = handle_edge_irq; ct->chip.name = mvchip->chip.label; @@ -1283,13 +1316,14 @@ static int mvebu_gpio_probe(struct platform_device *pdev) * interrupt handlers, with each handler dealing with 8 GPIO * pins. */ - for (i = 0; i < 4; i++) { + for (i = 0; i < ARRAY_SIZE(mvchip->bank_irq); i++) { int irq = platform_get_irq_optional(pdev, i); if (irq < 0) continue; irq_set_chained_handler_and_data(irq, mvebu_gpio_irq_handler, mvchip); + mvchip->bank_irq[i] = irq; } return 0; -- 2.54.0