Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp758222lqb; Wed, 29 May 2024 09:37:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUt4FOL/JSHe4S9sXq1Vz1+CMkltK7Sn3AE4CQty4pKZ9XqM8WXwwt5hqcoTMCdz2WdGfLpRcXL3tRQB6BTVQ5RVT4NrNkefz0Xmq8NkA== X-Google-Smtp-Source: AGHT+IEho/soUmnM+XQJDGdGFTlvYD1tOrBViIaa00+yx23GksFL16/HYyeUmyhDt/HrsNKylx/0 X-Received: by 2002:a05:6a20:324b:b0:1b0:14ee:3b1c with SMTP id adf61e73a8af0-1b212d2852bmr14036293637.22.1717000668879; Wed, 29 May 2024 09:37:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717000668; cv=pass; d=google.com; s=arc-20160816; b=VhyXusxb4xAzvum3dCWBWSBFZFbrQwXWF3eDPN9QcsmhWgZCcomJ1UoKeEcCM+czxm 2gwnXzKVpVgxBhbAwzYFSmB4TfZHWaD4Px1NnhyTTQChTqh2y65tPXoQYK1bL9l0fE7n bFV4zw/y9bjtrQlnLnGrGsn8vQhRDQfsgnL0b9bCArnq8Yc+3p//Su8j4H9R5j93+ias oVpKTjQkCXDG2v7YUpYpxLRcBJcaSdEd6d1g3KWiTAeRM1mjAeHED0wc+Pdv4lQEGrWG LurAFTD/1bNqPauNLKkTStUIGOn6NNA2OwmiXre8cZNAXNeTf70CvHJxsq7SMBQdAVm0 RkJw== 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=UYXJM/M3MXdA0GDUThOsFfnXcdX6uvJseS3rRMuXnoU=; fh=x+Zd7UvMx2t8tXw5ng9M6xK/nnIPEHXRKsUbNBmr8uk=; b=TQt3ZllSr2/Uaae7UFigYzmjwT3B29odlvFB2p5cO0pkhaIzIpO6UBiALghO79LHVW TOfoVcgMpFWMC+5vUJl9Q8y7RWUBXTG+i84GmeZ7qdemAvGFXr4WpIwL/a9S1Efokuf9 nAEq+w7KIj5kYvYWhBVGKU0xQoJlr680RQvh4ITkZr+AGJKwcIjuEzJQMsPPcFqJXgXG P8VJhb/hYo2m00RFRuknE/y5w/3RCjoInyIVVx0q4Bb/2jWG4nXDwMfHwbFU0H4oRKCH HQn5MCmK/QaWg2bAsCU10lgxN3XriWLf60sGn45LQIKyoUU9Q8kqr8oMiC5B0VVUMYIc LxSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QTc+cHhp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-194469-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194469-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6822ae569e1si10425917a12.792.2024.05.29.09.37.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 09:37:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194469-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QTc+cHhp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-194469-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194469-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C3B17285268 for ; Wed, 29 May 2024 16:37:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9070620FA9C; Wed, 29 May 2024 16:30:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QTc+cHhp" 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 6D8D6194C68; Wed, 29 May 2024 16:30:36 +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=1717000236; cv=none; b=NR8J/HnX7mcf0YfGYGzSnyx5monT6KSLxx413TPLTuN0mrUiXx6W37JwVT7UypyDaQS0E2X7FmCaUB71vO9NeF6xLOjZs82cYK3GAVCKSpN3bQ9Uzc/BVcQu5ABfc1obek1CWZUXN0xtU+8B6zhBgiyZrJSfYwc0YNJPLOA0N5Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717000236; c=relaxed/simple; bh=2q8uKA69UrATuj6FRt0GVVqnEyADsM00txP6nQDM2tk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S4Rd2VWnyU3NLbjdAakt37M2Mbg0HT/7NMTKew8JgkHuSLMzRx67krgOLRifW4leoqB39wsLjCXuiRNuuQPASs8wzMEZTxSN+5GABaUVqm0x4ogyJwwJ68IwKuSsJq1VJDPh5YWeWCI8hhWiKl9HhQq2Sm4WOy0E3zlJQiMTh2o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QTc+cHhp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D944C4AF07; Wed, 29 May 2024 16:30:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717000235; bh=2q8uKA69UrATuj6FRt0GVVqnEyADsM00txP6nQDM2tk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QTc+cHhp+mlJVys6+DmmcCUMfF9Df7Mso5WBnbpCap491+vYMb3f6IajcUpgBJL6R uuEXVYRLCKERUUGkNF2lQPPkPYznWTpvdjOdIIqMcrv6VYLityd2Iar8pjz++aODpZ ZmH34eCXi/5VATN2wmBloBwMPsbKnqN7ENOimqQxLgRe1DiNdbfHhEFkQEMA5L0/Ww 1dSC2qATQwsMCp4YUn33MS6QSqCH4gga6Zyt8rWj5kP6s+NVt68pK4lSOfHj2VbVee ShwR9hNzz8cagYuCMrWTG09RTfE33b+nhj9WYwliejk5N/1+B1E+EoC5jUaHoRyDpL VViTL+bQKKlVA== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1sCMCB-000000004ik-1oZd; Wed, 29 May 2024 18:30:35 +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 Kakitapalli , Stephen Boyd , Bryan O'Donoghue , Andy Shevchenko , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Johan Hovold Subject: [PATCH v2 02/14] mfd: pm8008: fix regmap irq chip initialisation Date: Wed, 29 May 2024 18:29:46 +0200 Message-ID: <20240529162958.18081-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.44.1 In-Reply-To: <20240529162958.18081-1-johan+linaro@kernel.org> References: <20240529162958.18081-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 | 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