2024-03-01 18:01:51

by Trevor Gamblin

[permalink] [raw]
Subject: [PATCH 0/2 v4] pwm: add axi-pwm-gen driver

This series adds support for the AXI PWM GEN subsystem found on FPGA IP
cores. It can be used to generate configurable PWM outputs, and includes
options for external synchronization and clock signals. The work is
being done on behalf of, and therefore lists maintainers from Analog
Devices, Inc.

The series has been tested on actual hardware using an EVAL-AD7985FMCZ
evaluation board. An oscilloscope was used to validate that the
generated PWM signal matched the requested one.

---
v4 changes:
* Address feedback for driver in v3:
* Update to use devm_pwmchip_alloc() function
* Simplify use of dev symbol in axi_pwmgen_probe
* Remove unnecessary axi_pwmgen_from_chip function and use
pwmchip_get_drvdata directly

Link to v3: https://lore.kernel.org/linux-pwm/[email protected]/

v3 changes:
* Address feedback for driver in v2:
* Remove unnecessary blank line in axi_pwmgen_apply
* Use macros already defined in <linux/fpga/adi-axi-common.h> for
version checking

Link to v2: https://lore.kernel.org/linux-pwm/[email protected]/

v2 changes:
* Address feedback for driver and device tree in v1:
* Use more reasonable Kconfig approach
* Use common prefixes for all functions
* Rename axi_pwmgen struct to axi_pwmgen_ddata
* Change use of "pwm" to "ddata"
* Set and check state->polarity
* Multiply safely with mul_u64_u64_div_u64()
* Improve handling of max and zero periods
* Error if clk_rate_hz > NSEC_PER_SEC
* Add "Limitations" section at top of pwm-axi-pwmgen.c
* Don't disable outputs by default
* Remove unnecessary macros for period, duty, offset
* Fix axi_pwmgen_ddata alignment
* Don't artificially limit npwm to four
* Use clk_rate_exclusive_get(), balance with clk_rate_exclusive_put()
* Cache clk rate in axi_pwmgen_ddata
* Don't assign pwm->chip.base, do assign pwm->chip.atomic
* Relocate "unevaluatedProperties" in device tree binding
* Remove redundant calls to clk_get_rate
* Test contents of AXI_PWMGEN_REG_CORE_MAGIC instead of
arbitrary AXI_PWMGEN_TEST_DATA in AXI_PWMGEN_REG_SCRATCHPAD
* Remove redundant clk struct from axi_pwmgen_ddata
* Add self as module author
* Add major version check for IP core

Link to v1: https://lore.kernel.org/linux-pwm/[email protected]/

Drew Fustini (2):
dt-bindings: pwm: Add AXI PWM generator
pwm: Add driver for AXI PWM generator

.../bindings/pwm/adi,axi-pwmgen.yaml | 48 ++++
MAINTAINERS | 9 +
drivers/pwm/Kconfig | 13 +
drivers/pwm/Makefile | 1 +
drivers/pwm/pwm-axi-pwmgen.c | 244 ++++++++++++++++++
5 files changed, 315 insertions(+)
create mode 100644 Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
create mode 100644 drivers/pwm/pwm-axi-pwmgen.c

--
2.43.2



2024-03-01 18:07:12

by Trevor Gamblin

[permalink] [raw]
Subject: [PATCH 1/2 v4] dt-bindings: pwm: Add AXI PWM generator

From: Drew Fustini <[email protected]>

Add Analog Devices AXI PWM generator.

Link: https://wiki.analog.com/resources/fpga/docs/axi_pwm_gen
Signed-off-by: Drew Fustini <[email protected]>
Reviewed-by: Krzysztof Kozlowski <[email protected]>
Co-developed-by: Trevor Gamblin <[email protected]>
Signed-off-by: Trevor Gamblin <[email protected]>
---
v4 changes: None (rebased, added maintainer's previous Reviewed-by)
v3 changes: None (rebased, added maintainer's previous Reviewed-by)

v2 changes:
* Address feedback for driver and device tree in v1:
* Relocate "unevaluatedProperties" in device tree binding
* Remove redundant "bindings for" in description

---
.../bindings/pwm/adi,axi-pwmgen.yaml | 48 +++++++++++++++++++
MAINTAINERS | 8 ++++
2 files changed, 56 insertions(+)
create mode 100644 Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml

diff --git a/Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml b/Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
new file mode 100644
index 000000000000..63461920a362
--- /dev/null
+++ b/Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pwm/adi,axi-pwmgen.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices AXI PWM generator
+
+maintainers:
+ - Michael Hennerich <[email protected]>
+ - Nuno Sá <[email protected]>
+
+description:
+ The Analog Devices AXI PWM generator can generate PWM signals
+ with variable pulse width and period.
+
+ https://wiki.analog.com/resources/fpga/docs/axi_pwm_gen
+
+allOf:
+ - $ref: pwm.yaml#
+
+properties:
+ compatible:
+ const: adi,axi-pwmgen-1.00.a
+
+ reg:
+ maxItems: 1
+
+ "#pwm-cells":
+ const: 2
+
+ clocks:
+ maxItems: 1
+
+required:
+ - reg
+ - clocks
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ pwm@44b00000 {
+ compatible = "adi,axi-pwmgen-1.00.a";
+ reg = <0x44b00000 0x1000>;
+ clocks = <&spi_clk>;
+ #pwm-cells = <2>;
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index 8d1052fa6a69..8a4ed5545680 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3431,6 +3431,14 @@ W: https://ez.analog.com/linux-software-drivers
F: Documentation/devicetree/bindings/spi/adi,axi-spi-engine.yaml
F: drivers/spi/spi-axi-spi-engine.c

+AXI PWM GENERATOR
+M: Michael Hennerich <[email protected]>
+M: Nuno Sá <[email protected]>
+L: [email protected]
+S: Supported
+W: https://ez.analog.com/linux-software-drivers
+F: Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
+
AXXIA I2C CONTROLLER
M: Krzysztof Adamski <[email protected]>
L: [email protected]
--
2.43.2


2024-04-11 10:35:29

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 1/2 v4] dt-bindings: pwm: Add AXI PWM generator

Hello,

On Fri, Mar 01, 2024 at 12:33:41PM -0500, Trevor Gamblin wrote:
> From: Drew Fustini <[email protected]>
>
> Add Analog Devices AXI PWM generator.
>
> Link: https://wiki.analog.com/resources/fpga/docs/axi_pwm_gen
> Signed-off-by: Drew Fustini <[email protected]>
> Reviewed-by: Krzysztof Kozlowski <[email protected]>
> Co-developed-by: Trevor Gamblin <[email protected]>
> Signed-off-by: Trevor Gamblin <[email protected]>
> ---
> v4 changes: None (rebased, added maintainer's previous Reviewed-by)
> v3 changes: None (rebased, added maintainer's previous Reviewed-by)
>
> v2 changes:
> * Address feedback for driver and device tree in v1:
> * Relocate "unevaluatedProperties" in device tree binding
> * Remove redundant "bindings for" in description
>
> ---
> .../bindings/pwm/adi,axi-pwmgen.yaml | 48 +++++++++++++++++++
> MAINTAINERS | 8 ++++
> 2 files changed, 56 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
>
> diff --git a/Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml b/Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
> new file mode 100644
> index 000000000000..63461920a362
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
> @@ -0,0 +1,48 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/pwm/adi,axi-pwmgen.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Analog Devices AXI PWM generator
> +
> +maintainers:
> + - Michael Hennerich <[email protected]>
> + - Nuno S? <[email protected]>

Would be great to get an ack from these two.

Otherwise looks fine to me.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | https://www.pengutronix.de/ |


Attachments:
(No filename) (1.96 kB)
signature.asc (499.00 B)
Download all attachments

2024-04-11 10:39:48

by Hennerich, Michael

[permalink] [raw]
Subject: RE: [PATCH 1/2 v4] dt-bindings: pwm: Add AXI PWM generator



> -----Original Message-----
> From: Uwe Kleine-K?nig <[email protected]>
> Sent: Thursday, April 11, 2024 12:33 PM
> To: Trevor Gamblin <[email protected]>
> Cc: [email protected]; [email protected]; Hennerich,
> Michael <[email protected]>; Sa, Nuno
> <[email protected]>; [email protected]; [email protected];
> [email protected]; [email protected]; David Lechner
> <[email protected]>; Drew Fustini <[email protected]>; Krzysztof
> Kozlowski <[email protected]>
> Subject: Re: [PATCH 1/2 v4] dt-bindings: pwm: Add AXI PWM generator
>
>
> Hello,
>
> On Fri, Mar 01, 2024 at 12:33:41PM -0500, Trevor Gamblin wrote:
> > From: Drew Fustini <[email protected]>
> >
> > Add Analog Devices AXI PWM generator.
> >
> > Link: https://wiki.analog.com/resources/fpga/docs/axi_pwm_gen
> > Signed-off-by: Drew Fustini <[email protected]>
> > Reviewed-by: Krzysztof Kozlowski <[email protected]>
> > Co-developed-by: Trevor Gamblin <[email protected]>
> > Signed-off-by: Trevor Gamblin <[email protected]>
> > ---
> > v4 changes: None (rebased, added maintainer's previous Reviewed-by)
> > v3 changes: None (rebased, added maintainer's previous Reviewed-by)
> >
> > v2 changes:
> > * Address feedback for driver and device tree in v1:
> > * Relocate "unevaluatedProperties" in device tree binding
> > * Remove redundant "bindings for" in description
> >
> > ---
> > .../bindings/pwm/adi,axi-pwmgen.yaml | 48 +++++++++++++++++++
> > MAINTAINERS | 8 ++++
> > 2 files changed, 56 insertions(+)
> > create mode 100644
> > Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
> > b/Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
> > new file mode 100644
> > index 000000000000..63461920a362
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
> > @@ -0,0 +1,48 @@
> > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause %YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/pwm/adi,axi-pwmgen.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Analog Devices AXI PWM generator
> > +
> > +maintainers:
> > + - Michael Hennerich <[email protected]>
> > + - Nuno S? <[email protected]>
>
> Would be great to get an ack from these two.

Looks good to me.

Acked-by: Michael Hennerich <[email protected]>

> Otherwise looks fine to me.
>
> Best regards
> Uwe
>
> --
> Pengutronix e.K. | Uwe Kleine-K?nig |
> Industrial Linux Solutions | https://www.pengutronix.de/ |

2024-04-11 10:42:34

by Nuno Sá

[permalink] [raw]
Subject: Re: [PATCH 1/2 v4] dt-bindings: pwm: Add AXI PWM generator

On Fri, 2024-03-01 at 12:33 -0500, Trevor Gamblin wrote:
> From: Drew Fustini <[email protected]>
>
> Add Analog Devices AXI PWM generator.
>
> Link: https://wiki.analog.com/resources/fpga/docs/axi_pwm_gen
> Signed-off-by: Drew Fustini <[email protected]>
> Reviewed-by: Krzysztof Kozlowski <[email protected]>
> Co-developed-by: Trevor Gamblin <[email protected]>
> Signed-off-by: Trevor Gamblin <[email protected]>
> ---

Acked-by: Nuno Sa <[email protected]>

> v4 changes: None (rebased, added maintainer's previous Reviewed-by)
> v3 changes: None (rebased, added maintainer's previous Reviewed-by)
>
> v2 changes:
> * Address feedback for driver and device tree in v1:
>   * Relocate "unevaluatedProperties" in device tree binding
>   * Remove redundant "bindings for" in description
>
> ---
>  .../bindings/pwm/adi,axi-pwmgen.yaml          | 48 +++++++++++++++++++
>  MAINTAINERS                                   |  8 ++++
>  2 files changed, 56 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
>
> diff --git a/Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
> b/Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
> new file mode 100644
> index 000000000000..63461920a362
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
> @@ -0,0 +1,48 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/pwm/adi,axi-pwmgen.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Analog Devices AXI PWM generator
> +
> +maintainers:
> +  - Michael Hennerich <[email protected]>
> +  - Nuno Sá <[email protected]>
> +
> +description:
> +  The Analog Devices AXI PWM generator can generate PWM signals
> +  with variable pulse width and period.
> +
> +  https://wiki.analog.com/resources/fpga/docs/axi_pwm_gen
> +
> +allOf:
> +  - $ref: pwm.yaml#
> +
> +properties:
> +  compatible:
> +    const: adi,axi-pwmgen-1.00.a
> +
> +  reg:
> +    maxItems: 1
> +
> +  "#pwm-cells":
> +    const: 2
> +
> +  clocks:
> +    maxItems: 1
> +
> +required:
> +  - reg
> +  - clocks
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +    pwm@44b00000 {
> +       compatible = "adi,axi-pwmgen-1.00a";
> +       reg = <0x44b00000 0x1000>;
> +       clocks = <&spi_clk>;
> +       #pwm-cells = <2>;
> +    };
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 8d1052fa6a69..8a4ed5545680 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -3431,6 +3431,14 @@ W: https://ez.analog.com/linux-software-drivers
>  F: Documentation/devicetree/bindings/spi/adi,axi-spi-engine.yaml
>  F: drivers/spi/spi-axi-spi-engine.c
>  
> +AXI PWM GENERATOR
> +M: Michael Hennerich <[email protected]>
> +M: Nuno Sá <[email protected]>
> +L: [email protected]
> +S: Supported
> +W: https://ez.analog.com/linux-software-drivers
> +F: Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
> +
>  AXXIA I2C CONTROLLER
>  M: Krzysztof Adamski <[email protected]>
>  L: [email protected]