[PATCH v9 2/4] pwm: opencores: Add PWM driver support
William Qiu
william.qiu at starfivetech.com
Wed Dec 13 01:27:26 PST 2023
On 2023/12/12 1:41, Rob Herring wrote:
> On Fri, Dec 8, 2023 at 3:42 AM William Qiu <william.qiu at starfivetech.com> wrote:
>>
>> Add driver for OpenCores PWM Controller. And add compatibility code
>> which based on StarFive SoC.
>>
>> Co-developed-by: Hal Feng <hal.feng at starfivetech.com>
>> Signed-off-by: Hal Feng <hal.feng at starfivetech.com>
>> Signed-off-by: William Qiu <william.qiu at starfivetech.com>
>> ---
>> MAINTAINERS | 7 ++
>> drivers/pwm/Kconfig | 12 ++
>> drivers/pwm/Makefile | 1 +
>> drivers/pwm/pwm-ocores.c | 229 +++++++++++++++++++++++++++++++++++++++
>> 4 files changed, 249 insertions(+)
>> create mode 100644 drivers/pwm/pwm-ocores.c
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 788be9ab5b73..7a11a22da09e 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -16204,6 +16204,13 @@ F: Documentation/i2c/busses/i2c-ocores.rst
>> F: drivers/i2c/busses/i2c-ocores.c
>> F: include/linux/platform_data/i2c-ocores.h
>>
>> +OPENCORES PWM DRIVER
>> +M: William Qiu <william.qiu at starfivetech.com>
>> +M: Hal Feng <hal.feng at starfivetech.com>
>> +S: Supported
>> +F: Documentation/devicetree/bindings/pwm/opencores,pwm.yaml
>> +F: drivers/pwm/pwm-ocores.c
>> +
>> OPENRISC ARCHITECTURE
>> M: Jonas Bonn <jonas at southpole.se>
>> M: Stefan Kristiansson <stefan.kristiansson at saunalahti.fi>
>> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
>> index 4b956d661755..d87e1bb350ba 100644
>> --- a/drivers/pwm/Kconfig
>> +++ b/drivers/pwm/Kconfig
>> @@ -444,6 +444,18 @@ config PWM_NTXEC
>> controller found in certain e-book readers designed by the original
>> design manufacturer Netronix.
>>
>> +config PWM_OCORES
>> + tristate "OpenCores PWM support"
>> + depends on HAS_IOMEM && OF
>> + depends on COMMON_CLK && RESET_CONTROLLER
>> + depends on ARCH_STARFIVE || COMPILE_TEST
>> + help
>> + If you say yes to this option, support will be included for the
>> + OpenCores PWM. For details see https://opencores.org/projects/ptc.
>> +
>> + To compile this driver as a module, choose M here: the module
>> + will be called pwm-ocores.
>> +
>> config PWM_OMAP_DMTIMER
>> tristate "OMAP Dual-Mode Timer PWM support"
>> depends on OF
>> diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
>> index c5ec9e168ee7..517c4f643058 100644
>> --- a/drivers/pwm/Makefile
>> +++ b/drivers/pwm/Makefile
>> @@ -40,6 +40,7 @@ obj-$(CONFIG_PWM_MICROCHIP_CORE) += pwm-microchip-core.o
>> obj-$(CONFIG_PWM_MTK_DISP) += pwm-mtk-disp.o
>> obj-$(CONFIG_PWM_MXS) += pwm-mxs.o
>> obj-$(CONFIG_PWM_NTXEC) += pwm-ntxec.o
>> +obj-$(CONFIG_PWM_OCORES) += pwm-ocores.o
>> obj-$(CONFIG_PWM_OMAP_DMTIMER) += pwm-omap-dmtimer.o
>> obj-$(CONFIG_PWM_PCA9685) += pwm-pca9685.o
>> obj-$(CONFIG_PWM_PXA) += pwm-pxa.o
>> diff --git a/drivers/pwm/pwm-ocores.c b/drivers/pwm/pwm-ocores.c
>> new file mode 100644
>> index 000000000000..996ca3805901
>> --- /dev/null
>> +++ b/drivers/pwm/pwm-ocores.c
>> @@ -0,0 +1,229 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * OpenCores PWM Driver
>> + *
>> + * https://opencores.org/projects/ptc
>> + *
>> + * Copyright (C) 2018-2023 StarFive Technology Co., Ltd.
>> + *
>> + * Limitations:
>> + * - The hardware only do inverted polarity.
>> + * - The hardware minimum period / duty_cycle is (1 / pwm_apb clock frequency) ns.
>> + * - The hardware maximum period / duty_cycle is (U32_MAX / pwm_apb clock frequency) ns.
>> + */
>> +
>> +#include <linux/clk.h>
>> +#include <linux/io.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/of_device.h>
>
> You probably don't need this header and the implicit includes it makes
> are dropped now in linux-next. Please check what you actually need and
> make them explicit.
>
> Rob
Will drop.
Thank you for spending time on this patchset.
Best Regards
William
More information about the linux-riscv
mailing list