Lines Matching +full:sun20i +full:- +full:d1 +full:- +full:gpadc

1 // SPDX-License-Identifier: GPL-2.0
3 * GPADC driver for sunxi platforms (D1, T113-S3 and R329)
20 #define SUN20I_GPADC_DRIVER_NAME "sun20i-gpadc"
68 mutex_lock(&info->lock); in sun20i_gpadc_adc_read()
70 reinit_completion(&info->completion); in sun20i_gpadc_adc_read()
72 if (info->last_channel != chan->channel) { in sun20i_gpadc_adc_read()
73 info->last_channel = chan->channel; in sun20i_gpadc_adc_read()
76 writel(SUN20I_GPADC_CS_EN_ADC_CH(chan->channel), in sun20i_gpadc_adc_read()
77 info->regs + SUN20I_GPADC_CS_EN); in sun20i_gpadc_adc_read()
80 writel(SUN20I_GPADC_DATA_INTC_CH_DATA_IRQ_EN(chan->channel), in sun20i_gpadc_adc_read()
81 info->regs + SUN20I_GPADC_DATA_INTC); in sun20i_gpadc_adc_read()
85 ctrl = readl(info->regs + SUN20I_GPADC_CTRL); in sun20i_gpadc_adc_read()
87 writel(ctrl, info->regs + SUN20I_GPADC_CTRL); in sun20i_gpadc_adc_read()
96 if (!wait_for_completion_timeout(&info->completion, msecs_to_jiffies(10))) { in sun20i_gpadc_adc_read()
97 ret = -ETIMEDOUT; in sun20i_gpadc_adc_read()
102 *val = readl(info->regs + SUN20I_GPADC_CH_DATA(chan->channel)); in sun20i_gpadc_adc_read()
105 mutex_unlock(&info->lock); in sun20i_gpadc_adc_read()
125 return -EINVAL; in sun20i_gpadc_read_raw()
134 writel(GENMASK(31, 0), info->regs + SUN20I_GPADC_DATA_INTS); in sun20i_gpadc_irq_handler()
136 complete(&info->completion); in sun20i_gpadc_irq_handler()
162 return dev_err_probe(dev, -ENODEV, "no channel children\n"); in sun20i_gpadc_alloc_channels()
167 return -ENOMEM; in sun20i_gpadc_alloc_channels()
186 indio_dev->channels = channels; in sun20i_gpadc_alloc_channels()
187 indio_dev->num_channels = num_channels; in sun20i_gpadc_alloc_channels()
194 struct device *dev = &pdev->dev; in sun20i_gpadc_probe()
204 return -ENOMEM; in sun20i_gpadc_probe()
207 info->last_channel = -1; in sun20i_gpadc_probe()
209 mutex_init(&info->lock); in sun20i_gpadc_probe()
210 init_completion(&info->completion); in sun20i_gpadc_probe()
216 indio_dev->info = &sun20i_gpadc_iio_info; in sun20i_gpadc_probe()
217 indio_dev->name = SUN20I_GPADC_DRIVER_NAME; in sun20i_gpadc_probe()
219 info->regs = devm_platform_ioremap_resource(pdev, 0); in sun20i_gpadc_probe()
220 if (IS_ERR(info->regs)) in sun20i_gpadc_probe()
221 return PTR_ERR(info->regs); in sun20i_gpadc_probe()
250 info->regs + SUN20I_GPADC_CTRL); in sun20i_gpadc_probe()
260 { .compatible = "allwinner,sun20i-d1-gpadc" },