Skip to content

Commit 4b4bb99

Browse files
committed
Merge tag 'pwm/for-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm
Pull pwm updates from Thierry Reding: "This contains a couple of fixes and cleanups for the Meson and ACPI/LPSS drivers as well as capture support for STM32. Note that given the cross- subsystem changes, the STM32 patches were merged through the MFD and PWM trees, both sharing an immutable branch" * tag 'pwm/for-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: pwm: stm32: Fix build warning with CONFIG_DMA_ENGINE disabled pwm: stm32: Enforce dependency on CONFIG_MFD_STM32_TIMERS ACPI / LPSS: Add missing prv_offset setting for byt/cht PWM devices pwm: lpss: platform: Save/restore the ctrl register over a suspend/resume dt-bindings: mfd: stm32-timers: Add support for dmas pwm: simplify getting .drvdata pwm: meson: Fix allocation of PWM channel array
2 parents 9bca19a + 414c52b commit 4b4bb99

File tree

10 files changed

+66
-12
lines changed

10 files changed

+66
-12
lines changed

Documentation/devicetree/bindings/mfd/stm32-timers.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ Required parameters:
1919
Optional parameters:
2020
- resets: Phandle to the parent reset controller.
2121
See ../reset/st,stm32-rcc.txt
22+
- dmas: List of phandle to dma channels that can be used for
23+
this timer instance. There may be up to 7 dma channels.
24+
- dma-names: List of dma names. Must match 'dmas' property. Valid
25+
names are: "ch1", "ch2", "ch3", "ch4", "up", "trig",
26+
"com".
2227

2328
Optional subnodes:
2429
- pwm: See ../pwm/pwm-stm32.txt
@@ -44,3 +49,18 @@ Example:
4449
reg = <0>;
4550
};
4651
};
52+
53+
Example with all dmas:
54+
timer@40010000 {
55+
...
56+
dmas = <&dmamux1 11 0x400 0x0>,
57+
<&dmamux1 12 0x400 0x0>,
58+
<&dmamux1 13 0x400 0x0>,
59+
<&dmamux1 14 0x400 0x0>,
60+
<&dmamux1 15 0x400 0x0>,
61+
<&dmamux1 16 0x400 0x0>,
62+
<&dmamux1 17 0x400 0x0>;
63+
dma-names = "ch1", "ch2", "ch3", "ch4", "up", "trig", "com";
64+
...
65+
child nodes...
66+
};

drivers/acpi/acpi_lpss.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,13 @@ static const struct lpss_device_desc lpt_sdio_dev_desc = {
233233

234234
static const struct lpss_device_desc byt_pwm_dev_desc = {
235235
.flags = LPSS_SAVE_CTX,
236+
.prv_offset = 0x800,
236237
.setup = byt_pwm_setup,
237238
};
238239

239240
static const struct lpss_device_desc bsw_pwm_dev_desc = {
240241
.flags = LPSS_SAVE_CTX | LPSS_NO_D3_DELAY,
242+
.prv_offset = 0x800,
241243
.setup = bsw_pwm_setup,
242244
};
243245

drivers/pwm/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ config PWM_STI
401401

402402
config PWM_STM32
403403
tristate "STMicroelectronics STM32 PWM"
404-
depends on MFD_STM32_TIMERS || COMPILE_TEST
404+
depends on MFD_STM32_TIMERS
405405
help
406406
Generic PWM framework driver for STM32 SoCs.
407407

drivers/pwm/pwm-atmel-tcb.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,7 @@ MODULE_DEVICE_TABLE(of, atmel_tcb_pwm_dt_ids);
460460
#ifdef CONFIG_PM_SLEEP
461461
static int atmel_tcb_pwm_suspend(struct device *dev)
462462
{
463-
struct platform_device *pdev = to_platform_device(dev);
464-
struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
463+
struct atmel_tcb_pwm_chip *tcbpwm = dev_get_drvdata(dev);
465464
void __iomem *base = tcbpwm->tc->regs;
466465
int i;
467466

@@ -478,8 +477,7 @@ static int atmel_tcb_pwm_suspend(struct device *dev)
478477

479478
static int atmel_tcb_pwm_resume(struct device *dev)
480479
{
481-
struct platform_device *pdev = to_platform_device(dev);
482-
struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
480+
struct atmel_tcb_pwm_chip *tcbpwm = dev_get_drvdata(dev);
483481
void __iomem *base = tcbpwm->tc->regs;
484482
int i;
485483

drivers/pwm/pwm-lpss-platform.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ static int pwm_lpss_remove_platform(struct platform_device *pdev)
7474
return pwm_lpss_remove(lpwm);
7575
}
7676

77+
static SIMPLE_DEV_PM_OPS(pwm_lpss_platform_pm_ops,
78+
pwm_lpss_suspend,
79+
pwm_lpss_resume);
80+
7781
static const struct acpi_device_id pwm_lpss_acpi_match[] = {
7882
{ "80860F09", (unsigned long)&pwm_lpss_byt_info },
7983
{ "80862288", (unsigned long)&pwm_lpss_bsw_info },
@@ -86,6 +90,7 @@ static struct platform_driver pwm_lpss_driver_platform = {
8690
.driver = {
8791
.name = "pwm-lpss",
8892
.acpi_match_table = pwm_lpss_acpi_match,
93+
.pm = &pwm_lpss_platform_pm_ops,
8994
},
9095
.probe = pwm_lpss_probe_platform,
9196
.remove = pwm_lpss_remove_platform,

drivers/pwm/pwm-lpss.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@
3232
/* Size of each PWM register space if multiple */
3333
#define PWM_SIZE 0x400
3434

35+
#define MAX_PWMS 4
36+
3537
struct pwm_lpss_chip {
3638
struct pwm_chip chip;
3739
void __iomem *regs;
3840
const struct pwm_lpss_boardinfo *info;
41+
u32 saved_ctrl[MAX_PWMS];
3942
};
4043

4144
static inline struct pwm_lpss_chip *to_lpwm(struct pwm_chip *chip)
@@ -177,6 +180,9 @@ struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
177180
unsigned long c;
178181
int ret;
179182

183+
if (WARN_ON(info->npwm > MAX_PWMS))
184+
return ERR_PTR(-ENODEV);
185+
180186
lpwm = devm_kzalloc(dev, sizeof(*lpwm), GFP_KERNEL);
181187
if (!lpwm)
182188
return ERR_PTR(-ENOMEM);
@@ -212,6 +218,30 @@ int pwm_lpss_remove(struct pwm_lpss_chip *lpwm)
212218
}
213219
EXPORT_SYMBOL_GPL(pwm_lpss_remove);
214220

221+
int pwm_lpss_suspend(struct device *dev)
222+
{
223+
struct pwm_lpss_chip *lpwm = dev_get_drvdata(dev);
224+
int i;
225+
226+
for (i = 0; i < lpwm->info->npwm; i++)
227+
lpwm->saved_ctrl[i] = readl(lpwm->regs + i * PWM_SIZE + PWM);
228+
229+
return 0;
230+
}
231+
EXPORT_SYMBOL_GPL(pwm_lpss_suspend);
232+
233+
int pwm_lpss_resume(struct device *dev)
234+
{
235+
struct pwm_lpss_chip *lpwm = dev_get_drvdata(dev);
236+
int i;
237+
238+
for (i = 0; i < lpwm->info->npwm; i++)
239+
writel(lpwm->saved_ctrl[i], lpwm->regs + i * PWM_SIZE + PWM);
240+
241+
return 0;
242+
}
243+
EXPORT_SYMBOL_GPL(pwm_lpss_resume);
244+
215245
MODULE_DESCRIPTION("PWM driver for Intel LPSS");
216246
MODULE_AUTHOR("Mika Westerberg <[email protected]>");
217247
MODULE_LICENSE("GPL v2");

drivers/pwm/pwm-lpss.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ struct pwm_lpss_boardinfo {
2828
struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
2929
const struct pwm_lpss_boardinfo *info);
3030
int pwm_lpss_remove(struct pwm_lpss_chip *lpwm);
31+
int pwm_lpss_suspend(struct device *dev);
32+
int pwm_lpss_resume(struct device *dev);
3133

3234
#endif /* __PWM_LPSS_H */

drivers/pwm/pwm-meson.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ static int meson_pwm_probe(struct platform_device *pdev)
541541
meson->data = of_device_get_match_data(&pdev->dev);
542542
meson->inverter_mask = BIT(meson->chip.npwm) - 1;
543543

544-
channels = devm_kcalloc(&pdev->dev, meson->chip.npwm, sizeof(*meson),
545-
GFP_KERNEL);
544+
channels = devm_kcalloc(&pdev->dev, meson->chip.npwm,
545+
sizeof(*channels), GFP_KERNEL);
546546
if (!channels)
547547
return -ENOMEM;
548548

drivers/pwm/pwm-rcar.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ MODULE_DEVICE_TABLE(of, rcar_pwm_of_table);
261261
#ifdef CONFIG_PM_SLEEP
262262
static struct pwm_device *rcar_pwm_dev_to_pwm_dev(struct device *dev)
263263
{
264-
struct platform_device *pdev = to_platform_device(dev);
265-
struct rcar_pwm_chip *rcar_pwm = platform_get_drvdata(pdev);
264+
struct rcar_pwm_chip *rcar_pwm = dev_get_drvdata(dev);
266265
struct pwm_chip *chip = &rcar_pwm->chip;
267266

268267
return &chip->pwms[0];

drivers/pwm/pwm-stm32.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,7 @@ static int stm32_pwm_apply_locked(struct pwm_chip *chip, struct pwm_device *pwm,
484484
static const struct pwm_ops stm32pwm_ops = {
485485
.owner = THIS_MODULE,
486486
.apply = stm32_pwm_apply_locked,
487-
#if IS_ENABLED(CONFIG_DMA_ENGINE)
488-
.capture = stm32_pwm_capture,
489-
#endif
487+
.capture = IS_ENABLED(CONFIG_DMA_ENGINE) ? stm32_pwm_capture : NULL,
490488
};
491489

492490
static int stm32_pwm_set_breakinput(struct stm32_pwm *priv,

0 commit comments

Comments
 (0)