Lines Matching full:dac
3 * IIO DAC driver for NXP LPC18xx DAC
25 /* LPC18XX DAC registers and bits */
53 struct lpc18xx_dac *dac = iio_priv(indio_dev); in lpc18xx_dac_read_raw() local
58 reg = readl(dac->base + LPC18XX_DAC_CR); in lpc18xx_dac_read_raw()
65 *val = regulator_get_voltage(dac->vref) / 1000; in lpc18xx_dac_read_raw()
78 struct lpc18xx_dac *dac = iio_priv(indio_dev); in lpc18xx_dac_write_raw() local
89 mutex_lock(&dac->lock); in lpc18xx_dac_write_raw()
90 writel(reg, dac->base + LPC18XX_DAC_CR); in lpc18xx_dac_write_raw()
91 writel(LPC18XX_DAC_CTRL_DMA_ENA, dac->base + LPC18XX_DAC_CTRL); in lpc18xx_dac_write_raw()
92 mutex_unlock(&dac->lock); in lpc18xx_dac_write_raw()
108 struct lpc18xx_dac *dac; in lpc18xx_dac_probe() local
111 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*dac)); in lpc18xx_dac_probe()
116 dac = iio_priv(indio_dev); in lpc18xx_dac_probe()
117 mutex_init(&dac->lock); in lpc18xx_dac_probe()
119 dac->base = devm_platform_ioremap_resource(pdev, 0); in lpc18xx_dac_probe()
120 if (IS_ERR(dac->base)) in lpc18xx_dac_probe()
121 return PTR_ERR(dac->base); in lpc18xx_dac_probe()
123 dac->clk = devm_clk_get(&pdev->dev, NULL); in lpc18xx_dac_probe()
124 if (IS_ERR(dac->clk)) { in lpc18xx_dac_probe()
126 return PTR_ERR(dac->clk); in lpc18xx_dac_probe()
129 dac->vref = devm_regulator_get(&pdev->dev, "vref"); in lpc18xx_dac_probe()
130 if (IS_ERR(dac->vref)) { in lpc18xx_dac_probe()
132 return PTR_ERR(dac->vref); in lpc18xx_dac_probe()
141 ret = regulator_enable(dac->vref); in lpc18xx_dac_probe()
147 ret = clk_prepare_enable(dac->clk); in lpc18xx_dac_probe()
153 writel(0, dac->base + LPC18XX_DAC_CTRL); in lpc18xx_dac_probe()
154 writel(0, dac->base + LPC18XX_DAC_CR); in lpc18xx_dac_probe()
165 clk_disable_unprepare(dac->clk); in lpc18xx_dac_probe()
167 regulator_disable(dac->vref); in lpc18xx_dac_probe()
174 struct lpc18xx_dac *dac = iio_priv(indio_dev); in lpc18xx_dac_remove() local
178 writel(0, dac->base + LPC18XX_DAC_CTRL); in lpc18xx_dac_remove()
179 clk_disable_unprepare(dac->clk); in lpc18xx_dac_remove()
180 regulator_disable(dac->vref); in lpc18xx_dac_remove()
186 { .compatible = "nxp,lpc1850-dac" },
195 .name = "lpc18xx-dac",
201 MODULE_DESCRIPTION("LPC18xx DAC driver");