linux/drivers/iio/magnetometer/hmc5843_core.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Device driver for the HMC5843 multi-chip module designed
 * for low field magnetic sensing.
 *
 * Copyright (C) 2010 Texas Instruments
 *
 * Author: Shubhrajyoti Datta <[email protected]>
 * Acknowledgment: Jonathan Cameron <[email protected]> for valuable inputs.
 * Support for HMC5883 and HMC5883L by Peter Meerwald <[email protected]>.
 * Split to multiple files by Josef Gajdusek <[email protected]> - 2014
 */

#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/buffer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/delay.h>

#include "hmc5843.h"

/*
 * Range gain settings in (+-)Ga
 * Beware: HMC5843 and HMC5883 have different recommended sensor field
 * ranges; default corresponds to +-1.0 Ga and +-1.3 Ga, respectively
 */
#define HMC5843_RANGE_GAIN_OFFSET
#define HMC5843_RANGE_GAIN_DEFAULT
#define HMC5843_RANGE_GAIN_MASK

/* Device status */
#define HMC5843_DATA_READY
#define HMC5843_DATA_OUTPUT_LOCK

/* Mode register configuration */
#define HMC5843_MODE_CONVERSION_CONTINUOUS
#define HMC5843_MODE_CONVERSION_SINGLE
#define HMC5843_MODE_IDLE
#define HMC5843_MODE_SLEEP
#define HMC5843_MODE_MASK

/*
 * HMC5843: Minimum data output rate
 * HMC5883: Typical data output rate
 */
#define HMC5843_RATE_OFFSET
#define HMC5843_RATE_DEFAULT
#define HMC5843_RATE_MASK

/* Device measurement configuration */
#define HMC5843_MEAS_CONF_NORMAL
#define HMC5843_MEAS_CONF_POSITIVE_BIAS
#define HMC5843_MEAS_CONF_NEGATIVE_BIAS
#define HMC5843_MEAS_CONF_MASK

/*
 * API for setting the measurement configuration to
 * Normal, Positive bias and Negative bias
 *
 * From the datasheet:
 * 0 - Normal measurement configuration (default): In normal measurement
 *     configuration the device follows normal measurement flow. Pins BP
 *     and BN are left floating and high impedance.
 *
 * 1 - Positive bias configuration: In positive bias configuration, a
 *     positive current is forced across the resistive load on pins BP
 *     and BN.
 *
 * 2 - Negative bias configuration. In negative bias configuration, a
 *     negative current is forced across the resistive load on pins BP
 *     and BN.
 *
 * 3 - Only available on HMC5983. Magnetic sensor is disabled.
 *     Temperature sensor is enabled.
 */

static const char *const hmc5843_meas_conf_modes[] =;

static const char *const hmc5983_meas_conf_modes[] =;
/* Scaling factors: 10000000/Gain */
static const int hmc5843_regval_to_nanoscale[] =;

static const int hmc5883_regval_to_nanoscale[] =;

static const int hmc5883l_regval_to_nanoscale[] =;

/*
 * From the datasheet:
 * Value	| HMC5843		| HMC5883/HMC5883L
 *		| Data output rate (Hz)	| Data output rate (Hz)
 * 0		| 0.5			| 0.75
 * 1		| 1			| 1.5
 * 2		| 2			| 3
 * 3		| 5			| 7.5
 * 4		| 10 (default)		| 15
 * 5		| 20			| 30
 * 6		| 50			| 75
 * 7		| Not used		| Not used
 */
static const int hmc5843_regval_to_samp_freq[][2] =;

static const int hmc5883_regval_to_samp_freq[][2] =;

static const int hmc5983_regval_to_samp_freq[][2] =;

/* Describe chip variants */
struct hmc5843_chip_info {};

/* The lower two bits contain the current conversion mode */
static s32 hmc5843_set_mode(struct hmc5843_data *data, u8 operating_mode)
{}

static int hmc5843_wait_measurement(struct hmc5843_data *data)
{}

/* Return the measurement value from the specified channel */
static int hmc5843_read_measurement(struct hmc5843_data *data,
				    int idx, int *val)
{}

static int hmc5843_set_meas_conf(struct hmc5843_data *data, u8 meas_conf)
{}

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

static
int hmc5843_set_measurement_configuration(struct iio_dev *indio_dev,
					  const struct iio_chan_spec *chan,
					  unsigned int meas_conf)
{}

static const struct iio_mount_matrix *
hmc5843_get_mount_matrix(const struct iio_dev *indio_dev,
			  const struct iio_chan_spec *chan)
{}

static const struct iio_enum hmc5843_meas_conf_enum =;

static const struct iio_chan_spec_ext_info hmc5843_ext_info[] =;

static const struct iio_enum hmc5983_meas_conf_enum =;

static const struct iio_chan_spec_ext_info hmc5983_ext_info[] =;

static
ssize_t hmc5843_show_samp_freq_avail(struct device *dev,
				     struct device_attribute *attr, char *buf)
{}

static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(hmc5843_show_samp_freq_avail);

static int hmc5843_set_samp_freq(struct hmc5843_data *data, u8 rate)
{}

static int hmc5843_get_samp_freq_index(struct hmc5843_data *data,
				       int val, int val2)
{}

static int hmc5843_set_range_gain(struct hmc5843_data *data, u8 range)
{}

static ssize_t hmc5843_show_scale_avail(struct device *dev,
					struct device_attribute *attr,
					char *buf)
{}

static IIO_DEVICE_ATTR(scale_available, S_IRUGO,
	hmc5843_show_scale_avail, NULL, 0);

static int hmc5843_get_scale_index(struct hmc5843_data *data, int val, int val2)
{}

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

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

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

static irqreturn_t hmc5843_trigger_handler(int irq, void *p)
{}

#define HMC5843_CHANNEL(axis, idx)

#define HMC5983_CHANNEL(axis, idx)

static const struct iio_chan_spec hmc5843_channels[] =;

/* Beware: Y and Z are exchanged on HMC5883 and 5983 */
static const struct iio_chan_spec hmc5883_channels[] =;

static const struct iio_chan_spec hmc5983_channels[] =;

static struct attribute *hmc5843_attributes[] =;

static const struct attribute_group hmc5843_group =;

static const struct hmc5843_chip_info hmc5843_chip_info_tbl[] =;

static int hmc5843_init(struct hmc5843_data *data)
{}

static const struct iio_info hmc5843_info =;

static const unsigned long hmc5843_scan_masks[] =;

static int hmc5843_common_suspend(struct device *dev)
{}

static int hmc5843_common_resume(struct device *dev)
{}
EXPORT_NS_SIMPLE_DEV_PM_OPS(hmc5843_pm_ops, hmc5843_common_suspend,
			    hmc5843_common_resume, IIO_HMC5843);

int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
			 enum hmc5843_ids id, const char *name)
{}
EXPORT_SYMBOL_NS();

void hmc5843_common_remove(struct device *dev)
{}
EXPORT_SYMBOL_NS();

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