5.1 Detection principle
– Using i2c connection and device information to detect the different
device.
– If using one i2c address to connect device fail, then don’t choose this
device.
– When i2c connection is success, then read the device information. If the
information is right, then choose this device. Otherwise, don’t choose it.
5.2 There use accelerometer as example
Step 1:
– The first sensor driver do not need change.
– It still use DCT to configure the first sensor’s i2c address.
Step 2:
– Modify the second sensor driver.
Step 3:
– Configure the second sensor’s i2c address in $(project).dts
Step 4:
– Configure the customization parameter for second sensor in $(project).dts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | cust_accel@0 { compatible = "mediatek,icm20645g"; i2c_num = <1>; i2c_addr = <0x68 0 0 0>; direction = <3>; power_id = <0xffff>; power_vol = <0>; firlen = <0>; is_batch_supported = <0>; }; cust_alsps@0 { compatible = "mediatek,cm36558"; i2c_num = <1>; i2c_addr = <0x51 0 0 0>; polling_mode_ps = <0>; polling_mode_als = <1>; power_id = <0xffff>; power_vol = <0>; als_level = <0 328 861 1377 3125 7721 7767 12621 23062 28430 33274 47116 57694 57694 65535>; als_value = <0 133 304 502 1004 2005 3058 5005 8008 10010 12000 16000 20000 20000 20000 20000>; ps_threshold_high = <26>; ps_threshold_low = <21>; is_batch_supported_ps = <0>; is_batch_supported_als = <0>; }; |