linux/drivers/iio/dac/mcp4821.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (C) 2023 Anshul Dalal <[email protected]>
 *
 * Driver for Microchip MCP4801, MCP4802, MCP4811, MCP4812, MCP4821 and MCP4822
 *
 * Based on the work of:
 *	Michael Welling (MCP4922 Driver)
 *
 * Datasheet:
 *	MCP48x1: https://ww1.microchip.com/downloads/en/DeviceDoc/22244B.pdf
 *	MCP48x2: https://ww1.microchip.com/downloads/en/DeviceDoc/20002249B.pdf
 *
 * TODO:
 *	- Configurable gain
 *	- Regulator control
 */

#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/spi/spi.h>

#include <linux/iio/iio.h>
#include <linux/iio/types.h>

#include <asm/unaligned.h>

#define MCP4821_ACTIVE_MODE
#define MCP4802_SECOND_CHAN

/* DAC uses an internal Voltage reference of 4.096V at a gain of 2x */
#define MCP4821_2X_GAIN_VREF_MV

enum mcp4821_supported_drvice_ids {};

struct mcp4821_state {};

struct mcp4821_chip_info {};

#define MCP4821_CHAN(channel_id, resolution)

static const struct mcp4821_chip_info mcp4821_chip_info_table[6] =;

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

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

static const struct iio_info mcp4821_info =;

static int mcp4821_probe(struct spi_device *spi)
{}

#define MCP4821_COMPATIBLE(of_compatible, id)

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

static const struct spi_device_id mcp4821_id_table[] =;
MODULE_DEVICE_TABLE(spi, mcp4821_id_table);

static struct spi_driver mcp4821_driver =;
module_spi_driver();

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