Skip to content

Commit c371f62

Browse files
committed
Merge tag 'pwm/for-7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux
Pull pwm updates from Uwe Kleine-König: "There are a few patches adapting to changes in Rust land which seems to be the norm since there is a pwm driver written in Rust. Other than that just a few cleanups and a single fix for the tiehrpwm driver that came in too late for making it into v6.19. Thanks to Andy Shevchenko, Bartosz Golaszewski, Daniel Almeida and Michal Wilczynski for reviews in this cycle, and to Alice Ryhl, Ben Zong-You Xie, Gokul Praveen, Kari Argillander, Markus Probst, Raag Jadav, Shankari Anand, Tamir Duberstein and Vladimir Zapolskiy for code contributions" * tag 'pwm/for-7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux: pwm: Remove redundant check in pwm_ops_check() pwm: tiehrpwm: Enable pwmchip's parent device before setting configuration pwm: Update MAINTAINER entry rust: pwm: Add __rust_helper to helpers rust: pwm: Simplify to_result call sites and unsafe blocks rust: pwm: Fix potential memory leak on init error dt-bindings: pwm: nxp,lpc32xx-pwm: Specify clocks property as mandatory pwm: th1520: Replace `kernel::c_str!` with C-Strings pwm: dwc: Use size macro pwm: Emit native configuration in /sys/kernel/debug/pwm rust: pwm: Add UnregisteredChip wrapper around Chip rust: pwm: Update ARef and AlwaysRefCounted imports to use sync::aref
2 parents e86dda7 + 9321f9d commit c371f62

8 files changed

Lines changed: 103 additions & 81 deletions

File tree

Documentation/devicetree/bindings/pwm/nxp,lpc3220-pwm.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ properties:
2727
required:
2828
- compatible
2929
- reg
30+
- clocks
3031
- '#pwm-cells'
3132

3233
allOf:
@@ -36,9 +37,12 @@ unevaluatedProperties: false
3637

3738
examples:
3839
- |
40+
#include <dt-bindings/clock/lpc32xx-clock.h>
41+
3942
pwm@4005c000 {
4043
compatible = "nxp,lpc3220-pwm";
4144
reg = <0x4005c000 0x4>;
45+
clocks = <&clk LPC32XX_CLK_PWM1>;
4246
#pwm-cells = <3>;
4347
};
4448

MAINTAINERS

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21151,16 +21151,14 @@ L: linux-pwm@vger.kernel.org
2115121151
S: Maintained
2115221152
Q: https://patchwork.ozlabs.org/project/linux-pwm/list/
2115321153
T: git https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git
21154-
F: Documentation/devicetree/bindings/gpio/gpio-mvebu.yaml
2115521154
F: Documentation/devicetree/bindings/pwm/
2115621155
F: Documentation/driver-api/pwm.rst
21157-
F: drivers/gpio/gpio-mvebu.c
2115821156
F: drivers/pwm/
21159-
F: drivers/video/backlight/pwm_bl.c
2116021157
F: include/dt-bindings/pwm/
2116121158
F: include/linux/pwm.h
21162-
F: include/linux/pwm_backlight.h
2116321159
K: pwm_(config|apply_might_sleep|apply_atomic|ops)
21160+
K: (devm_)?pwmchip_(add|alloc|remove)
21161+
K: pwm_(round|get|set)_waveform
2116421162

2116521163
PWM SUBSYSTEM BINDINGS [RUST]
2116621164
M: Michal Wilczynski <m.wilczynski@samsung.com>

drivers/pwm/core.c

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,8 +1699,7 @@ static bool pwm_ops_check(const struct pwm_chip *chip)
16991699

17001700
if (ops->write_waveform) {
17011701
if (!ops->round_waveform_tohw ||
1702-
!ops->round_waveform_fromhw ||
1703-
!ops->write_waveform)
1702+
!ops->round_waveform_fromhw)
17041703
return false;
17051704

17061705
if (PWM_WFHWSIZE < ops->sizeof_wfhw) {
@@ -2638,10 +2637,10 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
26382637

26392638
for (i = 0; i < chip->npwm; i++) {
26402639
struct pwm_device *pwm = &chip->pwms[i];
2641-
struct pwm_state state, hwstate;
2640+
struct pwm_state state;
2641+
int err;
26422642

26432643
pwm_get_state(pwm, &state);
2644-
pwm_get_state_hw(pwm, &hwstate);
26452644

26462645
seq_printf(s, " pwm-%-3d (%-20.20s):", i, pwm->label);
26472646

@@ -2657,9 +2656,26 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
26572656
seq_puts(s, ", usage_power");
26582657
seq_puts(s, "\n");
26592658

2660-
seq_printf(s, " actual configuration: %3sabled, %llu/%llu ns, %s polarity",
2661-
hwstate.enabled ? "en" : "dis", hwstate.duty_cycle, hwstate.period,
2662-
hwstate.polarity ? "inverse" : "normal");
2659+
if (pwmchip_supports_waveform(chip)) {
2660+
struct pwm_waveform wf;
2661+
2662+
err = pwm_get_waveform_might_sleep(pwm, &wf);
2663+
if (!err)
2664+
seq_printf(s, " actual configuration: %lld/%lld [+%lld]",
2665+
wf.duty_length_ns, wf.period_length_ns, wf.duty_offset_ns);
2666+
else
2667+
seq_printf(s, " actual configuration: read out error: %pe\n", ERR_PTR(err));
2668+
} else {
2669+
struct pwm_state hwstate;
2670+
2671+
err = pwm_get_state_hw(pwm, &hwstate);
2672+
if (!err)
2673+
seq_printf(s, " actual configuration: %3sabled, %llu/%llu ns, %s polarity",
2674+
hwstate.enabled ? "en" : "dis", hwstate.duty_cycle, hwstate.period,
2675+
hwstate.polarity ? "inverse" : "normal");
2676+
else
2677+
seq_printf(s, " actual configuration: read out error: %pe", ERR_PTR(err));
2678+
}
26632679

26642680
seq_puts(s, "\n");
26652681
}

drivers/pwm/pwm-dwc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
#include <linux/pci.h>
2323
#include <linux/pm_runtime.h>
2424
#include <linux/pwm.h>
25+
#include <linux/sizes.h>
2526

2627
#include "pwm-dwc.h"
2728

2829
/* Elkhart Lake */
2930
static const struct dwc_pwm_info ehl_pwm_info = {
3031
.nr = 2,
31-
.size = 0x1000,
32+
.size = SZ_4K,
3233
};
3334

3435
static int dwc_pwm_init_one(struct device *dev, struct dwc_pwm_drvdata *ddata, unsigned int idx)

drivers/pwm/pwm-tiehrpwm.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,6 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
237237
if (period_cycles < 1)
238238
period_cycles = 1;
239239

240-
pm_runtime_get_sync(pwmchip_parent(chip));
241-
242240
/* Update clock prescaler values */
243241
ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_CLKDIV_MASK, tb_divval);
244242

@@ -290,8 +288,6 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
290288
if (!(duty_cycles > period_cycles))
291289
ehrpwm_write(pc->mmio_base, cmp_reg, duty_cycles);
292290

293-
pm_runtime_put_sync(pwmchip_parent(chip));
294-
295291
return 0;
296292
}
297293

@@ -378,6 +374,8 @@ static int ehrpwm_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
378374
int err;
379375
bool enabled = pwm->state.enabled;
380376

377+
guard(pm_runtime_active)(pwmchip_parent(chip));
378+
381379
if (state->polarity != pwm->state.polarity) {
382380
if (enabled) {
383381
ehrpwm_pwm_disable(chip, pwm);

drivers/pwm/pwm_th1520.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
2323
use core::ops::Deref;
2424
use kernel::{
25-
c_str,
2625
clk::Clk,
2726
device::{Bound, Core, Device},
2827
devres,
@@ -327,7 +326,7 @@ kernel::of_device_table!(
327326
OF_TABLE,
328327
MODULE_OF_TABLE,
329328
<Th1520PwmPlatformDriver as platform::Driver>::IdInfo,
330-
[(of::DeviceId::new(c_str!("thead,th1520-pwm")), ())]
329+
[(of::DeviceId::new(c"thead,th1520-pwm"), ())]
331330
);
332331

333332
impl platform::Driver for Th1520PwmPlatformDriver {
@@ -372,7 +371,7 @@ impl platform::Driver for Th1520PwmPlatformDriver {
372371
}),
373372
)?;
374373

375-
pwm::Registration::register(dev, chip)?;
374+
chip.register()?;
376375

377376
Ok(Th1520PwmPlatformDriver)
378377
}

rust/helpers/pwm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
#include <linux/pwm.h>
66

7-
struct device *rust_helper_pwmchip_parent(const struct pwm_chip *chip)
7+
__rust_helper struct device *rust_helper_pwmchip_parent(const struct pwm_chip *chip)
88
{
99
return pwmchip_parent(chip);
1010
}
1111

12-
void *rust_helper_pwmchip_get_drvdata(struct pwm_chip *chip)
12+
__rust_helper void *rust_helper_pwmchip_get_drvdata(struct pwm_chip *chip)
1313
{
1414
return pwmchip_get_drvdata(chip);
1515
}
1616

17-
void rust_helper_pwmchip_set_drvdata(struct pwm_chip *chip, void *data)
17+
__rust_helper void rust_helper_pwmchip_set_drvdata(struct pwm_chip *chip, void *data)
1818
{
1919
pwmchip_set_drvdata(chip, data);
2020
}

0 commit comments

Comments
 (0)