Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1454421lqh; Mon, 6 May 2024 08:11:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXVW0qwwp0ivswPRMJYBWFrStejwXXkEDVCu8BBz9fUviFSJ3FyN6n+zK80ShEAF4Emx2lYBOujHE72H+aLmkIyfcKXEso3qu9U3iVbPg== X-Google-Smtp-Source: AGHT+IH6p2ShpfdxrONT9jbqTxKm3ty/Jp+etOWuyVw+qIAy7Kd/YkE0RHnx6HhzPg5nhIOk/jtd X-Received: by 2002:a17:907:7da6:b0:a59:ae39:bfba with SMTP id oz38-20020a1709077da600b00a59ae39bfbamr4630225ejc.34.1715008273801; Mon, 06 May 2024 08:11:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715008273; cv=pass; d=google.com; s=arc-20160816; b=iTmq1eF2TpiyYiwhsjdksN99gHup7+y6/yeFx0hFz7tEJBuSIyqWnXYogH2qNccoVo 4CR6Ew8tXDvBrSZR6tNDE+tJnW6nK64kAznSZAltjQp7aaPRgGWBWGjT7g0xrRsh5/jK QSmv+55sQAJLntaPgDBJW8OxmJglJt9niRlh1Vh5c9b0hm/NQw/KhRS1fhf7ZSjJgpmm N/ZEoJwhZPPhxiXlPXgKVNPgDHYUpN7ruYkXWhOfyw4iyxZbNNfcXOcKqvnA9OHHPSaH i8SoH6OQVnagY0fWx1l8AXb7Wa+v6uHT8ptEqvZAr2vAKZeidpgGH6ZmkPQlW1+cVuC4 4g4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4L/8IqU71GmA4YH0QNSv39wMHGGv8sUE+PzIsil0Za8=; fh=Wj77nLC6hlOAsb1H1AZQ+yB5J8vH53oH67JdxycAAGU=; b=A+TLSSWkypiLktfUrk5gLioS/P3119ya/f1NKlcNHlSdXFSqEIpeQpq9sArq8CymVs NeRy2DQ+5SBqluJc8x9WkQlMV3uyxF4jq49S08LZvigpxxfah1FMzTKlg+6SykLAdayN gzHwh/w8A4wzoNhDfX0L8cZYOBPrDwb+I6iW/WT4hY+L6PomqkNj/GmerS/oKWWXuACk f+smnM11iKdZ7ty86biYwU58jUuESEQbwDH30zGnQbvQkQh6e7FKnQb/nvSODzgvl0nc hikzvxdJYwUQ/rCLkGNAwtUcf8iZHBdgTKHXrdKj9mXeWD40MJIIexrP7ZAtpBIpJA+w 5rkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jNWS0c7A; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-170044-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170044-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id b23-20020a170906491700b00a59a2b1c203si3211191ejq.937.2024.05.06.08.11.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 08:11:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170044-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jNWS0c7A; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-170044-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170044-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 613741F223F9 for ; Mon, 6 May 2024 15:11:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A516156661; Mon, 6 May 2024 15:10:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jNWS0c7A" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3218215359F; Mon, 6 May 2024 15:10:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715008215; cv=none; b=uKp73a9814zQTAYj5TX1jTNQxrIi280/LdKIMWJZRjJSLR1yaSKGCLauQc6CovZDCA2Gg+F40tD8Ow9lZS9Vsq6uIEx7+yQtAXn7fp2NNC/g5CEe/p4FARUmrXPB7cFJpF3I1p4vCeIVyZZraFpa5Cj5KZSe/APMsg/z/CwcAVc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715008215; c=relaxed/simple; bh=Wuk22wlBQckYaKY1MQvvxaDZ5/OzjHLdVhwSrf/Ys6E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N09rswsrF+zhk2qF4zF5rb8DL3vtOZfw6BjGJyPweyh9u/K1twpfFx5SVQeibXvZzFRpY2I2vkISTvDZktlt2ejb/A1z0Ooe8gJtHh40Cp52Cnx8h164SPyfJQmbqKKXWm9lyP13c4/J5jUEjK/amv3QQ7jMvi77Za1hm6hTF6o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jNWS0c7A; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE8B2C4AF68; Mon, 6 May 2024 15:10:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715008214; bh=Wuk22wlBQckYaKY1MQvvxaDZ5/OzjHLdVhwSrf/Ys6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jNWS0c7A2MtlH5FWua/YmeJWdwguEgdt3iAsXT8ulGsXej5N4u+NDtwOKva93TXa9 Uq/cOT00nLHdD8QA2jX+eS6/ITnjjxiFOD7kd6IRcG+R7x+YS30C8lbNLpXqlVI5gw YbiJjZV8Iarvmk4z68Y9GW/Oaj3bAmYx/R6HQ43sS6Abk7kFPJTQ+G5Wz7/3I028IF VSYmHTEtPLuRilRQFwQ5+gUJ2292ib2xRfVRxNIUxGghW5xqReR9RGa7RZwHbL5OB1 GLEqcRfkAMRK8BTi9Q5F4+DJqJqFmKmoOaTfzY4DhM7yE3XiqHhiknGIAl8jLh25ix YubgIJO2T9U1Q== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1s3zyp-000000006CB-49HO; Mon, 06 May 2024 17:10:16 +0200 From: Johan Hovold To: Lee Jones , Mark Brown , Linus Walleij , Bjorn Andersson Cc: Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Liam Girdwood , Das Srinagesh , Satya Priya , Stephen Boyd , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Johan Hovold Subject: [PATCH 02/13] mfd: pm8008: fix regmap irq chip initialisation Date: Mon, 6 May 2024 17:08:19 +0200 Message-ID: <20240506150830.23709-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240506150830.23709-1-johan+linaro@kernel.org> References: <20240506150830.23709-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The regmap irq array is potentially shared between multiple PMICs and should only contain static data. Use a custom macro to initialise also the type fields and drop the unnecessary updates on each probe. Fixes: 6b149f3310a4 ("mfd: pm8008: Add driver for QCOM PM8008 PMIC") Signed-off-by: Johan Hovold --- drivers/mfd/qcom-pm8008.c | 66 +++++++++++++++------------------------ 1 file changed, 25 insertions(+), 41 deletions(-) diff --git a/drivers/mfd/qcom-pm8008.c b/drivers/mfd/qcom-pm8008.c index 3ac3742f438b..d53c987b0d49 100644 --- a/drivers/mfd/qcom-pm8008.c +++ b/drivers/mfd/qcom-pm8008.c @@ -56,15 +56,27 @@ static unsigned int pm8008_config_regs[] = { INT_POL_LOW_OFFSET, }; -static struct regmap_irq pm8008_irqs[] = { - REGMAP_IRQ_REG(PM8008_IRQ_MISC_UVLO, PM8008_MISC, BIT(0)), - REGMAP_IRQ_REG(PM8008_IRQ_MISC_OVLO, PM8008_MISC, BIT(1)), - REGMAP_IRQ_REG(PM8008_IRQ_MISC_OTST2, PM8008_MISC, BIT(2)), - REGMAP_IRQ_REG(PM8008_IRQ_MISC_OTST3, PM8008_MISC, BIT(3)), - REGMAP_IRQ_REG(PM8008_IRQ_MISC_LDO_OCP, PM8008_MISC, BIT(4)), - REGMAP_IRQ_REG(PM8008_IRQ_TEMP_ALARM, PM8008_TEMP_ALARM, BIT(0)), - REGMAP_IRQ_REG(PM8008_IRQ_GPIO1, PM8008_GPIO1, BIT(0)), - REGMAP_IRQ_REG(PM8008_IRQ_GPIO2, PM8008_GPIO2, BIT(0)), +#define _IRQ(_irq, _off, _mask, _types) \ + [_irq] = { \ + .reg_offset = (_off), \ + .mask = (_mask), \ + .type = { \ + .type_reg_offset = (_off), \ + .types_supported = (_types), \ + }, \ + } + +#define _IRQ_TYPE_ALL (IRQ_TYPE_EDGE_BOTH | IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW) + +static const struct regmap_irq pm8008_irqs[] = { + _IRQ(PM8008_IRQ_MISC_UVLO, PM8008_MISC, BIT(0), IRQ_TYPE_EDGE_RISING), + _IRQ(PM8008_IRQ_MISC_OVLO, PM8008_MISC, BIT(1), IRQ_TYPE_EDGE_RISING), + _IRQ(PM8008_IRQ_MISC_OTST2, PM8008_MISC, BIT(2), IRQ_TYPE_EDGE_RISING), + _IRQ(PM8008_IRQ_MISC_OTST3, PM8008_MISC, BIT(3), IRQ_TYPE_EDGE_RISING), + _IRQ(PM8008_IRQ_MISC_LDO_OCP, PM8008_MISC, BIT(4), IRQ_TYPE_EDGE_RISING), + _IRQ(PM8008_IRQ_TEMP_ALARM, PM8008_TEMP_ALARM,BIT(0), _IRQ_TYPE_ALL), + _IRQ(PM8008_IRQ_GPIO1, PM8008_GPIO1, BIT(0), _IRQ_TYPE_ALL), + _IRQ(PM8008_IRQ_GPIO2, PM8008_GPIO2, BIT(0), _IRQ_TYPE_ALL), }; static const unsigned int pm8008_periph_base[] = { @@ -143,38 +155,9 @@ static struct regmap_config qcom_mfd_regmap_cfg = { .max_register = 0xFFFF, }; -static int pm8008_probe_irq_peripherals(struct device *dev, - struct regmap *regmap, - int client_irq) -{ - int rc, i; - struct regmap_irq_type *type; - struct regmap_irq_chip_data *irq_data; - - for (i = 0; i < ARRAY_SIZE(pm8008_irqs); i++) { - type = &pm8008_irqs[i].type; - - type->type_reg_offset = pm8008_irqs[i].reg_offset; - - if (type->type_reg_offset == PM8008_MISC) - type->types_supported = IRQ_TYPE_EDGE_RISING; - else - type->types_supported = (IRQ_TYPE_EDGE_BOTH | - IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW); - } - - rc = devm_regmap_add_irq_chip(dev, regmap, client_irq, - IRQF_SHARED, 0, &pm8008_irq_chip, &irq_data); - if (rc) { - dev_err(dev, "Failed to add IRQ chip: %d\n", rc); - return rc; - } - - return 0; -} - static int pm8008_probe(struct i2c_client *client) { + struct regmap_irq_chip_data *irq_data; int rc; struct device *dev; struct regmap *regmap; @@ -187,9 +170,10 @@ static int pm8008_probe(struct i2c_client *client) i2c_set_clientdata(client, regmap); if (of_property_read_bool(dev->of_node, "interrupt-controller")) { - rc = pm8008_probe_irq_peripherals(dev, regmap, client->irq); + rc = devm_regmap_add_irq_chip(dev, regmap, client->irq, + IRQF_SHARED, 0, &pm8008_irq_chip, &irq_data); if (rc) - dev_err(dev, "Failed to probe irq periphs: %d\n", rc); + dev_err(dev, "failed to add IRQ chip: %d\n", rc); } return devm_of_platform_populate(dev); -- 2.43.2