1. copy iam20680.c, iam20680.h, invn_selftest.c and invn_selftest.h into kernel/drivers/misc

2. modify Kconfig, example is shown below

config SENSORS_IAM20680
    tristate "INV_MPU Accelerometer and Gyroscope support"
    default n
    depends on I2C
      If you say yes here you get support for InvenSense's
      Accelerometer and Gyroscope sensor.
3. modify Makefile, example is shown below

obj-$(CONFIG_SENSORS_IAM20680)  += iam20680.o invn_selftest.o

4. if dts is using, please enable #define INVN_DTS

5. In iam20680.h, choose the correct macro definition between BUS_TYPE_I2C and BUS_TYPE_SPI according to what interface is in use  

6. In iam20680.h, choose the correct macro definition for Invensense chip part number(IAM20680 or ICM20600) 

7. If using INT signal, please assign proper interrupt pin in dts or board config file, for example, using gpio_to_irq() function to get correct pin number

8. example of dts is attached with the package
    /* I2C device */
    i2c@f9968000 {
        // status = "disabled";
        /* Invensense */
        mpu6515_acc@68 {
            compatible = "inven,iam20680";
            reg = <0x68>;
            interrupt-parent = <&msmgpio>;
            interrupts = <73 0x2>;
            inven,vdd_ana-supply = <&pm8941_l17>;        //platform related
            inven,vcc_i2c-supply = <&pm8941_lvs1>;        //platform related
            inven,gpio_int1 = <&msmgpio 73 0x00>;        //platform related
            axis_map_x = <1>;                            //define for matrix
            axis_map_y = <0>;                            //matrix = {0, -1, 0, -1, 0, 0, 0, 0, -1}
            axis_map_z = <2>;
            negate_x = <1>;
            negate_y = <1>;
            negate_z = <1>;

9. there are 3 devices created, 
sensor_dump                    //cat to get sensor register data
sensor_enable                //echo 1 or 0 to enable or disable iam20680
sensor_imu_enable            //echo 1 or 0 to enable or disable ima20680 imu mode
sensor_matrix                //cat to get matrix for placement
sensor_mode                    //echo 0, 1, 2, 3 for timer mode, FIFO mode, IMU DRI mode and test mode
sensor_name                    //cat to get sensor name
sensor_odr                    //echo 100 for 100Hz ODR, max ODR is 100Hz
sensor_selftest                //cat to get selfter result in test mode, 3 means success
sensor_temp                    //cat to get temperature, 245 means 24.5C

accel_bias                    //echo or cat sensor bias value
accel_bw                    //echo 44 for 44Hz BW
accel_delay                    //echo 10 for 10ms delay
accel_enable                //echo 1 or 0 to enable or disable event output
accel_fsr                    //echo 2 for 2G, 4 for 4G
accel_raw                    //cat to get sensor data from register
accel_value                    //cat to get sensor data after remving bias


10. dynamic debug
except error informations are printed, warning and info are selectable to print.
enable CONFIG_DYNAMIC_DEBUG=y during building the kernel
cat /sys/kernel/debug/dynamic_debug/control to get dynamic debug info

echo -n "file iam20680.c +p" > /sys/kernel/debug/dynamic_debug/control to enable all log
echo -n "file iam20680.c line 1863 +p" > /sys/kernel/debug/dynamic_debug/control to enable one log

echo -n "file iam20680.c line 1863 -p" > /sys/kernel/debug/dynamic_debug/control to disable one log

©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页