PWM: PXA: add device tree support to PWM driver
Subsystems (2)
PATCH v3 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 ID table is reused for the match table data.
Tested on a Palm Treo 680 (both platform data and DT cases).
---
Changle log:
v3:
- remove support for the polarity flag
- remove per-chip pwm index cell; define custom of_xlate() (now #pwm-cells = <1>)
- "compatible" strings for all devices added to OF match table
- various stylistic changes recommended by reviewers
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 | 31 ++++++++++++ arch/arm/boot/dts/pxa27x.dtsi | 24 +++++++++ drivers/pwm/pwm-pxa.c | 62 +++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pxa-pwm.txt
Documentation/devicetree/bindings/pwm/pxa-pwm.txt new file +31 -0
@@ -0,0 +1,31 @@ +Marvell PWM controller + +Required properties: +- compatible: should be one of: + - "marvell,pxa250-pwm" + - "marvell,pxa270-pwm" + - "marvell,pxa168-pwm" + - "marvell,pxa910-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 1. This cell is used to specify the period in + nanoseconds. (Because one device instance is created for each PWM output, + the per-chip index is superflous and not used.) + +Example PWM device node: + +pwm0: pwm at 40b00000 { + compatible = "marvell,pxa250-pwm"; + reg = <0x40b00000 0x10>; + #pwm-cells = <1>; +}; + +Example PWM client node: + +backlight { + compatible = "pwm-backlight"; + pwms = <&pwm0 5000000>; + ... +}
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,pxa270-pwm"; + reg = <0x40b00000 0x10>; + #pwm-cells = <1>; + }; + + pwm1: pwm at 40b00010 { + compatible = "marvell,pxa270-pwm"; + reg = <0x40b00010 0x10>; + #pwm-cells = <1>; + }; + + pwm2: pwm at 40c00000 { + compatible = "marvell,pxa270-pwm"; + reg = <0x40c00000 0x10>; + #pwm-cells = <1>; + }; + + pwm3: pwm at 40c00010 { + compatible = "marvell,pxa270-pwm"; + reg = <0x40c00010 0x10>; + #pwm-cells = <1>; + }; }; };
drivers/pwm/pwm-pxa.c +62 -0
92 lines not on this page · raw message
Signature · 1 line
1.8.1.5
PATCH v3 1/1 PWM: PXA: add device tree support to PWM driver
Dear Mike Dunn,
Quoted 38 lines
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 ID table is reused for the match table data.
Tested on a Palm Treo 680 (both platform data and DT cases).
Signed-off-by Mike Dunn <[email protected]>---
Changle log:
v3:
- remove support for the polarity flag
- remove per-chip pwm index cell; define customof_xlate()(now #pwm-cells = <1>)
- "compatible" strings for all devices added to OF match table
- various stylistic changes recommended by reviewersv2:
-of_match_tablecontains only the "pxa250-pwm" compatible string; require one device instance per pwm
- addDocumentation/devicetree/bindings/pwm/pxa-pwm.txt
- add support for polarity flag in DT and implementset_polarity()method (the treo 680 inverts the signal between pwm out and backlight)
- return-EINVALinstead of-ENODEVif platform data or DT node not found
- outputdev_infostring if platform data missing
- expanded CC list of patchDocumentation/devicetree/bindings/pwm/pxa-pwm.txt | 31 ++++++++++++ arch/arm/boot/dts/pxa27x.dtsi | 24 +++++++++ drivers/pwm/pwm-pxa.c | 62 +++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pxa-pwm.txt(quoted diff) +0
-0
b/Documentation/devicetree/bindings/pwm/pxa-pwm.txtnew file mode 100644 index 0000000..6fcf90c
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt new file +8
-0@@ -0,0 +1,31 @@ +Marvell PWM controller + +Required properties: +- compatible: should be one of: + - "marvell,pxa250-pwm" + - "marvell,pxa270-pwm" + - "marvell,pxa168-pwm" + - "marvell,pxa910-pwm"
This really is something I dont quite understand. Why should the driver list _every_ _single_ existing CPU that contains such PWM block? Is there any agreement about that? For me, it'd make much more sense to list only the CPUs where the IP block actually changed in some way, so that the differences can be discerned that way.
Best regards,
Marek Vasut
PATCH v3 1/1 PWM: PXA: add device tree support to PWM driver
Quoted 46 lines · Marek Vasut
Dear Mike Dunn,
Quoted 44 lines
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 ID table is reused for the match table data.
Tested on a Palm Treo 680 (both platform data and DT cases).
Signed-off-by Mike Dunn <[email protected]>---
Changle log:
v3:
- remove support for the polarity flag
- remove per-chip pwm index cell; define customof_xlate()(now #pwm-cells = <1>)
- "compatible" strings for all devices added to OF match table
- various stylistic changes recommended by reviewersv2:
-of_match_tablecontains only the "pxa250-pwm" compatible string; require one device instance per pwm
- addDocumentation/devicetree/bindings/pwm/pxa-pwm.txt
- add support for polarity flag in DT and implementset_polarity()method (the treo 680 inverts the signal between pwm out and backlight)
- return-EINVALinstead of-ENODEVif platform data or DT node not found
- outputdev_infostring if platform data missing
- expanded CC list of patchDocumentation/devicetree/bindings/pwm/pxa-pwm.txt | 31 ++++++++++++ arch/arm/boot/dts/pxa27x.dtsi | 24 +++++++++ drivers/pwm/pwm-pxa.c | 62 +++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pxa-pwm.txt(quoted diff) +0
-0
b/Documentation/devicetree/bindings/pwm/pxa-pwm.txtnew file mode 100644 index 0000000..6fcf90cDocumentation/devicetree/bindings/pwm/pxa-pwm.txt new file +6
-0@@ -0,0 +1,31 @@ +Marvell PWM controller + +Required properties: +- compatible: should be one of: + - "marvell,pxa250-pwm" + - "marvell,pxa270-pwm"
Quoted 8 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 8
Quoted 2 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt new file +2
-0+ - "marvell,pxa168-pwm" + - "marvell,pxa910-pwm"This really is something I dont quite understand. Why should the driver list _every_ _single_ existing CPU that contains such PWM block? Is there any agreement about that? For me, it'd make much more sense to list only the CPUs where the IP block actually changed in some way, so that the differences can be discerned that way.
I believe that this was Stephen's suggestion.
I actually don't object myself. For the price of a few strings, it
- clearly shows which SoCs the driver supports
- ensures that any future differences are handled cleanly (e.g., if a hw bug in one is discovered and a work-around is implemented)
- keeps thngs clean if support for another processor which does have pwm hw differences is added
Especially the third point... otherwise, you have the case of a somewhat confusing many-to-one mapping of processors to compatible strings.
Thanks,
Mike
PATCH v3 1/1 PWM: PXA: add device tree support to PWM driver
Dear Mike Dunn,
Quoted 72 lines · Marek Vasut
Quoted 53 lines
Dear Mike Dunn,
Quoted 51 lines
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 ID table is reused for the match table data.
Tested on a Palm Treo 680 (both platform data and DT cases).
Signed-off-by Mike Dunn <[email protected]>---
Changle log:
v3:
- remove support for the polarity flag
- remove per-chip pwm index cell; define customof_xlate()(now #pwm-cells = <1>)- "compatible" strings for all devices added to OF match table
- various stylistic changes recommended by reviewersv2:
-of_match_tablecontains only the "pxa250-pwm" compatible string; require one device instance per pwm
- addDocumentation/devicetree/bindings/pwm/pxa-pwm.txt
- add support for polarity flag in DT and implementset_polarity()method(the treo 680 inverts the signal between pwm out and backlight)
- return
-EINVALinstead of-ENODEVif platform data or DT node not found - outputdev_infostring if platform data missing
- expanded CC list of patchDocumentation/devicetree/bindings/pwm/pxa-pwm.txt | 31 ++++++++++++ arch/arm/boot/dts/pxa27x.dtsi | 24 +++++++++ drivers/pwm/pwm-pxa.c | 62+++++++++++++++++++++++ 3 files changed, 117 insertions(+)
create mode 100644 Documentation/devicetree/bindings/pwm/pxa-pwm.txt(quoted diff) +0
-0
b/Documentation/devicetree/bindings/pwm/pxa-pwm.txtnew file mode 100644 index 0000000..6fcf90cDocumentation/devicetree/bindings/pwm/pxa-pwm.txt new file +6
-0@@ -0,0 +1,31 @@ +Marvell PWM controller + +Required properties: +- compatible: should be one of: + - "marvell,pxa250-pwm" + - "marvell,pxa270-pwm"Quoted 8 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 8
Quoted 2 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt new file +2
-0+ - "marvell,pxa168-pwm" + - "marvell,pxa910-pwm"This really is something I dont quite understand. Why should the driver list _every_ _single_ existing CPU that contains such PWM block? Is there any agreement about that? For me, it'd make much more sense to list only the CPUs where the IP block actually changed in some way, so that the differences can be discerned that way.
I believe that this was Stephen's suggestion.
I actually don't object myself. For the price of a few strings, it
- clearly shows which SoCs the driver supports
- ensures that any future differences are handled cleanly (e.g., if a hw bug in one is discovered and a work-around is implemented)
- keeps thngs clean if support for another processor which does have pwm hw differences is added
Quoted 2 lines
Especially the third point... otherwise, you have the case of a somewhat confusing many-to-one mapping of processors to compatible strings.
OK, to push it ad-absurdum, shall we not start listing every single revision of the CPU as well ? Like pxa250a0 250a1 etc ? Yes , this many-to-one mapping is something I don't quite understand, that's why I'd love to see a good reasoning from Stephen.
Best regards,
Marek Vasut
PATCH v3 1/1 PWM: PXA: add device tree support to PWM driver
On 09/16/2013 09:10 AM, Marek Vasut wrote:
...
Quoted 2 lines
OK, to push it ad-absurdum, shall we not start listing every single revision of the CPU as well? Like pxa250a0 250a1 etc ? Yes , this many-to-one mapping is
It's not about CPU revisions, it's about revisions of the SoC that contain the IP block.
Quoted 2 lines
something I don't quite understand, that's why I'd love to see a good reasoning from Stephen.
Please see the earlier discussions.
PATCH v3 1/1 PWM: PXA: add device tree support to PWM driver
Dear Stephen Warren,
Quoted 9 lines · Marek Vasut
...
Quoted 3 lines
OK, to push it ad-absurdum, shall we not start listing every single revision of the CPU as well? Like pxa250a0 250a1 etc ? Yes , this many-to-one mapping is
It's not about CPU revisions, it's about revisions of the SoC that contain the IP block.
But that doesn't matter if the IP block is the same in all of them.
Quoted 4 lines
Quoted 2 lines
something I don't quite understand, that's why I'd love to see a good reasoning from Stephen.
Please see the earlier discussions.
I did, so I must really be slow or something.
Best regards,
Marek Vasut
PATCH v3 1/1 PWM: PXA: add device tree support to PWM driver
In reply to Mike DunnDocumentation/devicetree/bindings/pwm/pxa-pwm.txt line 8
Quoted 13 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 ID table is reused for the match table data.
Tested on a Palm Treo 680 (both platform data and DT cases).
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +5
-0+- compatible: should be one of: + - "marvell,pxa250-pwm" + - "marvell,pxa270-pwm" + - "marvell,pxa168-pwm" + - "marvell,pxa910-pwm"
Not just one of, but possible more than one...
arch/arm/boot/dts/pxa27x.dtsi line 15
Quoted 4 lines
arch/arm/boot/dts/pxa27x.dtsi +2
-0+ pwm0: pwm at 40b00000 { + compatible = "marvell,pxa270-pwm";
I thought the assertion was that pax270 and pxa250 were both compatible? If so, that should be:
compatible = "marvell,pxa270-pwm", "marvell,pxa250-pwm";
PATCH v3 1/1 PWM: PXA: add device tree support to PWM driver
Dear Stephen Warren,
Quoted 21 lines · Mike Dunn
Quoted 8 lines
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 ID table is reused for the match table data.
Tested on a Palm Treo 680 (both platform data and DT cases).
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 8
Quoted 6 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +5
-0+- compatible: should be one of: + - "marvell,pxa250-pwm" + - "marvell,pxa270-pwm" + - "marvell,pxa168-pwm" + - "marvell,pxa910-pwm"Not just one of, but possible more than one...
Quoted 3 lines
arch/arm/boot/dts/pxa27x.dtsi +0
-0
Quoted 7 lines
arch/arm/boot/dts/pxa27x.dtsi
Quoted 2 lines
arch/arm/boot/dts/pxa27x.dtsi +2
-0+ pwm0: pwm at 40b00000 { + compatible = "marvell,pxa270-pwm";I thought the assertion was that pax270 and pxa250 were both compatible? If so, that should be:
compatible = "marvell,pxa270-pwm", "marvell,pxa250-pwm";
I see what you mean with the compatible strings ... but if we have this "fallback" compatiblity string, do we also need the table of all chips sporting the IP block in the driver itself?
Best regards,
Marek Vasut
PATCH v3 1/1 PWM: PXA: add device tree support to PWM driver
Quoted 29 lines · Marek Vasut
Dear Stephen Warren,
Quoted 27 lines · Mike Dunn
Quoted 8 lines
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 ID table is reused for the match table data.
Tested on a Palm Treo 680 (both platform data and DT cases).
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 8
Quoted 6 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +5
-0+- compatible: should be one of: + - "marvell,pxa250-pwm" + - "marvell,pxa270-pwm" + - "marvell,pxa168-pwm" + - "marvell,pxa910-pwm"Not just one of, but possible more than one...
arch/arm/boot/dts/pxa27x.dtsi line 15
Quoted 5 lines
arch/arm/boot/dts/pxa27x.dtsi +2
-0+ pwm0: pwm at 40b00000 { + compatible = "marvell,pxa270-pwm";I thought the assertion was that pax270 and pxa250 were both compatible? If so, that should be:
Quoted 5 lines
Quoted 1 line
compatible = "marvell,pxa270-pwm", "marvell,pxa250-pwm";I see what you mean with the compatible strings ... but if we have this "fallback" compatiblity string, do we also need the table of all chips sporting the IP block in the driver itself?
I would assume the driver can just support "marvell,pxa250-pwm" for now.
PATCH v3 1/1 PWM: PXA: add device tree support to PWM driver
In reply to Stephen WarrenQuoted 9 lines · Stephen Warren
Quoted 7 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 ID table is reused for the match table data.
Tested on a Palm Treo 680 (both platform data and DT cases).
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +0
-0
Quoted 7 lines
Documentation/devicetree/bindings/pwm/pxa-pwm.txt line 8
Quoted 5 lines
+- compatible: should be one of:
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +4
-0+ - "marvell,pxa250-pwm" + - "marvell,pxa270-pwm" + - "marvell,pxa168-pwm" + - "marvell,pxa910-pwm"Not just one of, but possible more than one...
So the phrasing should be "compatible: should be among:" ?
Quoted 10 lines
arch/arm/boot/dts/pxa27x.dtsi line 15
Quoted 5 lines
arch/arm/boot/dts/pxa27x.dtsi +2
-0+ pwm0: pwm at 40b00000 { + compatible = "marvell,pxa270-pwm";I thought the assertion was that pax270 and pxa250 were both compatible? If so, that should be:
compatible = "marvell,pxa270-pwm", "marvell,pxa250-pwm";
Indeed. Currently, they are all the same. By that logic, shouldn't it be
compatible = "marvell,pxa250-pwm", "marvell,pxa270-pwm", "marvell,pxa168-pwm", "marvell,pxa910-pwm";
I am admittedly fuzzy on device tree, but this is starting to seem strange.
Anyway, I'll defer to your judgement and resubmit if you can give me precise guidance on the above. Thanks again for the review.
Thanks,
Mike
PATCH v3 1/1 PWM: PXA: add device tree support to PWM driver
Quoted 16 lines · Mike Dunn
Quoted 15 lines · Stephen Warren
Quoted 13 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 ID table is reused for the match table data.
Tested on a Palm Treo 680 (both platform data and DT cases).
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +5
-0+- compatible: should be one of: + - "marvell,pxa250-pwm" + - "marvell,pxa270-pwm" + - "marvell,pxa168-pwm" + - "marvell,pxa910-pwm"
Quoted 3 lines
Quoted 1 line
Not just one of, but possible more than one...
So the phrasing should be "compatible: should be among:" ?
I think I've seen "One or more of".
Quoted 8 lines
Quoted 8 lines
arch/arm/boot/dts/pxa27x.dtsi line 15
Quoted 4 lines
arch/arm/boot/dts/pxa27x.dtsi +2
-0+ pwm0: pwm at 40b00000 { + compatible = "marvell,pxa270-pwm";I thought the assertion was that pax270 and pxa250 were both compatible? If so, that should be:
Quoted 7 lines
Quoted 1 line
compatible = "marvell,pxa270-pwm", "marvell,pxa250-pwm";Indeed. Currently, they are all the same. By that logic, shouldn't it be
compatible = "marvell,pxa250-pwm", "marvell,pxa270-pwm", "marvell,pxa168-pwm", "marvell,pxa910-pwm";
compatible should include:
* The exact HW model (so the driver knows exactly which HW is present in order to enable any bug quirks).
* The "first" HW model this HW is compatible with, since this is what the driver will bind to (ignoring the possibility of bug quirks).
So, you don't need to include all the values, just two in this case.
PATCH v3 1/1 PWM: PXA: add device tree support to PWM driver
Quoted 17 lines · Stephen Warren
Quoted 16 lines · Mike Dunn
Quoted 15 lines · Stephen Warren
Quoted 13 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 ID table is reused for the match table data.
Tested on a Palm Treo 680 (both platform data and DT cases).
Documentation/devicetree/bindings/pwm/pxa-pwm.txt +5
-0+- compatible: should be one of: + - "marvell,pxa250-pwm" + - "marvell,pxa270-pwm" + - "marvell,pxa168-pwm" + - "marvell,pxa910-pwm"
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Not just one of, but possible more than one...
So the phrasing should be "compatible: should be among:" ?
I think I've seen "One or more of".
OK.
Quoted 18 lines
Quoted 10 lines
Quoted 10 lines
arch/arm/boot/dts/pxa27x.dtsi line 15
Quoted 6 lines
arch/arm/boot/dts/pxa27x.dtsi +2
-0+ pwm0: pwm at 40b00000 { + compatible = "marvell,pxa270-pwm";I thought the assertion was that pax270 and pxa250 were both compatible? If so, that should be:
Quoted 7 lines
Quoted 1 line
compatible = "marvell,pxa270-pwm", "marvell,pxa250-pwm";Indeed. Currently, they are all the same. By that logic, shouldn't it be
compatible = "marvell,pxa250-pwm", "marvell,pxa270-pwm", "marvell,pxa168-pwm", "marvell,pxa910-pwm";
Quoted 8 lines
compatible should include:
* The exact HW model (so the driver knows exactly which HW is present in order to enable any bug quirks).
* The "first" HW model this HW is compatible with, since this is what the driver will bind to (ignoring the possibility of bug quirks).So, you don't need to include all the values, just two in this case.
I think I see... and hypothetically, if the the driver must know that it is a pxa270 in order for it to function correctly due to (hypothetical) hardware differences, then only the first compatible string should appear?
Anyway, thanks again! I'll resubmit tomorrow.
Mike
PATCH v3 1/1 PWM: PXA: add device tree support to PWM driver
Quoted 33 lines · Mike Dunn
Quoted 32 lines · Stephen Warren
Quoted 16 lines · Mike Dunn
Quoted 15 lines · Stephen Warren
arch/arm/boot/dts/pxa27x.dtsi line 15
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 ID table is reused for the match table data.
Tested on a Palm Treo 680 (both platform data and DT cases).
arch/arm/boot/dts/pxa27x.dtsi +2
-0+ pwm0: pwm at 40b00000 { + compatible = "marvell,pxa270-pwm";I thought the assertion was that pax270 and pxa250 were both compatible? If so, that should be:
Quoted 7 lines
Quoted 1 line
compatible = "marvell,pxa270-pwm", "marvell,pxa250-pwm";Indeed. Currently, they are all the same. By that logic, shouldn't it be
compatible = "marvell,pxa250-pwm", "marvell,pxa270-pwm", "marvell,pxa168-pwm", "marvell,pxa910-pwm";
compatible should include:
* The exact HW model (so the driver knows exactly which HW is present in order to enable any bug quirks).
* The "first" HW model this HW is compatible with, since this is what the driver will bind to (ignoring the possibility of bug quirks).
Quoted 5 lines
Quoted 1 line
So, you don't need to include all the values, just two in this case.
I think I see... and hypothetically, if the the driver must know that it is a pxa270 in order for it to function correctly due to (hypothetical) hardware differences, then only the first compatible string should appear?
Yes, if the 250 and 270 HW were actually different, then you'd only include one or the other compatible values in the property.