Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp397262lqh; Thu, 28 Mar 2024 05:41:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXy1x7YziHfwc2F1dUZvHCUBRGkMLx98wAZwANFfFSv24hXWYIzvEGhkPCRCGj7McgONUus0tG2X5x0uUbdrXOs8Jy/GA8fPSACnym38w== X-Google-Smtp-Source: AGHT+IGn3UUcsu151pdMANimWXm90t0mPorFvyCCFRJv1TbTqQB21zTNuAfqGRO3dQ/jvtSXr/P9 X-Received: by 2002:a17:906:13d4:b0:a4e:23d4:ab82 with SMTP id g20-20020a17090613d400b00a4e23d4ab82mr929136ejc.55.1711629669056; Thu, 28 Mar 2024 05:41:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711629669; cv=pass; d=google.com; s=arc-20160816; b=R+1/I9toDCoYQXmsNwAvR6ve1X6ZGcbWtcyqiPM0RsV8YkfxMhpvbmhr8cMsmiZVeV +Jk5nUhuA0ZmCzJ6fRcO6xkBF6Ia7w5fsTt4WzusrbWth4vNhjuoG2p8psQ1hFI/w6s7 wFqZBJFdLvQy8AgZSEiaNje3aiG0IfL9/5AUlILcXdkusJTMpOwtdMzF+/cZKWBYv1ij 7hAVoGm/hViarF0KE4r+zH47AxZW1ic/WiZz6frjy8vb6j/O7Tj7Eyl2MTOV5e8UOBGp r5uC7STAtVA5XSEDgsAuTUPuDLdmCXuTkM2eXeY5UEJNmyX4mJAalSXH+qj8jnPVZL3g JF0g== 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=DfU5UpCLzdlxewahGmHzVnk5dbbyIMJRLCij+TJCBayLmgT4jQiO6fduFiSUrURCcJ D/i9hdzKVMe/EDSNUlsc5x4kJFhXXDZUOKlAR9Y9VDpJZU/CFGsoItQjJt1M9FfRS+D+ f9BDiylStoxjBU6Qttq8ajkH+4nAuBRe5Kb8eZZLs/QIC10ORdAIemMFSKTFU8zTWptG eFrbQryNlnBZCHgvaXxYUsG1Lhht/5PGulEBOkozQurRB+L96HhJDHsiwQcV5Aeg1wQC LjTpDf4Rx4z+VHsZvPzjNBg7WrMHld+TPS54Eqye+Ee7qgMqXh39jeHN6Z7gYp8OA4EZ 5G0A==; 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-122904-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122904-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. [147.75.80.249]) by mx.google.com with ESMTPS id h20-20020a1709066d9400b00a48e7aaaf62si708698ejt.120.2024.03.28.05.41.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 05:41:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122904-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-122904-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122904-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 9C4871F24BF4 for ; Thu, 28 Mar 2024 12:41:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B689B8003D; Thu, 28 Mar 2024 12:40:39 +0000 (UTC) Received: from esa2.ltts.com (unknown [14.140.155.42]) (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 390707F492; Thu, 28 Mar 2024 12:40:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=14.140.155.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711629639; cv=none; b=mlOIEdk9c1BdurH/MCOFQQsu/cDwRF7uy2e9J13dOfWCUOa7pTCQujkRsnZ9WJUD0IJZd8zyhod3Xw9NtwWIuJPtNpGal6FZD+ymoeyhukVnfBQ4StCSECM6KmsyyaBypF9ipqfxN0oMvRynQll4qliZ8e6jS6jzYgumBSBFz6o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711629639; c=relaxed/simple; bh=EclyQN+YA7HHsemmcLckQ4roFm2VU11PIgupyA6ilZI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eV7kMmVAIpkfU4yE2IueGYc/v0NWqxf0vszy1xjGZKne9QfgdUrJ1jlRFfSE0vCVlFK9JYXJfTRHRwSqr0n56zqMLFMTf2JGFge7lu3wfHksio00/AG3AlWKknyPiYUxu0iGfIzM1miaClQIVgUauLFzhASSc3hSbKqDdfAmUBc= 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=14.140.155.42 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: e9SFgnoZmGO8KizyPAW5U3DdFIn8S5onontP6l76GHLwAU0NpzyRwg4R5qxTg8PFXgsaOlw0EG 6q3q1dhwd8AQ== Received: from unknown (HELO localhost.localdomain) ([192.168.34.55]) by esa2.ltts.com with ESMTP; 28 Mar 2024 18:10:33 +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 v5 03/11] mfd: tps6594: add regmap config in match data Date: Thu, 28 Mar 2024 18:10:08 +0530 Message-Id: <20240328124016.161959-4-bhargav.r@ltts.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240328124016.161959-1-bhargav.r@ltts.com> References: <20240328124016.161959-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