drivers/iio/imu/bmi323/bmi323_core.c

Source file repositories/reference/linux-study-clean/drivers/iio/imu/bmi323/bmi323_core.c

File Facts

System
Linux kernel
Corpus path
drivers/iio/imu/bmi323/bmi323_core.c
Extension
.c
Size
59072 bytes
Lines
2304
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 bmi323_hw {
	u8 data;
	u8 config;
	const int (*scale_table)[2];
	int scale_table_len;
};

/*
 * The accelerometer supports +-2G/4G/8G/16G ranges, and the resolution of
 * each sample is 16 bits, signed.
 * At +-8G the scale can calculated by
 * ((8 + 8) * 9.80665 / (2^16 - 1)) * 10^6 = 2394.23819 scale in micro
 *
 */
static const int bmi323_accel_scale[][2] = {
	{ 0, 598 },
	{ 0, 1197 },
	{ 0, 2394 },
	{ 0, 4788 },
};

static const int bmi323_gyro_scale[][2] = {
	{ 0, 66 },
	{ 0, 133 },
	{ 0, 266 },
	{ 0, 532 },
	{ 0, 1065 },
};

static const int bmi323_accel_gyro_avrg[] = {0, 2, 4, 8, 16, 32, 64};

static const struct bmi323_hw bmi323_hw[2] = {
	[BMI323_ACCEL] = {
		.data = BMI323_ACCEL_X_REG,
		.config = BMI323_ACC_CONF_REG,
		.scale_table = bmi323_accel_scale,
		.scale_table_len = ARRAY_SIZE(bmi323_accel_scale),
	},
	[BMI323_GYRO] = {
		.data = BMI323_GYRO_X_REG,
		.config = BMI323_GYRO_CONF_REG,
		.scale_table = bmi323_gyro_scale,
		.scale_table_len = ARRAY_SIZE(bmi323_gyro_scale),
	},
};

static const unsigned int bmi323_reg_savestate[] = {
	BMI323_INT_MAP1_REG,
	BMI323_INT_MAP2_REG,
	BMI323_IO_INT_CTR_REG,
	BMI323_IO_INT_CONF_REG,
	BMI323_ACC_CONF_REG,
	BMI323_GYRO_CONF_REG,
	BMI323_FEAT_IO0_REG,
	BMI323_FIFO_WTRMRK_REG,
	BMI323_FIFO_CONF_REG
};

static const unsigned int bmi323_ext_reg_savestate[] = {
	BMI323_GEN_SET1_REG,
	BMI323_TAP1_REG,
	BMI323_TAP2_REG,
	BMI323_TAP3_REG,
	BMI323_FEAT_IO0_S_TAP_MSK,
	BMI323_STEP_SC1_REG,
	BMI323_ANYMO1_REG,
	BMI323_NOMO1_REG,
	BMI323_ANYMO1_REG + BMI323_MO2_OFFSET,
	BMI323_NOMO1_REG + BMI323_MO2_OFFSET,
	BMI323_ANYMO1_REG + BMI323_MO3_OFFSET,
	BMI323_NOMO1_REG + BMI323_MO3_OFFSET
};

struct bmi323_regs_runtime_pm {
	unsigned int reg_settings[ARRAY_SIZE(bmi323_reg_savestate)];
	unsigned int ext_reg_settings[ARRAY_SIZE(bmi323_ext_reg_savestate)];
};

struct bmi323_data {
	struct device *dev;
	struct regmap *regmap;
	struct iio_mount_matrix orientation;
	enum bmi323_irq_pin irq_pin;
	struct iio_trigger *trig;
	enum bmi323_state state;
	s64 fifo_tstamp, old_fifo_tstamp;
	u32 odrns[BMI323_SENSORS_CNT];
	u32 odrhz[BMI323_SENSORS_CNT];
	unsigned int feature_events;
	struct bmi323_regs_runtime_pm runtime_pm_status;

Annotation

Implementation Notes