Lines Matching refs:adc

69 static int lpc18xx_adc_read_chan(struct lpc18xx_adc *adc, unsigned int ch)  in lpc18xx_adc_read_chan()  argument
74 reg = adc->cr_reg | BIT(ch) | LPC18XX_ADC_CR_START_NOW; in lpc18xx_adc_read_chan()
75 writel(reg, adc->base + LPC18XX_ADC_CR); in lpc18xx_adc_read_chan()
77 ret = readl_poll_timeout(adc->base + LPC18XX_ADC_GDR, reg, in lpc18xx_adc_read_chan()
80 dev_warn(adc->dev, "adc read timed out\n"); in lpc18xx_adc_read_chan()
91 struct lpc18xx_adc *adc = iio_priv(indio_dev); in lpc18xx_adc_read_raw() local
95 mutex_lock(&adc->lock); in lpc18xx_adc_read_raw()
96 *val = lpc18xx_adc_read_chan(adc, chan->channel); in lpc18xx_adc_read_raw()
97 mutex_unlock(&adc->lock); in lpc18xx_adc_read_raw()
104 *val = regulator_get_voltage(adc->vref) / 1000; in lpc18xx_adc_read_raw()
119 struct lpc18xx_adc *adc = data; in lpc18xx_clear_cr_reg() local
121 writel(0, adc->base + LPC18XX_ADC_CR); in lpc18xx_clear_cr_reg()
132 struct lpc18xx_adc *adc; in lpc18xx_adc_probe() local
137 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc)); in lpc18xx_adc_probe()
141 adc = iio_priv(indio_dev); in lpc18xx_adc_probe()
142 adc->dev = &pdev->dev; in lpc18xx_adc_probe()
143 mutex_init(&adc->lock); in lpc18xx_adc_probe()
145 adc->base = devm_platform_ioremap_resource(pdev, 0); in lpc18xx_adc_probe()
146 if (IS_ERR(adc->base)) in lpc18xx_adc_probe()
147 return PTR_ERR(adc->base); in lpc18xx_adc_probe()
149 adc->clk = devm_clk_get_enabled(&pdev->dev, NULL); in lpc18xx_adc_probe()
150 if (IS_ERR(adc->clk)) in lpc18xx_adc_probe()
151 return dev_err_probe(&pdev->dev, PTR_ERR(adc->clk), in lpc18xx_adc_probe()
154 adc->vref = devm_regulator_get(&pdev->dev, "vref"); in lpc18xx_adc_probe()
155 if (IS_ERR(adc->vref)) in lpc18xx_adc_probe()
156 return dev_err_probe(&pdev->dev, PTR_ERR(adc->vref), in lpc18xx_adc_probe()
165 ret = regulator_enable(adc->vref); in lpc18xx_adc_probe()
171 ret = devm_add_action_or_reset(&pdev->dev, lpc18xx_regulator_disable, adc->vref); in lpc18xx_adc_probe()
175 rate = clk_get_rate(adc->clk); in lpc18xx_adc_probe()
178 adc->cr_reg = (clkdiv << LPC18XX_ADC_CR_CLKDIV_SHIFT) | in lpc18xx_adc_probe()
180 writel(adc->cr_reg, adc->base + LPC18XX_ADC_CR); in lpc18xx_adc_probe()
182 ret = devm_add_action_or_reset(&pdev->dev, lpc18xx_clear_cr_reg, adc); in lpc18xx_adc_probe()