pwm: pxa: add device tree support to pwm driver
Subsystems (2)
PATCH RESEND v2 1/1 pwm: pxa: add device tree support to pwm driver
This patch adds device tree support to the pxa's pwm driver. Only an OF match table is added; nothing needs to be extracted from the device tree node. The existing platform_device id table is reused for the match table data. Support for inverted polarity is also added.
Tested on a Palm Treo 680 (both platform data and DT cases).
---
Changle log:
Resent with expanded Cc list
v2:
- of_match_table contains only the "pxa250-pwm" compatible string; require one device instance per pwm
- add Documentation/devicetree/bindings/pwm/pxa-pwm.txt
- add support for polarity flag in DT and implement set_polarity() method (the treo 680 inverts the signal between pwm out and backlight)
- return -EINVAL instead of -ENODEV if platform data or DT node not found
- output dev_info string if platform data missing
- expanded CC list of patch
Documentation/devicetree/bindings/pwm/pxa-pwm.txt | 33 +++++++++++++ arch/arm/boot/dts/pxa27x.dtsi | 24 ++++++++++ drivers/pwm/pwm-pxa.c | 57 +++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pxa-pwm.txt
Documentation/devicetree/bindings/pwm/pxa-pwm.txt new file +33 -0
@@ -0,0 +1,33 @@ +Marvell pwm controller + +Required properties: +- compatible: + for pxa25x, pxa27x, pxa168, pxa910: must be compatible = "marvell,pxa250-pwm"; +- reg: physical base address and length of the registers used by the pwm channel + NB: One device instance must be created for each pwm that is used, so the + length covers only the register window for one pwm output, not that of the + entire pwm controller. Currently length is 0x10 for all supported devices. +- #pwm-cells: should be 3. + cell 1: the per-chip index of the PWM to use, + cell 2: the period in nanoseconds, + cell 3: flags; set bit 0 to specify inverse polarity. The pwm controller + does not implement reverse polarity, but some boards may pass the pwm output + through an external inverter, which can cause problems if a client device + assumes that an increase in the duty cycle results in an increase in output + power. The pwm-backlight is an example of such a client. + +Example pwm device node: + +pwm0: pwm at 40b00000 { + compatible = "marvell,pxa250-pwm"; + reg = <0x40b00000 0x10>; + #pwm-cells = <3>; +}; + +Example pwm client node: + +backlight { + compatible = "pwm-backlight"; + pwms = <&pwm0 0 5000000 1>; /* pwm output is inverted */ + ... +}
arch/arm/boot/dts/pxa27x.dtsi +24 -0
@@ -10,5 +10,29 @@ marvell,intc-priority; marvell,intc-nr-irqs = <34>; }; + + pwm0: pwm at 40b00000 { + compatible = "marvell,pxa250-pwm"; + reg = <0x40b00000 0x10>; + #pwm-cells = <3>; + }; + + pwm1: pwm at 40b00010 { + compatible = "marvell,pxa250-pwm"; + reg = <0x40b00010 0x10>; + #pwm-cells = <3>; + }; + + pwm2: pwm at 40c00000 { + compatible = "marvell,pxa250-pwm"; + reg = <0x40c00000 0x10>; + #pwm-cells = <3>; + }; + + pwm3: pwm at 40c00010 { + compatible = "marvell,pxa250-pwm"; + reg = <0x40c00010 0x10>; + #pwm-cells = <3>; + }; }; };
drivers/pwm/pwm-pxa.c +57 -0
106 lines not on this page · raw message
Signature · 1 line
1.8.1.5
PATCH RESEND v2 1/1 pwm: pxa: add device tree support to pwm driver
Documentation/devicetree/bindings/pwm/pxa-pwm.txt
Quoted 10 lines · Mike Dunn
This patch adds device tree support to the pxa's pwm driver. Only an OF match table is added; nothing needs to be extracted from the device tree node. The existing
platform_deviceid table is reused for the match table data. Support for inverted polarity is also added.Tested on a Palm Treo 680 (both platform data and DT cases).
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +1
-0+Marvell pwm controller
s/pwm/PWM/ throughout.
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 5
Quoted 4 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +4
-0+ +Required properties: +- compatible: + for pxa25x, pxa27x, pxa168, pxa910: must be compatible = "marvell,pxa250-pwm";
I think you want a separate compatible value for each HW, to allow for any HW-specific quirks to be enabled later if required. So, you could document "marvell,pxa250-pwm" as the basic compatible value that a driver can bind to, yet also document the other values as being required for the relevant HW?
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 11
Quoted 6 lines
+- reg: physical base address and length of the registers used by the pwm channel
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +5
-0+ NB: One device instance must be created for each pwm that is used, so the + length covers only the register window for one pwm output, not that of the + entire pwm controller. Currently length is 0x10 for all supported devices. +- #pwm-cells: should be 3. + cell 1: the per-chip index of the PWM to use,
That cell shouldn't be needed if you really want to have one DT node per PWM channel.
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 17
Quoted 6 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +6
-0+ cell 2: the period in nanoseconds, + cell 3: flags; set bit 0 to specify inverse polarity. The pwm controller + does not implement reverse polarity, but some boards may pass the pwm output + through an external inverter, which can cause problems if a client device + assumes that an increase in the duty cycle results in an increase in output + power. The pwm-backlight is an example of such a client.
Hmm. I wonder what are the semantics of the PWM subsystem's "inverse polarity" flag. What about a HW block that can do inverse polarity, but also has an inverter on the board? If we subvert this flag (in this case) to mean "there's an inverter on the board", then how can a different PWM binding use it to mean "configure the PWM HW block to invert the signal"?
Quoted 15 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +15
-0+Example pwm device node: + +pwm0: pwm at 40b00000 { + compatible = "marvell,pxa250-pwm"; + reg = <0x40b00000 0x10>; + #pwm-cells = <3>; +}; + +Example pwm client node: + +backlight { + compatible = "pwm-backlight"; + pwms = <&pwm0 0 5000000 1>; /* pwm output is inverted */ + ... +}
PATCH RESEND v2 1/1 pwm: pxa: add device tree support to pwm driver
Quoted 14 lines · Stephen Warren
Documentation/devicetree/bindings/pwm/pxa-pwm.txt
Quoted 10 lines · Mike Dunn
This patch adds device tree support to the pxa's pwm driver. Only an OF match table is added; nothing needs to be extracted from the device tree node. The existing
platform_deviceid table is reused for the match table data. Support for inverted polarity is also added.Tested on a Palm Treo 680 (both platform data and DT cases).
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +1
-0+Marvell pwm controllers/pwm/PWM/ throughout.
Quoted 10 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 5
Quoted 4 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +4
-0+ +Required properties: +- compatible: + for pxa25x, pxa27x, pxa168, pxa910: must be compatible = "marvell,pxa250-pwm";I think you want a separate compatible value for each HW, to allow for any HW-specific quirks to be enabled later if required. So, you could document "marvell,pxa250-pwm" as the basic compatible value that a driver can bind to, yet also document the other values as being required for the relevant HW?
IOW...
- compatible: should be one of:
- "marvell,pxa250-pwm"
- "marvell,pxa270-pwm"
- "marvell,pxa168-pwm"
- "marvell,pxa910-pwm"
Even though the driver makes no functional distinction currently?
Quoted 10 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 11
Quoted 7 lines
+- reg: physical base address and length of the registers used by the pwm channel
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +5
-0+ NB: One device instance must be created for each pwm that is used, so the + length covers only the register window for one pwm output, not that of the + entire pwm controller. Currently length is 0x10 for all supported devices. +- #pwm-cells: should be 3. + cell 1: the per-chip index of the PWM to use,That cell shouldn't be needed if you really want to have one DT node per PWM channel.
Yes, but I was afraid to deviate from the format used by the other PWM controllers. (But in that case, it should at least be documented as "must be zero". Thanks.) If going my owm way is acceptable, I'll define my own of_xlate() parser and remove this cell.
Quoted 8 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 17
Quoted 7 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +6
-0+ cell 2: the period in nanoseconds, + cell 3: flags; set bit 0 to specify inverse polarity. The pwm controller + does not implement reverse polarity, but some boards may pass the pwm output + through an external inverter, which can cause problems if a client device + assumes that an increase in the duty cycle results in an increase in output + power. The pwm-backlight is an example of such a client.
Quoted 6 lines
Hmm. I wonder what are the semantics of the PWM subsystem's "inverse polarity" flag. What about a HW block that can do inverse polarity, but also has an inverter on the board? If we subvert this flag (in this case) to mean "there's an inverter on the board", then how can a different PWM binding use it to mean "configure the PWM HW block to invert the signal"?
Yeah, Thierry shot this down for the same good reasons. The correct approach for my issue is to fix the pwm-backlight driver.
I really appreciate the review Stephen. Thanks again! Mike
PATCH RESEND v2 1/1 pwm: pxa: add device tree support to pwm driver
Quoted 26 lines · Mike Dunn
Quoted 14 lines · Stephen Warren
Documentation/devicetree/bindings/pwm/pxa-pwm.txt
Quoted 10 lines · Mike Dunn
This patch adds device tree support to the pxa's pwm driver. Only an OF match table is added; nothing needs to be extracted from the device tree node. The existing
platform_deviceid table is reused for the match table data. Support for inverted polarity is also added.Tested on a Palm Treo 680 (both platform data and DT cases).
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +1
-0+Marvell pwm controllers/pwm/PWM/ throughout.
Quoted 10 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 5
Quoted 4 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +4
-0+ +Required properties: +- compatible: + for pxa25x, pxa27x, pxa168, pxa910: must be compatible = "marvell,pxa250-pwm";I think you want a separate compatible value for each HW, to allow for any HW-specific quirks to be enabled later if required. So, you could document "marvell,pxa250-pwm" as the basic compatible value that a driver can bind to, yet also document the other values as being required for the relevant HW?
Quoted 8 lines
IOW...
- compatible: should be one of:
- "marvell,pxa250-pwm"
- "marvell,pxa270-pwm"
- "marvell,pxa168-pwm"
- "marvell,pxa910-pwm"Even though the driver makes no functional distinction currently?
Yes (although it's fine to make the driver only look for the first of those, since you say they're all compatible, and currently the driver doesn't care about exactly which HW is in use).
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
+- reg: physical base address and length of the registers used by the pwm channel
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +5
-0+ NB: One device instance must be created for each pwm that is used, so the + length covers only the register window for one pwm output, not that of the + entire pwm controller. Currently length is 0x10 for all supported devices. +- #pwm-cells: should be 3. + cell 1: the per-chip index of the PWM to use,
Quoted 7 lines
Quoted 2 lines
That cell shouldn't be needed if you really want to have one DT node per PWM channel.
Yes, but I was afraid to deviate from the format used by the other PWM controllers. (But in that case, it should at least be documented as "must be zero". Thanks.) If going my owm way is acceptable, I'll define my own
of_xlate()parser and remove this cell.
I don't think there's any issue with deviating; that's exactly what #pwm-cells is for.
PATCH RESEND v2 1/1 pwm: pxa: add device tree support to pwm driver
Quoted 3 lines · Stephen Warren
Quoted 2 lines · Mike Dunn
Quoted 1 line · Stephen Warren
On 09/09/2013 12:30 PM, Mike Dunn wrote:
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 11
Quoted 6 lines
+- reg: physical base address and length of the registers used by the pwm channel
Documentation/devicetree/bindings/pwm/pxa-pwm.txt new file +5
-0+ NB: One device instance must be created for each pwm that is used, so the + length covers only the register window for one pwm output, not that of the + entire pwm controller. Currently length is 0x10 for all supported devices. +- #pwm-cells: should be 3. + cell 1: the per-chip index of the PWM to use,That cell shouldn't be needed if you really want to have one DT node per PWM channel.
Quoted 7 lines
Quoted 4 lines
Yes, but I was afraid to deviate from the format used by the other PWM controllers. (But in that case, it should at least be documented as "must be zero". Thanks.) If going my owm way is acceptable, I'll define my own
of_xlate()parser and remove this cell.I don't think there's any issue with deviating; that's exactly what #pwm-cells is for.
Agreed, I have no objections to using a custom .of_xlate().
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130910/f91e6adc/attachment.sig>