// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2019 TDK-InvenSense, Inc. */ #include <linux/kernel.h> #include <linux/device.h> #include <linux/string.h> #include "inv_mpu_aux.h" #include "inv_mpu_iio.h" #include "inv_mpu_magn.h" /* * MPU9xxx magnetometer are AKM chips on I2C aux bus * MPU9150 is AK8975 * MPU9250 is AK8963 */ #define INV_MPU_MAGN_I2C_ADDR … #define INV_MPU_MAGN_REG_WIA … #define INV_MPU_MAGN_BITS_WIA … #define INV_MPU_MAGN_REG_ST1 … #define INV_MPU_MAGN_BIT_DRDY … #define INV_MPU_MAGN_BIT_DOR … #define INV_MPU_MAGN_REG_DATA … #define INV_MPU_MAGN_REG_ST2 … #define INV_MPU_MAGN_BIT_HOFL … #define INV_MPU_MAGN_BIT_BITM … #define INV_MPU_MAGN_REG_CNTL1 … #define INV_MPU_MAGN_BITS_MODE_PWDN … #define INV_MPU_MAGN_BITS_MODE_SINGLE … #define INV_MPU_MAGN_BITS_MODE_FUSE … #define INV_MPU9250_MAGN_BIT_OUTPUT_BIT … #define INV_MPU9250_MAGN_REG_CNTL2 … #define INV_MPU9250_MAGN_BIT_SRST … #define INV_MPU_MAGN_REG_ASAX … #define INV_MPU_MAGN_REG_ASAY … #define INV_MPU_MAGN_REG_ASAZ … static bool inv_magn_supported(const struct inv_mpu6050_state *st) { … } /* init magnetometer chip */ static int inv_magn_init(struct inv_mpu6050_state *st) { … } /** * inv_mpu_magn_probe() - probe and setup magnetometer chip * @st: driver internal state * * Returns 0 on success, a negative error code otherwise * * It is probing the chip and setting up all needed i2c transfers. * Noop if there is no magnetometer in the chip. */ int inv_mpu_magn_probe(struct inv_mpu6050_state *st) { … } /** * inv_mpu_magn_set_rate() - set magnetometer sampling rate * @st: driver internal state * @fifo_rate: mpu set fifo rate * * Returns 0 on success, a negative error code otherwise * * Limit sampling frequency to the maximum value supported by the * magnetometer chip. Resulting in duplicated data for higher frequencies. * Noop if there is no magnetometer in the chip. */ int inv_mpu_magn_set_rate(const struct inv_mpu6050_state *st, int fifo_rate) { … } /** * inv_mpu_magn_set_orient() - fill magnetometer mounting matrix * @st: driver internal state * * Returns 0 on success, a negative error code otherwise * * Fill magnetometer mounting matrix using the provided chip matrix. */ int inv_mpu_magn_set_orient(struct inv_mpu6050_state *st) { … } /** * inv_mpu_magn_read() - read magnetometer data * @st: driver internal state * @axis: IIO modifier axis value * @val: store corresponding axis value * * Returns 0 on success, a negative error code otherwise */ int inv_mpu_magn_read(struct inv_mpu6050_state *st, int axis, int *val) { … }