最开始尝试在安卓下直接配置,可以看到可以出测试节点,但是会出现测试失败。
--- a/arch/arm64/configs/vendor/autogvm_QGKI.config
+++ b/arch/arm64/configs/vendor/autogvm_QGKI.config
@@ -159,3 +159,7 @@ CONFIG_CHSC5XXX_TOUCHPANEL_DRIVER=m
#add for ghk
CONFIG_NET_VENDOR_RTL8125=m
CONFIG_ETHERNET=y
+
+#add for smic
+CONFIG_QCOM_SPMI_ADC5=y
diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c
index 5c671b017c17..24eef3ff098b 100644
--- a/drivers/iio/adc/qcom-spmi-adc5.c
+++ b/drivers/iio/adc/qcom-spmi-adc5.c@@ -971,26 +988,78 @@ static const struct adc5_channels adc5_chans_pmic[ADC5_MAX_CHANNEL] = {
SCALE_HW_CALIB_BATT_THERM_400K)
[ADC5_BAT_ID_100K_PU] = ADC5_CHAN_TEMP("bat_id", 0,
SCALE_HW_CALIB_DEFAULT)
- [ADC5_AMUX_THM1_100K_PU] = ADC5_CHAN_TEMP("amux_thm1_100k_pu", 0,
- SCALE_HW_CALIB_THERM_100K_PULLUP)
- [ADC5_AMUX_THM2_100K_PU] = ADC5_CHAN_TEMP("amux_thm2_100k_pu", 0,
- SCALE_HW_CALIB_THERM_100K_PULLUP)
+ //[ADC5_AMUX_THM1_100K_PU] = ADC5_CHAN_TEMP("amux_thm1_100k_pu", 0, SCALE_HW_CALIB_THERM_100K_PULLUP)
+ [ADC5_AMUX_THM1] = ADC5_CHAN_VOLT("amux_thm1", 0, SCALE_HW_CALIB_DEFAULT)
+ //[ADC5_AMUX_THM2_100K_PU] = ADC5_CHAN_TEMP("amux_thm2_100k_pu", 0, SCALE_HW_CALIB_THERM_100K_PULLUP)
+ [ADC5_AMUX_THM2] = ADC5_CHAN_VOLT("amux_thm2", 0, SCALE_HW_CALIB_DEFAULT)
[ADC5_AMUX_THM3_100K_PU] = ADC5_CHAN_TEMP("amux_thm3_100k_pu", 0,
SCALE_HW_CALIB_THERM_100K_PULLUP)
[ADC5_AMUX_THM4_100K_PU] = ADC5_CHAN_TEMP("amux_thm4_100k_pu", 0,
SCALE_HW_CALIB_THERM_100K_PULLUP)
- [ADC5_AMUX_THM2] = ADC5_CHAN_TEMP("amux_thm2", 0,
- SCALE_HW_CALIB_PM5_SMB_TEMP)
+ //[ADC5_AMUX_THM2] = ADC5_CHAN_TEMP("amux_thm2", 0, SCALE_HW_CALIB_PM5_SMB_TEMP)
[ADC5_PARALLEL_ISENSE] = ADC5_CHAN_VOLT("parallel_isense", 0,
SCALE_HW_CALIB_PM5_CUR)
- [ADC5_GPIO1_100K_PU] = ADC5_CHAN_TEMP("gpio1_100k_pu", 0,
- SCALE_HW_CALIB_THERM_100K_PULLUP)
+ //[ADC5_GPIO1_100K_PU] = ADC5_CHAN_TEMP("gpio1_100k_pu", 0, SCALE_HW_CALIB_THERM_100K_PULLUP)
+ [ADC5_GPIO1] = ADC5_CHAN_VOLT("gpio1", 0, SCALE_HW_CALIB_DEFAULT)
[ADC5_GPIO2_100K_PU] = ADC5_CHAN_TEMP("gpio2_100k_pu", 0,
SCALE_HW_CALIB_THERM_100K_PULLUP)
[ADC5_GPIO3_100K_PU] = ADC5_CHAN_TEMP("gpio3_100k_pu", 0,
SCALE_HW_CALIB_THERM_100K_PULLUP)
- [ADC5_GPIO4_100K_PU] = ADC5_CHAN_TEMP("gpio4_100k_pu", 0,
+ //[ADC5_GPIO4_100K_PU] = ADC5_CHAN_TEMP("gpio4_100k_pu", 0, SCALE_HW_CALIB_THERM_100K_PULLUP)
+ [ADC5_GPIO4] = ADC5_CHAN_VOLT("gpio4", 0, SCALE_HW_CALIB_DEFAULT)
+};
--- a/devicetree/qcom/pm8150-vm.dtsi
+++ b/devicetree/qcom/pm8150-vm.dtsi
@@ -18,6 +18,61 @@
interrupt-controller;
#interrupt-cells = <2>;
};
+ pm8150_vadc: vadc@3100 {
+ compatible = "qcom,spmi-adc5";
+ reg = <0x3100>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ interrupts = <0x0 0x31 0x0 IRQ_TYPE_EDGE_RISING>;
+ interrupt-names = "eoc-int-en-set";
+ #io-channel-cells = <1>;
+ io-channel-ranges;
+
+ /* Channel node */
+ pm8150_amux1_vol {
+ reg = <ADC5_AMUX_THM1>;//0x0d
+ label = "pm8150_amux1_vol";
+ qcom,pre-scaling = <1 1>;
+ };
+ pm8150_amux2_vol {
+ reg = <ADC5_AMUX_THM2>;//0x0e
+ label = "pm8150_amux2_vol";
+ qcom,pre-scaling = <1 1>;
+ };
+ pm8150_gpio2_vol {
+ reg = <ADC5_GPIO4>;//0x15
+ label = "pm8150_gpio2_vol";
+ qcom,pre-scaling = <1 1>;
+ };
+ pm8150_gpio3_vol {
+ reg = <ADC5_GPIO1>;//0x12
+ label = "pm8150_gpio3_vol";
+ qcom,pre-scaling = <1 1>;
+ };
+ };
};
以上代码修改后,可以出测试节点如下:
cat /sys/bus/spmi/devices/spmi0-00/1c800000.virtio-spmi:qcom,pm8150@0:vadc@3100/iio:device0/in_voltage_PMIC_GPIPO2_input
cat /sys/bus/spmi/devices/spmi0-00/1c800000.virtio-spmi:qcom,pm8150@0:vadc@3100/iio:device0/in_voltage_PMIC_GPIPO3_input
cat /sys/bus/spmi/devices/spmi0-00/1c800000.virtio-spmi:qcom,pm8150@0:vadc@3100/iio:device0/in_voltage_PMIC_THERM1_input
cat /sys/bus/spmi/devices/spmi0-00/1c800000.virtio-spmi:qcom,pm8150@0:vadc@3100/iio:device0/in_voltage_PMIC_THERM2_input
但是实测会有以下问题:
读adc节点时报错:
[ 174.157064] qcom-spmi-adc5>>>adc5_read: adc read to register 0x42 of length:6 succeed, ret=0
[ 174.157352] qcom-spmi-adc5>>>adc5_write: adc write to register 0x42 of length:6 failed, ret=1
[ 174.157499] ADC configure failed with 1
[ 174.157665] qcom-spmi-adc5>>>adc5_read: adc read to register 0x42 of length:6 succeed, ret=0
[ 174.157891] qcom-spmi-adc5>>>adc5_write: adc write to register 0x42 of length:6 failed, ret=1
[ 174.158080] ADC configure failed with 1
[ 174.158262] qcom-spmi-adc5>>>adc5_read: adc read to register 0x42 of length:6 succeed, ret=0
[ 174.158485] qcom-spmi-adc5>>>adc5_write: adc write to register 0x42 of length:6 failed, ret=1
[ 174.158648] ADC configure failed with 1
[ 174.158850] qcom-spmi-adc5>>>adc5_read: adc read to register 0x42 of length:6 succeed, ret=0
[ 174.159099] qcom-spmi-adc5>>>adc5_write: adc write to register 0x42 of length:6 failed, ret=1
[ 174.159384] ADC configure failed with 1
另外cat /d/gpio看到引脚状态也不符合预设配置:
gpiochip1: GPIOs 326-335, parent: platform/1c800000.virtio-spmi:qcom,pm8150@0:pinctrl@c000, 1c800000.virtio-spmi:qcom,pm8150@0:pinctrl@c000:
gpio1 : in low normal vin-0 pull-down 10uA push-pull high atest-1 dtest-0
gpio2 : ---
gpio3 : in low normal vin-0 no pull push-pull high atest-1 dtest-0
gpio4 : in low normal vin-0 pull-up 1.5uA push-pull high atest-1 dtest-0
gpio5 : ---
gpio6 : in low normal vin-0 pull-down 10uA push-pull high atest-1 dtest-0
gpio7 : ---
gpio8 : ---
gpio9 : out high normal vin-1 no pull push-pull low atest-1 dtest-0
gpio10: in low normal vin-0 pull-down 10uA push-pull high atest-1 dtest-0
后续更新QNX下adc配置调试记录