Lines Matching full:dac
3 * This file is part of STM32 DAC driver
18 #include "stm32-dac-core.h"
27 * struct stm32_dac - private data of DAC driver
28 * @common: reference to DAC common data
39 struct stm32_dac *dac = iio_priv(indio_dev); in stm32_dac_is_enabled() local
43 ret = regmap_read(dac->common->regmap, STM32_DAC_CR, &val); in stm32_dac_is_enabled()
57 struct stm32_dac *dac = iio_priv(indio_dev); in stm32_dac_set_enable_state() local
64 mutex_lock(&dac->lock); in stm32_dac_set_enable_state()
67 mutex_unlock(&dac->lock); in stm32_dac_set_enable_state()
75 mutex_unlock(&dac->lock); in stm32_dac_set_enable_state()
80 ret = regmap_update_bits(dac->common->regmap, STM32_DAC_CR, msk, en); in stm32_dac_set_enable_state()
81 mutex_unlock(&dac->lock); in stm32_dac_set_enable_state()
93 if (en && dac->common->hfsel) in stm32_dac_set_enable_state()
112 static int stm32_dac_get_value(struct stm32_dac *dac, int channel, int *val) in stm32_dac_get_value() argument
117 ret = regmap_read(dac->common->regmap, STM32_DAC_DOR1, val); in stm32_dac_get_value()
119 ret = regmap_read(dac->common->regmap, STM32_DAC_DOR2, val); in stm32_dac_get_value()
124 static int stm32_dac_set_value(struct stm32_dac *dac, int channel, int val) in stm32_dac_set_value() argument
129 ret = regmap_write(dac->common->regmap, STM32_DAC_DHR12R1, val); in stm32_dac_set_value()
131 ret = regmap_write(dac->common->regmap, STM32_DAC_DHR12R2, val); in stm32_dac_set_value()
140 struct stm32_dac *dac = iio_priv(indio_dev); in stm32_dac_read_raw() local
144 return stm32_dac_get_value(dac, chan->channel, val); in stm32_dac_read_raw()
146 *val = dac->common->vref_mv; in stm32_dac_read_raw()
158 struct stm32_dac *dac = iio_priv(indio_dev); in stm32_dac_write_raw() local
162 return stm32_dac_set_value(dac, chan->channel, val); in stm32_dac_write_raw()
172 struct stm32_dac *dac = iio_priv(indio_dev); in stm32_dac_debugfs_reg_access() local
175 return regmap_write(dac->common->regmap, reg, writeval); in stm32_dac_debugfs_reg_access()
177 return regmap_read(dac->common->regmap, reg, readval); in stm32_dac_debugfs_reg_access()
315 struct stm32_dac *dac; in stm32_dac_probe() local
321 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*dac)); in stm32_dac_probe()
326 dac = iio_priv(indio_dev); in stm32_dac_probe()
327 dac->common = dev_get_drvdata(pdev->dev.parent); in stm32_dac_probe()
333 mutex_init(&dac->lock); in stm32_dac_probe()
339 /* Get stm32-dac-core PM online */ in stm32_dac_probe()
382 /* Ensure DAC is disabled before suspend */ in stm32_dac_suspend()
395 { .compatible = "st,stm32-dac", },
404 .name = "stm32-dac",
411 MODULE_ALIAS("platform:stm32-dac");
413 MODULE_DESCRIPTION("STMicroelectronics STM32 DAC driver");