Skip to contentSkip to conversation

pwm: pwm-gpio: Generic GPIO bit-banged PWM driver

PATCH In review Angelo Compagnucci 4 participants 5 messages Dec 22, 2020 – Jan 17, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm: pwm-gpio: Generic GPIO bit-banged PWM driver

This patch adds a driver to generate a PWM signal on a generic GPIO pin. Driver can use hrtimers when available to allow nano-second resolution, the precision of the resulting signal depends on the switching speed of the gpio pins, timers and the system load.

---
 .../devicetree/bindings/pwm/pwm-gpio.txt      |  14 +
 drivers/pwm/Kconfig                           |  10 +
 drivers/pwm/Makefile                          |   1 +
 drivers/pwm/pwm-gpio.c                        | 244 ++++++++++++++++++
 4 files changed, 269 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/pwm-gpio.txt
 create mode 100644 drivers/pwm/pwm-gpio.c
Documentation/devicetree/bindings/pwm/pwm-gpio.txt new file +14 -0
new file mode 100644
index 000000000000..fe15569c0332
@@ -0,0 +1,14 @@
+Generic GPIO bit-banged PWM driver
+
+Required properties:
+  - compatible: should be "pwm-gpio"
+  - pwm-gpio: gpio describing the used gpio, see the gpio
+    bindings for the used gpio driver.
+
+Example:
+#include <dt-bindings/gpio/gpio.h>
+
+	pwm: pwm@0 {
+		compatible = "pwm-gpio";
+		pwm-gpio = <&pio 7 1 GPIO_ACTIVE_LOW>;
+	};
drivers/pwm/Kconfig +10 -0
index 0937e1c047ac..47c8b68a5f13 100644
@@ -195,6 +195,16 @@ config PWM_FSL_FTM
 	  To compile this driver as a module, choose M here: the module
 	  will be called pwm-fsl-ftm.
 
+config PWM_GPIO
+	tristate "Generic GPIO bit-banged PWM support"
+	depends on GPIOLIB
+	depends on PWM
+	help
+	  Driver to generate soft PWM on GPIO pin.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called pwm-gpio.
+
 config PWM_HIBVT
 	tristate "HiSilicon BVT PWM support"
 	depends on ARCH_HISI || COMPILE_TEST
drivers/pwm/Makefile +1 -0
index 18b89d7fd092..4d2aad6eb3bc 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_PWM_CROS_EC)	+= pwm-cros-ec.o
 obj-$(CONFIG_PWM_DWC)		+= pwm-dwc.o
 obj-$(CONFIG_PWM_EP93XX)	+= pwm-ep93xx.o
 obj-$(CONFIG_PWM_FSL_FTM)	+= pwm-fsl-ftm.o
+obj-$(CONFIG_PWM_GPIO)		+= pwm-gpio.o
 obj-$(CONFIG_PWM_HIBVT)		+= pwm-hibvt.o
 obj-$(CONFIG_PWM_IMG)		+= pwm-img.o
 obj-$(CONFIG_PWM_IMX1)		+= pwm-imx1.o
drivers/pwm/pwm-gpio.c new file +244 -0

244 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw

Hello,

there are currently two patches with the same goal ready for review on the linux-pwm list:

- https://lore.kernel.org/r/[email protected]
- https://lore.kernel.org/r/[email protected]

    (i.e. this one)

In my eyes the former is the better one, so @Angelo: Maybe you can join forces with Nicola and work on his patch set.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
maintainer
#2 lore raw
Quoted 6 lines · Uwe Kleine-König

Hello,

there are currently two patches with the same goal ready for review on the linux-pwm list:

Quoted 6 lines

- https://lore.kernel.org/r/[email protected]
- https://lore.kernel.org/r/[email protected]

    (i.e. this one)

In my eyes the former is the better one, so @Angelo: Maybe you can join forces with Nicola and work on his patch set.

Neither one went to DT list, so they're not in my queue. Though v1 of Nicola's did go to the list.

Rob

maintainer
#3 lore raw
Quoted 13 lines · Rob Herring
Quoted 10 lines · Uwe Kleine-König

Hello,

there are currently two patches with the same goal ready for review on the linux-pwm list:

- https://lore.kernel.org/r/[email protected]
- https://lore.kernel.org/r/[email protected]

    (i.e. this one)
Quoted 5 lines
Quoted 2 lines

In my eyes the former is the better one, so @Angelo: Maybe you can join forces with Nicola and work on his patch set.

Neither one went to DT list, so they're not in my queue. Though v1 of Nicola's did go to the list.

And there's a 3rd one from Vincent that I already reviewed:

https://lore.kernel.org/linux-devicetree/[email protected]/

And one from 5 years ago...:

https://lore.kernel.org/patchwork/patch/612159/