mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-13 20:59:37 +02:00
iio: adc: ad9467: use chip_info variables instead of array
[ Upstream commit6dd3fa9fcc
] Instead of having an array and keeping IDs for each entry of the array, just have a chip_info struct per device. Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20231207-iio-backend-prep-v2-6-a4a33bc4d70e@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Stable-dep-of:cf1c833f89
("iio: adc: adi-axi-adc: only error out in major version mismatch") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
a679a40bd2
commit
864b42f8b3
|
@ -101,12 +101,6 @@
|
||||||
#define AD9467_DEF_OUTPUT_MODE 0x08
|
#define AD9467_DEF_OUTPUT_MODE 0x08
|
||||||
#define AD9467_REG_VREF_MASK 0x0F
|
#define AD9467_REG_VREF_MASK 0x0F
|
||||||
|
|
||||||
enum {
|
|
||||||
ID_AD9265,
|
|
||||||
ID_AD9434,
|
|
||||||
ID_AD9467,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ad9467_chip_info {
|
struct ad9467_chip_info {
|
||||||
struct adi_axi_adc_chip_info axi_adc_info;
|
struct adi_axi_adc_chip_info axi_adc_info;
|
||||||
unsigned int default_output_mode;
|
unsigned int default_output_mode;
|
||||||
|
@ -234,33 +228,9 @@ static const struct iio_chan_spec ad9467_channels[] = {
|
||||||
AD9467_CHAN(0, 0, 16, 'S'),
|
AD9467_CHAN(0, 0, 16, 'S'),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct ad9467_chip_info ad9467_chip_tbl[] = {
|
static const struct ad9467_chip_info ad9467_chip_tbl = {
|
||||||
[ID_AD9265] = {
|
|
||||||
.axi_adc_info = {
|
|
||||||
.id = CHIPID_AD9265,
|
|
||||||
.max_rate = 125000000UL,
|
|
||||||
.scale_table = ad9265_scale_table,
|
|
||||||
.num_scales = ARRAY_SIZE(ad9265_scale_table),
|
|
||||||
.channels = ad9467_channels,
|
|
||||||
.num_channels = ARRAY_SIZE(ad9467_channels),
|
|
||||||
},
|
|
||||||
.default_output_mode = AD9265_DEF_OUTPUT_MODE,
|
|
||||||
.vref_mask = AD9265_REG_VREF_MASK,
|
|
||||||
},
|
|
||||||
[ID_AD9434] = {
|
|
||||||
.axi_adc_info = {
|
|
||||||
.id = CHIPID_AD9434,
|
|
||||||
.max_rate = 500000000UL,
|
|
||||||
.scale_table = ad9434_scale_table,
|
|
||||||
.num_scales = ARRAY_SIZE(ad9434_scale_table),
|
|
||||||
.channels = ad9434_channels,
|
|
||||||
.num_channels = ARRAY_SIZE(ad9434_channels),
|
|
||||||
},
|
|
||||||
.default_output_mode = AD9434_DEF_OUTPUT_MODE,
|
|
||||||
.vref_mask = AD9434_REG_VREF_MASK,
|
|
||||||
},
|
|
||||||
[ID_AD9467] = {
|
|
||||||
.axi_adc_info = {
|
.axi_adc_info = {
|
||||||
|
.name = "ad9467",
|
||||||
.id = CHIPID_AD9467,
|
.id = CHIPID_AD9467,
|
||||||
.max_rate = 250000000UL,
|
.max_rate = 250000000UL,
|
||||||
.scale_table = ad9467_scale_table,
|
.scale_table = ad9467_scale_table,
|
||||||
|
@ -270,7 +240,34 @@ static const struct ad9467_chip_info ad9467_chip_tbl[] = {
|
||||||
},
|
},
|
||||||
.default_output_mode = AD9467_DEF_OUTPUT_MODE,
|
.default_output_mode = AD9467_DEF_OUTPUT_MODE,
|
||||||
.vref_mask = AD9467_REG_VREF_MASK,
|
.vref_mask = AD9467_REG_VREF_MASK,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct ad9467_chip_info ad9434_chip_tbl = {
|
||||||
|
.axi_adc_info = {
|
||||||
|
.name = "ad9434",
|
||||||
|
.id = CHIPID_AD9434,
|
||||||
|
.max_rate = 500000000UL,
|
||||||
|
.scale_table = ad9434_scale_table,
|
||||||
|
.num_scales = ARRAY_SIZE(ad9434_scale_table),
|
||||||
|
.channels = ad9434_channels,
|
||||||
|
.num_channels = ARRAY_SIZE(ad9434_channels),
|
||||||
},
|
},
|
||||||
|
.default_output_mode = AD9434_DEF_OUTPUT_MODE,
|
||||||
|
.vref_mask = AD9434_REG_VREF_MASK,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct ad9467_chip_info ad9265_chip_tbl = {
|
||||||
|
.axi_adc_info = {
|
||||||
|
.name = "ad9265",
|
||||||
|
.id = CHIPID_AD9265,
|
||||||
|
.max_rate = 125000000UL,
|
||||||
|
.scale_table = ad9265_scale_table,
|
||||||
|
.num_scales = ARRAY_SIZE(ad9265_scale_table),
|
||||||
|
.channels = ad9467_channels,
|
||||||
|
.num_channels = ARRAY_SIZE(ad9467_channels),
|
||||||
|
},
|
||||||
|
.default_output_mode = AD9265_DEF_OUTPUT_MODE,
|
||||||
|
.vref_mask = AD9265_REG_VREF_MASK,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ad9467_get_scale(struct adi_axi_adc_conv *conv, int *val, int *val2)
|
static int ad9467_get_scale(struct adi_axi_adc_conv *conv, int *val, int *val2)
|
||||||
|
@ -504,17 +501,17 @@ static int ad9467_probe(struct spi_device *spi)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id ad9467_of_match[] = {
|
static const struct of_device_id ad9467_of_match[] = {
|
||||||
{ .compatible = "adi,ad9265", .data = &ad9467_chip_tbl[ID_AD9265], },
|
{ .compatible = "adi,ad9265", .data = &ad9265_chip_tbl, },
|
||||||
{ .compatible = "adi,ad9434", .data = &ad9467_chip_tbl[ID_AD9434], },
|
{ .compatible = "adi,ad9434", .data = &ad9434_chip_tbl, },
|
||||||
{ .compatible = "adi,ad9467", .data = &ad9467_chip_tbl[ID_AD9467], },
|
{ .compatible = "adi,ad9467", .data = &ad9467_chip_tbl, },
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, ad9467_of_match);
|
MODULE_DEVICE_TABLE(of, ad9467_of_match);
|
||||||
|
|
||||||
static const struct spi_device_id ad9467_ids[] = {
|
static const struct spi_device_id ad9467_ids[] = {
|
||||||
{ "ad9265", (kernel_ulong_t)&ad9467_chip_tbl[ID_AD9265] },
|
{ "ad9265", (kernel_ulong_t)&ad9265_chip_tbl },
|
||||||
{ "ad9434", (kernel_ulong_t)&ad9467_chip_tbl[ID_AD9434] },
|
{ "ad9434", (kernel_ulong_t)&ad9434_chip_tbl },
|
||||||
{ "ad9467", (kernel_ulong_t)&ad9467_chip_tbl[ID_AD9467] },
|
{ "ad9467", (kernel_ulong_t)&ad9467_chip_tbl },
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(spi, ad9467_ids);
|
MODULE_DEVICE_TABLE(spi, ad9467_ids);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user