linux/drivers/hwmon/ads7871.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  ads7871 - driver for TI ADS7871 A/D converter
 *
 *  Copyright (c) 2010 Paul Thomas <[email protected]>
 *
 *	You need to have something like this in struct spi_board_info
 *	{
 *		.modalias	= "ads7871",
 *		.max_speed_hz	= 2*1000*1000,
 *		.chip_select	= 0,
 *		.bus_num	= 1,
 *	},
 */

/*From figure 18 in the datasheet*/
/*Register addresses*/
#define REG_LS_BYTE
#define REG_MS_BYTE
#define REG_PGA_VALID
#define REG_AD_CONTROL
#define REG_GAIN_MUX
#define REG_IO_STATE
#define REG_IO_CONTROL
#define REG_OSC_CONTROL
#define REG_SER_CONTROL
#define REG_ID

/*
 * From figure 17 in the datasheet
 * These bits get ORed with the address to form
 * the instruction byte
 */
/*Instruction Bit masks*/
#define INST_MODE_BM
#define INST_READ_BM
#define INST_16BIT_BM

/*From figure 18 in the datasheet*/
/*bit masks for Rev/Oscillator Control Register*/
#define MUX_CNV_BV
#define MUX_CNV_BM
#define MUX_M3_BM
#define MUX_G_BV

/*From figure 18 in the datasheet*/
/*bit masks for Rev/Oscillator Control Register*/
#define OSC_OSCR_BM
#define OSC_OSCE_BM
#define OSC_REFE_BM
#define OSC_BUFE_BM
#define OSC_R2V_BM
#define OSC_RBG_BM

#include <linux/module.h>
#include <linux/init.h>
#include <linux/spi/spi.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
#include <linux/delay.h>

#define DEVICE_NAME

struct ads7871_data {};

static int ads7871_read_reg8(struct spi_device *spi, int reg)
{}

static int ads7871_read_reg16(struct spi_device *spi, int reg)
{}

static int ads7871_write_reg8(struct spi_device *spi, int reg, u8 val)
{}

static ssize_t voltage_show(struct device *dev, struct device_attribute *da,
			    char *buf)
{}

static SENSOR_DEVICE_ATTR_RO(in0_input, voltage, 0);
static SENSOR_DEVICE_ATTR_RO(in1_input, voltage, 1);
static SENSOR_DEVICE_ATTR_RO(in2_input, voltage, 2);
static SENSOR_DEVICE_ATTR_RO(in3_input, voltage, 3);
static SENSOR_DEVICE_ATTR_RO(in4_input, voltage, 4);
static SENSOR_DEVICE_ATTR_RO(in5_input, voltage, 5);
static SENSOR_DEVICE_ATTR_RO(in6_input, voltage, 6);
static SENSOR_DEVICE_ATTR_RO(in7_input, voltage, 7);

static struct attribute *ads7871_attrs[] =;

ATTRIBUTE_GROUPS();

static int ads7871_probe(struct spi_device *spi)
{}

static struct spi_driver ads7871_driver =;

module_spi_driver();

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