drivers/iio/accel/fxls8962af-core.c

Source file repositories/reference/linux-study-clean/drivers/iio/accel/fxls8962af-core.c

File Facts

System
Linux kernel
Corpus path
drivers/iio/accel/fxls8962af-core.c
Extension
.c
Size
33372 bytes
Lines
1318
Domain
Driver Families
Bucket
drivers/iio
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct fxls8962af_chip_info {
	const char *name;
	const struct iio_chan_spec *channels;
	int num_channels;
	u8 chip_id;
};

struct fxls8962af_data {
	struct regmap *regmap;
	const struct fxls8962af_chip_info *chip_info;
	struct {
		__le16 channels[3];
		aligned_s64 ts;
	} scan;
	int64_t timestamp, old_timestamp;	/* Only used in hw fifo mode. */
	struct iio_mount_matrix orientation;
	int irq;
	u8 watermark;
	u8 enable_event;
	u16 lower_thres;
	u16 upper_thres;
};

const struct regmap_config fxls8962af_i2c_regmap_conf = {
	.reg_bits = 8,
	.val_bits = 8,
	.max_register = FXLS8962AF_MAX_REG,
};
EXPORT_SYMBOL_NS_GPL(fxls8962af_i2c_regmap_conf, "IIO_FXLS8962AF");

const struct regmap_config fxls8962af_spi_regmap_conf = {
	.reg_bits = 8,
	.pad_bits = 8,
	.val_bits = 8,
	.max_register = FXLS8962AF_MAX_REG,
};
EXPORT_SYMBOL_NS_GPL(fxls8962af_spi_regmap_conf, "IIO_FXLS8962AF");

enum {
	fxls8962af_idx_x,
	fxls8962af_idx_y,
	fxls8962af_idx_z,
	fxls8962af_idx_ts,
};

enum fxls8962af_int_pin {
	FXLS8962AF_PIN_INT1,
	FXLS8962AF_PIN_INT2,
};

static int fxls8962af_power_on(struct fxls8962af_data *data)
{
	struct device *dev = regmap_get_device(data->regmap);
	int ret;

	ret = pm_runtime_resume_and_get(dev);
	if (ret)
		dev_err(dev, "failed to power on\n");

	return ret;
}

static int fxls8962af_power_off(struct fxls8962af_data *data)
{
	struct device *dev = regmap_get_device(data->regmap);
	int ret;

	ret = pm_runtime_put_autosuspend(dev);
	if (ret)
		dev_err(dev, "failed to power off\n");

	return ret;
}

static int fxls8962af_standby(struct fxls8962af_data *data)
{
	return regmap_clear_bits(data->regmap, FXLS8962AF_SENS_CONFIG1,
				 FXLS8962AF_SENS_CONFIG1_ACTIVE);
}

static int fxls8962af_active(struct fxls8962af_data *data)
{
	return regmap_update_bits(data->regmap, FXLS8962AF_SENS_CONFIG1,
				  FXLS8962AF_SENS_CONFIG1_ACTIVE, 1);
}

static int fxls8962af_is_active(struct fxls8962af_data *data)
{
	unsigned int reg;
	int ret;

Annotation

Implementation Notes