Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 1 | Qualcomm's QPNP PMIC current ADC driver |
| 2 | |
| 3 | QPNP PMIC current ADC (IADC) provides interface to clients to read |
| 4 | current. A 16 bit ADC is used for current measurements. There are multiple |
| 5 | peripherals to the IADC and the scope of the driver is to provide interface |
| 6 | for the USR peripheral of the IADC. |
| 7 | |
| 8 | IADC node |
| 9 | |
| 10 | Required properties: |
| 11 | - compatible : should be "qcom,qpnp-iadc" for Current ADC driver. |
Siddartha Mohanadoss | 18c4b9f | 2014-01-23 16:13:31 -0800 | [diff] [blame] | 12 | - reg : offset and length of the PMIC Arbiter register map. |
| 13 | - reg-names : resource names used for the physical base address of the PMIC IADC |
| 14 | peripheral, the SMBB_BAT_IF_TRIM_CNST_RDS register. |
| 15 | Should be "iadc-base" for the PMIC IADC peripheral base register. |
| 16 | Should be "batt-id-trim-cnst-rds" for reading the |
| 17 | SMBB_BAT_IF_TRIM_CNST_RDS register. |
Siddartha Mohanadoss | 96be0a0 | 2012-12-07 14:38:48 -0800 | [diff] [blame] | 18 | - address-cells : Must be one. |
| 19 | - size-cells : Must be zero. |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 20 | - interrupts : The USR bank peripheral IADC interrupt. |
Siddartha Mohanadoss | 1210995 | 2012-11-20 14:57:51 -0800 | [diff] [blame] | 21 | - interrupt-names : Should contain "eoc-int-en-set". |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 22 | - qcom,adc-bit-resolution : Bit resolution of the ADC. |
| 23 | - qcom,adc-vdd-reference : Voltage reference used by the ADC. |
Siddartha Mohanadoss | e70010b | 2013-04-04 14:51:41 -0700 | [diff] [blame] | 24 | |
| 25 | Optional properties: |
| 26 | - qcom,rsense : Use this property when external rsense should be used |
| 27 | for current calculation and specify the units in nano-ohms. |
Siddartha Mohanadoss | f82a6f2 | 2013-07-27 20:47:34 -0700 | [diff] [blame] | 28 | - qcom,iadc-poll-eoc: Use polling instead of interrupts for End of Conversion completion. |
Siddartha Mohanadoss | 18c4b9f | 2014-01-23 16:13:31 -0800 | [diff] [blame] | 29 | - qcom,use-default-rds-trim : Add this property to check if certain conditions are to be checked |
| 30 | reading the SMBB_BAT_IF_CNST_RDS, IADC_RDS trim register and |
| 31 | manufacturer type. Check the driver for conditions that each of the type. |
| 32 | 0 : Select this type to read the IADC and SMBB trim register and |
| 33 | apply the default RSENSE if conditions are met. |
| 34 | 1 : Select this type to read the IADC, SMBB trim register and |
| 35 | manufacturer type and apply the default RSENSE if conditions are met. |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 36 | |
| 37 | Channel node |
| 38 | NOTE: Atleast one Channel node is required. |
| 39 | |
Siddartha Mohanadoss | 55d0bca | 2013-06-24 08:29:34 -0700 | [diff] [blame] | 40 | Client required property: |
| 41 | - qcom,<consumer name>-iadc : The phandle to the corresponding iadc device. |
| 42 | The consumer name passed to the driver when calling |
| 43 | qpnp_get_iadc() is used to associate the client |
| 44 | with the corresponding device. |
| 45 | |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 46 | Required properties: |
| 47 | - label : Channel name used for sysfs entry. |
Siddartha Mohanadoss | 96be0a0 | 2012-12-07 14:38:48 -0800 | [diff] [blame] | 48 | - reg : AMUX channel number. |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 49 | - qcom,channel-num : Channel number associated to the AMUX input. |
| 50 | - qcom,decimation : Sampling rate to use for the individual channel measurement. |
| 51 | Select from the following unsigned int. |
| 52 | 0 : 512 |
| 53 | 1 : 1K |
| 54 | 2 : 2K |
| 55 | 3 : 4K |
| 56 | - qcom,pre-div-channel-scaling : Pre-div used for the channel before the signal |
| 57 | is being measured. |
| 58 | - qcom,calibration-type : Calibration point values vary with temperature. |
| 59 | For improved accuracy fresh gain and offset point values |
| 60 | can be used for calibration. Reading fresh values for ever |
| 61 | read affects the reading time. Application can use the historic |
| 62 | values used from the trim register values. |
| 63 | Select from the following strings. |
| 64 | "absolute" : Uses TRIM gain and offset values for calibration. |
| 65 | "ratiometric" : Calculate the gain and offset calibration value when an ADC |
| 66 | request is issued. |
| 67 | - qcom,scale-function : Scaling fuction used to convert raw ADC code to units specific to |
| 68 | a given channel. |
| 69 | Select from the following unsigned int. |
| 70 | 0 : Default scaling to convert raw adc code to voltage. |
| 71 | 1 : Conversion to temperature based on btm parameters. |
| 72 | 2 : Returns result in milli degree's Centigrade. |
| 73 | 3 : Returns current across 0.1 ohm resistor. |
| 74 | 4 : Returns XO thermistor voltage in degree's Centigrade. |
| 75 | - qcom,hw-settle-time : Settling period for the channel before ADC read. |
| 76 | Select from the following unsigned int. |
| 77 | 0 : 0us |
| 78 | 1 : 100us |
| 79 | 2 : 200us |
| 80 | 3 : 300us |
| 81 | 4 : 400us |
| 82 | 5 : 500us |
| 83 | 6 : 600us |
| 84 | 7 : 700us |
| 85 | 8 : 800us |
| 86 | 9 : 900us |
| 87 | 0xa : 1ms |
| 88 | 0xb : 2ms |
| 89 | 0xc : 4ms |
| 90 | 0xd : 6ms |
| 91 | 0xe : 8ms |
| 92 | 0xf : 10ms |
| 93 | - qcom,fast-avg-setup : Average number of samples to be used for measurement. Fast averaging |
| 94 | provides the option to obtain a single measurement from the ADC that |
| 95 | is an average of multiple samples. The value selected is 2^(value) |
| 96 | Select from the following unsigned int. |
| 97 | 0 : 1 |
| 98 | 1 : 2 |
| 99 | 2 : 4 |
| 100 | 3 : 8 |
| 101 | 4 : 16 |
| 102 | 5 : 32 |
| 103 | 6 : 64 |
| 104 | 7 : 128 |
| 105 | 8 : 256 |
Siddartha Mohanadoss | 3cb2b6b | 2013-06-21 12:07:05 -0700 | [diff] [blame] | 106 | - qcom,iadc-vadc : Corresponding phandle of the VADC device to read the die_temperature and set |
| 107 | simultaneous voltage and current conversion requests. |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 108 | |
| 109 | Example: |
| 110 | /* Main Node */ |
| 111 | qcom,iadc@3200 { |
| 112 | compatible = "qcom,qpnp-iadc"; |
| 113 | reg = <0x3200 0x100>; |
Siddartha Mohanadoss | 96be0a0 | 2012-12-07 14:38:48 -0800 | [diff] [blame] | 114 | #address-cells = <1>; |
| 115 | #size-cells = <0>; |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 116 | interrupts = <0 0x36 0>; |
Siddartha Mohanadoss | 1210995 | 2012-11-20 14:57:51 -0800 | [diff] [blame] | 117 | interrupt-names = "eoc-int-en-set"; |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 118 | qcom,adc-bit-resolution = <16>; |
| 119 | qcom,adc-vdd-reference = <1800>; |
| 120 | qcom,rsense = <1500>; |
Siddartha Mohanadoss | 3cb2b6b | 2013-06-21 12:07:05 -0700 | [diff] [blame] | 121 | qcom,iadc-vadc = <&pm8941_vadc>; |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 122 | |
| 123 | /* Channel Node */ |
| 124 | chan@0 = { |
| 125 | label = "rsense"; |
Siddartha Mohanadoss | 96be0a0 | 2012-12-07 14:38:48 -0800 | [diff] [blame] | 126 | reg = <0>; |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 127 | qcom,decimation = <0>; |
| 128 | qcom,pre-div-channel-scaling = <20>; |
| 129 | qcom,calibration-type = "fresh"; |
| 130 | qcom,scale-function = <0>; |
| 131 | qcom,hw-settle-time = <0>; |
| 132 | qcom,fast-avg-setup = <0>; |
| 133 | }; |
| 134 | }; |
Siddartha Mohanadoss | 55d0bca | 2013-06-24 08:29:34 -0700 | [diff] [blame] | 135 | |
| 136 | Client device example: |
| 137 | /* Add to the clients node that needs the IADC */ |
| 138 | client_node { |
| 139 | qcom,client-iadc = <&pm8941_iadc>; |
| 140 | }; |