From 31e2803cc935b32d65f9a1da3dffc54ef19cae1d Mon Sep 17 00:00:00 2001 From: Damon Ding Date: Tue, 4 Jan 2022 18:48:18 +0800 Subject: [PATCH] FROMLIST: pwm: gpio: Add a generic gpio based PWM driver This patch adds a bit-banging gpio PWM driver. It makes use of hrtimers, to allow nano-second resolution, though it obviously strongly depends on the switching speed of the gpio pins, hrtimer and system load. Each pwm node can have 1 or more "pwm-gpio" entries, which will be treated as pwm's as part of a pwm chip. Link: https://patchwork.ozlabs.org/project/linux-pwm/patch/1445895161-2317-8-git-send-email-o.schinagl@ultimaker.com/ Signed-off-by: Olliver Schinagl Signed-off-by: Damon Ding Change-Id: Ibdb28eca3239a3a8503c947667117a9b0e9427b9 --- drivers/pwm/Kconfig | 15 +++++++++++++++ drivers/pwm/Makefile | 1 + drivers/pwm/pwm-gpio.c | 1 - 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index ca5db43118d4..e60b5fc85fa4 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -181,6 +181,21 @@ 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 driver" + depends on OF + depends on GPIOLIB + help + Some platforms do not offer any hardware PWM capabilities but do have + General Purpose Input Output (GPIO) pins available. Using the kernels + High-Resolution Timer API this driver tries to toggle GPIO using the + generic kernel PWM framework. The maximum frequency and/or accuracy + is dependent on several factors such as system load and the maximum + speed a pin can be toggled at the hardware. + + 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 diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index cbdcd55d69ee..eea0216215a7 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_CROS_EC) += pwm-cros-ec.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 diff --git a/drivers/pwm/pwm-gpio.c b/drivers/pwm/pwm-gpio.c index 92963771d080..7ac10bf24ebf 100644 --- a/drivers/pwm/pwm-gpio.c +++ b/drivers/pwm/pwm-gpio.c @@ -157,7 +157,6 @@ static int gpio_pwm_probe(struct platform_device *pdev) pc->chip.npwm = 1; pc->chip.of_xlate = of_pwm_xlate_with_flags; pc->chip.of_pwm_n_cells = 3; - pc->chip.can_sleep = true; pc->gpiod = devm_gpiod_get(&pdev->dev, "pwm", GPIOD_OUT_LOW);