Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp130197lqp; Sat, 8 Jun 2024 08:58:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUcR4Sc+6y2BikqRrSrnjrP9DesMmJB4YWip75wHFy8Qk+/u3c2hveelm12YR57FMhRscRlKDD9cXHk/Z/C06uL/P0i5PRnRpe+DiXvxw== X-Google-Smtp-Source: AGHT+IH15ztEM5tIcGFiooTtxAmWef2lD7uEL3DzyolexP3Bm7u8rhaHsVKNgzqkjntYefX4gU0S X-Received: by 2002:a50:d65a:0:b0:57c:600d:5875 with SMTP id 4fb4d7f45d1cf-57c600d58f7mr2113747a12.24.1717862297636; Sat, 08 Jun 2024 08:58:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717862297; cv=pass; d=google.com; s=arc-20160816; b=EZ8yqpKD2vXENmaPwrpqb5TTTjgzFVp9vQvKeWRCXaJcHDJjgdqkr6fc/uxvRD0QI0 VPKPiCkjrNYRyCUhcMXh8QmWj1lckdgVfipZk5idZJkAjMmBjKVHnN9d7wLCnegp0jH4 1y23azwi/nHn7q7dQ+HGe4D4lEChbYhH3XqeVoIp3thnNWGAccJVMQ9EXKT5fPJbGDRw Cb2VO+X5kLj/foIaiOeHQf0L1n84zXKfkdU8yNlDlxvtnzxC46GVp4I2iRUaG1b6wdO4 /n01l//UAZ1kPK/NaPFOXV+ptG2O09ET05XVb0zRl3DN9SG9G7fNkbJDBeYz0/0eavdn 5PCQ== 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=62U65ywvBJn+pjKmD1q78v7iMjUzWlgwZOIQEVoRJ/g=; fh=QhgSg1Zbhg0k1Y3sexI0DeQQQskTWRSzxoSuuRe9W3s=; b=syteHDet8UX8JhKRzwwecOx5EtgfkzFwYlM+G6Eh7D4EaywUDMiWeDhvN3FUygfBta 9A6AWV2tVKCXdMBBd6HLLjPCuy39/e2lhw1m8i6/PnDuUd+taDbMJrwKS8L1aXh9eaTk rg632wZpaQv3WaliJXGxar7Tma3WEAkd8l1eDz8v7fzPczZUJK5JEbVA96+FdaPD4lS7 O7/pRAbmu3MFlyezf3QaPTGVSiyOx42kNlRpW8d0Un+MS4Aqu3hL3TjlM4hyMPDN3KNk 2aAT7T3cvPjDHE6nSllSZTxV0Cc2cuMgaKW0GY3q1TBexLiootg10AL9UExLSzILY0K/ Ksbg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DoyTdela; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-207112-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207112-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 4fb4d7f45d1cf-57aae0f9c51si2122242a12.194.2024.06.08.08.58.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 08:58:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207112-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=DoyTdela; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-207112-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207112-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 5F0B91F2141B for ; Sat, 8 Jun 2024 15:58:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5491617C22D; Sat, 8 Jun 2024 15:57:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DoyTdela" 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 2E1F5179958; Sat, 8 Jun 2024 15:57:21 +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=1717862241; cv=none; b=bsOfAy2stHRy6Tz1clez7UaEiRNBiJvIdCH4RwJn1mAbfzJDsfxBJ/f2aPUbqXWt6CpCBvzFuLOVUVwFlqBU8HrgdFagwBjGobJnAn+TX4HVqA+fCJDq8ANV04hT9YOZZ/XCr8Yqx+ICUJwZXDYQx9d2rwya4KElngVPUmiZqk8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717862241; c=relaxed/simple; bh=pIx9hISv3tD47SUT5qu5as5nwq98Svr/ggvTneh6Yl8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dkSMIkIrael+UHlQ/huvPtFQvBQ0fA2SjA9z0duLcoe29ietU6JBsBct4X03WwfRvJR6ike0iqLxgnTf5iLJnxyg5FOivag1aw80zBMbm7Z4CX+vQ2JAV09TwZGnsG+sZT0O9yNVzQlMc0idgcyHBq/btG2SQn9N9HVySpkR1fM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DoyTdela; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92E0EC4AF09; Sat, 8 Jun 2024 15:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717862240; bh=pIx9hISv3tD47SUT5qu5as5nwq98Svr/ggvTneh6Yl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DoyTdelatrO7ntOSY6Qv3wpP2E5zYm6eJ5fErtUuz13kSjDqoBENpYXi1FlW0/KHB YJkVDgz2i115rfPg0t7CTguDvKOOKzDGXI8r9BZEuRqGz9YTNBwVoKc6jW1BGErW6l HoE9do2WmNyTHkLxoWBSqEyh88UWsoW5q76vsfHpTbIs9mlOWpY0cjZALWMshreUv0 At59cH2dYw0jxn+HnEjjXo8KroLfHCjLcFbpoyJG7qrHYQqF8TkHUPqn2IxuPpyDOO PHsoECEKn9vcWLuytknXL5s6xpo35gWF9bw1HUAO/SBSiBIyyQsYFjLEya/fs7RWhH iGUpr5V9XZadg== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1sFyRT-000000003Pv-2nO6; Sat, 08 Jun 2024 17:57:19 +0200 From: Johan Hovold To: Lee Jones , Mark Brown , Bjorn Andersson Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Konrad Dybcio , Liam Girdwood , Das Srinagesh , Satya Priya Kakitapalli , Linus Walleij , Stephen Boyd , Bryan O'Donoghue , Andy Shevchenko , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v3 02/12] mfd: pm8008: Fix regmap irq chip initialisation Date: Sat, 8 Jun 2024 17:55:16 +0200 Message-ID: <20240608155526.12996-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.44.1 In-Reply-To: <20240608155526.12996-1-johan+linaro@kernel.org> References: <20240608155526.12996-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") Reviewed-by: Bryan O'Donoghue Signed-off-by: Johan Hovold --- drivers/mfd/qcom-pm8008.c | 64 ++++++++++++++------------------------- 1 file changed, 23 insertions(+), 41 deletions(-) diff --git a/drivers/mfd/qcom-pm8008.c b/drivers/mfd/qcom-pm8008.c index 3ac3742f438b..f71c490f25c8 100644 --- a/drivers/mfd/qcom-pm8008.c +++ b/drivers/mfd/qcom-pm8008.c @@ -56,15 +56,25 @@ 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), \ + }, \ + } + +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_SENSE_MASK), + _IRQ(PM8008_IRQ_GPIO1, PM8008_GPIO1, BIT(0), IRQ_TYPE_SENSE_MASK), + _IRQ(PM8008_IRQ_GPIO2, PM8008_GPIO2, BIT(0), IRQ_TYPE_SENSE_MASK), }; static const unsigned int pm8008_periph_base[] = { @@ -143,38 +153,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 +168,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.44.1