Lines Matching full:dac
3 * IIO DAC driver for NXP LPC18xx DAC
24 /* LPC18XX DAC registers and bits */
52 struct lpc18xx_dac *dac = iio_priv(indio_dev); in lpc18xx_dac_read_raw() local
57 reg = readl(dac->base + LPC18XX_DAC_CR); in lpc18xx_dac_read_raw()
64 *val = regulator_get_voltage(dac->vref) / 1000; in lpc18xx_dac_read_raw()
77 struct lpc18xx_dac *dac = iio_priv(indio_dev); in lpc18xx_dac_write_raw() local
88 mutex_lock(&dac->lock); in lpc18xx_dac_write_raw()
89 writel(reg, dac->base + LPC18XX_DAC_CR); in lpc18xx_dac_write_raw()
90 writel(LPC18XX_DAC_CTRL_DMA_ENA, dac->base + LPC18XX_DAC_CTRL); in lpc18xx_dac_write_raw()
91 mutex_unlock(&dac->lock); in lpc18xx_dac_write_raw()
107 struct lpc18xx_dac *dac; in lpc18xx_dac_probe() local
110 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*dac)); in lpc18xx_dac_probe()
115 dac = iio_priv(indio_dev); in lpc18xx_dac_probe()
116 mutex_init(&dac->lock); in lpc18xx_dac_probe()
118 dac->base = devm_platform_ioremap_resource(pdev, 0); in lpc18xx_dac_probe()
119 if (IS_ERR(dac->base)) in lpc18xx_dac_probe()
120 return PTR_ERR(dac->base); in lpc18xx_dac_probe()
122 dac->clk = devm_clk_get(&pdev->dev, NULL); in lpc18xx_dac_probe()
123 if (IS_ERR(dac->clk)) in lpc18xx_dac_probe()
124 return dev_err_probe(&pdev->dev, PTR_ERR(dac->clk), in lpc18xx_dac_probe()
127 dac->vref = devm_regulator_get(&pdev->dev, "vref"); in lpc18xx_dac_probe()
128 if (IS_ERR(dac->vref)) in lpc18xx_dac_probe()
129 return dev_err_probe(&pdev->dev, PTR_ERR(dac->vref), in lpc18xx_dac_probe()
138 ret = regulator_enable(dac->vref); in lpc18xx_dac_probe()
144 ret = clk_prepare_enable(dac->clk); in lpc18xx_dac_probe()
150 writel(0, dac->base + LPC18XX_DAC_CTRL); in lpc18xx_dac_probe()
151 writel(0, dac->base + LPC18XX_DAC_CR); in lpc18xx_dac_probe()
162 clk_disable_unprepare(dac->clk); in lpc18xx_dac_probe()
164 regulator_disable(dac->vref); in lpc18xx_dac_probe()
171 struct lpc18xx_dac *dac = iio_priv(indio_dev); in lpc18xx_dac_remove() local
175 writel(0, dac->base + LPC18XX_DAC_CTRL); in lpc18xx_dac_remove()
176 clk_disable_unprepare(dac->clk); in lpc18xx_dac_remove()
177 regulator_disable(dac->vref); in lpc18xx_dac_remove()
183 { .compatible = "nxp,lpc1850-dac" },
192 .name = "lpc18xx-dac",
198 MODULE_DESCRIPTION("LPC18xx DAC driver");