Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1416144lqt; Wed, 20 Mar 2024 03:27:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpfxUGDx8aNGlzHDvK+pSokbFNQqkDxA5xfQLkFXqkIXrU6zgWNZohw0kU1earBX/qeN3ThHo4gnj4rilh/GIUVbU14wHp+qPF+n0bfQ== X-Google-Smtp-Source: AGHT+IF2naeoRzjVWlb/2+lXQh3FYnFejX77mMNRJIVa+TT+o1OvQOPfuzd8/7CrUgkMHn/+E43g X-Received: by 2002:a05:6402:2486:b0:566:c572:6fa0 with SMTP id q6-20020a056402248600b00566c5726fa0mr14850559eda.15.1710930439739; Wed, 20 Mar 2024 03:27:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710930439; cv=pass; d=google.com; s=arc-20160816; b=SRPMK3njOMbAkRuZ5Olu26wDa+CYXZ1jGt5/joh513ZRvs0mf5Zkktu4BKQ4ut5bRY 7EK0Ha0xx2+chWeN7kU1cf1sFbW4WnRCvvual3AQzaqIycx9+kM1yX7r+ychyR6JwA8D gO0S3ci2X6sCstR0Z6G+e8fBXCjyWvn6ASRIxVe749wnDm2jnmrVBxkA3qvlSCqEalvO tJPjVUC3hxCqP25YpBxA9BGvepFoYFhC4PYXxUFtqgNlbwYq85tvcWii2EpznZEwduel ddRL1NK90dYjdQjuimOb4k9SGajWftzR5tLGrNLVZQGW26s4s0KxQAJE0DwMALZlXVtz cZZQ== 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:ironport-sdr; bh=9pZ9U7x03YFGLDgzRCpgr0OF/z71yMsL0P+hraMyAww=; fh=wiCHd3sd+nGR6RMzX74j5wvnmiIZ1CMGhEcpQW9vpus=; b=mwhsit+04vDar8cF4Cfo93eJHhY98Db7phfjAcua/yyWGNzoccTCTYQqFDnNvMFk8w X4AJyHoSEywHW/Z0KLHqkqyagF63sMz60cm+WqxEuw7nTNiwGaygQgRfpSqVkUNv35LZ JYVHehCI5lVvRdscpZo+UPIc08EuCsYNkiJWHlYHkJxkNyeXodV5Uedm12lxE3OBbv6k EmA+rrOU+9CaY03u6xQd/ldlotfMh7bKUX0MFVhJ1IC49N8ZVDyl+gutIS6jx0wEdWXw BTyH+UgzHnEKDvYvI5H1jhNam+viHTpQXfwE7SbCgNDaqQGnpSwm/GQt4QloWDEHLVGZ Xx4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=ltts.com dmarc=pass fromdomain=ltts.com); spf=pass (google.com: domain of linux-kernel+bounces-108762-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108762-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) header.from=ltts.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f8-20020a056402004800b0056884c2f202si6447477edu.515.2024.03.20.03.27.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 03:27:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108762-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; arc=pass (i=1 spf=pass spfdomain=ltts.com dmarc=pass fromdomain=ltts.com); spf=pass (google.com: domain of linux-kernel+bounces-108762-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108762-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=NONE dis=QUARANTINE) header.from=ltts.com 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 4C8E31F21333 for ; Wed, 20 Mar 2024 10:27:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B60340847; Wed, 20 Mar 2024 10:26:24 +0000 (UTC) Received: from esa1.ltts.com (unknown [118.185.121.105]) (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 8B8EF3F8DA; Wed, 20 Mar 2024 10:26:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.185.121.105 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710930383; cv=none; b=Esz/k+FgGC2PfHccf+hRPBw2N49FY6QesKhqMincPAJStOKb9jYnuM6175jcoj2Ku8sDNYZCd9B2MwQy/pTiXw+wB8ogmintynVFscOIxDvXLERWBX0MpjtQPrTotM5Q3rur5FcMbd3T8H1qkkUQ0Ltp4RhfMb7ni3F0GinNwBs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710930383; c=relaxed/simple; bh=EclyQN+YA7HHsemmcLckQ4roFm2VU11PIgupyA6ilZI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dYzsH+KOBzNgNO+ybNCEDLGAMsGxZW4D9T9em/2s5hUYdGe3Xn0Mafv04khf/PXQNgGherKD9d607NO+hyULLlkiKkzUwaxaGa91aXDUqRYQwJ5hc29Ho6knEqz46+UwKL/9h1UqW4N8tf/TddQjLOrHCA0OsHcDCNgzu+YaYHE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ltts.com; spf=pass smtp.mailfrom=ltts.com; arc=none smtp.client-ip=118.185.121.105 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ltts.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ltts.com IronPort-SDR: lwDijFzrxCWzYrW2ESiIu3InwGBNcfiW5zM6G8UOqBcWr7U4fcJ4Jj6I0zUm0XdrNmJU9Mr5a9 2WImTxb12WKg== Received: from unknown (HELO localhost.localdomain) ([192.168.34.55]) by esa1.ltts.com with ESMTP; 20 Mar 2024 15:56:15 +0530 From: Bhargav Raviprakash To: linux-kernel@vger.kernel.org Cc: m.nirmaladevi@ltts.com, lee@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, jpanis@baylibre.com, devicetree@vger.kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org, lgirdwood@gmail.com, broonie@kernel.org, linus.walleij@linaro.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, nm@ti.com, vigneshr@ti.com, kristo@kernel.org, eblanc@baylibre.com, Bhargav Raviprakash Subject: [PATCH v4 03/11] mfd: tps6594: add regmap config in match data Date: Wed, 20 Mar 2024 15:55:51 +0530 Message-Id: <20240320102559.464981-4-bhargav.r@ltts.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240320102559.464981-1-bhargav.r@ltts.com> References: <20240320102559.464981-1-bhargav.r@ltts.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Introduces a new struct tps6594_match_data. This struct holds fields for chip id and regmap config. Using this struct in of_device_id data field. This helps in adding support for TPS65224 PMIC. Signed-off-by: Bhargav Raviprakash Acked-by: Julien Panis --- drivers/mfd/tps6594-i2c.c | 24 ++++++++++++++++-------- drivers/mfd/tps6594-spi.c | 24 ++++++++++++++++-------- include/linux/mfd/tps6594.h | 11 +++++++++++ 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/drivers/mfd/tps6594-i2c.c b/drivers/mfd/tps6594-i2c.c index c125b474b..9e2ed48b7 100644 --- a/drivers/mfd/tps6594-i2c.c +++ b/drivers/mfd/tps6594-i2c.c @@ -192,10 +192,16 @@ static const struct regmap_config tps6594_i2c_regmap_config = { .write = tps6594_i2c_write, }; +static const struct tps6594_match_data match_data[] = { + [TPS6594] = {TPS6594, &tps6594_i2c_regmap_config}, + [TPS6593] = {TPS6593, &tps6594_i2c_regmap_config}, + [LP8764] = {LP8764, &tps6594_i2c_regmap_config}, +}; + static const struct of_device_id tps6594_i2c_of_match_table[] = { - { .compatible = "ti,tps6594-q1", .data = (void *)TPS6594, }, - { .compatible = "ti,tps6593-q1", .data = (void *)TPS6593, }, - { .compatible = "ti,lp8764-q1", .data = (void *)LP8764, }, + { .compatible = "ti,tps6594-q1", .data = &match_data[TPS6594], }, + { .compatible = "ti,tps6593-q1", .data = &match_data[TPS6593], }, + { .compatible = "ti,lp8764-q1", .data = &match_data[LP8764], }, {} }; MODULE_DEVICE_TABLE(of, tps6594_i2c_of_match_table); @@ -205,6 +211,7 @@ static int tps6594_i2c_probe(struct i2c_client *client) struct device *dev = &client->dev; struct tps6594 *tps; const struct of_device_id *match; + const struct tps6594_match_data *mdata; tps = devm_kzalloc(dev, sizeof(*tps), GFP_KERNEL); if (!tps) @@ -216,14 +223,15 @@ static int tps6594_i2c_probe(struct i2c_client *client) tps->reg = client->addr; tps->irq = client->irq; - tps->regmap = devm_regmap_init(dev, NULL, client, &tps6594_i2c_regmap_config); - if (IS_ERR(tps->regmap)) - return dev_err_probe(dev, PTR_ERR(tps->regmap), "Failed to init regmap\n"); - match = of_match_device(tps6594_i2c_of_match_table, dev); if (!match) return dev_err_probe(dev, -EINVAL, "Failed to find matching chip ID\n"); - tps->chip_id = (unsigned long)match->data; + mdata = (struct tps6594_match_data *)match->data; + tps->chip_id = mdata->chip_id; + + tps->regmap = devm_regmap_init(dev, NULL, client, mdata->config); + if (IS_ERR(tps->regmap)) + return dev_err_probe(dev, PTR_ERR(tps->regmap), "Failed to init regmap\n"); crc8_populate_msb(tps6594_i2c_crc_table, TPS6594_CRC8_POLYNOMIAL); diff --git a/drivers/mfd/tps6594-spi.c b/drivers/mfd/tps6594-spi.c index 5afb1736f..82a1c02e3 100644 --- a/drivers/mfd/tps6594-spi.c +++ b/drivers/mfd/tps6594-spi.c @@ -77,10 +77,16 @@ static const struct regmap_config tps6594_spi_regmap_config = { .use_single_write = true, }; +static const struct tps6594_match_data match_data[] = { + [TPS6594] = {TPS6594, &tps6594_spi_regmap_config}, + [TPS6593] = {TPS6593, &tps6594_spi_regmap_config}, + [LP8764] = {LP8764, &tps6594_spi_regmap_config}, +}; + static const struct of_device_id tps6594_spi_of_match_table[] = { - { .compatible = "ti,tps6594-q1", .data = (void *)TPS6594, }, - { .compatible = "ti,tps6593-q1", .data = (void *)TPS6593, }, - { .compatible = "ti,lp8764-q1", .data = (void *)LP8764, }, + { .compatible = "ti,tps6594-q1", .data = &match_data[TPS6594], }, + { .compatible = "ti,tps6593-q1", .data = &match_data[TPS6593], }, + { .compatible = "ti,lp8764-q1", .data = &match_data[LP8764], }, {} }; MODULE_DEVICE_TABLE(of, tps6594_spi_of_match_table); @@ -90,6 +96,7 @@ static int tps6594_spi_probe(struct spi_device *spi) struct device *dev = &spi->dev; struct tps6594 *tps; const struct of_device_id *match; + const struct tps6594_match_data *mdata; tps = devm_kzalloc(dev, sizeof(*tps), GFP_KERNEL); if (!tps) @@ -101,14 +108,15 @@ static int tps6594_spi_probe(struct spi_device *spi) tps->reg = spi_get_chipselect(spi, 0); tps->irq = spi->irq; - tps->regmap = devm_regmap_init(dev, NULL, spi, &tps6594_spi_regmap_config); - if (IS_ERR(tps->regmap)) - return dev_err_probe(dev, PTR_ERR(tps->regmap), "Failed to init regmap\n"); - match = of_match_device(tps6594_spi_of_match_table, dev); if (!match) return dev_err_probe(dev, -EINVAL, "Failed to find matching chip ID\n"); - tps->chip_id = (unsigned long)match->data; + mdata = (struct tps6594_match_data *)match->data; + tps->chip_id = mdata->chip_id; + + tps->regmap = devm_regmap_init(dev, NULL, spi, mdata->config); + if (IS_ERR(tps->regmap)) + return dev_err_probe(dev, PTR_ERR(tps->regmap), "Failed to init regmap\n"); crc8_populate_msb(tps6594_spi_crc_table, TPS6594_CRC8_POLYNOMIAL); diff --git a/include/linux/mfd/tps6594.h b/include/linux/mfd/tps6594.h index 16543fd4d..d781e0fe3 100644 --- a/include/linux/mfd/tps6594.h +++ b/include/linux/mfd/tps6594.h @@ -1337,6 +1337,17 @@ struct tps6594 { struct regmap_irq_chip_data *irq_data; }; +/** + * struct tps6594_match_data - of match data of PMIC + * + * @chip_id: chip ID of PMIC + * @config: regmap config of PMIC + */ +struct tps6594_match_data { + unsigned long chip_id; + const struct regmap_config *config; +}; + extern const struct regmap_access_table tps6594_volatile_table; extern const struct regmap_access_table tps65224_volatile_table; -- 2.25.1