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