pwm-qpnp.txt 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. Qualcomm Technologies, Inc. QPNP PWM/LPG controller
  2. qpnp-pwm driver supports Pulse Width Module (PWM) functionality. PWM feature is
  3. used in range of applications such as varying Display brightness, LED dimming,
  4. etc. QTI PMICs have a physical device called Light Pulse Generator (LPG). In
  5. addition to support PWM functionality, the LPG module provides a rich set of
  6. user defined PWM pattern configurations, such as sawtooth, linear up, linear
  7. down, triangular patterns etc. The PWM patterns are used in applications such as
  8. charger driver where the driver uses these patterns to indicate various states
  9. of charging.
  10. Required device bindings:
  11. - compatible: should be "qcom,qpnp-pwm"
  12. - reg: Offset and length of the controller's LPG channel register.
  13. - reg-names: Name for the above register.
  14. "qpnp-lpg-channel-base" = physical base address of the
  15. controller's LPG channel register.
  16. - qcom,lpg-lut-size: LPG LUT size.
  17. - qcom,channel-id: channel Id for the PWM.
  18. - qcom,supported-sizes: Supported PWM sizes.
  19. Following three pwm sizes lists are supported by PWM/LPG controllers.
  20. <6>, <9>;
  21. <7>, <8>;
  22. <6>, <7>, <9>;
  23. - qcom,ramp-index: Ramp index in LUT ramp control register.
  24. Each LPG has an index in the LUT ramp control register.
  25. One exception is that, if LPG does not support LUT mode
  26. and supports only PWM mode then there is no need to
  27. provide the ramp-index.
  28. Optional device bindings:
  29. - qcom,force-pwm-size: For certain LPG channels, PWM size can be forced.
  30. Possible values 6, 7, 8 and 9.
  31. - qcom,channel-owner: A string value to supply owner information.
  32. - qcom,mode-select: 0 = PWM mode
  33. 1 = LPG mode
  34. - qcom,dtest-line: indicates which DTEST line to be configured for LPG
  35. or PWM output. For LPG subtypes, possible values are 1,
  36. 2, 3 and 4. For PWM subtype, possibe values are 1 and 2.
  37. - qcom,dtest-output: indicates the output configuration for DTEST line.
  38. For LPG subtypes, possible output values are:
  39. 0 = Disabled
  40. 1 = LPG output low
  41. 2 = LPG output high
  42. 3,4,5 = DTEST line specific configuration
  43. 6,7 = Not used
  44. For PWM subtype, possible output values are:
  45. 0 = Disabled
  46. 1 = pwm_out for DTEST1 or reserved
  47. 2 = pwm_out for DTEST2 or reserved
  48. 3 = Not used
  49. If this binding is specified along with the required bindings of PWM/LPG then
  50. in addition to configure PWM/LPG the qpnp-pwm driver also enables the feature
  51. at the probe time. In the case where the binding is not specified the qpnp-pwm
  52. driver does not enable the feature. Also, it is considered an error to specify
  53. a particular mode using this binding but not the respective feature subnode.
  54. All PWM devices support both PWM and LPG features within the same device.
  55. To support each feature, there are some required and optional bindings passed
  56. through device tree.
  57. The PWM device can enable one feature (either PWM or LPG) at any given time.
  58. Therefore, the qpnp-pwm driver applies the last PWM or LPG feature configuration
  59. and enables that feature.
  60. Required bindings to support PWM feature:
  61. - qcom,period: PWM period time in microseconds.
  62. - qcom,duty: PWM duty time in microseconds.
  63. - label: "pwm"
  64. Required bindings to support LPG feature:
  65. The following bindings are needed to configure LPG mode, where a list of
  66. duty cycle percentages is populated. The size of the list cannot exceed
  67. the size of the LPG look-up table.
  68. - reg: Offset and length of LPG look-up table (LUT). The LPG look-up table is a
  69. contiguous address space that is populated with PWM values.
  70. The size of PWM value is 9 bit and the size of each
  71. entry of the table is 8 bit. Thus, two entries are used
  72. to fill each PWM value. The lower entry is used for PWM
  73. LSB byte and higher entry is used for PWM MSB bit.
  74. - reg-names: Name for the above register.
  75. "qpnp-lpg-lut-base" = physical base address of LPG LUT.
  76. - qcom,period: PWM period time in microseconds.
  77. - qcom,duty-percents: List of entries for look-up table
  78. - cell-index: Index of look-up table that should be used to start
  79. filling up the duty-pct list. start-idx + size of list
  80. cannot exceed the size of look-up table.
  81. - label: "lpg"
  82. Optional bindings to support LPG feature:
  83. - qcom,ramp-step-duration: Time (in ms) to wait before loading next entry of LUT
  84. - qcom,lpg-lut-pause-hi: Time (in ms) to wait once pattern reaches to hi
  85. index.
  86. - qcom,lpg-lut-pause-lo: Time (in ms) to wait once pattern reaches to lo
  87. index.
  88. - qcom,lpg-lut-ramp-direction: 1 = Start the pattern from lo index to hi index.
  89. 0 = Start the pattern from hi index to lo index.
  90. - qcom,lpg-lut-pattern-repeat: 1 = Repeat the pattern after the pause once it
  91. reaches to last duty cycle.
  92. 0 = Do not repeat the pattern.
  93. - qcom,lpg-lut-ramp-toggle: 1 = Toggle the direction of the pattern.
  94. 0 = Do not toggle the direction.
  95. - qcom,lpg-lut-enable-pause-hi: 1 = Enable pause time at hi index.
  96. 0 = Disable pause time at hi index.
  97. - qcom,lpg-lut-enable-pause-lo: 1 = Enable pause time at lo index.
  98. 0 = Disable pause time at lo index.
  99. Example:
  100. qcom,spmi@fc4c0000 {
  101. #address-cells = <1>;
  102. #size-cells = <0>;
  103. qcom,pm8941@1 {
  104. spmi-slave-container;
  105. reg = <0x1>;
  106. #address-cells = <1>;
  107. #size-cells = <1>;
  108. pwm@b100 {
  109. #address-cells = <1>;
  110. #size-cells = <1>;
  111. compatible = "qcom,qpnp-pwm";
  112. reg = <0xb100 0x100>, <0xb040 0x80>;
  113. reg-names = "qpnp-lpg-channel-base", "qpnp-lpg-lut-base";
  114. qcom,channel-id = <0>;
  115. qcom,supported-sizes = <6>, <7>, <9>;
  116. qcom,ramp-index = <0>;
  117. status = "okay";
  118. };
  119. pwm@b200 {
  120. #address-cells = <1>;
  121. #size-cells = <1>;
  122. compatible = "qcom,qpnp-pwm";
  123. reg = <0xb200 0x100>, <0xb040 0x80>;
  124. reg-names = "qpnp-lpg-channel-base", "qpnp-lpg-lut-base";
  125. qcom,channel-id = <1>;
  126. qcom,supported-sizes = <6>, <7>, <9>;
  127. qcom,ramp-index = <1>;
  128. qcom,force-pwm-size = <9>;
  129. qcom,period = <6000000>;
  130. status = "okay";
  131. qcom,pwm {
  132. qcom,duty = <4000000>;
  133. label = "pwm";
  134. };
  135. };
  136. pwm@b500 {
  137. #address-cells = <1>;
  138. #size-cells = <1>;
  139. compatible = "qcom,qpnp-pwm"
  140. reg = <0xb500 0x100>, <0xb040 0x80>;
  141. reg-names = "qpnp-lpg-channel-base", "qpnp-lpg-lut-base";
  142. qcom,channel-id = <4>;
  143. qcom,supported-sizes = <6>, <7>, <9>;
  144. qcom,ramp-index = <4>;
  145. qcom,period = <6000000>;
  146. qcom,mode-select = <0>;
  147. qcom,channel-owner = "RGB-led";
  148. status = "okay";
  149. qcom,pwm {
  150. qcom,duty = <4000000>;
  151. label = "pwm";
  152. };
  153. qcom,lpg {
  154. qcom,duty-percents = <1 14 28 42 56 84 100
  155. 100 84 56 42 28 14 1>;
  156. cell-index = <0>;
  157. qcom,ramp-step-duration = <20>;
  158. label = "lpg";
  159. };
  160. };
  161. pwm@b300 {
  162. #address-cells = <1>;
  163. #size-cells = <1>;
  164. compatible = "qcom,qpnp-pwm";
  165. reg = <0xb200 0x100>, <0xb040 0x80>;
  166. reg-names = "qpnp-lpg-channel-base", "qpnp-lpg-lut-base";
  167. qcom,channel-id = <2>;
  168. qcom,supported-sizes = <6>, <7>, <9>;
  169. qcom,ramp-index = <1>;
  170. qcom,force-pwm-size = <9>;
  171. qcom,period = <6000000>;
  172. qcom,dtest-line = <3>;
  173. qcom,dtest-output = <1>;
  174. status = "okay";
  175. qcom,pwm {
  176. qcom,duty = <4000000>;
  177. label = "pwm";
  178. };
  179. };
  180. };
  181. };
  182. There are couple of ways to configure PWM device channels as shown in above
  183. example,
  184. 1. The PWM device channel #0 is configured with only required device bindings.
  185. In this case, the qpnp-pwm driver does not configure any mode by default.
  186. 2. The qpnp-pwm driver configures PWM device channel #1 with PWM feature
  187. configuration, but does not enable the channel since "qcom,mode-select" binding
  188. is not specified in the devicetree.
  189. 3. Both the PWM and LPG configurations are provided for PWM device channel #4.
  190. The qpnp-pwm driver configures both the modes, but enables PWM mode at the probe
  191. time. It also sets the channel owner information for the channel.
  192. 4. This configuration is pretty similar to #2 above except in this case channel
  193. #3 is configured for PWM mode. Also it's DTEST3 line is configured to output
  194. LPG OUT low.