pwm: airoha: Add support for EN7581 SoC
PATCH v24 1/1 pwm: airoha: Add support for EN7581 SoC
From: Benjamin Larsson <[email protected]>
Introduce driver for PWM module available on EN7581 SoC.
Limitations:
- Only 8 concurrent waveform generators are available for 8 combinations of duty_cycle and period. Waveform generators are shared between 16 GPIO pins and 17 SIPO GPIO pins.
- Supports only normal polarity.
- On configuration the currently running period is completed.
- Minimum supported period is 4 ms
- Maximum supported period is 1s
---
Changes v24:
- Align to NUMBER space UNIT standard for comments
- Drop redundant rounddown
- Fix bucket logic selection
Changes v23:
- Fix typo in airoha_pwm_config where period and duty variables order was swapped
Changes v22:
- Drop do_div and use raw / and %
- Drop refcount.h include
Changes v21:
- Revert offset to u64 in airoha_pwm_apply_bucket_config (do_div require u64)
Changes v20:
- Add Review tag
- Drop duty normalization
- Drop mutex usage
- Use non-atomic bit OPs
- Use unsigned int for offset and bucket in airoha_pwm_apply_bucket_config
Changes v19:
- Fix copyright update
- Drop use of refcount and use mutex + simple counter
Changes v18:
- Fix not inizialized period_ns
- Update copyright name
- Improve define and comments
- Add array_size.h
- Better handle refcount in airoha_pwm_consume_generator
Changes v17:
- Drop math64.h patch
- Move to rounddown()
- Use u32 for period_ns (after clamp)
- Use ticks in inner function and for buckets
Changes v16:
- Always check regmap return
- Add missing header
- Use bitmask APIs
- Use refcount instead of raw u64
- Fix spelling mistake and improve text
- Drop OF dependency
- Drop redundant always true if condition
- Add myself as Author
Changes v15:
- Fix compilation error for 64bit division on 32bit (patch 01)
- Add prefer async probe
Changes v14:
- Fix logic for bucket recycle
(was tested by not releasing the bucket and observing
the best one gets used)
- Assign bucket period and duty only if not used
- Skip bucket period/duty calculation if already used
- Permit disable also if inversed polarity is asked
- Normalize duty similar to period
Changes v13:
- Reorder include
- Split ticks_from_ns function
- Add additional comments for shift register chip clock
- Address suggested minor optimization (Uwe)
Changes v12:
- Make shift function more readable
- Use unsigned int where possible
- Better comment some SIPO strangeness
- Move SIPO init after flash map config
- Retrun real values in get_state instead of the one saved in bucket
- Improve period_ns parsing so we can better share generators
Changes v11:
- Fix wrong calculation of period and duty
- Use AIROHA_PWM prefix for each define
- Drop set/get special define in favour of BITS and GENMASK
- Correctly use dev_err_probe
- Init bucket with initial values
- Rework define to make use of FIELD_PREP and FIELD_GET
Changes in v10:
- repost just patch 6/6 (pwm driver) since patches {1/6-5/6} have been already applied in linux-pinctrl tree
- pwm: introduce AIROHA_PWM_FIELD_GET and AIROHA_PWM_FIELD_SET macros to get/set field with non-const mask
- pwm: simplify airoha_pwm_get_generator() to report unused generator
and remove double lookup
- pwm: remove device_node pointer in airoha_pwm struct since this is write-only field
- pwm: cosmetics
- Link to v9: https://lore.kernel.org/r/[email protected]
Changes in v9:
- pwm: remove unused properties
- Link to v8: https://lore.kernel.org/r/[email protected]
Changes in v8:
- pwm: add missing properties documentation
- Link to v7: https://lore.kernel.org/r/[email protected]
Changes in v7:
- pinctrl: cosmetics
- pinctrl: fix compilation warning
- Link to v6: https://lore.kernel.org/r/[email protected]
Changes in v6:
- pwm: rely on regmap APIs
- pwm: introduce compatible string
- pinctrl: introduce compatible string
- remove airoha-mfd driver
- add airoha,en7581-pinctrl binding
- add airoha,en7581-pwm binding
- update airoha,en7581-gpio-sysctl binding
- Link to v5: https://lore.kernel.org/r/[email protected]
Changes in v5:
- use spin_lock in airoha_pinctrl_rmw instead of a mutex since it can run
in interrupt context
- remove unused includes in pinctrl driver
- since the irq_chip is immutable, allocate the gpio_irq_chip struct statically in pinctrl driver
- rely on regmap APIs in pinctrl driver but keep the spin_lock local to the driver
- rely on guard/guard_scope APIs in pinctrl driver
- improve naming convention pinctrl driver
- introduce airoha_pinconf_set_pin_value utility routine
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- add 'Limitation' description in pwm driver
- fix comments in pwm driver
- rely on mfd->base __iomem pointer in pwm driver, modify register
offsets according to it and get rid of sgpio_cfg, flash_cfg and
cycle_cfg pointers
- simplify register utility routines in pwm driver
- use 'generator' instead of 'waveform' suffix for pwm routines
- fix possible overflow calculating duty cycle in pwm driver
- do not modify pwm state in free callback in pwm driver
- cap the maximum period in pwm driver
- do not allow inverse polarity in pwm driver
- do not set of_xlate callback in the pwm driver and allow the stack to
do it
- fix MAINTAINERS file for airoha pinctrl driver
- fix undefined reference to __ffsdi2 in pinctrl driver
- simplify airoha,en7581-gpio-sysctl.yam binding
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- introduce airoha-mfd driver
- add pwm driver to the same series
- model pinctrl and pwm drivers as childs of a parent mfd driver.
- access chip-scu memory region in pinctrl driver via syscon
- introduce a single airoha,en7581-gpio-sysctl.yaml binding and get rid
of dedicated bindings for pinctrl and pwm
- add airoha,en7581-chip-scu.yaml binding do the series
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Fix compilation errors
- Collapse some register mappings for gpio and irq controllers
- update dt-bindings according to new register mapping
- fix some dt-bindings errors
- Link to v1: https://lore.kernel.org/all/[email protected]/
drivers/pwm/Kconfig | 10 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-airoha.c | 622 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 633 insertions(+) create mode 100644 drivers/pwm/pwm-airoha.c
drivers/pwm/Kconfig +10 -0
@@ -54,6 +54,16 @@ config PWM_ADP5585 This option enables support for the PWM function found in the Analog Devices ADP5585. +config PWM_AIROHA + tristate "Airoha PWM support" + depends on ARCH_AIROHA || COMPILE_TEST + select REGMAP_MMIO + help + Generic PWM framework driver for Airoha SoC. + + To compile this driver as a module, choose M here: the module + will be called pwm-airoha. + config PWM_APPLE tristate "Apple SoC PWM support" depends on ARCH_APPLE || COMPILE_TEST
drivers/pwm/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-$(CONFIG_PWM) += core.o obj-$(CONFIG_PWM_AB8500) += pwm-ab8500.o obj-$(CONFIG_PWM_ADP5585) += pwm-adp5585.o +obj-$(CONFIG_PWM_AIROHA) += pwm-airoha.o obj-$(CONFIG_PWM_APPLE) += pwm-apple.o obj-$(CONFIG_PWM_ATMEL) += pwm-atmel.o obj-$(CONFIG_PWM_ATMEL_HLCDC_PWM) += pwm-atmel-hlcdc.o
drivers/pwm/pwm-airoha.c new file +622 -0
622 lines not on this page · raw message
Signature · 1 line
2.51.0
Uwe Kleine-König
maintainerHello Christian,
Quoted 13 lines · Christian Marangi
From: Benjamin Larsson <[email protected]>
Introduce driver for PWM module available on EN7581 SoC.
Limitations:
- Only 8 concurrent waveform generators are available for 8 combinations ofduty_cycleand period. Waveform generators are shared between 16 GPIO pins and 17 SIPO GPIO pins.
- Supports only normal polarity.
- On configuration the currently running period is completed.
- Minimum supported period is 4 ms
- Maximum supported period is 1s
Quoted 7 lines
Signed-off-by Benjamin Larsson <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Co-developed-by Lorenzo Bianconi <[email protected]>Signed-off-by Lorenzo Bianconi <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>Co-developed-by Christian Marangi <[email protected]>Signed-off-by Christian Marangi <[email protected]>
I still have the impression that the bucket selection is more complicated than necessary, but I don't want to delay this patch further, so I applied it to
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next as 6.19-rc1 material.
Thanks for your perseverance,
Uwe