From patchwork Mon Feb 27 16:45:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 658301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 968A5C7EE2E for ; Mon, 27 Feb 2023 16:54:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230249AbjB0Qy0 (ORCPT ); Mon, 27 Feb 2023 11:54:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbjB0QyZ (ORCPT ); Mon, 27 Feb 2023 11:54:25 -0500 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CF19F76E for ; Mon, 27 Feb 2023 08:54:24 -0800 (PST) Received: by mail-qv1-xf34.google.com with SMTP id ev13so4836306qvb.10 for ; Mon, 27 Feb 2023 08:54:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wzM1FyAgchik+Dup/9deHHYpfXbDm5/FZoytx5b+K08=; b=P3B1CjO7qxyvgQxciO8LtZPx0qQ7K7ufxl/u3qOJDYVbZUKF/qBizuKzBZUJDtsVNH O4p120fia7Hq8Y5zVkTXDvJKdIsszlX6C2ddx+pg1PdIblSgCuvi/w37L11SG0g1Mjpn I18BQIC67zKRlGj9n/gBk+kdqj3l8heqLwbzIEVP85poUcGT3sKBBtdzCecVXT18vGD7 ZW6kVzSpoSHhxdrB6uO3hTTE10JHop/JsxtRHGWd85/3tRjkOuegWw3GSNdF5ExoI0Lj s7QbsV1RpPxFN5nydD8Ni+mp6jsL3+lTMTVOtJNF3p4HO+uTSdj5S1y7ao8tI9eLdvXv jBgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wzM1FyAgchik+Dup/9deHHYpfXbDm5/FZoytx5b+K08=; b=U9dq+wvpVuvMC3HwbX5Y8r4vU5ClSwn+CV3qh2qPtMUJiVa05N0TH3v2HMUHBOPT/4 rQlqZKeGN9G7WOM5eg9fk5PYuU4ZUUwFqmp4p4uMthqwWdwIJrLUCmSPJnsLA8E1i1+d vzSKxh8ul5YKA3/6760Lv5zAbQWl+6viX+mwaNIp7C6yr6ZBFdbDwd2KbGopTgkQ10M7 NCF825KPReqY9jYgcg8x9KgE6MoZeBKjgLsJxtnkBfIsq9AkGyDUMaIS+SHHzKwOpPzv IwjXUKgL14VCQAQIC5dfpJX/CFCvKLf6HNGIfU9iIiM3ufTkBVsqt0w8M/jjoPi9w/Ld UjwQ== X-Gm-Message-State: AO0yUKU5HvgVAkUAmgIhJgF9RzbJBkuz1NO2YK5d9swliKIaT8Vb7M8p 9tFEQiLFCvUgUpOILKn21mbNLw== X-Google-Smtp-Source: AK7set+wTzIvkGOdefHpA+JETrYPiVIYbUJHm8fXQx13Fj4p8cwr3eY0I0JtnJOs9XM4PR3wZIMDZA== X-Received: by 2002:a05:6214:f09:b0:570:bf43:48e with SMTP id gw9-20020a0562140f0900b00570bf43048emr182116qvb.30.1677516863465; Mon, 27 Feb 2023 08:54:23 -0800 (PST) Received: from fedora.attlocal.net (69-109-179-158.lightspeed.dybhfl.sbcglobal.net. [69.109.179.158]) by smtp.gmail.com with ESMTPSA id x15-20020a05620a098f00b0073b929d0371sm5238714qkx.4.2023.02.27.08.54.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 08:54:23 -0800 (PST) From: William Breathitt Gray To: linus.walleij@linaro.org, brgl@bgdev.pl Cc: broonie@kernel.org, andriy.shevchenko@linux.intel.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, William Breathitt Gray Subject: [PATCH v2 1/6] regmap-irq: Add no_status support Date: Mon, 27 Feb 2023 11:45:22 -0500 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Some devices lack status registers, yet expect to handle interrupts. Introduce a no_status flag to indicate such a configuration, where rather than read a status register to verify, all interrupts received are assumed to be active. Cc: Mark Brown Signed-off-by: William Breathitt Gray --- Changes in v2: - Utilize memset32() to set status_buf for no_status case - Utilize GENMASK() to generate status_buf mask - Move no_status kernel doc line under runtime_pm line drivers/base/regmap/regmap-irq.c | 22 +++++++++++++++------- include/linux/regmap.h | 2 ++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index a8f185430a07..290e26664a21 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -437,7 +437,10 @@ static irqreturn_t regmap_irq_thread(int irq, void *d) * possible in order to reduce the I/O overheads. */ - if (chip->num_main_regs) { + if (chip->no_status) { + /* no status register so default to all active */ + memset32(data->status_buf, GENMASK(31, 0), chip->num_regs); + } else if (chip->num_main_regs) { unsigned int max_main_bits; unsigned long size; @@ -967,12 +970,17 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, continue; /* Ack masked but set interrupts */ - reg = d->get_irq_reg(d, d->chip->status_base, i); - ret = regmap_read(map, reg, &d->status_buf[i]); - if (ret != 0) { - dev_err(map->dev, "Failed to read IRQ status: %d\n", - ret); - goto err_alloc; + if (d->chip->no_status) { + /* no status register so default to all active */ + d->status_buf[i] = GENMASK(31, 0); + } else { + reg = d->get_irq_reg(d, d->chip->status_base, i); + ret = regmap_read(map, reg, &d->status_buf[i]); + if (ret != 0) { + dev_err(map->dev, "Failed to read IRQ status: %d\n", + ret); + goto err_alloc; + } } if (chip->status_invert) diff --git a/include/linux/regmap.h b/include/linux/regmap.h index a3bc695bcca0..c6d80d4e73de 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -1564,6 +1564,7 @@ struct regmap_irq_chip_data; * the need for a @sub_reg_offsets table. * @status_invert: Inverted status register: cleared bits are active interrupts. * @runtime_pm: Hold a runtime PM lock on the device when accessing it. + * @no_status: No status register: all interrupts assumed generated by device. * * @num_regs: Number of registers in each control bank. * @irqs: Descriptors for individual IRQs. Interrupt numbers are @@ -1630,6 +1631,7 @@ struct regmap_irq_chip { unsigned int clear_on_unmask:1; unsigned int not_fixed_stride:1; unsigned int status_invert:1; + unsigned int no_status:1; int num_regs;