mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 02:00:43 -04:00
iio: adc: adi-axi-adc: add struct axi_adc_info
Add struct axi_adc_info to allow different axi-adc compatibles that can be added to this generic implementation. Signed-off-by: Angelo Dureghello <adureghello@baylibre.com> Link: https://patch.msgid.link/20250210-wip-bl-ad7606_add_backend_sw_mode-v4-4-160df18b1da7@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
committed by
Jonathan Cameron
parent
d2477887f6
commit
c4330d0817
@@ -80,7 +80,16 @@
|
||||
ADI_AXI_REG_CHAN_CTRL_FMT_EN | \
|
||||
ADI_AXI_REG_CHAN_CTRL_ENABLE)
|
||||
|
||||
struct axi_adc_info {
|
||||
unsigned int version;
|
||||
const struct iio_backend_info *backend_info;
|
||||
bool has_child_nodes;
|
||||
const void *pdata;
|
||||
unsigned int pdata_sz;
|
||||
};
|
||||
|
||||
struct adi_axi_adc_state {
|
||||
const struct axi_adc_info *info;
|
||||
struct regmap *regmap;
|
||||
struct device *dev;
|
||||
/* lock to protect multiple accesses to the device registers */
|
||||
@@ -348,7 +357,6 @@ static const struct iio_backend_info adi_axi_adc_generic = {
|
||||
|
||||
static int adi_axi_adc_probe(struct platform_device *pdev)
|
||||
{
|
||||
const unsigned int *expected_ver;
|
||||
struct adi_axi_adc_state *st;
|
||||
void __iomem *base;
|
||||
unsigned int ver;
|
||||
@@ -370,8 +378,8 @@ static int adi_axi_adc_probe(struct platform_device *pdev)
|
||||
return dev_err_probe(&pdev->dev, PTR_ERR(st->regmap),
|
||||
"failed to init register map\n");
|
||||
|
||||
expected_ver = device_get_match_data(&pdev->dev);
|
||||
if (!expected_ver)
|
||||
st->info = device_get_match_data(&pdev->dev);
|
||||
if (!st->info)
|
||||
return -ENODEV;
|
||||
|
||||
clk = devm_clk_get_enabled(&pdev->dev, NULL);
|
||||
@@ -391,12 +399,13 @@ static int adi_axi_adc_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (ADI_AXI_PCORE_VER_MAJOR(ver) != ADI_AXI_PCORE_VER_MAJOR(*expected_ver)) {
|
||||
if (ADI_AXI_PCORE_VER_MAJOR(ver) !=
|
||||
ADI_AXI_PCORE_VER_MAJOR(st->info->version)) {
|
||||
dev_err(&pdev->dev,
|
||||
"Major version mismatch. Expected %d.%.2d.%c, Reported %d.%.2d.%c\n",
|
||||
ADI_AXI_PCORE_VER_MAJOR(*expected_ver),
|
||||
ADI_AXI_PCORE_VER_MINOR(*expected_ver),
|
||||
ADI_AXI_PCORE_VER_PATCH(*expected_ver),
|
||||
ADI_AXI_PCORE_VER_MAJOR(st->info->version),
|
||||
ADI_AXI_PCORE_VER_MINOR(st->info->version),
|
||||
ADI_AXI_PCORE_VER_PATCH(st->info->version),
|
||||
ADI_AXI_PCORE_VER_MAJOR(ver),
|
||||
ADI_AXI_PCORE_VER_MINOR(ver),
|
||||
ADI_AXI_PCORE_VER_PATCH(ver));
|
||||
@@ -416,11 +425,14 @@ static int adi_axi_adc_probe(struct platform_device *pdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int adi_axi_adc_10_0_a_info = ADI_AXI_PCORE_VER(10, 0, 'a');
|
||||
static const struct axi_adc_info adc_generic = {
|
||||
.version = ADI_AXI_PCORE_VER(10, 0, 'a'),
|
||||
.backend_info = &adi_axi_adc_generic,
|
||||
};
|
||||
|
||||
/* Match table for of_platform binding */
|
||||
static const struct of_device_id adi_axi_adc_of_match[] = {
|
||||
{ .compatible = "adi,axi-adc-10.0.a", .data = &adi_axi_adc_10_0_a_info },
|
||||
{ .compatible = "adi,axi-adc-10.0.a", .data = &adc_generic },
|
||||
{ /* end of list */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, adi_axi_adc_of_match);
|
||||
|
||||
Reference in New Issue
Block a user