summaryrefslogtreecommitdiff
path: root/drivers/iio/dac
diff options
context:
space:
mode:
authorBiju Das <biju.das.jz@bp.renesas.com>2023-09-03 12:55:47 +0100
committerJonathan Cameron <jonathan.cameron@huawei.com>2023-09-12 10:42:04 +0100
commit155da070b4388ed53f058259923f46740a51afde (patch)
treea607c039f1f7884c39cbaf6084037ce2ab01698f /drivers/iio/dac
parent18bdc686c1519e067dc80ec0015da52e2bd628b9 (diff)
iio: dac: mcp4725: Add use_ext_ref_voltage to struct mcp4725_chip_info
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> Link: https://lore.kernel.org/r/20230903115548.59306-4-biju.das.jz@bp.renesas.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/dac')
-rw-r--r--drivers/iio/dac/mcp4725.c8
1 files 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 = {