linux/drivers/iio/dac/mcp4728.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Support for Microchip MCP4728
 *
 * Copyright (C) 2023 Andrea Collamati <[email protected]>
 *
 * Based on mcp4725 by Peter Meerwald <[email protected]>
 *
 * Driver for the Microchip I2C 12-bit digital-to-analog quad channels
 * converter (DAC).
 *
 * (7-bit I2C slave address 0x60, the three LSBs can be configured in
 * hardware)
 */

#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/property.h>
#include <linux/regulator/consumer.h>

#define MCP4728_RESOLUTION
#define MCP4728_N_CHANNELS

#define MCP4728_CMD_MASK
#define MCP4728_CHSEL_MASK
#define MCP4728_UDAC_MASK

#define MCP4728_VREF_MASK
#define MCP4728_PDMODE_MASK
#define MCP4728_GAIN_MASK

#define MCP4728_DAC_H_MASK
#define MCP4728_DAC_L_MASK

#define MCP4728_RDY_MASK

#define MCP4728_MW_CMD
#define MCP4728_SW_CMD

#define MCP4728_READ_RESPONSE_LEN
#define MCP4728_WRITE_EEPROM_LEN

enum vref_mode {};

enum gain_mode {};

enum iio_powerdown_mode {};

struct mcp4728_channel_data {};

/* MCP4728 Full Scale Ranges
 * the device available ranges are
 * - VREF = VDD				FSR = from 0.0V to VDD
 * - VREF = Internal	Gain = 1	FSR = from 0.0V to VREF
 * - VREF = Internal	Gain = 2	FSR = from 0.0V to 2*VREF
 */
enum mcp4728_scale {};

struct mcp4728_data {};

#define MCP4728_CHAN(chan)

static int mcp4728_suspend(struct device *dev);
static int mcp4728_resume(struct device *dev);

static ssize_t mcp4728_store_eeprom(struct device *dev,
				    struct device_attribute *attr,
				    const char *buf, size_t len)
{}

static IIO_DEVICE_ATTR(store_eeprom, 0200, NULL, mcp4728_store_eeprom, 0);

static struct attribute *mcp4728_attributes[] =;

static const struct attribute_group mcp4728_attribute_group =;

static int mcp4728_program_channel_cfg(int channel, struct iio_dev *indio_dev)
{}

static const char *const mcp4728_powerdown_modes[] =;

static int mcp4728_get_powerdown_mode(struct iio_dev *indio_dev,
				      const struct iio_chan_spec *chan)
{}

static int mcp4728_set_powerdown_mode(struct iio_dev *indio_dev,
				      const struct iio_chan_spec *chan,
				      unsigned int mode)
{}

static ssize_t mcp4728_read_powerdown(struct iio_dev *indio_dev,
				      uintptr_t private,
				      const struct iio_chan_spec *chan,
				      char *buf)
{}

static ssize_t mcp4728_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 mcp4728_powerdown_mode_enum =;

static const struct iio_chan_spec_ext_info mcp4728_ext_info[] =;

static const struct iio_chan_spec mcp4728_channels[MCP4728_N_CHANNELS] =;

static void mcp4728_get_scale_avail(enum mcp4728_scale scale,
				    struct mcp4728_data *data, int *val,
				    int *val2)
{}

static void mcp4728_get_scale(int channel, struct mcp4728_data *data, int *val,
			      int *val2)
{}

static int mcp4728_find_matching_scale(struct mcp4728_data *data, int val,
				       int val2)
{}

static int mcp4728_set_scale(int channel, struct mcp4728_data *data, int val,
			     int val2)
{}

static int mcp4728_read_raw(struct iio_dev *indio_dev,
			    struct iio_chan_spec const *chan, int *val,
			    int *val2, long mask)
{}

static int mcp4728_write_raw(struct iio_dev *indio_dev,
			     struct iio_chan_spec const *chan, int val,
			     int val2, long mask)
{}

static void mcp4728_init_scale_avail(enum mcp4728_scale scale, int vref_mv,
				     struct mcp4728_data *data)
{}

static int mcp4728_init_scales_avail(struct mcp4728_data *data)
{}

static int mcp4728_read_avail(struct iio_dev *indio_dev,
			      struct iio_chan_spec const *chan,
			      const int **vals, int *type, int *length,
			      long info)
{}

static const struct iio_info mcp4728_info =;

static int mcp4728_suspend(struct device *dev)
{}

static int mcp4728_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(mcp4728_pm_ops, mcp4728_suspend,
				mcp4728_resume);

static int mcp4728_init_channels_data(struct mcp4728_data *data)
{}

static void mcp4728_reg_disable(void *reg)
{}

static int mcp4728_probe(struct i2c_client *client)
{}

static const struct i2c_device_id mcp4728_id[] =;
MODULE_DEVICE_TABLE(i2c, mcp4728_id);

static const struct of_device_id mcp4728_of_match[] =;
MODULE_DEVICE_TABLE(of, mcp4728_of_match);

static struct i2c_driver mcp4728_driver =;
module_i2c_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();