#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/iio/iio.h>
#include <linux/kernel.h>
#include <linux/kstrtox.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/string_choices.h>
#include "stm32-dac-core.h"
#define STM32_DAC_CHANNEL_1 …
#define STM32_DAC_CHANNEL_2 …
#define STM32_DAC_IS_CHAN_1(ch) …
#define STM32_DAC_AUTO_SUSPEND_DELAY_MS …
struct stm32_dac { … };
static int stm32_dac_is_enabled(struct iio_dev *indio_dev, int channel)
{ … }
static int stm32_dac_set_enable_state(struct iio_dev *indio_dev, int ch,
bool enable)
{ … }
static int stm32_dac_get_value(struct stm32_dac *dac, int channel, int *val)
{ … }
static int stm32_dac_set_value(struct stm32_dac *dac, int channel, int val)
{ … }
static int stm32_dac_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{ … }
static int stm32_dac_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val, int val2, long mask)
{ … }
static int stm32_dac_debugfs_reg_access(struct iio_dev *indio_dev,
unsigned reg, unsigned writeval,
unsigned *readval)
{ … }
static const struct iio_info stm32_dac_iio_info = …;
static const char * const stm32_dac_powerdown_modes[] = …;
static int stm32_dac_get_powerdown_mode(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan)
{ … }
static int stm32_dac_set_powerdown_mode(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
unsigned int type)
{ … }
static ssize_t stm32_dac_read_powerdown(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan,
char *buf)
{ … }
static ssize_t stm32_dac_write_powerdown(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan,
const char *buf, size_t len)
{ … }
static const struct iio_enum stm32_dac_powerdown_mode_en = …;
static const struct iio_chan_spec_ext_info stm32_dac_ext_info[] = …;
#define STM32_DAC_CHANNEL(chan, name) …
static const struct iio_chan_spec stm32_dac_channels[] = …;
static int stm32_dac_chan_of_init(struct iio_dev *indio_dev)
{
struct device_node *np = indio_dev->dev.of_node;
unsigned int i;
u32 channel;
int ret;
ret = of_property_read_u32(np, "reg", &channel);
if (ret) {
dev_err(&indio_dev->dev, "Failed to read reg property\n");
return ret;
}
for (i = 0; i < ARRAY_SIZE(stm32_dac_channels); i++) {
if (stm32_dac_channels[i].channel == channel)
break;
}
if (i >= ARRAY_SIZE(stm32_dac_channels)) {
dev_err(&indio_dev->dev, "Invalid reg property\n");
return -EINVAL;
}
indio_dev->channels = &stm32_dac_channels[i];
indio_dev->num_channels = 1;
return 0;
};
static int stm32_dac_probe(struct platform_device *pdev)
{ … }
static void stm32_dac_remove(struct platform_device *pdev)
{ … }
static int stm32_dac_suspend(struct device *dev)
{ … }
static DEFINE_SIMPLE_DEV_PM_OPS(stm32_dac_pm_ops, stm32_dac_suspend,
pm_runtime_force_resume);
static const struct of_device_id stm32_dac_of_match[] = …;
MODULE_DEVICE_TABLE(of, stm32_dac_of_match);
static struct platform_driver stm32_dac_driver = …;
module_platform_driver(…) …;
MODULE_ALIAS(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;