Configure MPP2 to get current(I) value




We need to monitor current from current limit switch. Hence, we need to configure mpp2 as analog input.

Please suggest how can we configure mpp2 to get current’s value.

Note: We are working on Linaro_18.01 (Linux).



Obviously we cannot test this on DB410C (where MPP2 is routed to an LED) and we don’t even compile all the neccessary drivers by default so you will have to fill in the fine detail and test yourself but I think there are likely to be three steps involved:

  1. Set up the pinctrl correctly to configure MPP2 as an analog input. The compatible string you need to look for in DT is qcom,pm8916-mpp (+ qcom,spmi-mpp). The PM8916 HRM is unclear about what the correct amux-route is (the MPP documentation claims to control the routing, the VADC documentation suggests the routing is fixed). So perhaps try PMIC_MPP_AMUX_ROUTE_CH6 to start with but try other values if you have problems.
  2. Set up the vadc correctly to ensure the ADC presents the MPP2 reading via the IIO sysfs files. The compatible string to look for is qcom,spmi-vadc. Again the documenation is unclear but it looks like MPP2 is available with scaling 1/1
    on ADC channel 17 and 1/3 on channel 33 so try enabling these channels first (add an additional subnode to &pm8916_vadc with reg set appropriately).
  3. The VADC driver is not enabled by default in the DB410C kernels. It must be enabled using CONFIG_QCOM_SPMI_VADC .

Enable/disable charging from PMIC
Pm8916 mpp analog configuration