Update designware pwm driver
Subsystems (3)
v14 cover Update designware pwm driver
From: Xuyang Dong <[email protected]>
There is already a patch [1] for the DesignWare PWM driver, which is posted by Ben and still under review. Based on this patch, this series is a continuation of [1] to add support for IP versions 2.11a and later, which includes support for "Pulse Width Modulation with 0% and 100% Duty Cycle".
Supported chips:
ESWIN EIC7700 series SoC.
Test:
Tested this patch on the Sifive HiFive Premier P550 (which uses the EIC7700 SoC).
[1] https://lore.kernel.org/lkml/[email protected]/
Updates:
Changes in v14:
- YAML:
- Add 'Reviewed-by: Krzysztof Kozlowski <[email protected]>' for patch 1.
- Drop minItems of reset-names property.
- Add the resets and reset-names properties and restrictions for other compatible strings.
- Driver:
- Remove MODULE_ALIAS() (Sashiko review of v13).
- Update the commit message and comment for patch 5.
The exclusive reset references must be retained for the lifetime of the timer: the hardware keeps running after init, and holding the references keeps the resets deasserted, preventing other devices on the bus from re-asserting them (Sashiko review of v13).
- Link to v13: https://lore.kernel.org/all/[email protected]/
Changes in v13:
- YAML:
- Dropped Conor's Acked-by due to significant schema changes for patch 1 and 2.
- Add 'Acked-by: Krzysztof Kozlowski <[email protected]>' for patch 4.
- Add a reset-names property in snps,dw-apb-timers-pwm2.yaml.
- Add description "Combined APB interface and timer logic reset" for the eswin,eic7700-pwm resets property, because the single entry is the combined interface bus and timer logic reset.
- Mark reset-names as not applicable (reset-names: false) for this compatible, since there is only one reset.
- Driver:
- Remove the structure 'dwc_pwm_plat_data', because it is not needed to distinguish whether to support resets.
- Drop reset_required and use devm_reset_control_array_get_optional_exclusive().
- Replace dev_err() with dev_err_probe() in the probe function.
- Add patch 5 for dw_apb_timer_of.c. Replace of_reset_control_get() with of_reset_control_array_get_optional_exclusive() to get both resets from the device tree (Sashiko review of v12).
- Link to v12: https://lore.kernel.org/all/[email protected]/
Changes in v12:
- YAML:
- Update snps,dw-apb-timer binding to allow up to two reset lines (Sashiko review of v11).
- Driver:
- Update the boundary check to match hardware specification. Check the low and high boundary no more than 1 << 32 (Sashiko review of v11).
- Replace "dwc->feature" with "ctrl" in dwc_pwm_get_state(). Check DWC_TIM_CTRL_0N100PWM_EN bit from the hardware control register to determine the actual timing formula in use (Sashiko review of v11).
- Save the initial hardware state into dwc->ctx in probe() before clocks are gated (Sashiko review of v11).
- Link to v11: https://lore.kernel.org/all/[email protected]/
Changes in v11:
- YAML:
- The timer binding does not need to be updated
(Sashiko review of v10).
- Driver:
- Mask the interrupt by setting the DWC_TIM_CTRL_INT_MASK bit (Sashiko review of v10).
- Call pm_runtime_disable() before manually rolling back the clock state (Sashiko review of v10).
Drop pm_runtime_resume_and_get() and pm_runtime_put_sync(). Access registers and disable clocks only in the resumed state.
- Remove reset assert in remove function, as disabling PM and clocks prevents further operation (Sashiko review of v10).
- Link to v10: https://lore.kernel.org/all/[email protected]/
Changes in v10:
- Driver:
- Do not add a dependency on PM. Additionally, the issues below will be fixed to ensure compatibility with and without PM support (Sashiko review of v9).
- Note that writes to dwc->clk_rate in apply()/get_state() cannot race due to PWM core's chip->nonatomic_lock (Sashiko review of v9).
- Fix __dwc_pwm_configure_timer() precision loss from dual rounding (compute period_cyc once); reject sub-clock-cycle periods in 0N100 mode (add !period_cyc check to avoid writing 0 to LD_CNT/LD_CNT2).
- dwc_pwm_get_state():
Fix pm_runtime_resume_and_get() error check to use 'if (ret < 0)' to allow stub return value 1 when CONFIG_PM=n.
- Deassert reset before reading MMIO in probe() to avoid bus stalls on SoCs that leave the block in reset (Sashiko review of v9).
- Keep clocks enabled when CONFIG_PM=n.
Condition the clock gating on IS_ENABLED(CONFIG_PM) (Sashiko review of v9).
- Move register save/restore into runtime PM callbacks. Replace legacy suspend/resume with pm_runtime_force_suspend()/resume() to properly manage the generic power domain.
- Link to v9: https://lore.kernel.org/all/[email protected]/
Changes in v9:
- YAML:
- Add 'Acked-by: Conor Dooley <[email protected]>' for patch 1 and 2.
- Driver:
- __dwc_pwm_configure_timer():
reads state->polarity and swaps registers:
NORMAL (active-high): duty_cycle to DWC_TIM_LD_CNT2 (HIGH), remainder to DWC_TIM_LD_CNT (LOW)
INVERSED (active-low): duty_cycle to DWC_TIM_LD_CNT (LOW), remainder to DWC_TIM_LD_CNT2 (HIGH)
Applies to both 0N100 and classic paths.
dwc_pwm_apply():
removed -EINVAL polarity guard; both polarities accepted. dwc_pwm_get_state():
reconstructs polarity from pwm->state.polarity (last apply() value); initial read zero-initialized to PWM_POLARITY_NORMAL; decode mirrors apply() swap logic for consistent round-trip (Sashiko review of v8).
- Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() in dwc_pwm_apply() and add error checking (Sashiko review of v8).
- Add a non-zero check for clk_rate in dwc_pwm_get_state(). Add a non-zero check for dwc->clk_rate in probe (Sashiko review of v8).
- When pwm_en is true, adding 'goto disable_clk;'. When pwm_en is false, return early from pm_disable without falling through to disable_clk. (Sashiko review of v8).
- Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() in dwc_pwm_plat_remove() and add error checking.
On failure, skip register reads and pm_runtime_put_sync() (Sashiko review of v8).
- Remove the -EBUSY check in dwc_pwm_suspend() and save all contexts (Sashiko review of v8).
- Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() in dwc_pwm_resume() (Sashiko review of v8).
- Link to v8: https://lore.kernel.org/all/[email protected]/
Changes in v8:
- YAML:
- Split the v7 binding into two patches.
Patch 1 explains why to add the resets property.
Patch 2 adds the eswin compatible string and specified reset.
- Driver:
- Use mul_u64_u64_div_u64() to safely scale the values and avoid 64-bit multiplication overflow in __dwc_pwm_configure_timer() and dwc_pwm_get_state().
Add the include for linux/math64.h (Sashiko review of v7).
- Keep the current usage of pwm->args.polarity until a better solution is available.
- Use pm_runtime_resume_and_get() in dwc_pwm_get_state() instead of pm_runtime_get_sync(), so that register access is skipped if the device fails to resume (Sashiko review of v7).
- Replace devm_pwmchip_add() with pwmchip_add() and move it after pm_runtime_enable(), so that the PWM chip is registered only after runtime PM has been fully initialized (Sashiko review of v7).
- Remove the reset_assert label and reset_control_assert() (Sashiko review of v7).
- Remove the pm_runtime_status_suspended() check and unconditionally use pm_runtime_get_sync() instead (Sashiko review of v7).
- Remove the pwm_en flag, but keep the pm_runtime_put_noidle() call (Sashiko review of v7; see email for explanation)
- Use pm_runtime_status_suspended() to check the runtime PM status. If the device is not suspended (i.e., active), call clk_disable_unprepare(). If it is suspended, skip this block (Sashiko review of v7).
- Use an explicit pwmchip_remove() as the first step of .remove(), instead of relying on devm_pwmchip_add() to unregister the chip after .remove() returns. This prevents the hardware teardown that follows from racing against a still-registered chip (Sashiko review of v7).
- Add a check for dwc->rst before asserting reset in the remove path (Sashiko review of v7).
- Drop the return value check from pm_runtime_put_sync() (Sashiko review of v7).
- Link to v7: https://lore.kernel.org/all/[email protected]/
Changes in v7:
- YAML:
- Dropped Conor's Acked-by due to significant schema changes.
- Rename patch 1 from "dt-bindings: pwm: dwc: add optional reset" to "dt-bindings: pwm: dwc: Add eswin compatible and resets property".
- Update the commit message to explain why the EIC7700 supports only one reset.
- Add constraints 'minItems: 1' and 'maxItems: 1' for the 'resets' property of eswin,eic7700-pwm.
- Add an example for eswin,eic7700-pwm.
- Link to v6: https://lore.kernel.org/all/[email protected]/
Changes in v6:
- YAML:
- Drop properties resets and its items description for eswin,eic7700-pwm.
- Link to v5: https://lore.kernel.org/all/[email protected]/
Changes in v5:
- YAML:
- Add 'eswin,eic7700-pwm' compatible string.
- Add the items description for the resets property and set minItems to 1.
- Require resets property with exactly 1 reset for eswin,eic7700-pwm compatible.
- Driver:
- Add support for 'eswin,eic7700-pwm' compatible.
- Add structure dwc_pwm_plat_data to manage the API for obtaining resets.
- Link to v4: https://lore.kernel.org/all/[email protected]/
Changes in v4:
- YAML:
- Change maxItems from 1 to 2. As there is a corresponding reset signal for each clock domain, the effective maxItems of the resets property is set to 2.
- Update the YAML commit message to describe the hardware.
- Driver:
- Replace devm_reset_control_get_optional_exclusive() with devm_reset_control_array_get_optional_exclusive(). Since the number of reset signals has increased from one to two, we need to use the array API to acquire them.
- Link to v3: https://lore.kernel.org/all/[email protected]/
Changes in v3:
- YAML:
- Added a clear justification for the optional resets property. It is required to support proper controller initialization when no PWM channel is active at boot time, while allowing the driver to skip reset deassertion if any channel is already enabled.
- Driver:
- Update the boundary value check of tmp in __dwc_pwm_configure_timer() for DWC_TIM_CTRL_0N100PWM_EN.
- Replace 'sizeof(struct dwc_pwm_drvdata)' with 'struct_size(data, chips, 1)'.
- Drop devm_clk_get_enabled() in favor of devm_clk_get() with explicit clk_prepare_enable() and clk_disable_unprepare() allowing runtime PM to manage clock state.
- Replace devm_reset_control_get_optional_exclusive_deasserted() with devm_reset_control_get_optional_exclusive() and issue a full reset via reset_control_reset() only when no PWM channel is active at probe time.
- Detect bootloader-enabled PWM channels by reading the enable bit, and initialize runtime PM as active for those channels by calling pm_runtime_set_active() and pm_runtime_get_noresume().
- Remove autosuspend as it is not required for this driver.
- Use explicit pm_runtime_enable() and pm_runtime_disable() instead of the managed devm_pm_runtime_enable() variant to ensure correct cleanup.
- On device removal, recheck the channel enable status. If any channel remains active, call pm_runtime_put_noidle() before disabling clocks via clk_disable_unprepare().
Resume device before register access during removal if it is runtime suspended, and re-suspend it afterward.
- If device is suspended, resume it before register access during system resume/suspend.
- Use pm_ptr() instead of pm_sleep_ptr() for correct PM operation.
- Link to v2: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- YAML:
- Remove eswin,eic7700-pwm.yaml. Use snps,dw-apb-timers-pwm2.yaml. The description in snps,dw-apb-timers-pwm2.yaml is better.
- Add the resets property as optional, as defined in the databook.
- Remove snps,pwm-full-range-enable as no additional property is needed.
- Driver:
- Change the file from pwm-dwc-eic7700.c to pwm-dwc-of.c from [1].
- Define DWC_TIM_VERSION_ID_2_11A 2.11a as the baseline version.
- Enable the 0% and 100% duty cycle mode by setting dwc->feature if the version read from the TIMERS_COMP_VERSION register is later than or equal to DWC_TIM_VERSION_ID_2_11A.
- Use the DIV_ROUND_UP_ULL() to calculate width in the .apply and .get_state.
- Additionally, Power Management (PM) support has been added to the pwm-dwc-of.c driver.
- Drop the headers that are not used.
- Use devm_clk_get_enabled() instead of devm_clk_get().
- Drop of_match_ptr.
- Fix build error with 1ULL << 32.
- Link to v1: https://lore.kernel.org/all/[email protected]/
- Link to v9: https://lore.kernel.org/lkml/[email protected]/
Xuyang Dong (5):
dt-bindings: pwm: dwc: Document optional resets property
dt-bindings: pwm: dwc: Add eswin compatible
pwm: dwc: add of/platform support
dt-bindings: timer: dwc: Update resets property items
clocksource: dw_apb_timer: Use reset array API to handle all resets
.../bindings/pwm/snps,dw-apb-timers-pwm2.yaml | 50 ++- .../bindings/timer/snps,dw-apb-timer.yaml | 5 +- drivers/clocksource/dw_apb_timer_of.c | 9 +- drivers/pwm/Kconfig | 10 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-dwc-core.c | 172 ++++++++-- drivers/pwm/pwm-dwc-of.c | 298 ++++++++++++++++++ drivers/pwm/pwm-dwc.h | 25 +- 8 files changed, 524 insertions(+), 46 deletions(-) create mode 100644 drivers/pwm/pwm-dwc-of.c
--
2.34.1
PATCH v14 1/5 dt-bindings: pwm: dwc: Document optional resets property
From: Xuyang Dong <[email protected]>
The DesignWare PWM IP has two active-low reset inputs: presetn resets the register interface logic in the pclk (bus) domain, and timer_N_resetn resets the counter/timer logic in the timer_N_clk domain. The existing snps,dw-apb-timers-pwm2 binding does not describe either of these lines.
Add the resets property and describe the function of each reset to support future use of resets. Add the reset-names property to allow independent control of the two reset signals.
--- .../bindings/pwm/snps,dw-apb-timers-pwm2.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/pwm/snps,dw-apb-timers-pwm2.yaml +10 -0
@@ -43,6 +43,16 @@ properties: - const: bus - const: timer + resets: + items: + - description: Interface bus (presetn) reset + - description: PWM timer logic (timer_N_resetn) reset + + reset-names: + items: + - const: bus + - const: timer + snps,pwm-number: $ref: /schemas/types.yaml#/definitions/uint32 description: The number of PWM channels configured for this instance
Signature · 1 line
2.34.1
PATCH v14 2/5 dt-bindings: pwm: dwc: Add eswin compatible
In reply to [email protected]From: Xuyang Dong <[email protected]>
EIC7700 integrates the DesignWare PWM IP described by the generic snps,dw-apb-timers-pwm2 binding. On this SoC, the presetn and timer_N_resetn inputs are physically tied together to a single reset line, so exactly one reset is both required and sufficient, unlike the generic binding where up to two independent lines are optional.
Add the eswin,eic7700-pwm compatible string and constrain its resets property to exactly one entry.
--- .../bindings/pwm/snps,dw-apb-timers-pwm2.yaml | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/pwm/snps,dw-apb-timers-pwm2.yaml +36 -4
@@ -20,12 +20,11 @@ description: instead of having to encode the IP version number in the device tree compatible. -allOf: - - $ref: pwm.yaml# - properties: compatible: - const: snps,dw-apb-timers-pwm2 + enum: + - snps,dw-apb-timers-pwm2 + - eswin,eic7700-pwm reg: maxItems: 1
@@ -44,6 +43,7 @@ properties: - const: timer resets: + minItems: 1 items: - description: Interface bus (presetn) reset - description: PWM timer logic (timer_N_resetn) reset
@@ -64,6 +64,29 @@ required: - clocks - clock-names +allOf: + - $ref: pwm.yaml# + + - if: + properties: + compatible: + contains: + const: eswin,eic7700-pwm + then: + properties: + resets: + items: + - description: Combined APB interface and timer logic reset + reset-names: false + required: + - resets + else: + properties: + resets: + minItems: 2 + reset-names: + minItems: 2 + additionalProperties: false examples:
@@ -75,3 +98,12 @@ examples: clocks = <&bus>, <&timer>; clock-names = "bus", "timer"; }; + - | + pwm@50818000 { + compatible = "eswin,eic7700-pwm"; + reg = <0x50818000 0x4000>; + #pwm-cells = <3>; + clocks = <&bus>, <&timer>; + clock-names = "bus", "timer"; + resets = <&reset>; + };
Signature · 1 line
2.34.1
PATCH v14 3/5 pwm: dwc: add of/platform support
In reply to [email protected]From: Xuyang Dong <[email protected]>
The dwc pwm controller can be used in non-PCI systems, so allow either platform or OF based probing.
The controller is reset only when no PWM channel is enabled. Otherwise, clocks are enabled and the runtime PM state is updated to reflect the active hardware configuration.
The DWC PWM controller does not provide a hardware polarity bit. Currently, the driver only supports active-low output, which is incompatible with devices requiring active-high waveforms (e.g., backlight controllers, fan speed regulators).
Implement polarity control by exploiting the timer's dual load registers. The hardware uses:
- LD_CNT: LOW period count
- LD_CNT2: HIGH period count
The total period is defined as (LD_CNT + LD_CNT2). By swapping the duty cycle between these registers, we invert the polarity while keeping the period unchanged:
- PWM_POLARITY_NORMAL: write duty_cycle to LD_CNT2 (HIGH period)
- PWM_POLARITY_INVERSED: write duty_cycle to LD_CNT (LOW period)
Implementation:
Update both apply() and get_state() to handle state->polarity consistently. Since the hardware does not store polarity, get_state() returns the last successfully applied software state, ensuring that read-back matches what was originally set.
--- drivers/pwm/Kconfig | 10 ++ drivers/pwm/Makefile | 1 + drivers/pwm/pwm-dwc-core.c | 172 +++++++++++++++++---- drivers/pwm/pwm-dwc-of.c | 298 +++++++++++++++++++++++++++++++++++++ drivers/pwm/pwm-dwc.h | 25 +++- 5 files changed, 467 insertions(+), 39 deletions(-) create mode 100644 drivers/pwm/pwm-dwc-of.c
drivers/pwm/Kconfig +10 -0
@@ -249,6 +249,16 @@ config PWM_DWC To compile this driver as a module, choose M here: the module will be called pwm-dwc. +config PWM_DWC_OF + tristate "DesignWare PWM Controller (OF bus)" + depends on HAS_IOMEM && (OF || COMPILE_TEST) + select PWM_DWC_CORE + help + PWM driver for Synopsys DWC PWM Controller on an OF bus or + a platform bus. + To compile this driver as a module, choose M here: the module + will be called pwm-dwc-of. + config PWM_EP93XX tristate "Cirrus Logic EP93xx PWM support" depends on ARCH_EP93XX || COMPILE_TEST
drivers/pwm/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_CROS_EC) += pwm-cros-ec.o obj-$(CONFIG_PWM_DWC_CORE) += pwm-dwc-core.o obj-$(CONFIG_PWM_DWC) += pwm-dwc.o +obj-$(CONFIG_PWM_DWC_OF) += pwm-dwc-of.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o obj-$(CONFIG_PWM_GPIO) += pwm-gpio.o
drivers/pwm/pwm-dwc-core.c +140 -32
239 lines not on this page · raw message
drivers/pwm/pwm-dwc-of.c new file +298 -0
298 lines not on this page · raw message
drivers/pwm/pwm-dwc.h +18 -7
@@ -26,12 +26,19 @@ MODULE_IMPORT_NS("dwc_pwm");#define DWC_TIMERS_TOTAL 8/* Timer Control Register */ -#define DWC_TIM_CTRL_EN BIT(0) -#define DWC_TIM_CTRL_MODE BIT(1) -#define DWC_TIM_CTRL_MODE_FREE (0 << 1) -#define DWC_TIM_CTRL_MODE_USER (1 << 1) -#define DWC_TIM_CTRL_INT_MASK BIT(2) -#define DWC_TIM_CTRL_PWM BIT(3) +#define DWC_TIM_CTRL_EN BIT(0) +#define DWC_TIM_CTRL_MODE BIT(1) +#define DWC_TIM_CTRL_MODE_FREE (0 << 1) +#define DWC_TIM_CTRL_MODE_USER BIT(1) +#define DWC_TIM_CTRL_INT_MASK BIT(2) +#define DWC_TIM_CTRL_PWM BIT(3) +#define DWC_TIM_CTRL_0N100PWM_EN BIT(4) + +/* +* The version 2.11a and later add "Pulse Width Modulation with +* 0% and 100% Duty Cycle". +*/ +#define DWC_TIM_VERSION_ID_2_11A 0x3231312astruct dwc_pwm_info {unsigned int nr;
@@ -52,8 +59,12 @@ struct dwc_pwm_ctx {struct dwc_pwm {void __iomem *base; -unsigned int clk_ns; +struct clk *bus_clk; +struct clk *clk; +unsigned long clk_rate; +struct reset_control *rst;struct dwc_pwm_ctx ctx[DWC_TIMERS_TOTAL ]; +u32 features; };static inline struct dwc_pwm *to_dwc_pwm (struct pwm_chip *chip)
Signature · 1 line
2.34.1
PATCH v14 4/5 dt-bindings: timer: dwc: Update resets property items
In reply to [email protected]From: Xuyang Dong <[email protected]>
The DesignWare DW_apb_timers IP has two active-low reset inputs:
presetn resets the register interface logic in the pclk (bus) domain, and timer_N_resetn resets the counter/timer logic in the timer_N_clk domain. The existing snps,dw-apb-timer binding only describes one.
Update snps,dw-apb-timer binding to allow up to two reset lines, matching the hardware capabilities of the DesignWare IP family.
--- .../devicetree/bindings/timer/snps,dw-apb-timer.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/timer/snps,dw-apb-timer.yaml +4 -1
@@ -25,7 +25,10 @@ properties: maxItems: 1 resets: - maxItems: 1 + minItems: 1 + items: + - description: Timer ticks reference (timer_N_resetn) reset + - description: APB interface (presetn) reset clocks: minItems: 1
Signature · 1 line
2.34.1
PATCH v14 5/5 clocksource: dw_apb_timer: Use reset array API to handle all resets
In reply to [email protected]From: Xuyang Dong <[email protected]>
timer_get_base_and_rate() only fetched a single, index-0 reset control via of_reset_control_get(np, NULL), which does not consult reset-names and always resolves to the first entry. With the binding now allowing a second entry (APB interface reset), a device tree that lists both lines would leave the second entry permanently unasserted, since the driver never touches it.
Replace it with of_reset_control_array_get_optional_exclusive() to fetch and trigger all reset lines listed in the device tree at once, ensuring every line is properly asserted and deasserted rather than only the first. The exclusive references are intentionally retained for the lifetime of the timer -- the hardware continues to operate after initialization, and holding the references keeps the resets deasserted, preventing other devices on the bus from re-asserting them while the timer is running.
--- drivers/clocksource/dw_apb_timer_of.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/clocksource/dw_apb_timer_of.c +7 -2
@@ -29,9 +29,14 @@ static int __init timer_get_base_and_rate(struct device_node *np,/* * Reset the timer if the reset control is available, wiping -* out the state the firmware may have left it +* out the state the firmware may have left it. +* Use the array variant to fetch and trigger all reset lines +* (e.g., timer and APB interface resets) together, without +* ordering requirements. +* The exclusive references are intentionally held to keep the +* resets deasserted while the timer is running. */ - rstc =of_reset_control_get (np,NULL ); + rstc =of_reset_control_array_get_optional_exclusive (np);if (!IS_ERR (rstc)) {reset_control_assert (rstc);reset_control_deassert (rstc);
--
2.34.1
[email protected]
AI reviewRe: [PATCH v14 2/5] dt-bindings: pwm: dwc: Add eswin compatible
In reply to [email protected]Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The conditional schema for `eswin,eic7700-pwm` fails to constrain the `resets` property to a…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The conditional schema for eswin,eic7700-pwm fails to constrain the resets property to a maximum of 1 item. --
--- Patch [2]: [PATCH v14 2/5] dt-bindings: pwm: dwc: Add eswin compatible --- commit 804c34afffe86d4a3ff253201b6470e700f1af47
Author: Xuyang Dong <[email protected]>
dt-bindings: pwm: dwc: Add eswin compatible
This commit adds the eswin,eic7700-pwm compatible string to the snps,dw-apb-timers-pwm2 binding. The EIC7700 integrates this IP but requires exactly one combined reset line instead of up to two independent lines.
Quoted 4 lines
Documentation/devicetree/bindings/pwm/snps,dw-apb-timers-pwm2.yaml +0
-0
[ ... ]
Quoted 7 lines
Documentation/devicetree/bindings/pwm/snps,dw-apb-timers-pwm2.yaml +3
-0@@ -64,6 +64,29 @@ required: - clocks - clock-names +allOf: + - $ref: pwm.yaml# +
Documentation/devicetree/bindings/pwm/snps,dw-apb-timers-pwm2.yaml required: · line 79
Quoted 10 lines
Documentation/devicetree/bindings/pwm/snps,dw-apb-timers-pwm2.yaml +10
-0+ - if: + properties: + compatible: + contains: + const: eswin,eic7700-pwm + then: + properties: + resets: + items: + - description: Combined APB interface and timer logic reset
[Severity: Medium]
Is it possible for a device tree to pass validation with two resets for this compatible, despite the intention in the commit message?
Because the top-level resets property implicitly allows up to 2 items, overriding the items list here with a single element doesn't automatically reduce the maximum allowed items.
Should maxItems: 1 be added explicitly in this block alongside items?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewRe: [PATCH v14 3/5] pwm: dwc: add of/platform support
In reply to [email protected]Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] dwc_pwm_runtime_resume() writes the EN bit and timer configuration simultaneously, violating the…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dwc_pwm_runtime_resume() writes the EN bit and timer configuration simultaneously, violating the hardware specification. --
--- Patch [3]: [PATCH v14 3/5] pwm: dwc: add of/platform support --- commit b441231de2fcc89e4187b672bde1919622ac7347
Author: Xuyang Dong <[email protected]>
pwm: dwc: add of/platform support
This commit adds platform and OF device tree support for the DesignWare PWM controller, enabling its use in non-PCI systems. It also implements polarity control using dual load registers and adds runtime PM callbacks to save and restore hardware state.
Quoted 5 lines
drivers/pwm/pwm-dwc-of.c new file +0
-0
[ ... ]
Quoted 2 lines
drivers/pwm/pwm-dwc-of.c new file +2
-0+static int dwc_pwm_runtime_resume (struct device *dev) +{
[ ... ]
drivers/pwm/pwm-dwc-of.c line 266
Quoted 4 lines
drivers/pwm/pwm-dwc-of.c new file +4
-0+for (idx =0 ; idx < chip->npwm; idx++) { +dwc_pwm_writel (dwc, dwc->ctx[idx].cnt,DWC_TIM_LD_CNT (idx)); +dwc_pwm_writel (dwc, dwc->ctx[idx].cnt2,DWC_TIM_LD_CNT2 (idx)); +dwc_pwm_writel (dwc, dwc->ctx[idx].ctrl,DWC_TIM_CTRL (idx));
[Severity: Medium]
Does writing the saved control register directly in dwc_pwm_runtime_resume() violate the hardware initialization sequence?
The driver notes in __dwc_pwm_configure_timer() that the specification requires disabling the timer, programming it, and then enabling it.
Since ctx[idx].ctrl may have the DWC_TIM_CTRL_EN bit set from when the device was active, does this single write attempt to configure and enable the timer simultaneously? Could this cause unpredictable behavior upon resume?
Quoted 4 lines
drivers/pwm/pwm-dwc-of.c new file +4
-0+ } + +return 0 ; +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
[email protected]
AI reviewRe: [PATCH v14 5/5] clocksource: dw_apb_timer: Use reset array API to handle all resets
In reply to [email protected]Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Exclusive acquisition of a shared bus reset blocks other devices on the bus from probing and may…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Exclusive acquisition of a shared bus reset blocks other devices on the bus from probing and may inadvertently reset the entire bus. --
--- Patch [5]: [PATCH v14 5/5] clocksource: dw_apb_timer: Use reset array API to handle all resets --- commit 66ef3e54cc1daa673ec2f6b658e0a17fb7f358ab
Author: Xuyang Dong <[email protected]>
clocksource: dw_apb_timer: Use reset array API to handle all resets
This commit updates the timer initialization to fetch and trigger all reset lines listed in the device tree using the array variant of the reset API. It intentionally holds exclusive references to these lines to keep them deasserted while the timer runs.
Quoted 7 lines
drivers/clocksource/dw_apb_timer_of.c +0
-0@@ -29,9 +29,14 @@ static int __init timer_get_base_and_rate(struct device_node *np,/* * Reset the timer if the reset control is available, wiping
drivers/clocksource/dw_apb_timer_of.c static int __init timer_get_base_and_rate(struct device_node *np, · line 39
Quoted 10 lines
drivers/clocksource/dw_apb_timer_of.c +7
-2-* out the state the firmware may have left it +* out the state the firmware may have left it. +* Use the array variant to fetch and trigger all reset lines +* (e.g., timer and APB interface resets) together, without +* ordering requirements. +* The exclusive references are intentionally held to keep the +* resets deasserted while the timer is running. */ - rstc =of_reset_control_get (np,NULL ); + rstc =of_reset_control_array_get_optional_exclusive (np);
[Severity: High]
If any of these reset lines are shared bus resets, does acquiring them exclusively lock out other devices that share the same reset line?
The commit message mentions APB interface resets, which are typically shared across multiple peripherals. If this driver holds a shared reset line exclusively, subsequent reset_control_get() calls from other drivers sharing the bus will fail with -EBUSY, preventing them from probing.
Furthermore, unconditionally asserting a shared bus reset here in timer_get_base_and_rate() might inadvertently reset other peripherals on the same bus that are already initialized. Does the timer driver need to use a shared reset API to avoid disrupting other devices on the bus?
Quoted 3 lines
drivers/clocksource/dw_apb_timer_of.c +0
-0if (!IS_ERR (rstc)) {reset_control_assert (rstc);reset_control_deassert (rstc);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: Re: [PATCH v14 2/5] dt-bindings: pwm: dwc: Add eswin compatible
In reply to [email protected]Quoted 33 lines
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The conditional schema foreswin,eic7700-pwmfails to constrain theresetsproperty to a maximum of 1 item. ----- Patch [2]: [PATCH v14 2/5] dt-bindings: pwm: dwc: Add eswin compatible --- commit
804c34afffe86d4a3ff253201b6470e700f1af47
Author: Xuyang Dong <[email protected]>dt-bindings: pwm: dwc: Add eswin compatible
This commit adds the eswin,eic7700-pwm compatible string to the snps,dw-apb-timers-pwm2 binding. The EIC7700 integrates this IP but requires exactly one combined reset line instead of up to two independent lines.
Quoted 4 lines
Documentation/devicetree/bindings/pwm/snps,dw-apb-timers-pwm2.yaml +0
-0[ ... ]
Quoted 13 lines
Documentation/devicetree/bindings/pwm/snps,dw-apb-timers-pwm2.yaml +9
-0@@ -64,6 +64,29 @@ required: - clocks - clock-names +allOf: + - $ref: pwm.yaml# + + - if: + properties: + compatible: + contains: + const: eswin,eic7700-pwm + then:
Quoted 9 lines
Documentation/devicetree/bindings/pwm/snps,dw-apb-timers-pwm2.yaml required: · line 79
Quoted 4 lines
Documentation/devicetree/bindings/pwm/snps,dw-apb-timers-pwm2.yaml +4
-0+ properties: + resets: + items: + - description: Combined APB interface and timer logic reset[Severity: Medium]
Is it possible for a device tree to pass validation with two resets for this compatible, despite the intention in the commit message?
Hi Sashiko,
Because we added an example for one reset.
If you add two resets for eswin,eic7700-pwm in a device tree, running "make dtbs_check" will report that the resets property is too long.
Quoted 6 lines
Because the top-level resets property implicitly allows up to 2 items, overriding the items list here with a single element doesn't automatically reduce the maximum allowed items.
Should maxItems: 1 be added explicitly in this block alongside items?
If we add "maxItems: 1", running "make dt_binding_check" will report that maxItems is not needed when an items list is already present.
Best regards,
Xuyang Dong
Quoted 2 lines
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: Re: [PATCH v14 3/5] pwm: dwc: add of/platform support
In reply to [email protected]Quoted 25 lines
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium]dwc_pwm_runtime_resume()writes the EN bit and timer configuration simultaneously, violating the hardware specification. ----- Patch [3]: [PATCH v14 3/5] pwm: dwc: add of/platform support --- commit
b441231de2fcc89e4187b672bde1919622ac7347
Author: Xuyang Dong <[email protected]>pwm: dwc: add of/platform support
This commit adds platform and OF device tree support for the DesignWare PWM controller, enabling its use in non-PCI systems. It also implements polarity control using dual load registers and adds runtime PM callbacks to save and restore hardware state.
Quoted 5 lines
drivers/pwm/pwm-dwc-of.c new file +0
-0[ ... ]
Quoted 2 lines
drivers/pwm/pwm-dwc-of.c new file +2
-0+static int dwc_pwm_runtime_resume (struct device *dev) +{[ ... ]
Quoted 9 lines
drivers/pwm/pwm-dwc-of.c line 266
Quoted 4 lines
drivers/pwm/pwm-dwc-of.c new file +4
-0+for (idx =0 ; idx < chip->npwm; idx++) { +dwc_pwm_writel (dwc, dwc->ctx[idx].cnt,DWC_TIM_LD_CNT (idx)); +dwc_pwm_writel (dwc, dwc->ctx[idx].cnt2,DWC_TIM_LD_CNT2 (idx)); +dwc_pwm_writel (dwc, dwc->ctx[idx].ctrl,DWC_TIM_CTRL (idx));[Severity: Medium]
Does writing the saved control register directly indwc_pwm_runtime_resume()violate the hardware initialization sequence?
Hi Sashiko,
No, because if the Load Count register is written after the control register, it will be updated after the timer is enabled.
Quoted 7 lines
The driver notes in
__dwc_pwm_configure_timer()that the specification requires disabling the timer, programming it, and then enabling it.Since ctx[idx].ctrl may have the
DWC_TIM_CTRL_ENbit set from when the device was active, does this single write attempt to configure and enable the timer simultaneously? Could this cause unpredictable behavior upon resume?
Although the single write attempts to configure and enable the timer simultaneously, the Load Count registers are updated before the timer is enabled. Therefore, this approach will not cause unpredictable behavior.
Best regards,
Xuyang Dong
Quoted 7 lines
Quoted 4 lines
drivers/pwm/pwm-dwc-of.c new file +4
-0+ } + +return 0 ; +}Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: Re: [PATCH v14 5/5] clocksource: dw_apb_timer: Use reset array API to handle all resets
In reply to [email protected]Quoted 21 lines
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Exclusive acquisition of a shared bus reset blocks other devices on the bus from probing and may inadvertently reset the entire bus. ----- Patch [5]: [PATCH v14 5/5] clocksource:
dw_apb_timer: Use reset array API to handle all resets --- commit66ef3e54cc1daa673ec2f6b658e0a17fb7f358ab
Author: Xuyang Dong <[email protected]>clocksource:
dw_apb_timer: Use reset array API to handle all resetsThis commit updates the timer initialization to fetch and trigger all reset lines listed in the device tree using the array variant of the reset API. It intentionally holds exclusive references to these lines to keep them deasserted while the timer runs.
Quoted 5 lines
drivers/clocksource/dw_apb_timer_of.c +0
-0@@ -29,9 +29,14 @@ static int __init timer_get_base_and_rate(struct device_node *np,
Quoted 17 lines
drivers/clocksource/dw_apb_timer_of.c static int __init timer_get_base_and_rate(struct device_node *np, · line 39
Quoted 12 lines
drivers/clocksource/dw_apb_timer_of.c +7
-2/* * Reset the timer if the reset control is available, wiping -* out the state the firmware may have left it +* out the state the firmware may have left it. +* Use the array variant to fetch and trigger all reset lines +* (e.g., timer and APB interface resets) together, without +* ordering requirements. +* The exclusive references are intentionally held to keep the +* resets deasserted while the timer is running. */ - rstc =of_reset_control_get (np,NULL ); + rstc =of_reset_control_array_get_optional_exclusive (np);[Severity: High]
If any of these reset lines are shared bus resets, does acquiring them exclusively lock out other devices that share the same reset line?
Hi Sashiko,
These reset lines should be exclusively owned by each timer.
Quoted 10 lines
The commit message mentions APB interface resets, which are typically shared across multiple peripherals. If this driver holds a shared reset line exclusively, subsequent
reset_control_get()calls from other drivers sharing the bus will fail with-EBUSY, preventing them from probing.Furthermore, unconditionally asserting a shared bus reset here in
timer_get_base_and_rate()might inadvertently reset other peripherals on the same bus that are already initialized. Does the timer driver need to use a shared reset API to avoid disrupting other devices on the bus?
If the resets are exclusive, do you think using the exclusive reset API is better?
Best regards,
Xuyang Dong
Quoted 6 lines
Quoted 3 lines
drivers/clocksource/dw_apb_timer_of.c +0
-0if (!IS_ERR (rstc)) {reset_control_assert (rstc);reset_control_deassert (rstc);Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH v14 2/5] dt-bindings: pwm: dwc: Add eswin compatible
In reply to [email protected]Quoted 8 lines · On Thu, Jul 30, 2026 at 07:15:34PM +0800, [email protected] wrote:
From: Xuyang Dong <[email protected]>
EIC7700 integrates the DesignWare PWM IP described by the generic snps,dw-apb-timers-pwm2 binding. On this SoC, the presetn and
timer_N_resetninputs are physically tied together to a single reset line, so exactly one reset is both required and sufficient, unlike the generic binding where up to two independent lines are optional.
Quoted 7 lines
Add the eswin,eic7700-pwm compatible string and constrain its resets property to exactly one entry.
Signed-off-by Xuyang Dong <[email protected]>--- .../bindings/pwm/snps,dw-apb-timers-pwm2.yaml | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-)
Best regards,
Krzysztof
Quoted 17 lines
There is already a patch [1] for the DesignWare PWM driver, which is posted by Ben and still under review. Based on this patch, this series is a continuation of [1] to add support for IP versions 2.11a and later, which includes support for "Pulse Width Modulation with 0% and 100% Duty Cycle".
Supported chips:
ESWIN EIC7700 series SoC.Test:
Tested this patch on the Sifive HiFive Premier P550 (which uses the EIC7700 SoC).
Quoted 16 lines
Updates:
Changes in v14:
- YAML:
- Add 'Reviewed-by: Krzysztof Kozlowski <[email protected]>' for patch 1.
- Drop minItems of reset-names property.
- Add the resets and reset-names properties and restrictions for other compatible strings.
- Driver:
- RemoveMODULE_ALIAS()(Sashiko review of v13).
- Update the commit message and comment for patch 5.
The exclusive reset references must be retained for the lifetime of the timer: the hardware keeps running after init, and holding the references keeps the resets deasserted, preventing other devices on the bus from re-asserting them (Sashiko review of v13).
Hi Uwe, Daniel, and Thomas,
Just a gentle reminder on this series. This patch series has received Reviewed-by and Acked-by tags from Krzysztof on the bindings portion. For the driver part, I have already responded to Sashiko's review comments and provided explanations.
Could you please help review the remaining patches? I would appreciate any further feedback or suggestions on how to proceed with this series.
Thanks for your time and attention.
Best regards,
Xuyang Dong
Quoted 18 lines
Quoted 18 lines
There is already a patch [1] for the DesignWare PWM driver, which is posted by Ben and still under review. Based on this patch, this series is a continuation of [1] to add support for IP versions 2.11a and later, which includes support for "Pulse Width Modulation with 0% and 100% Duty Cycle".
Supported chips:
ESWIN EIC7700 series SoC.Test:
Tested this patch on the Sifive HiFive Premier P550 (which uses the EIC7700 SoC).
Quoted 17 lines
Quoted 7 lines
Updates:
Changes in v14:
- YAML:
- Add 'Reviewed-by: Krzysztof Kozlowski <[email protected]>' for patch 1.
- Drop minItems of reset-names property.
- Add the resets and reset-names properties and restrictions forQuoted 9 lines
other compatible strings.
- Driver:
- RemoveMODULE_ALIAS()(Sashiko review of v13).
- Update the commit message and comment for patch 5.
The exclusive reset references must be retained for the lifetime of the timer: the hardware keeps running after init, and holding the references keeps the resets deasserted, preventing other devices on the bus from re-asserting them (Sashiko review of v13).
Hi Uwe, Daniel, Thomas and Philipp,
Just a friendly reminder regarding this series. Any feedback or comments?
We haven't received any comments yet, apart from the sashiko-bot (whose points were already addressed in previous versions).
Could you please help review the remaining patches? I would appreciate any feedback or suggestions on how to proceed with this series, or if there is anything else I should do to help move it forward.
Thanks for your time and attention.
Best regards,
Xuyang Dong