Category: Software
Product Number: AD7606
我使用imx6cpu,内核版本是6.1.22,以下是设备树,7606b挂载在spi1上:
adc_vref: fixedregulator {
compatible = "regulator-fixed";
regulator-name = "adc_vref";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
// GPIO属性被移除,因为不需要通过GPIO控制电源
regulator-always-on;
};
&ecspi1 {
cs-gpios = <&gpio3 19 GPIO_ACTIVE_LOW>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi1>;
status = "okay";
ad7606@0 {
compatible = "adi,ad7606b";
reg = <0>;
spi-max-frequency = <1000000>;
spi-cpol;
// spi-cpha;
//busy 4 24
//reset 4 22
//adi,conversion-start-gpios 4 23
//adi,first-data-gpios 4 25
//interrupt 4 21
avcc-supply = <&adc_vref>; //很重要,电源的重写可以规避识别不了的问题
interrupts = <24 IRQ_TYPE_EDGE_FALLING>; //目前给的是busy信号
interrupt-parent = <&gpio4>;
adi,conversion-start-gpios = <&gpio4 23 GPIO_ACTIVE_HIGH>;
reset-gpios = <&gpio4 22 GPIO_ACTIVE_HIGH>;
adi,first-data-gpios = <&gpio4 25 GPIO_ACTIVE_HIGH>;
// adi,oversampling-ratio-gpios = <&gpio 18 GPIO_ACTIVE_HIGH
// &gpio 23 GPIO_ACTIVE_HIGH
// &gpio 26 GPIO_ACTIVE_HIGH>;
// standby-gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
adi,sw-mode;
// status = "okay";
};
};
目前使用的中断管教给的是busy信号,不知道会不会有影响
// adi,oversampling-ratio-gpios = <&gpio 18 GPIO_ACTIVE_HIGH
// &gpio 23 GPIO_ACTIVE_HIGH
// &gpio 26 GPIO_ACTIVE_HIGH>;
// standby-gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
这几个管教因为硬件直接上拉了,所以设置不了。
内核下打开7606的配置,目前可以在sys下看到设备:
root@imx6q-custom:~# cd /sys/bus/iio/devices/iio\:device0
root@imx6q-custom:/sys/bus/iio/devices/iio:device0# ls -l
drwxr-xr-x 2 root root 0 Mar 10 01:08 buffer
drwxr-xr-x 2 root root 0 Mar 10 01:08 buffer0
-rw-r--r-- 1 root root 4096 Mar 10 01:08 current_timestamp_clock
-r--r--r-- 1 root root 4096 Mar 10 01:08 dev
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage0_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage0_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage1_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage1_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage2_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage2_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage3_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage3_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage4_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage4_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage5_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage5_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage6_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage6_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage7_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage7_scale
-r--r--r-- 1 root root 4096 Mar 10 01:08 in_voltage_scale_available
-r--r--r-- 1 root root 4096 Mar 10 01:08 name
lrwxrwxrwx 1 root root 0 Mar 10 01:08 of_node -> ../../../../../../../../../../firmware/devicetree/base/soc/bus@2000000/spba-bus@2000000/spi@2008000/ad7606@0
-rw-r--r-- 1 root root 4096 Mar 10 01:08 oversampling_ratio
-r--r--r-- 1 root root 4096 Mar 10 01:08 oversampling_ratio_available
drwxr-xr-x 2 root root 0 Mar 10 01:08 power
drwxr-xr-x 2 root root 0 Mar 10 01:08 scan_elements
lrwxrwxrwx 1 root root 0 Mar 10 01:08 subsystem -> ../../../../../../../../../../bus/iio
drwxr-xr-x 2 root root 0 Mar 10 01:08 trigger
-rw-r--r-- 1 root root 4096 Mar 10 01:07 uevent
-r--r--r-- 1 root root 4096 Mar 10 01:08 waiting_for_supplier
root@imx6q-custom:/sys/bus/iio/devices/iio:device0# ls -l
drwxr-xr-x 2 root root 0 Mar 10 01:08 buffer
drwxr-xr-x 2 root root 0 Mar 10 01:08 buffer0
-rw-r--r-- 1 root root 4096 Mar 10 01:08 current_timestamp_clock
-r--r--r-- 1 root root 4096 Mar 10 01:08 dev
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage0_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage0_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage1_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage1_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage2_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage2_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage3_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage3_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage4_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage4_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage5_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage5_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage6_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage6_scale
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage7_raw
-rw-r--r-- 1 root root 4096 Mar 10 01:08 in_voltage7_scale
-r--r--r-- 1 root root 4096 Mar 10 01:08 in_voltage_scale_available
-r--r--r-- 1 root root 4096 Mar 10 01:08 name
lrwxrwxrwx 1 root root 0 Mar 10 01:08 of_node -> ../../../../../../../../../../firmware/devicetree/base/soc/bus@2000000/spba-bus@2000000/spi@2008000/ad7606@0
-rw-r--r-- 1 root root 4096 Mar 10 01:08 oversampling_ratio
-r--r--r-- 1 root root 4096 Mar 10 01:08 oversampling_ratio_available
drwxr-xr-x 2 root root 0 Mar 10 01:08 power
drwxr-xr-x 2 root root 0 Mar 10 01:08 scan_elements
lrwxrwxrwx 1 root root 0 Mar 10 01:08 subsystem -> ../../../../../../../../../../bus/iio
drwxr-xr-x 2 root root 0 Mar 10 01:08 trigger
-rw-r--r-- 1 root root 4096 Mar 10 01:07 uevent
-r--r--r-- 1 root root 4096 Mar 10 01:08 waiting_for_supplier
但是我根据官方的文档,打开通道报如下错误:
root@imx6q-custom:/sys/bus/iio/devices/iio:device0# cat in_voltage0_raw
cat: read error: Input/output error
cat: read error: Input/output error
请帮我分析下,是设备树还有问题吗,还是需要一些初始化才能成功