Commit 1c8dbb5b authored by Kory Maincent's avatar Kory Maincent Committed by Jonathan Cameron

iio: dac: mcp4922: add support to mcp4921

Add support to mcp4921 which has only one output channel.
Signed-off-by: default avatarKory Maincent <kory.maincent@bootlin.com>
Reviewed-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20220624095619.1415614-1-kory.maincent@bootlin.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 53bee458
...@@ -17,10 +17,12 @@ ...@@ -17,10 +17,12 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#define MCP4922_NUM_CHANNELS 2 #define MCP4922_NUM_CHANNELS 2
#define MCP4921_NUM_CHANNELS 1
enum mcp4922_supported_device_ids { enum mcp4922_supported_device_ids {
ID_MCP4902, ID_MCP4902,
ID_MCP4912, ID_MCP4912,
ID_MCP4921,
ID_MCP4922, ID_MCP4922,
}; };
...@@ -105,9 +107,10 @@ static int mcp4922_write_raw(struct iio_dev *indio_dev, ...@@ -105,9 +107,10 @@ static int mcp4922_write_raw(struct iio_dev *indio_dev,
} }
} }
static const struct iio_chan_spec mcp4922_channels[3][MCP4922_NUM_CHANNELS] = { static const struct iio_chan_spec mcp4922_channels[4][MCP4922_NUM_CHANNELS] = {
[ID_MCP4902] = { MCP4922_CHAN(0, 8), MCP4922_CHAN(1, 8) }, [ID_MCP4902] = { MCP4922_CHAN(0, 8), MCP4922_CHAN(1, 8) },
[ID_MCP4912] = { MCP4922_CHAN(0, 10), MCP4922_CHAN(1, 10) }, [ID_MCP4912] = { MCP4922_CHAN(0, 10), MCP4922_CHAN(1, 10) },
[ID_MCP4921] = { MCP4922_CHAN(0, 12), {} },
[ID_MCP4922] = { MCP4922_CHAN(0, 12), MCP4922_CHAN(1, 12) }, [ID_MCP4922] = { MCP4922_CHAN(0, 12), MCP4922_CHAN(1, 12) },
}; };
...@@ -154,7 +157,10 @@ static int mcp4922_probe(struct spi_device *spi) ...@@ -154,7 +157,10 @@ static int mcp4922_probe(struct spi_device *spi)
indio_dev->info = &mcp4922_info; indio_dev->info = &mcp4922_info;
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = mcp4922_channels[id->driver_data]; indio_dev->channels = mcp4922_channels[id->driver_data];
indio_dev->num_channels = MCP4922_NUM_CHANNELS; if (id->driver_data == ID_MCP4921)
indio_dev->num_channels = MCP4921_NUM_CHANNELS;
else
indio_dev->num_channels = MCP4922_NUM_CHANNELS;
indio_dev->name = id->name; indio_dev->name = id->name;
ret = iio_device_register(indio_dev); ret = iio_device_register(indio_dev);
...@@ -185,6 +191,7 @@ static void mcp4922_remove(struct spi_device *spi) ...@@ -185,6 +191,7 @@ static void mcp4922_remove(struct spi_device *spi)
static const struct spi_device_id mcp4922_id[] = { static const struct spi_device_id mcp4922_id[] = {
{"mcp4902", ID_MCP4902}, {"mcp4902", ID_MCP4902},
{"mcp4912", ID_MCP4912}, {"mcp4912", ID_MCP4912},
{"mcp4921", ID_MCP4921},
{"mcp4922", ID_MCP4922}, {"mcp4922", ID_MCP4922},
{} {}
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment