Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3664662pxb; Mon, 4 Oct 2021 07:10:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBA26npsneB3M+Ds/Ut5sxDp3iqq6a6txeict5S9ROKhtGSjGfERur6mrTPLpKXU9joyFI X-Received: by 2002:a50:cd87:: with SMTP id p7mr18388785edi.294.1633356608209; Mon, 04 Oct 2021 07:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633356608; cv=none; d=google.com; s=arc-20160816; b=P/bYF5/1PUUrQRHSif5MSGGnd02dhLLbFXwtwNmuHp8N84k3WrxXgz9dFa6aTGkqBr iYxI71VCjAayx4JTPoWch6/56xxy1yx+xyxAoYYJHF5Zj/llNNPM6ZLf4lW4/aJBtw+E 9hlQk17jar2DzZQ8FSZVAg1aI7EFF+73jjKLFEomWjuRl+yObf3QJY2CLKzE4VH3WMCJ x6/VfE7zwUQGsUeSkfI0K25/PWdDdVUKWM6/+LwpB0DZDIQcEyBdZIK0vP4h7XyDRww8 gbj+gsjfvBdVBB7W8Bs9ohbDVvwjuzp+dC83iZ/mWjtE8p3RAdMICGLwHslyUXDphElC AhcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=9X2zJ02BEA6vucexBKU87r4kULjpk2+10KyNSe9/xww=; b=WUpEnObBhojiiZ8AN/qXGQwLai1P+n59Q56BovHakhON5SgYYuMwCrsoOwe3KSXLtF l0SC1Ov0Fjfez9oasdgDEJ8IG4d9Ix3rK2TX1Qlhj53yW1kcXvajLWutOq5PAkuZZ0NQ VpDWYugOtrihFomJNI3ZItMk0bg7jzE60fwrsWLEw+G14Px+l7KdNmdr4ihzQWFEObxk 0HrOncXLWQ9/bZuxB0XuONv7tLlLQ7kP7iacBKwkaUlVp1YhzFPayY5MEyPIpppYWzV9 LeKgjzL21aCKsRwRFFifKdC7xbAJWHPI87hkULoLy1ytnj1zyhy3cEQ7NQuXoU5JbLEQ HmQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si17269506ejk.702.2021.10.04.07.09.34; Mon, 04 Oct 2021 07:10:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230010AbhJDMqa (ORCPT + 99 others); Mon, 4 Oct 2021 08:46:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233141AbhJDMq3 (ORCPT ); Mon, 4 Oct 2021 08:46:29 -0400 Received: from baptiste.telenet-ops.be (baptiste.telenet-ops.be [IPv6:2a02:1800:120:4::f00:13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC50EC061749 for ; Mon, 4 Oct 2021 05:44:39 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed20:9ca4:a53a:9ffa:e003]) by baptiste.telenet-ops.be with bizsmtp id 1okb2600G11933301okbfx; Mon, 04 Oct 2021 14:44:38 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1mXNKd-001rhi-9u; Mon, 04 Oct 2021 14:44:35 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1mXNKc-0042wr-Lg; Mon, 04 Oct 2021 14:44:34 +0200 From: Geert Uytterhoeven To: Linus Walleij , Bartosz Golaszewski , Viresh Kumar , Enrico@rox.of.borg, Weigelt@rox.of.borg, metux IT consult , Andy Shevchenko , Arnd Bergmann Cc: linux-gpio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, stratos-dev@op-lists.linaro.org, Geert Uytterhoeven Subject: [PATCH] gpio: aggregator: Add interrupt support Date: Mon, 4 Oct 2021 14:44:33 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the GPIO Aggregator does not support interrupts. This means that kernel drivers going from a GPIO to an IRQ using gpiod_to_irq(), and userspace applications using line events do not work. Add interrupt support by providing a gpio_chip.to_irq() callback, which just calls into the parent GPIO controller. Note that this does not implement full interrupt controller (irq_chip) support, so using e.g. gpio-keys with "interrupts" instead of "gpios" still does not work. Signed-off-by: Geert Uytterhoeven --- I would prefer to avoid implementing irq_chip support, until there is a real use case for this. This has been tested with gpio-keys and gpiomon on the Koelsch development board: - gpio-keys, using a DT overlay[1]: $ overlay add r8a7791-koelsch-keyboard-controlled-led $ echo gpio-aggregator > /sys/devices/platform/frobnicator/driver_override $ echo frobnicator > /sys/bus/platform/drivers/gpio-aggregator/bind $ gpioinfo frobnicator gpiochip12 - 3 lines: line 0: "light" "light" output active-high [used] line 1: "on" "On" input active-low [used] line 2: "off" "Off" input active-low [used] $ echo 255 > /sys/class/leds/light/brightness $ echo 0 > /sys/class/leds/light/brightness $ evtest /dev/input/event0 - gpiomon, using the GPIO sysfs API: $ echo keyboard > /sys/bus/platform/drivers/gpio-keys/unbind $ echo e6055800.gpio 2,6 > /sys/bus/platform/drivers/gpio-aggregator/new_device $ gpiomon gpiochip12 0 1 [1] "ARM: dts: koelsch: Add overlay for keyboard-controlled LED" https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git/commit/?h=topic/renesas-overlays&id=c78d817869e63a3485bb4ab98aeea6ce368a396e --- drivers/gpio/gpio-aggregator.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c index 34e35b64dcdc0581..2ff867d2a3630d3b 100644 --- a/drivers/gpio/gpio-aggregator.c +++ b/drivers/gpio/gpio-aggregator.c @@ -374,6 +374,13 @@ static int gpio_fwd_set_config(struct gpio_chip *chip, unsigned int offset, return gpiod_set_config(fwd->descs[offset], config); } +static int gpio_fwd_to_irq(struct gpio_chip *chip, unsigned int offset) +{ + struct gpiochip_fwd *fwd = gpiochip_get_data(chip); + + return gpiod_to_irq(fwd->descs[offset]); +} + /** * gpiochip_fwd_create() - Create a new GPIO forwarder * @dev: Parent device pointer @@ -414,7 +421,8 @@ static struct gpiochip_fwd *gpiochip_fwd_create(struct device *dev, for (i = 0; i < ngpios; i++) { struct gpio_chip *parent = gpiod_to_chip(descs[i]); - dev_dbg(dev, "%u => gpio-%d\n", i, desc_to_gpio(descs[i])); + dev_dbg(dev, "%u => gpio %d irq %d\n", i, + desc_to_gpio(descs[i]), gpiod_to_irq(descs[i])); if (gpiod_cansleep(descs[i])) chip->can_sleep = true; @@ -432,6 +440,7 @@ static struct gpiochip_fwd *gpiochip_fwd_create(struct device *dev, chip->get_multiple = gpio_fwd_get_multiple_locked; chip->set = gpio_fwd_set; chip->set_multiple = gpio_fwd_set_multiple_locked; + chip->to_irq = gpio_fwd_to_irq; chip->base = -1; chip->ngpio = ngpios; fwd->descs = descs; -- 2.25.1