Lines Matching +full:idle +full:- +full:wait +full:- +full:delay
1 // SPDX-License-Identifier: GPL-2.0-only
8 #include <linux/delay.h>
118 reg_channel = adc_dev->reg_base + MT6577_AUXADC_DAT0 + in mt6577_auxadc_read()
119 chan->channel * 0x04; in mt6577_auxadc_read()
121 mutex_lock(&adc_dev->lock); in mt6577_auxadc_read()
123 mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_CON1, in mt6577_auxadc_read()
124 0, 1 << chan->channel); in mt6577_auxadc_read()
132 dev_err(indio_dev->dev.parent, in mt6577_auxadc_read()
133 "wait for channel[%d] ready bit clear time out\n", in mt6577_auxadc_read()
134 chan->channel); in mt6577_auxadc_read()
139 mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_CON1, in mt6577_auxadc_read()
140 1 << chan->channel, 0); in mt6577_auxadc_read()
142 /* we must delay here for hardware sample channel data */ in mt6577_auxadc_read()
145 if (adc_dev->dev_comp->check_global_idle) { in mt6577_auxadc_read()
146 /* check MTK_AUXADC_CON2 if auxadc is idle */ in mt6577_auxadc_read()
147 ret = readl_poll_timeout(adc_dev->reg_base + MT6577_AUXADC_CON2, in mt6577_auxadc_read()
152 dev_err(indio_dev->dev.parent, in mt6577_auxadc_read()
153 "wait for auxadc idle time out\n"); in mt6577_auxadc_read()
164 dev_err(indio_dev->dev.parent, in mt6577_auxadc_read()
165 "wait for channel[%d] data ready time out\n", in mt6577_auxadc_read()
166 chan->channel); in mt6577_auxadc_read()
173 mutex_unlock(&adc_dev->lock); in mt6577_auxadc_read()
179 mutex_unlock(&adc_dev->lock); in mt6577_auxadc_read()
181 return -ETIMEDOUT; in mt6577_auxadc_read()
196 dev_err(indio_dev->dev.parent, in mt6577_auxadc_read_raw()
198 chan->channel); in mt6577_auxadc_read_raw()
201 if (adc_dev->dev_comp->sample_data_cali) in mt6577_auxadc_read_raw()
204 /* Convert adc raw data to voltage: 0 - 1500 mV */ in mt6577_auxadc_read_raw()
210 return -EINVAL; in mt6577_auxadc_read_raw()
224 ret = clk_prepare_enable(adc_dev->adc_clk); in mt6577_auxadc_resume()
230 mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC, in mt6577_auxadc_resume()
242 mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC, in mt6577_auxadc_suspend()
244 clk_disable_unprepare(adc_dev->adc_clk); in mt6577_auxadc_suspend()
253 mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC, in mt6577_power_off()
264 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc_dev)); in mt6577_auxadc_probe()
266 return -ENOMEM; in mt6577_auxadc_probe()
269 indio_dev->name = dev_name(&pdev->dev); in mt6577_auxadc_probe()
270 indio_dev->info = &mt6577_auxadc_info; in mt6577_auxadc_probe()
271 indio_dev->modes = INDIO_DIRECT_MODE; in mt6577_auxadc_probe()
272 indio_dev->channels = mt6577_auxadc_iio_channels; in mt6577_auxadc_probe()
273 indio_dev->num_channels = ARRAY_SIZE(mt6577_auxadc_iio_channels); in mt6577_auxadc_probe()
275 adc_dev->reg_base = devm_platform_ioremap_resource(pdev, 0); in mt6577_auxadc_probe()
276 if (IS_ERR(adc_dev->reg_base)) in mt6577_auxadc_probe()
277 return dev_err_probe(&pdev->dev, PTR_ERR(adc_dev->reg_base), in mt6577_auxadc_probe()
280 adc_dev->adc_clk = devm_clk_get_enabled(&pdev->dev, "main"); in mt6577_auxadc_probe()
281 if (IS_ERR(adc_dev->adc_clk)) in mt6577_auxadc_probe()
282 return dev_err_probe(&pdev->dev, PTR_ERR(adc_dev->adc_clk), in mt6577_auxadc_probe()
285 adc_clk_rate = clk_get_rate(adc_dev->adc_clk); in mt6577_auxadc_probe()
287 return dev_err_probe(&pdev->dev, -EINVAL, "null clock rate\n"); in mt6577_auxadc_probe()
289 adc_dev->dev_comp = device_get_match_data(&pdev->dev); in mt6577_auxadc_probe()
291 mutex_init(&adc_dev->lock); in mt6577_auxadc_probe()
293 mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC, in mt6577_auxadc_probe()
298 ret = devm_add_action_or_reset(&pdev->dev, mt6577_power_off, adc_dev); in mt6577_auxadc_probe()
300 return dev_err_probe(&pdev->dev, ret, in mt6577_auxadc_probe()
303 ret = devm_iio_device_register(&pdev->dev, indio_dev); in mt6577_auxadc_probe()
305 return dev_err_probe(&pdev->dev, ret, "failed to register iio device\n"); in mt6577_auxadc_probe()
315 { .compatible = "mediatek,mt2701-auxadc", .data = &mt8173_compat },
316 { .compatible = "mediatek,mt2712-auxadc", .data = &mt8173_compat },
317 { .compatible = "mediatek,mt7622-auxadc", .data = &mt8173_compat },
318 { .compatible = "mediatek,mt8173-auxadc", .data = &mt8173_compat },
319 { .compatible = "mediatek,mt8186-auxadc", .data = &mt8186_compat },
320 { .compatible = "mediatek,mt6765-auxadc", .data = &mt6765_compat },
327 .name = "mt6577-auxadc",