Skip to content

[PW_SID:955622] Change PWM-controlled LED pin active mode and algorithm#326

Closed
linux-riscv-bot wants to merge 5 commits into
workflow__riscv__fixesfrom
pw955622
Closed

[PW_SID:955622] Change PWM-controlled LED pin active mode and algorithm#326
linux-riscv-bot wants to merge 5 commits into
workflow__riscv__fixesfrom
pw955622

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

PR for series 955622 applied to workflow__riscv__fixes

Name: Change PWM-controlled LED pin active mode and algorithm
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=955622
Version: 12

nylon7 added 5 commits April 22, 2025 10:19
…active-low properties

This removes the active-low properties of the PWM-controlled LEDs in
the HiFive Unmatched device tree.

The reference is hifive-unleashed-a00.pdf[0] and hifive-unmatched-schematics-v3.pdf[1].

Link: https://sifive.cdn.prismic.io/sifive/c52a8e32-05ce-4aaf-95c8-7bf8453f8698_hifive-unleashed-a00-schematics-1.pdf [0]
Link: https://sifive.cdn.prismic.io/sifive/6a06d6c0-6e66-49b5-8e9e-e68ce76f4192_hifive-unmatched-schematics-v3.pdf [1]

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The `frac` variable represents the pulse inactive time, and the result
of this algorithm is the pulse active time. Therefore, we must reverse the result.

The reference is SiFive FU740-C000 Manual[0]

Link: https://sifive.cdn.prismic.io/sifive/1a82e600-1f93-4f41-b2d8-86ed8b16acba_fu740-c000-manual-v1p6.pdf [0]

Co-developed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Zong Li <zong.li@sifive.com>
Co-developed-by: Vincent Chen <vincent.chen@sifive.com>
Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
…y_state_debug function

Round the result to the nearest whole number. This ensures that real_period
is always a reasonable integer that is not lower than the actual value.

e.g.
$ echo 110 > /sys/devices/platform/led-controller-1/leds/d12/brightness
$ .apply is not idempotent (ena=1 pol=0 1739692/4032985) -> (ena=1 pol=0
1739630/4032985)

Co-developed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Fix PWM apply and get_state rounding to ensure consistency between
setting and reading values

This fixes the reported errors:
pwm-sifive 10021000.pwm: .apply is supposed to round down
duty_cycle (requested: 360/504000, applied: 361/504124)
pwm-sifive 10021000.pwm: .apply is supposed to round down
period (requested: 504000, applied: 504124)

Co-developed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The reference manual says "pwms >= pwmcmpX -> HIGH", but in Figure 29 pwmcmpXcenter
is forced to 0 via an XOR, so hardware actually outputs HIGH when pwms < pwmcmpX.
Thus pwmcmp holds the off-period count, and the driver must invert it
to expose a normal active-high interface.

Co-developed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v12,1/5] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 100.07 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v12,1/5] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 894.06 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v12,1/5] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1180.15 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v12,1/5] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 19.70 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v12,1/5] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 20.45 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v12,1/5] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.86 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v12,1/5] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 38.19 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v12,1/5] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v12,1/5] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties"
kdoc
Desc: Detects for kdoc errors
Duration: 0.88 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v12,1/5] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties"
module-param
Desc: Detect module_param changes
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v12,1/5] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v12,1/5] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.28 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v12,2/5] pwm: sifive: change the PWM algorithm"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 100.67 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v12,2/5] pwm: sifive: change the PWM algorithm"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 876.93 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v12,2/5] pwm: sifive: change the PWM algorithm"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1164.49 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v12,2/5] pwm: sifive: change the PWM algorithm"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 19.13 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v12,2/5] pwm: sifive: change the PWM algorithm"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 20.74 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v12,2/5] pwm: sifive: change the PWM algorithm"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.73 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v12,2/5] pwm: sifive: change the PWM algorithm"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 38.43 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v12,2/5] pwm: sifive: change the PWM algorithm"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v12,2/5] pwm: sifive: change the PWM algorithm"
kdoc
Desc: Detects for kdoc errors
Duration: 0.87 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v12,2/5] pwm: sifive: change the PWM algorithm"
module-param
Desc: Detect module_param changes
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v12,2/5] pwm: sifive: change the PWM algorithm"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v12,2/5] pwm: sifive: change the PWM algorithm"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.28 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v12,3/5] pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 99.01 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v12,3/5] pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function"
kdoc
Desc: Detects for kdoc errors
Duration: 0.84 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v12,3/5] pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function"
module-param
Desc: Detect module_param changes
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v12,3/5] pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v12,3/5] pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.28 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v12,4/5] pwm: sifive: Fix rounding issues in apply and get_state functions"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 100.47 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v12,4/5] pwm: sifive: Fix rounding issues in apply and get_state functions"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 612.35 seconds
Result: ERROR
Output:

Redirect to /build/tmp.UCM0pvv9Ri and /build/tmp.kFoRz4TGW9
Tree base:
19fcfce472df ("pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function")
Building the whole tree with the patch
error:
/build/tmpavd5s8x8/drivers/pwm/pwm-sifive.c:161:2: error: unterminated function-like macro invocation
/build/tmpavd5s8x8/drivers/pwm/pwm-sifive.c:351:26: error: expected '}'



real	10m6.242s
user	389m49.756s
sys	73m38.942s

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v12,4/5] pwm: sifive: Fix rounding issues in apply and get_state functions"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 876.26 seconds
Result: ERROR
Output:

Redirect to /build/tmp.x34ssRXuIT and /build/tmp.pLW27h4i32
Tree base:
19fcfce472df ("pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function")
Building the whole tree with the patch
error:
/build/tmpavd5s8x8/drivers/pwm/pwm-sifive.c:351:26: error: unterminated argument list invoking macro "do_div"
/build/tmpavd5s8x8/drivers/pwm/pwm-sifive.c:161:9: error: 'do_div' undeclared (first use in this function)
/build/tmpavd5s8x8/drivers/pwm/pwm-sifive.c:161:15: error: expected ';' at end of input
/build/tmpavd5s8x8/drivers/pwm/pwm-sifive.c:161:9: error: expected declaration or statement at end of input



real	14m29.996s
user	569m1.552s
sys	90m19.269s

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v12,4/5] pwm: sifive: Fix rounding issues in apply and get_state functions"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.12 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v12,4/5] pwm: sifive: Fix rounding issues in apply and get_state functions"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 21.55 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v12,4/5] pwm: sifive: Fix rounding issues in apply and get_state functions"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.71 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v12,4/5] pwm: sifive: Fix rounding issues in apply and get_state functions"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 37.94 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v12,4/5] pwm: sifive: Fix rounding issues in apply and get_state functions"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v12,4/5] pwm: sifive: Fix rounding issues in apply and get_state functions"
kdoc
Desc: Detects for kdoc errors
Duration: 0.80 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v12,4/5] pwm: sifive: Fix rounding issues in apply and get_state functions"
module-param
Desc: Detect module_param changes
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v12,4/5] pwm: sifive: Fix rounding issues in apply and get_state functions"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v12,4/5] pwm: sifive: Fix rounding issues in apply and get_state functions"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v12,5/5] pwm: sifive: clarify inverted compare logic in comments"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 99.84 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v12,5/5] pwm: sifive: clarify inverted compare logic in comments"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 612.46 seconds
Result: ERROR
Output:

Redirect to /build/tmp.sMTB9AdBII and /build/tmp.qBU2cItZbJ
Tree base:
d3c37a7caabf ("pwm: sifive: Fix rounding issues in apply and get_state functions")
Building the whole tree with the patch
error:
/build/tmpr21hf431/drivers/pwm/pwm-sifive.c:182:2: error: unterminated function-like macro invocation
/build/tmpr21hf431/drivers/pwm/pwm-sifive.c:373:26: error: expected '}'



real	10m6.148s
user	390m14.684s
sys	73m38.556s

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v12,5/5] pwm: sifive: clarify inverted compare logic in comments"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 876.98 seconds
Result: ERROR
Output:

Redirect to /build/tmp.kB78P6hIF4 and /build/tmp.hgPDm7GyrN
Tree base:
d3c37a7caabf ("pwm: sifive: Fix rounding issues in apply and get_state functions")
Building the whole tree with the patch
error:
/build/tmpr21hf431/drivers/pwm/pwm-sifive.c:373:26: error: unterminated argument list invoking macro "do_div"
/build/tmpr21hf431/drivers/pwm/pwm-sifive.c:182:9: error: 'do_div' undeclared (first use in this function)
/build/tmpr21hf431/drivers/pwm/pwm-sifive.c:182:15: error: expected ';' at end of input
/build/tmpr21hf431/drivers/pwm/pwm-sifive.c:182:9: error: expected declaration or statement at end of input



real	14m30.428s
user	569m3.008s
sys	90m52.134s

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v12,5/5] pwm: sifive: clarify inverted compare logic in comments"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.11 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v12,5/5] pwm: sifive: clarify inverted compare logic in comments"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 21.46 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v12,5/5] pwm: sifive: clarify inverted compare logic in comments"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.71 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v12,5/5] pwm: sifive: clarify inverted compare logic in comments"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 38.33 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v12,5/5] pwm: sifive: clarify inverted compare logic in comments"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v12,5/5] pwm: sifive: clarify inverted compare logic in comments"
kdoc
Desc: Detects for kdoc errors
Duration: 0.82 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v12,5/5] pwm: sifive: clarify inverted compare logic in comments"
module-param
Desc: Detect module_param changes
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v12,5/5] pwm: sifive: clarify inverted compare logic in comments"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v12,5/5] pwm: sifive: clarify inverted compare logic in comments"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.28 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot deleted the pw955622 branch April 23, 2025 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants