Skip to content

Commit 42bff4d

Browse files
committed
Merge tag 'pwm/for-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm
Pull pwm updates from Thierry Reding: "This contains a bunch of cleanups and simplifications across the board, as well as a number of small fixes. Perhaps the most notable change here is the addition of an API that allows PWMs to be used in atomic contexts, which is useful when time- critical operations are involved, such as using a PWM to generate IR signals. Finally, I have decided to step down as PWM subsystem maintainer. Due to other responsibilities I have lately not been able to find the time that the subsystem deserves and Uwe, who has been helping out a lot for the past few years and has many things planned for the future, has kindly volunteered to take over. I have no doubt that he will be a suitable replacement" * tag 'pwm/for-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (44 commits) MAINTAINERS: pwm: Thierry steps down, Uwe takes over pwm: linux/pwm.h: fix Excess kernel-doc description warning pwm: Add pwm_apply_state() compatibility stub pwm: cros-ec: Drop documentation for dropped struct member pwm: Drop two unused API functions pwm: lpc18xx-sct: Don't modify the cached period of other PWM outputs pwm: meson: Simplify using dev_err_probe() pwm: stmpe: Silence duplicate error messages pwm: Reduce number of pointer dereferences in pwm_device_request() pwm: crc: Use consistent variable naming for driver data pwm: omap-dmtimer: Drop locking dt-bindings: pwm: ti,pwm-omap-dmtimer: Update binding for yaml media: pwm-ir-tx: Trigger edges from hrtimer interrupt context pwm: bcm2835: Allow PWM driver to be used in atomic context pwm: Make it possible to apply PWM changes in atomic context pwm: renesas: Remove unused include pwm: Replace ENOTSUPP with EOPNOTSUPP pwm: Rename pwm_apply_state() to pwm_apply_might_sleep() pwm: Stop referencing pwm->chip pwm: Update kernel doc for struct pwm_chip ...
2 parents fef018d + 7afc0e7 commit 42bff4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+517
-365
lines changed

Documentation/devicetree/bindings/pwm/mediatek,pwm-disp.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ title: MediaTek DISP_PWM Controller
88

99
maintainers:
1010
- Jitao Shi <jitao.shi@mediatek.com>
11-
- Xinlei Lee <xinlei.lee@mediatek.com>
1211

1312
allOf:
1413
- $ref: pwm.yaml#

Documentation/devicetree/bindings/pwm/pwm-omap-dmtimer.txt

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/pwm/ti,omap-dmtimer-pwm.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: TI dual mode timer PWM controller
8+
9+
maintainers:
10+
- Tony Lindgren <tony@atomide.com>
11+
12+
description:
13+
TI dual mode timer instances have an IO pin for PWM capability
14+
15+
allOf:
16+
- $ref: pwm.yaml#
17+
18+
properties:
19+
compatible:
20+
const: ti,omap-dmtimer-pwm
21+
22+
"#pwm-cells":
23+
const: 3
24+
25+
ti,timers:
26+
description: Timer instance phandle for the PWM
27+
$ref: /schemas/types.yaml#/definitions/phandle
28+
29+
ti,prescaler:
30+
description: |
31+
Legacy clock prescaler for timer. The timer counter is prescaled
32+
with 2^n where n is the prescaler.
33+
$ref: /schemas/types.yaml#/definitions/uint32
34+
enum: [ 0, 1, 2, 3, 4, 5, 6, 7 ]
35+
deprecated: true
36+
37+
ti,clock-source:
38+
description: |
39+
Legacy clock for timer, please use assigned-clocks instead.
40+
0x00 - high-frequency system clock (timer_sys_ck)
41+
0x01 - 32-kHz always-on clock (timer_32k_ck)
42+
0x02 - external clock (timer_ext_ck, OMAP2 only)
43+
$ref: /schemas/types.yaml#/definitions/uint32
44+
enum: [ 0, 1, 2 ]
45+
deprecated: true
46+
47+
required:
48+
- compatible
49+
- ti,timers
50+
51+
unevaluatedProperties: false
52+
53+
examples:
54+
- |
55+
pwm9: pwm {
56+
compatible = "ti,omap-dmtimer-pwm";
57+
ti,timers = <&timer9>;
58+
#pwm-cells = <3>;
59+
};

Documentation/driver-api/pwm.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,20 @@ the getter, devm_pwm_get() and devm_fwnode_pwm_get(), also exist.
4141

4242
After being requested, a PWM has to be configured using::
4343

44-
int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state);
44+
int pwm_apply_might_sleep(struct pwm_device *pwm, struct pwm_state *state);
4545

4646
This API controls both the PWM period/duty_cycle config and the
4747
enable/disable state.
4848

49+
PWM devices can be used from atomic context, if the PWM does not sleep. You
50+
can check if this the case with::
51+
52+
bool pwm_might_sleep(struct pwm_device *pwm);
53+
54+
If false, the PWM can also be configured from atomic context with::
55+
56+
int pwm_apply_atomic(struct pwm_device *pwm, struct pwm_state *state);
57+
4958
As a consumer, don't rely on the output's state for a disabled PWM. If it's
5059
easily possible, drivers are supposed to emit the inactive state, but some
5160
drivers cannot. If you rely on getting the inactive state, use .duty_cycle=0,
@@ -57,13 +66,13 @@ If supported by the driver, the signal can be optimized, for example to improve
5766
EMI by phase shifting the individual channels of a chip.
5867

5968
The pwm_config(), pwm_enable() and pwm_disable() functions are just wrappers
60-
around pwm_apply_state() and should not be used if the user wants to change
69+
around pwm_apply_might_sleep() and should not be used if the user wants to change
6170
several parameter at once. For example, if you see pwm_config() and
6271
pwm_{enable,disable}() calls in the same function, this probably means you
63-
should switch to pwm_apply_state().
72+
should switch to pwm_apply_might_sleep().
6473

6574
The PWM user API also allows one to query the PWM state that was passed to the
66-
last invocation of pwm_apply_state() using pwm_get_state(). Note this is
75+
last invocation of pwm_apply_might_sleep() using pwm_get_state(). Note this is
6776
different to what the driver has actually implemented if the request cannot be
6877
satisfied exactly with the hardware in use. There is currently no way for
6978
consumers to get the actually implemented settings.

MAINTAINERS

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17645,12 +17645,11 @@ F: Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.yaml
1764517645
F: drivers/media/rc/pwm-ir-tx.c
1764617646

1764717647
PWM SUBSYSTEM
17648-
M: Thierry Reding <thierry.reding@gmail.com>
17649-
R: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
17648+
M: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
1765017649
L: linux-pwm@vger.kernel.org
1765117650
S: Maintained
1765217651
Q: https://patchwork.ozlabs.org/project/linux-pwm/list/
17653-
T: git git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm.git
17652+
T: git https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git
1765417653
F: Documentation/devicetree/bindings/gpio/gpio-mvebu.yaml
1765517654
F: Documentation/devicetree/bindings/pwm/
1765617655
F: Documentation/driver-api/pwm.rst
@@ -17660,7 +17659,7 @@ F: drivers/video/backlight/pwm_bl.c
1766017659
F: include/dt-bindings/pwm/
1766117660
F: include/linux/pwm.h
1766217661
F: include/linux/pwm_backlight.h
17663-
K: pwm_(config|apply_state|ops)
17662+
K: pwm_(config|apply_might_sleep|apply_atomic|ops)
1766417663

1766517664
PXA GPIO DRIVER
1766617665
M: Robert Jarzmik <robert.jarzmik@free.fr>

drivers/gpu/drm/i915/display/intel_backlight.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static void ext_pwm_set_backlight(const struct drm_connector_state *conn_state,
275275
struct intel_panel *panel = &to_intel_connector(conn_state->connector)->panel;
276276

277277
pwm_set_relative_duty_cycle(&panel->backlight.pwm_state, level, 100);
278-
pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state);
278+
pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state);
279279
}
280280

281281
static void
@@ -428,7 +428,7 @@ static void ext_pwm_disable_backlight(const struct drm_connector_state *old_conn
428428
intel_backlight_set_pwm_level(old_conn_state, level);
429429

430430
panel->backlight.pwm_state.enabled = false;
431-
pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state);
431+
pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state);
432432
}
433433

434434
void intel_backlight_disable(const struct drm_connector_state *old_conn_state)
@@ -750,7 +750,7 @@ static void ext_pwm_enable_backlight(const struct intel_crtc_state *crtc_state,
750750

751751
pwm_set_relative_duty_cycle(&panel->backlight.pwm_state, level, 100);
752752
panel->backlight.pwm_state.enabled = true;
753-
pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state);
753+
pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state);
754754
}
755755

756756
static void __intel_backlight_enable(const struct intel_crtc_state *crtc_state,

drivers/gpu/drm/solomon/ssd130x.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static int ssd130x_pwm_enable(struct ssd130x_device *ssd130x)
319319

320320
pwm_init_state(ssd130x->pwm, &pwmstate);
321321
pwm_set_relative_duty_cycle(&pwmstate, 50, 100);
322-
pwm_apply_state(ssd130x->pwm, &pwmstate);
322+
pwm_apply_might_sleep(ssd130x->pwm, &pwmstate);
323323

324324
/* Enable the PWM */
325325
pwm_enable(ssd130x->pwm);

drivers/hwmon/pwm-fan.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static int pwm_fan_power_on(struct pwm_fan_ctx *ctx)
151151
}
152152

153153
state->enabled = true;
154-
ret = pwm_apply_state(ctx->pwm, state);
154+
ret = pwm_apply_might_sleep(ctx->pwm, state);
155155
if (ret) {
156156
dev_err(ctx->dev, "failed to enable PWM\n");
157157
goto disable_regulator;
@@ -181,7 +181,7 @@ static int pwm_fan_power_off(struct pwm_fan_ctx *ctx)
181181

182182
state->enabled = false;
183183
state->duty_cycle = 0;
184-
ret = pwm_apply_state(ctx->pwm, state);
184+
ret = pwm_apply_might_sleep(ctx->pwm, state);
185185
if (ret) {
186186
dev_err(ctx->dev, "failed to disable PWM\n");
187187
return ret;
@@ -207,7 +207,7 @@ static int __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
207207

208208
period = state->period;
209209
state->duty_cycle = DIV_ROUND_UP(pwm * (period - 1), MAX_PWM);
210-
ret = pwm_apply_state(ctx->pwm, state);
210+
ret = pwm_apply_might_sleep(ctx->pwm, state);
211211
if (ret)
212212
return ret;
213213
ret = pwm_fan_power_on(ctx);
@@ -278,7 +278,7 @@ static int pwm_fan_update_enable(struct pwm_fan_ctx *ctx, long val)
278278
state,
279279
&enable_regulator);
280280

281-
pwm_apply_state(ctx->pwm, state);
281+
pwm_apply_might_sleep(ctx->pwm, state);
282282
pwm_fan_switch_power(ctx, enable_regulator);
283283
pwm_fan_update_state(ctx, 0);
284284
}

drivers/input/misc/da7280.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static int da7280_haptic_set_pwm(struct da7280_haptic *haptics, bool enabled)
352352
state.duty_cycle = period_mag_multi;
353353
}
354354

355-
error = pwm_apply_state(haptics->pwm_dev, &state);
355+
error = pwm_apply_might_sleep(haptics->pwm_dev, &state);
356356
if (error)
357357
dev_err(haptics->dev, "Failed to apply pwm state: %d\n", error);
358358

@@ -1175,7 +1175,7 @@ static int da7280_probe(struct i2c_client *client)
11751175
/* Sync up PWM state and ensure it is off. */
11761176
pwm_init_state(haptics->pwm_dev, &state);
11771177
state.enabled = false;
1178-
error = pwm_apply_state(haptics->pwm_dev, &state);
1178+
error = pwm_apply_might_sleep(haptics->pwm_dev, &state);
11791179
if (error) {
11801180
dev_err(dev, "Failed to apply PWM state: %d\n", error);
11811181
return error;

drivers/input/misc/pwm-beeper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static int pwm_beeper_on(struct pwm_beeper *beeper, unsigned long period)
3939
state.period = period;
4040
pwm_set_relative_duty_cycle(&state, 50, 100);
4141

42-
error = pwm_apply_state(beeper->pwm, &state);
42+
error = pwm_apply_might_sleep(beeper->pwm, &state);
4343
if (error)
4444
return error;
4545

@@ -138,7 +138,7 @@ static int pwm_beeper_probe(struct platform_device *pdev)
138138
/* Sync up PWM state and ensure it is off. */
139139
pwm_init_state(beeper->pwm, &state);
140140
state.enabled = false;
141-
error = pwm_apply_state(beeper->pwm, &state);
141+
error = pwm_apply_might_sleep(beeper->pwm, &state);
142142
if (error) {
143143
dev_err(dev, "failed to apply initial PWM state: %d\n",
144144
error);

0 commit comments

Comments
 (0)