xref: /freebsd/sys/contrib/device-tree/Bindings/pwm/pwm.txt (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
1*c66ec88fSEmmanuel VadotSpecifying PWM information for devices
2*c66ec88fSEmmanuel Vadot======================================
3*c66ec88fSEmmanuel Vadot
4*c66ec88fSEmmanuel Vadot1) PWM user nodes
5*c66ec88fSEmmanuel Vadot-----------------
6*c66ec88fSEmmanuel Vadot
7*c66ec88fSEmmanuel VadotPWM users should specify a list of PWM devices that they want to use
8*c66ec88fSEmmanuel Vadotwith a property containing a 'pwm-list':
9*c66ec88fSEmmanuel Vadot
10*c66ec88fSEmmanuel Vadot	pwm-list ::= <single-pwm> [pwm-list]
11*c66ec88fSEmmanuel Vadot	single-pwm ::= <pwm-phandle> <pwm-specifier>
12*c66ec88fSEmmanuel Vadot	pwm-phandle : phandle to PWM controller node
13*c66ec88fSEmmanuel Vadot	pwm-specifier : array of #pwm-cells specifying the given PWM
14*c66ec88fSEmmanuel Vadot			(controller specific)
15*c66ec88fSEmmanuel Vadot
16*c66ec88fSEmmanuel VadotPWM properties should be named "pwms". The exact meaning of each pwms
17*c66ec88fSEmmanuel Vadotproperty must be documented in the device tree binding for each device.
18*c66ec88fSEmmanuel VadotAn optional property "pwm-names" may contain a list of strings to label
19*c66ec88fSEmmanuel Vadoteach of the PWM devices listed in the "pwms" property. If no "pwm-names"
20*c66ec88fSEmmanuel Vadotproperty is given, the name of the user node will be used as fallback.
21*c66ec88fSEmmanuel Vadot
22*c66ec88fSEmmanuel VadotDrivers for devices that use more than a single PWM device can use the
23*c66ec88fSEmmanuel Vadot"pwm-names" property to map the name of the PWM device requested by the
24*c66ec88fSEmmanuel Vadotpwm_get() call to an index into the list given by the "pwms" property.
25*c66ec88fSEmmanuel Vadot
26*c66ec88fSEmmanuel VadotThe following example could be used to describe a PWM-based backlight
27*c66ec88fSEmmanuel Vadotdevice:
28*c66ec88fSEmmanuel Vadot
29*c66ec88fSEmmanuel Vadot	pwm: pwm {
30*c66ec88fSEmmanuel Vadot		#pwm-cells = <2>;
31*c66ec88fSEmmanuel Vadot	};
32*c66ec88fSEmmanuel Vadot
33*c66ec88fSEmmanuel Vadot	[...]
34*c66ec88fSEmmanuel Vadot
35*c66ec88fSEmmanuel Vadot	bl: backlight {
36*c66ec88fSEmmanuel Vadot		pwms = <&pwm 0 5000000>;
37*c66ec88fSEmmanuel Vadot		pwm-names = "backlight";
38*c66ec88fSEmmanuel Vadot	};
39*c66ec88fSEmmanuel Vadot
40*c66ec88fSEmmanuel VadotNote that in the example above, specifying the "pwm-names" is redundant
41*c66ec88fSEmmanuel Vadotbecause the name "backlight" would be used as fallback anyway.
42*c66ec88fSEmmanuel Vadot
43*c66ec88fSEmmanuel Vadotpwm-specifier typically encodes the chip-relative PWM number and the PWM
44*c66ec88fSEmmanuel Vadotperiod in nanoseconds.
45*c66ec88fSEmmanuel Vadot
46*c66ec88fSEmmanuel VadotOptionally, the pwm-specifier can encode a number of flags (defined in
47*c66ec88fSEmmanuel Vadot<dt-bindings/pwm/pwm.h>) in a third cell:
48*c66ec88fSEmmanuel Vadot- PWM_POLARITY_INVERTED: invert the PWM signal polarity
49*c66ec88fSEmmanuel Vadot
50*c66ec88fSEmmanuel VadotExample with optional PWM specifier for inverse polarity
51*c66ec88fSEmmanuel Vadot
52*c66ec88fSEmmanuel Vadot	bl: backlight {
53*c66ec88fSEmmanuel Vadot		pwms = <&pwm 0 5000000 PWM_POLARITY_INVERTED>;
54*c66ec88fSEmmanuel Vadot		pwm-names = "backlight";
55*c66ec88fSEmmanuel Vadot	};
56*c66ec88fSEmmanuel Vadot
57*c66ec88fSEmmanuel Vadot2) PWM controller nodes
58*c66ec88fSEmmanuel Vadot-----------------------
59*c66ec88fSEmmanuel Vadot
60*c66ec88fSEmmanuel VadotSee pwm.yaml.
61