Lines Matching refs:adc

70 static int lpc18xx_adc_read_chan(struct lpc18xx_adc *adc, unsigned int ch)  in lpc18xx_adc_read_chan()  argument
75 reg = adc->cr_reg | BIT(ch) | LPC18XX_ADC_CR_START_NOW; in lpc18xx_adc_read_chan()
76 writel(reg, adc->base + LPC18XX_ADC_CR); in lpc18xx_adc_read_chan()
78 ret = readl_poll_timeout(adc->base + LPC18XX_ADC_GDR, reg, in lpc18xx_adc_read_chan()
81 dev_warn(adc->dev, "adc read timed out\n"); in lpc18xx_adc_read_chan()
92 struct lpc18xx_adc *adc = iio_priv(indio_dev); in lpc18xx_adc_read_raw() local
96 mutex_lock(&adc->lock); in lpc18xx_adc_read_raw()
97 *val = lpc18xx_adc_read_chan(adc, chan->channel); in lpc18xx_adc_read_raw()
98 mutex_unlock(&adc->lock); in lpc18xx_adc_read_raw()
105 *val = regulator_get_voltage(adc->vref) / 1000; in lpc18xx_adc_read_raw()
120 struct lpc18xx_adc *adc = data; in lpc18xx_clear_cr_reg() local
122 writel(0, adc->base + LPC18XX_ADC_CR); in lpc18xx_clear_cr_reg()
138 struct lpc18xx_adc *adc; in lpc18xx_adc_probe() local
143 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc)); in lpc18xx_adc_probe()
147 adc = iio_priv(indio_dev); in lpc18xx_adc_probe()
148 adc->dev = &pdev->dev; in lpc18xx_adc_probe()
149 mutex_init(&adc->lock); in lpc18xx_adc_probe()
151 adc->base = devm_platform_ioremap_resource(pdev, 0); in lpc18xx_adc_probe()
152 if (IS_ERR(adc->base)) in lpc18xx_adc_probe()
153 return PTR_ERR(adc->base); in lpc18xx_adc_probe()
155 adc->clk = devm_clk_get(&pdev->dev, NULL); in lpc18xx_adc_probe()
156 if (IS_ERR(adc->clk)) in lpc18xx_adc_probe()
157 return dev_err_probe(&pdev->dev, PTR_ERR(adc->clk), in lpc18xx_adc_probe()
160 rate = clk_get_rate(adc->clk); in lpc18xx_adc_probe()
163 adc->vref = devm_regulator_get(&pdev->dev, "vref"); in lpc18xx_adc_probe()
164 if (IS_ERR(adc->vref)) in lpc18xx_adc_probe()
165 return dev_err_probe(&pdev->dev, PTR_ERR(adc->vref), in lpc18xx_adc_probe()
174 ret = regulator_enable(adc->vref); in lpc18xx_adc_probe()
180 ret = devm_add_action_or_reset(&pdev->dev, lpc18xx_regulator_disable, adc->vref); in lpc18xx_adc_probe()
184 ret = clk_prepare_enable(adc->clk); in lpc18xx_adc_probe()
191 adc->clk); in lpc18xx_adc_probe()
195 adc->cr_reg = (clkdiv << LPC18XX_ADC_CR_CLKDIV_SHIFT) | in lpc18xx_adc_probe()
197 writel(adc->cr_reg, adc->base + LPC18XX_ADC_CR); in lpc18xx_adc_probe()
199 ret = devm_add_action_or_reset(&pdev->dev, lpc18xx_clear_cr_reg, adc); in lpc18xx_adc_probe()