drivers/iio/imu/kmx61.c

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

File Facts

System
Linux kernel
Corpus path
drivers/iio/imu/kmx61.c
Extension
.c
Size
36192 bytes
Lines
1505
Domain
Driver Families
Bucket
drivers/iio
Inferred role
Driver Families: implementation source
Status
source 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 kmx61_data {
	struct i2c_client *client;

	/* serialize access to non-atomic ops, e.g set_mode */
	struct mutex lock;

	/* standby state */
	bool acc_stby;
	bool mag_stby;

	/* power state */
	bool acc_ps;
	bool mag_ps;

	/* config bits */
	u8 range;
	u8 odr_bits;
	u8 wake_thresh;
	u8 wake_duration;

	/* accelerometer specific data */
	struct iio_dev *acc_indio_dev;
	struct iio_trigger *acc_dready_trig;
	struct iio_trigger *motion_trig;
	bool acc_dready_trig_on;
	bool motion_trig_on;
	bool ev_enable_state;

	/* magnetometer specific data */
	struct iio_dev *mag_indio_dev;
	struct iio_trigger *mag_dready_trig;
	bool mag_dready_trig_on;
};

enum kmx61_range {
	KMX61_RANGE_2G,
	KMX61_RANGE_4G,
	KMX61_RANGE_8G,
};

enum kmx61_axis {
	KMX61_AXIS_X,
	KMX61_AXIS_Y,
	KMX61_AXIS_Z,
};

static const u16 kmx61_uscale_table[] = {9582, 19163, 38326};

static const struct {
	int val;
	int val2;
} kmx61_samp_freq_table[] = { {12, 500000},
			{25, 0},
			{50, 0},
			{100, 0},
			{200, 0},
			{400, 0},
			{800, 0},
			{1600, 0},
			{0, 781000},
			{1, 563000},
			{3, 125000},
			{6, 250000} };

static const struct {
	int val;
	int val2;
	int odr_bits;
} kmx61_wake_up_odr_table[] = { {0, 781000, 0x00},
				 {1, 563000, 0x01},
				 {3, 125000, 0x02},
				 {6, 250000, 0x03},
				 {12, 500000, 0x04},
				 {25, 0, 0x05},
				 {50, 0, 0x06},
				 {100, 0, 0x06},
				 {200, 0, 0x06},
				 {400, 0, 0x06},
				 {800, 0, 0x06},
				 {1600, 0, 0x06} };

static IIO_CONST_ATTR(accel_scale_available, "0.009582 0.019163 0.038326");
static IIO_CONST_ATTR(magn_scale_available, "0.001465");
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL(
	"0.781000 1.563000 3.125000 6.250000 12.500000 25 50 100 200 400 800");

static struct attribute *kmx61_acc_attributes[] = {
	&iio_const_attr_accel_scale_available.dev_attr.attr,
	&iio_const_attr_sampling_frequency_available.dev_attr.attr,
	NULL,

Annotation

Implementation Notes