^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) Specifying PWM information for devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) ======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) 1) PWM user nodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) PWM users should specify a list of PWM devices that they want to use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) with a property containing a 'pwm-list':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) pwm-list ::= <single-pwm> [pwm-list]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) single-pwm ::= <pwm-phandle> <pwm-specifier>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) pwm-phandle : phandle to PWM controller node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) pwm-specifier : array of #pwm-cells specifying the given PWM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) (controller specific)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) PWM properties should be named "pwms". The exact meaning of each pwms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) property must be documented in the device tree binding for each device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) An optional property "pwm-names" may contain a list of strings to label
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) each of the PWM devices listed in the "pwms" property. If no "pwm-names"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) property is given, the name of the user node will be used as fallback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) Drivers for devices that use more than a single PWM device can use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) "pwm-names" property to map the name of the PWM device requested by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) pwm_get() call to an index into the list given by the "pwms" property.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) The following example could be used to describe a PWM-based backlight
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) pwm: pwm {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #pwm-cells = <2>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) [...]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) bl: backlight {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) pwms = <&pwm 0 5000000>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) pwm-names = "backlight";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) Note that in the example above, specifying the "pwm-names" is redundant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) because the name "backlight" would be used as fallback anyway.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) pwm-specifier typically encodes the chip-relative PWM number and the PWM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) period in nanoseconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) Optionally, the pwm-specifier can encode a number of flags (defined in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) <dt-bindings/pwm/pwm.h>) in a third cell:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) - PWM_POLARITY_INVERTED: invert the PWM signal polarity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) Example with optional PWM specifier for inverse polarity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) bl: backlight {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) pwms = <&pwm 0 5000000 PWM_POLARITY_INVERTED>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) pwm-names = "backlight";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 2) PWM controller nodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) See pwm.yaml.