qpnp-adc-tm.txt 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. Qualcomm Technologies, Inc. QPNP PMIC thermal monitor ADC driver (VADC_TM)
  2. QPNP PMIC thermal monitoring (TM) provides interface to thermal clients
  3. to set temperature thresholds and receive notification when the thresholds
  4. are crossed. A 15 bit ADC is used for measurements. The driver is part
  5. of the sysfs thermal framework that provides support to read the trip
  6. points, set threshold for the trip points and enable the trip points.
  7. Separat kernel api's are provided to usb_id and batt_therm
  8. to set thresholds and receive threshold notifications.
  9. VADC_TM node
  10. Required properties:
  11. - compatible : should be "qcom,qpnp-adc-tm-hc" for thermal ADC driver using
  12. refreshed BTM peripheral.
  13. should include "qcom,qpnp-adc-tm-hc-pm5" for PMIC5.
  14. - reg : offset and length of the PMIC Aribter register map.
  15. - address-cells : Must be one.
  16. - size-cells : Must be zero.
  17. - interrupts : The thermal ADC bank peripheral interrupts for eoc, high and low interrupts.
  18. - interrupt-names : Should be "eoc-int-en-set", "high-thr-en-set" and "low-thr-en-set"
  19. for qcom,qpnp-adc-tm type.
  20. : Should be "eoc-int-en-set" for qcom,qpnp-adc-tm-hc type.
  21. - qcom,adc-bit-resolution : Bit resolution of the ADC.
  22. - qcom,adc-vdd-reference : Voltage reference used by the ADC.
  23. The following properties are required in the main node for qcom,qpnp-adc-tm-hc peripheral.
  24. - qcom,decimation : Should be present for qcom,qpnp-adc-tm-hc peripheral as its common setting
  25. across all the channels. Sampling rate to use for all the channel measurements.
  26. Select from the following unsigned int.
  27. 0 : 512
  28. 1 : 1K
  29. 2 : 2K
  30. 3 : 4K
  31. - qcom,fast-avg-setup : Should be present for qcom,qpnp-adc-tm-hc peripheral as its common setting
  32. across all the channels. Average number of samples to be used for measurement.
  33. Fast averaging provides the option to obtain a single measurement from the ADC
  34. that is an average of multiple samples. The value selected is 2^(value)
  35. Select from the following unsigned int.
  36. 0 : 1
  37. 1 : 2
  38. 2 : 4
  39. 3 : 8
  40. 4 : 16
  41. 5 : 32
  42. 6 : 64
  43. 7 : 128
  44. 8 : 256
  45. Optional properties:
  46. - qcom,thermal-node : If present a thermal node is created and the channel is registered as
  47. part of the thermal sysfs which allows clients to use the thermal framework
  48. to set temperature thresholds and receive notification when the temperature
  49. crosses a set threshold, read temperature and enable/set trip types supported
  50. by the thermal framework.
  51. - qcom,meas-interval-timer-idx: If present select from the following timer index to choose
  52. a preset configurable measurement interval timer value. The driver defaults
  53. to timer 2 with a measurement interval of 1 second if the property is not present.
  54. 0 : Select Timer 1 for a measurement polling interval of 3.9 milliseconds.
  55. 1 : Select Timer 2 for a measurement polling interval of 1 second.
  56. 2 : Select Timer 3 for a measurement polling interval of 4 seconds.
  57. - qcom,adc-tm-recalib-check: Add this property to check if recalibration required due to inaccuracy.
  58. - hkadc_ldo-supply : Add this property if VADC needs to perform a Software Vote for the HKADC.
  59. - hkadc_ok-supply : Add this property if the VADC needs to perform a Software vote for the HKADC VREG_OK.
  60. - #thermal-sensor-cells : To register ADC sensors with of_thermal. Should be 1.
  61. See ./thermal.txt for a description.
  62. Client required property:
  63. - qcom,<consumer name>-adc_tm : The phandle to the corresponding adc_tm device.
  64. The consumer name passed to the driver when calling
  65. qpnp_get_adc_tm() is used to associate the client
  66. with the corresponding device.
  67. Channel nodes
  68. NOTE: Atleast one Channel node is required.
  69. Required properties:
  70. - label : Channel name used for sysfs entry.
  71. - reg : AMUX channel number.
  72. - qcom,decimation : Sampling rate to use for the individual channel measurement.
  73. Select from the following unsigned int.
  74. 0 : 512
  75. 1 : 1K
  76. 2 : 2K
  77. 3 : 4K
  78. Note: This property is not required in the channel node in qcom,qpnp-adc-tm-hc
  79. peripheral.
  80. - qcom,pre-div-channel-scaling : Pre-div used for the channel before the signal is being measured.
  81. Select from the following unsigned int for the corresponding
  82. numerator/denominator pre-div ratio.
  83. 0 : pre-div ratio of {1, 1}
  84. 1 : pre-div ratio of {1, 3}
  85. 2 : pre-div ratio of {1, 4}
  86. 3 : pre-div ratio of {1, 6}
  87. 4 : pre-div ratio of {1, 20}
  88. 5 : pre-div ratio of {1, 8}
  89. 6 : pre-div ratio of {10, 81}
  90. 7 : pre-div ratio of {1, 10}
  91. - qcom,calibration-type : Reference voltage to use for channel calibration.
  92. Channel calibration is dependendent on the channel.
  93. Certain channels like XO_THERM, BATT_THERM use ratiometric
  94. calibration. Most other channels fall under absolute calibration.
  95. Select from the following strings.
  96. "absolute" : Uses the 625mv and 1.25V reference channels.
  97. "ratiometric" : Uses the reference Voltage/GND for calibration.
  98. - qcom,scale-function : Reverse scaling function used to convert raw ADC code to units specific to
  99. a given channel.
  100. Select from the following unsigned int.
  101. 0 : Scaling to convert voltage in uV to raw adc code.
  102. 1 : Scaling to convert decidegC to raw adc code.
  103. 2 : Scaling for converting USB_ID reverse scaling.
  104. 3 : Scaling to convert milldegC to raw ADC code.
  105. 4 : Scaling to convert smb_batt_therm values to raw ADC code.
  106. 5 : Scaling to perform reverse calibration for absolute voltage from uV
  107. to raw ADC code.
  108. 6 : Scaling to convert qrd skuh battery decidegC to raw ADC code.
  109. - qcom,hw-settle-time : Settling period for the channel before ADC read.
  110. Select from the following unsigned int.
  111. 0 : 0us
  112. 1 : 100us
  113. 2 : 200us
  114. 3 : 300us
  115. 4 : 400us
  116. 5 : 500us
  117. 6 : 600us
  118. 7 : 700us
  119. 8 : 800us
  120. 9 : 900us
  121. 0xa : 1ms
  122. 0xb : 2ms
  123. 0xc : 4ms
  124. 0xd : 6ms
  125. 0xe : 8ms
  126. 0xf : 10ms
  127. - qcom,fast-avg-setup : Average number of samples to be used for measurement. Fast averaging
  128. provides the option to obtain a single measurement from the ADC that
  129. is an average of multiple samples. The value selected is 2^(value)
  130. Select from
  131. 0 : 1
  132. 1 : 2
  133. 2 : 4
  134. 3 : 8
  135. 4 : 16
  136. 5 : 32
  137. 6 : 64
  138. 7 : 128
  139. 8 : 256
  140. Note: This property is not required in the channel node in
  141. qcom,qpnp-adc-tm-hc peripheral.
  142. - qcom,btm-channel-number : Depending on the PMIC version, a max of upto 8 BTM channels.
  143. The BTM channel numbers are statically allocated to the
  144. corresponding channel node.
  145. - qcom,adc_tm-vadc : phandle to the corresponding VADC device to read the ADC channels.
  146. Client device example:
  147. /* Add to the clients node that needs the ADC_TM channel A/D */
  148. client_node {
  149. qcom,client-adc_tm = <&pm8941_adc_tm>;
  150. };
  151. Example for "qcom,qpnp-adc-tm-hc" device:
  152. /* Main Node */
  153. pm8998_adc_tm: vadc@3400 {
  154. compatible = "qcom,qpnp-adc-tm-hc";
  155. reg = <0x3400 0x100>;
  156. #address-cells = <1>;
  157. #size-cells = <0>;
  158. interrupts = <0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
  159. interrupt-names = "eoc-int-en-set";
  160. qcom,adc-bit-resolution = <15>;
  161. qcom,adc-vdd-reference = <1875>;
  162. qcom,adc_tm-vadc = <&pm8998_vadc>;
  163. qcom,decimation = <0>;
  164. qcom,fast-avg-setup = <0>;
  165. /* Channel Node to be registered as part of thermal sysfs */
  166. chan@b5 {
  167. label = "msm_therm";
  168. reg = <0xb5>;
  169. qcom,pre-div-channel-scaling = <0>;
  170. qcom,calibration-type = "absolute";
  171. qcom,scale-function = <2>;
  172. qcom,hw-settle-time = <0>;
  173. qcom,btm-channel-number = <0x70>;
  174. qcom,thermal-node;
  175. };
  176. /* Channel Node */
  177. chan@6 {
  178. label = "vbat_sns";
  179. reg = <6>;
  180. qcom,pre-div-channel-scaling = <1>;
  181. qcom,calibration-type = "absolute";
  182. qcom,scale-function = <3>;
  183. qcom,hw-settle-time = <0>;
  184. qcom,btm-channel-number = <0x78>;
  185. };
  186. };
  187. /* Example to register thermal sensor using of_thermal */
  188. &thermal_zones {
  189. msm-therm-adc {
  190. polling-delay-passive = <0>;
  191. polling-delay = <0>;
  192. thermal-sensors = <&pm8998_adc_tm 0xb5>;
  193. thermal-governor = "user_space";
  194. trips {
  195. active-config0 {
  196. temperature = <65000>;
  197. hysteresis = <1000>;
  198. type = "passive";
  199. };
  200. };
  201. };
  202. };