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

Merge tag 'pwm/for-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm

Pull pwm updates from Thierry Reding:
"This set is mostly small fixes and cleanups, so more of a janitorial
update for this cycle"

* tag 'pwm/for-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm:
pwm: vt8500: Rename pwm_busy_wait() to make it obviously driver-specific
dt-bindings: pwm: tpu: Add R-Car M3-W+ device tree bindings
dt-bindings: pwm: tpu: Add R-Car V3U device tree bindings
pwm: pwm-samsung: Trigger manual update when disabling PWM
pwm: visconti: Simplify using devm_pwmchip_add()
pwm: samsung: Describe driver in Kconfig
pwm: Make it explicit that pwm_apply_state() might sleep
pwm: Add might_sleep() annotations for !CONFIG_PWM API functions
pwm: atmel: Drop unused header

+58 -31
+2
Documentation/devicetree/bindings/pwm/renesas,tpu-pwm.yaml
··· 35 35 - renesas,tpu-r8a7794 # R-Car E2 36 36 - renesas,tpu-r8a7795 # R-Car H3 37 37 - renesas,tpu-r8a7796 # R-Car M3-W 38 + - renesas,tpu-r8a77961 # R-Car M3-W+ 38 39 - renesas,tpu-r8a77965 # R-Car M3-N 39 40 - renesas,tpu-r8a77970 # R-Car V3M 40 41 - renesas,tpu-r8a77980 # R-Car V3H 42 + - renesas,tpu-r8a779a0 # R-Car V3U 41 43 - const: renesas,tpu 42 44 43 45 reg:
+3 -1
drivers/pwm/Kconfig
··· 476 476 depends on PLAT_SAMSUNG || ARCH_S5PV210 || ARCH_EXYNOS || COMPILE_TEST 477 477 depends on HAS_IOMEM 478 478 help 479 - Generic PWM framework driver for Samsung. 479 + Generic PWM framework driver for Samsung S3C24xx, S3C64xx, S5Pv210 480 + and Exynos SoCs. 481 + Choose Y here only if you build for such Samsung SoC. 480 482 481 483 To compile this driver as a module, choose M here: the module 482 484 will be called pwm-samsung.
+9
drivers/pwm/core.c
··· 532 532 struct pwm_chip *chip; 533 533 int err; 534 534 535 + /* 536 + * Some lowlevel driver's implementations of .apply() make use of 537 + * mutexes, also with some drivers only returning when the new 538 + * configuration is active calling pwm_apply_state() from atomic context 539 + * is a bad idea. So make it explicit that calling this function might 540 + * sleep. 541 + */ 542 + might_sleep(); 543 + 535 544 if (!pwm || !state || !state->period || 536 545 state->duty_cycle > state->period) 537 546 return -EINVAL;
-1
drivers/pwm/pwm-atmel.c
··· 24 24 #include <linux/err.h> 25 25 #include <linux/io.h> 26 26 #include <linux/module.h> 27 - #include <linux/mutex.h> 28 27 #include <linux/of.h> 29 28 #include <linux/of_device.h> 30 29 #include <linux/platform_device.h>
+22 -8
drivers/pwm/pwm-samsung.c
··· 117 117 return (channel == 0) ? 0 : (channel + 1); 118 118 } 119 119 120 + static void __pwm_samsung_manual_update(struct samsung_pwm_chip *chip, 121 + struct pwm_device *pwm) 122 + { 123 + unsigned int tcon_chan = to_tcon_channel(pwm->hwpwm); 124 + u32 tcon; 125 + 126 + tcon = readl(chip->base + REG_TCON); 127 + tcon |= TCON_MANUALUPDATE(tcon_chan); 128 + writel(tcon, chip->base + REG_TCON); 129 + 130 + tcon &= ~TCON_MANUALUPDATE(tcon_chan); 131 + writel(tcon, chip->base + REG_TCON); 132 + } 133 + 120 134 static void pwm_samsung_set_divisor(struct samsung_pwm_chip *pwm, 121 135 unsigned int channel, u8 divisor) 122 136 { ··· 290 276 tcon &= ~TCON_AUTORELOAD(tcon_chan); 291 277 writel(tcon, our_chip->base + REG_TCON); 292 278 279 + /* 280 + * In case the PWM is at 100% duty cycle, force a manual 281 + * update to prevent the signal from staying high. 282 + */ 283 + if (readl(our_chip->base + REG_TCMPB(pwm->hwpwm)) == (u32)-1U) 284 + __pwm_samsung_manual_update(our_chip, pwm); 285 + 293 286 our_chip->disabled_mask |= BIT(pwm->hwpwm); 294 287 295 288 spin_unlock_irqrestore(&samsung_pwm_lock, flags); ··· 305 284 static void pwm_samsung_manual_update(struct samsung_pwm_chip *chip, 306 285 struct pwm_device *pwm) 307 286 { 308 - unsigned int tcon_chan = to_tcon_channel(pwm->hwpwm); 309 - u32 tcon; 310 287 unsigned long flags; 311 288 312 289 spin_lock_irqsave(&samsung_pwm_lock, flags); 313 290 314 - tcon = readl(chip->base + REG_TCON); 315 - tcon |= TCON_MANUALUPDATE(tcon_chan); 316 - writel(tcon, chip->base + REG_TCON); 317 - 318 - tcon &= ~TCON_MANUALUPDATE(tcon_chan); 319 - writel(tcon, chip->base + REG_TCON); 291 + __pwm_samsung_manual_update(chip, pwm); 320 292 321 293 spin_unlock_irqrestore(&samsung_pwm_lock, flags); 322 294 }
+1 -13
drivers/pwm/pwm-visconti.c
··· 144 144 if (IS_ERR(priv->base)) 145 145 return PTR_ERR(priv->base); 146 146 147 - platform_set_drvdata(pdev, priv); 148 - 149 147 priv->chip.dev = dev; 150 148 priv->chip.ops = &visconti_pwm_ops; 151 149 priv->chip.npwm = 4; 152 150 153 - ret = pwmchip_add(&priv->chip); 151 + ret = devm_pwmchip_add(&pdev->dev, &priv->chip); 154 152 if (ret < 0) 155 153 return dev_err_probe(&pdev->dev, ret, "Cannot register visconti PWM\n"); 156 - 157 - return 0; 158 - } 159 - 160 - static int visconti_pwm_remove(struct platform_device *pdev) 161 - { 162 - struct visconti_pwm_chip *priv = platform_get_drvdata(pdev); 163 - 164 - pwmchip_remove(&priv->chip); 165 154 166 155 return 0; 167 156 } ··· 167 178 .of_match_table = visconti_pwm_of_match, 168 179 }, 169 180 .probe = visconti_pwm_probe, 170 - .remove = visconti_pwm_remove, 171 181 }; 172 182 module_platform_driver(visconti_pwm_driver); 173 183
+8 -8
drivers/pwm/pwm-vt8500.c
··· 56 56 #define to_vt8500_chip(chip) container_of(chip, struct vt8500_chip, chip) 57 57 58 58 #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t) 59 - static inline void pwm_busy_wait(struct vt8500_chip *vt8500, int nr, u8 bitmask) 59 + static inline void vt8500_pwm_busy_wait(struct vt8500_chip *vt8500, int nr, u8 bitmask) 60 60 { 61 61 int loops = msecs_to_loops(10); 62 62 u32 mask = bitmask << (nr << 8); ··· 106 106 dc = c; 107 107 108 108 writel(prescale, vt8500->base + REG_SCALAR(pwm->hwpwm)); 109 - pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_SCALAR_UPDATE); 109 + vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_SCALAR_UPDATE); 110 110 111 111 writel(pv, vt8500->base + REG_PERIOD(pwm->hwpwm)); 112 - pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_PERIOD_UPDATE); 112 + vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_PERIOD_UPDATE); 113 113 114 114 writel(dc, vt8500->base + REG_DUTY(pwm->hwpwm)); 115 - pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_DUTY_UPDATE); 115 + vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_DUTY_UPDATE); 116 116 117 117 val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); 118 118 val |= CTRL_AUTOLOAD; 119 119 writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); 120 - pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); 120 + vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); 121 121 122 122 clk_disable(vt8500->clk); 123 123 return 0; ··· 138 138 val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); 139 139 val |= CTRL_ENABLE; 140 140 writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); 141 - pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); 141 + vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); 142 142 143 143 return 0; 144 144 } ··· 151 151 val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); 152 152 val &= ~CTRL_ENABLE; 153 153 writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); 154 - pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); 154 + vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); 155 155 156 156 clk_disable(vt8500->clk); 157 157 } ··· 171 171 val &= ~CTRL_INVERT; 172 172 173 173 writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); 174 - pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); 174 + vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); 175 175 176 176 return 0; 177 177 }
+13
include/linux/pwm.h
··· 429 429 #else 430 430 static inline struct pwm_device *pwm_request(int pwm_id, const char *label) 431 431 { 432 + might_sleep(); 432 433 return ERR_PTR(-ENODEV); 433 434 } 434 435 435 436 static inline void pwm_free(struct pwm_device *pwm) 436 437 { 438 + might_sleep(); 437 439 } 438 440 439 441 static inline int pwm_apply_state(struct pwm_device *pwm, 440 442 const struct pwm_state *state) 441 443 { 444 + might_sleep(); 442 445 return -ENOTSUPP; 443 446 } 444 447 ··· 453 450 static inline int pwm_config(struct pwm_device *pwm, int duty_ns, 454 451 int period_ns) 455 452 { 453 + might_sleep(); 456 454 return -EINVAL; 457 455 } 458 456 ··· 466 462 467 463 static inline int pwm_enable(struct pwm_device *pwm) 468 464 { 465 + might_sleep(); 469 466 return -EINVAL; 470 467 } 471 468 472 469 static inline void pwm_disable(struct pwm_device *pwm) 473 470 { 471 + might_sleep(); 474 472 } 475 473 476 474 static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data) ··· 499 493 unsigned int index, 500 494 const char *label) 501 495 { 496 + might_sleep(); 502 497 return ERR_PTR(-ENODEV); 503 498 } 504 499 505 500 static inline struct pwm_device *pwm_get(struct device *dev, 506 501 const char *consumer) 507 502 { 503 + might_sleep(); 508 504 return ERR_PTR(-ENODEV); 509 505 } 510 506 ··· 514 506 struct device_node *np, 515 507 const char *con_id) 516 508 { 509 + might_sleep(); 517 510 return ERR_PTR(-ENODEV); 518 511 } 519 512 520 513 static inline void pwm_put(struct pwm_device *pwm) 521 514 { 515 + might_sleep(); 522 516 } 523 517 524 518 static inline struct pwm_device *devm_pwm_get(struct device *dev, 525 519 const char *consumer) 526 520 { 521 + might_sleep(); 527 522 return ERR_PTR(-ENODEV); 528 523 } 529 524 ··· 534 523 struct device_node *np, 535 524 const char *con_id) 536 525 { 526 + might_sleep(); 537 527 return ERR_PTR(-ENODEV); 538 528 } 539 529 ··· 542 530 devm_fwnode_pwm_get(struct device *dev, struct fwnode_handle *fwnode, 543 531 const char *con_id) 544 532 { 533 + might_sleep(); 545 534 return ERR_PTR(-ENODEV); 546 535 } 547 536 #endif