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