Add OpenCores PTC PWM support
Subsystems (3)
v25 cover Add OpenCores PTC PWM support
Add OpenCores PTC PWM driver which is used in StarFive JH7100/JH7110/JHB100 SoC.
I will maintain this pwm module in place of William.
Changes since v24:
- Acquire clock rate exclusivity with devm_clk_rate_exclusive_get() before caching the rate.
- Read and validate the clock rate after enabling the clock.
Changes since v23:
- Drop the Tested-by tag for the dt-bindings patch.
Changes since v22:
- Drop patch 2 since it is already merged.
- Drop the starfive,jhb100-pwm compatible from the dt-bindings, as the pwm module of JHB100 SoC differs slightly from the OpenCores PTC PWM module in polarity handling. The support for JHB100 SoC will be added in a separate patch.
- Move the polarity check later in .apply().
- Add comments for keeping the reference when the pwm is already enabled.
- Rebase on linux-next.
Changes since v21:
- Allow non-zero duty cycles shorter than one clock tick to round down to zero.
- Drop the .free() callback to preserve the PWM hardware state after pwm_put().
- Update the comment.
Changes since v20:
- Fix 0% duty cycle support.
Changes since v19:
- Drop the oneOf construct in dt-bindings.
- Address Sashiko AI review comments for the OpenCores PWM driver. In ocores_pwm_apply(), handling disable requests first, then calculating and validating period/duty for enable requests before taking a runtime PM reference or touching the hardware registers.
Changes since v18:
- Address Sashiko AI review comments for the OpenCores PWM driver.
- Fix runtime PM usage count handling on probe, error paths, PWM release and driver teardown.
- Reject period or duty cycle values below the hardware minimum.
- Restore PWM registers across system sleep resume.
- Return the real error from devm_pwmchip_alloc().
- Preserve bootloader-configured PWM state during probe and keep runtime PM active if the PWM is already enabled.
- Use synchronous runtime PM put before possible teardown.
Changes since v17:
- Simplify the code. Make it more readable.
- Restructure the driver to register the pwm chip for one pwm channel, because each OpenCores PTC IP core only supports one PWM channel. Drop starfive compatibles.
Add patches to fix the dt-bindings and device tree.
- Support runtime pm and system sleep pm.
- Disable the pwm module and reset the pwm counter before updating the period and duty cycle.
- Improve the descriptions.
- Update the dt-bindings maintainer to Hal Feng.
History:
v24: https://lore.kernel.org/all/[email protected]/
v23: https://lore.kernel.org/all/[email protected]/
v22: https://lore.kernel.org/all/[email protected]/
v21: https://lore.kernel.org/all/[email protected]/
v20: https://lore.kernel.org/all/[email protected]/
v19: https://lore.kernel.org/all/[email protected]/
v18: https://lore.kernel.org/all/[email protected]/
v17: https://lore.kernel.org/all/[email protected]/
Hal Feng (2):
dt-bindings: pwm: opencores: Update compatibles, examples and
maintainers
pwm: Add OpenCores PTC PWM driver
.../bindings/pwm/opencores,pwm.yaml | 5 +- MAINTAINERS | 6 + drivers/pwm/Kconfig | 12 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-ocores.c | 305 ++++++++++++++++++ 5 files changed, 326 insertions(+), 3 deletions(-) create mode 100644 drivers/pwm/pwm-ocores.c
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
Signature · 1 line
2.43.2
PATCH v25 1/2 dt-bindings: pwm: opencores: Update compatibles, examples and maintainers
Remove the jh8100 compatible since the JH8100 SoC has been canceled and will not be released.
Change the register size in examples to 0x10, since an OpenCores PTC IP has only 4 32-bit registers: CNTR, HRC, LRC and CTRL.
I will maintain this pwm module in place of William.
--- Documentation/devicetree/bindings/pwm/opencores,pwm.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/pwm/opencores,pwm.yaml +2 -3
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml# title: OpenCores PWM controller maintainers: - - William Qiu <[email protected]> + - Hal Feng <[email protected]> description: The OpenCores PTC ip core contains a PWM controller. When operating in PWM
@@ -23,7 +23,6 @@ properties: - enum: - starfive,jh7100-pwm - starfive,jh7110-pwm - - starfive,jh8100-pwm - const: opencores,pwm-v1 reg:
@@ -49,7 +48,7 @@ examples: - | pwm@12490000 { compatible = "starfive,jh7110-pwm", "opencores,pwm-v1"; - reg = <0x12490000 0x10000>; + reg = <0x12490000 0x10>; clocks = <&clkgen 181>; resets = <&rstgen 109>; #pwm-cells = <3>;
Signature · 1 line
2.43.2
PATCH v25 2/2 pwm: Add OpenCores PTC PWM driver
In reply to Hal FengAdd PWM driver for OpenCores PTC IP core.
--- MAINTAINERS | 6 + drivers/pwm/Kconfig | 12 ++ drivers/pwm/Makefile | 1 + drivers/pwm/pwm-ocores.c | 305 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 324 insertions(+) create mode 100644 drivers/pwm/pwm-ocores.c
MAINTAINERS +6 -0
@@ -21081,6 +21081,12 @@ 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: Hal Feng <[email protected]> +S: Supported +F: Documentation/devicetree/bindings/pwm/opencores,pwm.yaml +F: drivers/pwm/pwm-ocores.c + OPENRISC ARCHITECTURE M: Jonas Bonn <[email protected]> M: Stefan Kristiansson <[email protected]>
drivers/pwm/Kconfig +12 -0
@@ -546,6 +546,18 @@ config PWM_NTXEC controller found in certain e-book readers designed by the original design manufacturer Netronix. +config PWM_OCORES + tristate "OpenCores PTC PWM support" + depends on HAS_IOMEM && OF + depends on COMMON_CLK + depends on ARCH_STARFIVE || COMPILE_TEST + help + PWM driver for OpenCores PTC IP core. + 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
drivers/pwm/Makefile +1 -0
@@ -48,6 +48,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
drivers/pwm/pwm-ocores.c new file +305 -0
305 lines not on this page · raw message
Signature · 1 line
2.43.2