Lines Matching +full:settling +full:- +full:time +full:- +full:us

1 // SPDX-License-Identifier: GPL-2.0-only
31 * HR Timers-based version loads CPU only up to 10% during back to back ADC
32 * conversion, while busy wait-based version consumes whole CPU power.
89 mutex_lock(&priv->lock); in ep93xx_read_raw()
90 if (priv->lastch != channel->channel) { in ep93xx_read_raw()
91 priv->lastch = channel->channel; in ep93xx_read_raw()
93 * Switch register is software-locked, unlocking must be in ep93xx_read_raw()
97 writel_relaxed(0xAA, priv->base + EP93XX_ADC_SW_LOCK); in ep93xx_read_raw()
98 writel_relaxed(channel->address, in ep93xx_read_raw()
99 priv->base + EP93XX_ADC_SWITCH); in ep93xx_read_raw()
102 * Settling delay depends on module clock and could be in ep93xx_read_raw()
103 * 2ms or 500us in ep93xx_read_raw()
108 readl_relaxed(priv->base + EP93XX_ADC_RESULT); in ep93xx_read_raw()
118 t = readl_relaxed(priv->base + EP93XX_ADC_RESULT); in ep93xx_read_raw()
125 dev_err(&iiodev->dev, "Conversion timeout\n"); in ep93xx_read_raw()
126 ret = -ETIMEDOUT; in ep93xx_read_raw()
132 mutex_unlock(&priv->lock); in ep93xx_read_raw()
136 /* According to datasheet, range is -25000..25000 */ in ep93xx_read_raw()
147 return -EINVAL; in ep93xx_read_raw()
161 iiodev = devm_iio_device_alloc(&pdev->dev, sizeof(*priv)); in ep93xx_adc_probe()
163 return -ENOMEM; in ep93xx_adc_probe()
166 priv->base = devm_platform_ioremap_resource(pdev, 0); in ep93xx_adc_probe()
167 if (IS_ERR(priv->base)) in ep93xx_adc_probe()
168 return PTR_ERR(priv->base); in ep93xx_adc_probe()
170 iiodev->name = dev_name(&pdev->dev); in ep93xx_adc_probe()
171 iiodev->modes = INDIO_DIRECT_MODE; in ep93xx_adc_probe()
172 iiodev->info = &ep93xx_adc_info; in ep93xx_adc_probe()
173 iiodev->num_channels = ARRAY_SIZE(ep93xx_adc_channels); in ep93xx_adc_probe()
174 iiodev->channels = ep93xx_adc_channels; in ep93xx_adc_probe()
176 priv->lastch = -1; in ep93xx_adc_probe()
177 mutex_init(&priv->lock); in ep93xx_adc_probe()
181 priv->clk = devm_clk_get(&pdev->dev, NULL); in ep93xx_adc_probe()
182 if (IS_ERR(priv->clk)) { in ep93xx_adc_probe()
183 dev_err(&pdev->dev, "Cannot obtain clock\n"); in ep93xx_adc_probe()
184 return PTR_ERR(priv->clk); in ep93xx_adc_probe()
187 pclk = clk_get_parent(priv->clk); in ep93xx_adc_probe()
189 dev_warn(&pdev->dev, "Cannot obtain parent clock\n"); in ep93xx_adc_probe()
193 * EP93xx ADC supports two clock divisors -- 4 and 16, in ep93xx_adc_probe()
195 * with 500us or 2ms settling time respectively. in ep93xx_adc_probe()
198 ret = clk_set_rate(priv->clk, clk_get_rate(pclk) / 16); in ep93xx_adc_probe()
200 dev_warn(&pdev->dev, "Cannot set clock rate\n"); in ep93xx_adc_probe()
207 ret = clk_prepare_enable(priv->clk); in ep93xx_adc_probe()
209 dev_err(&pdev->dev, "Cannot enable clock\n"); in ep93xx_adc_probe()
215 clk_disable_unprepare(priv->clk); in ep93xx_adc_probe()
226 clk_disable_unprepare(priv->clk); in ep93xx_adc_remove()
230 { .compatible = "cirrus,ep9301-adc" },
237 .name = "ep93xx-adc",
248 MODULE_ALIAS("platform:ep93xx-adc");