All of lore.kernel.org
 help / color / mirror / Atom feed
From: Biju Das <biju.das.jz@bp.renesas.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Biju Das" <biju.das.jz@bp.renesas.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Marek Vasut" <marex@denx.de>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Biju Das" <biju.das.au@gmail.com>
Subject: [PATCH v3 3/4] iio: dac: mcp4725: Add use_ext_ref_voltage to struct mcp4725_chip_info
Date: Sun,  3 Sep 2023 12:55:47 +0100	[thread overview]
Message-ID: <20230903115548.59306-4-biju.das.jz@bp.renesas.com> (raw)
In-Reply-To: <20230903115548.59306-1-biju.das.jz@bp.renesas.com>

The MCP4725 has external voltage reference compared MCP4725 which
has reference embeedded in eeprom. Add use_ext_ref_voltage variable
to struct mcp4725_chip_info to handle this difference.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v3:
 * New patch
---
 drivers/iio/dac/mcp4725.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
index fe8981ec7923..9cbea6f223e4 100644
--- a/drivers/iio/dac/mcp4725.c
+++ b/drivers/iio/dac/mcp4725.c
@@ -33,6 +33,7 @@
 struct mcp4725_chip_info {
 	const struct iio_chan_spec *chan_spec;
 	unsigned int chip_id;
+	bool use_ext_ref_voltage;
 };
 
 struct mcp4725_data {
@@ -416,7 +417,7 @@ static int mcp4725_probe(struct i2c_client *client)
 		pdata = &pdata_dt;
 	}
 
-	if (info->chip_id == MCP4725 && pdata->use_vref) {
+	if (info->use_ext_ref_voltage && pdata->use_vref) {
 		dev_err(&client->dev,
 			"external reference is unavailable on MCP4725");
 		return -EINVAL;
@@ -472,10 +473,10 @@ static int mcp4725_probe(struct i2c_client *client)
 	data->powerdown = pd > 0;
 	data->powerdown_mode = pd ? pd - 1 : 2; /* largest resistor to gnd */
 	data->dac_value = (inbuf[1] << 4) | (inbuf[2] >> 4);
-	if (info->chip_id == MCP4726)
+	if (!info->use_ext_ref_voltage)
 		ref = (inbuf[3] >> 3) & 0x3;
 
-	if (info->chip_id == MCP4726 && ref != data->ref_mode) {
+	if (!info->use_ext_ref_voltage && ref != data->ref_mode) {
 		dev_info(&client->dev,
 			"voltage reference mode differs (conf: %u, eeprom: %u), setting %u",
 			data->ref_mode, ref, data->ref_mode);
@@ -515,6 +516,7 @@ static void mcp4725_remove(struct i2c_client *client)
 static const struct mcp4725_chip_info mcp4725 = {
 	.chan_spec = &mcp472x_channel[MCP4725],
 	.chip_id = MCP4725,
+	.use_ext_ref_voltage = true,
 };
 
 static const struct mcp4725_chip_info mcp4726 = {
-- 
2.25.1


  parent reply	other threads:[~2023-09-03 11:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-03 11:55 [PATCH v3 0/4] Match data improvements for mcp4725 driver Biju Das
2023-09-03 11:55 ` [PATCH v3 1/4] iio: dac: mcp4725: Replace variable 'id' from struct mcp4725_data Biju Das
2023-09-03 11:55 ` [PATCH v3 2/4] iio: dac: mcp4725: Use i2c_get_match_data() Biju Das
2023-09-03 11:55 ` Biju Das [this message]
2023-09-03 11:55 ` [PATCH v3 4/4] iio: dac: mcp4725: Add dac_reg_offset to struct mcp4725_chip_info Biju Das
2023-09-03 12:15 ` [PATCH v3 0/4] Match data improvements for mcp4725 driver Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230903115548.59306-4-biju.das.jz@bp.renesas.com \
    --to=biju.das.jz@bp.renesas.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=biju.das.au@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marex@denx.de \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.