From c7caebc07047065be5d6d52d141f82006fc0c63c Mon Sep 17 00:00:00 2001 From: Luwei Zhou Date: Tue, 11 Jan 2022 07:31:59 +0100 Subject: [PATCH] NXP: MLK-11476 iio: adc: Enable i.MX6SX adc driver. Enable i.MX6SX adc driver. ADC driver will try getting ADC controller channel number via device tree, because i.MX chip enable 4 channels on each controller. Signed-off-by: Luwei Zhou Signed-off-by: Fugang Duan (cherry picked from commit 9a1c0b13424b1c8f2cddbe863cdcdc04ecd6a822) Using this patch to provide a number of channel limitation if the supported channel number is smaller than the maximum channel number. Signed-off-by: Stefan Riedmueller Signed-off-by: Christoph Fritz Signed-off-by: Christian Hemp Signed-off-by: Jan Remmet Signed-off-by: Yunus Bas Signed-off-by: Andrej Picej Reviewed-by: Yunus Bas --- drivers/iio/adc/vf610_adc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index fd57fc43e8e5c..1d4d3cfc8965c 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -803,6 +803,7 @@ static int vf610_adc_probe(struct platform_device *pdev) struct iio_dev *indio_dev; int irq; int ret; + u32 channels; indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct vf610_adc)); if (!indio_dev) { @@ -858,11 +859,16 @@ static int vf610_adc_probe(struct platform_device *pdev) init_completion(&info->completion); + ret = of_property_read_u32(pdev->dev.of_node, + "num-channels", &channels); + if (ret) + channels = ARRAY_SIZE(vf610_adc_iio_channels); + indio_dev->name = dev_name(&pdev->dev); indio_dev->info = &vf610_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = vf610_adc_iio_channels; - indio_dev->num_channels = ARRAY_SIZE(vf610_adc_iio_channels); + indio_dev->num_channels = (int)channels; ret = clk_prepare_enable(info->clk); if (ret) {