Skip to content

Commit 89b7fd5

Browse files
committed
Merge tag 'pwm/for-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm
Pull pwm updates from Thierry Reding: "The bulk of this is trivial conversions to the new .remove_new() callback for drivers as part of Uwe's effort to clean that up. Other than that a driver is added for Apple devices and various small fixes are included for existing drivers. Last but not least, this finally gets rid of the old pwm_request() and pwm_free() APIs are removed since the last user was dropped in v6.3" * tag 'pwm/for-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (44 commits) pwm: Remove unused radix tree pwm: Delete deprecated functions pwm_request() and pwm_free() pwm: meson: Fix g12a ao clk81 name pwm: meson: Fix axg ao mux parents pwm: stm32: Enforce settings for PWM capture MAINTAINERS: Add entries for Apple PWM driver pwm: Add Apple PWM controller dt-bindings: pwm: Add Apple PWM controller pwm: mtk-disp: Configure double buffering before reading in .get_state() pwm: mtk-disp: Disable shadow registers before setting backlight values pwm: stm32-lp: Drop of_match_ptr for ID table pwm: rcar: Drop of_match_ptr for ID table dt-bindings: pwm: Convert Amlogic Meson PWM binding dt-bindings: pwm: mediatek: Add mediatek,mt7986 compatible pwm: xilinx: Convert to platform remove callback returning void pwm: vt8500: Convert to platform remove callback returning void pwm: tiehrpwm: Convert to platform remove callback returning void pwm: tiecap: Convert to platform remove callback returning void pwm: tegra: Convert to platform remove callback returning void pwm: sun4i: Convert to platform remove callback returning void ...
2 parents 4c9818d + 247ee6c commit 89b7fd5

44 files changed

Lines changed: 397 additions & 252 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/pwm/apple,s5l-fpwm.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Apple FPWM controller
8+
9+
maintainers:
10+
- asahi@lists.linux.dev
11+
- Sasha Finkelstein <fnkl.kernel@gmail.com>
12+
13+
description: PWM controller used for keyboard backlight on ARM Macs
14+
15+
properties:
16+
compatible:
17+
items:
18+
- enum:
19+
- apple,t8103-fpwm
20+
- apple,t6000-fpwm
21+
- apple,t8112-fpwm
22+
- const: apple,s5l-fpwm
23+
24+
reg:
25+
maxItems: 1
26+
27+
clocks:
28+
maxItems: 1
29+
30+
power-domains:
31+
maxItems: 1
32+
33+
"#pwm-cells":
34+
const: 2
35+
36+
required:
37+
- compatible
38+
- reg
39+
- clocks
40+
41+
additionalProperties: false
42+
43+
examples:
44+
- |
45+
pwm@235044000 {
46+
compatible = "apple,t8103-fpwm", "apple,s5l-fpwm";
47+
reg = <0x35044000 0x4000>;
48+
power-domains = <&ps_fpwm1>;
49+
clocks = <&clkref>;
50+
#pwm-cells = <2>;
51+
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ properties:
2222
- mediatek,mt7623-pwm
2323
- mediatek,mt7628-pwm
2424
- mediatek,mt7629-pwm
25+
- mediatek,mt7986-pwm
2526
- mediatek,mt8183-pwm
2627
- mediatek,mt8365-pwm
2728
- mediatek,mt8516-pwm
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/pwm/pwm-amlogic.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Amlogic PWM
8+
9+
maintainers:
10+
- Heiner Kallweit <hkallweit1@gmail.com>
11+
12+
allOf:
13+
- $ref: pwm.yaml#
14+
15+
properties:
16+
compatible:
17+
oneOf:
18+
- enum:
19+
- amlogic,meson8b-pwm
20+
- amlogic,meson-gxbb-pwm
21+
- amlogic,meson-gxbb-ao-pwm
22+
- amlogic,meson-axg-ee-pwm
23+
- amlogic,meson-axg-ao-pwm
24+
- amlogic,meson-g12a-ee-pwm
25+
- amlogic,meson-g12a-ao-pwm-ab
26+
- amlogic,meson-g12a-ao-pwm-cd
27+
- amlogic,meson-s4-pwm
28+
- items:
29+
- const: amlogic,meson-gx-pwm
30+
- const: amlogic,meson-gxbb-pwm
31+
- items:
32+
- const: amlogic,meson-gx-ao-pwm
33+
- const: amlogic,meson-gxbb-ao-pwm
34+
- items:
35+
- const: amlogic,meson8-pwm
36+
- const: amlogic,meson8b-pwm
37+
38+
reg:
39+
maxItems: 1
40+
41+
clocks:
42+
minItems: 1
43+
maxItems: 2
44+
45+
clock-names:
46+
oneOf:
47+
- items:
48+
- enum: [clkin0, clkin1]
49+
- items:
50+
- const: clkin0
51+
- const: clkin1
52+
53+
"#pwm-cells":
54+
const: 3
55+
56+
required:
57+
- compatible
58+
- reg
59+
60+
additionalProperties: false
61+
62+
examples:
63+
- |
64+
pwm@8550 {
65+
compatible = "amlogic,meson-gxbb-pwm";
66+
reg = <0x08550 0x10>;
67+
clocks = <&xtal>, <&xtal>;
68+
clock-names = "clkin0", "clkin1";
69+
#pwm-cells = <3>;
70+
};

Documentation/devicetree/bindings/pwm/pwm-meson.txt

Lines changed: 0 additions & 29 deletions
This file was deleted.

Documentation/driver-api/pwm.rst

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@ consumers to providers, as given in the following example::
3535
Using PWMs
3636
----------
3737

38-
Legacy users can request a PWM device using pwm_request() and free it
39-
after usage with pwm_free().
40-
41-
New users should use the pwm_get() function and pass to it the consumer
42-
device or a consumer name. pwm_put() is used to free the PWM device. Managed
43-
variants of the getter, devm_pwm_get() and devm_fwnode_pwm_get(), also exist.
38+
Consumers use the pwm_get() function and pass to it the consumer device or a
39+
consumer name. pwm_put() is used to free the PWM device. Managed variants of
40+
the getter, devm_pwm_get() and devm_fwnode_pwm_get(), also exist.
4441

4542
After being requested, a PWM has to be configured using::
4643

@@ -165,8 +162,8 @@ consumers should implement it as described in the "Using PWMs" section.
165162
Locking
166163
-------
167164

168-
The PWM core list manipulations are protected by a mutex, so pwm_request()
169-
and pwm_free() may not be called from an atomic context. Currently the
165+
The PWM core list manipulations are protected by a mutex, so pwm_get()
166+
and pwm_put() may not be called from an atomic context. Currently the
170167
PWM core does not enforce any locking to pwm_enable(), pwm_disable() and
171168
pwm_config(), so the calling context is currently driver specific. This
172169
is an issue derived from the former barebone API and should be fixed soon.

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,6 +1961,7 @@ F: Documentation/devicetree/bindings/nvmem/apple,efuses.yaml
19611961
F: Documentation/devicetree/bindings/pci/apple,pcie.yaml
19621962
F: Documentation/devicetree/bindings/pinctrl/apple,pinctrl.yaml
19631963
F: Documentation/devicetree/bindings/power/apple*
1964+
F: Documentation/devicetree/bindings/pwm/pwm-apple.yaml
19641965
F: Documentation/devicetree/bindings/watchdog/apple,wdt.yaml
19651966
F: arch/arm64/boot/dts/apple/
19661967
F: drivers/bluetooth/hci_bcm4377.c
@@ -1976,6 +1977,7 @@ F: drivers/mailbox/apple-mailbox.c
19761977
F: drivers/nvme/host/apple.c
19771978
F: drivers/nvmem/apple-efuses.c
19781979
F: drivers/pinctrl/pinctrl-apple-gpio.c
1980+
F: drivers/pwm/pwm-apple.c
19791981
F: drivers/soc/apple/*
19801982
F: drivers/watchdog/apple_wdt.c
19811983
F: include/dt-bindings/interrupt-controller/apple-aic.h

drivers/pwm/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ config PWM_AB8500
5151
To compile this driver as a module, choose M here: the module
5252
will be called pwm-ab8500.
5353

54+
config PWM_APPLE
55+
tristate "Apple SoC PWM support"
56+
depends on ARCH_APPLE || COMPILE_TEST
57+
help
58+
Generic PWM framework driver for PWM controller present on
59+
Apple SoCs
60+
61+
Say Y here if you have an ARM Apple laptop, otherwise say N
62+
63+
To compile this driver as a module, choose M here: the module
64+
will be called pwm-apple.
65+
5466
config PWM_ATMEL
5567
tristate "Atmel PWM support"
5668
depends on ARCH_AT91 || COMPILE_TEST

drivers/pwm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
obj-$(CONFIG_PWM) += core.o
33
obj-$(CONFIG_PWM_SYSFS) += sysfs.o
44
obj-$(CONFIG_PWM_AB8500) += pwm-ab8500.o
5+
obj-$(CONFIG_PWM_APPLE) += pwm-apple.o
56
obj-$(CONFIG_PWM_ATMEL) += pwm-atmel.o
67
obj-$(CONFIG_PWM_ATMEL_HLCDC_PWM) += pwm-atmel-hlcdc.o
78
obj-$(CONFIG_PWM_ATMEL_TCB) += pwm-atmel-tcb.o

drivers/pwm/core.c

Lines changed: 3 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,11 @@
2828
static DEFINE_MUTEX(pwm_lookup_lock);
2929
static LIST_HEAD(pwm_lookup_list);
3030

31-
/* protects access to pwm_chips, allocated_pwms, and pwm_tree */
31+
/* protects access to pwm_chips and allocated_pwms */
3232
static DEFINE_MUTEX(pwm_lock);
3333

3434
static LIST_HEAD(pwm_chips);
3535
static DECLARE_BITMAP(allocated_pwms, MAX_PWMS);
36-
static RADIX_TREE(pwm_tree, GFP_KERNEL);
37-
38-
static struct pwm_device *pwm_to_device(unsigned int pwm)
39-
{
40-
return radix_tree_lookup(&pwm_tree, pwm);
41-
}
4236

4337
/* Called with pwm_lock held */
4438
static int alloc_pwms(unsigned int count)
@@ -59,14 +53,6 @@ static int alloc_pwms(unsigned int count)
5953
/* Called with pwm_lock held */
6054
static void free_pwms(struct pwm_chip *chip)
6155
{
62-
unsigned int i;
63-
64-
for (i = 0; i < chip->npwm; i++) {
65-
struct pwm_device *pwm = &chip->pwms[i];
66-
67-
radix_tree_delete(&pwm_tree, pwm->pwm);
68-
}
69-
7056
bitmap_clear(allocated_pwms, chip->base, chip->npwm);
7157

7258
kfree(chip->pwms);
@@ -307,8 +293,6 @@ int pwmchip_add(struct pwm_chip *chip)
307293
pwm->chip = chip;
308294
pwm->pwm = chip->base + i;
309295
pwm->hwpwm = i;
310-
311-
radix_tree_insert(&pwm_tree, pwm->pwm, pwm);
312296
}
313297

314298
list_add(&chip->list, &pwm_chips);
@@ -369,43 +353,6 @@ int devm_pwmchip_add(struct device *dev, struct pwm_chip *chip)
369353
}
370354
EXPORT_SYMBOL_GPL(devm_pwmchip_add);
371355

372-
/**
373-
* pwm_request() - request a PWM device
374-
* @pwm: global PWM device index
375-
* @label: PWM device label
376-
*
377-
* This function is deprecated, use pwm_get() instead.
378-
*
379-
* Returns: A pointer to a PWM device or an ERR_PTR()-encoded error code on
380-
* failure.
381-
*/
382-
struct pwm_device *pwm_request(int pwm, const char *label)
383-
{
384-
struct pwm_device *dev;
385-
int err;
386-
387-
if (pwm < 0 || pwm >= MAX_PWMS)
388-
return ERR_PTR(-EINVAL);
389-
390-
mutex_lock(&pwm_lock);
391-
392-
dev = pwm_to_device(pwm);
393-
if (!dev) {
394-
dev = ERR_PTR(-EPROBE_DEFER);
395-
goto out;
396-
}
397-
398-
err = pwm_device_request(dev, label);
399-
if (err < 0)
400-
dev = ERR_PTR(err);
401-
402-
out:
403-
mutex_unlock(&pwm_lock);
404-
405-
return dev;
406-
}
407-
EXPORT_SYMBOL_GPL(pwm_request);
408-
409356
/**
410357
* pwm_request_from_chip() - request a PWM device relative to a PWM chip
411358
* @chip: PWM chip
@@ -438,18 +385,6 @@ struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
438385
}
439386
EXPORT_SYMBOL_GPL(pwm_request_from_chip);
440387

441-
/**
442-
* pwm_free() - free a PWM device
443-
* @pwm: PWM device
444-
*
445-
* This function is deprecated, use pwm_put() instead.
446-
*/
447-
void pwm_free(struct pwm_device *pwm)
448-
{
449-
pwm_put(pwm);
450-
}
451-
EXPORT_SYMBOL_GPL(pwm_free);
452-
453388
static void pwm_apply_state_debug(struct pwm_device *pwm,
454389
const struct pwm_state *state)
455390
{
@@ -790,7 +725,7 @@ static struct pwm_device *of_pwm_get(struct device *dev, struct device_node *np,
790725
dl = pwm_device_link_add(dev, pwm);
791726
if (IS_ERR(dl)) {
792727
/* of_xlate ended up calling pwm_request_from_chip() */
793-
pwm_free(pwm);
728+
pwm_put(pwm);
794729
pwm = ERR_CAST(dl);
795730
goto put;
796731
}
@@ -1014,7 +949,7 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
1014949

1015950
dl = pwm_device_link_add(dev, pwm);
1016951
if (IS_ERR(dl)) {
1017-
pwm_free(pwm);
952+
pwm_put(pwm);
1018953
return ERR_CAST(dl);
1019954
}
1020955

0 commit comments

Comments
 (0)