Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+66 -12
+20
Documentation/devicetree/bindings/mfd/stm32-timers.txt
··· 19 19 Optional parameters: 20 20 - resets: Phandle to the parent reset controller. 21 21 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". 22 27 23 28 Optional subnodes: 24 29 - pwm: See ../pwm/pwm-stm32.txt ··· 48 43 compatible = "st,stm32-timer-trigger"; 49 44 reg = <0>; 50 45 }; 46 + }; 47 + 48 + Example with all dmas: 49 + timer@40010000 { 50 + ... 51 + dmas = <&dmamux1 11 0x400 0x0>, 52 + <&dmamux1 12 0x400 0x0>, 53 + <&dmamux1 13 0x400 0x0>, 54 + <&dmamux1 14 0x400 0x0>, 55 + <&dmamux1 15 0x400 0x0>, 56 + <&dmamux1 16 0x400 0x0>, 57 + <&dmamux1 17 0x400 0x0>; 58 + dma-names = "ch1", "ch2", "ch3", "ch4", "up", "trig", "com"; 59 + ... 60 + child nodes... 51 61 };
+2
drivers/acpi/acpi_lpss.c
··· 233 233 234 234 static const struct lpss_device_desc byt_pwm_dev_desc = { 235 235 .flags = LPSS_SAVE_CTX, 236 + .prv_offset = 0x800, 236 237 .setup = byt_pwm_setup, 237 238 }; 238 239 239 240 static const struct lpss_device_desc bsw_pwm_dev_desc = { 240 241 .flags = LPSS_SAVE_CTX | LPSS_NO_D3_DELAY, 242 + .prv_offset = 0x800, 241 243 .setup = bsw_pwm_setup, 242 244 }; 243 245
+1 -1
drivers/pwm/Kconfig
··· 401 401 402 402 config PWM_STM32 403 403 tristate "STMicroelectronics STM32 PWM" 404 - depends on MFD_STM32_TIMERS || COMPILE_TEST 404 + depends on MFD_STM32_TIMERS 405 405 help 406 406 Generic PWM framework driver for STM32 SoCs. 407 407
+2 -4
drivers/pwm/pwm-atmel-tcb.c
··· 460 460 #ifdef CONFIG_PM_SLEEP 461 461 static int atmel_tcb_pwm_suspend(struct device *dev) 462 462 { 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); 465 464 void __iomem *base = tcbpwm->tc->regs; 466 465 int i; 467 466 ··· 477 478 478 479 static int atmel_tcb_pwm_resume(struct device *dev) 479 480 { 480 - struct platform_device *pdev = to_platform_device(dev); 481 - struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev); 481 + struct atmel_tcb_pwm_chip *tcbpwm = dev_get_drvdata(dev); 482 482 void __iomem *base = tcbpwm->tc->regs; 483 483 int i; 484 484
+5
drivers/pwm/pwm-lpss-platform.c
··· 74 74 return pwm_lpss_remove(lpwm); 75 75 } 76 76 77 + static SIMPLE_DEV_PM_OPS(pwm_lpss_platform_pm_ops, 78 + pwm_lpss_suspend, 79 + pwm_lpss_resume); 80 + 77 81 static const struct acpi_device_id pwm_lpss_acpi_match[] = { 78 82 { "80860F09", (unsigned long)&pwm_lpss_byt_info }, 79 83 { "80862288", (unsigned long)&pwm_lpss_bsw_info }, ··· 90 86 .driver = { 91 87 .name = "pwm-lpss", 92 88 .acpi_match_table = pwm_lpss_acpi_match, 89 + .pm = &pwm_lpss_platform_pm_ops, 93 90 }, 94 91 .probe = pwm_lpss_probe_platform, 95 92 .remove = pwm_lpss_remove_platform,
+30
drivers/pwm/pwm-lpss.c
··· 32 32 /* Size of each PWM register space if multiple */ 33 33 #define PWM_SIZE 0x400 34 34 35 + #define MAX_PWMS 4 36 + 35 37 struct pwm_lpss_chip { 36 38 struct pwm_chip chip; 37 39 void __iomem *regs; 38 40 const struct pwm_lpss_boardinfo *info; 41 + u32 saved_ctrl[MAX_PWMS]; 39 42 }; 40 43 41 44 static inline struct pwm_lpss_chip *to_lpwm(struct pwm_chip *chip) ··· 180 177 unsigned long c; 181 178 int ret; 182 179 180 + if (WARN_ON(info->npwm > MAX_PWMS)) 181 + return ERR_PTR(-ENODEV); 182 + 183 183 lpwm = devm_kzalloc(dev, sizeof(*lpwm), GFP_KERNEL); 184 184 if (!lpwm) 185 185 return ERR_PTR(-ENOMEM); ··· 217 211 return pwmchip_remove(&lpwm->chip); 218 212 } 219 213 EXPORT_SYMBOL_GPL(pwm_lpss_remove); 214 + 215 + int pwm_lpss_suspend(struct device *dev) 216 + { 217 + struct pwm_lpss_chip *lpwm = dev_get_drvdata(dev); 218 + int i; 219 + 220 + for (i = 0; i < lpwm->info->npwm; i++) 221 + lpwm->saved_ctrl[i] = readl(lpwm->regs + i * PWM_SIZE + PWM); 222 + 223 + return 0; 224 + } 225 + EXPORT_SYMBOL_GPL(pwm_lpss_suspend); 226 + 227 + int pwm_lpss_resume(struct device *dev) 228 + { 229 + struct pwm_lpss_chip *lpwm = dev_get_drvdata(dev); 230 + int i; 231 + 232 + for (i = 0; i < lpwm->info->npwm; i++) 233 + writel(lpwm->saved_ctrl[i], lpwm->regs + i * PWM_SIZE + PWM); 234 + 235 + return 0; 236 + } 237 + EXPORT_SYMBOL_GPL(pwm_lpss_resume); 220 238 221 239 MODULE_DESCRIPTION("PWM driver for Intel LPSS"); 222 240 MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
+2
drivers/pwm/pwm-lpss.h
··· 28 28 struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r, 29 29 const struct pwm_lpss_boardinfo *info); 30 30 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); 31 33 32 34 #endif /* __PWM_LPSS_H */
+2 -2
drivers/pwm/pwm-meson.c
··· 541 541 meson->data = of_device_get_match_data(&pdev->dev); 542 542 meson->inverter_mask = BIT(meson->chip.npwm) - 1; 543 543 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); 546 546 if (!channels) 547 547 return -ENOMEM; 548 548
+1 -2
drivers/pwm/pwm-rcar.c
··· 261 261 #ifdef CONFIG_PM_SLEEP 262 262 static struct pwm_device *rcar_pwm_dev_to_pwm_dev(struct device *dev) 263 263 { 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); 266 265 struct pwm_chip *chip = &rcar_pwm->chip; 267 266 268 267 return &chip->pwms[0];
+1 -3
drivers/pwm/pwm-stm32.c
··· 484 484 static const struct pwm_ops stm32pwm_ops = { 485 485 .owner = THIS_MODULE, 486 486 .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, 490 488 }; 491 489 492 490 static int stm32_pwm_set_breakinput(struct stm32_pwm *priv,