MLK-11476 iio: adc: Enable i.MX6SX adc driver.
authorLuwei Zhou <b45643@freescale.com>
Thu, 6 Mar 2014 07:47:47 +0000 (15:47 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
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 <b45643@freescale.com>
Signed-off-by: Fugang Duan <B38611@freescale.com>
(cherry picked from commit 14a6a98f64e26702b1c0ecfc7d58a45ee5752d54)
Signed-off-by: Arulpandiyan Vadivel <arulpandiyan_vadivel@mentor.com>
drivers/iio/adc/vf610_adc.c

index bbcb7a4..a3cec1a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Freescale Vybrid vf610 ADC driver
  *
- * Copyright 2013 Freescale Semiconductor, Inc.
+ * Copyright 2013-2015 Freescale Semiconductor, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -818,6 +818,7 @@ static int vf610_adc_probe(struct platform_device *pdev)
        struct resource *mem;
        int irq;
        int ret;
+       u32 channels;
 
        indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct vf610_adc));
        if (!indio_dev) {
@@ -876,13 +877,18 @@ 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->dev.parent = &pdev->dev;
        indio_dev->dev.of_node = pdev->dev.of_node;
        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) {